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