react-virtual-sortable 1.1.2 → 1.1.4

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.
@@ -0,0 +1,1972 @@
1
+ /*!
2
+ * react-virtual-sortable v1.1.4
3
+ * open source under the MIT license
4
+ * https://github.com/mfuu/react-virtual-sortable#readme
5
+ */
6
+
7
+ import * as React from 'react';
8
+
9
+ function _arrayLikeToArray(r, a) {
10
+ (null == a || a > r.length) && (a = r.length);
11
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
12
+ return n;
13
+ }
14
+ function _arrayWithHoles(r) {
15
+ if (Array.isArray(r)) return r;
16
+ }
17
+ function _arrayWithoutHoles(r) {
18
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
19
+ }
20
+ function _classCallCheck(a, n) {
21
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
22
+ }
23
+ function _defineProperties(e, r) {
24
+ for (var t = 0; t < r.length; t++) {
25
+ var o = r[t];
26
+ o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
27
+ }
28
+ }
29
+ function _createClass(e, r, t) {
30
+ return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
31
+ writable: !1
32
+ }), e;
33
+ }
34
+ function _defineProperty(e, r, t) {
35
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
36
+ value: t,
37
+ enumerable: !0,
38
+ configurable: !0,
39
+ writable: !0
40
+ }) : e[r] = t, e;
41
+ }
42
+ function _iterableToArray(r) {
43
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
44
+ }
45
+ function _iterableToArrayLimit(r, l) {
46
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
47
+ if (null != t) {
48
+ var e,
49
+ n,
50
+ i,
51
+ u,
52
+ a = [],
53
+ f = !0,
54
+ o = !1;
55
+ try {
56
+ if (i = (t = t.call(r)).next, 0 === l) {
57
+ if (Object(t) !== t) return;
58
+ f = !1;
59
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
60
+ } catch (r) {
61
+ o = !0, n = r;
62
+ } finally {
63
+ try {
64
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
65
+ } finally {
66
+ if (o) throw n;
67
+ }
68
+ }
69
+ return a;
70
+ }
71
+ }
72
+ function _nonIterableRest() {
73
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
74
+ }
75
+ function _nonIterableSpread() {
76
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
77
+ }
78
+ function _slicedToArray(r, e) {
79
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
80
+ }
81
+ function _toConsumableArray(r) {
82
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
83
+ }
84
+ function _toPrimitive(t, r) {
85
+ if ("object" != typeof t || !t) return t;
86
+ var e = t[Symbol.toPrimitive];
87
+ if (void 0 !== e) {
88
+ var i = e.call(t, r || "default");
89
+ if ("object" != typeof i) return i;
90
+ throw new TypeError("@@toPrimitive must return a primitive value.");
91
+ }
92
+ return ("string" === r ? String : Number)(t);
93
+ }
94
+ function _toPropertyKey(t) {
95
+ var i = _toPrimitive(t, "string");
96
+ return "symbol" == typeof i ? i : i + "";
97
+ }
98
+ function _typeof(o) {
99
+ "@babel/helpers - typeof";
100
+
101
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
102
+ return typeof o;
103
+ } : function (o) {
104
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
105
+ }, _typeof(o);
106
+ }
107
+ function _unsupportedIterableToArray(r, a) {
108
+ if (r) {
109
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
110
+ var t = {}.toString.call(r).slice(8, -1);
111
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
112
+ }
113
+ }
114
+
115
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
116
+
117
+ function getDefaultExportFromCjs (x) {
118
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
119
+ }
120
+
121
+ var sortableDnd_min = {exports: {}};
122
+
123
+ /*!
124
+ * sortable-dnd v0.7.2
125
+ * open source under the MIT license
126
+ * https://github.com/mfuu/sortable-dnd#readme
127
+ */
128
+ sortableDnd_min.exports;
129
+ (function (module, exports) {
130
+ !function (t, e) {
131
+ module.exports = e() ;
132
+ }(commonjsGlobal, function () {
133
+
134
+ function t() {
135
+ return t = Object.assign ? Object.assign.bind() : function (t) {
136
+ for (var e = 1; e < arguments.length; e++) {
137
+ var n = arguments[e];
138
+ for (var o in n) ({}).hasOwnProperty.call(n, o) && (t[o] = n[o]);
139
+ }
140
+ return t;
141
+ }, t.apply(null, arguments);
142
+ }
143
+ function e(t) {
144
+ return e = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (t) {
145
+ return typeof t;
146
+ } : function (t) {
147
+ return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
148
+ }, e(t);
149
+ }
150
+ var n = {
151
+ capture: !1,
152
+ passive: !1
153
+ },
154
+ o = /\s+/g;
155
+ function i(t) {
156
+ if ("undefined" != typeof window && window.navigator) return !!navigator.userAgent.match(t);
157
+ }
158
+ var r = i(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),
159
+ a = i(/Edge/i),
160
+ l = i(/safari/i) && !i(/chrome/i) && !i(/android/i);
161
+ function s(t, e, o) {
162
+ window.addEventListener ? t.addEventListener(e, o, !r && n) : window.attachEvent ? t.attachEvent("on" + e, o) : t["on" + e] = o;
163
+ }
164
+ function c(t, e, o) {
165
+ window.removeEventListener ? t.removeEventListener(e, o, !r && n) : window.detachEvent ? t.detachEvent("on" + e, o) : t["on" + e] = null;
166
+ }
167
+ function h() {
168
+ return document.scrollingElement || document.documentElement;
169
+ }
170
+ function u(t, e, n) {
171
+ if (t.getBoundingClientRect || t === window) {
172
+ var o, i, a, l, s, c, u;
173
+ if (t !== window && t.parentNode && t !== h() ? (i = (o = t.getBoundingClientRect()).top, a = o.left, l = o.bottom, s = o.right, c = o.height, u = o.width) : (i = 0, a = 0, l = window.innerHeight, s = window.innerWidth, c = window.innerHeight, u = window.innerWidth), e && t !== window && (n = n || t.parentNode, !r)) do {
174
+ if (n && n.getBoundingClientRect && "none" !== y(n, "transform")) {
175
+ var d = n.getBoundingClientRect();
176
+ i -= d.top + parseInt(y(n, "border-top-width")), a -= d.left + parseInt(y(n, "border-left-width")), l = i + o.height, s = a + o.width;
177
+ break;
178
+ }
179
+ } while (n = n.parentNode);
180
+ return {
181
+ top: i,
182
+ left: a,
183
+ bottom: l,
184
+ right: s,
185
+ width: u,
186
+ height: c
187
+ };
188
+ }
189
+ }
190
+ function d(t, e, n, o) {
191
+ if (t) {
192
+ n = n || document;
193
+ do {
194
+ if (null != e && (">" === e[0] ? t.parentNode === n && b(t, e) : b(t, e)) || o && t === n) return t;
195
+ if (t === n) break;
196
+ } while (t = t.parentNode);
197
+ }
198
+ return null;
199
+ }
200
+ function p(t, e) {
201
+ if (!t || !e) return !1;
202
+ if (e.compareDocumentPosition) return !!(16 & e.compareDocumentPosition(t));
203
+ if (e.contains && 1 === t.nodeType) return e.contains(t) && e !== t;
204
+ for (; t = t.parentNode;) if (t === e) return !0;
205
+ return !1;
206
+ }
207
+ function f(t, e) {
208
+ for (var n = t.lastElementChild; n && (n === tt.ghost || "none" === y(n, "display") || e && !b(n, e));) n = n.previousElementSibling;
209
+ return n || null;
210
+ }
211
+ function m(t, e) {
212
+ if (!t || !t.parentNode) return -1;
213
+ for (var n = 0; t = t.previousElementSibling;) t === tt.ghost || "TEMPLATE" === t.nodeName.toUpperCase() || "none" === y(t, "display") || e && !b(t, e) || n++;
214
+ return n;
215
+ }
216
+ function v(t, e, n, o) {
217
+ for (var i = 0, r = 0, a = t.children; i < a.length;) {
218
+ if (a[i] !== tt.ghost && "none" !== y(a[i], "display") && (o || a[i] !== tt.dragged) && d(a[i], n, t, !1)) {
219
+ if (r === e) return a[i];
220
+ r++;
221
+ }
222
+ i++;
223
+ }
224
+ return null;
225
+ }
226
+ function g(t, e) {
227
+ var n = y(t),
228
+ o = parseInt(n.width) - parseInt(n.paddingLeft) - parseInt(n.paddingRight) - parseInt(n.borderLeftWidth) - parseInt(n.borderRightWidth),
229
+ i = v(t, 0, e),
230
+ l = v(t, 1, e),
231
+ s = i && y(i),
232
+ c = l && y(l),
233
+ h = s && parseInt(s.marginLeft) + parseInt(s.marginRight) + u(i).width,
234
+ d = c && parseInt(c.marginLeft) + parseInt(c.marginRight) + u(l).width,
235
+ p = a || r ? "cssFloat" : "float";
236
+ if ("flex" === n.display) return "column" === n.flexDirection || "column-reverse" === n.flexDirection ? "vertical" : "horizontal";
237
+ if ("grid" === n.display) return n.gridTemplateColumns.split(" ").length <= 1 ? "vertical" : "horizontal";
238
+ if (i && s.float && "none" !== s.float) {
239
+ var f = "left" === s.float ? "left" : "right";
240
+ return !l || "both" !== c.clear && c.clear !== f ? "horizontal" : "vertical";
241
+ }
242
+ return i && ("block" === s.display || "flex" === s.display || "table" === s.display || "grid" === s.display || h >= o && "none" === n[p] || l && "none" === n[p] && h + d > o) ? "vertical" : "horizontal";
243
+ }
244
+ function w(t, e, n) {
245
+ if (t && e) if (t.classList) t.classList[n ? "add" : "remove"](e);else {
246
+ var i = (" " + t.className + " ").replace(o, " ").replace(" " + e + " ", " ");
247
+ t.className = (i + (n ? " " + e : "")).replace(o, " ");
248
+ }
249
+ }
250
+ function b(t, e) {
251
+ if (!t || !e) return !1;
252
+ ">" === e[0] && (e = e.substring(1));
253
+ try {
254
+ if (t.matches) return t.matches(e);
255
+ if (t.msMatchesSelector) return t.msMatchesSelector(e);
256
+ if (t.webkitMatchesSelector) return t.webkitMatchesSelector(e);
257
+ } catch (t) {
258
+ return !1;
259
+ }
260
+ return !1;
261
+ }
262
+ function y(t, e, n) {
263
+ var o = t && t.style;
264
+ if (o) {
265
+ if (void 0 === n) return window.getComputedStyle ? n = window.getComputedStyle(t, "") : t.currentStyle && (n = t.currentStyle), void 0 === e ? n : n[e];
266
+ e in o || -1 !== e.indexOf("webkit") || (e = "-webkit-" + e), o[e] = n + ("string" == typeof n ? "" : "px");
267
+ }
268
+ }
269
+ function S(t, e) {
270
+ return Math.round(t.top) === Math.round(e.top) && Math.round(t.left) === Math.round(e.left) && Math.round(t.height) === Math.round(e.height) && Math.round(t.width) === Math.round(e.width);
271
+ }
272
+ function _(t, e) {
273
+ var n = t.compareDocumentPosition ? t.compareDocumentPosition(e) : t.contains ? (t != e && t.contains(e) && 16) + (t != e && e.contains(t) && 8) + (t.sourceIndex >= 0 && e.sourceIndex >= 0 ? (t.sourceIndex < e.sourceIndex && 4) + (t.sourceIndex > e.sourceIndex && 2) : 1) : 0;
274
+ return 2 === n ? 1 : 4 === n ? -1 : 0;
275
+ }
276
+ function x(t) {
277
+ if ("function" == typeof t) {
278
+ for (var e = arguments.length, n = new Array(e > 1 ? e - 1 : 0), o = 1; o < e; o++) n[o - 1] = arguments[o];
279
+ return t.apply(void 0, n);
280
+ }
281
+ return t;
282
+ }
283
+ function I(t) {
284
+ void 0 !== t.preventDefault && t.cancelable && t.preventDefault();
285
+ }
286
+ var C = "Sortable" + Date.now();
287
+ function M(t) {
288
+ this.options = t, this.scrollEl = null, this.autoScrollInterval = null;
289
+ }
290
+ function D(t) {
291
+ this.options = t, this.animationStack = [], this.animationCallbackId = null;
292
+ }
293
+ function T(t, e) {
294
+ return Math.sqrt(Math.pow(t.left - e.left, 2) + Math.pow(t.top - e.top, 2));
295
+ }
296
+ M.prototype = {
297
+ nulling: function () {
298
+ this.autoScrollInterval && (clearInterval(this.autoScrollInterval), this.autoScrollInterval = null);
299
+ },
300
+ onStarted: function () {
301
+ this.nulling(), this.autoScrollInterval = setInterval(this.autoScroll.bind(this));
302
+ },
303
+ onMove: function (t, e, n, o) {
304
+ var i = n ? n[C].options : o;
305
+ !n || i.autoScroll ? (this.options = i, this.scrollEl = function (t, e) {
306
+ if (!t || !t.getBoundingClientRect) return h();
307
+ var n = t,
308
+ o = !1;
309
+ do {
310
+ if (n.clientWidth < n.scrollWidth || n.clientHeight < n.scrollHeight) {
311
+ var i = y(n);
312
+ if (n.clientWidth < n.scrollWidth && ("auto" == i.overflowX || "scroll" == i.overflowX) || n.clientHeight < n.scrollHeight && ("auto" == i.overflowY || "scroll" == i.overflowY)) {
313
+ if (!n.getBoundingClientRect || n === document.body) return h();
314
+ if (o || e) return n;
315
+ o = !0;
316
+ }
317
+ }
318
+ } while (n = n.parentNode);
319
+ return h();
320
+ }(t, !0), this.moveEvent = e) : this.scrollEl = null;
321
+ },
322
+ autoScroll: function () {
323
+ var t = this.options,
324
+ e = this.moveEvent,
325
+ n = this.scrollEl,
326
+ o = t.scrollThreshold,
327
+ i = t.scrollSpeed;
328
+ if (n && void 0 !== e.clientX && void 0 !== e.clientY) {
329
+ var r = u(n);
330
+ if (r) {
331
+ var a = e.clientX,
332
+ l = e.clientY,
333
+ s = r.top,
334
+ c = r.right,
335
+ h = r.bottom,
336
+ d = r.left,
337
+ p = r.height,
338
+ f = r.width;
339
+ if (!(l < s || a > c || l > h || a < d)) {
340
+ var m = n.scrollTop,
341
+ v = n.scrollLeft,
342
+ g = n.scrollHeight,
343
+ w = n.scrollWidth;
344
+ n.scrollLeft += this.getScrollOffset(a, d, c, o, i.x, v, w, f), n.scrollTop += this.getScrollOffset(l, s, h, o, i.y, m, g, p);
345
+ }
346
+ }
347
+ }
348
+ },
349
+ getScrollOffset: function (t, e, n, o, i, r, a, l) {
350
+ return r > 0 && t >= e && t <= e + o ? Math.max(-1, (t - e) / o - 1) * i : r + l < a && t <= n && t >= n - o ? Math.min(1, (t - n) / o + 1) * i : 0;
351
+ }
352
+ }, D.prototype = {
353
+ collect: function (t) {
354
+ if (t) {
355
+ for (var e = u(t), n = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth, o = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight, i = Math.min(e.right, n), r = Math.min(e.bottom, o), a = Array.prototype.slice.call(t.children), l = [], s = 0, c = a.length; s < c; s++) {
356
+ var h = a[s];
357
+ if (h !== tt.ghost && "none" !== y(h, "display")) {
358
+ var d = u(h);
359
+ if (!(d.bottom < 0 || d.right < 0)) {
360
+ if (0 === l.length && h.previousElementSibling) {
361
+ var p = h.previousElementSibling;
362
+ do {
363
+ if (p && p !== tt.ghost && "none" !== y(p, "display")) break;
364
+ } while (p = p.previousElementSibling);
365
+ p && l.push({
366
+ el: p,
367
+ rect: u(p)
368
+ });
369
+ }
370
+ if (d.top - d.height > r || d.left - d.width > i) {
371
+ l.push({
372
+ el: h,
373
+ rect: d
374
+ });
375
+ break;
376
+ }
377
+ l.push({
378
+ el: h,
379
+ rect: d
380
+ });
381
+ }
382
+ }
383
+ }
384
+ this.animationStack.push(l);
385
+ }
386
+ },
387
+ animate: function (t) {
388
+ var e = this,
389
+ n = this.animationStack.pop(),
390
+ o = this.options.animation;
391
+ if (!n || !o) return clearTimeout(this.animationCallbackId), void ("function" == typeof t && t());
392
+ var i = 0;
393
+ n.forEach(function (t) {
394
+ var n = 0,
395
+ r = t.el,
396
+ a = u(r),
397
+ l = t.rect,
398
+ s = r.prevToRect,
399
+ c = r.prevFromRect;
400
+ if (r.animating && c && s && S(l, a)) {
401
+ var h = function (t, e) {
402
+ var n = "";
403
+ if ("string" == typeof t) n = t;else do {
404
+ var o = y(t, "transform");
405
+ o && "none" !== o && (n = o + " " + n);
406
+ } while (!e && (t = t.parentNode));
407
+ var i = window.DOMMatrix || window.WebKitCSSMatrix || window.CSSMatrix || window.MSCSSMatrix;
408
+ return i && new i(n);
409
+ }(r, !0);
410
+ if (h) n = T({
411
+ top: a.top - h.f,
412
+ left: a.left - h.e
413
+ }, a) / T(c, s) * o;
414
+ }
415
+ S(l, a) || (r.prevFromRect = l, r.prevToRect = a, n || (n = o), e.execute(r, l, a, n)), n && (i = Math.max(i, n));
416
+ }), clearTimeout(this.animationCallbackId), i ? this.animationCallbackId = setTimeout(function () {
417
+ "function" == typeof t && t();
418
+ }, i) : "function" == typeof t && t();
419
+ },
420
+ execute: function (t, e, n, o) {
421
+ if (o) {
422
+ y(t, "transition", ""), y(t, "transform", "");
423
+ var i = this.options.easing || "",
424
+ r = e.left - n.left,
425
+ a = e.top - n.top;
426
+ y(t, "transform", "translate3d(".concat(r, "px, ").concat(a, "px, 0)")), this.repaintDummy = function (t) {
427
+ return t.offsetWidth;
428
+ }(t), y(t, "transition", "transform ".concat(o, "ms ").concat(i)), y(t, "transform", "translate3d(0, 0, 0)"), "number" == typeof t.animating && clearTimeout(t.animating), t.animating = setTimeout(function () {
429
+ y(t, "transition", ""), y(t, "transform", ""), t.prevFromRect = null, t.prevToRect = null, t.animating = null;
430
+ }, o);
431
+ }
432
+ }
433
+ };
434
+ var E,
435
+ N,
436
+ O,
437
+ R,
438
+ k,
439
+ H,
440
+ X,
441
+ Y,
442
+ W,
443
+ L,
444
+ B,
445
+ A,
446
+ P,
447
+ z,
448
+ j,
449
+ F,
450
+ G,
451
+ U,
452
+ q,
453
+ K,
454
+ J,
455
+ Q = [];
456
+ function V(t) {
457
+ var n,
458
+ o,
459
+ i,
460
+ r = {},
461
+ a = t.group;
462
+ a && "object" === e(a) || (a = {
463
+ name: a,
464
+ pull: !0,
465
+ put: !0,
466
+ revertDrag: !0
467
+ }), r.name = a.name, r.pull = null === (n = a.pull) || void 0 === n || n, r.put = null === (o = a.put) || void 0 === o || o, r.revertDrag = null === (i = a.revertDrag) || void 0 === i || i, t.group = r;
468
+ }
469
+ function Z(e) {
470
+ var n = e.sortable,
471
+ o = e.name,
472
+ i = e.evt,
473
+ r = n.options[o];
474
+ if ("function" == typeof r) return r(t({}, i));
475
+ }
476
+ function $(e) {
477
+ var n = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {},
478
+ o = {};
479
+ return o.event = e, o.to = E, o.from = N, o.node = O, o.clone = X, o.target = W, o.oldIndex = A, o.newIndex = P, o.pullMode = B, t(o, n), o.relative = W === O ? 0 : _(X, W), o;
480
+ }
481
+ function tt(e, n) {
482
+ if (!e || !e.nodeType || 1 !== e.nodeType) throw "Sortable-dnd: `el` must be an HTMLElement, not ".concat({}.toString.call(e));
483
+ e[C] = this, this.el = e, this.options = n = t({}, n);
484
+ var o = {
485
+ store: null,
486
+ group: "",
487
+ handle: null,
488
+ draggable: ">*",
489
+ sortable: !0,
490
+ disabled: !1,
491
+ customGhost: null,
492
+ lockAxis: "",
493
+ direction: "",
494
+ animation: 150,
495
+ easing: "",
496
+ chosenClass: "",
497
+ placeholderClass: "",
498
+ ghostClass: "",
499
+ ghostStyle: {},
500
+ ghostContainer: null,
501
+ appendToBody: !1,
502
+ autoScroll: !0,
503
+ scrollThreshold: 55,
504
+ scrollSpeed: {
505
+ x: 10,
506
+ y: 10
507
+ },
508
+ delay: 0,
509
+ delayOnTouchOnly: !1,
510
+ swapOnDrop: !0,
511
+ removeCloneOnDrop: !0,
512
+ dropOnAnimationEnd: !1,
513
+ supportTouch: "ontouchstart" in window,
514
+ touchStartThreshold: (Number.parseInt ? Number : window).parseInt(window.devicePixelRatio, 10) || 1,
515
+ emptyInsertThreshold: -1
516
+ };
517
+ for (var i in o) !(i in n) && (n[i] = o[i]);
518
+ for (var r in V(n), this) "_" === r.charAt(0) && "function" == typeof this[r] && (this[r] = this[r].bind(this));
519
+ s(e, n.supportTouch ? "touchstart" : "mousedown", this._onDrag), this.autoScroller = new M(n), this.animator = new D(n), Q.push(e);
520
+ }
521
+ return tt.prototype = {
522
+ constructor: tt,
523
+ _onDrag: function (t) {
524
+ var e = this,
525
+ n = this.el,
526
+ o = this.options,
527
+ i = o.handle,
528
+ c = t.touches && t.touches[0],
529
+ h = (c || t).target,
530
+ u = n.ownerDocument;
531
+ if (!O && !o.disabled && o.group.pull && !(/mousedown|pointerdown/.test(t.type) && 0 !== t.button || l && h && "SELECT" === h.tagName.toUpperCase())) {
532
+ var p = d(h, o.draggable, n);
533
+ p && !p.animating && (j = {
534
+ event: t,
535
+ clientX: (c || t).clientX,
536
+ clientY: (c || t).clientY
537
+ }, O = p, s(U = c ? O : document, "mouseup", this._onDrop), s(U, "touchend", this._onDrop), s(U, "touchcancel", this._onDrop), "function" == typeof i && !i(t) || "string" == typeof i && !d(h, i, O) || (!o.delay || o.delayOnTouchOnly && !c || a || r ? this._onStart(c, t) : (s(u, "touchmove", this._delayedMoveHandler), s(u, "mousemove", this._delayedMoveHandler), s(u, "mouseup", this._cancelStart), s(u, "touchend", this._cancelStart), s(u, "touchcancel", this._cancelStart), this._dragStartTimer = setTimeout(function () {
538
+ return e._onStart(c, t);
539
+ }, o.delay))));
540
+ }
541
+ },
542
+ _delayedMoveHandler: function (t) {
543
+ var e = t.touches ? t.touches[0] : t;
544
+ Math.max(Math.abs(e.clientX - j.clientX), Math.abs(e.clientY - j.clientY)) >= Math.floor(this.options.touchStartThreshold / (window.devicePixelRatio || 1)) && this._cancelStart();
545
+ },
546
+ _cancelStart: function () {
547
+ var t = this.el.ownerDocument;
548
+ clearTimeout(this._dragStartTimer), c(t, "touchmove", this._delayedMoveHandler), c(t, "mousemove", this._delayedMoveHandler), c(t, "mouseup", this._cancelStart), c(t, "touchend", this._cancelStart), c(t, "touchcancel", this._cancelStart);
549
+ },
550
+ _onStart: function (t, e) {
551
+ I(e);
552
+ var n = this.el,
553
+ o = this.options,
554
+ i = m(O);
555
+ A = i, P = i, z = i, E = n, N = n, H = n, W = O, L = O.parentNode, B = o.group.pull, K = O, q = {
556
+ to: n,
557
+ target: O,
558
+ newIndex: i,
559
+ relative: 0
560
+ }, X = O.cloneNode(!0), tt.dragged = O, tt.clone = X, tt.active = this, Z({
561
+ sortable: this,
562
+ name: "onChoose",
563
+ evt: $(e)
564
+ }), w(O, o.chosenClass, !0), s(U, t ? "touchmove" : "mousemove", this._nearestSortable);
565
+ try {
566
+ document.selection ? setTimeout(function () {
567
+ return document.selection.empty();
568
+ }, 0) : window.getSelection().removeAllRanges();
569
+ } catch (t) {}
570
+ s(document, "selectstart", I), l && y(document.body, "user-select", "none");
571
+ },
572
+ _onStarted: function () {
573
+ var t = this.options;
574
+ this.animator.collect(L), this._appendGhost(), w(X, t.chosenClass, !0), w(X, t.placeholderClass, !0), O.parentNode.insertBefore(X, O), y(O, "display", "none"), Z({
575
+ sortable: this,
576
+ name: "onDrag",
577
+ evt: $(j.event)
578
+ }), this.animator.animate(), this.autoScroller.onStarted();
579
+ },
580
+ _appendGhost: function () {
581
+ if (!Y) {
582
+ var e = this.options,
583
+ n = e.appendToBody ? document.body : x(e.ghostContainer, this) || this.el,
584
+ o = x(e.customGhost, X) || X;
585
+ w(Y = o.cloneNode(!0), e.ghostClass, !0);
586
+ var i = u(O),
587
+ r = t({
588
+ position: "fixed",
589
+ top: i.top,
590
+ left: i.left,
591
+ width: i.width,
592
+ height: i.height,
593
+ margin: 0,
594
+ zIndex: 1e5,
595
+ opacity: "0.8",
596
+ overflow: "hidden",
597
+ boxSizing: "border-box",
598
+ transform: "",
599
+ transition: "",
600
+ pointerEvents: "none"
601
+ }, e.ghostStyle);
602
+ for (var a in r) y(Y, a, r[a]);
603
+ tt.ghost = Y, n.appendChild(Y);
604
+ var l = (j.clientX - i.left) / parseInt(Y.style.width) * 100,
605
+ s = (j.clientY - i.top) / parseInt(Y.style.height) * 100;
606
+ y(Y, "transform-origin", "".concat(l, "% ").concat(s, "%")), y(Y, "will-change", "transform");
607
+ }
608
+ },
609
+ _nearestSortable: function (t) {
610
+ I(t);
611
+ var e = t.touches && t.touches[0] || t;
612
+ if (O && function (t) {
613
+ var e = F || j;
614
+ return !(void 0 !== t.clientX && void 0 !== t.clientY && Math.abs(t.clientX - e.clientX) <= 0 && Math.abs(t.clientY - e.clientY) <= 0);
615
+ }(e)) {
616
+ !F && this._onStarted();
617
+ var n = this.options.lockAxis,
618
+ o = "x" === n ? j.clientX : e.clientX,
619
+ i = "y" === n ? j.clientY : e.clientY,
620
+ r = document.elementFromPoint(o, i),
621
+ a = o - j.clientX,
622
+ l = i - j.clientY;
623
+ F = {
624
+ event: t,
625
+ clientX: o,
626
+ clientY: i
627
+ }, y(Y, "transform", "translate3d(".concat(a, "px, ").concat(l, "px, 0)"));
628
+ var s,
629
+ c,
630
+ h,
631
+ d = (s = o, c = i, Q.reduce(function (t, e) {
632
+ var n = e[C].options.emptyInsertThreshold;
633
+ if (null != n) {
634
+ var o = u(e),
635
+ i = s >= o.left - n && s <= o.right + n,
636
+ r = c >= o.top - n && c <= o.bottom + n;
637
+ return i && r && (!h || h && o.left >= h.left && o.right <= h.right && o.top >= h.top && o.bottom <= h.bottom) && (t = e, h = o), t;
638
+ }
639
+ }, null));
640
+ d && d[C]._onMove(t, r), this.autoScroller.onMove(r, F, d, this.options);
641
+ }
642
+ },
643
+ _allowPut: function () {
644
+ var t = this.options.group,
645
+ e = H[C].options.group;
646
+ return this.el === H || !!t.put && (t.put.join && t.put.indexOf(e.name) > -1 || e.name && t.name && e.name === t.name);
647
+ },
648
+ _getDirection: function () {
649
+ var t = this.options.draggable,
650
+ e = this.options.direction;
651
+ return e ? x(e, F.event, X, this) : g(L, t);
652
+ },
653
+ _allowSwap: function () {
654
+ var t = u(R),
655
+ e = "vertical" === this._getDirection(),
656
+ n = e ? "top" : "left",
657
+ o = e ? "bottom" : "right",
658
+ i = R[e ? "offsetHeight" : "offsetWidth"],
659
+ r = e ? F.clientY : F.clientX,
660
+ a = r >= t[n] && r < t[o] - i / 2 ? -1 : 1,
661
+ l = v(L, 0, this.options.draggable),
662
+ s = f(L),
663
+ c = u(l),
664
+ h = u(s);
665
+ if (R === L || p(L, R)) return X === l && r < c[n] ? (k = R, !0) : X === s && r > h[o] && (k = R.nextSibling, !0);
666
+ var d = _(X, R);
667
+ return k = d < 0 ? R.nextSibling : R, G !== R ? (J = a, !0) : J !== a && (J = a, a < 0 ? d > 0 : d < 0);
668
+ },
669
+ _onMove: function (t, e) {
670
+ var n = this.el,
671
+ o = this.options;
672
+ if (!o.disabled && this._allowPut()) {
673
+ if (Z({
674
+ sortable: this,
675
+ name: "onMove",
676
+ evt: $(t, {
677
+ target: R = d(e, o.draggable, n)
678
+ })
679
+ }), o.sortable || n !== H) return n === N || e !== n && f(n, o.draggable) ? void (R && !R.animating && !p(R, X) && this._allowSwap() && (R !== X && k !== X ? (n !== N ? this._onInsert(t) : R !== O && this._onChange(t), G = R) : G = R)) : (R = G = null, void this._onInsert(t));
680
+ N !== H && (R = G = O, J = 0, this._onInsert(t));
681
+ }
682
+ },
683
+ _onInsert: function (t) {
684
+ var e = this.el,
685
+ n = R || X,
686
+ o = "clone" === B && e !== H && N === H,
687
+ i = "clone" === B && e === H && N !== H,
688
+ r = p(R, document),
689
+ a = R === O && !r,
690
+ l = N[C],
691
+ s = H[C];
692
+ E = e, A = m(X), W = n, L = r ? R.parentNode : e, l.animator.collect(X.parentNode), this.animator.collect(L), o && (q.target = K, q.newIndex = A, q.relative = K === O ? 0 : _(X, K), y(O, "display", ""), s.options.group.revertDrag || X.parentNode.insertBefore(O, X)), i && (A = m(O), y(O, "display", "none")), y(X, "display", a ? "none" : ""), R && r ? L.insertBefore(X, J < 0 ? R : R.nextSibling) : L.appendChild(X), P = a ? z : m(X), o && s.options.group.revertDrag && (q.target = O, q.newIndex = z, q.relative = 0, Z({
693
+ sortable: s,
694
+ name: "onChange",
695
+ evt: $(t, {
696
+ to: H,
697
+ target: O,
698
+ newIndex: z,
699
+ revertDrag: !0
700
+ })
701
+ })), o || Z({
702
+ sortable: l,
703
+ name: "onRemove",
704
+ evt: $(t, {
705
+ newIndex: -1
706
+ })
707
+ }), i && n !== O && (K = n, Z({
708
+ sortable: this,
709
+ name: "onChange",
710
+ evt: $(t, {
711
+ from: H,
712
+ backToOrigin: !0
713
+ })
714
+ })), i || Z({
715
+ sortable: this,
716
+ name: "onAdd",
717
+ evt: $(t, {
718
+ oldIndex: -1
719
+ })
720
+ }), l.animator.animate(), this.animator.animate(), N = e;
721
+ },
722
+ _onChange: function (t) {
723
+ var e = this.el;
724
+ this.animator.collect(L), A = m(X), L = R.parentNode, W = R, e === H && (K = R), L.insertBefore(X, k), P = m(X), Z({
725
+ sortable: this,
726
+ name: "onChange",
727
+ evt: $(t)
728
+ }), this.animator.animate(), N = e;
729
+ },
730
+ _onDrop: function (t) {
731
+ var e = this,
732
+ n = this.options;
733
+ if (this._cancelStart(), c(U, "touchmove", this._nearestSortable), c(U, "mousemove", this._nearestSortable), c(U, "mouseup", this._onDrop), c(U, "touchend", this._onDrop), c(U, "touchcancel", this._onDrop), c(document, "selectstart", I), l && y(document.body, "user-select", ""), Y && Y.parentNode && Y.parentNode.removeChild(Y), H) {
734
+ if (N = H, A = z, W === X && (W = O), w(O, n.chosenClass, !1), Z({
735
+ sortable: this,
736
+ name: "onUnchoose",
737
+ evt: $(t)
738
+ }), F) {
739
+ this.animator.collect(L), w(X, n.chosenClass, !1), w(X, n.placeholderClass, !1);
740
+ var o = $(t);
741
+ !n.dropOnAnimationEnd && this._onEnd(o), this.animator.animate(function () {
742
+ n.dropOnAnimationEnd && e._onEnd(o);
743
+ });
744
+ } else this._nulling();
745
+ } else this._nulling();
746
+ },
747
+ _onEnd: function (e) {
748
+ var n = this.options,
749
+ o = "clone" === B,
750
+ i = N === E;
751
+ o && !i || !x(n.swapOnDrop, e) || L.insertBefore(O, X), o && !i || !x(n.removeCloneOnDrop, e) || X && X.parentNode && X.parentNode.removeChild(X), y(O, "display", ""), N !== E && Z({
752
+ sortable: N[C],
753
+ name: "onDrop",
754
+ evt: t({}, e, o ? q : {
755
+ newIndex: -1
756
+ })
757
+ }), Z({
758
+ sortable: E[C],
759
+ name: "onDrop",
760
+ evt: t({}, e, i ? {} : {
761
+ oldIndex: -1
762
+ })
763
+ }), this._nulling();
764
+ },
765
+ _nulling: function () {
766
+ E = N = O = R = k = H = X = Y = W = L = B = A = P = z = j = F = G = U = q = K = J = tt.clone = tt.ghost = tt.active = tt.dragged = null, this.autoScroller.nulling();
767
+ },
768
+ destroy: function () {
769
+ this._cancelStart(), this._nulling(), c(this.el, "touchstart", this._onDrag), c(this.el, "mousedown", this._onDrag);
770
+ var t = Q.indexOf(this.el);
771
+ t > -1 && Q.splice(t, 1), this.el[C] = this.animator = this.autoScroller = null;
772
+ },
773
+ option: function (t, e) {
774
+ if (void 0 === e) return this.options[t];
775
+ this.options[t] = e, this.animator.options[t] = e, this.autoScroller.options[t] = e, "group" === t && V(this.options);
776
+ }
777
+ }, tt.utils = {
778
+ on: s,
779
+ off: c,
780
+ css: y,
781
+ index: m,
782
+ matches: b,
783
+ closest: d,
784
+ getRect: u,
785
+ getChild: v,
786
+ toggleClass: w,
787
+ detectDirection: g
788
+ }, tt.get = function (t) {
789
+ return t[C];
790
+ }, tt.create = function (t, e) {
791
+ return new tt(t, e);
792
+ }, tt.store = {}, tt;
793
+ });
794
+ })(sortableDnd_min, sortableDnd_min.exports);
795
+ var sortableDnd_minExports = sortableDnd_min.exports;
796
+ var Sortable = /*@__PURE__*/getDefaultExportFromCjs(sortableDnd_minExports);
797
+
798
+ function throttle(fn, wait) {
799
+ var timer;
800
+ var result = function result() {
801
+ var _this = this;
802
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
803
+ args[_key] = arguments[_key];
804
+ }
805
+ if (timer) return;
806
+ if (wait <= 0) {
807
+ fn.apply(this, args);
808
+ } else {
809
+ timer = setTimeout(function () {
810
+ timer = null;
811
+ fn.apply(_this, args);
812
+ }, wait);
813
+ }
814
+ };
815
+ result['cancel'] = function () {
816
+ if (timer) {
817
+ clearTimeout(timer);
818
+ timer = null;
819
+ }
820
+ };
821
+ return result;
822
+ }
823
+ function debounce(fn, wait) {
824
+ var throttled = throttle(fn, wait);
825
+ var result = function result() {
826
+ throttled['cancel']();
827
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
828
+ args[_key2] = arguments[_key2];
829
+ }
830
+ throttled.apply(this, args);
831
+ };
832
+ result['cancel'] = function () {
833
+ throttled['cancel']();
834
+ };
835
+ return result;
836
+ }
837
+ function isEqual(a, b) {
838
+ // 0 & -0
839
+ if (a === 0 && b === 0) {
840
+ return 1 / a === 1 / b;
841
+ }
842
+ // NaN
843
+ if (Number.isNaN(a) && Number.isNaN(b)) {
844
+ return true;
845
+ }
846
+ return a == b;
847
+ }
848
+ function getDataKey(item, dataKey) {
849
+ return (!Array.isArray(dataKey) ? dataKey.replace(/\[/g, '.').replace(/\]/g, '.').split('.') : dataKey).reduce(function (o, k) {
850
+ return (o || {})[k];
851
+ }, item);
852
+ }
853
+ function elementIsDocumentOrWindow(element) {
854
+ return element instanceof Document && element.nodeType === 9 || element instanceof Window;
855
+ }
856
+
857
+ var Virtual = /*#__PURE__*/function () {
858
+ function Virtual(options) {
859
+ _classCallCheck(this, Virtual);
860
+ this.options = options;
861
+ var defaults = {
862
+ size: 0,
863
+ keeps: 0,
864
+ buffer: 0,
865
+ wrapper: null,
866
+ scroller: null,
867
+ direction: 'vertical',
868
+ uniqueKeys: [],
869
+ debounceTime: null,
870
+ throttleTime: null
871
+ };
872
+ for (var name in defaults) {
873
+ !(name in this.options) && (this.options[name] = defaults[name]);
874
+ }
875
+ this.option('buffer', options.buffer);
876
+ this.sizes = new Map(); // store item size
877
+ this.sizeType = 'INIT';
878
+ this.fixedSize = 0;
879
+ this.averageSize = 0;
880
+ this.range = {
881
+ start: 0,
882
+ end: 0,
883
+ front: 0,
884
+ behind: 0
885
+ };
886
+ this.offset = 0;
887
+ this.direction = 'STATIONARY';
888
+ this.updateScrollElement();
889
+ this.updateOnScrollFunction();
890
+ this.addScrollEventListener();
891
+ this.checkIfUpdate(0, options.keeps - 1);
892
+ }
893
+ return _createClass(Virtual, [{
894
+ key: "isFixed",
895
+ value: function isFixed() {
896
+ return this.sizeType === 'FIXED';
897
+ }
898
+ }, {
899
+ key: "isFront",
900
+ value: function isFront() {
901
+ return this.direction === 'FRONT';
902
+ }
903
+ }, {
904
+ key: "isBehind",
905
+ value: function isBehind() {
906
+ return this.direction === 'BEHIND';
907
+ }
908
+ }, {
909
+ key: "isHorizontal",
910
+ value: function isHorizontal() {
911
+ return this.options.direction === 'horizontal';
912
+ }
913
+ }, {
914
+ key: "getSize",
915
+ value: function getSize(key) {
916
+ return this.sizes.get(key) || this.getItemSize();
917
+ }
918
+ }, {
919
+ key: "getOffset",
920
+ value: function getOffset() {
921
+ var offsetKey = this.isHorizontal() ? 'scrollLeft' : 'scrollTop';
922
+ return this.scrollEl[offsetKey];
923
+ }
924
+ }, {
925
+ key: "getScrollSize",
926
+ value: function getScrollSize() {
927
+ var sizeKey = this.isHorizontal() ? 'scrollWidth' : 'scrollHeight';
928
+ return this.scrollEl[sizeKey];
929
+ }
930
+ }, {
931
+ key: "getClientSize",
932
+ value: function getClientSize() {
933
+ var sizeKey = this.isHorizontal() ? 'offsetWidth' : 'offsetHeight';
934
+ return this.scrollEl[sizeKey];
935
+ }
936
+ }, {
937
+ key: "scrollToOffset",
938
+ value: function scrollToOffset(offset) {
939
+ var offsetKey = this.isHorizontal() ? 'scrollLeft' : 'scrollTop';
940
+ this.scrollEl[offsetKey] = offset;
941
+ }
942
+ }, {
943
+ key: "scrollToIndex",
944
+ value: function scrollToIndex(index) {
945
+ var align = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
946
+ if (index >= this.options.uniqueKeys.length - 1) {
947
+ this.scrollToBottom();
948
+ return;
949
+ }
950
+ if (index < 0) {
951
+ this.scrollToOffset(0);
952
+ return;
953
+ }
954
+ var offset = this.getOffset();
955
+ var clientSize = this.getClientSize();
956
+ // calc item position
957
+ var itemSize = this.getSize(this.options.uniqueKeys[index]);
958
+ var itemTop = this.getOffsetByRange(0, index) + this.getScrollStartOffset();
959
+ var itemBottom = itemTop + itemSize;
960
+ var viewportTop = offset;
961
+ var viewportBottom = offset + clientSize;
962
+ if (align === 'auto') {
963
+ if (itemTop >= viewportTop && itemBottom <= viewportBottom) {
964
+ return;
965
+ }
966
+ align = itemTop < viewportTop ? 'top' : 'bottom';
967
+ }
968
+ if (align === 'top') {
969
+ this.scrollToOffset(itemTop);
970
+ } else if (align === 'bottom') {
971
+ var targetOffset = Math.max(0, itemBottom - clientSize);
972
+ this.scrollToOffset(targetOffset);
973
+ }
974
+ }
975
+ }, {
976
+ key: "scrollToBottom",
977
+ value: function scrollToBottom() {
978
+ var _this = this;
979
+ var offset = this.getScrollSize();
980
+ this.scrollToOffset(offset);
981
+ // if the bottom is not reached, execute the scroll method again
982
+ setTimeout(function () {
983
+ if (!_this.isReachedBottom()) {
984
+ _this.scrollToBottom();
985
+ }
986
+ }, 5);
987
+ }
988
+ }, {
989
+ key: "isReachedBottom",
990
+ value: function isReachedBottom() {
991
+ return this.getOffset() + this.getClientSize() + 1 >= this.getScrollSize();
992
+ }
993
+ }, {
994
+ key: "option",
995
+ value: function option(key, value) {
996
+ var _this2 = this;
997
+ var oldValue = this.options[key];
998
+ this.options[key] = value;
999
+ if (key === 'buffer') {
1000
+ if (value === undefined || value === null) {
1001
+ this.buffer = Math.round(this.options.keeps / 3);
1002
+ } else {
1003
+ this.buffer = value;
1004
+ }
1005
+ }
1006
+ if (key === 'uniqueKeys') {
1007
+ this.sizes.forEach(function (_v, k) {
1008
+ if (!value.includes(k)) {
1009
+ _this2.sizes["delete"](k);
1010
+ }
1011
+ });
1012
+ }
1013
+ if (key === 'scroller') {
1014
+ oldValue && Sortable.utils.off(oldValue, 'scroll', this.onScroll);
1015
+ this.updateScrollElement();
1016
+ this.addScrollEventListener();
1017
+ }
1018
+ }
1019
+ }, {
1020
+ key: "updateRange",
1021
+ value: function updateRange(range) {
1022
+ if (range) {
1023
+ this.handleUpdate(range.start);
1024
+ return;
1025
+ }
1026
+ var start = this.range.start;
1027
+ start = Math.max(start, 0);
1028
+ this.handleUpdate(start);
1029
+ }
1030
+ }, {
1031
+ key: "updateItemSize",
1032
+ value: function updateItemSize(key, size) {
1033
+ if (!size || this.sizes.get(key) === size) {
1034
+ return;
1035
+ }
1036
+ this.sizes.set(key, size);
1037
+ if (this.sizeType === 'INIT') {
1038
+ this.sizeType = 'FIXED';
1039
+ this.fixedSize = size;
1040
+ } else if (this.isFixed() && this.fixedSize !== size) {
1041
+ this.sizeType = 'DYNAMIC';
1042
+ this.fixedSize = 0;
1043
+ }
1044
+ // calculate the average size only once
1045
+ if (!this.averageSize && this.sizeType === 'DYNAMIC' && this.sizes.size === this.options.keeps) {
1046
+ this.updateAverageSize();
1047
+ }
1048
+ }
1049
+ }, {
1050
+ key: "updateAverageSize",
1051
+ value: function updateAverageSize() {
1052
+ var total = _toConsumableArray(this.sizes.values()).reduce(function (t, i) {
1053
+ return t + i;
1054
+ }, 0);
1055
+ this.averageSize = Math.round(total / this.sizes.size);
1056
+ }
1057
+ }, {
1058
+ key: "addScrollEventListener",
1059
+ value: function addScrollEventListener() {
1060
+ if (this.options.scroller) {
1061
+ Sortable.utils.on(this.options.scroller, 'scroll', this.onScroll);
1062
+ }
1063
+ }
1064
+ }, {
1065
+ key: "removeScrollEventListener",
1066
+ value: function removeScrollEventListener() {
1067
+ if (this.options.scroller) {
1068
+ Sortable.utils.off(this.options.scroller, 'scroll', this.onScroll);
1069
+ }
1070
+ }
1071
+ }, {
1072
+ key: "enableScroll",
1073
+ value: function enableScroll(scrollable) {
1074
+ var scroller = this.options.scroller;
1075
+ var eventFn = scrollable ? Sortable.utils.off : Sortable.utils.on;
1076
+ var wheelEvent = 'onwheel' in document.createElement('div') ? 'wheel' : 'mousewheel';
1077
+ eventFn(scroller, 'DOMMouseScroll', this.preventDefault);
1078
+ eventFn(scroller, wheelEvent, this.preventDefault);
1079
+ eventFn(scroller, 'touchmove', this.preventDefault);
1080
+ eventFn(scroller, 'keydown', this.preventDefaultForKeyDown);
1081
+ }
1082
+ }, {
1083
+ key: "preventDefault",
1084
+ value: function preventDefault(e) {
1085
+ e.preventDefault();
1086
+ }
1087
+ }, {
1088
+ key: "preventDefaultForKeyDown",
1089
+ value: function preventDefaultForKeyDown(e) {
1090
+ var keys = {
1091
+ 37: 1,
1092
+ 38: 1,
1093
+ 39: 1,
1094
+ 40: 1
1095
+ };
1096
+ if (keys[e.keyCode]) {
1097
+ this.preventDefault(e);
1098
+ return false;
1099
+ }
1100
+ }
1101
+ }, {
1102
+ key: "updateScrollElement",
1103
+ value: function updateScrollElement() {
1104
+ var scroller = this.options.scroller;
1105
+ if (elementIsDocumentOrWindow(scroller)) {
1106
+ var scrollEl = document.scrollingElement || document.documentElement || document.body;
1107
+ this.scrollEl = scrollEl;
1108
+ } else {
1109
+ this.scrollEl = scroller;
1110
+ }
1111
+ }
1112
+ }, {
1113
+ key: "updateOnScrollFunction",
1114
+ value: function updateOnScrollFunction() {
1115
+ var _this3 = this;
1116
+ var _this$options = this.options,
1117
+ debounceTime = _this$options.debounceTime,
1118
+ throttleTime = _this$options.throttleTime;
1119
+ if (debounceTime) {
1120
+ this.onScroll = debounce(function () {
1121
+ return _this3.handleScroll();
1122
+ }, debounceTime);
1123
+ } else if (throttleTime) {
1124
+ this.onScroll = throttle(function () {
1125
+ return _this3.handleScroll();
1126
+ }, throttleTime);
1127
+ } else {
1128
+ this.onScroll = function () {
1129
+ return _this3.handleScroll();
1130
+ };
1131
+ }
1132
+ }
1133
+ }, {
1134
+ key: "handleScroll",
1135
+ value: function handleScroll() {
1136
+ var offset = this.getOffset();
1137
+ var clientSize = this.getClientSize();
1138
+ var scrollSize = this.getScrollSize();
1139
+ if (offset === this.offset) {
1140
+ this.direction = 'STATIONARY';
1141
+ } else {
1142
+ this.direction = offset < this.offset ? 'FRONT' : 'BEHIND';
1143
+ }
1144
+ this.offset = offset;
1145
+ var top = this.isFront() && offset <= 0;
1146
+ var bottom = this.isBehind() && clientSize + offset + 1 >= scrollSize;
1147
+ this.options.onScroll({
1148
+ top: top,
1149
+ bottom: bottom,
1150
+ offset: offset,
1151
+ direction: this.direction
1152
+ });
1153
+ if (this.isFront()) {
1154
+ this.handleScrollFront();
1155
+ } else if (this.isBehind()) {
1156
+ this.handleScrollBehind();
1157
+ }
1158
+ }
1159
+ }, {
1160
+ key: "handleScrollFront",
1161
+ value: function handleScrollFront() {
1162
+ var scrolls = this.getScrollItems();
1163
+ if (scrolls >= this.range.start) {
1164
+ return;
1165
+ }
1166
+ var start = Math.max(scrolls - this.buffer, 0);
1167
+ this.checkIfUpdate(start, this.getEndByStart(start));
1168
+ }
1169
+ }, {
1170
+ key: "handleScrollBehind",
1171
+ value: function handleScrollBehind() {
1172
+ var scrolls = this.getScrollItems();
1173
+ if (scrolls < this.range.start + this.buffer) {
1174
+ return;
1175
+ }
1176
+ this.checkIfUpdate(scrolls, this.getEndByStart(scrolls));
1177
+ }
1178
+ }, {
1179
+ key: "getScrollItems",
1180
+ value: function getScrollItems() {
1181
+ var offset = this.offset - this.getScrollStartOffset();
1182
+ if (offset <= 0) {
1183
+ return 0;
1184
+ }
1185
+ if (this.isFixed()) {
1186
+ return Math.floor(offset / this.fixedSize);
1187
+ }
1188
+ var low = 0;
1189
+ var high = this.options.uniqueKeys.length;
1190
+ var middle = 0;
1191
+ var middleOffset = 0;
1192
+ while (low <= high) {
1193
+ middle = low + Math.floor((high - low) / 2);
1194
+ middleOffset = this.getOffsetByRange(0, middle);
1195
+ if (middleOffset === offset) {
1196
+ return middle;
1197
+ } else if (middleOffset < offset) {
1198
+ low = middle + 1;
1199
+ } else if (middleOffset > offset) {
1200
+ high = middle - 1;
1201
+ }
1202
+ }
1203
+ return low > 0 ? --low : 0;
1204
+ }
1205
+ }, {
1206
+ key: "checkIfUpdate",
1207
+ value: function checkIfUpdate(start, end) {
1208
+ var keeps = this.options.keeps;
1209
+ var total = this.options.uniqueKeys.length;
1210
+ if (total <= keeps) {
1211
+ start = 0;
1212
+ } else if (end - start < keeps - 1) {
1213
+ start = end - keeps + 1;
1214
+ }
1215
+ if (this.range.start !== start) {
1216
+ this.handleUpdate(start);
1217
+ }
1218
+ }
1219
+ }, {
1220
+ key: "handleUpdate",
1221
+ value: function handleUpdate(start) {
1222
+ var rangeChanged = this.range.start !== start;
1223
+ this.range.start = start;
1224
+ this.range.end = this.getEndByStart(start);
1225
+ this.range.front = this.getFrontOffset();
1226
+ this.range.behind = this.getBehindOffset();
1227
+ this.options.onUpdate(Object.assign({}, this.range), rangeChanged);
1228
+ }
1229
+ }, {
1230
+ key: "getFrontOffset",
1231
+ value: function getFrontOffset() {
1232
+ if (this.isFixed()) {
1233
+ return this.fixedSize * this.range.start;
1234
+ } else {
1235
+ return this.getOffsetByRange(0, this.range.start);
1236
+ }
1237
+ }
1238
+ }, {
1239
+ key: "getBehindOffset",
1240
+ value: function getBehindOffset() {
1241
+ var end = this.range.end;
1242
+ var last = this.getLastIndex();
1243
+ if (this.isFixed()) {
1244
+ return (last - end) * this.fixedSize;
1245
+ }
1246
+ return (last - end) * this.getItemSize();
1247
+ }
1248
+ }, {
1249
+ key: "getOffsetByRange",
1250
+ value: function getOffsetByRange(start, end) {
1251
+ if (start >= end) {
1252
+ return 0;
1253
+ }
1254
+ var offset = 0;
1255
+ for (var i = start; i < end; i++) {
1256
+ var size = this.sizes.get(this.options.uniqueKeys[i]);
1257
+ offset = offset + (typeof size === 'number' ? size : this.getItemSize());
1258
+ }
1259
+ return offset;
1260
+ }
1261
+ }, {
1262
+ key: "getEndByStart",
1263
+ value: function getEndByStart(start) {
1264
+ return Math.min(start + this.options.keeps - 1, this.getLastIndex());
1265
+ }
1266
+ }, {
1267
+ key: "getLastIndex",
1268
+ value: function getLastIndex() {
1269
+ var _this$options2 = this.options,
1270
+ uniqueKeys = _this$options2.uniqueKeys,
1271
+ keeps = _this$options2.keeps;
1272
+ return uniqueKeys.length > 0 ? uniqueKeys.length - 1 : keeps - 1;
1273
+ }
1274
+ }, {
1275
+ key: "getItemSize",
1276
+ value: function getItemSize() {
1277
+ return this.isFixed() ? this.fixedSize : this.options.size || this.averageSize;
1278
+ }
1279
+ }, {
1280
+ key: "getScrollStartOffset",
1281
+ value: function getScrollStartOffset() {
1282
+ var _this$options3 = this.options,
1283
+ wrapper = _this$options3.wrapper,
1284
+ scroller = _this$options3.scroller;
1285
+ if (scroller === wrapper) {
1286
+ return 0;
1287
+ }
1288
+ var offset = 0;
1289
+ if (scroller && wrapper) {
1290
+ var offsetKey = this.isHorizontal() ? 'left' : 'top';
1291
+ var rect = elementIsDocumentOrWindow(scroller) ? Sortable.utils.getRect(wrapper) : Sortable.utils.getRect(wrapper, true, scroller);
1292
+ offset = this.offset + rect[offsetKey];
1293
+ }
1294
+ return offset;
1295
+ }
1296
+ }]);
1297
+ }();
1298
+
1299
+ var SortableAttrs = ['delay', 'group', 'handle', 'lockAxis', 'disabled', 'sortable', 'draggable', 'animation', 'autoScroll', 'ghostClass', 'ghostStyle', 'chosenClass', 'scrollSpeed', 'appendToBody', 'ghostContainer', 'scrollThreshold', 'delayOnTouchOnly', 'placeholderClass', 'dropOnAnimationEnd'];
1300
+ var VirtualAttrs = ['size', 'keeps', 'buffer', 'scroller', 'direction', 'debounceTime', 'throttleTime'];
1301
+ var VirtualSortable = /*#__PURE__*/function () {
1302
+ function VirtualSortable(el, options) {
1303
+ _classCallCheck(this, VirtualSortable);
1304
+ this.el = el;
1305
+ this.options = options;
1306
+ this.initVirtual();
1307
+ this.initSortable();
1308
+ }
1309
+ return _createClass(VirtualSortable, [{
1310
+ key: "destroy",
1311
+ value: function destroy() {
1312
+ this.virtual.removeScrollEventListener();
1313
+ this.sortable.destroy();
1314
+ }
1315
+ }, {
1316
+ key: "option",
1317
+ value: function option(key, value) {
1318
+ this.options[key] = value;
1319
+ if (VirtualAttrs.includes(key) || key === 'uniqueKeys') {
1320
+ this.virtual.option(key, value);
1321
+ }
1322
+ if (SortableAttrs.includes(key)) {
1323
+ this.sortable.option(key, value);
1324
+ }
1325
+ }
1326
+ }, {
1327
+ key: "call",
1328
+ value: function call(method) {
1329
+ if (method in this.virtual) {
1330
+ var func = this.virtual[method];
1331
+ if (typeof func === 'function') {
1332
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1333
+ args[_key - 1] = arguments[_key];
1334
+ }
1335
+ return func.apply(this.virtual, args);
1336
+ }
1337
+ throw new Error("Property ".concat(String(method), " is not a function on Virtual."));
1338
+ } else {
1339
+ throw new Error("Method ".concat(String(method), " does not exist on Virtual."));
1340
+ }
1341
+ }
1342
+ // ========================================== virtual ==========================================
1343
+ }, {
1344
+ key: "initVirtual",
1345
+ value: function initVirtual() {
1346
+ var _this = this;
1347
+ var props = VirtualAttrs.reduce(function (res, key) {
1348
+ res[key] = _this.options[key];
1349
+ return res;
1350
+ }, {});
1351
+ this.virtual = new Virtual(Object.assign(Object.assign({}, props), {
1352
+ wrapper: this.options.wrapper,
1353
+ uniqueKeys: this.options.uniqueKeys,
1354
+ onScroll: function onScroll(event) {
1355
+ return _this.onScroll(event);
1356
+ },
1357
+ onUpdate: function onUpdate(range, changed) {
1358
+ return _this.onUpdate(range, changed);
1359
+ }
1360
+ }));
1361
+ }
1362
+ }, {
1363
+ key: "onScroll",
1364
+ value: function onScroll(event) {
1365
+ this.dispatchEvent('onScroll', event);
1366
+ }
1367
+ }, {
1368
+ key: "onUpdate",
1369
+ value: function onUpdate(range, changed) {
1370
+ if (this.sortableState === 'dragging' && changed) {
1371
+ this.removeDraggedEl = true;
1372
+ }
1373
+ this.dispatchEvent('onUpdate', range, changed);
1374
+ }
1375
+ // ========================================== sortable ==========================================
1376
+ }, {
1377
+ key: "initSortable",
1378
+ value: function initSortable() {
1379
+ var _this2 = this;
1380
+ var props = SortableAttrs.reduce(function (res, key) {
1381
+ res[key] = _this2.options[key];
1382
+ return res;
1383
+ }, {});
1384
+ this.sortable = new Sortable(this.el, Object.assign(Object.assign({}, props), {
1385
+ emptyInsertThreshold: 0,
1386
+ swapOnDrop: false,
1387
+ removeCloneOnDrop: function removeCloneOnDrop(event) {
1388
+ return event.from === event.to;
1389
+ },
1390
+ onDrag: function onDrag(event) {
1391
+ return _this2.onDrag(event);
1392
+ },
1393
+ onDrop: function onDrop(event) {
1394
+ return _this2.onDrop(event);
1395
+ }
1396
+ }));
1397
+ }
1398
+ }, {
1399
+ key: "onDrag",
1400
+ value: function onDrag(event) {
1401
+ this.sortableState = 'dragging';
1402
+ var key = event.node.getAttribute('data-key');
1403
+ var index = this.getIndex(key);
1404
+ // store the dragged item
1405
+ this.sortable.option('store', {
1406
+ key: key,
1407
+ index: index
1408
+ });
1409
+ this.dispatchEvent('onDrag', {
1410
+ key: key,
1411
+ index: index,
1412
+ event: event
1413
+ });
1414
+ }
1415
+ }, {
1416
+ key: "onDrop",
1417
+ value: function onDrop(event) {
1418
+ var _a, _b;
1419
+ var _Sortable$get$option = Sortable.get(event.from).option('store'),
1420
+ key = _Sortable$get$option.key,
1421
+ index = _Sortable$get$option.index;
1422
+ var evt = {
1423
+ key: key,
1424
+ event: event,
1425
+ changed: false,
1426
+ oldIndex: index,
1427
+ newIndex: index
1428
+ };
1429
+ if (!(event.from === event.to && event.node === event.target)) {
1430
+ var eventProps = this.getEventProperties(evt, event);
1431
+ Object.assign(evt, eventProps);
1432
+ }
1433
+ this.dispatchEvent('onDrop', evt);
1434
+ if (event.from === this.el && this.removeDraggedEl) {
1435
+ (_a = Sortable.dragged) === null || _a === void 0 ? void 0 : _a.remove();
1436
+ }
1437
+ if (event.from !== event.to) {
1438
+ (_b = Sortable.clone) === null || _b === void 0 ? void 0 : _b.remove();
1439
+ }
1440
+ this.sortableState = '';
1441
+ this.removeDraggedEl = false;
1442
+ }
1443
+ }, {
1444
+ key: "getEventProperties",
1445
+ value: function getEventProperties(evt, event) {
1446
+ var key = evt.key;
1447
+ var index = evt.oldIndex;
1448
+ var targetKey = event.target.getAttribute('data-key');
1449
+ var newIndex = -1;
1450
+ var oldIndex = index;
1451
+ // changes position in current list
1452
+ if (event.from === event.to) {
1453
+ // re-get the dragged element's index
1454
+ oldIndex = this.getIndex(key);
1455
+ newIndex = this.getIndex(targetKey);
1456
+ if (oldIndex < newIndex && event.relative === -1 || oldIndex > newIndex && event.relative === 1) {
1457
+ newIndex += event.relative;
1458
+ }
1459
+ } else {
1460
+ // removed from current list
1461
+ if (event.from === this.el) {
1462
+ oldIndex = this.getIndex(key);
1463
+ }
1464
+ // added to another list
1465
+ if (event.to === this.el) {
1466
+ oldIndex = -1;
1467
+ newIndex = this.getIndex(targetKey);
1468
+ if (event.relative === 0) {
1469
+ // added to last
1470
+ newIndex = this.options.uniqueKeys.length;
1471
+ } else if (event.relative === 1) {
1472
+ newIndex += event.relative;
1473
+ }
1474
+ }
1475
+ }
1476
+ return {
1477
+ changed: event.from !== event.to || newIndex !== oldIndex,
1478
+ oldIndex: oldIndex,
1479
+ newIndex: newIndex
1480
+ };
1481
+ }
1482
+ }, {
1483
+ key: "getIndex",
1484
+ value: function getIndex(key) {
1485
+ if (key === null || key === undefined) {
1486
+ return -1;
1487
+ }
1488
+ var uniqueKeys = this.options.uniqueKeys;
1489
+ for (var i = 0, len = uniqueKeys.length; i < len; i++) {
1490
+ if (isEqual(uniqueKeys[i], key)) {
1491
+ return i;
1492
+ }
1493
+ }
1494
+ return -1;
1495
+ }
1496
+ }, {
1497
+ key: "dispatchEvent",
1498
+ value: function dispatchEvent(name) {
1499
+ // call only when the option exists
1500
+ if (name in this.options) {
1501
+ var func = this.options[name];
1502
+ if (typeof func === 'function') {
1503
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
1504
+ args[_key2 - 1] = arguments[_key2];
1505
+ }
1506
+ return func.apply(this, args);
1507
+ }
1508
+ }
1509
+ }
1510
+ }]);
1511
+ }();
1512
+
1513
+ function Item(props) {
1514
+ var dataKey = props.dataKey,
1515
+ horizontal = props.horizontal,
1516
+ dragging = props.dragging,
1517
+ children = props.children,
1518
+ onSizeChange = props.onSizeChange;
1519
+ var eleRef = React.useRef(null);
1520
+ React.useLayoutEffect(function () {
1521
+ var observer;
1522
+ if ((typeof ResizeObserver === "undefined" ? "undefined" : _typeof(ResizeObserver)) !== undefined) {
1523
+ observer = new ResizeObserver(function () {
1524
+ var sizeKey = horizontal ? 'offsetWidth' : 'offsetHeight';
1525
+ var size = eleRef.current[sizeKey];
1526
+ onSizeChange(dataKey, size);
1527
+ });
1528
+ eleRef.current && (observer === null || observer === void 0 ? void 0 : observer.observe(eleRef.current));
1529
+ }
1530
+ return function () {
1531
+ if (observer) {
1532
+ observer.disconnect();
1533
+ observer = null;
1534
+ }
1535
+ };
1536
+ }, [eleRef]);
1537
+ var itemStyle = React.useMemo(function () {
1538
+ var style = children.props.style || {};
1539
+ var isDragging = isEqual(dataKey, dragging);
1540
+ return Object.assign(Object.assign({}, style), {
1541
+ display: isDragging ? 'none' : ''
1542
+ });
1543
+ }, [dragging]);
1544
+ return /*#__PURE__*/React.cloneElement(children, {
1545
+ 'data-key': dataKey,
1546
+ role: 'item',
1547
+ ref: eleRef,
1548
+ style: itemStyle,
1549
+ className: children.props.className
1550
+ });
1551
+ }
1552
+ var Item$1 = /*#__PURE__*/React.memo(Item);
1553
+
1554
+ function useChildren(props) {
1555
+ var list = props.list,
1556
+ start = props.start,
1557
+ end = props.end,
1558
+ dataKey = props.dataKey,
1559
+ horizontal = props.horizontal,
1560
+ dragging = props.dragging,
1561
+ children = props.children,
1562
+ onSizeChange = props.onSizeChange;
1563
+ return React.useMemo(function () {
1564
+ return list.slice(start, end + 1).map(function (item, i) {
1565
+ var index = start + i;
1566
+ var key = getDataKey(item, dataKey);
1567
+ return /*#__PURE__*/React.createElement(Item$1, {
1568
+ key: key,
1569
+ dataKey: key,
1570
+ dragging: dragging,
1571
+ horizontal: horizontal,
1572
+ onSizeChange: onSizeChange
1573
+ }, typeof children === 'function' ? children(item, index, key) : children);
1574
+ });
1575
+ }, [list, start, end, dataKey, horizontal, dragging, children]);
1576
+ }
1577
+
1578
+ function useCombine(states, effect) {
1579
+ React.useEffect(effect, Object.values(states));
1580
+ }
1581
+
1582
+ var draggingItem;
1583
+ function VirtualList(props, ref) {
1584
+ var _props$dataKey = props.dataKey,
1585
+ dataKey = _props$dataKey === void 0 ? '' : _props$dataKey,
1586
+ _props$dataSource = props.dataSource,
1587
+ dataSource = _props$dataSource === void 0 ? [] : _props$dataSource,
1588
+ _props$tableMode = props.tableMode,
1589
+ tableMode = _props$tableMode === void 0 ? false : _props$tableMode,
1590
+ _props$wrapTag = props.wrapTag,
1591
+ wrapTag = _props$wrapTag === void 0 ? 'div' : _props$wrapTag,
1592
+ _props$rootTag = props.rootTag,
1593
+ rootTag = _props$rootTag === void 0 ? 'div' : _props$rootTag,
1594
+ _props$style = props.style,
1595
+ style = _props$style === void 0 ? {} : _props$style,
1596
+ _props$className = props.className,
1597
+ className = _props$className === void 0 ? '' : _props$className,
1598
+ _props$wrapStyle = props.wrapStyle,
1599
+ wrapStyle = _props$wrapStyle === void 0 ? {} : _props$wrapStyle,
1600
+ _props$wrapClass = props.wrapClass,
1601
+ wrapClass = _props$wrapClass === void 0 ? '' : _props$wrapClass,
1602
+ _props$size = props.size,
1603
+ size = _props$size === void 0 ? undefined : _props$size,
1604
+ _props$keeps = props.keeps,
1605
+ keeps = _props$keeps === void 0 ? 30 : _props$keeps,
1606
+ _props$buffer = props.buffer,
1607
+ buffer = _props$buffer === void 0 ? undefined : _props$buffer,
1608
+ _props$scroller = props.scroller,
1609
+ scroller = _props$scroller === void 0 ? undefined : _props$scroller,
1610
+ _props$direction = props.direction,
1611
+ direction = _props$direction === void 0 ? 'vertical' : _props$direction,
1612
+ _props$debounceTime = props.debounceTime,
1613
+ debounceTime = _props$debounceTime === void 0 ? 0 : _props$debounceTime,
1614
+ _props$throttleTime = props.throttleTime,
1615
+ throttleTime = _props$throttleTime === void 0 ? 0 : _props$throttleTime,
1616
+ _props$delay = props.delay,
1617
+ delay = _props$delay === void 0 ? 0 : _props$delay,
1618
+ _props$group = props.group,
1619
+ group = _props$group === void 0 ? '' : _props$group,
1620
+ _props$handle = props.handle,
1621
+ handle = _props$handle === void 0 ? '' : _props$handle,
1622
+ _props$lockAxis = props.lockAxis,
1623
+ lockAxis = _props$lockAxis === void 0 ? undefined : _props$lockAxis,
1624
+ _props$disabled = props.disabled,
1625
+ disabled = _props$disabled === void 0 ? false : _props$disabled,
1626
+ _props$sortable = props.sortable,
1627
+ sortable = _props$sortable === void 0 ? true : _props$sortable,
1628
+ _props$draggable = props.draggable,
1629
+ draggable = _props$draggable === void 0 ? '[role="item"]' : _props$draggable,
1630
+ _props$animation = props.animation,
1631
+ animation = _props$animation === void 0 ? 150 : _props$animation,
1632
+ _props$autoScroll = props.autoScroll,
1633
+ autoScroll = _props$autoScroll === void 0 ? true : _props$autoScroll,
1634
+ _props$scrollSpeed = props.scrollSpeed,
1635
+ scrollSpeed = _props$scrollSpeed === void 0 ? {
1636
+ x: 10,
1637
+ y: 10
1638
+ } : _props$scrollSpeed,
1639
+ _props$ghostClass = props.ghostClass,
1640
+ ghostClass = _props$ghostClass === void 0 ? '' : _props$ghostClass,
1641
+ _props$ghostStyle = props.ghostStyle,
1642
+ ghostStyle = _props$ghostStyle === void 0 ? undefined : _props$ghostStyle,
1643
+ _props$chosenClass = props.chosenClass,
1644
+ chosenClass = _props$chosenClass === void 0 ? '' : _props$chosenClass,
1645
+ _props$placeholderCla = props.placeholderClass,
1646
+ placeholderClass = _props$placeholderCla === void 0 ? '' : _props$placeholderCla,
1647
+ _props$appendToBody = props.appendToBody,
1648
+ appendToBody = _props$appendToBody === void 0 ? false : _props$appendToBody,
1649
+ _props$scrollThreshol = props.scrollThreshold,
1650
+ scrollThreshold = _props$scrollThreshol === void 0 ? 55 : _props$scrollThreshol,
1651
+ _props$delayOnTouchOn = props.delayOnTouchOnly,
1652
+ delayOnTouchOnly = _props$delayOnTouchOn === void 0 ? false : _props$delayOnTouchOn,
1653
+ _props$dropOnAnimatio = props.dropOnAnimationEnd,
1654
+ dropOnAnimationEnd = _props$dropOnAnimatio === void 0 ? true : _props$dropOnAnimatio;
1655
+ var _React$useState = React.useState({
1656
+ start: 0,
1657
+ end: keeps - 1,
1658
+ front: 0,
1659
+ behind: 0
1660
+ }),
1661
+ _React$useState2 = _slicedToArray(_React$useState, 2),
1662
+ range = _React$useState2[0],
1663
+ setRange = _React$useState2[1];
1664
+ var dragging = React.useRef('');
1665
+ var rootElRef = React.useRef();
1666
+ var wrapElRef = React.useRef();
1667
+ /**
1668
+ * git item size by data-key
1669
+ */
1670
+ var getSize = function getSize(key) {
1671
+ return VS.current.call('getSize', key);
1672
+ };
1673
+ /**
1674
+ * Get the current scroll height
1675
+ */
1676
+ var getOffset = function getOffset() {
1677
+ return VS.current.call('getOffset');
1678
+ };
1679
+ /**
1680
+ * Get client viewport size
1681
+ */
1682
+ var getClientSize = function getClientSize() {
1683
+ return VS.current.call('getClientSize');
1684
+ };
1685
+ /**
1686
+ * Get all scroll size
1687
+ */
1688
+ var getScrollSize = function getScrollSize() {
1689
+ return VS.current.call('getScrollSize');
1690
+ };
1691
+ /**
1692
+ * Scroll to the specified offset
1693
+ */
1694
+ var scrollToOffset = function scrollToOffset(offset) {
1695
+ VS.current.call('scrollToOffset', offset);
1696
+ };
1697
+ /**
1698
+ * Scroll to the specified index position
1699
+ */
1700
+ var scrollToIndex = function scrollToIndex(index, align) {
1701
+ VS.current.call('scrollToIndex', index, align);
1702
+ };
1703
+ /**
1704
+ * Scroll to the specified data-key position
1705
+ */
1706
+ var scrollToKey = function scrollToKey(key, align) {
1707
+ var index = uniqueKeys.current.indexOf(key);
1708
+ if (index > -1) {
1709
+ VS.current.call('scrollToIndex', index, align);
1710
+ }
1711
+ };
1712
+ /**
1713
+ * Scroll to top of list
1714
+ */
1715
+ var scrollToTop = function scrollToTop() {
1716
+ scrollToOffset(0);
1717
+ };
1718
+ /**
1719
+ * Scroll to bottom of list
1720
+ */
1721
+ var scrollToBottom = function scrollToBottom() {
1722
+ VS.current.call('scrollToBottom');
1723
+ };
1724
+ React.useImperativeHandle(ref, function () {
1725
+ return {
1726
+ getSize: getSize,
1727
+ getOffset: getOffset,
1728
+ getClientSize: getClientSize,
1729
+ getScrollSize: getScrollSize,
1730
+ scrollToTop: scrollToTop,
1731
+ scrollToKey: scrollToKey,
1732
+ scrollToIndex: scrollToIndex,
1733
+ scrollToOffset: scrollToOffset,
1734
+ scrollToBottom: scrollToBottom
1735
+ };
1736
+ });
1737
+ // ========================================== data source ==========================================
1738
+ var list = React.useRef([]);
1739
+ var uniqueKeys = React.useRef([]);
1740
+ var lastListLength = React.useRef(0);
1741
+ var listLengthWhenTopLoading = React.useRef(0);
1742
+ React.useEffect(function () {
1743
+ var _a;
1744
+ list.current = dataSource;
1745
+ updateUniqueKeys();
1746
+ detectRangeChange(lastListLength.current, dataSource.length);
1747
+ // if auto scroll to the last offset
1748
+ if (listLengthWhenTopLoading.current && props.keepOffset) {
1749
+ var index = dataSource.length - listLengthWhenTopLoading.current;
1750
+ if (index > 0) {
1751
+ (_a = VS.current) === null || _a === void 0 ? void 0 : _a.call('scrollToIndex', index);
1752
+ }
1753
+ listLengthWhenTopLoading.current = 0;
1754
+ }
1755
+ lastListLength.current = dataSource.length;
1756
+ }, [dataSource]);
1757
+ React.useEffect(function () {
1758
+ initVirtualSortable();
1759
+ return function () {
1760
+ VS.current.destroy();
1761
+ };
1762
+ }, []);
1763
+ var updateUniqueKeys = function updateUniqueKeys() {
1764
+ var _a;
1765
+ uniqueKeys.current = list.current.map(function (item) {
1766
+ return getDataKey(item, dataKey);
1767
+ });
1768
+ (_a = VS.current) === null || _a === void 0 ? void 0 : _a.option('uniqueKeys', uniqueKeys.current);
1769
+ };
1770
+ var detectRangeChange = function detectRangeChange(oldListLength, newListLength) {
1771
+ var _a, _b;
1772
+ if (oldListLength === newListLength) {
1773
+ return;
1774
+ }
1775
+ var newRange = Object.assign({}, range);
1776
+ if (oldListLength > keeps && newListLength > oldListLength && newRange.end === oldListLength - 1 && ((_a = VS.current) === null || _a === void 0 ? void 0 : _a.call('isReachedBottom'))) {
1777
+ newRange.start++;
1778
+ }
1779
+ (_b = VS.current) === null || _b === void 0 ? void 0 : _b.call('updateRange', newRange);
1780
+ };
1781
+ var dispatchEvent = function dispatchEvent(name) {
1782
+ var handler = props[name];
1783
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1784
+ args[_key - 1] = arguments[_key];
1785
+ }
1786
+ handler && handler.apply(null, args);
1787
+ };
1788
+ // ========================================== virtual sortable ==========================================
1789
+ var VS = React.useRef();
1790
+ var combinedAttrs = {
1791
+ // virtual attrs
1792
+ size: size,
1793
+ keeps: keeps,
1794
+ buffer: buffer,
1795
+ scroller: scroller,
1796
+ direction: direction,
1797
+ debounceTime: debounceTime,
1798
+ throttleTime: throttleTime,
1799
+ // sortable attrs
1800
+ delay: delay,
1801
+ group: group,
1802
+ handle: handle,
1803
+ lockAxis: lockAxis,
1804
+ disabled: disabled,
1805
+ sortable: sortable,
1806
+ draggable: draggable,
1807
+ animation: animation,
1808
+ autoScroll: autoScroll,
1809
+ ghostClass: ghostClass,
1810
+ ghostStyle: ghostStyle,
1811
+ chosenClass: chosenClass,
1812
+ scrollSpeed: scrollSpeed,
1813
+ appendToBody: appendToBody,
1814
+ scrollThreshold: scrollThreshold,
1815
+ delayOnTouchOnly: delayOnTouchOnly,
1816
+ placeholderClass: placeholderClass,
1817
+ dropOnAnimationEnd: dropOnAnimationEnd
1818
+ };
1819
+ var initVirtualSortable = function initVirtualSortable() {
1820
+ VS.current = new VirtualSortable(rootElRef.current, Object.assign(Object.assign({}, combinedAttrs), {
1821
+ wrapper: wrapElRef.current,
1822
+ scroller: scroller || rootElRef.current,
1823
+ uniqueKeys: uniqueKeys.current,
1824
+ ghostContainer: wrapElRef.current,
1825
+ onDrag: onDrag,
1826
+ onDrop: onDrop,
1827
+ onScroll: onScroll,
1828
+ onUpdate: onUpdate
1829
+ }));
1830
+ };
1831
+ useCombine(combinedAttrs, function () {
1832
+ if (!VS.current) return;
1833
+ Object.keys(combinedAttrs).forEach(function (key) {
1834
+ if (props[key] !== void 0) {
1835
+ VS.current.option(key, props[key]);
1836
+ }
1837
+ });
1838
+ });
1839
+ var handleToTop = debounce(function () {
1840
+ listLengthWhenTopLoading.current = list.current.length;
1841
+ dispatchEvent('onTop');
1842
+ }, 50);
1843
+ var handleToBottom = debounce(function () {
1844
+ dispatchEvent('onBottom');
1845
+ }, 50);
1846
+ var onScroll = function onScroll(event) {
1847
+ dispatchEvent('onScroll', event);
1848
+ listLengthWhenTopLoading.current = 0;
1849
+ if (event.top) {
1850
+ handleToTop();
1851
+ } else if (event.bottom) {
1852
+ handleToBottom();
1853
+ }
1854
+ };
1855
+ var onUpdate = function onUpdate(range, changed) {
1856
+ setRange(range);
1857
+ changed && dispatchEvent('onRangeChange', range);
1858
+ };
1859
+ var onSizeChange = function onSizeChange(key, size) {
1860
+ // ignore changes for dragging element
1861
+ if (isEqual(key, dragging.current) || !VS.current) {
1862
+ return;
1863
+ }
1864
+ var sizes = VS.current.virtual.sizes.size;
1865
+ VS.current.call('updateItemSize', key, size);
1866
+ if (sizes === keeps - 1 && list.current.length > keeps) {
1867
+ VS.current.call('updateRange', range);
1868
+ }
1869
+ };
1870
+ var onDrag = function onDrag(event) {
1871
+ var _a, _b;
1872
+ var key = event.key,
1873
+ index = event.index;
1874
+ var item = list.current[index];
1875
+ dragging.current = key;
1876
+ draggingItem = item;
1877
+ if (!sortable) {
1878
+ (_a = VS.current) === null || _a === void 0 ? void 0 : _a.call('enableScroll', false);
1879
+ (_b = VS.current) === null || _b === void 0 ? void 0 : _b.option('autoScroll', false);
1880
+ }
1881
+ dispatchEvent('onDrag', Object.assign(Object.assign({}, event), {
1882
+ item: item
1883
+ }));
1884
+ };
1885
+ var onDrop = function onDrop(event) {
1886
+ var item = draggingItem;
1887
+ var oldIndex = event.oldIndex,
1888
+ newIndex = event.newIndex;
1889
+ var oldList = _toConsumableArray(list.current);
1890
+ var newList = _toConsumableArray(list.current);
1891
+ if (oldIndex === -1) {
1892
+ newList.splice(newIndex, 0, item);
1893
+ } else if (newIndex === -1) {
1894
+ newList.splice(oldIndex, 1);
1895
+ } else {
1896
+ newList.splice(oldIndex, 1);
1897
+ newList.splice(newIndex, 0, item);
1898
+ }
1899
+ VS.current.call('enableScroll', true);
1900
+ VS.current.option('autoScroll', props.autoScroll);
1901
+ dragging.current = '';
1902
+ dispatchEvent('onDrop', Object.assign(Object.assign({}, event), {
1903
+ item: item,
1904
+ list: newList,
1905
+ oldList: oldList
1906
+ }));
1907
+ };
1908
+ // ========================================== layout ==========================================
1909
+ var _React$useMemo = React.useMemo(function () {
1910
+ var front = range.front,
1911
+ behind = range.behind;
1912
+ var isHorizontal = direction === 'horizontal';
1913
+ var overflow = isHorizontal ? 'auto hidden' : 'hidden auto';
1914
+ var padding = isHorizontal ? "0px ".concat(behind, "px 0px ").concat(front, "px") : "".concat(front, "px 0px ").concat(behind, "px");
1915
+ var rootElStyle = Object.assign(Object.assign({}, style), {
1916
+ overflow: tableMode || scroller ? '' : overflow
1917
+ });
1918
+ var wrapElStyle = Object.assign(Object.assign({}, wrapStyle), {
1919
+ padding: tableMode ? '' : padding
1920
+ });
1921
+ return {
1922
+ rootElStyle: rootElStyle,
1923
+ wrapElStyle: wrapElStyle
1924
+ };
1925
+ }, [range, style, wrapStyle, scroller, tableMode, direction]),
1926
+ rootElStyle = _React$useMemo.rootElStyle,
1927
+ wrapElStyle = _React$useMemo.wrapElStyle;
1928
+ var _React$useMemo2 = React.useMemo(function () {
1929
+ var rootElTag = tableMode ? 'table' : wrapTag;
1930
+ var wrapElTag = tableMode ? 'tbody' : wrapTag;
1931
+ return {
1932
+ rootElTag: rootElTag,
1933
+ wrapElTag: wrapElTag
1934
+ };
1935
+ }, [rootTag, wrapTag, tableMode]),
1936
+ rootElTag = _React$useMemo2.rootElTag,
1937
+ wrapElTag = _React$useMemo2.wrapElTag;
1938
+ var listChildren = useChildren({
1939
+ list: dataSource,
1940
+ start: range.start,
1941
+ end: range.end,
1942
+ dataKey: dataKey,
1943
+ children: props.children,
1944
+ dragging: dragging.current,
1945
+ horizontal: direction === 'horizontal',
1946
+ onSizeChange: onSizeChange
1947
+ });
1948
+ var TableSpacer = function TableSpacer(offset, key) {
1949
+ var offsetKey = direction === 'vertical' ? 'height' : 'width';
1950
+ var style = _defineProperty({
1951
+ padding: 0,
1952
+ border: 0
1953
+ }, offsetKey, "".concat(offset, "px"));
1954
+ return /*#__PURE__*/React.createElement("tr", {
1955
+ key: key
1956
+ }, /*#__PURE__*/React.createElement("td", {
1957
+ style: style
1958
+ }));
1959
+ };
1960
+ return /*#__PURE__*/React.createElement(rootElTag, {
1961
+ ref: rootElRef,
1962
+ style: rootElStyle,
1963
+ className: className
1964
+ }, props.header, React.createElement.apply(React, [wrapElTag, {
1965
+ ref: wrapElRef,
1966
+ style: wrapElStyle,
1967
+ className: wrapClass
1968
+ }, tableMode && TableSpacer(range.front, 'front')].concat(_toConsumableArray(listChildren), [tableMode && TableSpacer(range.behind, 'behind')])), props.footer);
1969
+ }
1970
+ var index = /*#__PURE__*/React.forwardRef(VirtualList);
1971
+
1972
+ export { index as default };