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