fluid-dnd 2.4.0 → 2.5.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.
- package/README.md +14 -15
- package/dist/{HandlerPublisher-B68XPAcH.cjs → HandlerPublisher-1MmlNkG3.cjs} +1 -1
- package/dist/{HandlerPublisher-pcX0Zmas.js → HandlerPublisher-DBjPMiyO.js} +1 -1
- package/dist/core/config/configHandler.js +4 -4
- package/dist/core/config/droppableConfigurator.d.ts +2 -1
- package/dist/core/config/droppableConfigurator.js +17 -21
- package/dist/core/events/changeDraggableStyles.js +3 -5
- package/dist/core/events/dragAndDrop/dragAndDrop.js +28 -40
- package/dist/core/events/dragAndDrop/getTranslateBeforeDropping.js +30 -30
- package/dist/core/events/dragAndDrop/getTranslationByDraggingAndEvent.js +10 -11
- package/dist/core/events/insert.d.ts +2 -1
- package/dist/core/events/insert.js +4 -10
- package/dist/core/events/remove.d.ts +2 -2
- package/dist/core/events/remove.js +28 -13
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.js +7 -0
- package/dist/core/positioning/autoScroll.js +6 -5
- package/dist/core/positioning/usePositioning.js +20 -23
- package/dist/core/tempChildren.js +32 -28
- package/dist/core/useDraggable.js +39 -50
- package/dist/core/useDroppable.d.ts +2 -2
- package/dist/core/useDroppable.js +10 -16
- package/dist/core/utils/GetStyles.d.ts +24 -3
- package/dist/core/utils/GetStyles.js +53 -5
- package/dist/core/utils/ParseStyles.d.ts +3 -2
- package/dist/core/utils/ParseStyles.js +12 -12
- package/dist/core/utils/SetStyles.d.ts +4 -3
- package/dist/core/utils/SetStyles.js +19 -14
- package/dist/core/utils/index.d.ts +5 -1
- package/dist/core/utils/index.js +7 -6
- package/dist/fluid-dnd-logo.png +0 -0
- package/dist/index-BdOAK6C7.cjs +1 -0
- package/dist/index-HczUoMBK.js +1131 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +2 -2
- package/dist/insert-Dd8savAS.js +51 -0
- package/dist/insert-T4Y6rI_j.cjs +1 -0
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.mjs +32 -30
- package/dist/react/utils/ReactLilstConfig.js +3 -2
- package/dist/remove-BC4sUY1o.cjs +1 -0
- package/dist/remove-M01dmTvo.js +48 -0
- package/dist/svelte/index.cjs +1 -1
- package/dist/svelte/index.mjs +18 -16
- package/dist/svelte/utils/SvelteListCondig.js +3 -2
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.mjs +26 -24
- package/dist/vue/utils/VueListCondig.js +3 -2
- package/package.json +1 -1
- package/dist/index-2hBSSK9_.cjs +0 -1
- package/dist/index-DFXw7kYo.js +0 -1223
package/dist/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BdOAK6C7.cjs");exports.dragAndDrop=e.dragAndDrop;
|
package/dist/index.mjs
CHANGED
@@ -0,0 +1,51 @@
|
|
1
|
+
import { u as B, c as C, h as g, i as L, j as N, k as F, e as O, g as _, f as G, o as M, a as u, l as v, r as T, n as R } from "./index-HczUoMBK.js";
|
2
|
+
function w(s, n, t, e) {
|
3
|
+
const { delayBeforeInsert: r } = s, [l, f, i] = B(
|
4
|
+
s,
|
5
|
+
t,
|
6
|
+
e
|
7
|
+
), h = (o, a, c, m, S) => {
|
8
|
+
const I = C(
|
9
|
+
a,
|
10
|
+
"insert",
|
11
|
+
s.direction,
|
12
|
+
c
|
13
|
+
), { onInsertEvent: y } = s, A = g(c);
|
14
|
+
for (const [D, d] of A.entries())
|
15
|
+
L(d, N) && D >= o && i(d, I);
|
16
|
+
F(a, !1, S), setTimeout(() => {
|
17
|
+
y(o, m), E(o, c, s), l(a), b(a, n), O(n, 0, !0);
|
18
|
+
}, r);
|
19
|
+
}, b = (o, a) => {
|
20
|
+
const [c] = _(o, a);
|
21
|
+
for (const m of [...c, o])
|
22
|
+
G(m);
|
23
|
+
};
|
24
|
+
return [h];
|
25
|
+
}
|
26
|
+
const j = (s) => s.addedNodes.values().filter((t) => !R(t)).toArray().length > 0, E = (s, n, t) => {
|
27
|
+
const { insertingFromClass: e, animationDuration: r } = t, l = M(
|
28
|
+
() => {
|
29
|
+
const i = g(n)[s];
|
30
|
+
u(i, e), u(i, v), setTimeout(() => {
|
31
|
+
T(i, v), T(i, e), l.disconnect();
|
32
|
+
}, r);
|
33
|
+
},
|
34
|
+
n,
|
35
|
+
{
|
36
|
+
childList: !0
|
37
|
+
},
|
38
|
+
j
|
39
|
+
);
|
40
|
+
}, P = (s, n, t, e) => {
|
41
|
+
if (!n)
|
42
|
+
return;
|
43
|
+
const { onInsertEvent: r, delayBeforeInsert: l } = s;
|
44
|
+
setTimeout(() => {
|
45
|
+
r(t, e), E(t, n, s);
|
46
|
+
}, l);
|
47
|
+
};
|
48
|
+
export {
|
49
|
+
w as default,
|
50
|
+
P as insertToListEmpty
|
51
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BdOAK6C7.cjs");function f(s,t,n,i){const{delayBeforeInsert:a}=s,[c,g,o]=e.useChangeDraggableStyles(s,n,i),v=(r,l,d,m,S)=>{const b=e.getTranslationByDraggingAndEvent(l,"insert",s.direction,d),{onInsertEvent:I}=s,h=e.getParentDraggableChildren(d);for(const[y,u]of h.entries())e.containClass(u,e.DRAGGABLE_CLASS)&&y>=r&&o(u,b);e.addTempChildOnInsert(l,!1,S),setTimeout(()=>{I(r,m),T(r,d,s),c(l),E(l,t),e.removeTempChild(t,0,!0)},a)},E=(r,l)=>{const[d]=e.getSiblings(r,l);for(const m of[...d,r])e.removeTranslateWhitoutTransition(m)};return[v]}const A=s=>s.addedNodes.values().filter(n=>!e.isTempElement(n)).toArray().length>0,T=(s,t,n)=>{const{insertingFromClass:i,animationDuration:a}=n,c=e.observeMutation(()=>{const o=e.getParentDraggableChildren(t)[s];e.addClass(o,i),e.addClass(o,e.DISABLE_TRANSITION),setTimeout(()=>{e.removeClass(o,e.DISABLE_TRANSITION),e.removeClass(o,i),c.disconnect()},a)},t,{childList:!0},A)},D=(s,t,n,i)=>{if(!t)return;const{onInsertEvent:a,delayBeforeInsert:c}=s;setTimeout(()=>{a(n,i),T(n,t,s)},c)};exports.default=f;exports.insertToListEmpty=D;
|
package/dist/react/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),b=require("../HandlerPublisher-1MmlNkG3.cjs"),v=require("../index-BdOAK6C7.cjs"),S=require("react-dom");function y(f,i){const[e,r]=u.useState(f),a=u.useRef(e);u.useEffect(()=>{a.current=e},[e]);function d(t,s=!1){const c=a.current[t],n=()=>{r(o=>[...o.slice(0,t),...o.slice(t+1)])};return s?S.flushSync(n):n(),c}function g(t,s,c=!1){const n=()=>{r(o=>[...o.slice(0,t),s,...o.slice(t)])};c?S.flushSync(n):n()}function h(){return e.length}function m(t){return e[t]}function l(t,s,c){Promise.resolve().then(()=>require("../insert-T4Y6rI_j.cjs")).then(({insertToListEmpty:n})=>{n(t,i.current,s,c)})}return[e,r,{removeAtEvent:d,insertEvent:g,getLength:h,getValue:m,insertToListEmpty:l}]}const A=new b.HandlerPublisher;function D(f,i){const e=u.useRef(null),[r,a,d]=y(f,e),[g,h,m]=v.dragAndDrop(d,A,i,"data-index");return u.useEffect(()=>{const l=m(e.current);return()=>{l&&l.disconnect()}},[r.length,i]),[e,r,a,h,g]}exports.useDragAndDrop=D;
|
package/dist/react/index.mjs
CHANGED
@@ -1,55 +1,57 @@
|
|
1
|
-
import { useState as
|
2
|
-
import { H as
|
3
|
-
import {
|
4
|
-
import { flushSync as
|
5
|
-
function
|
6
|
-
const [t,
|
7
|
-
|
8
|
-
|
1
|
+
import { useState as b, useRef as d, useEffect as S } from "react";
|
2
|
+
import { H as A } from "../HandlerPublisher-DBjPMiyO.js";
|
3
|
+
import { p as C } from "../index-HczUoMBK.js";
|
4
|
+
import { flushSync as h } from "react-dom";
|
5
|
+
function E(l, i) {
|
6
|
+
const [t, r] = b(l), u = d(t);
|
7
|
+
S(() => {
|
8
|
+
u.current = t;
|
9
9
|
}, [t]);
|
10
|
-
function f(e,
|
11
|
-
const
|
12
|
-
|
10
|
+
function f(e, s = !1) {
|
11
|
+
const o = u.current[e], n = () => {
|
12
|
+
r((c) => [...c.slice(0, e), ...c.slice(e + 1)]);
|
13
13
|
};
|
14
|
-
return
|
14
|
+
return s ? h(n) : n(), o;
|
15
15
|
}
|
16
|
-
function m(e,
|
17
|
-
const
|
18
|
-
|
16
|
+
function m(e, s, o = !1) {
|
17
|
+
const n = () => {
|
18
|
+
r((c) => [...c.slice(0, e), s, ...c.slice(e)]);
|
19
19
|
};
|
20
|
-
|
20
|
+
o ? h(n) : n();
|
21
21
|
}
|
22
|
-
function
|
22
|
+
function p() {
|
23
23
|
return t.length;
|
24
24
|
}
|
25
25
|
function g(e) {
|
26
26
|
return t[e];
|
27
27
|
}
|
28
|
-
function
|
29
|
-
|
28
|
+
function a(e, s, o) {
|
29
|
+
import("../insert-Dd8savAS.js").then(({ insertToListEmpty: n }) => {
|
30
|
+
n(e, i.current, s, o);
|
31
|
+
});
|
30
32
|
}
|
31
|
-
return [t,
|
33
|
+
return [t, r, {
|
32
34
|
removeAtEvent: f,
|
33
35
|
insertEvent: m,
|
34
|
-
getLength:
|
36
|
+
getLength: p,
|
35
37
|
getValue: g,
|
36
|
-
insertToListEmpty:
|
38
|
+
insertToListEmpty: a
|
37
39
|
}];
|
38
40
|
}
|
39
|
-
const v = new
|
40
|
-
function k(l,
|
41
|
-
const t =
|
41
|
+
const v = new A();
|
42
|
+
function k(l, i) {
|
43
|
+
const t = d(null), [r, u, f] = E(l, t), [m, p, g] = C(
|
42
44
|
f,
|
43
45
|
v,
|
44
|
-
|
46
|
+
i,
|
45
47
|
"data-index"
|
46
48
|
);
|
47
|
-
return
|
48
|
-
const
|
49
|
+
return S(() => {
|
50
|
+
const a = g(t.current);
|
49
51
|
return () => {
|
50
|
-
|
52
|
+
a && a.disconnect();
|
51
53
|
};
|
52
|
-
}, [
|
54
|
+
}, [r.length, i]), [t, r, u, p, m];
|
53
55
|
}
|
54
56
|
export {
|
55
57
|
k as useDragAndDrop
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import { useEffect, useRef, useState } from 'react';
|
2
|
-
import { insertToListEmpty as insertToListEmptyEvent } from '../../core/events/insert';
|
3
2
|
// @ts-ignore
|
4
3
|
import { flushSync } from 'react-dom';
|
5
4
|
export function useReactListConfig(items, parent) {
|
@@ -41,7 +40,9 @@ export function useReactListConfig(items, parent) {
|
|
41
40
|
return itemsState[index];
|
42
41
|
}
|
43
42
|
function insertToListEmpty(config, index, value) {
|
44
|
-
|
43
|
+
import('../../core/events/insert').then(({ insertToListEmpty }) => {
|
44
|
+
insertToListEmpty(config, parent.current, index, value);
|
45
|
+
});
|
45
46
|
}
|
46
47
|
const actions = {
|
47
48
|
removeAtEvent,
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-BdOAK6C7.cjs");function d(a,l,g,u){const{animationDuration:m}=a,[S]=t.useChangeDraggableStyles(a,g,u),R=(s,o,e,i)=>{if(!e||!e.droppable||!e.config)return;const{droppable:n,config:v}=e;let[r]=t.getSiblings(o,n);r=[o,...r].toReversed();const c=t.getTranslationByDraggingAndEvent(o,"remove",v.direction,n);for(const[h,T]of r.entries())h>=s&&(t.moveTranslate(T,c),setTimeout(()=>{i(T)},m))},b=s=>{t.removeTempChild(l,m,!0),setTimeout(()=>{S(s),f(s,l)},m)},f=(s,o)=>{const[e]=t.getSiblings(s,o);for(const i of[...e,s])t.removeTranslateWhitoutTransition(i)},y=(s,o,e,i,n)=>{const{removingClass:v,delayBeforeRemove:r}=a;o==s&&(t.addClass(e,v),setTimeout(()=>{D(s,o,e,i,n)},r))},D=(s,o,e,i,n)=>{const{removingClass:v,onRemoveAtEvent:r}=a;t.removeClass(e,v),t.addTempChild(e,l,i==t.DraggingState.START_DRAGGING,n),R(o,e,n,c=>{A(c),b(e)}),r(s,!0)},A=s=>{t.setTranistion(s,m,t.draggableTargetTimingFunction),t.moveTranslate(s)};return[y]}exports.default=d;
|
@@ -0,0 +1,48 @@
|
|
1
|
+
import { u as G, a as B, r as C, b as d, D as N, g as l, c as W, m as g, s as _, d as j, e as k, f as p } from "./index-HczUoMBK.js";
|
2
|
+
function w(r, m, u, R) {
|
3
|
+
const { animationDuration: v } = r, [S] = G(
|
4
|
+
r,
|
5
|
+
u,
|
6
|
+
R
|
7
|
+
), f = (s, t, o, e) => {
|
8
|
+
if (!o || !o.droppable || !o.config)
|
9
|
+
return;
|
10
|
+
const { droppable: i, config: a } = o;
|
11
|
+
let [n] = l(t, i);
|
12
|
+
n = [t, ...n].toReversed();
|
13
|
+
const c = W(
|
14
|
+
t,
|
15
|
+
"remove",
|
16
|
+
a.direction,
|
17
|
+
i
|
18
|
+
);
|
19
|
+
for (const [F, T] of n.entries())
|
20
|
+
F >= s && (g(T, c), setTimeout(() => {
|
21
|
+
e(T);
|
22
|
+
}, v));
|
23
|
+
}, D = (s) => {
|
24
|
+
k(m, v, !0), setTimeout(() => {
|
25
|
+
S(s), b(s, m);
|
26
|
+
}, v);
|
27
|
+
}, b = (s, t) => {
|
28
|
+
const [o] = l(s, t);
|
29
|
+
for (const e of [...o, s])
|
30
|
+
p(e);
|
31
|
+
}, A = (s, t, o, e, i) => {
|
32
|
+
const { removingClass: a, delayBeforeRemove: n } = r;
|
33
|
+
t == s && (B(o, a), setTimeout(() => {
|
34
|
+
h(s, t, o, e, i);
|
35
|
+
}, n));
|
36
|
+
}, h = (s, t, o, e, i) => {
|
37
|
+
const { removingClass: a, onRemoveAtEvent: n } = r;
|
38
|
+
C(o, a), d(o, m, e == N.START_DRAGGING, i), f(t, o, i, (c) => {
|
39
|
+
y(c), D(o);
|
40
|
+
}), n(s, !0);
|
41
|
+
}, y = (s) => {
|
42
|
+
_(s, v, j), g(s);
|
43
|
+
};
|
44
|
+
return [A];
|
45
|
+
}
|
46
|
+
export {
|
47
|
+
w as default
|
48
|
+
};
|
package/dist/svelte/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var
|
1
|
+
"use strict";var a=Object.defineProperty;var u=(n,e,t)=>e in n?a(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var i=(n,e,t)=>u(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../HandlerPublisher-1MmlNkG3.cjs"),c=require("../index-BdOAK6C7.cjs");class h{constructor(e){i(this,"items");i(this,"parent");this.items=e}setParent(e){this.parent=e}removeAtEvent(e){const t=this.items;if(t.length<=0)return;const[r]=t.splice(e,1);return r}insertEvent(e,t){this.items.splice(e,0,t)}getLength(){return this.items.length}getValue(e){return this.items[e]}insertToListEmpty(e,t,r){Promise.resolve().then(()=>require("../insert-T4Y6rI_j.cjs")).then(({insertToListEmpty:s})=>{s(e,this.parent,t,r)})}}const g=new d.HandlerPublisher;function m(n,e){const t=new h(n),[r,s,l]=c.dragAndDrop(t,g,e,"data-index");return[o=>(t.setParent(o),l(o),{destroy(){}}),s,r]}exports.useDragAndDrop=m;
|
package/dist/svelte/index.mjs
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
var l = Object.defineProperty;
|
2
2
|
var d = (n, t, e) => t in n ? l(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
3
|
-
var
|
4
|
-
import { H as c } from "../HandlerPublisher-
|
5
|
-
import {
|
6
|
-
class
|
3
|
+
var i = (n, t, e) => d(n, typeof t != "symbol" ? t + "" : t, e);
|
4
|
+
import { H as c } from "../HandlerPublisher-DBjPMiyO.js";
|
5
|
+
import { p as h } from "../index-HczUoMBK.js";
|
6
|
+
class m {
|
7
7
|
constructor(t) {
|
8
|
-
|
9
|
-
|
8
|
+
i(this, "items");
|
9
|
+
i(this, "parent");
|
10
10
|
this.items = t;
|
11
11
|
}
|
12
12
|
setParent(t) {
|
@@ -16,8 +16,8 @@ class h {
|
|
16
16
|
const e = this.items;
|
17
17
|
if (e.length <= 0)
|
18
18
|
return;
|
19
|
-
const [
|
20
|
-
return
|
19
|
+
const [r] = e.splice(t, 1);
|
20
|
+
return r;
|
21
21
|
}
|
22
22
|
insertEvent(t, e) {
|
23
23
|
this.items.splice(t, 0, e);
|
@@ -28,18 +28,20 @@ class h {
|
|
28
28
|
getValue(t) {
|
29
29
|
return this.items[t];
|
30
30
|
}
|
31
|
-
insertToListEmpty(t, e,
|
32
|
-
|
31
|
+
insertToListEmpty(t, e, r) {
|
32
|
+
import("../insert-Dd8savAS.js").then(({ insertToListEmpty: s }) => {
|
33
|
+
s(t, this.parent, e, r);
|
34
|
+
});
|
33
35
|
}
|
34
36
|
}
|
35
|
-
const
|
36
|
-
function
|
37
|
-
const e = new
|
38
|
-
return [(
|
37
|
+
const u = new c();
|
38
|
+
function D(n, t) {
|
39
|
+
const e = new m(n), [r, s, a] = h(e, u, t, "data-index");
|
40
|
+
return [(o) => (e.setParent(o), a(o), {
|
39
41
|
destroy() {
|
40
42
|
}
|
41
|
-
}),
|
43
|
+
}), s, r];
|
42
44
|
}
|
43
45
|
export {
|
44
|
-
|
46
|
+
D as useDragAndDrop
|
45
47
|
};
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { insertToListEmpty } from '../../core/events/insert';
|
2
1
|
export class SvelteListCondig {
|
3
2
|
items;
|
4
3
|
parent;
|
@@ -27,6 +26,8 @@ export class SvelteListCondig {
|
|
27
26
|
return this.items[index];
|
28
27
|
}
|
29
28
|
insertToListEmpty(config, index, value) {
|
30
|
-
|
29
|
+
import('../../core/events/insert').then(({ insertToListEmpty }) => {
|
30
|
+
insertToListEmpty(config, this.parent, index, value);
|
31
|
+
});
|
31
32
|
}
|
32
33
|
}
|
package/dist/vue/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var
|
1
|
+
"use strict";var a=Object.defineProperty;var c=(n,e,t)=>e in n?a(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var i=(n,e,t)=>c(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("vue"),h=require("../HandlerPublisher-1MmlNkG3.cjs"),v=require("../index-BdOAK6C7.cjs"),g=(n,e)=>{const t=n.value;if(t.length<=0)return;const[r]=t.splice(e,1);return r},d=(n,e,t)=>{n.value.splice(e,0,t)},m=n=>n.value.length,p=(n,e)=>n.value[e];class V{constructor(e,t){i(this,"items");i(this,"parent");this.items=e,this.parent=t}removeAtEvent(e){return g(this.items,e)}insertEvent(e,t){return d(this.items,e,t)}getLength(){return m(this.items)}getValue(e){return p(this.items,e)}insertToListEmpty(e,t,r){Promise.resolve().then(()=>require("../insert-T4Y6rI_j.cjs")).then(({insertToListEmpty:s})=>{s(e,this.parent.value,t,r)})}}const A=new h.HandlerPublisher;function L(n,e){const t=u.ref();var r=new V(n,t);const[s,l,o]=v.dragAndDrop(r,A,e);return u.watch(t,()=>{o(t.value)}),[t,l,s]}exports.useDragAndDrop=L;
|
package/dist/vue/index.mjs
CHANGED
@@ -1,49 +1,51 @@
|
|
1
|
-
var
|
2
|
-
var u = (n, t, e) => t in n ?
|
3
|
-
var
|
1
|
+
var a = Object.defineProperty;
|
2
|
+
var u = (n, t, e) => t in n ? a(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
3
|
+
var i = (n, t, e) => u(n, typeof t != "symbol" ? t + "" : t, e);
|
4
4
|
import { ref as c, watch as m } from "vue";
|
5
|
-
import { H as h } from "../HandlerPublisher-
|
6
|
-
import {
|
7
|
-
const
|
5
|
+
import { H as h } from "../HandlerPublisher-DBjPMiyO.js";
|
6
|
+
import { p } from "../index-HczUoMBK.js";
|
7
|
+
const v = (n, t) => {
|
8
8
|
const e = n.value;
|
9
9
|
if (e.length <= 0)
|
10
10
|
return;
|
11
|
-
const [
|
12
|
-
return
|
13
|
-
},
|
11
|
+
const [r] = e.splice(t, 1);
|
12
|
+
return r;
|
13
|
+
}, g = (n, t, e) => {
|
14
14
|
n.value.splice(t, 0, e);
|
15
|
-
},
|
15
|
+
}, d = (n) => n.value.length, V = (n, t) => n.value[t];
|
16
16
|
class f {
|
17
17
|
constructor(t, e) {
|
18
|
-
|
19
|
-
|
18
|
+
i(this, "items");
|
19
|
+
i(this, "parent");
|
20
20
|
this.items = t, this.parent = e;
|
21
21
|
}
|
22
22
|
removeAtEvent(t) {
|
23
|
-
return
|
23
|
+
return v(this.items, t);
|
24
24
|
}
|
25
25
|
insertEvent(t, e) {
|
26
|
-
return
|
26
|
+
return g(this.items, t, e);
|
27
27
|
}
|
28
28
|
getLength() {
|
29
|
-
return
|
29
|
+
return d(this.items);
|
30
30
|
}
|
31
31
|
getValue(t) {
|
32
|
-
return
|
32
|
+
return V(this.items, t);
|
33
33
|
}
|
34
|
-
insertToListEmpty(t, e,
|
35
|
-
|
34
|
+
insertToListEmpty(t, e, r) {
|
35
|
+
import("../insert-Dd8savAS.js").then(({ insertToListEmpty: s }) => {
|
36
|
+
s(t, this.parent.value, e, r);
|
37
|
+
});
|
36
38
|
}
|
37
39
|
}
|
38
40
|
const A = new h();
|
39
|
-
function
|
41
|
+
function D(n, t) {
|
40
42
|
const e = c();
|
41
|
-
var
|
42
|
-
const [
|
43
|
+
var r = new f(n, e);
|
44
|
+
const [s, o, l] = p(r, A, t);
|
43
45
|
return m(e, () => {
|
44
|
-
|
45
|
-
}), [e, o,
|
46
|
+
l(e.value);
|
47
|
+
}), [e, o, s];
|
46
48
|
}
|
47
49
|
export {
|
48
|
-
|
50
|
+
D as useDragAndDrop
|
49
51
|
};
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import { getLength, getValue, onInsertEventOnList, removeAtEventOnList } from './DropMethods';
|
2
|
-
import { insertToListEmpty } from '../../core/events/insert';
|
3
2
|
export class VueListCondig {
|
4
3
|
items;
|
5
4
|
parent;
|
@@ -20,6 +19,8 @@ export class VueListCondig {
|
|
20
19
|
return getValue(this.items, index);
|
21
20
|
}
|
22
21
|
insertToListEmpty(config, index, value) {
|
23
|
-
|
22
|
+
import('../../core/events/insert').then(({ insertToListEmpty }) => {
|
23
|
+
insertToListEmpty(config, this.parent.value, index, value);
|
24
|
+
});
|
24
25
|
}
|
25
26
|
}
|
package/package.json
CHANGED
package/dist/index-2hBSSK9_.cjs
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";var we=Object.defineProperty;var Oe=(e,t,n)=>t in e?we(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var H=(e,t,n)=>Oe(e,typeof t!="symbol"?t+"":t,n);const W="horizontal",J="vertical",k="draggable",Pt="droppable",xt="handler-class",wt="dragging",$t="dragging-handler-class",Gt="dropping",ee="grabbing",ne="grab",Zt="disable-transition",tt=(e,t)=>e.classList.contains(t),ct=(e,t,n=!1)=>{e.classList.toggle(t,n)},Z=(e,t)=>{e.classList.add(t)},Tt=(e,t)=>{e.classList.remove(t)},Re=(e,t)=>Et(t).every(n=>tt(e,n)),ft=e=>e?`.${Et(e).join(".")}`:"",Le=(e,t)=>{if(!t)return;const n=Et(t);e.classList.add(...n)},Et=e=>e?e.split(" ").filter(t=>t):[],Fe=()=>{const{scrollX:e,scrollY:t}=window;return{scrollX:e,scrollY:t}},Wt=e=>!e||e.trim().length==0||e=="normal"?0:parseFloat(e),Ne=e=>e?parseInt(e):-1,Pe=e=>{const t=getComputedStyle(e),n=new DOMMatrixReadOnly(t.transform);return{x:n.m41,y:n.m42}},se=(e,t)=>e.x1>t.x1?se(t,e):e.x2<t.x1?0:e.x2>=t.x2?e.x2-e.x1:e.x2-t.x1,bt=(e,t)=>!$e(e,t),$e=(e,t)=>{const{intersectionX:n,intersectionY:s,rect1:o,rect2:r}=oe(e,t);return s>=Math.min(o.height,r.height)/2&&n>=Math.min(o.width,r.width)/2},Ge=(e,t)=>!Ie(e,t),Ie=(e,t)=>{const{intersectionX:n,intersectionY:s}=oe(e,t);return s>=0&&n>=0},oe=(e,t)=>{const n=Mt(e),s=Mt(t),o=kt(n,s,J),r=kt(n,s,W);return{rect1:n,rect2:s,intersectionX:r,intersectionY:o}},kt=(e,t,n)=>{const{before:s,distance:o}=R(n);return se({x1:e[s],x2:e[s]+e[o]},{x1:t[s],x2:t[s]+t[o]})},N=(e,t)=>e?Wt(getComputedStyle(e)[t]):0,Jt=e=>{const{scrollLeft:t,scrollTop:n}=e;return{scrollLeft:t,scrollTop:n}},Mt=e=>e.getBoundingClientRect(),R=e=>{const t=e==W;return{beforeMargin:t?"marginLeft":"marginTop",afterMargin:t?"marginRight":"marginBottom",borderBeforeWidth:t?"borderLeftWidth":"borderTopWidth",before:t?"left":"top",after:t?"right":"down",gap:t?"columnGap":"rowGap",distance:t?"width":"height",axis:t?"x":"y",offset:t?"offsetX":"offsetY",scroll:t?"scrollX":"scrollY",scrollElement:t?"scrollLeft":"scrollTop",page:t?"pageX":"pageY",inner:t?"innerWidth":"innerHeight",offsetElement:t?"offsetLeft":"offsetTop",scrollDistance:t?"scrollWidth":"scrollHeight",clientDistance:t?"clientWidth":"clientHeight",paddingBefore:t?"paddingLeft":"paddingTop",getRect:Mt}},at=(e,t)=>Ye(e,t),re=e=>[...e.children].filter(n=>tt(n,k)),Ye=(e,t)=>{const n=[...t.children].filter(o=>tt(o,k)&&!o.isEqualNode(e)).toReversed(),s=[...t.children].findLastIndex(o=>o.isEqualNode(e));return[n,s,t]},Xe=e=>{let t=e.parentElement;for(;t;){if(window.getComputedStyle(t).position==="fixed")return t;t=t.parentElement}return null},ie=(e,t)=>{const{before:n,borderBeforeWidth:s}=R(t),o=Xe(e);return o?Mt(o)[n]+N(o,s):0},St=e=>window.TouchEvent&&e instanceof TouchEvent,K=e=>e instanceof HTMLElement,ce=e=>e instanceof MouseEvent,We=["onmouseup","onmousedown","onmousemove"],_e=(e,t,n)=>{e&&(e.style.height=`${t}px`,e.style.width=`${n}px`)},lt=(e,t,n)=>{!e||!K(e)||(n==0&&t==0?e.style.transform="":e.style.transform=`translate(${n}px,${t}px)`)},He=(e,t,n,s)=>{e[t]=o=>{if(o.defaultPrevented)return;s&&s(o);const r=It(o);n(r)}},Ft=(e,t,n,s)=>{n&&(Ve(t)?e[t]=n:He(e,t,n,s))},Ve=e=>We.includes(e),qe=e=>{const{target:t}=e;return{clientX:0,clientY:0,pageX:0,pageY:0,screenX:0,screenY:0,target:t,offsetX:0,offsetY:0}},ze=(e,t)=>{const n=(s,o)=>Ze(t,window,o,s);if(ce(e)){const{offsetX:s,offsetY:o}=e;return[s,o]}else{const s=e.target;return[n(s,W),n(s,J)]}},It=e=>{const t=je(e);if(!t)return qe(e);const[n,s]=ze(e,t),{clientX:o,clientY:r,pageX:a,pageY:i,screenX:f,screenY:l,target:m}=t;return{clientX:o,clientY:r,pageX:a,pageY:i,screenX:f,screenY:l,target:m,offsetX:n,offsetY:s}},je=e=>{if(St(e))return e.touches[0]??e.changedTouches[0];if(ce(e))return e},Ze=(e,t,n,s)=>{const{page:o,scroll:r,before:a,borderBeforeWidth:i,getRect:f}=R(n),l=f(s);return e[o]-t[r]-l[a]-N(s,i)},Ot=(e,t,n="ease-out",s="transform")=>{K(e)&&(e.style.transitionDuration=`${t}ms`,e.style.transitionTimingFunction=`${n}`,e.style.transitionProperty=`${s}`)},ae=(e,t,n)=>{!e||!K(e)||(e[t]=()=>{n()})},ke=e=>{var t=e.querySelector("style");if(!t){var n=document.createElement("style");return e.appendChild(n),n}return t},Je=(e,t)=>{const n=/\.-?[_a-zA-Z0-9-*\s<>():]+/g,[s]=t.match(n)||[];for(const o of e.cssRules){const[r]=o.cssText.match(n)||[];if(s===r)return!0}return!1},Ke=(e,t)=>{t.forEach(n=>{Qe(e,n)})},Qe=(e,t)=>{var s;var n=ke(e);n.sheet&&(Je(n.sheet,t)||(s=n.sheet)==null||s.insertRule(t,n.sheet.cssRules.length))},le=(e,t={})=>{for(const n of Object.keys(t)){const s=t[n];s!=null&&Ue(e,`--${n}`,s)}},Ue=(e,t,n)=>e&&e.style.setProperty(t,n),tn=(e,t,n)=>{n!=0&&(t==="vertical"?e.scrollBy(0,n):e.scrollBy(n,0))},en=e=>{let t=.5;const n=.03,s=(a,i,f,l)=>{const{before:m,distance:u,axis:D,getRect:b}=R(a),C=b(e)[u],O=b(i),S=f[m]-O[m]+l[D],v=O[u]-C,x=S/v,L=C/v,I=.25,P=.2,V=.8;let _=0;const $=Ge(e,i);!$&&x<P&&x>-L?_=o(x<0?0:x,P):!$&&x>V&&x<1+L&&(_=r(x,V));const q=I*C*_;t=Math.sign(q)*Math.min(Math.abs(q),Math.abs(t)+n),tn(i,a,t)},o=(a,i)=>Math.pow(a/i,1/3)-1,r=(a,i)=>Math.pow(1/(1-i)*(a-i),3);return[s]},nn=(e,t)=>{let n={offsetX:0,offsetY:0},s={top:0,left:0},o={x:0,y:0};const[r]=en(e),a=u=>{e.style.transform=`translate( ${u.x}px, ${u.y}px)`},i=u=>{e.style.top=`${u.top}px`,e.style.left=`${u.left}px`},f=(u,D,b,C)=>{const O=v=>{const{beforeMargin:x,borderBeforeWidth:L,before:I,offset:P,scroll:V,page:_,inner:$,distance:q,axis:nt,getRect:Q}=R(v),U=b[_],z=window[V],d=window[$],p=Q(u)[q],h=N(u,L),A=N(u,x),B=U-n[P],M=ie(u,v);if(B>=z-p/2&&B<=z+d){const F=B-s[I]-h-A-z-M;return S(v),F}return o[nt]},S=v=>{u&&tt(u,wt)&&v===C&&r(C,D,s,o)},E=v=>{const{axis:x}=R(v);o[x]=O(v),a(l())};E(W),E(J)},l=()=>{let u=o;for(const D of t)u=D(u,e);return u};return[f,(u,D)=>{const[b,C,O,S]=rn(u,D,e);s={top:b,left:C},i(s),n={offsetX:O,offsetY:S}}]},At=(e,t,n)=>{const{borderBeforeWidth:s,before:o,getRect:r}=R(e);return r(t)[o]-r(n)[o]-N(n,s)},sn=(e,t)=>{let{offsetX:n,offsetY:s,target:o}=e,r=on(o,t);const a=o;return a&&r&&!a.isSameNode(r)&&(n+=At(W,a,r),s+=At(J,a,r)),r&&t!=o&&(n+=At(W,r,t),s+=At(J,r,t)),[n,s]},on=(e,t)=>{const n=e==null?void 0:e.closest(`.${xt}`);return n&&n.isSameNode(t)?e:n},Kt=(e,t,n,s)=>{const{offset:o,beforeMargin:r,page:a,borderBeforeWidth:i,scroll:f}=R(e),l=ie(n,e);return t[a]-s[o]-N(n,r)-N(n,i)-window[f]-l},rn=(e,t,n)=>{const[s,o]=sn(e,n);return[Kt(J,e,t,{offsetX:s,offsetY:o}),Kt(W,e,t,{offsetX:s,offsetY:o}),s,o]},ue="startDrag",Bt="drag",fe="startDrop",ot="temp-child",de="cubic-bezier(0.2, 0, 0, 1)",Yt=e=>!e||e.length==0?0:Wt(e.replace("px","")),cn=(e,t)=>{const n=getComputedStyle(e)[t];if(n.match("%")){const o=Wt(n.replace("%","")),{width:r}=e.getBoundingClientRect();return r*(o/100)}return Yt(n)},_t=(e,t)=>{if(!(e instanceof Element))return[0,!1];const n=cn(e,t),s=getComputedStyle(e).display,o=n>0||s==="flex";return[n,o]},an=e=>{const{top:t,left:n}=getComputedStyle(e);return[Yt(t),Yt(n)]},ln=(e,t)=>{const{gap:n}=R(t),[s,o]=_t(e,n);return o?s:0};function ut(e,t,n,s,o=e.previousElementSibling,r=e.nextElementSibling){let{height:a,width:i}=un(n,e,o,r);return bt(e,s)&&t==Bt&&(a=0,i=0),{height:a,width:i}}const un=(e,t,n,s)=>{const{afterMargin:o,beforeMargin:r,distance:a,gap:i,getRect:f}=R(e),l=N(t,o),m=N(t,r),u=N(s,r),[D,b]=_t(t.parentElement,i),C=f(t)[a];if(b)return Qt(C,m,l,D,0,e);const[O,S,E]=fn(n,u,l,m,o);return Qt(C,S,O,0,E,e)},fn=(e,t,n,s,o)=>{const r=Math.max(t,n);let a=s,i=t;if(e){const f=N(e,o);a=Math.max(f,s),i=Math.max(i,f)}return[r,a,i]},Qt=(e,t,n,s,o,r)=>dn(r,e+t+n+s-o),dn=(e,t)=>e==W?{width:t,height:0}:{width:0,height:t},Ht=(e,t,n,s=()=>!0)=>{const o=new MutationObserver(r=>{if(r=r.filter(s),r.length>0){const a=r[0];e(o,a)}});return o.observe(t,n),o},Xt=e=>K(e)?e.classList.contains(ot):!1,gn="startDrag",ge="cubic-bezier(0.2, 0, 0, 1)",pe=50,pn=(e,t,n)=>{let s=ut(t,gn,n,e);const o=ln(e,n),{distance:r}=R(n);s[r]-=o;const[a,i]=hn(n,t);return s[i]=a,s},hn=(e,t)=>{const n=e==W?J:W,{distance:s,getRect:o}=R(n);return[o(t)[s],s]},dt=(e,t,n)=>{_e(e,t,n),e.style.minWidth=`${n}px`},mn=(e,t,n)=>s=>{t.contains(e)&&(dt(e,n.height,n.width),s.disconnect())},vn=(e,t,n)=>{const{scrollDistance:s,clientDistance:o,scrollElement:r}=R(e);return n[r]/(t[s]-t[o])},Sn=(e,t)=>{if(!t)return;const{droppable:n,config:s,scroll:o}=e,{direction:r}=s,a=vn(s.direction,n,o)>.99,{scrollDistance:i,clientDistance:f,scrollElement:l}=R(r);a&&(n[l]=n[i]-n[f])},he=(e,t,n,s)=>{if(!n)return;const{droppable:o,config:r}=n,{direction:a,animationDuration:i}=r;if(Sn(n,t),o.querySelector(`.${ot}`)||!e)return;var f=e.tagName=="LI"?"DIV":e.tagName,l=document.createElement(f);Z(l,ot),dt(l,0,0);const m=pn(o,e,a);return Ot(l,i,ge,"width, min-width, height"),[l,m,o]},Nt=(e,t,n,s,o)=>{const r=he(e,n,s);if(!r)return;const[a,i,f]=r;t.isSameNode(f)&&dt(a,i.height,i.width),Ht(mn(a,f,i),f,{childList:!0,subtree:!0}),f.appendChild(a)},Dn=(e,t,n)=>{const s=he(e,t,n);if(!s)return;const[o,r,a]=s;a.appendChild(o),Tn(o,r)},Tn=(e,t)=>requestAnimationFrame(()=>{dt(e,t.height,t.width),requestAnimationFrame(()=>{Ot(e,0,ge,"width, min-width, height")})}),bn=(e,t,n,s,o=!0)=>{if(n){var r=document.querySelectorAll(`${ft(n)} > .${ot}`);r.forEach(a=>{const i=a.parentElement;if(i!=null&&i.isSameNode(t)||!o&&(i!=null&&i.isSameNode(e)))return;dt(a,0,0),setTimeout(()=>{var l;(l=a.parentNode)==null||l.removeChild(a)},s+pe)})}},Dt=(e,t,n=!1)=>{var s=e.querySelectorAll(`.${ot}`);s.forEach(o=>{const r=o;n?(dt(r,0,0),setTimeout(()=>{e.contains(r)&&e.removeChild(r)},t+pe)):e.removeChild(o)})},Vt=(e,t,n)=>{const{handlerSelector:s,animationDuration:o}=e,r=l=>{n(),a(l,!1),l.style.transform="",l.style.transition="",l.style.top="",l.style.left="",le(l,{fixedHeight:"",fixedWidth:""})},a=(l,m)=>{ct(l,wt,m),i(m,l),t.toggleGrabClass(!m)},i=(l,m)=>{const u=m.querySelector(s);ct(document.body,ee,l),ct(u||m,$t,l)};return[r,a,(l,m)=>{const{width:u,height:D}=m;lt(l,D,u),Ot(l,o,de)}]};function En(e,t,n,s){const{animationDuration:o}=e,[r]=Vt(e,n,s),a=(u,D,b,C)=>{if(!b||!b.droppable||!b.config)return;const{droppable:O,config:S}=b;let[E]=at(D,O);E=[D,...E].toReversed();const v=ut(D,"remove",S.direction,O);for(const[x,L]of E.entries())x>=u&&(f(L,v),setTimeout(()=>{C(L)},o))},i=u=>{Dt(t,o,!0),setTimeout(()=>{r(u),l(u,t)},o)},f=(u,D)=>{const{width:b,height:C}=D;lt(u,C,b)},l=(u,D)=>{const[b]=at(u,D);for(const C of[...b,u])m(C)},m=u=>{K(u)&&(u.style.transition="",u.style.transform="")};return[a,i]}const j=class j{static addConfig(t,n){const s=j.configs.filter(r=>!r.droppable.isSameNode(t)),o=Jt(t);s.push({droppable:t,config:n,scroll:o}),j.configs=s}static updateScrolls(t,n){for(const s of j.configs){const{droppable:o}=s;(n&&Re(o,n)||o.isSameNode(t))&&(s.scroll=Jt(o))}}static getConfig(t){return j.configs.find(({droppable:s})=>s.isSameNode(t))}};H(j,"configs",[]),H(j,"removeObsoleteConfigs",()=>{const t=j.configs.filter(({droppable:n})=>document.contains(n));j.configs=t});let rt=j;const yn=(e,t)=>{const{config:n,droppable:s}=e,{onInsertEvent:o,onDragEnd:r}=n;return{...n,onDragEnd:f=>{const{index:l,value:m}=f;r({index:l,value:t(m,s)})},onInsertEvent:(f,l)=>o(f,t(l,s),!0)}};class Cn{constructor(t,n,s,o,r,a){H(this,"initial");H(this,"current");H(this,"parent");H(this,"draggableElement");H(this,"groupClass");H(this,"dragEvent");H(this,"changeDroppable");H(this,"mapFrom");this.parent=s,this.draggableElement=t,this.groupClass=n,this.dragEvent=o,this.mapFrom=a,this.initial=s?rt.getConfig(s):void 0,this.changeDroppable=r}getDraggableAncestor(t,n,s){return document.elementsFromPoint(t,n).filter(o=>!o.isSameNode(s))}getElementBelow(t,n,s=!0){const o=a=>{const[i]=a.getDraggableAncestor(n.clientX,n.clientY,t);return i};let r=null;return s?(t.hidden=!0,r=o(this),t.hidden=!1):r=o(this),r}getCurrent(t,n,s=!0){const o=this.getElementBelow(t,n,s);return!this.groupClass||!o?void 0:o.closest(ft(this.groupClass))}isOutsideOfAllDroppables(t){return(this.groupClass?Array.from(document.querySelectorAll(ft(this.groupClass))):[this.parent]).every(s=>bt(t,s))}isNotInsideAnotherDroppable(t,n){return!bt(t,n)||this.isOutsideOfAllDroppables(t)}onScrollEvent(){this.dragEvent()}setOnScroll(t){ae(t,"onscroll",()=>{this.onScrollEvent()})}getConfigFrom(t){const n=rt.getConfig(t);if(n)return t.isSameNode(this.parent)?n:{...n,config:yn(n,this.mapFrom)}}getCurrentConfig(t){var o;const n=this.draggableElement;if(this.current&&this.isNotInsideAnotherDroppable(n,(o=this.current)==null?void 0:o.droppable))return this.current;const s=this.getCurrent(n,t);return s?(K(s)&&!s.onscroll&&this.setOnScroll(s),this.getConfigFrom(s)):this.getConfigFrom(this.parent)}updateConfig(t){const n=this.current;this.current=this.getCurrentConfig(t),this.changeDroppable(this.current,n)}isOutside(t,n=!0){const s=this.draggableElement;return!this.getCurrent(s,t,n)}}const Ut=(e,t)=>{const{borderBeforeWidth:n,paddingBefore:s,axis:o,getRect:r}=R(e),a=N(t,n),i=N(t,s),f=r(t)[o];return a+i+f},An=(e,t)=>{const[n,s]=an(t),o=Ut(J,e);return[Ut(W,e)-s,o-n]};function xn(e,t,n,s,o,r,a,i,f){let l=0,m=0;const u=!!(n<0&&f);if(n===s&&!u)return te({height:l,width:m},e,o,a,u);const[D,b,C,O]=wn(t,n,s,f);if(u){const[h,A]=An(i,f);l+=A,m+=h}const{scrollElement:S,beforeMargin:E,afterMargin:v,distance:x,gap:L}=R(e),[I,P]=_t(i,L),[V,_,$]=Rn(E,v,D,b==null?void 0:b.previousElementSibling,O,P,u),[q,nt,Q]=On(E,v,x,C,I,P),U=Bn(nt,q,Q,_,V,I),z=u?i[S]:Mn(S,i,r),p=(O?U-$:$-U)-z;return e===J?l+=p:e===W&&(m+=p),te({height:l,width:m},e,o,a,u)}const Mn=(e,t,n)=>{const s=t[e],o=n[e];return s-o},Bn=(e,t,n,s,o,r)=>{const a=Math.max(t,o);return Math.max(n,s)+e+a+r},wn=(e,t,n,s)=>{const o=t<n,[r,a]=[t,n].toSorted((m,u)=>m-u),i=e[t]??s,f=e[n];let l=o?e.slice(r+1,a+1):e.slice(r,a);return r<0&&s&&(l=e.slice(r+1,a)),[i,f,l,o]},On=(e,t,n,s,o,r)=>{if(s.length==0)return[0,0,0];const a=N(s[0],e);let i=0,f=-a;for(const[l,m]of s.entries()){const u=m.getBoundingClientRect()[n],D=N(m,e);r&&(i+=D),r&&l>0?i+=o:i=Math.max(i,D),f+=i+u,i=N(m,t)}return[a,f,i]},te=(e,t,n,s,o)=>{const{scroll:r,distance:a}=R(t),i=window[r],f=n[r],l=o?0:f-2*i+s[r];return e[a]+=l,e},Rn=(e,t,n,s,o,r,a)=>{const i=o?n.previousElementSibling:s;return Ln(e,t,i,n,r,a)},Ln=(e,t,n,s,o,r)=>{if(o)return[0,0,0];const a=N(r?null:n,t),i=N(s,e);let f=Math.max(a,i);return[a,i,f]},Fn=50;function Nn(e,t,n,s,o,r){let a=t;const{direction:i,onRemoveAtEvent:f,animationDuration:l,draggingClass:m}=e,[u,D,b]=Vt(e,o,r),C=(d,p,h)=>{if(!h)return;const{droppable:A,config:B}=h,M=ut(d,p,B.direction,A);S(d,p,M,h)},O=(d,p,h,A,B)=>{if(!h)return;const{droppable:M,config:w}=h,F=ut(d,p,w.direction,M);L(d,p,F,A,h,B)},S=(d,p,h,A)=>{const{config:B,droppable:M}=A,[w]=at(d,M),F=bt(d,M);w.length==0&&v(h,1,B.direction,w);for(const[Y,G]of w.entries()){if(!tt(G,k))continue;const T=E(B.direction,d,G,h);if(!F&&T)h=T;else if(!F)continue;const X=w.length-Y;v(h,X,B.direction,w),p===ue?x(G,h):p===Bt&&b(G,h)}},E=(d,p,h,A)=>{const{before:B,distance:M,axis:w,getRect:F}=R(d),Y=F(p),G=F(h),T=Y[B],X=G[B],gt=G[M],pt=X+gt/2,ht=Pe(h)[w],et=pt-ht;return T>et?{height:0,width:0}:A},v=(d,p,h,A)=>{const B=A.filter(w=>tt(w,k)).length,{distance:M}=R(h);d[M]==0?a=Math.max(a,p):a=Math.min(a,p-1),a=Math.min(a,B)},x=(d,p)=>{const{width:h,height:A}=p;lt(d,A,h)},L=(d,p,h,A,B,M)=>{const{droppable:w,scroll:F,config:Y}=B,[G,T]=at(d,w),X=G.toReversed(),gt=T===-1?X.length:T;X.splice(gt,0,d);const[pt,ht,et]=I(d,T,X,w);h=ut(d,p,Y.direction,n,pt,ht);const Rt=Fe(),yt=xn(Y.direction,X,T,et,Rt,F,A,w,d);G.length==0&&P(void 0,h,d,yt);for(const[Lt,Ct]of G.toReversed().entries()){let mt=h;et-1>=Lt&&(mt={height:0,width:0}),p===fe&&!tt(Ct,ot)&&P(Ct,mt,d,yt)}V(et,d,Y,w,M)},I=(d,p,h,A)=>{const M=bt(d,A)?p:a,w=()=>p<M?[M,M+1]:p>M?[M-1,M]:[M-1,M+1],[F,Y]=w(),G=h[F]??null,T=h[Y]??null;return[G,T,M]},P=(d,p,h,A)=>{lt(d,p.height,p.width),lt(h,A.height,A.width)},V=(d,p,h,A,B)=>{const{onInsertEvent:M,onDragEnd:w}=h;Z(p,Gt),q(p,n,A,()=>{if(Tt(p,Gt),B!=null){const F=f(B,!0);F!=null&&(M(d,F,!0),w({value:F,index:d})),$(p),_()}})},_=()=>{if(s){var d=document.querySelectorAll(`${ft(s)} > .${k}`);for(const p of d)z(p)}},$=d=>{setTimeout(()=>{Tt(d,m)},Fn)},q=(d,p,h,A)=>{setTimeout(()=>{A&&A(),nt(p,h),Q(h),u(d),U(d,p),U(d,h)},l)},nt=(d,p)=>{d.isSameNode(p)?Dt(d,l):(Dt(d,l,!0),Dt(p,l))},Q=d=>{if(n.isSameNode(d))return;var[p]=n.querySelectorAll(`.${ot}`);if(!p)return;const{distance:h}=R(i);K(p)&&(p.style[h]="0px")},U=(d,p)=>{const[h]=at(d,p);for(const A of[...h,d])z(A)},z=d=>{K(d)&&(d.style.transition="",d.style.transform="")};return[C,O,D]}function Pn(e,t,n,s){const{delayBeforeInsert:o}=e,[r,a,i]=Vt(e,n,s),f=(u,D,b,C,O)=>{const S=ut(D,"insert",e.direction,b),{onInsertEvent:E}=e,v=re(b);for(const[x,L]of v.entries())tt(L,k)&&x>=u&&i(L,S);O(),setTimeout(()=>{E(u,C),me(u,b,e),r(D),l(D,t),Dt(t,0,!0)},o)},l=(u,D)=>{const[b]=at(u,D);for(const C of[...b,u])m(C)},m=u=>{K(u)&&(u.style.transition="",u.style.transform="")};return[f]}const $n=e=>e.addedNodes.values().filter(n=>!Xt(n)).toArray().length>0,me=(e,t,n)=>{const{insertingFromClass:s,animationDuration:o}=n,r=Ht(()=>{const i=re(t)[e];Z(i,s),Z(i,Zt),setTimeout(()=>{Tt(i,Zt),Tt(i,s),r.disconnect()},o)},t,{childList:!0},$n)},Gn=(e,t,n,s)=>{if(!t)return;const{onInsertEvent:o,delayBeforeInsert:r}=e;setTimeout(()=>{o(n,s),me(n,t,e)},r)};function In(e,t,n,s,o){const{handlerSelector:r,isDraggable:a,droppableGroup:i,animationDuration:f,delayBeforeRemove:l,draggingClass:m,removingClass:u,onRemoveAtEvent:D,droppableClass:b,onDragStart:C,delayBeforeTouchMoveEvent:O,coordinateTransform:S}=n,E=Et(i).map(c=>`droppable-group-${c}`).join(" ");let v=0,x={scrollX:0,scrollY:0},L={pageX:0,pageY:0},I,P;const[V,_]=nn(e,S),$=()=>{v=0},[q,nt]=En(n,s,o,$),[Q,U,z]=Nn(n,t,s,E,o,$),[d]=Pn(n,s,o,$),p=()=>{Z(e,k)},h=c=>{Z(c,xt),o.addSubscriber(c)},A=()=>{if(a(e)){const c=e.querySelector(r);h(c||e)}},B=()=>{A(),p()},M=c=>{const g=c==null?void 0:c.querySelector(`.${xt}`),y=g==null?void 0:g.parentElement;return g&&y&&tt(y,Pt)&&!y.isSameNode(s)?null:g},w=c=>{const g=M(c)??c;g&&a(c)&&(Ft(g,"onmousedown",mt("mousemove","mouseup")),Ft(g,"ontouchstart",mt("touchmove","touchend"),y=>{P={x:y.touches[0].clientX,y:y.touches[0].clientY}}),F(g)),c!=null&&c.isSameNode(g)||Ft(c,"onmousedown",ve),Z(s,Pt)},F=c=>{const g=c.querySelectorAll("img");Array.from(g).forEach(y=>{y.onmousedown=()=>!1})},Y=()=>{if(L.pageX==0&&L.pageY==0||!T.current)return;const{droppable:c,config:g}=T.current;V(e,c,L,g.direction),Q(e,Bt,T.current)},G=(c,g)=>{g&&v==2&&!(c!=null&&c.droppable.isSameNode(g.droppable))&&Q(e,Bt,g)},T=new Cn(e,E,s,Y,G,n.mapFrom),X=c=>{if(!T.current)return;const g=E?Array.from(document.querySelectorAll(ft(E))):[s];for(const y of g)y.classList.toggle(b,!c&&y.isSameNode(T.current.droppable))},gt=(c,g=!1)=>{T.updateConfig(c);const y=T.isOutside(c);X(y),v===1&&!g?zt(c):v===2&&(pt(y),be(c))},pt=(c=!0)=>{if(!T.current)return;const{droppable:g}=T.current;bn(g,s,E,f,c),!c&&Nt(e,s,v==1,T.current)},ht=c=>{if(St(c)&&P&&v==1){const g=Math.abs(c.touches[0].clientX-P.x),y=Math.abs(c.touches[0].clientY-P.y);if(Math.abs(g)>5&&Math.abs(y)>5)return clearTimeout(I),!1}return!0},et=c=>{clearTimeout(I);const g=It(c);if(St(c)&&c.cancelable&&v==2&&c.preventDefault(),St(c)&&!c.cancelable||!ht(c)){qt("touchmove",c);return}gt(g,St(c))},Rt=(c,g)=>{c=="touchmove"?I=setTimeout(()=>{g()},O):g()},yt=(c,g)=>{const{clientX:y,clientY:it}=c,st=document.elementFromPoint(y,it),vt=st==null?void 0:st.closest(`.${k}`);return vt&&g.isSameNode(vt)},Lt=c=>{const g=n.onGetValue(t);return{index:t,element:c,value:g}},Ct=c=>{T.updateConfig(c),X(T.isOutside(c)),zt(c)},mt=(c,g)=>y=>{if(!yt(y,e))return;rt.updateScrolls(s,E);const{scrollX:it,scrollY:st}=window;if(x={scrollX:it,scrollY:st},v===0){v=1;const vt=Lt(e);vt&&C(vt),Rt(c,()=>{c=="touchmove"&&Ct(y)}),document.addEventListener(c,et,{passive:!1}),Ee(s),document.addEventListener(g,Se(c),{once:!0})}},ve=c=>T.updateConfig(c),Se=c=>g=>{qt(c,g)},qt=(c,g)=>{X(!0);const y=It(g);Ce(T.isOutside(y,!1)),clearTimeout(I),document.removeEventListener(c,et),T.updateConfig(y);const it=T.getCurrentConfig(y);if(it){const{droppable:st}=it;De(st)}s.onscroll=null,$()},De=c=>{if(c.onscroll=null,!E)return;const g=Array.from(document.querySelectorAll(ft(E)));for(const y of g)K(y)&&(y.onscroll=null)},zt=c=>{Nt(e,s,v==1,T.current),Te(),Q(e,ue,T.current),Ae(e),_(c,e)},Te=()=>{v=2},be=c=>{const{pageX:g,pageY:y}=c;L={pageX:g,pageY:y},Y()},Ee=c=>ae(c,"onscroll",ye),ye=()=>Y(),Ce=c=>{if(v!==2&&v!==1){$();return}v=3,jt(e),e.classList.contains(wt)&&U(e,fe,c?T.initial:T.current,x,t)},jt=c=>{Ot(c,f,de),lt(c,0,0)},Ae=c=>{const{height:g,width:y}=c.getBoundingClientRect();le(c,{fixedHeight:`${g}px`,fixedWidth:`${y}px`}),z(c,!0),ct(c,m,!0),c.style.transition=""},xe=(c,g)=>{Tt(e,u),Nt(e,s,v==1,T.initial),q(c,e,g,y=>{jt(y),nt(e)}),D(t,!0)},Me=c=>{if(!T.initial)return;const g=T.initial;c==t&&(Z(e,u),setTimeout(()=>{xe(c,g)},l))},Be=(c,g)=>{(c===t||c===n.onGetLegth()&&t===c-1)&&d(c,e,s,g,()=>{Dn(e,v==1,T.initial)})};return B(),w(e),[Me,Be]}const Yn=(e,t)=>{e&&Le(t,e)},Xn=()=>{Ke(document.body,[`.${k}{touch-action:manipulation;user-select:none;box-sizing:border-box!important;-webkit-user-select:none;}`,`.${xt}{pointer-events:auto!important;}`,`.${ne}{cursor:grab;}`,".temp-child{touch-action:none;pointer-events:none;box-sizing:border-box!important;}",".droppable{box-sizing:border-box!important;}",`.${wt}{position:fixed;z-index:5000;width:var(--fixedWidth)!important;height:var(--fixedHeight)!important;}`,`.${$t}{pointer-events:none!important;}`,`.${Gt}{pointer-events:none!important;}`,`.${ee}{cursor:grabbing;}`,".disable-transition{transition:none!important;}"])};function Wn(e,t,n,s="index"){const o=s;let r=[],a=[];const{droppableGroup:i}=e;if(!n)return[r,a];const f=Et(i).map(l=>`droppable-group-${l}`).join(" ");Xn(),Yn(f,n);for(const l of n.children){const m=l.getAttribute(o),u=Ne(m),D=l;if(D&&u>=0){const[b,C]=In(D,u,e,n,t);r.push(b),a.push(C)}}return[r,a]}const _n=(e,t)=>{const n=(i,f)=>e.removeAtEvent(i,f),s=(i,f,l)=>e.insertEvent(i,f,l),o=()=>e.getLength(),r=i=>e.getValue(i),a=i=>i;return{direction:(t==null?void 0:t.direction)??J,handlerSelector:(t==null?void 0:t.handlerSelector)??k,draggingClass:(t==null?void 0:t.draggingClass)??"dragging",droppableClass:(t==null?void 0:t.droppableClass)??"droppable-hover",isDraggable:(t==null?void 0:t.isDraggable)??(()=>!0),onDragStart:(t==null?void 0:t.onDragStart)??(()=>{}),onDragEnd:(t==null?void 0:t.onDragEnd)??(()=>{}),droppableGroup:t==null?void 0:t.droppableGroup,onRemoveAtEvent:n,onInsertEvent:s,onGetLegth:o,onGetValue:r,animationDuration:(t==null?void 0:t.animationDuration)??200,removingClass:(t==null?void 0:t.removingClass)??"removing",insertingFromClass:(t==null?void 0:t.insertingFromClass)??"from-inserting",delayBeforeRemove:(t==null?void 0:t.delayBeforeRemove)??200,delayBeforeInsert:(t==null?void 0:t.delayBeforeInsert)??200,mapFrom:(t==null?void 0:t.mapFrom)??a,delayBeforeTouchMoveEvent:(t==null?void 0:t.delayBeforeTouchMoveEvent)??150,coordinateTransform:(t==null?void 0:t.coordinateTransform)??[i=>i]}};function Hn(e,t,n,s="index"){let o=[],r=[],a;const i=_n(e,n),f=S=>{for(const E of o)E(S)},l=(S,E)=>{if(i.onGetLegth()===0)e.insertToListEmpty(i,S,E);else for(const x of r)x(S,E)},m=S=>{const[E,v]=Wn(i,t,S,s);o=E,r=v},u=S=>{const E=S.addedNodes.values().filter(x=>!Xt(x)).toArray(),v=S.removedNodes.values().filter(x=>!Xt(x)).toArray();return E.length>0||v.length>0},D=S=>{a=Ht(()=>{m(S)},S,{childList:!0},u)},b=S=>{Z(S,Pt)},C=S=>{rt.addConfig(S,i)};return[f,l,S=>{if(S)return b(S),C(S),D(S),m(S),rt.removeObsoleteConfigs(),a}]}exports.GRAB_CLASS=ne;exports.addClass=Z;exports.dragAndDrop=Hn;exports.insertToListEmpty=Gn;exports.toggleClass=ct;
|