adverich-kun-ui 0.1.640 → 0.1.641
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/AGENTS.md +7 -1
- package/dist/AGENTS.md +7 -1
- package/dist/components/KunDragAndDrop/src/components/KunDragAndDrop.js +6 -0
- package/dist/components/KunDragAndDrop/src/composables/kunDragAndDropProps.js +12 -0
- package/dist/components/KunDragAndDrop/src/composables/useKunDragAndDrop.js +200 -165
- package/dist/components/KunDragAndDrop/src/utils/kunDragAndDropScroll.js +46 -0
- package/package.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -677,7 +677,11 @@ const items = ref([
|
|
|
677
677
|
| dragHandle | String | null | Selector del handle (`null` = ítem completo) |
|
|
678
678
|
| itemDraggable | Function | null | `(item) => boolean` |
|
|
679
679
|
| layout | String | `'list'` | `'list'` \| `'grid'` (solo CSS) |
|
|
680
|
-
| draggingClass | String | `'
|
|
680
|
+
| draggingClass | String | `''` | Clase extra mientras se arrastra |
|
|
681
|
+
| dropZoneClass | String | `'kun-dnd-drop-zone'` | Placeholder in-list |
|
|
682
|
+
| autoScroll | Boolean | true | Auto-scroll por bordes del ancestro overflow |
|
|
683
|
+
| scrollSensitivity | Number | 50 | Distancia (px) al borde para iniciar scroll |
|
|
684
|
+
| scrollSpeed | Number | 12 | Velocidad de scroll por frame |
|
|
681
685
|
| tag | String | `'div'` | Tag del contenedor |
|
|
682
686
|
|
|
683
687
|
**Eventos:** `update:modelValue`, `update:items`, `drag-start`, `drag-end`, `sort`, `transfer`
|
|
@@ -686,6 +690,8 @@ const items = ref([
|
|
|
686
690
|
|
|
687
691
|
**Subcomponentes:** `KunDragAndDropItem`, `KunDragAndDropHandle`
|
|
688
692
|
|
|
693
|
+
**Scroll durante drag:** HTML5 DnD bloquea la rueda del mouse. Con `autoScroll` (default), acercar el puntero al borde superior/inferior (o laterales) del contenedor `overflow: auto|scroll` más cercano desplaza la vista. No depende de la rueda.
|
|
694
|
+
|
|
689
695
|
**Composable headless:**
|
|
690
696
|
|
|
691
697
|
```js
|
package/dist/AGENTS.md
CHANGED
|
@@ -677,7 +677,11 @@ const items = ref([
|
|
|
677
677
|
| dragHandle | String | null | Selector del handle (`null` = ítem completo) |
|
|
678
678
|
| itemDraggable | Function | null | `(item) => boolean` |
|
|
679
679
|
| layout | String | `'list'` | `'list'` \| `'grid'` (solo CSS) |
|
|
680
|
-
| draggingClass | String | `'
|
|
680
|
+
| draggingClass | String | `''` | Clase extra mientras se arrastra |
|
|
681
|
+
| dropZoneClass | String | `'kun-dnd-drop-zone'` | Placeholder in-list |
|
|
682
|
+
| autoScroll | Boolean | true | Auto-scroll por bordes del ancestro overflow |
|
|
683
|
+
| scrollSensitivity | Number | 50 | Distancia (px) al borde para iniciar scroll |
|
|
684
|
+
| scrollSpeed | Number | 12 | Velocidad de scroll por frame |
|
|
681
685
|
| tag | String | `'div'` | Tag del contenedor |
|
|
682
686
|
|
|
683
687
|
**Eventos:** `update:modelValue`, `update:items`, `drag-start`, `drag-end`, `sort`, `transfer`
|
|
@@ -686,6 +690,8 @@ const items = ref([
|
|
|
686
690
|
|
|
687
691
|
**Subcomponentes:** `KunDragAndDropItem`, `KunDragAndDropHandle`
|
|
688
692
|
|
|
693
|
+
**Scroll durante drag:** HTML5 DnD bloquea la rueda del mouse. Con `autoScroll` (default), acercar el puntero al borde superior/inferior (o laterales) del contenedor `overflow: auto|scroll` más cercano desplaza la vista. No depende de la rueda.
|
|
694
|
+
|
|
689
695
|
**Composable headless:**
|
|
690
696
|
|
|
691
697
|
```js
|
|
@@ -45,6 +45,9 @@ var T = /* @__PURE__ */ e({ default: () => O }), E = { class: "flex items-center
|
|
|
45
45
|
orientation: T.orientation || (T.layout === "grid" ? "grid" : "vertical"),
|
|
46
46
|
itemDraggable: T.itemDraggable,
|
|
47
47
|
dragHandle: N.value,
|
|
48
|
+
autoScroll: T.autoScroll,
|
|
49
|
+
scrollSensitivity: T.scrollSensitivity,
|
|
50
|
+
scrollSpeed: T.scrollSpeed,
|
|
48
51
|
onDragstart: (e) => O("drag-start", e),
|
|
49
52
|
onDragend: (e) => O("drag-end", e),
|
|
50
53
|
onSort: (e) => {
|
|
@@ -74,6 +77,9 @@ var T = /* @__PURE__ */ e({ default: () => O }), E = { class: "flex items-center
|
|
|
74
77
|
T.orientation,
|
|
75
78
|
T.layout,
|
|
76
79
|
T.itemDraggable,
|
|
80
|
+
T.autoScroll,
|
|
81
|
+
T.scrollSensitivity,
|
|
82
|
+
T.scrollSpeed,
|
|
77
83
|
N.value
|
|
78
84
|
], () => {
|
|
79
85
|
I(F());
|
|
@@ -76,6 +76,18 @@ var e = {
|
|
|
76
76
|
listClass: {
|
|
77
77
|
type: String,
|
|
78
78
|
default: "flex flex-col gap-2"
|
|
79
|
+
},
|
|
80
|
+
autoScroll: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
default: !0
|
|
83
|
+
},
|
|
84
|
+
scrollSensitivity: {
|
|
85
|
+
type: Number,
|
|
86
|
+
default: 50
|
|
87
|
+
},
|
|
88
|
+
scrollSpeed: {
|
|
89
|
+
type: Number,
|
|
90
|
+
default: 12
|
|
79
91
|
}
|
|
80
92
|
};
|
|
81
93
|
//#endregion
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { getIncomingDirection as e, getInsertIndexFromPoint as t, getTargetItemFromPoint as n, passesSortThreshold as r, performSort as i, performTransfer as a, resolveItemKey as o } from "../utils/kunDragAndDropMath.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { findScrollParent as s, getAutoScrollDelta as c } from "../utils/kunDragAndDropScroll.js";
|
|
3
|
+
import { activeDragRef as l, clearActiveDrag as u, getActiveDrag as d, getGroupParents as f, registerParent as p, setActiveDrag as m, unregisterParent as h } from "./kunDragAndDropRegistry.js";
|
|
4
|
+
import { computed as g, isRef as _, onBeforeUnmount as ee, onMounted as te, ref as v, unref as y, watch as b } from "vue";
|
|
4
5
|
//#region src/components/KunDragAndDrop/src/composables/useKunDragAndDrop.js
|
|
5
|
-
var x = "data-kun-dnd-item", S = "data-kun-dnd-key",
|
|
6
|
-
function
|
|
6
|
+
var x = "data-kun-dnd-item", S = "data-kun-dnd-key", ne = "input,textarea,select,button,a,[role=\"button\"],[data-no-drag]", C = 0;
|
|
7
|
+
function re() {
|
|
7
8
|
return C += 1, `kun-dnd-${C}`;
|
|
8
9
|
}
|
|
9
|
-
function
|
|
10
|
+
function ie(e) {
|
|
10
11
|
return typeof e == "object" && !!e && !Array.isArray(e) && ("parent" in e || "values" in e);
|
|
11
12
|
}
|
|
12
|
-
function
|
|
13
|
+
function ae(e = {}) {
|
|
13
14
|
return {
|
|
14
15
|
group: e.group ?? null,
|
|
15
16
|
dragHandle: e.dragHandle ?? null,
|
|
@@ -28,19 +29,22 @@ function w(e = {}) {
|
|
|
28
29
|
onTransfer: typeof e.onTransfer == "function" ? e.onTransfer : null,
|
|
29
30
|
onDragstart: typeof e.onDragstart == "function" ? e.onDragstart : null,
|
|
30
31
|
onDragend: typeof e.onDragend == "function" ? e.onDragend : null,
|
|
31
|
-
onValuesChange: typeof e.onValuesChange == "function" ? e.onValuesChange : null
|
|
32
|
+
onValuesChange: typeof e.onValuesChange == "function" ? e.onValuesChange : null,
|
|
33
|
+
autoScroll: e.autoScroll !== !1,
|
|
34
|
+
scrollSensitivity: Number.isFinite(e.scrollSensitivity) ? e.scrollSensitivity : 50,
|
|
35
|
+
scrollSpeed: Number.isFinite(e.scrollSpeed) ? e.scrollSpeed : 12
|
|
32
36
|
};
|
|
33
37
|
}
|
|
34
|
-
function
|
|
38
|
+
function oe(e, t, n) {
|
|
35
39
|
if (e === t) return !0;
|
|
36
40
|
if (!e || !t || e.length !== t.length) return !1;
|
|
37
41
|
for (let r = 0; r < e.length; r++) if (o(e[r], n, r) !== o(t[r], n, r)) return !1;
|
|
38
42
|
return !0;
|
|
39
43
|
}
|
|
40
|
-
function
|
|
44
|
+
function se(e) {
|
|
41
45
|
return typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(String(e)) : String(e).replace(/"/g, "\\\"");
|
|
42
46
|
}
|
|
43
|
-
function
|
|
47
|
+
function w(e, t, n) {
|
|
44
48
|
if (!n) return !0;
|
|
45
49
|
let r = typeof e.composedPath == "function" ? e.composedPath() : [], i = r.indexOf(t), a = i === -1 ? [] : r.slice(0, i);
|
|
46
50
|
for (let e of a) if (e instanceof Element && e.matches(n)) return !0;
|
|
@@ -49,139 +53,176 @@ function T(e, t, n) {
|
|
|
49
53
|
for (let e of o) if (s === e || e.contains(s)) return !0;
|
|
50
54
|
return !1;
|
|
51
55
|
}
|
|
52
|
-
function
|
|
53
|
-
let
|
|
54
|
-
function
|
|
55
|
-
return y(
|
|
56
|
+
function ce(C, ce) {
|
|
57
|
+
let T = ie(C), E = T ? C : {}, le = ae(T ? E : ce || {}), D = re(), O = v({ ...le }), k = T && E.parent ? E.parent : v(null), A = T && E.values ? E.values : v(Array.isArray(C) ? [...C] : []), j = g(() => l.value?.itemKey ?? null), M = v(null), N = null, P = null, F = null, I = null, L = null, R = 0, z = null, B = null, V = 0, H = 0, U = null, W = !1;
|
|
58
|
+
function G() {
|
|
59
|
+
return y(A) || [];
|
|
56
60
|
}
|
|
57
|
-
function
|
|
61
|
+
function K(e, t = {}) {
|
|
58
62
|
let n = Array.isArray(e) ? e : [];
|
|
59
|
-
|
|
63
|
+
_(A) && (A.value = n), J().onValuesChange?.(n, t);
|
|
60
64
|
}
|
|
61
|
-
function
|
|
62
|
-
return y(
|
|
65
|
+
function q() {
|
|
66
|
+
return y(k) || null;
|
|
63
67
|
}
|
|
64
|
-
function
|
|
65
|
-
return
|
|
68
|
+
function J() {
|
|
69
|
+
return O.value;
|
|
66
70
|
}
|
|
67
|
-
function
|
|
68
|
-
|
|
69
|
-
...
|
|
71
|
+
function ue(e = {}) {
|
|
72
|
+
O.value = ae({
|
|
73
|
+
...O.value,
|
|
70
74
|
...e
|
|
71
|
-
}),
|
|
72
|
-
}
|
|
73
|
-
function
|
|
74
|
-
|
|
75
|
-
id:
|
|
76
|
-
group:
|
|
77
|
-
getParentEl:
|
|
78
|
-
getValues:
|
|
79
|
-
setValues:
|
|
80
|
-
getConfig:
|
|
81
|
-
},
|
|
82
|
-
}
|
|
83
|
-
function
|
|
84
|
-
let t =
|
|
85
|
-
return
|
|
86
|
-
}
|
|
87
|
-
function
|
|
88
|
-
let t =
|
|
75
|
+
}), de();
|
|
76
|
+
}
|
|
77
|
+
function de() {
|
|
78
|
+
N && h(N), N = {
|
|
79
|
+
id: D,
|
|
80
|
+
group: O.value.group,
|
|
81
|
+
getParentEl: q,
|
|
82
|
+
getValues: G,
|
|
83
|
+
setValues: K,
|
|
84
|
+
getConfig: J
|
|
85
|
+
}, p(N);
|
|
86
|
+
}
|
|
87
|
+
function Y(e) {
|
|
88
|
+
let t = J();
|
|
89
|
+
return G().findIndex((n, r) => String(o(n, t.itemKey, r)) === String(e));
|
|
90
|
+
}
|
|
91
|
+
function fe(e) {
|
|
92
|
+
let t = q();
|
|
89
93
|
if (!t || !e?.target?.closest) return null;
|
|
90
94
|
let n = e.target.closest(`[${x}="true"]`);
|
|
91
95
|
return !n || !t.contains(n) ? null : n;
|
|
92
96
|
}
|
|
93
|
-
function
|
|
94
|
-
let t =
|
|
95
|
-
return !t || e == null ? null : t.querySelector(`[${S}="${
|
|
97
|
+
function X(e) {
|
|
98
|
+
let t = q();
|
|
99
|
+
return !t || e == null ? null : t.querySelector(`[${S}="${se(e)}"]`);
|
|
96
100
|
}
|
|
97
|
-
function
|
|
98
|
-
let e =
|
|
101
|
+
function pe() {
|
|
102
|
+
let e = q(), t = J();
|
|
99
103
|
if (!e) return;
|
|
100
104
|
let n = [...(t.draggingClass || "").split(/\s+/), ...(t.dropZoneClass || "").split(/\s+/)].filter(Boolean);
|
|
101
105
|
n.length && e.querySelectorAll(`[${x}="true"]`).forEach((e) => {
|
|
102
106
|
n.forEach((t) => e.classList.remove(t));
|
|
103
107
|
});
|
|
104
108
|
}
|
|
105
|
-
function
|
|
106
|
-
let e =
|
|
109
|
+
function me() {
|
|
110
|
+
let e = d(), t = e?.group ? f(e.group) : [];
|
|
107
111
|
t.length ? t.forEach((e) => {
|
|
108
|
-
let t = e.getParentEl?.(), n = e.getConfig?.() ||
|
|
112
|
+
let t = e.getParentEl?.(), n = e.getConfig?.() || J();
|
|
109
113
|
if (!t) return;
|
|
110
114
|
let r = [...(n.draggingClass || "").split(/\s+/), ...(n.dropZoneClass || "").split(/\s+/)].filter(Boolean);
|
|
111
115
|
t.querySelectorAll(`[${x}="true"]`).forEach((e) => {
|
|
112
116
|
r.forEach((t) => e.classList.remove(t));
|
|
113
117
|
});
|
|
114
|
-
}) :
|
|
118
|
+
}) : pe();
|
|
119
|
+
}
|
|
120
|
+
function he() {
|
|
121
|
+
me(), M.value = null, I = null, R = 0, z = null, Z(), L?.parentNode && L.parentNode.removeChild(L), L = null;
|
|
122
|
+
}
|
|
123
|
+
function Z() {
|
|
124
|
+
V = 0, H = 0, U = null, B != null && (cancelAnimationFrame(B), B = null);
|
|
115
125
|
}
|
|
116
|
-
function
|
|
117
|
-
|
|
126
|
+
function ge() {
|
|
127
|
+
if (B = null, !d() || !U) {
|
|
128
|
+
Z();
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
(V !== 0 || H !== 0) && (H !== 0 && (U.scrollTop += H), V !== 0 && (U.scrollLeft += V), B = requestAnimationFrame(ge));
|
|
118
132
|
}
|
|
119
|
-
function
|
|
133
|
+
function _e(e, t) {
|
|
134
|
+
let n = J();
|
|
135
|
+
if (!n.autoScroll || !d()) {
|
|
136
|
+
Z();
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
let r = null;
|
|
140
|
+
try {
|
|
141
|
+
r = document.elementFromPoint(e, t);
|
|
142
|
+
} catch {}
|
|
143
|
+
let i = s(r) || s(q());
|
|
144
|
+
U = i;
|
|
145
|
+
let { dx: a, dy: o } = c(e, t, i, {
|
|
146
|
+
sensitivity: n.scrollSensitivity,
|
|
147
|
+
speed: n.scrollSpeed
|
|
148
|
+
});
|
|
149
|
+
V = a, H = o, (a !== 0 || o !== 0) && B == null && (B = requestAnimationFrame(ge)), a === 0 && o === 0 && B != null && (cancelAnimationFrame(B), B = null);
|
|
150
|
+
}
|
|
151
|
+
function ve(e) {
|
|
152
|
+
!W || !d() || (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "move"), _e(e.clientX, e.clientY));
|
|
153
|
+
}
|
|
154
|
+
function ye() {
|
|
155
|
+
W || (W = !0, document.addEventListener("dragover", ve, !0), document.addEventListener("dragend", Ae, !0));
|
|
156
|
+
}
|
|
157
|
+
function Q() {
|
|
158
|
+
W && (W = !1, document.removeEventListener("dragover", ve, !0), document.removeEventListener("dragend", Ae, !0));
|
|
159
|
+
}
|
|
160
|
+
function be() {
|
|
120
161
|
try {
|
|
121
162
|
return;
|
|
122
163
|
} catch {}
|
|
123
|
-
let e =
|
|
164
|
+
let e = q();
|
|
124
165
|
if (!e) return;
|
|
125
|
-
let t = [...e.children].filter((e) => e.getAttribute?.("data-kun-dnd-item") === "true" && !e.hasAttribute?.("data-kun-dnd-placeholder")).length, n =
|
|
166
|
+
let t = [...e.children].filter((e) => e.getAttribute?.("data-kun-dnd-item") === "true" && !e.hasAttribute?.("data-kun-dnd-placeholder")).length, n = G().length;
|
|
126
167
|
t !== n && console.warn("[KunDragAndDrop] The number of draggable items in the parent does not match the number of values, which may lead to unexpected behavior.", {
|
|
127
168
|
childCount: t,
|
|
128
169
|
valueCount: n
|
|
129
170
|
});
|
|
130
171
|
}
|
|
131
|
-
function
|
|
132
|
-
let t =
|
|
172
|
+
function xe(e) {
|
|
173
|
+
let t = J();
|
|
133
174
|
if (t.disabled || !t.sortable) return;
|
|
134
|
-
let n =
|
|
175
|
+
let n = fe(e);
|
|
135
176
|
if (!n) {
|
|
136
|
-
|
|
177
|
+
M.value = null;
|
|
137
178
|
return;
|
|
138
179
|
}
|
|
139
180
|
if (t.dragHandle) {
|
|
140
|
-
if (!
|
|
141
|
-
|
|
181
|
+
if (!w(e, n, t.dragHandle)) {
|
|
182
|
+
M.value = null, n.draggable = !1;
|
|
142
183
|
return;
|
|
143
184
|
}
|
|
144
185
|
let r = n.getAttribute(S);
|
|
145
|
-
|
|
186
|
+
M.value = r, n.draggable = !0;
|
|
146
187
|
return;
|
|
147
188
|
}
|
|
148
|
-
if (e.target?.closest?.(
|
|
149
|
-
n.draggable = !1,
|
|
189
|
+
if (e.target?.closest?.(ne)) {
|
|
190
|
+
n.draggable = !1, M.value = null;
|
|
150
191
|
return;
|
|
151
192
|
}
|
|
152
|
-
n.draggable = !0,
|
|
193
|
+
n.draggable = !0, M.value = n.getAttribute(S);
|
|
153
194
|
}
|
|
154
|
-
function
|
|
155
|
-
if (!
|
|
156
|
-
let e =
|
|
157
|
-
e && !
|
|
195
|
+
function $() {
|
|
196
|
+
if (!J().dragHandle) return;
|
|
197
|
+
let e = X(M.value);
|
|
198
|
+
e && !j.value && (e.draggable = !1, M.value = null);
|
|
158
199
|
}
|
|
159
|
-
function
|
|
160
|
-
let t =
|
|
200
|
+
function Se(e) {
|
|
201
|
+
let t = J();
|
|
161
202
|
if (t.disabled || !t.sortable) {
|
|
162
203
|
e.preventDefault();
|
|
163
204
|
return;
|
|
164
205
|
}
|
|
165
|
-
let n =
|
|
206
|
+
let n = fe(e);
|
|
166
207
|
if (!n) {
|
|
167
208
|
e.preventDefault();
|
|
168
209
|
return;
|
|
169
210
|
}
|
|
170
211
|
if (t.dragHandle) {
|
|
171
|
-
if (!
|
|
212
|
+
if (!w(e, n, t.dragHandle)) {
|
|
172
213
|
e.preventDefault(), n.draggable = !1;
|
|
173
214
|
return;
|
|
174
215
|
}
|
|
175
|
-
} else if (e.target?.closest?.(
|
|
216
|
+
} else if (e.target?.closest?.(ne)) {
|
|
176
217
|
e.preventDefault();
|
|
177
218
|
return;
|
|
178
219
|
}
|
|
179
|
-
let r = n.getAttribute(S), i =
|
|
220
|
+
let r = n.getAttribute(S), i = Y(r);
|
|
180
221
|
if (i < 0) {
|
|
181
222
|
e.preventDefault();
|
|
182
223
|
return;
|
|
183
224
|
}
|
|
184
|
-
let a =
|
|
225
|
+
let a = G()[i];
|
|
185
226
|
if (t.itemDraggable && !t.itemDraggable(a)) {
|
|
186
227
|
e.preventDefault();
|
|
187
228
|
return;
|
|
@@ -202,13 +243,13 @@ function E(C, E) {
|
|
|
202
243
|
opacity: "1",
|
|
203
244
|
zIndex: "9999",
|
|
204
245
|
transform: "none"
|
|
205
|
-
}), i.classList.remove(...(t.draggingClass || "").split(/\s+/).filter(Boolean), ...(t.dropZoneClass || "").split(/\s+/).filter(Boolean)), document.body.appendChild(i),
|
|
246
|
+
}), i.classList.remove(...(t.draggingClass || "").split(/\s+/).filter(Boolean), ...(t.dropZoneClass || "").split(/\s+/).filter(Boolean)), document.body.appendChild(i), L = i;
|
|
206
247
|
let a = typeof e.offsetX == "number" ? e.offsetX : r.width / 2, o = typeof e.offsetY == "number" ? e.offsetY : r.height / 2;
|
|
207
248
|
e.dataTransfer.setDragImage(i, a, o);
|
|
208
249
|
} catch {}
|
|
209
250
|
}
|
|
210
|
-
|
|
211
|
-
sourceId:
|
|
251
|
+
M.value = r, I = null, z = null, m({
|
|
252
|
+
sourceId: D,
|
|
212
253
|
group: t.group,
|
|
213
254
|
itemKey: r,
|
|
214
255
|
item: a,
|
|
@@ -220,11 +261,11 @@ function E(C, E) {
|
|
|
220
261
|
event: e
|
|
221
262
|
});
|
|
222
263
|
}
|
|
223
|
-
function
|
|
264
|
+
function Ce(t, n, i, a, o, s) {
|
|
224
265
|
if (!t || !n || t === n || o < 0 || s < 0 || o === s) return !1;
|
|
225
266
|
let c = t.getAttribute(S);
|
|
226
|
-
if (c == null || String(c) === String(
|
|
227
|
-
let l =
|
|
267
|
+
if (c == null || String(c) === String(I)) return !1;
|
|
268
|
+
let l = J(), u = t.getBoundingClientRect(), d = l.threshold || {
|
|
228
269
|
horizontal: 0,
|
|
229
270
|
vertical: 0
|
|
230
271
|
}, f = l.orientation || "vertical", p = o < s;
|
|
@@ -245,139 +286,133 @@ function E(C, E) {
|
|
|
245
286
|
let m = n.getBoundingClientRect(), h = e(m, u);
|
|
246
287
|
return r(h, u, i, a, d);
|
|
247
288
|
}
|
|
248
|
-
function
|
|
249
|
-
let n =
|
|
250
|
-
if (!r || r.sourceId !==
|
|
251
|
-
let a = e.getAttribute(S), s =
|
|
252
|
-
if (s < 0 || c < 0 || s === c || !
|
|
253
|
-
let
|
|
254
|
-
if (
|
|
255
|
-
|
|
256
|
-
let
|
|
257
|
-
|
|
289
|
+
function we(e, t) {
|
|
290
|
+
let n = J(), r = d();
|
|
291
|
+
if (!r || r.sourceId !== D) return;
|
|
292
|
+
let a = e.getAttribute(S), s = Y(r.itemKey), c = Y(a);
|
|
293
|
+
if (s < 0 || c < 0 || s === c || !Ce(e, X(r.itemKey), t.clientX, t.clientY, s, c)) return;
|
|
294
|
+
let l = G(), u = i(l, s, c);
|
|
295
|
+
if (oe(u, l, n.itemKey)) return;
|
|
296
|
+
I = a, R = performance.now() + 80;
|
|
297
|
+
let f = u.findIndex((e, t) => String(o(e, n.itemKey, t)) === String(r.itemKey));
|
|
298
|
+
K(u, { reason: "sort" }), m({
|
|
258
299
|
...r,
|
|
259
|
-
fromIndex:
|
|
300
|
+
fromIndex: f
|
|
260
301
|
}), n.onSort?.({
|
|
261
302
|
item: r.item,
|
|
262
303
|
fromIndex: s,
|
|
263
|
-
toIndex:
|
|
304
|
+
toIndex: f,
|
|
264
305
|
previousPosition: s,
|
|
265
|
-
position:
|
|
266
|
-
items:
|
|
306
|
+
position: f,
|
|
307
|
+
items: u,
|
|
267
308
|
event: t
|
|
268
309
|
});
|
|
269
310
|
}
|
|
270
|
-
function
|
|
271
|
-
let n =
|
|
272
|
-
if (!r || r.sourceId ===
|
|
273
|
-
let i =
|
|
311
|
+
function Te(e) {
|
|
312
|
+
let n = J(), r = d();
|
|
313
|
+
if (!r || r.sourceId === D || !n.group || n.group !== r.group || performance.now() < R) return;
|
|
314
|
+
let i = f(r.group).find((e) => e.id === r.sourceId);
|
|
274
315
|
if (!i) return;
|
|
275
|
-
let s =
|
|
276
|
-
if (
|
|
277
|
-
let
|
|
316
|
+
let s = q(), c = X(r.itemKey), l = t(s, e.clientX, e.clientY, n.orientation || "vertical", c), u = `${r.sourceId}:${l}:${r.itemKey}`;
|
|
317
|
+
if (u === z) return;
|
|
318
|
+
let p = i.getValues().findIndex((e, t) => {
|
|
278
319
|
let n = o(e, i.getConfig().itemKey, t);
|
|
279
320
|
return String(n) === String(r.itemKey);
|
|
280
321
|
});
|
|
281
|
-
if (
|
|
282
|
-
let { source: h, target: g, item: _ } = a(i.getValues(),
|
|
283
|
-
_ !== void 0 && (
|
|
322
|
+
if (p < 0) return;
|
|
323
|
+
let { source: h, target: g, item: _ } = a(i.getValues(), p, G(), l);
|
|
324
|
+
_ !== void 0 && (z = u, I = null, R = performance.now() + 80, i.setValues(h, { reason: "transfer-out" }), K(g, { reason: "transfer-in" }), m({
|
|
284
325
|
...r,
|
|
285
|
-
sourceId:
|
|
286
|
-
fromIndex:
|
|
326
|
+
sourceId: D,
|
|
327
|
+
fromIndex: l,
|
|
287
328
|
item: _
|
|
288
329
|
}), n.onTransfer?.({
|
|
289
330
|
item: _,
|
|
290
|
-
fromIndex:
|
|
291
|
-
toIndex:
|
|
331
|
+
fromIndex: p,
|
|
332
|
+
toIndex: l,
|
|
292
333
|
sourceItems: h,
|
|
293
334
|
targetItems: g,
|
|
294
335
|
event: e
|
|
295
336
|
}));
|
|
296
337
|
}
|
|
297
|
-
function
|
|
298
|
-
let t =
|
|
338
|
+
function Ee(e) {
|
|
339
|
+
let t = J(), r = d();
|
|
299
340
|
if (!r || t.disabled) return;
|
|
300
|
-
let i = r.sourceId ===
|
|
301
|
-
!i && !a || (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "move"), !
|
|
302
|
-
|
|
303
|
-
let r =
|
|
341
|
+
let i = r.sourceId === D, a = !!t.group && t.group === r.group;
|
|
342
|
+
!i && !a || (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "move"), _e(e.clientX, e.clientY), !F && (F = requestAnimationFrame(() => {
|
|
343
|
+
F = null;
|
|
344
|
+
let r = d();
|
|
304
345
|
if (!r) return;
|
|
305
|
-
let i = r.sourceId ===
|
|
346
|
+
let i = r.sourceId === D, a = !!t.group && t.group === r.group;
|
|
306
347
|
if (i && t.sortable) {
|
|
307
|
-
let t =
|
|
348
|
+
let t = q(), i = X(r.itemKey), a = n(t, e.clientX, e.clientY, i);
|
|
308
349
|
if (!a) {
|
|
309
|
-
|
|
350
|
+
I = null;
|
|
310
351
|
return;
|
|
311
352
|
}
|
|
312
|
-
if (performance.now() <
|
|
313
|
-
|
|
353
|
+
if (performance.now() < R) {
|
|
354
|
+
I = a.getAttribute(S);
|
|
314
355
|
return;
|
|
315
356
|
}
|
|
316
|
-
|
|
357
|
+
we(a, e);
|
|
317
358
|
return;
|
|
318
359
|
}
|
|
319
|
-
!i && a &&
|
|
360
|
+
!i && a && Te(e);
|
|
320
361
|
})));
|
|
321
362
|
}
|
|
322
|
-
function
|
|
363
|
+
function De(e) {
|
|
323
364
|
e.preventDefault();
|
|
324
|
-
let t =
|
|
325
|
-
!n || t.disabled || n.sourceId !==
|
|
365
|
+
let t = J(), n = d();
|
|
366
|
+
!n || t.disabled || n.sourceId !== D && Te(e);
|
|
326
367
|
}
|
|
327
|
-
function
|
|
328
|
-
let t =
|
|
329
|
-
if (!t && !
|
|
330
|
-
|
|
368
|
+
function Oe(e) {
|
|
369
|
+
let t = d();
|
|
370
|
+
if (!t && !L) {
|
|
371
|
+
M.value = null, Z(), Q();
|
|
331
372
|
return;
|
|
332
373
|
}
|
|
333
|
-
let n =
|
|
334
|
-
n.dragHandle && o && (o.draggable = !1),
|
|
374
|
+
let n = J(), r = t?.itemKey ?? j.value, i = r == null ? -1 : Y(r), a = i >= 0 ? G()[i] : t?.item, o = r == null ? null : X(r);
|
|
375
|
+
n.dragHandle && o && (o.draggable = !1), he(), u(), Q(), n.onDragend?.({
|
|
335
376
|
item: a,
|
|
336
377
|
index: i,
|
|
337
378
|
key: r,
|
|
338
379
|
event: e
|
|
339
380
|
});
|
|
340
381
|
}
|
|
341
|
-
function
|
|
342
|
-
|
|
382
|
+
function ke(e) {
|
|
383
|
+
Oe(e);
|
|
343
384
|
}
|
|
344
|
-
function
|
|
345
|
-
|
|
385
|
+
function Ae(e) {
|
|
386
|
+
Oe(e);
|
|
346
387
|
}
|
|
347
|
-
function
|
|
348
|
-
|
|
388
|
+
function je(e) {
|
|
389
|
+
P !== e && (Me(), P = e, e && (e.addEventListener("pointerdown", xe, !0), e.addEventListener("pointerup", $, !0), e.addEventListener("pointercancel", $, !0), e.addEventListener("dragstart", Se), e.addEventListener("dragover", Ee), e.addEventListener("drop", De), e.addEventListener("dragend", ke)));
|
|
349
390
|
}
|
|
350
|
-
function
|
|
351
|
-
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
}, { flush: "post" }), b(() => H().length, () => {
|
|
362
|
-
X();
|
|
363
|
-
}), _(() => {
|
|
364
|
-
K(), be(W()), X();
|
|
365
|
-
}), g(() => {
|
|
366
|
-
L && cancelAnimationFrame(L), $(), xe(), F && p(F), F = null, l()?.sourceId === k && c();
|
|
391
|
+
function Me() {
|
|
392
|
+
P &&= (P.removeEventListener("pointerdown", xe, !0), P.removeEventListener("pointerup", $, !0), P.removeEventListener("pointercancel", $, !0), P.removeEventListener("dragstart", Se), P.removeEventListener("dragover", Ee), P.removeEventListener("drop", De), P.removeEventListener("dragend", ke), null);
|
|
393
|
+
}
|
|
394
|
+
b(() => y(k), (e) => {
|
|
395
|
+
je(e), e && be();
|
|
396
|
+
}, { flush: "post" }), b(() => G().length, () => {
|
|
397
|
+
be();
|
|
398
|
+
}), te(() => {
|
|
399
|
+
de(), je(q()), be();
|
|
400
|
+
}), ee(() => {
|
|
401
|
+
F && cancelAnimationFrame(F), Z(), Q(), Me(), N && h(N), N = null, d()?.sourceId === D && u();
|
|
367
402
|
});
|
|
368
|
-
let
|
|
369
|
-
return b(() => !!
|
|
370
|
-
|
|
403
|
+
let Ne = v(!!le.dragHandle);
|
|
404
|
+
return b(() => !!J().dragHandle, (e) => {
|
|
405
|
+
Ne.value = e;
|
|
371
406
|
}), [
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
407
|
+
k,
|
|
408
|
+
A,
|
|
409
|
+
ue,
|
|
375
410
|
{
|
|
376
|
-
draggingKey:
|
|
377
|
-
armedKey:
|
|
378
|
-
hasDragHandle:
|
|
411
|
+
draggingKey: j,
|
|
412
|
+
armedKey: M,
|
|
413
|
+
hasDragHandle: Ne
|
|
379
414
|
}
|
|
380
415
|
];
|
|
381
416
|
}
|
|
382
417
|
//#endregion
|
|
383
|
-
export { x as KUN_DND_ITEM_ATTR, S as KUN_DND_KEY_ATTR, o as resolveItemKey,
|
|
418
|
+
export { x as KUN_DND_ITEM_ATTR, S as KUN_DND_KEY_ATTR, o as resolveItemKey, ce as useKunDragAndDrop, w as validateDragHandle };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//#region src/components/KunDragAndDrop/src/utils/kunDragAndDropScroll.js
|
|
2
|
+
function e(e) {
|
|
3
|
+
if (!e || e.nodeType !== 1) return !1;
|
|
4
|
+
let t = window.getComputedStyle(e), n = t.overflowY, r = t.overflowX, i = (n === "auto" || n === "scroll" || n === "overlay") && e.scrollHeight > e.clientHeight + 1, a = (r === "auto" || r === "scroll" || r === "overlay") && e.scrollWidth > e.clientWidth + 1;
|
|
5
|
+
return i || a;
|
|
6
|
+
}
|
|
7
|
+
function t(t) {
|
|
8
|
+
let n = t?.nodeType === 1 ? t : t?.parentElement;
|
|
9
|
+
for (; n && n !== document.body && n !== document.documentElement;) {
|
|
10
|
+
if (e(n)) return n;
|
|
11
|
+
n = n.parentElement;
|
|
12
|
+
}
|
|
13
|
+
return document.scrollingElement || document.documentElement || null;
|
|
14
|
+
}
|
|
15
|
+
function n(e, t, n, r = {}) {
|
|
16
|
+
let i = Math.max(0, Number(r.sensitivity ?? 50)), a = Math.max(0, Number(r.speed ?? 12));
|
|
17
|
+
if (!n || a === 0 || i === 0) return {
|
|
18
|
+
dx: 0,
|
|
19
|
+
dy: 0
|
|
20
|
+
};
|
|
21
|
+
let o = n.getBoundingClientRect(), s = 0, c = 0, l = n.scrollHeight - n.clientHeight, u = n.scrollWidth - n.clientWidth;
|
|
22
|
+
if (l > 0) {
|
|
23
|
+
if (t < o.top + i) {
|
|
24
|
+
let e = 1 - Math.max(0, t - o.top) / i;
|
|
25
|
+
c = -Math.ceil(a * e);
|
|
26
|
+
} else if (t > o.bottom - i) {
|
|
27
|
+
let e = 1 - Math.max(0, o.bottom - t) / i;
|
|
28
|
+
c = Math.ceil(a * e);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (u > 0) {
|
|
32
|
+
if (e < o.left + i) {
|
|
33
|
+
let t = 1 - Math.max(0, e - o.left) / i;
|
|
34
|
+
s = -Math.ceil(a * t);
|
|
35
|
+
} else if (e > o.right - i) {
|
|
36
|
+
let t = 1 - Math.max(0, o.right - e) / i;
|
|
37
|
+
s = Math.ceil(a * t);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
dx: s,
|
|
42
|
+
dy: c
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { t as findScrollParent, n as getAutoScrollDelta };
|