@ibiz-template/vue3-components 0.7.41-alpha.16 → 0.7.41-alpha.17

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 (117) hide show
  1. package/dist/{index-U4v1OOOD.js → index-AOFxMmyX.js} +1 -1
  2. package/dist/{index-lFGFvnYE.js → index-swminiXb.js} +1 -1
  3. package/dist/index-t1aZ8OJE.js +11 -0
  4. package/dist/index.min.css +1 -1
  5. package/dist/index.system.min.js +1 -1
  6. package/dist/{wang-editor-_06OYPpu.js → wang-editor-Y8puaTx2.js} +1 -1
  7. package/dist/{xlsx-util-FNiwKrqm.js → xlsx-util-jYyM8alm.js} +1 -1
  8. package/es/control/calendar/components/custom-calendar/custom-calendar.css +1 -1
  9. package/es/control/calendar/components/custom-calendar/custom-calendar.mjs +25 -8
  10. package/es/control/calendar/components/custom-calendar/use-custom-calendar.d.ts +8 -0
  11. package/es/control/calendar/components/custom-calendar/use-custom-calendar.mjs +20 -1
  12. package/es/control/data-view/data-view.css +1 -1
  13. package/es/control/data-view/data-view.mjs +95 -29
  14. package/es/control/drbar/drbar.css +1 -1
  15. package/es/control/drtab/drtab-control.util.mjs +1 -1
  16. package/es/control/drtab/drtab.controller.d.ts +24 -0
  17. package/es/control/drtab/drtab.controller.mjs +34 -0
  18. package/es/control/drtab/drtab.css +1 -1
  19. package/es/control/drtab/drtab.d.ts +2 -0
  20. package/es/control/drtab/drtab.mjs +5 -2
  21. package/es/control/drtab/flow-drtab.css +1 -1
  22. package/es/control/drtab/flow-drtab.d.ts +17 -2
  23. package/es/control/drtab/flow-drtab.mjs +189 -11
  24. package/es/control/drtab/index.d.ts +2 -0
  25. package/es/control/form/form-detail/form-mdctrl/form-mdctrl-repeater/repeater-grid/repeater-grid.css +1 -1
  26. package/es/control/form/form-detail/form-mdctrl/form-mdctrl-repeater/repeater-grid/repeater-grid.mjs +55 -4
  27. package/es/control/form/form-detail/form-mdctrl/mdctrl-container/mdctrl-container.css +1 -1
  28. package/es/control/form/form-detail/form-mdctrl/mdctrl-container/mdctrl-container.mjs +11 -11
  29. package/es/control/gantt/gantt.mjs +1 -0
  30. package/es/control/grid/grid/grid-control.util.mjs +36 -14
  31. package/es/control/grid/grid/grid.css +1 -1
  32. package/es/control/grid/grid/grid.mjs +8 -3
  33. package/es/control/kanban/index.d.ts +4 -1
  34. package/es/control/kanban/kanban.css +1 -1
  35. package/es/control/kanban/kanban.d.ts +4 -1
  36. package/es/control/kanban/kanban.mjs +51 -15
  37. package/es/control/kanban/swimlane-kanban/swimlane-kanban.css +1 -1
  38. package/es/control/kanban/swimlane-kanban/swimlane-kanban.d.ts +2 -1
  39. package/es/control/kanban/swimlane-kanban/swimlane-kanban.mjs +52 -6
  40. package/es/control/list/list.css +1 -1
  41. package/es/control/list/list.d.ts +1 -1
  42. package/es/control/list/list.mjs +83 -11
  43. package/es/control/medit-view-panel/medit-view-panel.css +1 -1
  44. package/es/control/medit-view-panel/medit-view-panel.mjs +37 -30
  45. package/es/editor/data-picker/ibiz-mpicker/ibiz-mpicker.d.ts +1 -1
  46. package/es/editor/data-picker/ibiz-mpicker/ibiz-mpicker.mjs +47 -8
  47. package/es/editor/upload/ibiz-file-upload/ibiz-file-upload.d.ts +1 -0
  48. package/es/editor/upload/ibiz-image-cropping/ibiz-image-cropping.d.ts +1 -0
  49. package/es/editor/upload/ibiz-image-upload/ibiz-image-upload.d.ts +1 -0
  50. package/es/editor/upload/upload-editor.controller.d.ts +25 -0
  51. package/es/editor/upload/upload-editor.controller.mjs +43 -1
  52. package/es/editor/upload/use/use-iview-upload.mjs +9 -2
  53. package/es/locale/en/index.d.ts +9 -5
  54. package/es/locale/en/index.mjs +5 -2
  55. package/es/locale/zh-CN/index.d.ts +9 -5
  56. package/es/locale/zh-CN/index.mjs +5 -2
  57. package/es/node_modules/.pnpm/sortablejs@1.15.6/node_modules/sortablejs/modular/sortable.esm.mjs +3377 -0
  58. package/es/panel-component/panel-button/panel-button.mjs +1 -0
  59. package/es/util/fullscreen/fullscreen-util.mjs +1 -1
  60. package/es/view-engine/calendar-view.engine.d.ts +11 -1
  61. package/es/view-engine/calendar-view.engine.mjs +10 -0
  62. package/es/view-engine/chart-exp-view.engine.d.ts +6 -6
  63. package/es/view-engine/chart-exp-view.engine.mjs +6 -15
  64. package/es/view-engine/gantt-view.engine.d.ts +3 -3
  65. package/es/view-engine/gantt-view.engine.mjs +3 -46
  66. package/es/view-engine/login-view.engine.mjs +7 -0
  67. package/es/view-engine/tab-exp-view.engine.mjs +1 -1
  68. package/es/view-engine/tab-search-view.engine.mjs +4 -2
  69. package/es/view-engine/tree-view.engine.d.ts +12 -2
  70. package/es/view-engine/tree-view.engine.mjs +39 -11
  71. package/lib/control/calendar/components/custom-calendar/custom-calendar.cjs +23 -6
  72. package/lib/control/calendar/components/custom-calendar/custom-calendar.css +1 -1
  73. package/lib/control/calendar/components/custom-calendar/use-custom-calendar.cjs +20 -0
  74. package/lib/control/data-view/data-view.cjs +95 -29
  75. package/lib/control/data-view/data-view.css +1 -1
  76. package/lib/control/drbar/drbar.css +1 -1
  77. package/lib/control/drtab/drtab-control.util.cjs +1 -1
  78. package/lib/control/drtab/drtab.cjs +5 -2
  79. package/lib/control/drtab/drtab.controller.cjs +34 -0
  80. package/lib/control/drtab/drtab.css +1 -1
  81. package/lib/control/drtab/flow-drtab.cjs +188 -10
  82. package/lib/control/drtab/flow-drtab.css +1 -1
  83. package/lib/control/form/form-detail/form-mdctrl/form-mdctrl-repeater/repeater-grid/repeater-grid.cjs +54 -3
  84. package/lib/control/form/form-detail/form-mdctrl/form-mdctrl-repeater/repeater-grid/repeater-grid.css +1 -1
  85. package/lib/control/form/form-detail/form-mdctrl/mdctrl-container/mdctrl-container.cjs +11 -11
  86. package/lib/control/form/form-detail/form-mdctrl/mdctrl-container/mdctrl-container.css +1 -1
  87. package/lib/control/gantt/gantt.cjs +1 -0
  88. package/lib/control/grid/grid/grid-control.util.cjs +36 -14
  89. package/lib/control/grid/grid/grid.cjs +8 -3
  90. package/lib/control/grid/grid/grid.css +1 -1
  91. package/lib/control/kanban/kanban.cjs +50 -14
  92. package/lib/control/kanban/kanban.css +1 -1
  93. package/lib/control/kanban/swimlane-kanban/swimlane-kanban.cjs +50 -4
  94. package/lib/control/kanban/swimlane-kanban/swimlane-kanban.css +1 -1
  95. package/lib/control/list/list.cjs +83 -11
  96. package/lib/control/list/list.css +1 -1
  97. package/lib/control/medit-view-panel/medit-view-panel.cjs +36 -29
  98. package/lib/control/medit-view-panel/medit-view-panel.css +1 -1
  99. package/lib/editor/data-picker/ibiz-mpicker/ibiz-mpicker.cjs +47 -8
  100. package/lib/editor/upload/upload-editor.controller.cjs +43 -1
  101. package/lib/editor/upload/use/use-iview-upload.cjs +9 -2
  102. package/lib/locale/en/index.cjs +5 -2
  103. package/lib/locale/zh-CN/index.cjs +5 -2
  104. package/lib/node_modules/.pnpm/sortablejs@1.15.6/node_modules/sortablejs/modular/sortable.esm.cjs +3384 -0
  105. package/lib/panel-component/panel-button/panel-button.cjs +1 -0
  106. package/lib/util/fullscreen/fullscreen-util.cjs +1 -1
  107. package/lib/view-engine/calendar-view.engine.cjs +10 -0
  108. package/lib/view-engine/chart-exp-view.engine.cjs +6 -15
  109. package/lib/view-engine/gantt-view.engine.cjs +2 -45
  110. package/lib/view-engine/login-view.engine.cjs +7 -0
  111. package/lib/view-engine/tab-exp-view.engine.cjs +1 -1
  112. package/lib/view-engine/tab-search-view.engine.cjs +4 -2
  113. package/lib/view-engine/tree-view.engine.cjs +39 -11
  114. package/package.json +9 -7
  115. package/dist/index-m8q8r8br.js +0 -4
  116. /package/es/node_modules/.pnpm/{@ibiz-template_core@0.7.41-alpha.14_axios@1.6.8_lodash-es@4.17.21_qs@6.11.2_qx-util@0.4.8_ramda@0.29.1 → @ibiz-template_core@0.7.41-alpha.17_axios@1.6.8_lodash-es@4.17.21_qs@6.11.2_qx-util@0.4.8_ramda@0.29.1}/node_modules/@ibiz-template/core/out/utils/namespace/namespace.mjs +0 -0
  117. /package/lib/node_modules/.pnpm/{@ibiz-template_core@0.7.41-alpha.14_axios@1.6.8_lodash-es@4.17.21_qs@6.11.2_qx-util@0.4.8_ramda@0.29.1 → @ibiz-template_core@0.7.41-alpha.17_axios@1.6.8_lodash-es@4.17.21_qs@6.11.2_qx-util@0.4.8_ramda@0.29.1}/node_modules/@ibiz-template/core/out/utils/namespace/namespace.cjs +0 -0
