@para-ui/core 3.0.37 → 3.0.39

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