fluid-dnd 1.0.7-beta.0 → 1.0.9-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,1255 +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), vt = (t, e, n = !1) => {
5
- t.classList.toggle(e, n);
6
- }, nt = (t, e) => {
7
- t.classList.add(e);
8
- }, yt = (t, e) => {
9
- t.classList.remove(e);
10
- }, De = (t, e) => Et(e).every(
11
- (n) => et(t, n)
12
- ), gt = (t) => t ? `.${Et(t).join(".")}` : "", ve = (t, e) => {
13
- if (!e)
14
- return;
15
- const n = Et(e);
16
- t.classList.add(...n);
17
- }, Et = (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
- }, bt = (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: g, target: h } = e;
136
- return {
137
- clientX: o,
138
- clientY: i,
139
- pageX: c,
140
- pageY: l,
141
- screenX: f,
142
- screenY: g,
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), g = f(s);
154
- return t[o] - e[i] - g[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 Tt(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), g = 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, g, B, 0, t);
233
- const [D, v, R] = qe(
234
- n,
235
- b,
236
- g,
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 g = 0, h = 0;
269
- const b = !!(n < 0 && f);
270
- if (n === s && !b)
271
- return te(
272
- { height: g, 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
- g += 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 ? g += $ : t === H && (h += $), te(
317
- { height: g, 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 g = o ? t.slice(i + 1, c + 1) : t.slice(i, c);
335
- return i < 0 && s && (g = t.slice(i + 1, c)), [
336
- l,
337
- f,
338
- g,
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 [g, h] of s.entries()) {
347
- const b = h.getBoundingClientRect()[n], B = L(h, t);
348
- i && (l += B), i && g > 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], g = o ? 0 : f - 2 * l + s[i];
353
- return t[c] += g, 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 = Tt(
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
- }, Ct = (t, e, n) => {
404
- we(t, e, n), t.style.minWidth = `${n}px`;
405
- }, cn = (t, e) => {
406
- if (!e)
407
- return;
408
- const { droppable: n, config: s, scroll: o } = t, { direction: i } = s, c = nn(s.direction, n, o) > 0.99, { scrollDistance: l, clientDistance: f, scrollElement: g } = w(i);
409
- c && (n[g] = n[l] - n[f]);
410
- }, ge = (t, e, n, s) => {
411
- if (!n)
412
- return;
413
- const { droppable: o, config: i } = n, { direction: c, animationDuration: l } = i;
414
- if (cn(n, e), o.querySelector(`.${pt}`) || !t)
415
- return;
416
- var f = t.tagName == "LI" ? "DIV" : t.tagName, g = document.createElement(f);
417
- nt(g, pt), Ct(g, 0, 0);
418
- const h = on(o, t, c);
419
- return Nt(
420
- g,
421
- l,
422
- fe,
423
- "width, min-width, height"
424
- ), [g, h, o];
425
- }, Gt = (t, e, n, s, o) => {
426
- const i = ge(t, n, s);
427
- if (!i)
428
- return;
429
- const [c, l, f] = i;
430
- e.isSameNode(f) && Ct(c, l.height, l.width);
431
- const g = kt(
432
- () => {
433
- g.disconnect();
434
- },
435
- f,
436
- {
437
- childList: !0,
438
- subtree: !0
439
- }
440
- );
441
- f.appendChild(c);
442
- }, an = (t, e, n) => {
443
- const s = ge(t, e, n);
444
- if (!s)
445
- return;
446
- const [o, i, c] = s;
447
- c.appendChild(o), ln(o, i);
448
- }, ln = (t, e) => requestAnimationFrame(() => {
449
- Ct(t, e.height, e.width), requestAnimationFrame(() => {
450
- Nt(
451
- t,
452
- 0,
453
- fe,
454
- "width, min-width, height"
455
- );
456
- });
457
- }), un = (t, e, n, s, o = !0) => {
458
- if (n) {
459
- var i = document.querySelectorAll(
460
- `${gt(n)} > .${pt}`
461
- );
462
- i.forEach((c) => {
463
- const l = c.parentElement;
464
- if (l != null && l.isSameNode(e) || !o && (l != null && l.isSameNode(t)))
465
- return;
466
- Ct(c, 0, 0), setTimeout(() => {
467
- var g;
468
- (g = c.parentNode) == null || g.removeChild(c);
469
- }, s);
470
- });
471
- }
472
- }, Dt = (t, e, n = !1) => {
473
- var s = t.querySelectorAll(`.${pt}`);
474
- s.forEach((o) => {
475
- n ? (Ct(o, 0, 0), setTimeout(() => {
476
- t.contains(o) && t.removeChild(o);
477
- }, e)) : t.removeChild(o);
478
- });
479
- }, fn = 50;
480
- function gn(t, e, n, s, o, i) {
481
- let c = e;
482
- const {
483
- direction: l,
484
- handlerSelector: f,
485
- onRemoveAtEvent: g,
486
- animationDuration: h,
487
- delayBeforeInsert: b,
488
- draggingClass: B
489
- } = t, M = (r, u, d, m, C) => {
490
- if (!m)
491
- return;
492
- const { droppable: T, config: y } = m, A = Tt(
493
- r,
494
- u,
495
- y.direction,
496
- T
497
- );
498
- Xe(u) ? F(
499
- r,
500
- u,
501
- A,
502
- d,
503
- m,
504
- C
505
- ) : R(
506
- r,
507
- u,
508
- A,
509
- m
510
- );
511
- }, S = (r, u, d, m, C) => {
512
- const T = Tt(
513
- u,
514
- "insert",
515
- t.direction,
516
- d
517
- ), { onInsertEvent: y } = t, A = oe(d);
518
- for (const [O, x] of A.entries())
519
- et(x, Q) && O >= r && X(x, T);
520
- C(), setTimeout(() => {
521
- y(r, m), Dt(n, 0, !0), de(r, d, t), tt(u), V(u, n);
522
- }, b);
523
- }, D = (r, u, d, m) => {
524
- if (!d || !d.droppable || !d.config)
525
- return;
526
- const { droppable: C, config: T } = d;
527
- let [y] = Rt(u, C);
528
- y = [u, ...y].toReversed();
529
- const A = Tt(
530
- u,
531
- "remove",
532
- T.direction,
533
- C
534
- );
535
- for (const [O, x] of y.entries())
536
- O >= r && (W(x, A), setTimeout(() => {
537
- m(x);
538
- }, h));
539
- }, v = (r) => {
540
- Dt(n, h, !0), setTimeout(() => {
541
- tt(r), V(r, n);
542
- }, h);
543
- }, R = (r, u, d, m) => {
544
- const { config: C, droppable: T } = m, [y] = Rt(r, T), A = dt(r, T);
545
- y.length == 0 && I(
546
- d,
547
- 1,
548
- C.direction,
549
- y
550
- );
551
- for (const [O, x] of y.entries()) {
552
- if (!et(x, Q))
553
- continue;
554
- const G = N(
555
- C.direction,
556
- r,
557
- x,
558
- d
559
- );
560
- if (!A && G)
561
- d = G;
562
- else if (!A)
563
- continue;
564
- const Z = y.length - O;
565
- I(
566
- d,
567
- Z,
568
- C.direction,
569
- y
570
- ), u === le ? W(x, d) : u === Pt && X(x, d);
571
- }
572
- }, N = (r, u, d, m) => {
573
- const { before: C, distance: T, axis: y, getRect: A } = w(r), O = A(u), x = A(d), G = O[C], Z = x[C], ut = x[T], ht = Z + ut / 2, mt = ye(d)[y], ct = ht - mt;
574
- return G > ct ? { height: 0, width: 0 } : m;
575
- }, I = (r, u, d, m) => {
576
- const C = m.filter(
577
- (y) => et(y, Q)
578
- ).length, { distance: T } = w(d);
579
- r[T] == 0 ? c = Math.max(c, u) : c = Math.min(c, u - 1), c = Math.min(c, C);
580
- }, W = (r, u) => {
581
- const { width: d, height: m } = u;
582
- bt(r, m, d);
583
- }, X = (r, u) => {
584
- const { width: d, height: m } = u;
585
- bt(r, m, d), Nt(r, h, ue);
586
- }, F = (r, u, d, m, C, T) => {
587
- const { droppable: y, scroll: A, config: O } = C, [x, G] = Rt(
588
- r,
589
- y
590
- ), Z = x.toReversed(), ut = G === -1 ? Z.length : G;
591
- Z.splice(ut, 0, r);
592
- const [ht, mt, ct] = st(
593
- r,
594
- G,
595
- Z,
596
- y
597
- );
598
- d = Tt(
599
- r,
600
- u,
601
- O.direction,
602
- n,
603
- ht,
604
- mt
605
- );
606
- const Ft = be(), At = ke(
607
- O.direction,
608
- Z,
609
- G,
610
- ct,
611
- Ft,
612
- A,
613
- m,
614
- y,
615
- r
616
- );
617
- x.length == 0 && _(
618
- void 0,
619
- d,
620
- r,
621
- At
622
- );
623
- for (const [xt, wt] of x.toReversed().entries()) {
624
- let Bt = d;
625
- ct - 1 >= xt && (Bt = { height: 0, width: 0 }), u === zt && !et(wt, pt) && _(
626
- wt,
627
- Bt,
628
- r,
629
- At
630
- );
631
- }
632
- P(
633
- ct,
634
- r,
635
- O,
636
- y,
637
- T
638
- );
639
- }, st = (r, u, d, m) => {
640
- 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 = d[A] ?? null, G = d[O] ?? null;
641
- return [
642
- x,
643
- G,
644
- T
645
- ];
646
- }, _ = (r, u, d, m) => {
647
- bt(r, u.height, u.width), bt(
648
- d,
649
- m.height,
650
- m.width
651
- );
652
- }, P = (r, u, d, m, C) => {
653
- const { onInsertEvent: T, onDragEnd: y } = d;
654
- nt(u, Xt), z(u, n, m, () => {
655
- if (yt(u, Xt), C != null) {
656
- const A = g(C);
657
- A != null && (T(r, A), y({ value: A, index: r })), q(u), k();
658
- }
659
- });
660
- }, k = () => {
661
- if (s) {
662
- var r = document.querySelectorAll(
663
- `${gt(s)} > .${Q}`
664
- );
665
- for (const u of r)
666
- $(u);
667
- }
668
- }, q = (r) => {
669
- setTimeout(() => {
670
- yt(r, B);
671
- }, fn);
672
- }, z = (r, u, d, m) => {
673
- setTimeout(() => {
674
- m && m(), Y(u, d), j(d), tt(r), V(r, u), V(r, d);
675
- }, h);
676
- }, Y = (r, u) => {
677
- r.isSameNode(u) ? Dt(r, h) : (Dt(r, h, !0), Dt(u, h));
678
- }, j = (r) => {
679
- if (n.isSameNode(r))
680
- return;
681
- var [u] = n.querySelectorAll(`.${pt}`);
682
- if (!u)
683
- return;
684
- const { distance: d } = w(l);
685
- at(u) && (u.style[d] = "0px");
686
- }, V = (r, u) => {
687
- const [d] = Rt(r, u);
688
- for (const m of [...d, r])
689
- $(m);
690
- }, $ = (r) => {
691
- at(r) && (r.style.transition = "", r.style.transform = "");
692
- }, tt = (r) => {
693
- i(), lt(r, !1), r.style.transform = "", r.style.transition = "", r.style.top = "", r.style.left = "", ae(r, {
694
- fixedHeight: "",
695
- fixedWidth: ""
696
- });
697
- }, ot = (r, u) => {
698
- const d = u.querySelector(f);
699
- vt(document.body, ne, r), vt(d || u, Wt, r);
700
- }, lt = (r, u) => {
701
- vt(r, _t, u), ot(u, r), o.toggleGrabClass(!u);
702
- };
703
- return [
704
- M,
705
- D,
706
- S,
707
- v,
708
- lt
709
- ];
710
- }
711
- const de = (t, e, n) => {
712
- const { insertingFromClass: s, animationDuration: o } = n, i = kt(() => {
713
- const l = oe(e)[t];
714
- nt(l, s), nt(l, Zt), setTimeout(() => {
715
- yt(l, Zt), yt(l, s), i.disconnect();
716
- }, o);
717
- }, e, {
718
- childList: !0
719
- });
720
- }, En = (t, e, n, s) => {
721
- if (!e)
722
- return;
723
- const { onInsertEvent: o, delayBeforeInsert: i } = t;
724
- setTimeout(() => {
725
- o(n, s), de(n, e, t);
726
- }, i);
727
- }, dn = (t, e) => {
728
- const n = (c) => t.removeAtEvent(c), s = (c, l) => t.insertEvent(c, l), o = () => t.getLength(), i = (c) => t.getValue(c);
729
- return {
730
- direction: (e == null ? void 0 : e.direction) ?? U,
731
- handlerSelector: (e == null ? void 0 : e.handlerSelector) ?? Q,
732
- draggingClass: (e == null ? void 0 : e.draggingClass) ?? "dragging",
733
- droppableClass: (e == null ? void 0 : e.droppableClass) ?? "droppable-hover",
734
- isDraggable: (e == null ? void 0 : e.isDraggable) ?? (() => !0),
735
- onDragStart: (e == null ? void 0 : e.onDragStart) ?? (() => {
736
- }),
737
- onDragEnd: (e == null ? void 0 : e.onDragEnd) ?? (() => {
738
- }),
739
- droppableGroup: e == null ? void 0 : e.droppableGroup,
740
- onRemoveAtEvent: n,
741
- onInsertEvent: s,
742
- onGetLegth: o,
743
- onGetValue: i,
744
- animationDuration: (e == null ? void 0 : e.animationDuration) ?? 150,
745
- removingClass: (e == null ? void 0 : e.removingClass) ?? "removing",
746
- insertingFromClass: (e == null ? void 0 : e.insertingFromClass) ?? "from-inserting",
747
- delayBeforeRemove: (e == null ? void 0 : e.delayBeforeRemove) ?? 200,
748
- delayBeforeInsert: (e == null ? void 0 : e.delayBeforeInsert) ?? 200
749
- };
750
- }, pn = (t) => {
751
- let e = { offsetX: 0, offsetY: 0 }, n = { top: 0, left: 0 }, s = { x: 0, y: 0 };
752
- const o = (f) => {
753
- t.style.transform = `translate( ${f.x}px, ${f.y}px)`;
754
- }, i = (f) => {
755
- t.style.top = `${f.top}px`, t.style.left = `${f.left}px`;
756
- };
757
- return [
758
- (f, g, h, b) => {
759
- const B = (D) => {
760
- const {
761
- beforeMargin: v,
762
- borderBeforeWidth: R,
763
- before: N,
764
- offset: I,
765
- scroll: W,
766
- page: X,
767
- inner: F,
768
- distance: st,
769
- axis: _,
770
- getRect: P
771
- } = 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);
772
- if ($ >= q - Y / 2 && $ <= q + z) {
773
- const lt = $ - n[N] - j - V - q - tt;
774
- return M(D), lt;
775
- }
776
- return s[_];
777
- }, M = (D) => {
778
- if (f && et(f, _t) && D === b) {
779
- const { before: v, distance: R, axis: N, getRect: I } = w(b), W = I(f)[R], X = I(g), F = n[v] - X[v] + s[N], _ = X[R] - W, P = F / _, k = W / _, q = 0.1, z = 0.2, Y = 0.8;
780
- let j = 0;
781
- const V = dt(f, g);
782
- !V && P < z && P > -k ? j = P / z - 1 : !V && P > Y && P < 1 + k && (j = 1 / (1 - Y) * (P - Y));
783
- const $ = q * W * j;
784
- en(g, b, $);
785
- }
786
- }, S = (D) => {
787
- const { axis: v } = w(D);
788
- s[v] = B(D), o(s);
789
- };
790
- S(H), S(U);
791
- },
792
- (f, g) => {
793
- const [h, b, B, M] = Sn(
794
- f,
795
- g,
796
- t
797
- );
798
- n = {
799
- top: h,
800
- left: b
801
- }, i(n), e = { offsetX: B, offsetY: M };
802
- }
803
- ];
804
- }, Lt = (t, e, n) => {
805
- const { borderBeforeWidth: s, before: o, getRect: i } = w(t);
806
- return i(e)[o] - i(n)[o] - L(n, s);
807
- }, hn = (t, e) => {
808
- let { offsetX: n, offsetY: s, target: o } = t, i = mn(o, e);
809
- const c = o;
810
- 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];
811
- }, mn = (t, e) => {
812
- const n = t == null ? void 0 : t.closest(`.${Ot}`);
813
- return n && n.isSameNode(e) ? t : n;
814
- }, ee = (t, e, n, s) => {
815
- const { offset: o, beforeMargin: i, page: c, borderBeforeWidth: l, scroll: f } = w(t), g = re(n, t);
816
- return e[c] - s[o] - L(n, i) - L(n, l) - window[f] - g;
817
- }, Sn = (t, e, n) => {
818
- const [s, o] = hn(t, n);
819
- return [
820
- ee(U, t, e, {
821
- offsetX: s,
822
- offsetY: o
823
- }),
824
- ee(H, t, e, {
825
- offsetX: s,
826
- offsetY: o
827
- }),
828
- s,
829
- o
830
- ];
831
- }, K = class K {
832
- static addConfig(e, n) {
833
- const s = K.configs.filter(
834
- (i) => !i.droppable.isSameNode(e)
835
- ), o = Kt(e);
836
- s.push({
837
- droppable: e,
838
- config: n,
839
- scroll: o
840
- }), K.configs = s;
841
- }
842
- static updateScrolls(e, n) {
843
- for (const s of K.configs) {
844
- const { droppable: o } = s;
845
- (n && De(o, n) || o.isSameNode(e)) && (s.scroll = Kt(o));
846
- }
847
- }
848
- static getConfig(e) {
849
- return K.configs.find(
850
- ({ droppable: s }) => s.isSameNode(e)
851
- );
852
- }
853
- };
854
- J(K, "configs", []), J(K, "removeObsoleteConfigs", () => {
855
- const e = K.configs.filter(
856
- ({ droppable: n }) => document.contains(n)
857
- );
858
- K.configs = e;
859
- });
860
- let it = K;
861
- class Dn {
862
- constructor(e, n, s, o, i) {
863
- J(this, "initial");
864
- J(this, "current");
865
- J(this, "parent");
866
- J(this, "draggableElement");
867
- J(this, "groupClass");
868
- J(this, "dragEvent");
869
- J(this, "changeDroppable");
870
- this.parent = s, this.draggableElement = e, this.groupClass = n, this.dragEvent = o, this.initial = s ? it.getConfig(s) : void 0, this.changeDroppable = i;
871
- }
872
- getDraggableAncestor(e, n, s) {
873
- return document.elementsFromPoint(e, n).filter((o) => !o.isSameNode(s));
874
- }
875
- getElementBelow(e, n, s = !0) {
876
- const o = (c) => {
877
- const [l] = c.getDraggableAncestor(
878
- n.clientX,
879
- n.clientY,
880
- e
881
- );
882
- return l;
883
- };
884
- let i = null;
885
- return s ? (e.hidden = !0, i = o(this), e.hidden = !1) : i = o(this), i;
886
- }
887
- getCurrent(e, n, s = !0) {
888
- const o = this.getElementBelow(e, n, s);
889
- return !this.groupClass || !o ? void 0 : o.closest(
890
- gt(this.groupClass)
891
- );
892
- }
893
- isOutsideOfAllDroppables(e) {
894
- return (this.groupClass ? Array.from(
895
- document.querySelectorAll(gt(this.groupClass))
896
- ) : [this.parent]).every(
897
- (s) => dt(e, s)
898
- );
899
- }
900
- isNotInsideAnotherDroppable(e, n) {
901
- return !dt(e, n) || this.isOutsideOfAllDroppables(e);
902
- }
903
- onScrollEvent() {
904
- this.dragEvent();
905
- }
906
- setOnScroll(e) {
907
- ce(e, "onscroll", () => {
908
- this.onScrollEvent();
909
- });
910
- }
911
- getCurrentConfig(e) {
912
- var o;
913
- const n = this.draggableElement;
914
- if (this.current && this.isNotInsideAnotherDroppable(
915
- n,
916
- (o = this.current) == null ? void 0 : o.droppable
917
- ))
918
- return this.current;
919
- const s = this.getCurrent(n, e);
920
- return s ? (at(s) && !s.onscroll && this.setOnScroll(s), it.getConfig(s)) : it.getConfig(this.parent);
921
- }
922
- updateConfig(e) {
923
- const n = this.current;
924
- this.current = this.getCurrentConfig(e), this.changeDroppable(this.current, n);
925
- }
926
- isOutside(e, n = !0) {
927
- const s = this.draggableElement;
928
- return !this.getCurrent(s, e, n);
929
- }
930
- }
931
- function vn(t, e, n, s, o) {
932
- const {
933
- handlerSelector: i,
934
- isDraggable: c,
935
- droppableGroup: l,
936
- animationDuration: f,
937
- delayBeforeRemove: g,
938
- draggingClass: h,
939
- removingClass: b,
940
- onRemoveAtEvent: B,
941
- droppableClass: M,
942
- onDragStart: S
943
- } = n, D = Et(l).map((a) => `droppable-group-${a}`).join(" ");
944
- let v = 0, R = {
945
- scrollX: 0,
946
- scrollY: 0
947
- }, N = { pageX: 0, pageY: 0 }, I;
948
- const [W, X] = pn(
949
- t
950
- ), [
951
- F,
952
- st,
953
- _,
954
- P,
955
- k
956
- ] = gn(
957
- n,
958
- e,
959
- s,
960
- D,
961
- o,
962
- () => v = 0
963
- /* NOT_DRAGGING */
964
- ), q = () => {
965
- nt(t, Q);
966
- }, z = (a) => {
967
- nt(a, Ot), o.addSubscriber(a);
968
- }, Y = () => {
969
- if (c(t)) {
970
- const a = t.querySelector(i);
971
- z(a || t);
972
- }
973
- }, j = () => {
974
- $e(document.body, [
975
- `.${Q}{touch-action:manipulation;user-select:none;box-sizing:border-box!important;-webkit-user-select:none;}`,
976
- `.${Ot}{pointer-events:auto!important;}`,
977
- `.${Se}{cursor:grab;}`,
978
- ".temp-child{touch-action:none;pointer-events:none;box-sizing:border-box!important;}",
979
- ".droppable{box-sizing:border-box!important;}",
980
- `.${_t}{position:fixed;z-index:5000;width:var(--fixedWidth)!important;height:var(--fixedHeight)!important;}`,
981
- `.${Wt}{pointer-events:none!important;}`,
982
- `.${Xt}{pointer-events:none!important;}`,
983
- `.${ne}{cursor:grabbing;}`,
984
- ".disable-transition{transition:none!important;}"
985
- ]), Y(), q();
986
- }, V = (a) => {
987
- const p = a == null ? void 0 : a.querySelector(`.${Ot}`), E = p == null ? void 0 : p.parentElement;
988
- return p && E && et(E, It) && !E.isSameNode(s) ? null : p;
989
- }, $ = (a) => {
990
- const p = V(a) ?? a;
991
- p && c(a) && ($t(
992
- p,
993
- "onmousedown",
994
- O("mousemove", "mouseup")
995
- ), $t(
996
- p,
997
- "ontouchstart",
998
- O("touchmove", "touchend")
999
- ), tt(p)), a != null && a.isSameNode(p) || $t(a, "onmousedown", x), nt(s, It);
1000
- }, tt = (a) => {
1001
- const p = a.querySelectorAll("img");
1002
- Array.from(p).forEach((E) => {
1003
- E.onmousedown = () => !1;
1004
- });
1005
- }, ot = () => {
1006
- if (N.pageX == 0 && N.pageY == 0 || !r.current)
1007
- return;
1008
- const { droppable: a, config: p } = r.current;
1009
- W(t, a, N, p.direction), F(
1010
- t,
1011
- Pt,
1012
- R,
1013
- r.current
1014
- );
1015
- }, lt = (a, p) => {
1016
- p && v == 2 && !(a != null && a.droppable.isSameNode(p.droppable)) && F(
1017
- t,
1018
- Pt,
1019
- R,
1020
- p
1021
- );
1022
- }, r = new Dn(
1023
- t,
1024
- D,
1025
- s,
1026
- ot,
1027
- lt
1028
- ), u = (a) => {
1029
- if (!r.current)
1030
- return;
1031
- const p = D ? Array.from(
1032
- document.querySelectorAll(gt(D))
1033
- ) : [s];
1034
- for (const E of p)
1035
- E.classList.toggle(
1036
- M,
1037
- !a && E.isSameNode(r.current.droppable)
1038
- );
1039
- }, d = (a) => {
1040
- r.updateConfig(a);
1041
- const p = r.isOutside(a);
1042
- u(p), v === 1 ? ut(a) : v === 2 && (m(p), mt(a));
1043
- }, m = (a = !0) => {
1044
- if (!r.current)
1045
- return;
1046
- const { droppable: p } = r.current;
1047
- un(
1048
- p,
1049
- s,
1050
- D,
1051
- f,
1052
- a
1053
- ), !a && Gt(
1054
- t,
1055
- s,
1056
- v == 1,
1057
- r.current
1058
- );
1059
- }, C = (a) => {
1060
- if (Yt(a) && a.cancelable)
1061
- a.preventDefault();
1062
- else if (Yt(a))
1063
- return;
1064
- const p = Vt(a);
1065
- d(p);
1066
- }, T = (a, p) => {
1067
- a == "touchmove" ? I = setTimeout(() => {
1068
- p();
1069
- }, 200) : p();
1070
- }, y = (a, p) => {
1071
- const { clientX: E, clientY: ft } = a, rt = document.elementFromPoint(E, ft), St = rt == null ? void 0 : rt.closest(`.${Q}`);
1072
- return rt && p && St && !p.isSameNode(St);
1073
- }, A = (a) => {
1074
- const p = n.onGetValue(e);
1075
- return { index: e, element: a, value: p };
1076
- }, O = (a, p) => (E) => {
1077
- if (y(E, t))
1078
- return;
1079
- it.updateScrolls(s, D);
1080
- const { scrollX: ft, scrollY: rt } = window;
1081
- if (R = { scrollX: ft, scrollY: rt }, v === 0) {
1082
- v = 1;
1083
- const St = A(t);
1084
- St && S(St), T(a, () => {
1085
- a == "touchmove" && (r.updateConfig(E), u(r.isOutside(E)), ut(E)), document.addEventListener(a, C, {
1086
- passive: !1
1087
- });
1088
- }), ct(s), document.addEventListener(p, G(a), {
1089
- once: !0
1090
- });
1091
- }
1092
- }, x = (a) => r.updateConfig(a), G = (a) => (p) => {
1093
- u(!0);
1094
- const E = Vt(p);
1095
- clearTimeout(I), At(r.isOutside(E, !1)), document.removeEventListener(a, C), r.updateConfig(E);
1096
- const ft = r.getCurrentConfig(E);
1097
- if (ft) {
1098
- const { droppable: rt } = ft;
1099
- Z(rt);
1100
- }
1101
- s.onscroll = null;
1102
- }, Z = (a) => {
1103
- if (a.onscroll = null, !D)
1104
- return;
1105
- const p = Array.from(
1106
- document.querySelectorAll(gt(D))
1107
- );
1108
- for (const E of p)
1109
- at(E) && (E.onscroll = null);
1110
- }, ut = (a) => {
1111
- Gt(
1112
- t,
1113
- s,
1114
- v == 1,
1115
- r.current
1116
- ), ht(), F(
1117
- t,
1118
- le,
1119
- R,
1120
- r.current
1121
- ), wt(t), X(a, t);
1122
- }, ht = () => {
1123
- v = 2;
1124
- }, mt = (a) => {
1125
- const { pageX: p, pageY: E } = a;
1126
- N = { pageX: p, pageY: E }, ot();
1127
- }, ct = (a) => ce(a, "onscroll", Ft), Ft = () => ot(), At = (a) => {
1128
- if (v !== 2) {
1129
- v = 0;
1130
- return;
1131
- }
1132
- v = 3, xt(t), F(
1133
- t,
1134
- zt,
1135
- R,
1136
- a ? r.initial : r.current,
1137
- e
1138
- );
1139
- }, xt = (a) => {
1140
- Nt(a, f, ue), bt(a, 0, 0);
1141
- }, wt = (a) => {
1142
- const { height: p, width: E } = a.getBoundingClientRect();
1143
- ae(a, {
1144
- fixedHeight: `${p}px`,
1145
- fixedWidth: `${E}px`
1146
- }), k(a, !0), vt(a, h, !0), a.style.transition = "";
1147
- }, Bt = (a) => {
1148
- if (!r.initial)
1149
- return;
1150
- const p = r.initial;
1151
- a == e && (nt(t, b), setTimeout(() => {
1152
- B(e), yt(t, b), Gt(
1153
- t,
1154
- s,
1155
- v == 1,
1156
- r.initial
1157
- ), st(
1158
- a,
1159
- t,
1160
- p,
1161
- (E) => {
1162
- xt(E), P(t);
1163
- }
1164
- );
1165
- }, g));
1166
- }, pe = (a, p) => {
1167
- (a === e || a === n.onGetLegth() && e === a - 1) && _(
1168
- a,
1169
- t,
1170
- s,
1171
- p,
1172
- () => {
1173
- an(
1174
- t,
1175
- v == 1,
1176
- r.initial
1177
- );
1178
- }
1179
- );
1180
- };
1181
- return j(), $(t), [Bt, pe];
1182
- }
1183
- const bn = (t, e) => {
1184
- t && ve(e, t);
1185
- };
1186
- function Tn(t, e, n, s = "index") {
1187
- const o = s;
1188
- let i = [], c = [];
1189
- const { droppableGroup: l } = t;
1190
- if (!n)
1191
- return [
1192
- i,
1193
- c
1194
- ];
1195
- const f = Et(l).map((g) => `droppable-group-${g}`).join(" ");
1196
- bn(f, n);
1197
- for (const g of n.children) {
1198
- const h = g.getAttribute(o), b = Te(h), B = g;
1199
- if (B && b >= 0) {
1200
- const [M, S] = vn(
1201
- B,
1202
- b,
1203
- t,
1204
- n,
1205
- e
1206
- );
1207
- i.push(M), c.push(S);
1208
- }
1209
- }
1210
- return [
1211
- i,
1212
- c
1213
- ];
1214
- }
1215
- function Cn(t, e, n, s = "index") {
1216
- let o = [], i = [];
1217
- const c = dn(t, n), l = (S) => {
1218
- for (const D of o)
1219
- D(S);
1220
- }, f = (S, D) => {
1221
- if (c.onGetLegth() === 0)
1222
- t.insertToListEmpty(c, S, D);
1223
- else
1224
- for (const R of i)
1225
- R(S, D);
1226
- }, g = (S) => {
1227
- const [D, v] = Tn(c, e, S, s);
1228
- o = D, i = v;
1229
- }, h = (S) => {
1230
- kt(
1231
- () => {
1232
- g(S);
1233
- },
1234
- S,
1235
- { childList: !0 }
1236
- );
1237
- }, b = (S) => {
1238
- nt(S, It);
1239
- }, B = (S) => {
1240
- it.addConfig(
1241
- S,
1242
- c
1243
- );
1244
- };
1245
- return [l, f, (S) => {
1246
- S && (b(S), B(S), h(S), g(S), it.removeObsoleteConfigs());
1247
- }];
1248
- }
1249
- export {
1250
- Se as G,
1251
- nt as a,
1252
- Cn as d,
1253
- En as i,
1254
- vt as t
1255
- };