@@ -0,0 +1,3384 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ /**!
6
+ * Sortable 1.15.6
7
+ * @author RubaXa <trash@rubaxa.org>
8
+ * @author owenm <owen23355@gmail.com>
9
+ * @license MIT
10
+ */
11
+ function ownKeys(object, enumerableOnly) {
12
+ var keys = Object.keys(object);
13
+ if (Object.getOwnPropertySymbols) {
14
+ var symbols = Object.getOwnPropertySymbols(object);
15
+ if (enumerableOnly) {
16
+ symbols = symbols.filter(function (sym) {
17
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
18
+ });
19
+ }
20
+ keys.push.apply(keys, symbols);
21
+ }
22
+ return keys;
23
+ }
24
+ function _objectSpread2(target) {
25
+ for (var i = 1; i < arguments.length; i++) {
26
+ var source = arguments[i] != null ? arguments[i] : {};
27
+ if (i % 2) {
28
+ ownKeys(Object(source), true).forEach(function (key) {
29
+ _defineProperty(target, key, source[key]);
30
+ });
31
+ } else if (Object.getOwnPropertyDescriptors) {
32
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
33
+ } else {
34
+ ownKeys(Object(source)).forEach(function (key) {
35
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
36
+ });
37
+ }
38
+ }
39
+ return target;
40
+ }
41
+ function _typeof(obj) {
42
+ "@babel/helpers - typeof";
43
+
44
+ if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
45
+ _typeof = function (obj) {
46
+ return typeof obj;
47
+ };
48
+ } else {
49
+ _typeof = function (obj) {
50
+ return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
51
+ };
52
+ }
53
+ return _typeof(obj);
54
+ }
55
+ function _defineProperty(obj, key, value) {
56
+ if (key in obj) {
57
+ Object.defineProperty(obj, key, {
58
+ value: value,
59
+ enumerable: true,
60
+ configurable: true,
61
+ writable: true
62
+ });
63
+ } else {
64
+ obj[key] = value;
65
+ }
66
+ return obj;
67
+ }
68
+ function _extends() {
69
+ _extends = Object.assign || function (target) {
70
+ for (var i = 1; i < arguments.length; i++) {
71
+ var source = arguments[i];
72
+ for (var key in source) {
73
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
74
+ target[key] = source[key];
75
+ }
76
+ }
77
+ }
78
+ return target;
79
+ };
80
+ return _extends.apply(this, arguments);
81
+ }
82
+ function _objectWithoutPropertiesLoose(source, excluded) {
83
+ if (source == null) return {};
84
+ var target = {};
85
+ var sourceKeys = Object.keys(source);
86
+ var key, i;
87
+ for (i = 0; i < sourceKeys.length; i++) {
88
+ key = sourceKeys[i];
89
+ if (excluded.indexOf(key) >= 0) continue;
90
+ target[key] = source[key];
91
+ }
92
+ return target;
93
+ }
94
+ function _objectWithoutProperties(source, excluded) {
95
+ if (source == null) return {};
96
+ var target = _objectWithoutPropertiesLoose(source, excluded);
97
+ var key, i;
98
+ if (Object.getOwnPropertySymbols) {
99
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
100
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
101
+ key = sourceSymbolKeys[i];
102
+ if (excluded.indexOf(key) >= 0) continue;
103
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
104
+ target[key] = source[key];
105
+ }
106
+ }
107
+ return target;
108
+ }
109
+ function _toConsumableArray(arr) {
110
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
111
+ }
112
+ function _arrayWithoutHoles(arr) {
113
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
114
+ }
115
+ function _iterableToArray(iter) {
116
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
117
+ }
118
+ function _unsupportedIterableToArray(o, minLen) {
119
+ if (!o) return;
120
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
121
+ var n = Object.prototype.toString.call(o).slice(8, -1);
122
+ if (n === "Object" && o.constructor) n = o.constructor.name;
123
+ if (n === "Map" || n === "Set") return Array.from(o);
124
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
125
+ }
126
+ function _arrayLikeToArray(arr, len) {
127
+ if (len == null || len > arr.length) len = arr.length;
128
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
129
+ return arr2;
130
+ }
131
+ function _nonIterableSpread() {
132
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
133
+ }
134
+
135
+ var version = "1.15.6";
136
+
137
+ function userAgent(pattern) {
138
+ if (typeof window !== 'undefined' && window.navigator) {
139
+ return !! /*@__PURE__*/navigator.userAgent.match(pattern);
140
+ }
141
+ }
142
+ var IE11OrLess = userAgent(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i);
143
+ var Edge = userAgent(/Edge/i);
144
+ var FireFox = userAgent(/firefox/i);
145
+ var Safari = userAgent(/safari/i) && !userAgent(/chrome/i) && !userAgent(/android/i);
146
+ var IOS = userAgent(/iP(ad|od|hone)/i);
147
+ var ChromeForAndroid = userAgent(/chrome/i) && userAgent(/android/i);
148
+
149
+ var captureMode = {
150
+ capture: false,
151
+ passive: false
152
+ };
153
+ function on(el, event, fn) {
154
+ el.addEventListener(event, fn, !IE11OrLess && captureMode);
155
+ }
156
+ function off(el, event, fn) {
157
+ el.removeEventListener(event, fn, !IE11OrLess && captureMode);
158
+ }
159
+ function matches( /**HTMLElement*/el, /**String*/selector) {
160
+ if (!selector) return;
161
+ selector[0] === '>' && (selector = selector.substring(1));
162
+ if (el) {
163
+ try {
164
+ if (el.matches) {
165
+ return el.matches(selector);
166
+ } else if (el.msMatchesSelector) {
167
+ return el.msMatchesSelector(selector);
168
+ } else if (el.webkitMatchesSelector) {
169
+ return el.webkitMatchesSelector(selector);
170
+ }
171
+ } catch (_) {
172
+ return false;
173
+ }
174
+ }
175
+ return false;
176
+ }
177
+ function getParentOrHost(el) {
178
+ return el.host && el !== document && el.host.nodeType ? el.host : el.parentNode;
179
+ }
180
+ function closest( /**HTMLElement*/el, /**String*/selector, /**HTMLElement*/ctx, includeCTX) {
181
+ if (el) {
182
+ ctx = ctx || document;
183
+ do {
184
+ if (selector != null && (selector[0] === '>' ? el.parentNode === ctx && matches(el, selector) : matches(el, selector)) || includeCTX && el === ctx) {
185
+ return el;
186
+ }
187
+ if (el === ctx) break;
188
+ /* jshint boss:true */
189
+ } while (el = getParentOrHost(el));
190
+ }
191
+ return null;
192
+ }
193
+ var R_SPACE = /\s+/g;
194
+ function toggleClass(el, name, state) {
195
+ if (el && name) {
196
+ if (el.classList) {
197
+ el.classList[state ? 'add' : 'remove'](name);
198
+ } else {
199
+ var className = (' ' + el.className + ' ').replace(R_SPACE, ' ').replace(' ' + name + ' ', ' ');
200
+ el.className = (className + (state ? ' ' + name : '')).replace(R_SPACE, ' ');
201
+ }
202
+ }
203
+ }
204
+ function css(el, prop, val) {
205
+ var style = el && el.style;
206
+ if (style) {
207
+ if (val === void 0) {
208
+ if (document.defaultView && document.defaultView.getComputedStyle) {
209
+ val = document.defaultView.getComputedStyle(el, '');
210
+ } else if (el.currentStyle) {
211
+ val = el.currentStyle;
212
+ }
213
+ return prop === void 0 ? val : val[prop];
214
+ } else {
215
+ if (!(prop in style) && prop.indexOf('webkit') === -1) {
216
+ prop = '-webkit-' + prop;
217
+ }
218
+ style[prop] = val + (typeof val === 'string' ? '' : 'px');
219
+ }
220
+ }
221
+ }
222
+ function matrix(el, selfOnly) {
223
+ var appliedTransforms = '';
224
+ if (typeof el === 'string') {
225
+ appliedTransforms = el;
226
+ } else {
227
+ do {
228
+ var transform = css(el, 'transform');
229
+ if (transform && transform !== 'none') {
230
+ appliedTransforms = transform + ' ' + appliedTransforms;
231
+ }
232
+ /* jshint boss:true */
233
+ } while (!selfOnly && (el = el.parentNode));
234
+ }
235
+ var matrixFn = window.DOMMatrix || window.WebKitCSSMatrix || window.CSSMatrix || window.MSCSSMatrix;
236
+ /*jshint -W056 */
237
+ return matrixFn && new matrixFn(appliedTransforms);
238
+ }
239
+ function find(ctx, tagName, iterator) {
240
+ if (ctx) {
241
+ var list = ctx.getElementsByTagName(tagName),
242
+ i = 0,
243
+ n = list.length;
244
+ if (iterator) {
245
+ for (; i < n; i++) {
246
+ iterator(list[i], i);
247
+ }
248
+ }
249
+ return list;
250
+ }
251
+ return [];
252
+ }
253
+ function getWindowScrollingElement() {
254
+ var scrollingElement = document.scrollingElement;
255
+ if (scrollingElement) {
256
+ return scrollingElement;
257
+ } else {
258
+ return document.documentElement;
259
+ }
260
+ }
261
+
262
+ /**
263
+ * Returns the "bounding client rect" of given element
264
+ * @param {HTMLElement} el The element whose boundingClientRect is wanted
265
+ * @param {[Boolean]} relativeToContainingBlock Whether the rect should be relative to the containing block of (including) the container
266
+ * @param {[Boolean]} relativeToNonStaticParent Whether the rect should be relative to the relative parent of (including) the contaienr
267
+ * @param {[Boolean]} undoScale Whether the container's scale() should be undone
268
+ * @param {[HTMLElement]} container The parent the element will be placed in
269
+ * @return {Object} The boundingClientRect of el, with specified adjustments
270
+ */
271
+ function getRect(el, relativeToContainingBlock, relativeToNonStaticParent, undoScale, container) {
272
+ if (!el.getBoundingClientRect && el !== window) return;
273
+ var elRect, top, left, bottom, right, height, width;
274
+ if (el !== window && el.parentNode && el !== getWindowScrollingElement()) {
275
+ elRect = el.getBoundingClientRect();
276
+ top = elRect.top;
277
+ left = elRect.left;
278
+ bottom = elRect.bottom;
279
+ right = elRect.right;
280
+ height = elRect.height;
281
+ width = elRect.width;
282
+ } else {
283
+ top = 0;
284
+ left = 0;
285
+ bottom = window.innerHeight;
286
+ right = window.innerWidth;
287
+ height = window.innerHeight;
288
+ width = window.innerWidth;
289
+ }
290
+ if ((relativeToContainingBlock || relativeToNonStaticParent) && el !== window) {
291
+ // Adjust for translate()
292
+ container = container || el.parentNode;
293
+
294
+ // solves #1123 (see: https://stackoverflow.com/a/37953806/6088312)
295
+ // Not needed on <= IE11
296
+ if (!IE11OrLess) {
297
+ do {
298
+ if (container && container.getBoundingClientRect && (css(container, 'transform') !== 'none' || relativeToNonStaticParent && css(container, 'position') !== 'static')) {
299
+ var containerRect = container.getBoundingClientRect();
300
+
301
+ // Set relative to edges of padding box of container
302
+ top -= containerRect.top + parseInt(css(container, 'border-top-width'));
303
+ left -= containerRect.left + parseInt(css(container, 'border-left-width'));
304
+ bottom = top + elRect.height;
305
+ right = left + elRect.width;
306
+ break;
307
+ }
308
+ /* jshint boss:true */
309
+ } while (container = container.parentNode);
310
+ }
311
+ }
312
+ if (undoScale && el !== window) {
313
+ // Adjust for scale()
314
+ var elMatrix = matrix(container || el),
315
+ scaleX = elMatrix && elMatrix.a,
316
+ scaleY = elMatrix && elMatrix.d;
317
+ if (elMatrix) {
318
+ top /= scaleY;
319
+ left /= scaleX;
320
+ width /= scaleX;
321
+ height /= scaleY;
322
+ bottom = top + height;
323
+ right = left + width;
324
+ }
325
+ }
326
+ return {
327
+ top: top,
328
+ left: left,
329
+ bottom: bottom,
330
+ right: right,
331
+ width: width,
332
+ height: height
333
+ };
334
+ }
335
+
336
+ /**
337
+ * Checks if a side of an element is scrolled past a side of its parents
338
+ * @param {HTMLElement} el The element who's side being scrolled out of view is in question
339
+ * @param {String} elSide Side of the element in question ('top', 'left', 'right', 'bottom')
340
+ * @param {String} parentSide Side of the parent in question ('top', 'left', 'right', 'bottom')
341
+ * @return {HTMLElement} The parent scroll element that the el's side is scrolled past, or null if there is no such element
342
+ */
343
+ function isScrolledPast(el, elSide, parentSide) {
344
+ var parent = getParentAutoScrollElement(el, true),
345
+ elSideVal = getRect(el)[elSide];
346
+
347
+ /* jshint boss:true */
348
+ while (parent) {
349
+ var parentSideVal = getRect(parent)[parentSide],
350
+ visible = void 0;
351
+ if (parentSide === 'top' || parentSide === 'left') {
352
+ visible = elSideVal >= parentSideVal;
353
+ } else {
354
+ visible = elSideVal <= parentSideVal;
355
+ }
356
+ if (!visible) return parent;
357
+ if (parent === getWindowScrollingElement()) break;
358
+ parent = getParentAutoScrollElement(parent, false);
359
+ }
360
+ return false;
361
+ }
362
+
363
+ /**
364
+ * Gets nth child of el, ignoring hidden children, sortable's elements (does not ignore clone if it's visible)
365
+ * and non-draggable elements
366
+ * @param {HTMLElement} el The parent element
367
+ * @param {Number} childNum The index of the child
368
+ * @param {Object} options Parent Sortable's options
369
+ * @return {HTMLElement} The child at index childNum, or null if not found
370
+ */
371
+ function getChild(el, childNum, options, includeDragEl) {
372
+ var currentChild = 0,
373
+ i = 0,
374
+ children = el.children;
375
+ while (i < children.length) {
376
+ if (children[i].style.display !== 'none' && children[i] !== Sortable.ghost && (includeDragEl || children[i] !== Sortable.dragged) && closest(children[i], options.draggable, el, false)) {
377
+ if (currentChild === childNum) {
378
+ return children[i];
379
+ }
380
+ currentChild++;
381
+ }
382
+ i++;
383
+ }
384
+ return null;
385
+ }
386
+
387
+ /**
388
+ * Gets the last child in the el, ignoring ghostEl or invisible elements (clones)
389
+ * @param {HTMLElement} el Parent element
390
+ * @param {selector} selector Any other elements that should be ignored
391
+ * @return {HTMLElement} The last child, ignoring ghostEl
392
+ */
393
+ function lastChild(el, selector) {
394
+ var last = el.lastElementChild;
395
+ while (last && (last === Sortable.ghost || css(last, 'display') === 'none' || selector && !matches(last, selector))) {
396
+ last = last.previousElementSibling;
397
+ }
398
+ return last || null;
399
+ }
400
+
401
+ /**
402
+ * Returns the index of an element within its parent for a selected set of
403
+ * elements
404
+ * @param {HTMLElement} el
405
+ * @param {selector} selector
406
+ * @return {number}
407
+ */
408
+ function index(el, selector) {
409
+ var index = 0;
410
+ if (!el || !el.parentNode) {
411
+ return -1;
412
+ }
413
+
414
+ /* jshint boss:true */
415
+ while (el = el.previousElementSibling) {
416
+ if (el.nodeName.toUpperCase() !== 'TEMPLATE' && el !== Sortable.clone && (!selector || matches(el, selector))) {
417
+ index++;
418
+ }
419
+ }
420
+ return index;
421
+ }
422
+
423
+ /**
424
+ * Returns the scroll offset of the given element, added with all the scroll offsets of parent elements.
425
+ * The value is returned in real pixels.
426
+ * @param {HTMLElement} el
427
+ * @return {Array} Offsets in the format of [left, top]
428
+ */
429
+ function getRelativeScrollOffset(el) {
430
+ var offsetLeft = 0,
431
+ offsetTop = 0,
432
+ winScroller = getWindowScrollingElement();
433
+ if (el) {
434
+ do {
435
+ var elMatrix = matrix(el),
436
+ scaleX = elMatrix.a,
437
+ scaleY = elMatrix.d;
438
+ offsetLeft += el.scrollLeft * scaleX;
439
+ offsetTop += el.scrollTop * scaleY;
440
+ } while (el !== winScroller && (el = el.parentNode));
441
+ }
442
+ return [offsetLeft, offsetTop];
443
+ }
444
+
445
+ /**
446
+ * Returns the index of the object within the given array
447
+ * @param {Array} arr Array that may or may not hold the object
448
+ * @param {Object} obj An object that has a key-value pair unique to and identical to a key-value pair in the object you want to find
449
+ * @return {Number} The index of the object in the array, or -1
450
+ */
451
+ function indexOfObject(arr, obj) {
452
+ for (var i in arr) {
453
+ if (!arr.hasOwnProperty(i)) continue;
454
+ for (var key in obj) {
455
+ if (obj.hasOwnProperty(key) && obj[key] === arr[i][key]) return Number(i);
456
+ }
457
+ }
458
+ return -1;
459
+ }
460
+ function getParentAutoScrollElement(el, includeSelf) {
461
+ // skip to window
462
+ if (!el || !el.getBoundingClientRect) return getWindowScrollingElement();
463
+ var elem = el;
464
+ var gotSelf = false;
465
+ do {
466
+ // we don't need to get elem css if it isn't even overflowing in the first place (performance)
467
+ if (elem.clientWidth < elem.scrollWidth || elem.clientHeight < elem.scrollHeight) {
468
+ var elemCSS = css(elem);
469
+ if (elem.clientWidth < elem.scrollWidth && (elemCSS.overflowX == 'auto' || elemCSS.overflowX == 'scroll') || elem.clientHeight < elem.scrollHeight && (elemCSS.overflowY == 'auto' || elemCSS.overflowY == 'scroll')) {
470
+ if (!elem.getBoundingClientRect || elem === document.body) return getWindowScrollingElement();
471
+ if (gotSelf || includeSelf) return elem;
472
+ gotSelf = true;
473
+ }
474
+ }
475
+ /* jshint boss:true */
476
+ } while (elem = elem.parentNode);
477
+ return getWindowScrollingElement();
478
+ }
479
+ function extend(dst, src) {
480
+ if (dst && src) {
481
+ for (var key in src) {
482
+ if (src.hasOwnProperty(key)) {
483
+ dst[key] = src[key];
484
+ }
485
+ }
486
+ }
487
+ return dst;
488
+ }
489
+ function isRectEqual(rect1, rect2) {
490
+ 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);
491
+ }
492
+ var _throttleTimeout;
493
+ function throttle(callback, ms) {
494
+ return function () {
495
+ if (!_throttleTimeout) {
496
+ var args = arguments,
497
+ _this = this;
498
+ if (args.length === 1) {
499
+ callback.call(_this, args[0]);
500
+ } else {
501
+ callback.apply(_this, args);
502
+ }
503
+ _throttleTimeout = setTimeout(function () {
504
+ _throttleTimeout = void 0;
505
+ }, ms);
506
+ }
507
+ };
508
+ }
509
+ function cancelThrottle() {
510
+ clearTimeout(_throttleTimeout);
511
+ _throttleTimeout = void 0;
512
+ }
513
+ function scrollBy(el, x, y) {
514
+ el.scrollLeft += x;
515
+ el.scrollTop += y;
516
+ }
517
+ function clone(el) {
518
+ var Polymer = window.Polymer;
519
+ var $ = window.jQuery || window.Zepto;
520
+ if (Polymer && Polymer.dom) {
521
+ return Polymer.dom(el).cloneNode(true);
522
+ } else if ($) {
523
+ return $(el).clone(true)[0];
524
+ } else {
525
+ return el.cloneNode(true);
526
+ }
527
+ }
528
+ function setRect(el, rect) {
529
+ css(el, 'position', 'absolute');
530
+ css(el, 'top', rect.top);
531
+ css(el, 'left', rect.left);
532
+ css(el, 'width', rect.width);
533
+ css(el, 'height', rect.height);
534
+ }
535
+ function unsetRect(el) {
536
+ css(el, 'position', '');
537
+ css(el, 'top', '');
538
+ css(el, 'left', '');
539
+ css(el, 'width', '');
540
+ css(el, 'height', '');
541
+ }
542
+ function getChildContainingRectFromElement(container, options, ghostEl) {
543
+ var rect = {};
544
+ Array.from(container.children).forEach(function (child) {
545
+ var _rect$left, _rect$top, _rect$right, _rect$bottom;
546
+ if (!closest(child, options.draggable, container, false) || child.animated || child === ghostEl) return;
547
+ var childRect = getRect(child);
548
+ rect.left = Math.min((_rect$left = rect.left) !== null && _rect$left !== void 0 ? _rect$left : Infinity, childRect.left);
549
+ rect.top = Math.min((_rect$top = rect.top) !== null && _rect$top !== void 0 ? _rect$top : Infinity, childRect.top);
550
+ rect.right = Math.max((_rect$right = rect.right) !== null && _rect$right !== void 0 ? _rect$right : -Infinity, childRect.right);
551
+ rect.bottom = Math.max((_rect$bottom = rect.bottom) !== null && _rect$bottom !== void 0 ? _rect$bottom : -Infinity, childRect.bottom);
552
+ });
553
+ rect.width = rect.right - rect.left;
554
+ rect.height = rect.bottom - rect.top;
555
+ rect.x = rect.left;
556
+ rect.y = rect.top;
557
+ return rect;
558
+ }
559
+ var expando = 'Sortable' + new Date().getTime();
560
+
561
+ function AnimationStateManager() {
562
+ var animationStates = [],
563
+ animationCallbackId;
564
+ return {
565
+ captureAnimationState: function captureAnimationState() {
566
+ animationStates = [];
567
+ if (!this.options.animation) return;
568
+ var children = [].slice.call(this.el.children);
569
+ children.forEach(function (child) {
570
+ if (css(child, 'display') === 'none' || child === Sortable.ghost) return;
571
+ animationStates.push({
572
+ target: child,
573
+ rect: getRect(child)
574
+ });
575
+ var fromRect = _objectSpread2({}, animationStates[animationStates.length - 1].rect);
576
+
577
+ // If animating: compensate for current animation
578
+ if (child.thisAnimationDuration) {
579
+ var childMatrix = matrix(child, true);
580
+ if (childMatrix) {
581
+ fromRect.top -= childMatrix.f;
582
+ fromRect.left -= childMatrix.e;
583
+ }
584
+ }
585
+ child.fromRect = fromRect;
586
+ });
587
+ },
588
+ addAnimationState: function addAnimationState(state) {
589
+ animationStates.push(state);
590
+ },
591
+ removeAnimationState: function removeAnimationState(target) {
592
+ animationStates.splice(indexOfObject(animationStates, {
593
+ target: target
594
+ }), 1);
595
+ },
596
+ animateAll: function animateAll(callback) {
597
+ var _this = this;
598
+ if (!this.options.animation) {
599
+ clearTimeout(animationCallbackId);
600
+ if (typeof callback === 'function') callback();
601
+ return;
602
+ }
603
+ var animating = false,
604
+ animationTime = 0;
605
+ animationStates.forEach(function (state) {
606
+ var time = 0,
607
+ target = state.target,
608
+ fromRect = target.fromRect,
609
+ toRect = getRect(target),
610
+ prevFromRect = target.prevFromRect,
611
+ prevToRect = target.prevToRect,
612
+ animatingRect = state.rect,
613
+ targetMatrix = matrix(target, true);
614
+ if (targetMatrix) {
615
+ // Compensate for current animation
616
+ toRect.top -= targetMatrix.f;
617
+ toRect.left -= targetMatrix.e;
618
+ }
619
+ target.toRect = toRect;
620
+ if (target.thisAnimationDuration) {
621
+ // Could also check if animatingRect is between fromRect and toRect
622
+ if (isRectEqual(prevFromRect, toRect) && !isRectEqual(fromRect, toRect) &&
623
+ // Make sure animatingRect is on line between toRect & fromRect
624
+ (animatingRect.top - toRect.top) / (animatingRect.left - toRect.left) === (fromRect.top - toRect.top) / (fromRect.left - toRect.left)) {
625
+ // If returning to same place as started from animation and on same axis
626
+ time = calculateRealTime(animatingRect, prevFromRect, prevToRect, _this.options);
627
+ }
628
+ }
629
+
630
+ // if fromRect != toRect: animate
631
+ if (!isRectEqual(toRect, fromRect)) {
632
+ target.prevFromRect = fromRect;
633
+ target.prevToRect = toRect;
634
+ if (!time) {
635
+ time = _this.options.animation;
636
+ }
637
+ _this.animate(target, animatingRect, toRect, time);
638
+ }
639
+ if (time) {
640
+ animating = true;
641
+ animationTime = Math.max(animationTime, time);
642
+ clearTimeout(target.animationResetTimer);
643
+ target.animationResetTimer = setTimeout(function () {
644
+ target.animationTime = 0;
645
+ target.prevFromRect = null;
646
+ target.fromRect = null;
647
+ target.prevToRect = null;
648
+ target.thisAnimationDuration = null;
649
+ }, time);
650
+ target.thisAnimationDuration = time;
651
+ }
652
+ });
653
+ clearTimeout(animationCallbackId);
654
+ if (!animating) {
655
+ if (typeof callback === 'function') callback();
656
+ } else {
657
+ animationCallbackId = setTimeout(function () {
658
+ if (typeof callback === 'function') callback();
659
+ }, animationTime);
660
+ }
661
+ animationStates = [];
662
+ },
663
+ animate: function animate(target, currentRect, toRect, duration) {
664
+ if (duration) {
665
+ css(target, 'transition', '');
666
+ css(target, 'transform', '');
667
+ var elMatrix = matrix(this.el),
668
+ scaleX = elMatrix && elMatrix.a,
669
+ scaleY = elMatrix && elMatrix.d,
670
+ translateX = (currentRect.left - toRect.left) / (scaleX || 1),
671
+ translateY = (currentRect.top - toRect.top) / (scaleY || 1);
672
+ target.animatingX = !!translateX;
673
+ target.animatingY = !!translateY;
674
+ css(target, 'transform', 'translate3d(' + translateX + 'px,' + translateY + 'px,0)');
675
+ this.forRepaintDummy = repaint(target); // repaint
676
+
677
+ css(target, 'transition', 'transform ' + duration + 'ms' + (this.options.easing ? ' ' + this.options.easing : ''));
678
+ css(target, 'transform', 'translate3d(0,0,0)');
679
+ typeof target.animated === 'number' && clearTimeout(target.animated);
680
+ target.animated = setTimeout(function () {
681
+ css(target, 'transition', '');
682
+ css(target, 'transform', '');
683
+ target.animated = false;
684
+ target.animatingX = false;
685
+ target.animatingY = false;
686
+ }, duration);
687
+ }
688
+ }
689
+ };
690
+ }
691
+ function repaint(target) {
692
+ return target.offsetWidth;
693
+ }
694
+ function calculateRealTime(animatingRect, fromRect, toRect, options) {
695
+ 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;
696
+ }
697
+
698
+ var plugins = [];
699
+ var defaults = {
700
+ initializeByDefault: true
701
+ };
702
+ var PluginManager = {
703
+ mount: function mount(plugin) {
704
+ // Set default static properties
705
+ for (var option in defaults) {
706
+ if (defaults.hasOwnProperty(option) && !(option in plugin)) {
707
+ plugin[option] = defaults[option];
708
+ }
709
+ }
710
+ plugins.forEach(function (p) {
711
+ if (p.pluginName === plugin.pluginName) {
712
+ throw "Sortable: Cannot mount plugin ".concat(plugin.pluginName, " more than once");
713
+ }
714
+ });
715
+ plugins.push(plugin);
716
+ },
717
+ pluginEvent: function pluginEvent(eventName, sortable, evt) {
718
+ var _this = this;
719
+ this.eventCanceled = false;
720
+ evt.cancel = function () {
721
+ _this.eventCanceled = true;
722
+ };
723
+ var eventNameGlobal = eventName + 'Global';
724
+ plugins.forEach(function (plugin) {
725
+ if (!sortable[plugin.pluginName]) return;
726
+ // Fire global events if it exists in this sortable
727
+ if (sortable[plugin.pluginName][eventNameGlobal]) {
728
+ sortable[plugin.pluginName][eventNameGlobal](_objectSpread2({
729
+ sortable: sortable
730
+ }, evt));
731
+ }
732
+
733
+ // Only fire plugin event if plugin is enabled in this sortable,
734
+ // and plugin has event defined
735
+ if (sortable.options[plugin.pluginName] && sortable[plugin.pluginName][eventName]) {
736
+ sortable[plugin.pluginName][eventName](_objectSpread2({
737
+ sortable: sortable
738
+ }, evt));
739
+ }
740
+ });
741
+ },
742
+ initializePlugins: function initializePlugins(sortable, el, defaults, options) {
743
+ plugins.forEach(function (plugin) {
744
+ var pluginName = plugin.pluginName;
745
+ if (!sortable.options[pluginName] && !plugin.initializeByDefault) return;
746
+ var initialized = new plugin(sortable, el, sortable.options);
747
+ initialized.sortable = sortable;
748
+ initialized.options = sortable.options;
749
+ sortable[pluginName] = initialized;
750
+
751
+ // Add default options from plugin
752
+ _extends(defaults, initialized.defaults);
753
+ });
754
+ for (var option in sortable.options) {
755
+ if (!sortable.options.hasOwnProperty(option)) continue;
756
+ var modified = this.modifyOption(sortable, option, sortable.options[option]);
757
+ if (typeof modified !== 'undefined') {
758
+ sortable.options[option] = modified;
759
+ }
760
+ }
761
+ },
762
+ getEventProperties: function getEventProperties(name, sortable) {
763
+ var eventProperties = {};
764
+ plugins.forEach(function (plugin) {
765
+ if (typeof plugin.eventProperties !== 'function') return;
766
+ _extends(eventProperties, plugin.eventProperties.call(sortable[plugin.pluginName], name));
767
+ });
768
+ return eventProperties;
769
+ },
770
+ modifyOption: function modifyOption(sortable, name, value) {
771
+ var modifiedValue;
772
+ plugins.forEach(function (plugin) {
773
+ // Plugin must exist on the Sortable
774
+ if (!sortable[plugin.pluginName]) return;
775
+
776
+ // If static option listener exists for this option, call in the context of the Sortable's instance of this plugin
777
+ if (plugin.optionListeners && typeof plugin.optionListeners[name] === 'function') {
778
+ modifiedValue = plugin.optionListeners[name].call(sortable[plugin.pluginName], value);
779
+ }
780
+ });
781
+ return modifiedValue;
782
+ }
783
+ };
784
+
785
+ function dispatchEvent(_ref) {
786
+ var sortable = _ref.sortable,
787
+ rootEl = _ref.rootEl,
788
+ name = _ref.name,
789
+ targetEl = _ref.targetEl,
790
+ cloneEl = _ref.cloneEl,
791
+ toEl = _ref.toEl,
792
+ fromEl = _ref.fromEl,
793
+ oldIndex = _ref.oldIndex,
794
+ newIndex = _ref.newIndex,
795
+ oldDraggableIndex = _ref.oldDraggableIndex,
796
+ newDraggableIndex = _ref.newDraggableIndex,
797
+ originalEvent = _ref.originalEvent,
798
+ putSortable = _ref.putSortable,
799
+ extraEventProperties = _ref.extraEventProperties;
800
+ sortable = sortable || rootEl && rootEl[expando];
801
+ if (!sortable) return;
802
+ var evt,
803
+ options = sortable.options,
804
+ onName = 'on' + name.charAt(0).toUpperCase() + name.substr(1);
805
+ // Support for new CustomEvent feature
806
+ if (window.CustomEvent && !IE11OrLess && !Edge) {
807
+ evt = new CustomEvent(name, {
808
+ bubbles: true,
809
+ cancelable: true
810
+ });
811
+ } else {
812
+ evt = document.createEvent('Event');
813
+ evt.initEvent(name, true, true);
814
+ }
815
+ evt.to = toEl || rootEl;
816
+ evt.from = fromEl || rootEl;
817
+ evt.item = targetEl || rootEl;
818
+ evt.clone = cloneEl;
819
+ evt.oldIndex = oldIndex;
820
+ evt.newIndex = newIndex;
821
+ evt.oldDraggableIndex = oldDraggableIndex;
822
+ evt.newDraggableIndex = newDraggableIndex;
823
+ evt.originalEvent = originalEvent;
824
+ evt.pullMode = putSortable ? putSortable.lastPutMode : undefined;
825
+ var allEventProperties = _objectSpread2(_objectSpread2({}, extraEventProperties), PluginManager.getEventProperties(name, sortable));
826
+ for (var option in allEventProperties) {
827
+ evt[option] = allEventProperties[option];
828
+ }
829
+ if (rootEl) {
830
+ rootEl.dispatchEvent(evt);
831
+ }
832
+ if (options[onName]) {
833
+ options[onName].call(sortable, evt);
834
+ }
835
+ }
836
+
837
+ var _excluded = ["evt"];
838
+ var pluginEvent = function pluginEvent(eventName, sortable) {
839
+ var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
840
+ originalEvent = _ref.evt,
841
+ data = _objectWithoutProperties(_ref, _excluded);
842
+ PluginManager.pluginEvent.bind(Sortable)(eventName, sortable, _objectSpread2({
843
+ dragEl: dragEl,
844
+ parentEl: parentEl,
845
+ ghostEl: ghostEl,
846
+ rootEl: rootEl,
847
+ nextEl: nextEl,
848
+ lastDownEl: lastDownEl,
849
+ cloneEl: cloneEl,
850
+ cloneHidden: cloneHidden,
851
+ dragStarted: moved,
852
+ putSortable: putSortable,
853
+ activeSortable: Sortable.active,
854
+ originalEvent: originalEvent,
855
+ oldIndex: oldIndex,
856
+ oldDraggableIndex: oldDraggableIndex,
857
+ newIndex: newIndex,
858
+ newDraggableIndex: newDraggableIndex,
859
+ hideGhostForTarget: _hideGhostForTarget,
860
+ unhideGhostForTarget: _unhideGhostForTarget,
861
+ cloneNowHidden: function cloneNowHidden() {
862
+ cloneHidden = true;
863
+ },
864
+ cloneNowShown: function cloneNowShown() {
865
+ cloneHidden = false;
866
+ },
867
+ dispatchSortableEvent: function dispatchSortableEvent(name) {
868
+ _dispatchEvent({
869
+ sortable: sortable,
870
+ name: name,
871
+ originalEvent: originalEvent
872
+ });
873
+ }
874
+ }, data));
875
+ };
876
+ function _dispatchEvent(info) {
877
+ dispatchEvent(_objectSpread2({
878
+ putSortable: putSortable,
879
+ cloneEl: cloneEl,
880
+ targetEl: dragEl,
881
+ rootEl: rootEl,
882
+ oldIndex: oldIndex,
883
+ oldDraggableIndex: oldDraggableIndex,
884
+ newIndex: newIndex,
885
+ newDraggableIndex: newDraggableIndex
886
+ }, info));
887
+ }
888
+ var dragEl,
889
+ parentEl,
890
+ ghostEl,
891
+ rootEl,
892
+ nextEl,
893
+ lastDownEl,
894
+ cloneEl,
895
+ cloneHidden,
896
+ oldIndex,
897
+ newIndex,
898
+ oldDraggableIndex,
899
+ newDraggableIndex,
900
+ activeGroup,
901
+ putSortable,
902
+ awaitingDragStarted = false,
903
+ ignoreNextClick = false,
904
+ sortables = [],
905
+ tapEvt,
906
+ touchEvt,
907
+ lastDx,
908
+ lastDy,
909
+ tapDistanceLeft,
910
+ tapDistanceTop,
911
+ moved,
912
+ lastTarget,
913
+ lastDirection,
914
+ pastFirstInvertThresh = false,
915
+ isCircumstantialInvert = false,
916
+ targetMoveDistance,
917
+ // For positioning ghost absolutely
918
+ ghostRelativeParent,
919
+ ghostRelativeParentInitialScroll = [],
920
+ // (left, top)
921
+
922
+ _silent = false,
923
+ savedInputChecked = [];
924
+
925
+ /** @const */
926
+ var documentExists = typeof document !== 'undefined',
927
+ PositionGhostAbsolutely = IOS,
928
+ CSSFloatProperty = Edge || IE11OrLess ? 'cssFloat' : 'float',
929
+ // This will not pass for IE9, because IE9 DnD only works on anchors
930
+ supportDraggable = documentExists && !ChromeForAndroid && !IOS && 'draggable' in document.createElement('div'),
931
+ supportCssPointerEvents = function () {
932
+ if (!documentExists) return;
933
+ // false when <= IE11
934
+ if (IE11OrLess) {
935
+ return false;
936
+ }
937
+ var el = document.createElement('x');
938
+ el.style.cssText = 'pointer-events:auto';
939
+ return el.style.pointerEvents === 'auto';
940
+ }(),
941
+ _detectDirection = function _detectDirection(el, options) {
942
+ var elCSS = css(el),
943
+ elWidth = parseInt(elCSS.width) - parseInt(elCSS.paddingLeft) - parseInt(elCSS.paddingRight) - parseInt(elCSS.borderLeftWidth) - parseInt(elCSS.borderRightWidth),
944
+ child1 = getChild(el, 0, options),
945
+ child2 = getChild(el, 1, options),
946
+ firstChildCSS = child1 && css(child1),
947
+ secondChildCSS = child2 && css(child2),
948
+ firstChildWidth = firstChildCSS && parseInt(firstChildCSS.marginLeft) + parseInt(firstChildCSS.marginRight) + getRect(child1).width,
949
+ secondChildWidth = secondChildCSS && parseInt(secondChildCSS.marginLeft) + parseInt(secondChildCSS.marginRight) + getRect(child2).width;
950
+ if (elCSS.display === 'flex') {
951
+ return elCSS.flexDirection === 'column' || elCSS.flexDirection === 'column-reverse' ? 'vertical' : 'horizontal';
952
+ }
953
+ if (elCSS.display === 'grid') {
954
+ return elCSS.gridTemplateColumns.split(' ').length <= 1 ? 'vertical' : 'horizontal';
955
+ }
956
+ if (child1 && firstChildCSS["float"] && firstChildCSS["float"] !== 'none') {
957
+ var touchingSideChild2 = firstChildCSS["float"] === 'left' ? 'left' : 'right';
958
+ return child2 && (secondChildCSS.clear === 'both' || secondChildCSS.clear === touchingSideChild2) ? 'vertical' : 'horizontal';
959
+ }
960
+ 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';
961
+ },
962
+ _dragElInRowColumn = function _dragElInRowColumn(dragRect, targetRect, vertical) {
963
+ var dragElS1Opp = vertical ? dragRect.left : dragRect.top,
964
+ dragElS2Opp = vertical ? dragRect.right : dragRect.bottom,
965
+ dragElOppLength = vertical ? dragRect.width : dragRect.height,
966
+ targetS1Opp = vertical ? targetRect.left : targetRect.top,
967
+ targetS2Opp = vertical ? targetRect.right : targetRect.bottom,
968
+ targetOppLength = vertical ? targetRect.width : targetRect.height;
969
+ return dragElS1Opp === targetS1Opp || dragElS2Opp === targetS2Opp || dragElS1Opp + dragElOppLength / 2 === targetS1Opp + targetOppLength / 2;
970
+ },
971
+ /**
972
+ * Detects first nearest empty sortable to X and Y position using emptyInsertThreshold.
973
+ * @param {Number} x X position
974
+ * @param {Number} y Y position
975
+ * @return {HTMLElement} Element of the first found nearest Sortable
976
+ */
977
+ _detectNearestEmptySortable = function _detectNearestEmptySortable(x, y) {
978
+ var ret;
979
+ sortables.some(function (sortable) {
980
+ var threshold = sortable[expando].options.emptyInsertThreshold;
981
+ if (!threshold || lastChild(sortable)) return;
982
+ var rect = getRect(sortable),
983
+ insideHorizontally = x >= rect.left - threshold && x <= rect.right + threshold,
984
+ insideVertically = y >= rect.top - threshold && y <= rect.bottom + threshold;
985
+ if (insideHorizontally && insideVertically) {
986
+ return ret = sortable;
987
+ }
988
+ });
989
+ return ret;
990
+ },
991
+ _prepareGroup = function _prepareGroup(options) {
992
+ function toFn(value, pull) {
993
+ return function (to, from, dragEl, evt) {
994
+ var sameGroup = to.options.group.name && from.options.group.name && to.options.group.name === from.options.group.name;
995
+ if (value == null && (pull || sameGroup)) {
996
+ // Default pull value
997
+ // Default pull and put value if same group
998
+ return true;
999
+ } else if (value == null || value === false) {
1000
+ return false;
1001
+ } else if (pull && value === 'clone') {
1002
+ return value;
1003
+ } else if (typeof value === 'function') {
1004
+ return toFn(value(to, from, dragEl, evt), pull)(to, from, dragEl, evt);
1005
+ } else {
1006
+ var otherGroup = (pull ? to : from).options.group.name;
1007
+ return value === true || typeof value === 'string' && value === otherGroup || value.join && value.indexOf(otherGroup) > -1;
1008
+ }
1009
+ };
1010
+ }
1011
+ var group = {};
1012
+ var originalGroup = options.group;
1013
+ if (!originalGroup || _typeof(originalGroup) != 'object') {
1014
+ originalGroup = {
1015
+ name: originalGroup
1016
+ };
1017
+ }
1018
+ group.name = originalGroup.name;
1019
+ group.checkPull = toFn(originalGroup.pull, true);
1020
+ group.checkPut = toFn(originalGroup.put);
1021
+ group.revertClone = originalGroup.revertClone;
1022
+ options.group = group;
1023
+ },
1024
+ _hideGhostForTarget = function _hideGhostForTarget() {
1025
+ if (!supportCssPointerEvents && ghostEl) {
1026
+ css(ghostEl, 'display', 'none');
1027
+ }
1028
+ },
1029
+ _unhideGhostForTarget = function _unhideGhostForTarget() {
1030
+ if (!supportCssPointerEvents && ghostEl) {
1031
+ css(ghostEl, 'display', '');
1032
+ }
1033
+ };
1034
+
1035
+ // #1184 fix - Prevent click event on fallback if dragged but item not changed position
1036
+ if (documentExists && !ChromeForAndroid) {
1037
+ document.addEventListener('click', function (evt) {
1038
+ if (ignoreNextClick) {
1039
+ evt.preventDefault();
1040
+ evt.stopPropagation && evt.stopPropagation();
1041
+ evt.stopImmediatePropagation && evt.stopImmediatePropagation();
1042
+ ignoreNextClick = false;
1043
+ return false;
1044
+ }
1045
+ }, true);
1046
+ }
1047
+ var nearestEmptyInsertDetectEvent = function nearestEmptyInsertDetectEvent(evt) {
1048
+ if (dragEl) {
1049
+ evt = evt.touches ? evt.touches[0] : evt;
1050
+ var nearest = _detectNearestEmptySortable(evt.clientX, evt.clientY);
1051
+ if (nearest) {
1052
+ // Create imitation event
1053
+ var event = {};
1054
+ for (var i in evt) {
1055
+ if (evt.hasOwnProperty(i)) {
1056
+ event[i] = evt[i];
1057
+ }
1058
+ }
1059
+ event.target = event.rootEl = nearest;
1060
+ event.preventDefault = void 0;
1061
+ event.stopPropagation = void 0;
1062
+ nearest[expando]._onDragOver(event);
1063
+ }
1064
+ }
1065
+ };
1066
+ var _checkOutsideTargetEl = function _checkOutsideTargetEl(evt) {
1067
+ if (dragEl) {
1068
+ dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
1069
+ }
1070
+ };
1071
+
1072
+ /**
1073
+ * @class Sortable
1074
+ * @param {HTMLElement} el
1075
+ * @param {Object} [options]
1076
+ */
1077
+ function Sortable(el, options) {
1078
+ if (!(el && el.nodeType && el.nodeType === 1)) {
1079
+ throw "Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(el));
1080
+ }
1081
+ this.el = el; // root element
1082
+ this.options = options = _extends({}, options);
1083
+
1084
+ // Export instance
1085
+ el[expando] = this;
1086
+ var defaults = {
1087
+ group: null,
1088
+ sort: true,
1089
+ disabled: false,
1090
+ store: null,
1091
+ handle: null,
1092
+ draggable: /^[uo]l$/i.test(el.nodeName) ? '>li' : '>*',
1093
+ swapThreshold: 1,
1094
+ // percentage; 0 <= x <= 1
1095
+ invertSwap: false,
1096
+ // invert always
1097
+ invertedSwapThreshold: null,
1098
+ // will be set to same as swapThreshold if default
1099
+ removeCloneOnHide: true,
1100
+ direction: function direction() {
1101
+ return _detectDirection(el, this.options);
1102
+ },
1103
+ ghostClass: 'sortable-ghost',
1104
+ chosenClass: 'sortable-chosen',
1105
+ dragClass: 'sortable-drag',
1106
+ ignore: 'a, img',
1107
+ filter: null,
1108
+ preventOnFilter: true,
1109
+ animation: 0,
1110
+ easing: null,
1111
+ setData: function setData(dataTransfer, dragEl) {
1112
+ dataTransfer.setData('Text', dragEl.textContent);
1113
+ },
1114
+ dropBubble: false,
1115
+ dragoverBubble: false,
1116
+ dataIdAttr: 'data-id',
1117
+ delay: 0,
1118
+ delayOnTouchOnly: false,
1119
+ touchStartThreshold: (Number.parseInt ? Number : window).parseInt(window.devicePixelRatio, 10) || 1,
1120
+ forceFallback: false,
1121
+ fallbackClass: 'sortable-fallback',
1122
+ fallbackOnBody: false,
1123
+ fallbackTolerance: 0,
1124
+ fallbackOffset: {
1125
+ x: 0,
1126
+ y: 0
1127
+ },
1128
+ // Disabled on Safari: #1571; Enabled on Safari IOS: #2244
1129
+ supportPointer: Sortable.supportPointer !== false && 'PointerEvent' in window && (!Safari || IOS),
1130
+ emptyInsertThreshold: 5
1131
+ };
1132
+ PluginManager.initializePlugins(this, el, defaults);
1133
+
1134
+ // Set default options
1135
+ for (var name in defaults) {
1136
+ !(name in options) && (options[name] = defaults[name]);
1137
+ }
1138
+ _prepareGroup(options);
1139
+
1140
+ // Bind all private methods
1141
+ for (var fn in this) {
1142
+ if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
1143
+ this[fn] = this[fn].bind(this);
1144
+ }
1145
+ }
1146
+
1147
+ // Setup drag mode
1148
+ this.nativeDraggable = options.forceFallback ? false : supportDraggable;
1149
+ if (this.nativeDraggable) {
1150
+ // Touch start threshold cannot be greater than the native dragstart threshold
1151
+ this.options.touchStartThreshold = 1;
1152
+ }
1153
+
1154
+ // Bind events
1155
+ if (options.supportPointer) {
1156
+ on(el, 'pointerdown', this._onTapStart);
1157
+ } else {
1158
+ on(el, 'mousedown', this._onTapStart);
1159
+ on(el, 'touchstart', this._onTapStart);
1160
+ }
1161
+ if (this.nativeDraggable) {
1162
+ on(el, 'dragover', this);
1163
+ on(el, 'dragenter', this);
1164
+ }
1165
+ sortables.push(this.el);
1166
+
1167
+ // Restore sorting
1168
+ options.store && options.store.get && this.sort(options.store.get(this) || []);
1169
+
1170
+ // Add animation state manager
1171
+ _extends(this, AnimationStateManager());
1172
+ }
1173
+ Sortable.prototype = /** @lends Sortable.prototype */{
1174
+ constructor: Sortable,
1175
+ _isOutsideThisEl: function _isOutsideThisEl(target) {
1176
+ if (!this.el.contains(target) && target !== this.el) {
1177
+ lastTarget = null;
1178
+ }
1179
+ },
1180
+ _getDirection: function _getDirection(evt, target) {
1181
+ return typeof this.options.direction === 'function' ? this.options.direction.call(this, evt, target, dragEl) : this.options.direction;
1182
+ },
1183
+ _onTapStart: function _onTapStart( /** Event|TouchEvent */evt) {
1184
+ if (!evt.cancelable) return;
1185
+ var _this = this,
1186
+ el = this.el,
1187
+ options = this.options,
1188
+ preventOnFilter = options.preventOnFilter,
1189
+ type = evt.type,
1190
+ touch = evt.touches && evt.touches[0] || evt.pointerType && evt.pointerType === 'touch' && evt,
1191
+ target = (touch || evt).target,
1192
+ originalTarget = evt.target.shadowRoot && (evt.path && evt.path[0] || evt.composedPath && evt.composedPath()[0]) || target,
1193
+ filter = options.filter;
1194
+ _saveInputCheckedState(el);
1195
+
1196
+ // Don't trigger start event when an element is been dragged, otherwise the evt.oldindex always wrong when set option.group.
1197
+ if (dragEl) {
1198
+ return;
1199
+ }
1200
+ if (/mousedown|pointerdown/.test(type) && evt.button !== 0 || options.disabled) {
1201
+ return; // only left button and enabled
1202
+ }
1203
+
1204
+ // cancel dnd if original target is content editable
1205
+ if (originalTarget.isContentEditable) {
1206
+ return;
1207
+ }
1208
+
1209
+ // Safari ignores further event handling after mousedown
1210
+ if (!this.nativeDraggable && Safari && target && target.tagName.toUpperCase() === 'SELECT') {
1211
+ return;
1212
+ }
1213
+ target = closest(target, options.draggable, el, false);
1214
+ if (target && target.animated) {
1215
+ return;
1216
+ }
1217
+ if (lastDownEl === target) {
1218
+ // Ignoring duplicate `down`
1219
+ return;
1220
+ }
1221
+
1222
+ // Get the index of the dragged element within its parent
1223
+ oldIndex = index(target);
1224
+ oldDraggableIndex = index(target, options.draggable);
1225
+
1226
+ // Check filter
1227
+ if (typeof filter === 'function') {
1228
+ if (filter.call(this, evt, target, this)) {
1229
+ _dispatchEvent({
1230
+ sortable: _this,
1231
+ rootEl: originalTarget,
1232
+ name: 'filter',
1233
+ targetEl: target,
1234
+ toEl: el,
1235
+ fromEl: el
1236
+ });
1237
+ pluginEvent('filter', _this, {
1238
+ evt: evt
1239
+ });
1240
+ preventOnFilter && evt.preventDefault();
1241
+ return; // cancel dnd
1242
+ }
1243
+ } else if (filter) {
1244
+ filter = filter.split(',').some(function (criteria) {
1245
+ criteria = closest(originalTarget, criteria.trim(), el, false);
1246
+ if (criteria) {
1247
+ _dispatchEvent({
1248
+ sortable: _this,
1249
+ rootEl: criteria,
1250
+ name: 'filter',
1251
+ targetEl: target,
1252
+ fromEl: el,
1253
+ toEl: el
1254
+ });
1255
+ pluginEvent('filter', _this, {
1256
+ evt: evt
1257
+ });
1258
+ return true;
1259
+ }
1260
+ });
1261
+ if (filter) {
1262
+ preventOnFilter && evt.preventDefault();
1263
+ return; // cancel dnd
1264
+ }
1265
+ }
1266
+ if (options.handle && !closest(originalTarget, options.handle, el, false)) {
1267
+ return;
1268
+ }
1269
+
1270
+ // Prepare `dragstart`
1271
+ this._prepareDragStart(evt, touch, target);
1272
+ },
1273
+ _prepareDragStart: function _prepareDragStart( /** Event */evt, /** Touch */touch, /** HTMLElement */target) {
1274
+ var _this = this,
1275
+ el = _this.el,
1276
+ options = _this.options,
1277
+ ownerDocument = el.ownerDocument,
1278
+ dragStartFn;
1279
+ if (target && !dragEl && target.parentNode === el) {
1280
+ var dragRect = getRect(target);
1281
+ rootEl = el;
1282
+ dragEl = target;
1283
+ parentEl = dragEl.parentNode;
1284
+ nextEl = dragEl.nextSibling;
1285
+ lastDownEl = target;
1286
+ activeGroup = options.group;
1287
+ Sortable.dragged = dragEl;
1288
+ tapEvt = {
1289
+ target: dragEl,
1290
+ clientX: (touch || evt).clientX,
1291
+ clientY: (touch || evt).clientY
1292
+ };
1293
+ tapDistanceLeft = tapEvt.clientX - dragRect.left;
1294
+ tapDistanceTop = tapEvt.clientY - dragRect.top;
1295
+ this._lastX = (touch || evt).clientX;
1296
+ this._lastY = (touch || evt).clientY;
1297
+ dragEl.style['will-change'] = 'all';
1298
+ dragStartFn = function dragStartFn() {
1299
+ pluginEvent('delayEnded', _this, {
1300
+ evt: evt
1301
+ });
1302
+ if (Sortable.eventCanceled) {
1303
+ _this._onDrop();
1304
+ return;
1305
+ }
1306
+ // Delayed drag has been triggered
1307
+ // we can re-enable the events: touchmove/mousemove
1308
+ _this._disableDelayedDragEvents();
1309
+ if (!FireFox && _this.nativeDraggable) {
1310
+ dragEl.draggable = true;
1311
+ }
1312
+
1313
+ // Bind the events: dragstart/dragend
1314
+ _this._triggerDragStart(evt, touch);
1315
+
1316
+ // Drag start event
1317
+ _dispatchEvent({
1318
+ sortable: _this,
1319
+ name: 'choose',
1320
+ originalEvent: evt
1321
+ });
1322
+
1323
+ // Chosen item
1324
+ toggleClass(dragEl, options.chosenClass, true);
1325
+ };
1326
+
1327
+ // Disable "draggable"
1328
+ options.ignore.split(',').forEach(function (criteria) {
1329
+ find(dragEl, criteria.trim(), _disableDraggable);
1330
+ });
1331
+ on(ownerDocument, 'dragover', nearestEmptyInsertDetectEvent);
1332
+ on(ownerDocument, 'mousemove', nearestEmptyInsertDetectEvent);
1333
+ on(ownerDocument, 'touchmove', nearestEmptyInsertDetectEvent);
1334
+ if (options.supportPointer) {
1335
+ on(ownerDocument, 'pointerup', _this._onDrop);
1336
+ // Native D&D triggers pointercancel
1337
+ !this.nativeDraggable && on(ownerDocument, 'pointercancel', _this._onDrop);
1338
+ } else {
1339
+ on(ownerDocument, 'mouseup', _this._onDrop);
1340
+ on(ownerDocument, 'touchend', _this._onDrop);
1341
+ on(ownerDocument, 'touchcancel', _this._onDrop);
1342
+ }
1343
+
1344
+ // Make dragEl draggable (must be before delay for FireFox)
1345
+ if (FireFox && this.nativeDraggable) {
1346
+ this.options.touchStartThreshold = 4;
1347
+ dragEl.draggable = true;
1348
+ }
1349
+ pluginEvent('delayStart', this, {
1350
+ evt: evt
1351
+ });
1352
+
1353
+ // Delay is impossible for native DnD in Edge or IE
1354
+ if (options.delay && (!options.delayOnTouchOnly || touch) && (!this.nativeDraggable || !(Edge || IE11OrLess))) {
1355
+ if (Sortable.eventCanceled) {
1356
+ this._onDrop();
1357
+ return;
1358
+ }
1359
+ // If the user moves the pointer or let go the click or touch
1360
+ // before the delay has been reached:
1361
+ // disable the delayed drag
1362
+ if (options.supportPointer) {
1363
+ on(ownerDocument, 'pointerup', _this._disableDelayedDrag);
1364
+ on(ownerDocument, 'pointercancel', _this._disableDelayedDrag);
1365
+ } else {
1366
+ on(ownerDocument, 'mouseup', _this._disableDelayedDrag);
1367
+ on(ownerDocument, 'touchend', _this._disableDelayedDrag);
1368
+ on(ownerDocument, 'touchcancel', _this._disableDelayedDrag);
1369
+ }
1370
+ on(ownerDocument, 'mousemove', _this._delayedDragTouchMoveHandler);
1371
+ on(ownerDocument, 'touchmove', _this._delayedDragTouchMoveHandler);
1372
+ options.supportPointer && on(ownerDocument, 'pointermove', _this._delayedDragTouchMoveHandler);
1373
+ _this._dragStartTimer = setTimeout(dragStartFn, options.delay);
1374
+ } else {
1375
+ dragStartFn();
1376
+ }
1377
+ }
1378
+ },
1379
+ _delayedDragTouchMoveHandler: function _delayedDragTouchMoveHandler( /** TouchEvent|PointerEvent **/e) {
1380
+ var touch = e.touches ? e.touches[0] : e;
1381
+ 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))) {
1382
+ this._disableDelayedDrag();
1383
+ }
1384
+ },
1385
+ _disableDelayedDrag: function _disableDelayedDrag() {
1386
+ dragEl && _disableDraggable(dragEl);
1387
+ clearTimeout(this._dragStartTimer);
1388
+ this._disableDelayedDragEvents();
1389
+ },
1390
+ _disableDelayedDragEvents: function _disableDelayedDragEvents() {
1391
+ var ownerDocument = this.el.ownerDocument;
1392
+ off(ownerDocument, 'mouseup', this._disableDelayedDrag);
1393
+ off(ownerDocument, 'touchend', this._disableDelayedDrag);
1394
+ off(ownerDocument, 'touchcancel', this._disableDelayedDrag);
1395
+ off(ownerDocument, 'pointerup', this._disableDelayedDrag);
1396
+ off(ownerDocument, 'pointercancel', this._disableDelayedDrag);
1397
+ off(ownerDocument, 'mousemove', this._delayedDragTouchMoveHandler);
1398
+ off(ownerDocument, 'touchmove', this._delayedDragTouchMoveHandler);
1399
+ off(ownerDocument, 'pointermove', this._delayedDragTouchMoveHandler);
1400
+ },
1401
+ _triggerDragStart: function _triggerDragStart( /** Event */evt, /** Touch */touch) {
1402
+ touch = touch || evt.pointerType == 'touch' && evt;
1403
+ if (!this.nativeDraggable || touch) {
1404
+ if (this.options.supportPointer) {
1405
+ on(document, 'pointermove', this._onTouchMove);
1406
+ } else if (touch) {
1407
+ on(document, 'touchmove', this._onTouchMove);
1408
+ } else {
1409
+ on(document, 'mousemove', this._onTouchMove);
1410
+ }
1411
+ } else {
1412
+ on(dragEl, 'dragend', this);
1413
+ on(rootEl, 'dragstart', this._onDragStart);
1414
+ }
1415
+ try {
1416
+ if (document.selection) {
1417
+ _nextTick(function () {
1418
+ document.selection.empty();
1419
+ });
1420
+ } else {
1421
+ window.getSelection().removeAllRanges();
1422
+ }
1423
+ } catch (err) {}
1424
+ },
1425
+ _dragStarted: function _dragStarted(fallback, evt) {
1426
+ awaitingDragStarted = false;
1427
+ if (rootEl && dragEl) {
1428
+ pluginEvent('dragStarted', this, {
1429
+ evt: evt
1430
+ });
1431
+ if (this.nativeDraggable) {
1432
+ on(document, 'dragover', _checkOutsideTargetEl);
1433
+ }
1434
+ var options = this.options;
1435
+
1436
+ // Apply effect
1437
+ !fallback && toggleClass(dragEl, options.dragClass, false);
1438
+ toggleClass(dragEl, options.ghostClass, true);
1439
+ Sortable.active = this;
1440
+ fallback && this._appendGhost();
1441
+
1442
+ // Drag start event
1443
+ _dispatchEvent({
1444
+ sortable: this,
1445
+ name: 'start',
1446
+ originalEvent: evt
1447
+ });
1448
+ } else {
1449
+ this._nulling();
1450
+ }
1451
+ },
1452
+ _emulateDragOver: function _emulateDragOver() {
1453
+ if (touchEvt) {
1454
+ this._lastX = touchEvt.clientX;
1455
+ this._lastY = touchEvt.clientY;
1456
+ _hideGhostForTarget();
1457
+ var target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
1458
+ var parent = target;
1459
+ while (target && target.shadowRoot) {
1460
+ target = target.shadowRoot.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
1461
+ if (target === parent) break;
1462
+ parent = target;
1463
+ }
1464
+ dragEl.parentNode[expando]._isOutsideThisEl(target);
1465
+ if (parent) {
1466
+ do {
1467
+ if (parent[expando]) {
1468
+ var inserted = void 0;
1469
+ inserted = parent[expando]._onDragOver({
1470
+ clientX: touchEvt.clientX,
1471
+ clientY: touchEvt.clientY,
1472
+ target: target,
1473
+ rootEl: parent
1474
+ });
1475
+ if (inserted && !this.options.dragoverBubble) {
1476
+ break;
1477
+ }
1478
+ }
1479
+ target = parent; // store last element
1480
+ }
1481
+ /* jshint boss:true */ while (parent = getParentOrHost(parent));
1482
+ }
1483
+ _unhideGhostForTarget();
1484
+ }
1485
+ },
1486
+ _onTouchMove: function _onTouchMove( /**TouchEvent*/evt) {
1487
+ if (tapEvt) {
1488
+ var options = this.options,
1489
+ fallbackTolerance = options.fallbackTolerance,
1490
+ fallbackOffset = options.fallbackOffset,
1491
+ touch = evt.touches ? evt.touches[0] : evt,
1492
+ ghostMatrix = ghostEl && matrix(ghostEl, true),
1493
+ scaleX = ghostEl && ghostMatrix && ghostMatrix.a,
1494
+ scaleY = ghostEl && ghostMatrix && ghostMatrix.d,
1495
+ relativeScrollOffset = PositionGhostAbsolutely && ghostRelativeParent && getRelativeScrollOffset(ghostRelativeParent),
1496
+ dx = (touch.clientX - tapEvt.clientX + fallbackOffset.x) / (scaleX || 1) + (relativeScrollOffset ? relativeScrollOffset[0] - ghostRelativeParentInitialScroll[0] : 0) / (scaleX || 1),
1497
+ dy = (touch.clientY - tapEvt.clientY + fallbackOffset.y) / (scaleY || 1) + (relativeScrollOffset ? relativeScrollOffset[1] - ghostRelativeParentInitialScroll[1] : 0) / (scaleY || 1);
1498
+
1499
+ // only set the status to dragging, when we are actually dragging
1500
+ if (!Sortable.active && !awaitingDragStarted) {
1501
+ if (fallbackTolerance && Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) < fallbackTolerance) {
1502
+ return;
1503
+ }
1504
+ this._onDragStart(evt, true);
1505
+ }
1506
+ if (ghostEl) {
1507
+ if (ghostMatrix) {
1508
+ ghostMatrix.e += dx - (lastDx || 0);
1509
+ ghostMatrix.f += dy - (lastDy || 0);
1510
+ } else {
1511
+ ghostMatrix = {
1512
+ a: 1,
1513
+ b: 0,
1514
+ c: 0,
1515
+ d: 1,
1516
+ e: dx,
1517
+ f: dy
1518
+ };
1519
+ }
1520
+ var cssMatrix = "matrix(".concat(ghostMatrix.a, ",").concat(ghostMatrix.b, ",").concat(ghostMatrix.c, ",").concat(ghostMatrix.d, ",").concat(ghostMatrix.e, ",").concat(ghostMatrix.f, ")");
1521
+ css(ghostEl, 'webkitTransform', cssMatrix);
1522
+ css(ghostEl, 'mozTransform', cssMatrix);
1523
+ css(ghostEl, 'msTransform', cssMatrix);
1524
+ css(ghostEl, 'transform', cssMatrix);
1525
+ lastDx = dx;
1526
+ lastDy = dy;
1527
+ touchEvt = touch;
1528
+ }
1529
+ evt.cancelable && evt.preventDefault();
1530
+ }
1531
+ },
1532
+ _appendGhost: function _appendGhost() {
1533
+ // Bug if using scale(): https://stackoverflow.com/questions/2637058
1534
+ // Not being adjusted for
1535
+ if (!ghostEl) {
1536
+ var container = this.options.fallbackOnBody ? document.body : rootEl,
1537
+ rect = getRect(dragEl, true, PositionGhostAbsolutely, true, container),
1538
+ options = this.options;
1539
+
1540
+ // Position absolutely
1541
+ if (PositionGhostAbsolutely) {
1542
+ // Get relatively positioned parent
1543
+ ghostRelativeParent = container;
1544
+ while (css(ghostRelativeParent, 'position') === 'static' && css(ghostRelativeParent, 'transform') === 'none' && ghostRelativeParent !== document) {
1545
+ ghostRelativeParent = ghostRelativeParent.parentNode;
1546
+ }
1547
+ if (ghostRelativeParent !== document.body && ghostRelativeParent !== document.documentElement) {
1548
+ if (ghostRelativeParent === document) ghostRelativeParent = getWindowScrollingElement();
1549
+ rect.top += ghostRelativeParent.scrollTop;
1550
+ rect.left += ghostRelativeParent.scrollLeft;
1551
+ } else {
1552
+ ghostRelativeParent = getWindowScrollingElement();
1553
+ }
1554
+ ghostRelativeParentInitialScroll = getRelativeScrollOffset(ghostRelativeParent);
1555
+ }
1556
+ ghostEl = dragEl.cloneNode(true);
1557
+ toggleClass(ghostEl, options.ghostClass, false);
1558
+ toggleClass(ghostEl, options.fallbackClass, true);
1559
+ toggleClass(ghostEl, options.dragClass, true);
1560
+ css(ghostEl, 'transition', '');
1561
+ css(ghostEl, 'transform', '');
1562
+ css(ghostEl, 'box-sizing', 'border-box');
1563
+ css(ghostEl, 'margin', 0);
1564
+ css(ghostEl, 'top', rect.top);
1565
+ css(ghostEl, 'left', rect.left);
1566
+ css(ghostEl, 'width', rect.width);
1567
+ css(ghostEl, 'height', rect.height);
1568
+ css(ghostEl, 'opacity', '0.8');
1569
+ css(ghostEl, 'position', PositionGhostAbsolutely ? 'absolute' : 'fixed');
1570
+ css(ghostEl, 'zIndex', '100000');
1571
+ css(ghostEl, 'pointerEvents', 'none');
1572
+ Sortable.ghost = ghostEl;
1573
+ container.appendChild(ghostEl);
1574
+
1575
+ // Set transform-origin
1576
+ css(ghostEl, 'transform-origin', tapDistanceLeft / parseInt(ghostEl.style.width) * 100 + '% ' + tapDistanceTop / parseInt(ghostEl.style.height) * 100 + '%');
1577
+ }
1578
+ },
1579
+ _onDragStart: function _onDragStart( /**Event*/evt, /**boolean*/fallback) {
1580
+ var _this = this;
1581
+ var dataTransfer = evt.dataTransfer;
1582
+ var options = _this.options;
1583
+ pluginEvent('dragStart', this, {
1584
+ evt: evt
1585
+ });
1586
+ if (Sortable.eventCanceled) {
1587
+ this._onDrop();
1588
+ return;
1589
+ }
1590
+ pluginEvent('setupClone', this);
1591
+ if (!Sortable.eventCanceled) {
1592
+ cloneEl = clone(dragEl);
1593
+ cloneEl.removeAttribute("id");
1594
+ cloneEl.draggable = false;
1595
+ cloneEl.style['will-change'] = '';
1596
+ this._hideClone();
1597
+ toggleClass(cloneEl, this.options.chosenClass, false);
1598
+ Sortable.clone = cloneEl;
1599
+ }
1600
+
1601
+ // #1143: IFrame support workaround
1602
+ _this.cloneId = _nextTick(function () {
1603
+ pluginEvent('clone', _this);
1604
+ if (Sortable.eventCanceled) return;
1605
+ if (!_this.options.removeCloneOnHide) {
1606
+ rootEl.insertBefore(cloneEl, dragEl);
1607
+ }
1608
+ _this._hideClone();
1609
+ _dispatchEvent({
1610
+ sortable: _this,
1611
+ name: 'clone'
1612
+ });
1613
+ });
1614
+ !fallback && toggleClass(dragEl, options.dragClass, true);
1615
+
1616
+ // Set proper drop events
1617
+ if (fallback) {
1618
+ ignoreNextClick = true;
1619
+ _this._loopId = setInterval(_this._emulateDragOver, 50);
1620
+ } else {
1621
+ // Undo what was set in _prepareDragStart before drag started
1622
+ off(document, 'mouseup', _this._onDrop);
1623
+ off(document, 'touchend', _this._onDrop);
1624
+ off(document, 'touchcancel', _this._onDrop);
1625
+ if (dataTransfer) {
1626
+ dataTransfer.effectAllowed = 'move';
1627
+ options.setData && options.setData.call(_this, dataTransfer, dragEl);
1628
+ }
1629
+ on(document, 'drop', _this);
1630
+
1631
+ // #1276 fix:
1632
+ css(dragEl, 'transform', 'translateZ(0)');
1633
+ }
1634
+ awaitingDragStarted = true;
1635
+ _this._dragStartId = _nextTick(_this._dragStarted.bind(_this, fallback, evt));
1636
+ on(document, 'selectstart', _this);
1637
+ moved = true;
1638
+ window.getSelection().removeAllRanges();
1639
+ if (Safari) {
1640
+ css(document.body, 'user-select', 'none');
1641
+ }
1642
+ },
1643
+ // Returns true - if no further action is needed (either inserted or another condition)
1644
+ _onDragOver: function _onDragOver( /**Event*/evt) {
1645
+ var el = this.el,
1646
+ target = evt.target,
1647
+ dragRect,
1648
+ targetRect,
1649
+ revert,
1650
+ options = this.options,
1651
+ group = options.group,
1652
+ activeSortable = Sortable.active,
1653
+ isOwner = activeGroup === group,
1654
+ canSort = options.sort,
1655
+ fromSortable = putSortable || activeSortable,
1656
+ vertical,
1657
+ _this = this,
1658
+ completedFired = false;
1659
+ if (_silent) return;
1660
+ function dragOverEvent(name, extra) {
1661
+ pluginEvent(name, _this, _objectSpread2({
1662
+ evt: evt,
1663
+ isOwner: isOwner,
1664
+ axis: vertical ? 'vertical' : 'horizontal',
1665
+ revert: revert,
1666
+ dragRect: dragRect,
1667
+ targetRect: targetRect,
1668
+ canSort: canSort,
1669
+ fromSortable: fromSortable,
1670
+ target: target,
1671
+ completed: completed,
1672
+ onMove: function onMove(target, after) {
1673
+ return _onMove(rootEl, el, dragEl, dragRect, target, getRect(target), evt, after);
1674
+ },
1675
+ changed: changed
1676
+ }, extra));
1677
+ }
1678
+
1679
+ // Capture animation state
1680
+ function capture() {
1681
+ dragOverEvent('dragOverAnimationCapture');
1682
+ _this.captureAnimationState();
1683
+ if (_this !== fromSortable) {
1684
+ fromSortable.captureAnimationState();
1685
+ }
1686
+ }
1687
+
1688
+ // Return invocation when dragEl is inserted (or completed)
1689
+ function completed(insertion) {
1690
+ dragOverEvent('dragOverCompleted', {
1691
+ insertion: insertion
1692
+ });
1693
+ if (insertion) {
1694
+ // Clones must be hidden before folding animation to capture dragRectAbsolute properly
1695
+ if (isOwner) {
1696
+ activeSortable._hideClone();
1697
+ } else {
1698
+ activeSortable._showClone(_this);
1699
+ }
1700
+ if (_this !== fromSortable) {
1701
+ // Set ghost class to new sortable's ghost class
1702
+ toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : activeSortable.options.ghostClass, false);
1703
+ toggleClass(dragEl, options.ghostClass, true);
1704
+ }
1705
+ if (putSortable !== _this && _this !== Sortable.active) {
1706
+ putSortable = _this;
1707
+ } else if (_this === Sortable.active && putSortable) {
1708
+ putSortable = null;
1709
+ }
1710
+
1711
+ // Animation
1712
+ if (fromSortable === _this) {
1713
+ _this._ignoreWhileAnimating = target;
1714
+ }
1715
+ _this.animateAll(function () {
1716
+ dragOverEvent('dragOverAnimationComplete');
1717
+ _this._ignoreWhileAnimating = null;
1718
+ });
1719
+ if (_this !== fromSortable) {
1720
+ fromSortable.animateAll();
1721
+ fromSortable._ignoreWhileAnimating = null;
1722
+ }
1723
+ }
1724
+
1725
+ // Null lastTarget if it is not inside a previously swapped element
1726
+ if (target === dragEl && !dragEl.animated || target === el && !target.animated) {
1727
+ lastTarget = null;
1728
+ }
1729
+
1730
+ // no bubbling and not fallback
1731
+ if (!options.dragoverBubble && !evt.rootEl && target !== document) {
1732
+ dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
1733
+
1734
+ // Do not detect for empty insert if already inserted
1735
+ !insertion && nearestEmptyInsertDetectEvent(evt);
1736
+ }
1737
+ !options.dragoverBubble && evt.stopPropagation && evt.stopPropagation();
1738
+ return completedFired = true;
1739
+ }
1740
+
1741
+ // Call when dragEl has been inserted
1742
+ function changed() {
1743
+ newIndex = index(dragEl);
1744
+ newDraggableIndex = index(dragEl, options.draggable);
1745
+ _dispatchEvent({
1746
+ sortable: _this,
1747
+ name: 'change',
1748
+ toEl: el,
1749
+ newIndex: newIndex,
1750
+ newDraggableIndex: newDraggableIndex,
1751
+ originalEvent: evt
1752
+ });
1753
+ }
1754
+ if (evt.preventDefault !== void 0) {
1755
+ evt.cancelable && evt.preventDefault();
1756
+ }
1757
+ target = closest(target, options.draggable, el, true);
1758
+ dragOverEvent('dragOver');
1759
+ if (Sortable.eventCanceled) return completedFired;
1760
+ if (dragEl.contains(evt.target) || target.animated && target.animatingX && target.animatingY || _this._ignoreWhileAnimating === target) {
1761
+ return completed(false);
1762
+ }
1763
+ ignoreNextClick = false;
1764
+ if (activeSortable && !options.disabled && (isOwner ? canSort || (revert = parentEl !== rootEl) // Reverting item into the original list
1765
+ : putSortable === this || (this.lastPutMode = activeGroup.checkPull(this, activeSortable, dragEl, evt)) && group.checkPut(this, activeSortable, dragEl, evt))) {
1766
+ vertical = this._getDirection(evt, target) === 'vertical';
1767
+ dragRect = getRect(dragEl);
1768
+ dragOverEvent('dragOverValid');
1769
+ if (Sortable.eventCanceled) return completedFired;
1770
+ if (revert) {
1771
+ parentEl = rootEl; // actualization
1772
+ capture();
1773
+ this._hideClone();
1774
+ dragOverEvent('revert');
1775
+ if (!Sortable.eventCanceled) {
1776
+ if (nextEl) {
1777
+ rootEl.insertBefore(dragEl, nextEl);
1778
+ } else {
1779
+ rootEl.appendChild(dragEl);
1780
+ }
1781
+ }
1782
+ return completed(true);
1783
+ }
1784
+ var elLastChild = lastChild(el, options.draggable);
1785
+ if (!elLastChild || _ghostIsLast(evt, vertical, this) && !elLastChild.animated) {
1786
+ // Insert to end of list
1787
+
1788
+ // If already at end of list: Do not insert
1789
+ if (elLastChild === dragEl) {
1790
+ return completed(false);
1791
+ }
1792
+
1793
+ // if there is a last element, it is the target
1794
+ if (elLastChild && el === evt.target) {
1795
+ target = elLastChild;
1796
+ }
1797
+ if (target) {
1798
+ targetRect = getRect(target);
1799
+ }
1800
+ if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, !!target) !== false) {
1801
+ capture();
1802
+ if (elLastChild && elLastChild.nextSibling) {
1803
+ // the last draggable element is not the last node
1804
+ el.insertBefore(dragEl, elLastChild.nextSibling);
1805
+ } else {
1806
+ el.appendChild(dragEl);
1807
+ }
1808
+ parentEl = el; // actualization
1809
+
1810
+ changed();
1811
+ return completed(true);
1812
+ }
1813
+ } else if (elLastChild && _ghostIsFirst(evt, vertical, this)) {
1814
+ // Insert to start of list
1815
+ var firstChild = getChild(el, 0, options, true);
1816
+ if (firstChild === dragEl) {
1817
+ return completed(false);
1818
+ }
1819
+ target = firstChild;
1820
+ targetRect = getRect(target);
1821
+ if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, false) !== false) {
1822
+ capture();
1823
+ el.insertBefore(dragEl, firstChild);
1824
+ parentEl = el; // actualization
1825
+
1826
+ changed();
1827
+ return completed(true);
1828
+ }
1829
+ } else if (target.parentNode === el) {
1830
+ targetRect = getRect(target);
1831
+ var direction = 0,
1832
+ targetBeforeFirstSwap,
1833
+ differentLevel = dragEl.parentNode !== el,
1834
+ differentRowCol = !_dragElInRowColumn(dragEl.animated && dragEl.toRect || dragRect, target.animated && target.toRect || targetRect, vertical),
1835
+ side1 = vertical ? 'top' : 'left',
1836
+ scrolledPastTop = isScrolledPast(target, 'top', 'top') || isScrolledPast(dragEl, 'top', 'top'),
1837
+ scrollBefore = scrolledPastTop ? scrolledPastTop.scrollTop : void 0;
1838
+ if (lastTarget !== target) {
1839
+ targetBeforeFirstSwap = targetRect[side1];
1840
+ pastFirstInvertThresh = false;
1841
+ isCircumstantialInvert = !differentRowCol && options.invertSwap || differentLevel;
1842
+ }
1843
+ direction = _getSwapDirection(evt, target, targetRect, vertical, differentRowCol ? 1 : options.swapThreshold, options.invertedSwapThreshold == null ? options.swapThreshold : options.invertedSwapThreshold, isCircumstantialInvert, lastTarget === target);
1844
+ var sibling;
1845
+ if (direction !== 0) {
1846
+ // Check if target is beside dragEl in respective direction (ignoring hidden elements)
1847
+ var dragIndex = index(dragEl);
1848
+ do {
1849
+ dragIndex -= direction;
1850
+ sibling = parentEl.children[dragIndex];
1851
+ } while (sibling && (css(sibling, 'display') === 'none' || sibling === ghostEl));
1852
+ }
1853
+ // If dragEl is already beside target: Do not insert
1854
+ if (direction === 0 || sibling === target) {
1855
+ return completed(false);
1856
+ }
1857
+ lastTarget = target;
1858
+ lastDirection = direction;
1859
+ var nextSibling = target.nextElementSibling,
1860
+ after = false;
1861
+ after = direction === 1;
1862
+ var moveVector = _onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, after);
1863
+ if (moveVector !== false) {
1864
+ if (moveVector === 1 || moveVector === -1) {
1865
+ after = moveVector === 1;
1866
+ }
1867
+ _silent = true;
1868
+ setTimeout(_unsilent, 30);
1869
+ capture();
1870
+ if (after && !nextSibling) {
1871
+ el.appendChild(dragEl);
1872
+ } else {
1873
+ target.parentNode.insertBefore(dragEl, after ? nextSibling : target);
1874
+ }
1875
+
1876
+ // Undo chrome's scroll adjustment (has no effect on other browsers)
1877
+ if (scrolledPastTop) {
1878
+ scrollBy(scrolledPastTop, 0, scrollBefore - scrolledPastTop.scrollTop);
1879
+ }
1880
+ parentEl = dragEl.parentNode; // actualization
1881
+
1882
+ // must be done before animation
1883
+ if (targetBeforeFirstSwap !== undefined && !isCircumstantialInvert) {
1884
+ targetMoveDistance = Math.abs(targetBeforeFirstSwap - getRect(target)[side1]);
1885
+ }
1886
+ changed();
1887
+ return completed(true);
1888
+ }
1889
+ }
1890
+ if (el.contains(dragEl)) {
1891
+ return completed(false);
1892
+ }
1893
+ }
1894
+ return false;
1895
+ },
1896
+ _ignoreWhileAnimating: null,
1897
+ _offMoveEvents: function _offMoveEvents() {
1898
+ off(document, 'mousemove', this._onTouchMove);
1899
+ off(document, 'touchmove', this._onTouchMove);
1900
+ off(document, 'pointermove', this._onTouchMove);
1901
+ off(document, 'dragover', nearestEmptyInsertDetectEvent);
1902
+ off(document, 'mousemove', nearestEmptyInsertDetectEvent);
1903
+ off(document, 'touchmove', nearestEmptyInsertDetectEvent);
1904
+ },
1905
+ _offUpEvents: function _offUpEvents() {
1906
+ var ownerDocument = this.el.ownerDocument;
1907
+ off(ownerDocument, 'mouseup', this._onDrop);
1908
+ off(ownerDocument, 'touchend', this._onDrop);
1909
+ off(ownerDocument, 'pointerup', this._onDrop);
1910
+ off(ownerDocument, 'pointercancel', this._onDrop);
1911
+ off(ownerDocument, 'touchcancel', this._onDrop);
1912
+ off(document, 'selectstart', this);
1913
+ },
1914
+ _onDrop: function _onDrop( /**Event*/evt) {
1915
+ var el = this.el,
1916
+ options = this.options;
1917
+
1918
+ // Get the index of the dragged element within its parent
1919
+ newIndex = index(dragEl);
1920
+ newDraggableIndex = index(dragEl, options.draggable);
1921
+ pluginEvent('drop', this, {
1922
+ evt: evt
1923
+ });
1924
+ parentEl = dragEl && dragEl.parentNode;
1925
+
1926
+ // Get again after plugin event
1927
+ newIndex = index(dragEl);
1928
+ newDraggableIndex = index(dragEl, options.draggable);
1929
+ if (Sortable.eventCanceled) {
1930
+ this._nulling();
1931
+ return;
1932
+ }
1933
+ awaitingDragStarted = false;
1934
+ isCircumstantialInvert = false;
1935
+ pastFirstInvertThresh = false;
1936
+ clearInterval(this._loopId);
1937
+ clearTimeout(this._dragStartTimer);
1938
+ _cancelNextTick(this.cloneId);
1939
+ _cancelNextTick(this._dragStartId);
1940
+
1941
+ // Unbind events
1942
+ if (this.nativeDraggable) {
1943
+ off(document, 'drop', this);
1944
+ off(el, 'dragstart', this._onDragStart);
1945
+ }
1946
+ this._offMoveEvents();
1947
+ this._offUpEvents();
1948
+ if (Safari) {
1949
+ css(document.body, 'user-select', '');
1950
+ }
1951
+ css(dragEl, 'transform', '');
1952
+ if (evt) {
1953
+ if (moved) {
1954
+ evt.cancelable && evt.preventDefault();
1955
+ !options.dropBubble && evt.stopPropagation();
1956
+ }
1957
+ ghostEl && ghostEl.parentNode && ghostEl.parentNode.removeChild(ghostEl);
1958
+ if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== 'clone') {
1959
+ // Remove clone(s)
1960
+ cloneEl && cloneEl.parentNode && cloneEl.parentNode.removeChild(cloneEl);
1961
+ }
1962
+ if (dragEl) {
1963
+ if (this.nativeDraggable) {
1964
+ off(dragEl, 'dragend', this);
1965
+ }
1966
+ _disableDraggable(dragEl);
1967
+ dragEl.style['will-change'] = '';
1968
+
1969
+ // Remove classes
1970
+ // ghostClass is added in dragStarted
1971
+ if (moved && !awaitingDragStarted) {
1972
+ toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : this.options.ghostClass, false);
1973
+ }
1974
+ toggleClass(dragEl, this.options.chosenClass, false);
1975
+
1976
+ // Drag stop event
1977
+ _dispatchEvent({
1978
+ sortable: this,
1979
+ name: 'unchoose',
1980
+ toEl: parentEl,
1981
+ newIndex: null,
1982
+ newDraggableIndex: null,
1983
+ originalEvent: evt
1984
+ });
1985
+ if (rootEl !== parentEl) {
1986
+ if (newIndex >= 0) {
1987
+ // Add event
1988
+ _dispatchEvent({
1989
+ rootEl: parentEl,
1990
+ name: 'add',
1991
+ toEl: parentEl,
1992
+ fromEl: rootEl,
1993
+ originalEvent: evt
1994
+ });
1995
+
1996
+ // Remove event
1997
+ _dispatchEvent({
1998
+ sortable: this,
1999
+ name: 'remove',
2000
+ toEl: parentEl,
2001
+ originalEvent: evt
2002
+ });
2003
+
2004
+ // drag from one list and drop into another
2005
+ _dispatchEvent({
2006
+ rootEl: parentEl,
2007
+ name: 'sort',
2008
+ toEl: parentEl,
2009
+ fromEl: rootEl,
2010
+ originalEvent: evt
2011
+ });
2012
+ _dispatchEvent({
2013
+ sortable: this,
2014
+ name: 'sort',
2015
+ toEl: parentEl,
2016
+ originalEvent: evt
2017
+ });
2018
+ }
2019
+ putSortable && putSortable.save();
2020
+ } else {
2021
+ if (newIndex !== oldIndex) {
2022
+ if (newIndex >= 0) {
2023
+ // drag & drop within the same list
2024
+ _dispatchEvent({
2025
+ sortable: this,
2026
+ name: 'update',
2027
+ toEl: parentEl,
2028
+ originalEvent: evt
2029
+ });
2030
+ _dispatchEvent({
2031
+ sortable: this,
2032
+ name: 'sort',
2033
+ toEl: parentEl,
2034
+ originalEvent: evt
2035
+ });
2036
+ }
2037
+ }
2038
+ }
2039
+ if (Sortable.active) {
2040
+ /* jshint eqnull:true */
2041
+ if (newIndex == null || newIndex === -1) {
2042
+ newIndex = oldIndex;
2043
+ newDraggableIndex = oldDraggableIndex;
2044
+ }
2045
+ _dispatchEvent({
2046
+ sortable: this,
2047
+ name: 'end',
2048
+ toEl: parentEl,
2049
+ originalEvent: evt
2050
+ });
2051
+
2052
+ // Save sorting
2053
+ this.save();
2054
+ }
2055
+ }
2056
+ }
2057
+ this._nulling();
2058
+ },
2059
+ _nulling: function _nulling() {
2060
+ pluginEvent('nulling', this);
2061
+ 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;
2062
+ savedInputChecked.forEach(function (el) {
2063
+ el.checked = true;
2064
+ });
2065
+ savedInputChecked.length = lastDx = lastDy = 0;
2066
+ },
2067
+ handleEvent: function handleEvent( /**Event*/evt) {
2068
+ switch (evt.type) {
2069
+ case 'drop':
2070
+ case 'dragend':
2071
+ this._onDrop(evt);
2072
+ break;
2073
+ case 'dragenter':
2074
+ case 'dragover':
2075
+ if (dragEl) {
2076
+ this._onDragOver(evt);
2077
+ _globalDragOver(evt);
2078
+ }
2079
+ break;
2080
+ case 'selectstart':
2081
+ evt.preventDefault();
2082
+ break;
2083
+ }
2084
+ },
2085
+ /**
2086
+ * Serializes the item into an array of string.
2087
+ * @returns {String[]}
2088
+ */
2089
+ toArray: function toArray() {
2090
+ var order = [],
2091
+ el,
2092
+ children = this.el.children,
2093
+ i = 0,
2094
+ n = children.length,
2095
+ options = this.options;
2096
+ for (; i < n; i++) {
2097
+ el = children[i];
2098
+ if (closest(el, options.draggable, this.el, false)) {
2099
+ order.push(el.getAttribute(options.dataIdAttr) || _generateId(el));
2100
+ }
2101
+ }
2102
+ return order;
2103
+ },
2104
+ /**
2105
+ * Sorts the elements according to the array.
2106
+ * @param {String[]} order order of the items
2107
+ */
2108
+ sort: function sort(order, useAnimation) {
2109
+ var items = {},
2110
+ rootEl = this.el;
2111
+ this.toArray().forEach(function (id, i) {
2112
+ var el = rootEl.children[i];
2113
+ if (closest(el, this.options.draggable, rootEl, false)) {
2114
+ items[id] = el;
2115
+ }
2116
+ }, this);
2117
+ useAnimation && this.captureAnimationState();
2118
+ order.forEach(function (id) {
2119
+ if (items[id]) {
2120
+ rootEl.removeChild(items[id]);
2121
+ rootEl.appendChild(items[id]);
2122
+ }
2123
+ });
2124
+ useAnimation && this.animateAll();
2125
+ },
2126
+ /**
2127
+ * Save the current sorting
2128
+ */
2129
+ save: function save() {
2130
+ var store = this.options.store;
2131
+ store && store.set && store.set(this);
2132
+ },
2133
+ /**
2134
+ * 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.
2135
+ * @param {HTMLElement} el
2136
+ * @param {String} [selector] default: `options.draggable`
2137
+ * @returns {HTMLElement|null}
2138
+ */
2139
+ closest: function closest$1(el, selector) {
2140
+ return closest(el, selector || this.options.draggable, this.el, false);
2141
+ },
2142
+ /**
2143
+ * Set/get option
2144
+ * @param {string} name
2145
+ * @param {*} [value]
2146
+ * @returns {*}
2147
+ */
2148
+ option: function option(name, value) {
2149
+ var options = this.options;
2150
+ if (value === void 0) {
2151
+ return options[name];
2152
+ } else {
2153
+ var modifiedValue = PluginManager.modifyOption(this, name, value);
2154
+ if (typeof modifiedValue !== 'undefined') {
2155
+ options[name] = modifiedValue;
2156
+ } else {
2157
+ options[name] = value;
2158
+ }
2159
+ if (name === 'group') {
2160
+ _prepareGroup(options);
2161
+ }
2162
+ }
2163
+ },
2164
+ /**
2165
+ * Destroy
2166
+ */
2167
+ destroy: function destroy() {
2168
+ pluginEvent('destroy', this);
2169
+ var el = this.el;
2170
+ el[expando] = null;
2171
+ off(el, 'mousedown', this._onTapStart);
2172
+ off(el, 'touchstart', this._onTapStart);
2173
+ off(el, 'pointerdown', this._onTapStart);
2174
+ if (this.nativeDraggable) {
2175
+ off(el, 'dragover', this);
2176
+ off(el, 'dragenter', this);
2177
+ }
2178
+ // Remove draggable attributes
2179
+ Array.prototype.forEach.call(el.querySelectorAll('[draggable]'), function (el) {
2180
+ el.removeAttribute('draggable');
2181
+ });
2182
+ this._onDrop();
2183
+ this._disableDelayedDragEvents();
2184
+ sortables.splice(sortables.indexOf(this.el), 1);
2185
+ this.el = el = null;
2186
+ },
2187
+ _hideClone: function _hideClone() {
2188
+ if (!cloneHidden) {
2189
+ pluginEvent('hideClone', this);
2190
+ if (Sortable.eventCanceled) return;
2191
+ css(cloneEl, 'display', 'none');
2192
+ if (this.options.removeCloneOnHide && cloneEl.parentNode) {
2193
+ cloneEl.parentNode.removeChild(cloneEl);
2194
+ }
2195
+ cloneHidden = true;
2196
+ }
2197
+ },
2198
+ _showClone: function _showClone(putSortable) {
2199
+ if (putSortable.lastPutMode !== 'clone') {
2200
+ this._hideClone();
2201
+ return;
2202
+ }
2203
+ if (cloneHidden) {
2204
+ pluginEvent('showClone', this);
2205
+ if (Sortable.eventCanceled) return;
2206
+
2207
+ // show clone at dragEl or original position
2208
+ if (dragEl.parentNode == rootEl && !this.options.group.revertClone) {
2209
+ rootEl.insertBefore(cloneEl, dragEl);
2210
+ } else if (nextEl) {
2211
+ rootEl.insertBefore(cloneEl, nextEl);
2212
+ } else {
2213
+ rootEl.appendChild(cloneEl);
2214
+ }
2215
+ if (this.options.group.revertClone) {
2216
+ this.animate(dragEl, cloneEl);
2217
+ }
2218
+ css(cloneEl, 'display', '');
2219
+ cloneHidden = false;
2220
+ }
2221
+ }
2222
+ };
2223
+ function _globalDragOver( /**Event*/evt) {
2224
+ if (evt.dataTransfer) {
2225
+ evt.dataTransfer.dropEffect = 'move';
2226
+ }
2227
+ evt.cancelable && evt.preventDefault();
2228
+ }
2229
+ function _onMove(fromEl, toEl, dragEl, dragRect, targetEl, targetRect, originalEvent, willInsertAfter) {
2230
+ var evt,
2231
+ sortable = fromEl[expando],
2232
+ onMoveFn = sortable.options.onMove,
2233
+ retVal;
2234
+ // Support for new CustomEvent feature
2235
+ if (window.CustomEvent && !IE11OrLess && !Edge) {
2236
+ evt = new CustomEvent('move', {
2237
+ bubbles: true,
2238
+ cancelable: true
2239
+ });
2240
+ } else {
2241
+ evt = document.createEvent('Event');
2242
+ evt.initEvent('move', true, true);
2243
+ }
2244
+ evt.to = toEl;
2245
+ evt.from = fromEl;
2246
+ evt.dragged = dragEl;
2247
+ evt.draggedRect = dragRect;
2248
+ evt.related = targetEl || toEl;
2249
+ evt.relatedRect = targetRect || getRect(toEl);
2250
+ evt.willInsertAfter = willInsertAfter;
2251
+ evt.originalEvent = originalEvent;
2252
+ fromEl.dispatchEvent(evt);
2253
+ if (onMoveFn) {
2254
+ retVal = onMoveFn.call(sortable, evt, originalEvent);
2255
+ }
2256
+ return retVal;
2257
+ }
2258
+ function _disableDraggable(el) {
2259
+ el.draggable = false;
2260
+ }
2261
+ function _unsilent() {
2262
+ _silent = false;
2263
+ }
2264
+ function _ghostIsFirst(evt, vertical, sortable) {
2265
+ var firstElRect = getRect(getChild(sortable.el, 0, sortable.options, true));
2266
+ var childContainingRect = getChildContainingRectFromElement(sortable.el, sortable.options, ghostEl);
2267
+ var spacer = 10;
2268
+ 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;
2269
+ }
2270
+ function _ghostIsLast(evt, vertical, sortable) {
2271
+ var lastElRect = getRect(lastChild(sortable.el, sortable.options.draggable));
2272
+ var childContainingRect = getChildContainingRectFromElement(sortable.el, sortable.options, ghostEl);
2273
+ var spacer = 10;
2274
+ 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;
2275
+ }
2276
+ function _getSwapDirection(evt, target, targetRect, vertical, swapThreshold, invertedSwapThreshold, invertSwap, isLastTarget) {
2277
+ var mouseOnAxis = vertical ? evt.clientY : evt.clientX,
2278
+ targetLength = vertical ? targetRect.height : targetRect.width,
2279
+ targetS1 = vertical ? targetRect.top : targetRect.left,
2280
+ targetS2 = vertical ? targetRect.bottom : targetRect.right,
2281
+ invert = false;
2282
+ if (!invertSwap) {
2283
+ // Never invert or create dragEl shadow when target movemenet causes mouse to move past the end of regular swapThreshold
2284
+ if (isLastTarget && targetMoveDistance < targetLength * swapThreshold) {
2285
+ // multiplied only by swapThreshold because mouse will already be inside target by (1 - threshold) * targetLength / 2
2286
+ // check if past first invert threshold on side opposite of lastDirection
2287
+ if (!pastFirstInvertThresh && (lastDirection === 1 ? mouseOnAxis > targetS1 + targetLength * invertedSwapThreshold / 2 : mouseOnAxis < targetS2 - targetLength * invertedSwapThreshold / 2)) {
2288
+ // past first invert threshold, do not restrict inverted threshold to dragEl shadow
2289
+ pastFirstInvertThresh = true;
2290
+ }
2291
+ if (!pastFirstInvertThresh) {
2292
+ // dragEl shadow (target move distance shadow)
2293
+ if (lastDirection === 1 ? mouseOnAxis < targetS1 + targetMoveDistance // over dragEl shadow
2294
+ : mouseOnAxis > targetS2 - targetMoveDistance) {
2295
+ return -lastDirection;
2296
+ }
2297
+ } else {
2298
+ invert = true;
2299
+ }
2300
+ } else {
2301
+ // Regular
2302
+ if (mouseOnAxis > targetS1 + targetLength * (1 - swapThreshold) / 2 && mouseOnAxis < targetS2 - targetLength * (1 - swapThreshold) / 2) {
2303
+ return _getInsertDirection(target);
2304
+ }
2305
+ }
2306
+ }
2307
+ invert = invert || invertSwap;
2308
+ if (invert) {
2309
+ // Invert of regular
2310
+ if (mouseOnAxis < targetS1 + targetLength * invertedSwapThreshold / 2 || mouseOnAxis > targetS2 - targetLength * invertedSwapThreshold / 2) {
2311
+ return mouseOnAxis > targetS1 + targetLength / 2 ? 1 : -1;
2312
+ }
2313
+ }
2314
+ return 0;
2315
+ }
2316
+
2317
+ /**
2318
+ * Gets the direction dragEl must be swapped relative to target in order to make it
2319
+ * seem that dragEl has been "inserted" into that element's position
2320
+ * @param {HTMLElement} target The target whose position dragEl is being inserted at
2321
+ * @return {Number} Direction dragEl must be swapped
2322
+ */
2323
+ function _getInsertDirection(target) {
2324
+ if (index(dragEl) < index(target)) {
2325
+ return 1;
2326
+ } else {
2327
+ return -1;
2328
+ }
2329
+ }
2330
+
2331
+ /**
2332
+ * Generate id
2333
+ * @param {HTMLElement} el
2334
+ * @returns {String}
2335
+ * @private
2336
+ */
2337
+ function _generateId(el) {
2338
+ var str = el.tagName + el.className + el.src + el.href + el.textContent,
2339
+ i = str.length,
2340
+ sum = 0;
2341
+ while (i--) {
2342
+ sum += str.charCodeAt(i);
2343
+ }
2344
+ return sum.toString(36);
2345
+ }
2346
+ function _saveInputCheckedState(root) {
2347
+ savedInputChecked.length = 0;
2348
+ var inputs = root.getElementsByTagName('input');
2349
+ var idx = inputs.length;
2350
+ while (idx--) {
2351
+ var el = inputs[idx];
2352
+ el.checked && savedInputChecked.push(el);
2353
+ }
2354
+ }
2355
+ function _nextTick(fn) {
2356
+ return setTimeout(fn, 0);
2357
+ }
2358
+ function _cancelNextTick(id) {
2359
+ return clearTimeout(id);
2360
+ }
2361
+
2362
+ // Fixed #973:
2363
+ if (documentExists) {
2364
+ on(document, 'touchmove', function (evt) {
2365
+ if ((Sortable.active || awaitingDragStarted) && evt.cancelable) {
2366
+ evt.preventDefault();
2367
+ }
2368
+ });
2369
+ }
2370
+
2371
+ // Export utils
2372
+ Sortable.utils = {
2373
+ on: on,
2374
+ off: off,
2375
+ css: css,
2376
+ find: find,
2377
+ is: function is(el, selector) {
2378
+ return !!closest(el, selector, el, false);
2379
+ },
2380
+ extend: extend,
2381
+ throttle: throttle,
2382
+ closest: closest,
2383
+ toggleClass: toggleClass,
2384
+ clone: clone,
2385
+ index: index,
2386
+ nextTick: _nextTick,
2387
+ cancelNextTick: _cancelNextTick,
2388
+ detectDirection: _detectDirection,
2389
+ getChild: getChild,
2390
+ expando: expando
2391
+ };
2392
+
2393
+ /**
2394
+ * Get the Sortable instance of an element
2395
+ * @param {HTMLElement} element The element
2396
+ * @return {Sortable|undefined} The instance of Sortable
2397
+ */
2398
+ Sortable.get = function (element) {
2399
+ return element[expando];
2400
+ };
2401
+
2402
+ /**
2403
+ * Mount a plugin to Sortable
2404
+ * @param {...SortablePlugin|SortablePlugin[]} plugins Plugins being mounted
2405
+ */
2406
+ Sortable.mount = function () {
2407
+ for (var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++) {
2408
+ plugins[_key] = arguments[_key];
2409
+ }
2410
+ if (plugins[0].constructor === Array) plugins = plugins[0];
2411
+ plugins.forEach(function (plugin) {
2412
+ if (!plugin.prototype || !plugin.prototype.constructor) {
2413
+ throw "Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(plugin));
2414
+ }
2415
+ if (plugin.utils) Sortable.utils = _objectSpread2(_objectSpread2({}, Sortable.utils), plugin.utils);
2416
+ PluginManager.mount(plugin);
2417
+ });
2418
+ };
2419
+
2420
+ /**
2421
+ * Create sortable instance
2422
+ * @param {HTMLElement} el
2423
+ * @param {Object} [options]
2424
+ */
2425
+ Sortable.create = function (el, options) {
2426
+ return new Sortable(el, options);
2427
+ };
2428
+
2429
+ // Export
2430
+ Sortable.version = version;
2431
+
2432
+ var autoScrolls = [],
2433
+ scrollEl,
2434
+ scrollRootEl,
2435
+ scrolling = false,
2436
+ lastAutoScrollX,
2437
+ lastAutoScrollY,
2438
+ touchEvt$1,
2439
+ pointerElemChangedInterval;
2440
+ function AutoScrollPlugin() {
2441
+ function AutoScroll() {
2442
+ this.defaults = {
2443
+ scroll: true,
2444
+ forceAutoScrollFallback: false,
2445
+ scrollSensitivity: 30,
2446
+ scrollSpeed: 10,
2447
+ bubbleScroll: true
2448
+ };
2449
+
2450
+ // Bind all private methods
2451
+ for (var fn in this) {
2452
+ if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
2453
+ this[fn] = this[fn].bind(this);
2454
+ }
2455
+ }
2456
+ }
2457
+ AutoScroll.prototype = {
2458
+ dragStarted: function dragStarted(_ref) {
2459
+ var originalEvent = _ref.originalEvent;
2460
+ if (this.sortable.nativeDraggable) {
2461
+ on(document, 'dragover', this._handleAutoScroll);
2462
+ } else {
2463
+ if (this.options.supportPointer) {
2464
+ on(document, 'pointermove', this._handleFallbackAutoScroll);
2465
+ } else if (originalEvent.touches) {
2466
+ on(document, 'touchmove', this._handleFallbackAutoScroll);
2467
+ } else {
2468
+ on(document, 'mousemove', this._handleFallbackAutoScroll);
2469
+ }
2470
+ }
2471
+ },
2472
+ dragOverCompleted: function dragOverCompleted(_ref2) {
2473
+ var originalEvent = _ref2.originalEvent;
2474
+ // For when bubbling is canceled and using fallback (fallback 'touchmove' always reached)
2475
+ if (!this.options.dragOverBubble && !originalEvent.rootEl) {
2476
+ this._handleAutoScroll(originalEvent);
2477
+ }
2478
+ },
2479
+ drop: function drop() {
2480
+ if (this.sortable.nativeDraggable) {
2481
+ off(document, 'dragover', this._handleAutoScroll);
2482
+ } else {
2483
+ off(document, 'pointermove', this._handleFallbackAutoScroll);
2484
+ off(document, 'touchmove', this._handleFallbackAutoScroll);
2485
+ off(document, 'mousemove', this._handleFallbackAutoScroll);
2486
+ }
2487
+ clearPointerElemChangedInterval();
2488
+ clearAutoScrolls();
2489
+ cancelThrottle();
2490
+ },
2491
+ nulling: function nulling() {
2492
+ touchEvt$1 = scrollRootEl = scrollEl = scrolling = pointerElemChangedInterval = lastAutoScrollX = lastAutoScrollY = null;
2493
+ autoScrolls.length = 0;
2494
+ },
2495
+ _handleFallbackAutoScroll: function _handleFallbackAutoScroll(evt) {
2496
+ this._handleAutoScroll(evt, true);
2497
+ },
2498
+ _handleAutoScroll: function _handleAutoScroll(evt, fallback) {
2499
+ var _this = this;
2500
+ var x = (evt.touches ? evt.touches[0] : evt).clientX,
2501
+ y = (evt.touches ? evt.touches[0] : evt).clientY,
2502
+ elem = document.elementFromPoint(x, y);
2503
+ touchEvt$1 = evt;
2504
+
2505
+ // IE does not seem to have native autoscroll,
2506
+ // Edge's autoscroll seems too conditional,
2507
+ // MACOS Safari does not have autoscroll,
2508
+ // Firefox and Chrome are good
2509
+ if (fallback || this.options.forceAutoScrollFallback || Edge || IE11OrLess || Safari) {
2510
+ autoScroll(evt, this.options, elem, fallback);
2511
+
2512
+ // Listener for pointer element change
2513
+ var ogElemScroller = getParentAutoScrollElement(elem, true);
2514
+ if (scrolling && (!pointerElemChangedInterval || x !== lastAutoScrollX || y !== lastAutoScrollY)) {
2515
+ pointerElemChangedInterval && clearPointerElemChangedInterval();
2516
+ // Detect for pointer elem change, emulating native DnD behaviour
2517
+ pointerElemChangedInterval = setInterval(function () {
2518
+ var newElem = getParentAutoScrollElement(document.elementFromPoint(x, y), true);
2519
+ if (newElem !== ogElemScroller) {
2520
+ ogElemScroller = newElem;
2521
+ clearAutoScrolls();
2522
+ }
2523
+ autoScroll(evt, _this.options, newElem, fallback);
2524
+ }, 10);
2525
+ lastAutoScrollX = x;
2526
+ lastAutoScrollY = y;
2527
+ }
2528
+ } else {
2529
+ // if DnD is enabled (and browser has good autoscrolling), first autoscroll will already scroll, so get parent autoscroll of first autoscroll
2530
+ if (!this.options.bubbleScroll || getParentAutoScrollElement(elem, true) === getWindowScrollingElement()) {
2531
+ clearAutoScrolls();
2532
+ return;
2533
+ }
2534
+ autoScroll(evt, this.options, getParentAutoScrollElement(elem, false), false);
2535
+ }
2536
+ }
2537
+ };
2538
+ return _extends(AutoScroll, {
2539
+ pluginName: 'scroll',
2540
+ initializeByDefault: true
2541
+ });
2542
+ }
2543
+ function clearAutoScrolls() {
2544
+ autoScrolls.forEach(function (autoScroll) {
2545
+ clearInterval(autoScroll.pid);
2546
+ });
2547
+ autoScrolls = [];
2548
+ }
2549
+ function clearPointerElemChangedInterval() {
2550
+ clearInterval(pointerElemChangedInterval);
2551
+ }
2552
+ var autoScroll = throttle(function (evt, options, rootEl, isFallback) {
2553
+ // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=505521
2554
+ if (!options.scroll) return;
2555
+ var x = (evt.touches ? evt.touches[0] : evt).clientX,
2556
+ y = (evt.touches ? evt.touches[0] : evt).clientY,
2557
+ sens = options.scrollSensitivity,
2558
+ speed = options.scrollSpeed,
2559
+ winScroller = getWindowScrollingElement();
2560
+ var scrollThisInstance = false,
2561
+ scrollCustomFn;
2562
+
2563
+ // New scroll root, set scrollEl
2564
+ if (scrollRootEl !== rootEl) {
2565
+ scrollRootEl = rootEl;
2566
+ clearAutoScrolls();
2567
+ scrollEl = options.scroll;
2568
+ scrollCustomFn = options.scrollFn;
2569
+ if (scrollEl === true) {
2570
+ scrollEl = getParentAutoScrollElement(rootEl, true);
2571
+ }
2572
+ }
2573
+ var layersOut = 0;
2574
+ var currentParent = scrollEl;
2575
+ do {
2576
+ var el = currentParent,
2577
+ rect = getRect(el),
2578
+ top = rect.top,
2579
+ bottom = rect.bottom,
2580
+ left = rect.left,
2581
+ right = rect.right,
2582
+ width = rect.width,
2583
+ height = rect.height,
2584
+ canScrollX = void 0,
2585
+ canScrollY = void 0,
2586
+ scrollWidth = el.scrollWidth,
2587
+ scrollHeight = el.scrollHeight,
2588
+ elCSS = css(el),
2589
+ scrollPosX = el.scrollLeft,
2590
+ scrollPosY = el.scrollTop;
2591
+ if (el === winScroller) {
2592
+ canScrollX = width < scrollWidth && (elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll' || elCSS.overflowX === 'visible');
2593
+ canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll' || elCSS.overflowY === 'visible');
2594
+ } else {
2595
+ canScrollX = width < scrollWidth && (elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll');
2596
+ canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll');
2597
+ }
2598
+ var vx = canScrollX && (Math.abs(right - x) <= sens && scrollPosX + width < scrollWidth) - (Math.abs(left - x) <= sens && !!scrollPosX);
2599
+ var vy = canScrollY && (Math.abs(bottom - y) <= sens && scrollPosY + height < scrollHeight) - (Math.abs(top - y) <= sens && !!scrollPosY);
2600
+ if (!autoScrolls[layersOut]) {
2601
+ for (var i = 0; i <= layersOut; i++) {
2602
+ if (!autoScrolls[i]) {
2603
+ autoScrolls[i] = {};
2604
+ }
2605
+ }
2606
+ }
2607
+ if (autoScrolls[layersOut].vx != vx || autoScrolls[layersOut].vy != vy || autoScrolls[layersOut].el !== el) {
2608
+ autoScrolls[layersOut].el = el;
2609
+ autoScrolls[layersOut].vx = vx;
2610
+ autoScrolls[layersOut].vy = vy;
2611
+ clearInterval(autoScrolls[layersOut].pid);
2612
+ if (vx != 0 || vy != 0) {
2613
+ scrollThisInstance = true;
2614
+ /* jshint loopfunc:true */
2615
+ autoScrolls[layersOut].pid = setInterval(function () {
2616
+ // emulate drag over during autoscroll (fallback), emulating native DnD behaviour
2617
+ if (isFallback && this.layer === 0) {
2618
+ Sortable.active._onTouchMove(touchEvt$1); // To move ghost if it is positioned absolutely
2619
+ }
2620
+ var scrollOffsetY = autoScrolls[this.layer].vy ? autoScrolls[this.layer].vy * speed : 0;
2621
+ var scrollOffsetX = autoScrolls[this.layer].vx ? autoScrolls[this.layer].vx * speed : 0;
2622
+ if (typeof scrollCustomFn === 'function') {
2623
+ if (scrollCustomFn.call(Sortable.dragged.parentNode[expando], scrollOffsetX, scrollOffsetY, evt, touchEvt$1, autoScrolls[this.layer].el) !== 'continue') {
2624
+ return;
2625
+ }
2626
+ }
2627
+ scrollBy(autoScrolls[this.layer].el, scrollOffsetX, scrollOffsetY);
2628
+ }.bind({
2629
+ layer: layersOut
2630
+ }), 24);
2631
+ }
2632
+ }
2633
+ layersOut++;
2634
+ } while (options.bubbleScroll && currentParent !== winScroller && (currentParent = getParentAutoScrollElement(currentParent, false)));
2635
+ scrolling = scrollThisInstance; // in case another function catches scrolling as false in between when it is not
2636
+ }, 30);
2637
+
2638
+ var drop = function drop(_ref) {
2639
+ var originalEvent = _ref.originalEvent,
2640
+ putSortable = _ref.putSortable,
2641
+ dragEl = _ref.dragEl,
2642
+ activeSortable = _ref.activeSortable,
2643
+ dispatchSortableEvent = _ref.dispatchSortableEvent,
2644
+ hideGhostForTarget = _ref.hideGhostForTarget,
2645
+ unhideGhostForTarget = _ref.unhideGhostForTarget;
2646
+ if (!originalEvent) return;
2647
+ var toSortable = putSortable || activeSortable;
2648
+ hideGhostForTarget();
2649
+ var touch = originalEvent.changedTouches && originalEvent.changedTouches.length ? originalEvent.changedTouches[0] : originalEvent;
2650
+ var target = document.elementFromPoint(touch.clientX, touch.clientY);
2651
+ unhideGhostForTarget();
2652
+ if (toSortable && !toSortable.el.contains(target)) {
2653
+ dispatchSortableEvent('spill');
2654
+ this.onSpill({
2655
+ dragEl: dragEl,
2656
+ putSortable: putSortable
2657
+ });
2658
+ }
2659
+ };
2660
+ function Revert() {}
2661
+ Revert.prototype = {
2662
+ startIndex: null,
2663
+ dragStart: function dragStart(_ref2) {
2664
+ var oldDraggableIndex = _ref2.oldDraggableIndex;
2665
+ this.startIndex = oldDraggableIndex;
2666
+ },
2667
+ onSpill: function onSpill(_ref3) {
2668
+ var dragEl = _ref3.dragEl,
2669
+ putSortable = _ref3.putSortable;
2670
+ this.sortable.captureAnimationState();
2671
+ if (putSortable) {
2672
+ putSortable.captureAnimationState();
2673
+ }
2674
+ var nextSibling = getChild(this.sortable.el, this.startIndex, this.options);
2675
+ if (nextSibling) {
2676
+ this.sortable.el.insertBefore(dragEl, nextSibling);
2677
+ } else {
2678
+ this.sortable.el.appendChild(dragEl);
2679
+ }
2680
+ this.sortable.animateAll();
2681
+ if (putSortable) {
2682
+ putSortable.animateAll();
2683
+ }
2684
+ },
2685
+ drop: drop
2686
+ };
2687
+ _extends(Revert, {
2688
+ pluginName: 'revertOnSpill'
2689
+ });
2690
+ function Remove() {}
2691
+ Remove.prototype = {
2692
+ onSpill: function onSpill(_ref4) {
2693
+ var dragEl = _ref4.dragEl,
2694
+ putSortable = _ref4.putSortable;
2695
+ var parentSortable = putSortable || this.sortable;
2696
+ parentSortable.captureAnimationState();
2697
+ dragEl.parentNode && dragEl.parentNode.removeChild(dragEl);
2698
+ parentSortable.animateAll();
2699
+ },
2700
+ drop: drop
2701
+ };
2702
+ _extends(Remove, {
2703
+ pluginName: 'removeOnSpill'
2704
+ });
2705
+
2706
+ var lastSwapEl;
2707
+ function SwapPlugin() {
2708
+ function Swap() {
2709
+ this.defaults = {
2710
+ swapClass: 'sortable-swap-highlight'
2711
+ };
2712
+ }
2713
+ Swap.prototype = {
2714
+ dragStart: function dragStart(_ref) {
2715
+ var dragEl = _ref.dragEl;
2716
+ lastSwapEl = dragEl;
2717
+ },
2718
+ dragOverValid: function dragOverValid(_ref2) {
2719
+ var completed = _ref2.completed,
2720
+ target = _ref2.target,
2721
+ onMove = _ref2.onMove,
2722
+ activeSortable = _ref2.activeSortable,
2723
+ changed = _ref2.changed,
2724
+ cancel = _ref2.cancel;
2725
+ if (!activeSortable.options.swap) return;
2726
+ var el = this.sortable.el,
2727
+ options = this.options;
2728
+ if (target && target !== el) {
2729
+ var prevSwapEl = lastSwapEl;
2730
+ if (onMove(target) !== false) {
2731
+ toggleClass(target, options.swapClass, true);
2732
+ lastSwapEl = target;
2733
+ } else {
2734
+ lastSwapEl = null;
2735
+ }
2736
+ if (prevSwapEl && prevSwapEl !== lastSwapEl) {
2737
+ toggleClass(prevSwapEl, options.swapClass, false);
2738
+ }
2739
+ }
2740
+ changed();
2741
+ completed(true);
2742
+ cancel();
2743
+ },
2744
+ drop: function drop(_ref3) {
2745
+ var activeSortable = _ref3.activeSortable,
2746
+ putSortable = _ref3.putSortable,
2747
+ dragEl = _ref3.dragEl;
2748
+ var toSortable = putSortable || this.sortable;
2749
+ var options = this.options;
2750
+ lastSwapEl && toggleClass(lastSwapEl, options.swapClass, false);
2751
+ if (lastSwapEl && (options.swap || putSortable && putSortable.options.swap)) {
2752
+ if (dragEl !== lastSwapEl) {
2753
+ toSortable.captureAnimationState();
2754
+ if (toSortable !== activeSortable) activeSortable.captureAnimationState();
2755
+ swapNodes(dragEl, lastSwapEl);
2756
+ toSortable.animateAll();
2757
+ if (toSortable !== activeSortable) activeSortable.animateAll();
2758
+ }
2759
+ }
2760
+ },
2761
+ nulling: function nulling() {
2762
+ lastSwapEl = null;
2763
+ }
2764
+ };
2765
+ return _extends(Swap, {
2766
+ pluginName: 'swap',
2767
+ eventProperties: function eventProperties() {
2768
+ return {
2769
+ swapItem: lastSwapEl
2770
+ };
2771
+ }
2772
+ });
2773
+ }
2774
+ function swapNodes(n1, n2) {
2775
+ var p1 = n1.parentNode,
2776
+ p2 = n2.parentNode,
2777
+ i1,
2778
+ i2;
2779
+ if (!p1 || !p2 || p1.isEqualNode(n2) || p2.isEqualNode(n1)) return;
2780
+ i1 = index(n1);
2781
+ i2 = index(n2);
2782
+ if (p1.isEqualNode(p2) && i1 < i2) {
2783
+ i2++;
2784
+ }
2785
+ p1.insertBefore(n2, p1.children[i1]);
2786
+ p2.insertBefore(n1, p2.children[i2]);
2787
+ }
2788
+
2789
+ var multiDragElements = [],
2790
+ multiDragClones = [],
2791
+ lastMultiDragSelect,
2792
+ // for selection with modifier key down (SHIFT)
2793
+ multiDragSortable,
2794
+ initialFolding = false,
2795
+ // Initial multi-drag fold when drag started
2796
+ folding = false,
2797
+ // Folding any other time
2798
+ dragStarted = false,
2799
+ dragEl$1,
2800
+ clonesFromRect,
2801
+ clonesHidden;
2802
+ function MultiDragPlugin() {
2803
+ function MultiDrag(sortable) {
2804
+ // Bind all private methods
2805
+ for (var fn in this) {
2806
+ if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
2807
+ this[fn] = this[fn].bind(this);
2808
+ }
2809
+ }
2810
+ if (!sortable.options.avoidImplicitDeselect) {
2811
+ if (sortable.options.supportPointer) {
2812
+ on(document, 'pointerup', this._deselectMultiDrag);
2813
+ } else {
2814
+ on(document, 'mouseup', this._deselectMultiDrag);
2815
+ on(document, 'touchend', this._deselectMultiDrag);
2816
+ }
2817
+ }
2818
+ on(document, 'keydown', this._checkKeyDown);
2819
+ on(document, 'keyup', this._checkKeyUp);
2820
+ this.defaults = {
2821
+ selectedClass: 'sortable-selected',
2822
+ multiDragKey: null,
2823
+ avoidImplicitDeselect: false,
2824
+ setData: function setData(dataTransfer, dragEl) {
2825
+ var data = '';
2826
+ if (multiDragElements.length && multiDragSortable === sortable) {
2827
+ multiDragElements.forEach(function (multiDragElement, i) {
2828
+ data += (!i ? '' : ', ') + multiDragElement.textContent;
2829
+ });
2830
+ } else {
2831
+ data = dragEl.textContent;
2832
+ }
2833
+ dataTransfer.setData('Text', data);
2834
+ }
2835
+ };
2836
+ }
2837
+ MultiDrag.prototype = {
2838
+ multiDragKeyDown: false,
2839
+ isMultiDrag: false,
2840
+ delayStartGlobal: function delayStartGlobal(_ref) {
2841
+ var dragged = _ref.dragEl;
2842
+ dragEl$1 = dragged;
2843
+ },
2844
+ delayEnded: function delayEnded() {
2845
+ this.isMultiDrag = ~multiDragElements.indexOf(dragEl$1);
2846
+ },
2847
+ setupClone: function setupClone(_ref2) {
2848
+ var sortable = _ref2.sortable,
2849
+ cancel = _ref2.cancel;
2850
+ if (!this.isMultiDrag) return;
2851
+ for (var i = 0; i < multiDragElements.length; i++) {
2852
+ multiDragClones.push(clone(multiDragElements[i]));
2853
+ multiDragClones[i].sortableIndex = multiDragElements[i].sortableIndex;
2854
+ multiDragClones[i].draggable = false;
2855
+ multiDragClones[i].style['will-change'] = '';
2856
+ toggleClass(multiDragClones[i], this.options.selectedClass, false);
2857
+ multiDragElements[i] === dragEl$1 && toggleClass(multiDragClones[i], this.options.chosenClass, false);
2858
+ }
2859
+ sortable._hideClone();
2860
+ cancel();
2861
+ },
2862
+ clone: function clone(_ref3) {
2863
+ var sortable = _ref3.sortable,
2864
+ rootEl = _ref3.rootEl,
2865
+ dispatchSortableEvent = _ref3.dispatchSortableEvent,
2866
+ cancel = _ref3.cancel;
2867
+ if (!this.isMultiDrag) return;
2868
+ if (!this.options.removeCloneOnHide) {
2869
+ if (multiDragElements.length && multiDragSortable === sortable) {
2870
+ insertMultiDragClones(true, rootEl);
2871
+ dispatchSortableEvent('clone');
2872
+ cancel();
2873
+ }
2874
+ }
2875
+ },
2876
+ showClone: function showClone(_ref4) {
2877
+ var cloneNowShown = _ref4.cloneNowShown,
2878
+ rootEl = _ref4.rootEl,
2879
+ cancel = _ref4.cancel;
2880
+ if (!this.isMultiDrag) return;
2881
+ insertMultiDragClones(false, rootEl);
2882
+ multiDragClones.forEach(function (clone) {
2883
+ css(clone, 'display', '');
2884
+ });
2885
+ cloneNowShown();
2886
+ clonesHidden = false;
2887
+ cancel();
2888
+ },
2889
+ hideClone: function hideClone(_ref5) {
2890
+ var _this = this;
2891
+ var sortable = _ref5.sortable,
2892
+ cloneNowHidden = _ref5.cloneNowHidden,
2893
+ cancel = _ref5.cancel;
2894
+ if (!this.isMultiDrag) return;
2895
+ multiDragClones.forEach(function (clone) {
2896
+ css(clone, 'display', 'none');
2897
+ if (_this.options.removeCloneOnHide && clone.parentNode) {
2898
+ clone.parentNode.removeChild(clone);
2899
+ }
2900
+ });
2901
+ cloneNowHidden();
2902
+ clonesHidden = true;
2903
+ cancel();
2904
+ },
2905
+ dragStartGlobal: function dragStartGlobal(_ref6) {
2906
+ var sortable = _ref6.sortable;
2907
+ if (!this.isMultiDrag && multiDragSortable) {
2908
+ multiDragSortable.multiDrag._deselectMultiDrag();
2909
+ }
2910
+ multiDragElements.forEach(function (multiDragElement) {
2911
+ multiDragElement.sortableIndex = index(multiDragElement);
2912
+ });
2913
+
2914
+ // Sort multi-drag elements
2915
+ multiDragElements = multiDragElements.sort(function (a, b) {
2916
+ return a.sortableIndex - b.sortableIndex;
2917
+ });
2918
+ dragStarted = true;
2919
+ },
2920
+ dragStarted: function dragStarted(_ref7) {
2921
+ var _this2 = this;
2922
+ var sortable = _ref7.sortable;
2923
+ if (!this.isMultiDrag) return;
2924
+ if (this.options.sort) {
2925
+ // Capture rects,
2926
+ // hide multi drag elements (by positioning them absolute),
2927
+ // set multi drag elements rects to dragRect,
2928
+ // show multi drag elements,
2929
+ // animate to rects,
2930
+ // unset rects & remove from DOM
2931
+
2932
+ sortable.captureAnimationState();
2933
+ if (this.options.animation) {
2934
+ multiDragElements.forEach(function (multiDragElement) {
2935
+ if (multiDragElement === dragEl$1) return;
2936
+ css(multiDragElement, 'position', 'absolute');
2937
+ });
2938
+ var dragRect = getRect(dragEl$1, false, true, true);
2939
+ multiDragElements.forEach(function (multiDragElement) {
2940
+ if (multiDragElement === dragEl$1) return;
2941
+ setRect(multiDragElement, dragRect);
2942
+ });
2943
+ folding = true;
2944
+ initialFolding = true;
2945
+ }
2946
+ }
2947
+ sortable.animateAll(function () {
2948
+ folding = false;
2949
+ initialFolding = false;
2950
+ if (_this2.options.animation) {
2951
+ multiDragElements.forEach(function (multiDragElement) {
2952
+ unsetRect(multiDragElement);
2953
+ });
2954
+ }
2955
+
2956
+ // Remove all auxiliary multidrag items from el, if sorting enabled
2957
+ if (_this2.options.sort) {
2958
+ removeMultiDragElements();
2959
+ }
2960
+ });
2961
+ },
2962
+ dragOver: function dragOver(_ref8) {
2963
+ var target = _ref8.target,
2964
+ completed = _ref8.completed,
2965
+ cancel = _ref8.cancel;
2966
+ if (folding && ~multiDragElements.indexOf(target)) {
2967
+ completed(false);
2968
+ cancel();
2969
+ }
2970
+ },
2971
+ revert: function revert(_ref9) {
2972
+ var fromSortable = _ref9.fromSortable,
2973
+ rootEl = _ref9.rootEl,
2974
+ sortable = _ref9.sortable,
2975
+ dragRect = _ref9.dragRect;
2976
+ if (multiDragElements.length > 1) {
2977
+ // Setup unfold animation
2978
+ multiDragElements.forEach(function (multiDragElement) {
2979
+ sortable.addAnimationState({
2980
+ target: multiDragElement,
2981
+ rect: folding ? getRect(multiDragElement) : dragRect
2982
+ });
2983
+ unsetRect(multiDragElement);
2984
+ multiDragElement.fromRect = dragRect;
2985
+ fromSortable.removeAnimationState(multiDragElement);
2986
+ });
2987
+ folding = false;
2988
+ insertMultiDragElements(!this.options.removeCloneOnHide, rootEl);
2989
+ }
2990
+ },
2991
+ dragOverCompleted: function dragOverCompleted(_ref10) {
2992
+ var sortable = _ref10.sortable,
2993
+ isOwner = _ref10.isOwner,
2994
+ insertion = _ref10.insertion,
2995
+ activeSortable = _ref10.activeSortable,
2996
+ parentEl = _ref10.parentEl,
2997
+ putSortable = _ref10.putSortable;
2998
+ var options = this.options;
2999
+ if (insertion) {
3000
+ // Clones must be hidden before folding animation to capture dragRectAbsolute properly
3001
+ if (isOwner) {
3002
+ activeSortable._hideClone();
3003
+ }
3004
+ initialFolding = false;
3005
+ // If leaving sort:false root, or already folding - Fold to new location
3006
+ if (options.animation && multiDragElements.length > 1 && (folding || !isOwner && !activeSortable.options.sort && !putSortable)) {
3007
+ // Fold: Set all multi drag elements's rects to dragEl's rect when multi-drag elements are invisible
3008
+ var dragRectAbsolute = getRect(dragEl$1, false, true, true);
3009
+ multiDragElements.forEach(function (multiDragElement) {
3010
+ if (multiDragElement === dragEl$1) return;
3011
+ setRect(multiDragElement, dragRectAbsolute);
3012
+
3013
+ // Move element(s) to end of parentEl so that it does not interfere with multi-drag clones insertion if they are inserted
3014
+ // while folding, and so that we can capture them again because old sortable will no longer be fromSortable
3015
+ parentEl.appendChild(multiDragElement);
3016
+ });
3017
+ folding = true;
3018
+ }
3019
+
3020
+ // Clones must be shown (and check to remove multi drags) after folding when interfering multiDragElements are moved out
3021
+ if (!isOwner) {
3022
+ // Only remove if not folding (folding will remove them anyways)
3023
+ if (!folding) {
3024
+ removeMultiDragElements();
3025
+ }
3026
+ if (multiDragElements.length > 1) {
3027
+ var clonesHiddenBefore = clonesHidden;
3028
+ activeSortable._showClone(sortable);
3029
+
3030
+ // Unfold animation for clones if showing from hidden
3031
+ if (activeSortable.options.animation && !clonesHidden && clonesHiddenBefore) {
3032
+ multiDragClones.forEach(function (clone) {
3033
+ activeSortable.addAnimationState({
3034
+ target: clone,
3035
+ rect: clonesFromRect
3036
+ });
3037
+ clone.fromRect = clonesFromRect;
3038
+ clone.thisAnimationDuration = null;
3039
+ });
3040
+ }
3041
+ } else {
3042
+ activeSortable._showClone(sortable);
3043
+ }
3044
+ }
3045
+ }
3046
+ },
3047
+ dragOverAnimationCapture: function dragOverAnimationCapture(_ref11) {
3048
+ var dragRect = _ref11.dragRect,
3049
+ isOwner = _ref11.isOwner,
3050
+ activeSortable = _ref11.activeSortable;
3051
+ multiDragElements.forEach(function (multiDragElement) {
3052
+ multiDragElement.thisAnimationDuration = null;
3053
+ });
3054
+ if (activeSortable.options.animation && !isOwner && activeSortable.multiDrag.isMultiDrag) {
3055
+ clonesFromRect = _extends({}, dragRect);
3056
+ var dragMatrix = matrix(dragEl$1, true);
3057
+ clonesFromRect.top -= dragMatrix.f;
3058
+ clonesFromRect.left -= dragMatrix.e;
3059
+ }
3060
+ },
3061
+ dragOverAnimationComplete: function dragOverAnimationComplete() {
3062
+ if (folding) {
3063
+ folding = false;
3064
+ removeMultiDragElements();
3065
+ }
3066
+ },
3067
+ drop: function drop(_ref12) {
3068
+ var evt = _ref12.originalEvent,
3069
+ rootEl = _ref12.rootEl,
3070
+ parentEl = _ref12.parentEl,
3071
+ sortable = _ref12.sortable,
3072
+ dispatchSortableEvent = _ref12.dispatchSortableEvent,
3073
+ oldIndex = _ref12.oldIndex,
3074
+ putSortable = _ref12.putSortable;
3075
+ var toSortable = putSortable || this.sortable;
3076
+ if (!evt) return;
3077
+ var options = this.options,
3078
+ children = parentEl.children;
3079
+
3080
+ // Multi-drag selection
3081
+ if (!dragStarted) {
3082
+ if (options.multiDragKey && !this.multiDragKeyDown) {
3083
+ this._deselectMultiDrag();
3084
+ }
3085
+ toggleClass(dragEl$1, options.selectedClass, !~multiDragElements.indexOf(dragEl$1));
3086
+ if (!~multiDragElements.indexOf(dragEl$1)) {
3087
+ multiDragElements.push(dragEl$1);
3088
+ dispatchEvent({
3089
+ sortable: sortable,
3090
+ rootEl: rootEl,
3091
+ name: 'select',
3092
+ targetEl: dragEl$1,
3093
+ originalEvent: evt
3094
+ });
3095
+
3096
+ // Modifier activated, select from last to dragEl
3097
+ if (evt.shiftKey && lastMultiDragSelect && sortable.el.contains(lastMultiDragSelect)) {
3098
+ var lastIndex = index(lastMultiDragSelect),
3099
+ currentIndex = index(dragEl$1);
3100
+ if (~lastIndex && ~currentIndex && lastIndex !== currentIndex) {
3101
+ (function () {
3102
+ // Must include lastMultiDragSelect (select it), in case modified selection from no selection
3103
+ // (but previous selection existed)
3104
+ var n, i;
3105
+ if (currentIndex > lastIndex) {
3106
+ i = lastIndex;
3107
+ n = currentIndex;
3108
+ } else {
3109
+ i = currentIndex;
3110
+ n = lastIndex + 1;
3111
+ }
3112
+ var filter = options.filter;
3113
+ for (; i < n; i++) {
3114
+ if (~multiDragElements.indexOf(children[i])) continue;
3115
+ // Check if element is draggable
3116
+ if (!closest(children[i], options.draggable, parentEl, false)) continue;
3117
+ // Check if element is filtered
3118
+ var filtered = filter && (typeof filter === 'function' ? filter.call(sortable, evt, children[i], sortable) : filter.split(',').some(function (criteria) {
3119
+ return closest(children[i], criteria.trim(), parentEl, false);
3120
+ }));
3121
+ if (filtered) continue;
3122
+ toggleClass(children[i], options.selectedClass, true);
3123
+ multiDragElements.push(children[i]);
3124
+ dispatchEvent({
3125
+ sortable: sortable,
3126
+ rootEl: rootEl,
3127
+ name: 'select',
3128
+ targetEl: children[i],
3129
+ originalEvent: evt
3130
+ });
3131
+ }
3132
+ })();
3133
+ }
3134
+ } else {
3135
+ lastMultiDragSelect = dragEl$1;
3136
+ }
3137
+ multiDragSortable = toSortable;
3138
+ } else {
3139
+ multiDragElements.splice(multiDragElements.indexOf(dragEl$1), 1);
3140
+ lastMultiDragSelect = null;
3141
+ dispatchEvent({
3142
+ sortable: sortable,
3143
+ rootEl: rootEl,
3144
+ name: 'deselect',
3145
+ targetEl: dragEl$1,
3146
+ originalEvent: evt
3147
+ });
3148
+ }
3149
+ }
3150
+
3151
+ // Multi-drag drop
3152
+ if (dragStarted && this.isMultiDrag) {
3153
+ folding = false;
3154
+ // Do not "unfold" after around dragEl if reverted
3155
+ if ((parentEl[expando].options.sort || parentEl !== rootEl) && multiDragElements.length > 1) {
3156
+ var dragRect = getRect(dragEl$1),
3157
+ multiDragIndex = index(dragEl$1, ':not(.' + this.options.selectedClass + ')');
3158
+ if (!initialFolding && options.animation) dragEl$1.thisAnimationDuration = null;
3159
+ toSortable.captureAnimationState();
3160
+ if (!initialFolding) {
3161
+ if (options.animation) {
3162
+ dragEl$1.fromRect = dragRect;
3163
+ multiDragElements.forEach(function (multiDragElement) {
3164
+ multiDragElement.thisAnimationDuration = null;
3165
+ if (multiDragElement !== dragEl$1) {
3166
+ var rect = folding ? getRect(multiDragElement) : dragRect;
3167
+ multiDragElement.fromRect = rect;
3168
+
3169
+ // Prepare unfold animation
3170
+ toSortable.addAnimationState({
3171
+ target: multiDragElement,
3172
+ rect: rect
3173
+ });
3174
+ }
3175
+ });
3176
+ }
3177
+
3178
+ // Multi drag elements are not necessarily removed from the DOM on drop, so to reinsert
3179
+ // properly they must all be removed
3180
+ removeMultiDragElements();
3181
+ multiDragElements.forEach(function (multiDragElement) {
3182
+ if (children[multiDragIndex]) {
3183
+ parentEl.insertBefore(multiDragElement, children[multiDragIndex]);
3184
+ } else {
3185
+ parentEl.appendChild(multiDragElement);
3186
+ }
3187
+ multiDragIndex++;
3188
+ });
3189
+
3190
+ // If initial folding is done, the elements may have changed position because they are now
3191
+ // unfolding around dragEl, even though dragEl may not have his index changed, so update event
3192
+ // must be fired here as Sortable will not.
3193
+ if (oldIndex === index(dragEl$1)) {
3194
+ var update = false;
3195
+ multiDragElements.forEach(function (multiDragElement) {
3196
+ if (multiDragElement.sortableIndex !== index(multiDragElement)) {
3197
+ update = true;
3198
+ return;
3199
+ }
3200
+ });
3201
+ if (update) {
3202
+ dispatchSortableEvent('update');
3203
+ dispatchSortableEvent('sort');
3204
+ }
3205
+ }
3206
+ }
3207
+
3208
+ // Must be done after capturing individual rects (scroll bar)
3209
+ multiDragElements.forEach(function (multiDragElement) {
3210
+ unsetRect(multiDragElement);
3211
+ });
3212
+ toSortable.animateAll();
3213
+ }
3214
+ multiDragSortable = toSortable;
3215
+ }
3216
+
3217
+ // Remove clones if necessary
3218
+ if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== 'clone') {
3219
+ multiDragClones.forEach(function (clone) {
3220
+ clone.parentNode && clone.parentNode.removeChild(clone);
3221
+ });
3222
+ }
3223
+ },
3224
+ nullingGlobal: function nullingGlobal() {
3225
+ this.isMultiDrag = dragStarted = false;
3226
+ multiDragClones.length = 0;
3227
+ },
3228
+ destroyGlobal: function destroyGlobal() {
3229
+ this._deselectMultiDrag();
3230
+ off(document, 'pointerup', this._deselectMultiDrag);
3231
+ off(document, 'mouseup', this._deselectMultiDrag);
3232
+ off(document, 'touchend', this._deselectMultiDrag);
3233
+ off(document, 'keydown', this._checkKeyDown);
3234
+ off(document, 'keyup', this._checkKeyUp);
3235
+ },
3236
+ _deselectMultiDrag: function _deselectMultiDrag(evt) {
3237
+ if (typeof dragStarted !== "undefined" && dragStarted) return;
3238
+
3239
+ // Only deselect if selection is in this sortable
3240
+ if (multiDragSortable !== this.sortable) return;
3241
+
3242
+ // Only deselect if target is not item in this sortable
3243
+ if (evt && closest(evt.target, this.options.draggable, this.sortable.el, false)) return;
3244
+
3245
+ // Only deselect if left click
3246
+ if (evt && evt.button !== 0) return;
3247
+ while (multiDragElements.length) {
3248
+ var el = multiDragElements[0];
3249
+ toggleClass(el, this.options.selectedClass, false);
3250
+ multiDragElements.shift();
3251
+ dispatchEvent({
3252
+ sortable: this.sortable,
3253
+ rootEl: this.sortable.el,
3254
+ name: 'deselect',
3255
+ targetEl: el,
3256
+ originalEvent: evt
3257
+ });
3258
+ }
3259
+ },
3260
+ _checkKeyDown: function _checkKeyDown(evt) {
3261
+ if (evt.key === this.options.multiDragKey) {
3262
+ this.multiDragKeyDown = true;
3263
+ }
3264
+ },
3265
+ _checkKeyUp: function _checkKeyUp(evt) {
3266
+ if (evt.key === this.options.multiDragKey) {
3267
+ this.multiDragKeyDown = false;
3268
+ }
3269
+ }
3270
+ };
3271
+ return _extends(MultiDrag, {
3272
+ // Static methods & properties
3273
+ pluginName: 'multiDrag',
3274
+ utils: {
3275
+ /**
3276
+ * Selects the provided multi-drag item
3277
+ * @param {HTMLElement} el The element to be selected
3278
+ */
3279
+ select: function select(el) {
3280
+ var sortable = el.parentNode[expando];
3281
+ if (!sortable || !sortable.options.multiDrag || ~multiDragElements.indexOf(el)) return;
3282
+ if (multiDragSortable && multiDragSortable !== sortable) {
3283
+ multiDragSortable.multiDrag._deselectMultiDrag();
3284
+ multiDragSortable = sortable;
3285
+ }
3286
+ toggleClass(el, sortable.options.selectedClass, true);
3287
+ multiDragElements.push(el);
3288
+ },
3289
+ /**
3290
+ * Deselects the provided multi-drag item
3291
+ * @param {HTMLElement} el The element to be deselected
3292
+ */
3293
+ deselect: function deselect(el) {
3294
+ var sortable = el.parentNode[expando],
3295
+ index = multiDragElements.indexOf(el);
3296
+ if (!sortable || !sortable.options.multiDrag || !~index) return;
3297
+ toggleClass(el, sortable.options.selectedClass, false);
3298
+ multiDragElements.splice(index, 1);
3299
+ }
3300
+ },
3301
+ eventProperties: function eventProperties() {
3302
+ var _this3 = this;
3303
+ var oldIndicies = [],
3304
+ newIndicies = [];
3305
+ multiDragElements.forEach(function (multiDragElement) {
3306
+ oldIndicies.push({
3307
+ multiDragElement: multiDragElement,
3308
+ index: multiDragElement.sortableIndex
3309
+ });
3310
+
3311
+ // multiDragElements will already be sorted if folding
3312
+ var newIndex;
3313
+ if (folding && multiDragElement !== dragEl$1) {
3314
+ newIndex = -1;
3315
+ } else if (folding) {
3316
+ newIndex = index(multiDragElement, ':not(.' + _this3.options.selectedClass + ')');
3317
+ } else {
3318
+ newIndex = index(multiDragElement);
3319
+ }
3320
+ newIndicies.push({
3321
+ multiDragElement: multiDragElement,
3322
+ index: newIndex
3323
+ });
3324
+ });
3325
+ return {
3326
+ items: _toConsumableArray(multiDragElements),
3327
+ clones: [].concat(multiDragClones),
3328
+ oldIndicies: oldIndicies,
3329
+ newIndicies: newIndicies
3330
+ };
3331
+ },
3332
+ optionListeners: {
3333
+ multiDragKey: function multiDragKey(key) {
3334
+ key = key.toLowerCase();
3335
+ if (key === 'ctrl') {
3336
+ key = 'Control';
3337
+ } else if (key.length > 1) {
3338
+ key = key.charAt(0).toUpperCase() + key.substr(1);
3339
+ }
3340
+ return key;
3341
+ }
3342
+ }
3343
+ });
3344
+ }
3345
+ function insertMultiDragElements(clonesInserted, rootEl) {
3346
+ multiDragElements.forEach(function (multiDragElement, i) {
3347
+ var target = rootEl.children[multiDragElement.sortableIndex + (clonesInserted ? Number(i) : 0)];
3348
+ if (target) {
3349
+ rootEl.insertBefore(multiDragElement, target);
3350
+ } else {
3351
+ rootEl.appendChild(multiDragElement);
3352
+ }
3353
+ });
3354
+ }
3355
+
3356
+ /**
3357
+ * Insert multi-drag clones
3358
+ * @param {[Boolean]} elementsInserted Whether the multi-drag elements are inserted
3359
+ * @param {HTMLElement} rootEl
3360
+ */
3361
+ function insertMultiDragClones(elementsInserted, rootEl) {
3362
+ multiDragClones.forEach(function (clone, i) {
3363
+ var target = rootEl.children[clone.sortableIndex + (elementsInserted ? Number(i) : 0)];
3364
+ if (target) {
3365
+ rootEl.insertBefore(clone, target);
3366
+ } else {
3367
+ rootEl.appendChild(clone);
3368
+ }
3369
+ });
3370
+ }
3371
+ function removeMultiDragElements() {
3372
+ multiDragElements.forEach(function (multiDragElement) {
3373
+ if (multiDragElement === dragEl$1) return;
3374
+ multiDragElement.parentNode && multiDragElement.parentNode.removeChild(multiDragElement);
3375
+ });
3376
+ }
3377
+
3378
+ Sortable.mount(new AutoScrollPlugin());
3379
+ Sortable.mount(Remove, Revert);
3380
+
3381
+ exports.MultiDrag = MultiDragPlugin;
3382
+ exports.Sortable = Sortable;
3383
+ exports.Swap = SwapPlugin;
3384
+ exports.default = Sortable;