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