fluid-dnd 2.1.3 → 2.2.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.
@@ -1,1271 +0,0 @@
1
- var Ce = Object.defineProperty;
2
- var Ae = (e, t, n) => t in e ? Ce(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var z = (e, t, n) => Ae(e, typeof t != "symbol" ? t + "" : t, n);
4
- const _ = "horizontal", U = "vertical", Q = "draggable", Xt = "droppable", Nt = "handler-class", $t = "dragging", Wt = "dragging-handler-class", Vt = "dropping", oe = "grabbing", xe = "grab", Kt = "disable-transition", Be = (e, t) => {
5
- const n = (a, u) => e.removeAtEvent(a, u), s = (a, u, p) => e.insertEvent(a, u, p), o = () => e.getLength(), r = (a) => e.getValue(a), c = (a) => a;
6
- return {
7
- direction: (t == null ? void 0 : t.direction) ?? U,
8
- handlerSelector: (t == null ? void 0 : t.handlerSelector) ?? Q,
9
- draggingClass: (t == null ? void 0 : t.draggingClass) ?? "dragging",
10
- droppableClass: (t == null ? void 0 : t.droppableClass) ?? "droppable-hover",
11
- isDraggable: (t == null ? void 0 : t.isDraggable) ?? (() => !0),
12
- onDragStart: (t == null ? void 0 : t.onDragStart) ?? (() => {
13
- }),
14
- onDragEnd: (t == null ? void 0 : t.onDragEnd) ?? (() => {
15
- }),
16
- droppableGroup: t == null ? void 0 : t.droppableGroup,
17
- onRemoveAtEvent: n,
18
- onInsertEvent: s,
19
- onGetLegth: o,
20
- onGetValue: r,
21
- animationDuration: (t == null ? void 0 : t.animationDuration) ?? 200,
22
- removingClass: (t == null ? void 0 : t.removingClass) ?? "removing",
23
- insertingFromClass: (t == null ? void 0 : t.insertingFromClass) ?? "from-inserting",
24
- delayBeforeRemove: (t == null ? void 0 : t.delayBeforeRemove) ?? 200,
25
- delayBeforeInsert: (t == null ? void 0 : t.delayBeforeInsert) ?? 200,
26
- mapFrom: (t == null ? void 0 : t.mapFrom) ?? c,
27
- delayBeforeTouchMoveEvent: (t == null ? void 0 : t.delayBeforeTouchMoveEvent) ?? 150
28
- };
29
- }, Me = (e, t) => {
30
- const { config: n, droppable: s } = e, { onInsertEvent: o, onDragEnd: r } = n;
31
- return {
32
- ...n,
33
- onDragEnd: (u) => {
34
- const { index: p, value: S } = u;
35
- r({ index: p, value: t(S, s) });
36
- },
37
- onInsertEvent: (u, p) => o(u, t(p, s), !0)
38
- };
39
- }, et = (e, t) => e.classList.contains(t), bt = (e, t, n = !1) => {
40
- e.classList.toggle(t, n);
41
- }, nt = (e, t) => {
42
- e.classList.add(t);
43
- }, Ct = (e, t) => {
44
- e.classList.remove(t);
45
- }, we = (e, t) => At(t).every(
46
- (n) => et(e, n)
47
- ), gt = (e) => e ? `.${At(e).join(".")}` : "", Re = (e, t) => {
48
- if (!t)
49
- return;
50
- const n = At(t);
51
- e.classList.add(...n);
52
- }, At = (e) => e ? e.split(" ").filter((t) => t) : [], Le = () => {
53
- const { scrollX: e, scrollY: t } = window;
54
- return { scrollX: e, scrollY: t };
55
- }, zt = (e) => !e || e.trim().length == 0 || e == "normal" ? 0 : parseFloat(e), Oe = (e) => e ? parseInt(e) : -1, Ne = (e) => {
56
- const t = getComputedStyle(e), n = new DOMMatrixReadOnly(t.transform);
57
- return {
58
- x: n.m41,
59
- y: n.m42
60
- };
61
- }, re = (e, t) => e.x1 > t.x1 ? re(t, e) : e.x2 < t.x1 ? 0 : e.x2 >= t.x2 ? e.x2 - e.x1 : e.x2 - t.x1, pt = (e, t) => !Fe(e, t), Fe = (e, t) => {
62
- const n = Ft(e), s = Ft(t), o = Qt(n, s, U), r = Qt(n, s, _);
63
- return o >= Math.min(n.height, s.height) / 2 && r >= Math.min(n.width, s.width) / 2;
64
- }, Qt = (e, t, n) => {
65
- const { before: s, distance: o } = B(n);
66
- return re(
67
- {
68
- x1: e[s],
69
- x2: e[s] + e[o]
70
- },
71
- {
72
- x1: t[s],
73
- x2: t[s] + t[o]
74
- }
75
- );
76
- }, O = (e, t) => e ? zt(getComputedStyle(e)[t]) : 0, Ut = (e) => {
77
- const { scrollLeft: t, scrollTop: n } = e;
78
- return { scrollLeft: t, scrollTop: n };
79
- }, Ft = (e) => e.getBoundingClientRect(), B = (e) => {
80
- const t = e == _;
81
- return {
82
- beforeMargin: t ? "marginLeft" : "marginTop",
83
- afterMargin: t ? "marginRight" : "marginBottom",
84
- borderBeforeWidth: t ? "borderLeftWidth" : "borderTopWidth",
85
- before: t ? "left" : "top",
86
- after: t ? "right" : "down",
87
- gap: t ? "columnGap" : "rowGap",
88
- distance: t ? "width" : "height",
89
- axis: t ? "x" : "y",
90
- offset: t ? "offsetX" : "offsetY",
91
- scroll: t ? "scrollX" : "scrollY",
92
- scrollElement: t ? "scrollLeft" : "scrollTop",
93
- page: t ? "pageX" : "pageY",
94
- inner: t ? "innerWidth" : "innerHeight",
95
- offsetElement: t ? "offsetLeft" : "offsetTop",
96
- scrollDistance: t ? "scrollWidth" : "scrollHeight",
97
- clientDistance: t ? "clientWidth" : "clientHeight",
98
- paddingBefore: t ? "paddingLeft" : "paddingTop",
99
- getRect: Ft
100
- };
101
- }, Lt = (e, t) => Pe(e, t), ie = (e) => [...e.children].filter(
102
- (n) => et(n, Q)
103
- ), Pe = (e, t) => {
104
- const n = [...t.children].filter(
105
- (o) => et(o, Q) && !o.isEqualNode(e)
106
- ).toReversed(), s = [...t.children].findLastIndex(
107
- (o) => o.isEqualNode(e)
108
- );
109
- return [
110
- n,
111
- s,
112
- t
113
- ];
114
- }, $e = (e) => {
115
- let t = e.parentElement;
116
- for (; t; ) {
117
- if (window.getComputedStyle(t).position === "fixed")
118
- return t;
119
- t = t.parentElement;
120
- }
121
- return null;
122
- }, ce = (e, t) => {
123
- const {
124
- before: n,
125
- borderBeforeWidth: s
126
- } = B(t), o = $e(e);
127
- return o ? Ft(o)[n] + O(o, s) : 0;
128
- }, Tt = (e) => window.TouchEvent && e instanceof TouchEvent, ot = (e) => e instanceof HTMLElement, ae = (e) => e instanceof MouseEvent, Ge = ["onmouseup", "onmousedown", "onmousemove"], Ie = (e, t, n) => {
129
- e && (e.style.height = `${t}px`, e.style.width = `${n}px`);
130
- }, Et = (e, t, n) => {
131
- !e || !ot(e) || (n == 0 && t == 0 ? e.style.transform = "" : e.style.transform = `translate(${n}px,${t}px)`);
132
- }, Ye = (e, t, n, s) => {
133
- e[t] = (o) => {
134
- if (o.defaultPrevented)
135
- return;
136
- s && s(o);
137
- const r = _t(o);
138
- n(r);
139
- };
140
- }, It = (e, t, n, s) => {
141
- n && (Xe(t) ? e[t] = n : Ye(e, t, n, s));
142
- }, Xe = (e) => Ge.includes(e), We = (e) => {
143
- const { target: t } = e;
144
- return {
145
- clientX: 0,
146
- clientY: 0,
147
- pageX: 0,
148
- pageY: 0,
149
- screenX: 0,
150
- screenY: 0,
151
- target: t,
152
- offsetX: 0,
153
- offsetY: 0
154
- };
155
- }, Ve = (e, t) => {
156
- const n = (s, o) => He(t, window, o, s);
157
- if (ae(e)) {
158
- const { offsetX: s, offsetY: o } = e;
159
- return [s, o];
160
- } else {
161
- const s = e.target;
162
- return [
163
- n(s, _),
164
- n(s, U)
165
- ];
166
- }
167
- }, _t = (e) => {
168
- const t = _e(e);
169
- if (!t)
170
- return We(e);
171
- const [n, s] = Ve(e, t), { clientX: o, clientY: r, pageX: c, pageY: a, screenX: u, screenY: p, target: S } = t;
172
- return {
173
- clientX: o,
174
- clientY: r,
175
- pageX: c,
176
- pageY: a,
177
- screenX: u,
178
- screenY: p,
179
- target: S,
180
- offsetX: n,
181
- offsetY: s
182
- };
183
- }, _e = (e) => {
184
- if (Tt(e))
185
- return e.touches[0] ?? e.changedTouches[0];
186
- if (ae(e))
187
- return e;
188
- }, He = (e, t, n, s) => {
189
- const { page: o, scroll: r, before: c, borderBeforeWidth: a, getRect: u } = B(n), p = u(s);
190
- return e[o] - t[r] - p[c] - O(s, a);
191
- }, Gt = (e, t, n = "ease-out", s = "transform") => {
192
- ot(e) && (e.style.transitionDuration = `${t}ms`, e.style.transitionTimingFunction = `${n}`, e.style.transitionProperty = `${s}`);
193
- }, le = (e, t, n) => {
194
- !e || !ot(e) || (e[t] = () => {
195
- n();
196
- });
197
- }, qe = (e) => {
198
- var t = e.querySelector("style");
199
- if (!t) {
200
- var n = document.createElement("style");
201
- return e.appendChild(n), n;
202
- }
203
- return t;
204
- }, ze = (e, t) => {
205
- const n = /\.-?[_a-zA-Z0-9-*\s<>():]+/g, [s] = t.match(n) || [];
206
- for (const o of e.cssRules) {
207
- const [r] = o.cssText.match(n) || [];
208
- if (s === r)
209
- return !0;
210
- }
211
- return !1;
212
- }, je = (e, t) => {
213
- t.forEach((n) => {
214
- Ze(e, n);
215
- });
216
- }, Ze = (e, t) => {
217
- var s;
218
- var n = qe(e);
219
- n.sheet && (ze(n.sheet, t) || (s = n.sheet) == null || s.insertRule(t, n.sheet.cssRules.length));
220
- }, ue = (e, t = {}) => {
221
- for (const n of Object.keys(t)) {
222
- const s = t[n];
223
- s != null && ke(e, `--${n}`, s);
224
- }
225
- }, ke = (e, t, n) => e && e.style.setProperty(t, n), Je = (e, t, n) => {
226
- n != 0 && (t === "vertical" ? e.scrollBy(0, n) : e.scrollBy(n, 0));
227
- }, Ke = (e, t, n) => {
228
- const { scrollDistance: s, clientDistance: o, scrollElement: r } = B(e);
229
- return n[r] / (t[s] - t[o]);
230
- }, Qe = (e) => {
231
- let t = { offsetX: 0, offsetY: 0 }, n = { top: 0, left: 0 }, s = { x: 0, y: 0 };
232
- const o = (u) => {
233
- e.style.transform = `translate( ${u.x}px, ${u.y}px)`;
234
- }, r = (u) => {
235
- e.style.top = `${u.top}px`, e.style.left = `${u.left}px`;
236
- };
237
- return [
238
- (u, p, S, b) => {
239
- const M = (R) => {
240
- const {
241
- beforeMargin: m,
242
- borderBeforeWidth: v,
243
- before: w,
244
- offset: x,
245
- scroll: $,
246
- page: G,
247
- inner: j,
248
- distance: st,
249
- axis: I,
250
- getRect: L
251
- } = B(R), Z = S[G], H = window[$], k = window[j], V = L(u)[st], q = O(u, v), Y = O(u, m), X = Z - t[x], tt = ce(u, R);
252
- if (X >= H - V / 2 && X <= H + k) {
253
- const ut = X - n[w] - q - Y - H - tt;
254
- return N(R), ut;
255
- }
256
- return s[I];
257
- }, N = (R) => {
258
- if (u && et(u, $t) && R === b) {
259
- const { before: m, distance: v, axis: w, getRect: x } = B(b), $ = x(u)[v], G = x(p), j = n[m] - G[m] + s[w], I = G[v] - $, L = j / I, Z = $ / I, H = 0.1, k = 0.2, V = 0.8;
260
- let q = 0;
261
- const Y = pt(u, p);
262
- !Y && L < k && L > -Z ? q = L / k - 1 : !Y && L > V && L < 1 + Z && (q = 1 / (1 - V) * (L - V));
263
- const X = H * $ * q;
264
- Je(p, b, X);
265
- }
266
- }, P = (R) => {
267
- const { axis: m } = B(R);
268
- s[m] = M(R), o(s);
269
- };
270
- P(_), P(U);
271
- },
272
- (u, p) => {
273
- const [S, b, M, N] = en(
274
- u,
275
- p,
276
- e
277
- );
278
- n = {
279
- top: S,
280
- left: b
281
- }, r(n), t = { offsetX: M, offsetY: N };
282
- }
283
- ];
284
- }, Ot = (e, t, n) => {
285
- const { borderBeforeWidth: s, before: o, getRect: r } = B(e);
286
- return r(t)[o] - r(n)[o] - O(n, s);
287
- }, Ue = (e, t) => {
288
- let { offsetX: n, offsetY: s, target: o } = e, r = tn(o, t);
289
- const c = o;
290
- return c && r && !c.isSameNode(r) && (n += Ot(_, c, r), s += Ot(U, c, r)), r && t != o && (n += Ot(_, r, t), s += Ot(U, r, t)), [n, s];
291
- }, tn = (e, t) => {
292
- const n = e == null ? void 0 : e.closest(`.${Nt}`);
293
- return n && n.isSameNode(t) ? e : n;
294
- }, te = (e, t, n, s) => {
295
- const { offset: o, beforeMargin: r, page: c, borderBeforeWidth: a, scroll: u } = B(e), p = ce(n, e);
296
- return t[c] - s[o] - O(n, r) - O(n, a) - window[u] - p;
297
- }, en = (e, t, n) => {
298
- const [s, o] = Ue(e, n);
299
- return [
300
- te(U, e, t, {
301
- offsetX: s,
302
- offsetY: o
303
- }),
304
- te(_, e, t, {
305
- offsetX: s,
306
- offsetY: o
307
- }),
308
- s,
309
- o
310
- ];
311
- }, fe = "startDrag", Pt = "drag", jt = "startDrop", nn = "drop", ct = "temp-child", de = "cubic-bezier(0.2, 0, 0, 1)", sn = (e) => e === nn || e === jt, Ht = (e) => !e || e.length == 0 ? 0 : zt(e.replace("px", "")), on = (e, t) => {
312
- const n = getComputedStyle(e)[t];
313
- if (n.match("%")) {
314
- const o = zt(n.replace("%", "")), { width: r } = e.getBoundingClientRect();
315
- return r * (o / 100);
316
- }
317
- return Ht(n);
318
- }, Zt = (e, t) => {
319
- if (!(e instanceof Element))
320
- return [
321
- 0,
322
- !1
323
- ];
324
- const n = on(e, t), s = getComputedStyle(e).display, o = n > 0 || s === "flex";
325
- return [n, o];
326
- }, rn = (e) => {
327
- const { top: t, left: n } = getComputedStyle(e);
328
- return [Ht(t), Ht(n)];
329
- }, cn = (e, t) => {
330
- const { gap: n } = B(t), [s, o] = Zt(e, n);
331
- return o ? s : 0;
332
- };
333
- function yt(e, t, n, s, o = e.previousElementSibling, r = e.nextElementSibling) {
334
- let { height: c, width: a } = an(
335
- n,
336
- e,
337
- o,
338
- r
339
- );
340
- return pt(e, s) && t == Pt && (c = 0, a = 0), { height: c, width: a };
341
- }
342
- const an = (e, t, n, s) => {
343
- const {
344
- afterMargin: o,
345
- beforeMargin: r,
346
- distance: c,
347
- gap: a,
348
- getRect: u
349
- } = B(e), p = O(t, o), S = O(t, r), b = O(s, r), [M, N] = Zt(
350
- t.parentElement,
351
- a
352
- ), P = u(t)[c];
353
- if (N)
354
- return ee(P, S, p, M, 0, e);
355
- const [R, m, v] = ln(
356
- n,
357
- b,
358
- p,
359
- S,
360
- o
361
- );
362
- return ee(P, m, R, 0, v, e);
363
- }, ln = (e, t, n, s, o) => {
364
- const r = Math.max(t, n);
365
- let c = s, a = t;
366
- if (e) {
367
- const u = O(
368
- e,
369
- o
370
- );
371
- c = Math.max(u, s), a = Math.max(a, u);
372
- }
373
- return [r, c, a];
374
- }, ee = (e, t, n, s, o, r) => un(r, e + t + n + s - o), un = (e, t) => e == _ ? { width: t, height: 0 } : { width: 0, height: t }, ne = (e, t) => {
375
- const {
376
- borderBeforeWidth: n,
377
- paddingBefore: s,
378
- axis: o,
379
- getRect: r
380
- } = B(e), c = O(t, n), a = O(t, s), u = r(t)[o];
381
- return c + a + u;
382
- }, fn = (e, t) => {
383
- const [n, s] = rn(t), o = ne(U, e);
384
- return [
385
- ne(_, e) - s,
386
- o - n
387
- ];
388
- };
389
- function dn(e, t, n, s, o, r, c, a, u) {
390
- let p = 0, S = 0;
391
- const b = !!(n < 0 && u);
392
- if (n === s && !b)
393
- return se(
394
- { height: p, width: S },
395
- e,
396
- o,
397
- c,
398
- b
399
- );
400
- const [M, N, P, R] = hn(t, n, s, u);
401
- if (b) {
402
- const [tt, lt] = fn(a, u);
403
- p += lt, S += tt;
404
- }
405
- const {
406
- scrollElement: m,
407
- beforeMargin: v,
408
- afterMargin: w,
409
- distance: x,
410
- gap: $
411
- } = B(e), [G, j] = Zt(a, $), [
412
- st,
413
- I,
414
- L
415
- ] = Sn(
416
- v,
417
- w,
418
- M,
419
- N == null ? void 0 : N.previousElementSibling,
420
- R,
421
- j,
422
- b
423
- ), [Z, H, k] = mn(
424
- v,
425
- w,
426
- x,
427
- P,
428
- G,
429
- j
430
- ), V = pn(
431
- H,
432
- Z,
433
- k,
434
- I,
435
- st,
436
- G
437
- ), q = b ? a[m] : gn(m, a, r), X = (R ? V - L : L - V) - q;
438
- return e === U ? p += X : e === _ && (S += X), se(
439
- { height: p, width: S },
440
- e,
441
- o,
442
- c,
443
- b
444
- );
445
- }
446
- const gn = (e, t, n) => {
447
- const s = t[e], o = n[e];
448
- return s - o;
449
- }, pn = (e, t, n, s, o, r) => {
450
- const c = Math.max(t, o);
451
- return Math.max(n, s) + e + c + r;
452
- }, hn = (e, t, n, s) => {
453
- const o = t < n, [r, c] = [t, n].toSorted(
454
- (S, b) => S - b
455
- ), a = e[t] ?? s, u = e[n];
456
- let p = o ? e.slice(r + 1, c + 1) : e.slice(r, c);
457
- return r < 0 && s && (p = e.slice(r + 1, c)), [
458
- a,
459
- u,
460
- p,
461
- o
462
- ];
463
- }, mn = (e, t, n, s, o, r) => {
464
- if (s.length == 0)
465
- return [0, 0, 0];
466
- const c = O(s[0], e);
467
- let a = 0, u = -c;
468
- for (const [p, S] of s.entries()) {
469
- const b = S.getBoundingClientRect()[n], M = O(S, e);
470
- r && (a += M), r && p > 0 ? a += o : a = Math.max(a, M), u += a + b, a = O(S, t);
471
- }
472
- return [c, u, a];
473
- }, se = (e, t, n, s, o) => {
474
- const { scroll: r, distance: c } = B(t), a = window[r], u = n[r], p = o ? 0 : u - 2 * a + s[r];
475
- return e[c] += p, e;
476
- }, Sn = (e, t, n, s, o, r, c) => {
477
- const a = o ? n.previousElementSibling : s;
478
- return vn(
479
- e,
480
- t,
481
- a,
482
- n,
483
- r,
484
- c
485
- );
486
- }, vn = (e, t, n, s, o, r) => {
487
- if (o)
488
- return [0, 0, 0];
489
- const c = O(
490
- r ? null : n,
491
- t
492
- ), a = O(s, e);
493
- let u = Math.max(c, a);
494
- return [c, a, u];
495
- }, kt = (e, t, n, s = () => !0) => {
496
- const o = new MutationObserver((r) => {
497
- if (r = r.filter(s), r.length > 0) {
498
- const c = r[0];
499
- e(o, c);
500
- }
501
- });
502
- return o.observe(t, n), o;
503
- }, Dn = "startDrag", ge = "cubic-bezier(0.2, 0, 0, 1)", pe = 50, qt = (e) => ot(e) ? e.classList.contains(ct) : !1, bn = (e, t, n) => {
504
- let s = yt(
505
- t,
506
- Dn,
507
- n,
508
- e
509
- );
510
- const o = cn(e, n), { distance: r } = B(n);
511
- s[r] -= o;
512
- const [c, a] = Tn(n, t);
513
- return s[a] = c, s;
514
- }, Tn = (e, t) => {
515
- const n = e == _ ? U : _, { distance: s, getRect: o } = B(n);
516
- return [
517
- o(t)[s],
518
- s
519
- ];
520
- }, ht = (e, t, n) => {
521
- Ie(e, t, n), e.style.minWidth = `${n}px`;
522
- }, En = (e, t, n) => (s) => {
523
- t.contains(e) && (ht(e, n.height, n.width), s.disconnect());
524
- }, yn = (e, t) => {
525
- if (!t)
526
- return;
527
- const { droppable: n, config: s, scroll: o } = e, { direction: r } = s, c = Ke(s.direction, n, o) > 0.99, { scrollDistance: a, clientDistance: u, scrollElement: p } = B(r);
528
- c && (n[p] = n[a] - n[u]);
529
- }, he = (e, t, n, s) => {
530
- if (!n)
531
- return;
532
- const { droppable: o, config: r } = n, { direction: c, animationDuration: a } = r;
533
- if (yn(n, t), o.querySelector(`.${ct}`) || !e)
534
- return;
535
- var u = e.tagName == "LI" ? "DIV" : e.tagName, p = document.createElement(u);
536
- nt(p, ct), ht(p, 0, 0);
537
- const S = bn(o, e, c);
538
- return Gt(
539
- p,
540
- a,
541
- ge,
542
- "width, min-width, height"
543
- ), [p, S, o];
544
- }, Yt = (e, t, n, s, o) => {
545
- const r = he(e, n, s);
546
- if (!r)
547
- return;
548
- const [c, a, u] = r;
549
- t.isSameNode(u) && ht(c, a.height, a.width), kt(
550
- En(c, u, a),
551
- u,
552
- {
553
- childList: !0,
554
- subtree: !0
555
- }
556
- ), u.appendChild(c);
557
- }, Cn = (e, t, n) => {
558
- const s = he(e, t, n);
559
- if (!s)
560
- return;
561
- const [o, r, c] = s;
562
- c.appendChild(o), An(o, r);
563
- }, An = (e, t) => requestAnimationFrame(() => {
564
- ht(e, t.height, t.width), requestAnimationFrame(() => {
565
- Gt(
566
- e,
567
- 0,
568
- ge,
569
- "width, min-width, height"
570
- );
571
- });
572
- }), xn = (e, t, n, s, o = !0) => {
573
- if (n) {
574
- var r = document.querySelectorAll(
575
- `${gt(n)} > .${ct}`
576
- );
577
- r.forEach((c) => {
578
- const a = c.parentElement;
579
- if (a != null && a.isSameNode(t) || !o && (a != null && a.isSameNode(e)))
580
- return;
581
- ht(c, 0, 0), setTimeout(() => {
582
- var p;
583
- (p = c.parentNode) == null || p.removeChild(c);
584
- }, s + pe);
585
- });
586
- }
587
- }, Dt = (e, t, n = !1) => {
588
- var s = e.querySelectorAll(`.${ct}`);
589
- s.forEach((o) => {
590
- const r = o;
591
- n ? (ht(r, 0, 0), setTimeout(() => {
592
- e.contains(r) && e.removeChild(r);
593
- }, t + pe)) : e.removeChild(o);
594
- });
595
- }, Bn = 50;
596
- function Mn(e, t, n, s, o, r) {
597
- let c = t;
598
- const {
599
- direction: a,
600
- handlerSelector: u,
601
- onRemoveAtEvent: p,
602
- animationDuration: S,
603
- delayBeforeInsert: b,
604
- draggingClass: M
605
- } = e, N = (l, f, h, d, y) => {
606
- if (!d)
607
- return;
608
- const { droppable: T, config: E } = d, C = yt(
609
- l,
610
- f,
611
- E.direction,
612
- T
613
- );
614
- sn(f) ? j(
615
- l,
616
- f,
617
- C,
618
- h,
619
- d,
620
- y
621
- ) : v(
622
- l,
623
- f,
624
- C,
625
- d
626
- );
627
- }, P = (l, f, h, d, y) => {
628
- const T = yt(
629
- f,
630
- "insert",
631
- e.direction,
632
- h
633
- ), { onInsertEvent: E } = e, C = ie(h);
634
- for (const [F, A] of C.entries())
635
- et(A, Q) && F >= l && G(A, T);
636
- y(), setTimeout(() => {
637
- E(l, d), me(l, h, e), tt(f), Y(f, n), Dt(n, 0, !0);
638
- }, b);
639
- }, R = (l, f, h, d) => {
640
- if (!h || !h.droppable || !h.config)
641
- return;
642
- const { droppable: y, config: T } = h;
643
- let [E] = Lt(f, y);
644
- E = [f, ...E].toReversed();
645
- const C = yt(
646
- f,
647
- "remove",
648
- T.direction,
649
- y
650
- );
651
- for (const [F, A] of E.entries())
652
- F >= l && ($(A, C), setTimeout(() => {
653
- d(A);
654
- }, S));
655
- }, m = (l) => {
656
- Dt(n, S, !0), setTimeout(() => {
657
- tt(l), Y(l, n);
658
- }, S);
659
- }, v = (l, f, h, d) => {
660
- const { config: y, droppable: T } = d, [E] = Lt(l, T), C = pt(l, T);
661
- E.length == 0 && x(
662
- h,
663
- 1,
664
- y.direction,
665
- E
666
- );
667
- for (const [F, A] of E.entries()) {
668
- if (!et(A, Q))
669
- continue;
670
- const W = w(
671
- y.direction,
672
- l,
673
- A,
674
- h
675
- );
676
- if (!C && W)
677
- h = W;
678
- else if (!C)
679
- continue;
680
- const J = E.length - F;
681
- x(
682
- h,
683
- J,
684
- y.direction,
685
- E
686
- ), f === fe ? $(A, h) : f === Pt && G(A, h);
687
- }
688
- }, w = (l, f, h, d) => {
689
- const { before: y, distance: T, axis: E, getRect: C } = B(l), F = C(f), A = C(h), W = F[y], J = A[y], mt = A[T], ft = J + mt / 2, St = Ne(h)[E], rt = ft - St;
690
- return W > rt ? { height: 0, width: 0 } : d;
691
- }, x = (l, f, h, d) => {
692
- const y = d.filter(
693
- (E) => et(E, Q)
694
- ).length, { distance: T } = B(h);
695
- l[T] == 0 ? c = Math.max(c, f) : c = Math.min(c, f - 1), c = Math.min(c, y);
696
- }, $ = (l, f) => {
697
- const { width: h, height: d } = f;
698
- Et(l, d, h);
699
- }, G = (l, f) => {
700
- const { width: h, height: d } = f;
701
- Et(l, d, h), Gt(l, S, de);
702
- }, j = (l, f, h, d, y, T) => {
703
- const { droppable: E, scroll: C, config: F } = y, [A, W] = Lt(
704
- l,
705
- E
706
- ), J = A.toReversed(), mt = W === -1 ? J.length : W;
707
- J.splice(mt, 0, l);
708
- const [ft, St, rt] = st(
709
- l,
710
- W,
711
- J,
712
- E
713
- );
714
- h = yt(
715
- l,
716
- f,
717
- F.direction,
718
- n,
719
- ft,
720
- St
721
- );
722
- const xt = Le(), Bt = dn(
723
- F.direction,
724
- J,
725
- W,
726
- rt,
727
- xt,
728
- C,
729
- d,
730
- E,
731
- l
732
- );
733
- A.length == 0 && I(
734
- void 0,
735
- h,
736
- l,
737
- Bt
738
- );
739
- for (const [Mt, wt] of A.toReversed().entries()) {
740
- let Rt = h;
741
- rt - 1 >= Mt && (Rt = { height: 0, width: 0 }), f === jt && !et(wt, ct) && I(
742
- wt,
743
- Rt,
744
- l,
745
- Bt
746
- );
747
- }
748
- L(
749
- rt,
750
- l,
751
- F,
752
- E,
753
- T
754
- );
755
- }, st = (l, f, h, d) => {
756
- const T = pt(l, d) ? f : c, E = () => f < T ? [T, T + 1] : f > T ? [T - 1, T] : [T - 1, T + 1], [C, F] = E(), A = h[C] ?? null, W = h[F] ?? null;
757
- return [
758
- A,
759
- W,
760
- T
761
- ];
762
- }, I = (l, f, h, d) => {
763
- Et(l, f.height, f.width), Et(
764
- h,
765
- d.height,
766
- d.width
767
- );
768
- }, L = (l, f, h, d, y) => {
769
- const { onInsertEvent: T, onDragEnd: E } = h;
770
- nt(f, Vt), k(f, n, d, () => {
771
- if (Ct(f, Vt), y != null) {
772
- const C = p(y, !0);
773
- C != null && (T(l, C, !0), E({ value: C, index: l })), H(f), Z();
774
- }
775
- });
776
- }, Z = () => {
777
- if (s) {
778
- var l = document.querySelectorAll(
779
- `${gt(s)} > .${Q}`
780
- );
781
- for (const f of l)
782
- X(f);
783
- }
784
- }, H = (l) => {
785
- setTimeout(() => {
786
- Ct(l, M);
787
- }, Bn);
788
- }, k = (l, f, h, d) => {
789
- setTimeout(() => {
790
- d && d(), V(f, h), q(h), tt(l), Y(l, f), Y(l, h);
791
- }, S);
792
- }, V = (l, f) => {
793
- l.isSameNode(f) ? Dt(l, S) : (Dt(l, S, !0), Dt(f, S));
794
- }, q = (l) => {
795
- if (n.isSameNode(l))
796
- return;
797
- var [f] = n.querySelectorAll(`.${ct}`);
798
- if (!f)
799
- return;
800
- const { distance: h } = B(a);
801
- ot(f) && (f.style[h] = "0px");
802
- }, Y = (l, f) => {
803
- const [h] = Lt(l, f);
804
- for (const d of [...h, l])
805
- X(d);
806
- }, X = (l) => {
807
- ot(l) && (l.style.transition = "", l.style.transform = "");
808
- }, tt = (l) => {
809
- r(), ut(l, !1), l.style.transform = "", l.style.transition = "", l.style.top = "", l.style.left = "", ue(l, {
810
- fixedHeight: "",
811
- fixedWidth: ""
812
- });
813
- }, lt = (l, f) => {
814
- const h = f.querySelector(u);
815
- bt(document.body, oe, l), bt(h || f, Wt, l);
816
- }, ut = (l, f) => {
817
- bt(l, $t, f), lt(f, l), o.toggleGrabClass(!f);
818
- };
819
- return [
820
- N,
821
- R,
822
- P,
823
- m,
824
- ut
825
- ];
826
- }
827
- const wn = (e) => e.addedNodes.values().filter((n) => !qt(n)).toArray().length > 0, me = (e, t, n) => {
828
- const { insertingFromClass: s, animationDuration: o } = n, r = kt(() => {
829
- const a = ie(t)[e];
830
- nt(a, s), nt(a, Kt), setTimeout(() => {
831
- Ct(a, Kt), Ct(a, s), r.disconnect();
832
- }, o);
833
- }, t, {
834
- childList: !0
835
- }, wn);
836
- }, $n = (e, t, n, s) => {
837
- if (!t)
838
- return;
839
- const { onInsertEvent: o, delayBeforeInsert: r } = e;
840
- setTimeout(() => {
841
- o(n, s), me(n, t, e);
842
- }, r);
843
- }, K = class K {
844
- static addConfig(t, n) {
845
- const s = K.configs.filter(
846
- (r) => !r.droppable.isSameNode(t)
847
- ), o = Ut(t);
848
- s.push({
849
- droppable: t,
850
- config: n,
851
- scroll: o
852
- }), K.configs = s;
853
- }
854
- static updateScrolls(t, n) {
855
- for (const s of K.configs) {
856
- const { droppable: o } = s;
857
- (n && we(o, n) || o.isSameNode(t)) && (s.scroll = Ut(o));
858
- }
859
- }
860
- static getConfig(t) {
861
- return K.configs.find(
862
- ({ droppable: s }) => s.isSameNode(t)
863
- );
864
- }
865
- };
866
- z(K, "configs", []), z(K, "removeObsoleteConfigs", () => {
867
- const t = K.configs.filter(
868
- ({ droppable: n }) => document.contains(n)
869
- );
870
- K.configs = t;
871
- });
872
- let at = K;
873
- class Rn {
874
- constructor(t, n, s, o, r, c) {
875
- z(this, "initial");
876
- z(this, "current");
877
- z(this, "parent");
878
- z(this, "draggableElement");
879
- z(this, "groupClass");
880
- z(this, "dragEvent");
881
- z(this, "changeDroppable");
882
- z(this, "mapFrom");
883
- this.parent = s, this.draggableElement = t, this.groupClass = n, this.dragEvent = o, this.mapFrom = c, this.initial = s ? at.getConfig(s) : void 0, this.changeDroppable = r;
884
- }
885
- getDraggableAncestor(t, n, s) {
886
- return document.elementsFromPoint(t, n).filter((o) => !o.isSameNode(s));
887
- }
888
- getElementBelow(t, n, s = !0) {
889
- const o = (c) => {
890
- const [a] = c.getDraggableAncestor(
891
- n.clientX,
892
- n.clientY,
893
- t
894
- );
895
- return a;
896
- };
897
- let r = null;
898
- return s ? (t.hidden = !0, r = o(this), t.hidden = !1) : r = o(this), r;
899
- }
900
- getCurrent(t, n, s = !0) {
901
- const o = this.getElementBelow(t, n, s);
902
- return !this.groupClass || !o ? void 0 : o.closest(
903
- gt(this.groupClass)
904
- );
905
- }
906
- isOutsideOfAllDroppables(t) {
907
- return (this.groupClass ? Array.from(
908
- document.querySelectorAll(gt(this.groupClass))
909
- ) : [this.parent]).every(
910
- (s) => pt(t, s)
911
- );
912
- }
913
- isNotInsideAnotherDroppable(t, n) {
914
- return !pt(t, n) || this.isOutsideOfAllDroppables(t);
915
- }
916
- onScrollEvent() {
917
- this.dragEvent();
918
- }
919
- setOnScroll(t) {
920
- le(t, "onscroll", () => {
921
- this.onScrollEvent();
922
- });
923
- }
924
- getConfigFrom(t) {
925
- const n = at.getConfig(t);
926
- if (n)
927
- return t.isSameNode(this.parent) ? n : {
928
- ...n,
929
- config: Me(n, this.mapFrom)
930
- };
931
- }
932
- getCurrentConfig(t) {
933
- var o;
934
- const n = this.draggableElement;
935
- if (this.current && this.isNotInsideAnotherDroppable(
936
- n,
937
- (o = this.current) == null ? void 0 : o.droppable
938
- ))
939
- return this.current;
940
- const s = this.getCurrent(n, t);
941
- return s ? (ot(s) && !s.onscroll && this.setOnScroll(s), this.getConfigFrom(s)) : this.getConfigFrom(this.parent);
942
- }
943
- updateConfig(t) {
944
- const n = this.current;
945
- this.current = this.getCurrentConfig(t), this.changeDroppable(this.current, n);
946
- }
947
- isOutside(t, n = !0) {
948
- const s = this.draggableElement;
949
- return !this.getCurrent(s, t, n);
950
- }
951
- }
952
- function Ln(e, t, n, s, o) {
953
- const {
954
- handlerSelector: r,
955
- isDraggable: c,
956
- droppableGroup: a,
957
- animationDuration: u,
958
- delayBeforeRemove: p,
959
- draggingClass: S,
960
- removingClass: b,
961
- onRemoveAtEvent: M,
962
- droppableClass: N,
963
- onDragStart: P,
964
- delayBeforeTouchMoveEvent: R
965
- } = n, m = At(a).map((i) => `droppable-group-${i}`).join(" ");
966
- let v = 0, w = {
967
- scrollX: 0,
968
- scrollY: 0
969
- }, x = { pageX: 0, pageY: 0 }, $, G;
970
- const [j, st] = Qe(e), I = () => {
971
- v = 0;
972
- }, [
973
- L,
974
- Z,
975
- H,
976
- k,
977
- V
978
- ] = Mn(
979
- n,
980
- t,
981
- s,
982
- m,
983
- o,
984
- I
985
- ), q = () => {
986
- nt(e, Q);
987
- }, Y = (i) => {
988
- nt(i, Nt), o.addSubscriber(i);
989
- }, X = () => {
990
- if (c(e)) {
991
- const i = e.querySelector(r);
992
- Y(i || e);
993
- }
994
- }, tt = () => {
995
- X(), q();
996
- }, lt = (i) => {
997
- const g = i == null ? void 0 : i.querySelector(`.${Nt}`), D = g == null ? void 0 : g.parentElement;
998
- return g && D && et(D, Xt) && !D.isSameNode(s) ? null : g;
999
- }, ut = (i) => {
1000
- const g = lt(i) ?? i;
1001
- g && c(i) && (It(g, "onmousedown", ft("mousemove", "mouseup")), It(
1002
- g,
1003
- "ontouchstart",
1004
- ft("touchmove", "touchend"),
1005
- (D) => {
1006
- G = {
1007
- x: D.touches[0].clientX,
1008
- y: D.touches[0].clientY
1009
- };
1010
- }
1011
- ), l(g)), i != null && i.isSameNode(g) || It(i, "onmousedown", St), nt(s, Xt);
1012
- }, l = (i) => {
1013
- const g = i.querySelectorAll("img");
1014
- Array.from(g).forEach((D) => {
1015
- D.onmousedown = () => !1;
1016
- });
1017
- }, f = () => {
1018
- if (x.pageX == 0 && x.pageY == 0 || !d.current)
1019
- return;
1020
- const { droppable: i, config: g } = d.current;
1021
- j(e, i, x, g.direction), L(e, Pt, w, d.current);
1022
- }, h = (i, g) => {
1023
- g && v == 2 && !(i != null && i.droppable.isSameNode(g.droppable)) && L(e, Pt, w, g);
1024
- }, d = new Rn(
1025
- e,
1026
- m,
1027
- s,
1028
- f,
1029
- h,
1030
- n.mapFrom
1031
- ), y = (i) => {
1032
- if (!d.current)
1033
- return;
1034
- const g = m ? Array.from(document.querySelectorAll(gt(m))) : [s];
1035
- for (const D of g)
1036
- D.classList.toggle(
1037
- N,
1038
- !i && D.isSameNode(d.current.droppable)
1039
- );
1040
- }, T = (i, g = !1) => {
1041
- d.updateConfig(i);
1042
- const D = d.isOutside(i);
1043
- y(D), v === 1 && !g ? Mt(i) : v === 2 && (E(D), Rt(i));
1044
- }, E = (i = !0) => {
1045
- if (!d.current)
1046
- return;
1047
- const { droppable: g } = d.current;
1048
- xn(g, s, m, u, i), !i && Yt(
1049
- e,
1050
- s,
1051
- v == 1,
1052
- d.current
1053
- );
1054
- }, C = (i) => {
1055
- if (Tt(i) && G && v == 1) {
1056
- const g = Math.abs(i.touches[0].clientX - G.x), D = Math.abs(i.touches[0].clientY - G.y);
1057
- if (Math.abs(g) > 5 && Math.abs(D) > 5)
1058
- return clearTimeout($), !1;
1059
- }
1060
- return !0;
1061
- }, F = (i) => {
1062
- clearTimeout($);
1063
- const g = _t(i);
1064
- if (Tt(i) && i.cancelable && v == 2 && i.preventDefault(), Tt(i) && !i.cancelable || !C(i)) {
1065
- xt("touchmove", i);
1066
- return;
1067
- }
1068
- T(g, Tt(i));
1069
- }, A = (i, g) => {
1070
- i == "touchmove" ? $ = setTimeout(() => {
1071
- g();
1072
- }, R) : g();
1073
- }, W = (i, g) => {
1074
- const { clientX: D, clientY: dt } = i, it = document.elementFromPoint(D, dt), vt = it == null ? void 0 : it.closest(`.${Q}`);
1075
- return vt && g.isSameNode(vt);
1076
- }, J = (i) => {
1077
- const g = n.onGetValue(t);
1078
- return { index: t, element: i, value: g };
1079
- }, mt = (i) => {
1080
- d.updateConfig(i), y(d.isOutside(i)), Mt(i);
1081
- }, ft = (i, g) => (D) => {
1082
- if (!W(D, e))
1083
- return;
1084
- at.updateScrolls(s, m);
1085
- const { scrollX: dt, scrollY: it } = window;
1086
- if (w = { scrollX: dt, scrollY: it }, v === 0) {
1087
- v = 1;
1088
- const vt = J(e);
1089
- vt && P(vt), A(i, () => {
1090
- i == "touchmove" && mt(D);
1091
- }), document.addEventListener(i, F, {
1092
- passive: !1
1093
- }), Se(s), document.addEventListener(g, rt(i), {
1094
- once: !0
1095
- });
1096
- }
1097
- }, St = (i) => d.updateConfig(i), rt = (i) => (g) => {
1098
- xt(i, g);
1099
- }, xt = (i, g) => {
1100
- y(!0);
1101
- const D = _t(g);
1102
- De(d.isOutside(D, !1)), clearTimeout($), document.removeEventListener(i, F), d.updateConfig(D);
1103
- const dt = d.getCurrentConfig(D);
1104
- if (dt) {
1105
- const { droppable: it } = dt;
1106
- Bt(it);
1107
- }
1108
- s.onscroll = null, I();
1109
- }, Bt = (i) => {
1110
- if (i.onscroll = null, !m)
1111
- return;
1112
- const g = Array.from(
1113
- document.querySelectorAll(gt(m))
1114
- );
1115
- for (const D of g)
1116
- ot(D) && (D.onscroll = null);
1117
- }, Mt = (i) => {
1118
- Yt(
1119
- e,
1120
- s,
1121
- v == 1,
1122
- d.current
1123
- ), wt(), L(
1124
- e,
1125
- fe,
1126
- w,
1127
- d.current
1128
- ), be(e), st(i, e);
1129
- }, wt = () => {
1130
- v = 2;
1131
- }, Rt = (i) => {
1132
- const { pageX: g, pageY: D } = i;
1133
- x = { pageX: g, pageY: D }, f();
1134
- }, Se = (i) => le(i, "onscroll", ve), ve = () => f(), De = (i) => {
1135
- if (v !== 2 && v !== 1) {
1136
- I();
1137
- return;
1138
- }
1139
- v = 3, Jt(e), e.classList.contains($t) && L(
1140
- e,
1141
- jt,
1142
- w,
1143
- i ? d.initial : d.current,
1144
- t
1145
- );
1146
- }, Jt = (i) => {
1147
- Gt(i, u, de), Et(i, 0, 0);
1148
- }, be = (i) => {
1149
- const { height: g, width: D } = i.getBoundingClientRect();
1150
- ue(i, {
1151
- fixedHeight: `${g}px`,
1152
- fixedWidth: `${D}px`
1153
- }), V(i, !0), bt(i, S, !0), i.style.transition = "";
1154
- }, Te = (i, g) => {
1155
- Ct(e, b), Yt(
1156
- e,
1157
- s,
1158
- v == 1,
1159
- d.initial
1160
- ), Z(i, e, g, (D) => {
1161
- Jt(D), k(e);
1162
- }), M(t, !0);
1163
- }, Ee = (i) => {
1164
- if (!d.initial)
1165
- return;
1166
- const g = d.initial;
1167
- i == t && (nt(e, b), setTimeout(() => {
1168
- Te(i, g);
1169
- }, p));
1170
- }, ye = (i, g) => {
1171
- (i === t || i === n.onGetLegth() && t === i - 1) && H(i, e, s, g, () => {
1172
- Cn(
1173
- e,
1174
- v == 1,
1175
- d.initial
1176
- );
1177
- });
1178
- };
1179
- return tt(), ut(e), [Ee, ye];
1180
- }
1181
- const On = (e, t) => {
1182
- e && Re(t, e);
1183
- }, Nn = () => {
1184
- je(document.body, [
1185
- `.${Q}{touch-action:manipulation;user-select:none;box-sizing:border-box!important;-webkit-user-select:none;}`,
1186
- `.${Nt}{pointer-events:auto!important;}`,
1187
- `.${xe}{cursor:grab;}`,
1188
- ".temp-child{touch-action:none;pointer-events:none;box-sizing:border-box!important;}",
1189
- ".droppable{box-sizing:border-box!important;}",
1190
- `.${$t}{position:fixed;z-index:5000;width:var(--fixedWidth)!important;height:var(--fixedHeight)!important;}`,
1191
- `.${Wt}{pointer-events:none!important;}`,
1192
- `.${Vt}{pointer-events:none!important;}`,
1193
- `.${oe}{cursor:grabbing;}`,
1194
- ".disable-transition{transition:none!important;}"
1195
- ]);
1196
- };
1197
- function Fn(e, t, n, s = "index") {
1198
- const o = s;
1199
- let r = [], c = [];
1200
- const { droppableGroup: a } = e;
1201
- if (!n)
1202
- return [
1203
- r,
1204
- c
1205
- ];
1206
- const u = At(a).map((p) => `droppable-group-${p}`).join(" ");
1207
- Nn(), On(u, n);
1208
- for (const p of n.children) {
1209
- const S = p.getAttribute(o), b = Oe(S), M = p;
1210
- if (M && b >= 0) {
1211
- const [N, P] = Ln(
1212
- M,
1213
- b,
1214
- e,
1215
- n,
1216
- t
1217
- );
1218
- r.push(N), c.push(P);
1219
- }
1220
- }
1221
- return [
1222
- r,
1223
- c
1224
- ];
1225
- }
1226
- function Gn(e, t, n, s = "index") {
1227
- let o = [], r = [], c;
1228
- const a = Be(e, n), u = (m) => {
1229
- for (const v of o)
1230
- v(m);
1231
- }, p = (m, v) => {
1232
- if (a.onGetLegth() === 0)
1233
- e.insertToListEmpty(a, m, v);
1234
- else
1235
- for (const x of r)
1236
- x(m, v);
1237
- }, S = (m) => {
1238
- const [v, w] = Fn(a, t, m, s);
1239
- o = v, r = w;
1240
- }, b = (m) => {
1241
- const v = m.addedNodes.values().filter((x) => !qt(x)).toArray(), w = m.removedNodes.values().filter((x) => !qt(x)).toArray();
1242
- return v.length > 0 || w.length > 0;
1243
- }, M = (m) => {
1244
- c = kt(
1245
- () => {
1246
- S(m);
1247
- },
1248
- m,
1249
- { childList: !0 },
1250
- b
1251
- );
1252
- }, N = (m) => {
1253
- nt(m, Xt);
1254
- }, P = (m) => {
1255
- at.addConfig(
1256
- m,
1257
- a
1258
- );
1259
- };
1260
- return [u, p, (m) => {
1261
- if (m)
1262
- return N(m), P(m), M(m), S(m), at.removeObsoleteConfigs(), c;
1263
- }];
1264
- }
1265
- export {
1266
- xe as G,
1267
- nt as a,
1268
- Gn as d,
1269
- $n as i,
1270
- bt as t
1271
- };