react-virtual-sortable 1.0.0

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