fluid-dnd 2.3.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-BNn5KECH.cjs → HandlerPublisher-1MmlNkG3.cjs} +1 -1
- package/dist/{HandlerPublisher-xM3zyGAn.js → HandlerPublisher-DBjPMiyO.js} +1 -1
- package/dist/core/{configHandler.d.ts → config/configHandler.d.ts} +2 -2
- package/dist/core/{configHandler.js → config/configHandler.js} +7 -8
- package/dist/core/{utils → config}/droppableConfigurator.d.ts +5 -4
- package/dist/core/{utils → config}/droppableConfigurator.js +42 -29
- package/dist/core/dragAndDrop.d.ts +3 -3
- package/dist/core/dragAndDrop.js +53 -9
- package/dist/core/events/changeDraggableStyles.d.ts +4 -0
- package/dist/core/events/changeDraggableStyles.js +38 -0
- package/dist/core/events/dragAndDrop/dragAndDrop.d.ts +9 -0
- package/dist/core/events/dragAndDrop/dragAndDrop.js +202 -0
- package/dist/core/{utils/translate/GetTranslateBeforeDropping.d.ts → events/dragAndDrop/getTranslateBeforeDropping.d.ts} +2 -2
- package/dist/core/{utils/translate/GetTranslateBeforeDropping.js → events/dragAndDrop/getTranslateBeforeDropping.js} +33 -41
- package/dist/core/{utils/translate/GetTranslationByDraggingAndEvent.d.ts → events/dragAndDrop/getTranslationByDraggingAndEvent.d.ts} +2 -2
- package/dist/core/{utils/translate/GetTranslationByDraggingAndEvent.js → events/dragAndDrop/getTranslationByDraggingAndEvent.js} +12 -13
- package/dist/core/events/insert.d.ts +5 -0
- package/dist/core/events/insert.js +74 -0
- package/dist/core/events/remove.d.ts +4 -0
- package/dist/core/events/remove.js +66 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.js +7 -0
- package/dist/core/{utils/scroll.d.ts → positioning/autoScroll.d.ts} +0 -2
- package/dist/core/{utils/scroll.js → positioning/autoScroll.js} +6 -9
- package/dist/core/{utils/SetTransform.d.ts → positioning/usePositioning.d.ts} +1 -1
- package/dist/core/{utils/SetTransform.js → positioning/usePositioning.js} +24 -27
- package/dist/core/{utils/tempChildren.d.ts → tempChildren.d.ts} +1 -2
- package/dist/core/{utils/tempChildren.js → tempChildren.js} +44 -47
- package/dist/core/useDraggable.js +50 -57
- 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 +6 -5
- package/dist/core/utils/SetStyles.js +30 -25
- package/dist/core/utils/index.d.ts +5 -1
- package/dist/core/utils/index.js +7 -6
- package/dist/core/utils/observer.d.ts +1 -0
- package/dist/core/utils/observer.js +8 -0
- 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 -37
- package/dist/react/utils/ReactLilstConfig.d.ts +2 -2
- package/dist/react/utils/ReactLilstConfig.js +9 -18
- 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.d.ts +3 -3
- package/dist/vue/utils/VueListCondig.js +4 -6
- package/package.json +1 -1
- package/dist/core/utils/config.d.ts +0 -5
- package/dist/core/utils/config.js +0 -57
- package/dist/core/utils/events/emitEvents.d.ts +0 -11
- package/dist/core/utils/events/emitEvents.js +0 -333
- package/dist/index-BYT3HBbe.cjs +0 -1
- package/dist/index-m7C-XuaH.js +0 -1275
- /package/dist/core/utils/{touchDevice.d.ts → typesCheckers.d.ts} +0 -0
- /package/dist/core/utils/{touchDevice.js → typesCheckers.js} +0 -0
@@ -1,333 +0,0 @@
|
|
1
|
-
import { draggableIsOutside, getParentDraggableChildren, getPropByDirection, getSiblings, getTransform, getWindowScroll, } from "../GetStyles";
|
2
|
-
import { moveTranslate, setCustomFixedSize, setTranistion } from "../SetStyles";
|
3
|
-
import getTranslationByDragging from "../translate/GetTranslationByDraggingAndEvent";
|
4
|
-
import getTranslateBeforeDropping from "../translate/GetTranslateBeforeDropping";
|
5
|
-
import { DRAG_EVENT, draggableTargetTimingFunction, IsDropEvent, START_DRAG_EVENT, START_DROP_EVENT, TEMP_CHILD_CLASS } from "..";
|
6
|
-
import { IsHTMLElement } from "../touchDevice";
|
7
|
-
import { isTempElement, removeTempChild } from "../tempChildren";
|
8
|
-
import { DISABLE_TRANSITION, DRAGGABLE_CLASS, DRAGGING_CLASS, DRAGGING_HANDLER_CLASS, DROPPING_CLASS, GRABBING_CLASS } from "../classes";
|
9
|
-
import { addClass, containClass, getClassesSelector, removeClass, toggleClass } from "../dom/classList";
|
10
|
-
import { observeMutation } from "../observer";
|
11
|
-
const DELAY_TIME_TO_SWAP = 50;
|
12
|
-
export default function useEmitEvents(currentConfig, index, parent, droppableGroupClass, handlerPublisher, endDraggingAction) {
|
13
|
-
let actualIndex = index;
|
14
|
-
const { direction, handlerSelector, onRemoveAtEvent, animationDuration, delayBeforeInsert, draggingClass } = currentConfig;
|
15
|
-
const emitEventToSiblings = (draggedElement, event, initialWindowScroll, droppableConfig, positionOnSourceDroppable) => {
|
16
|
-
if (!droppableConfig) {
|
17
|
-
return;
|
18
|
-
}
|
19
|
-
const { droppable, config } = droppableConfig;
|
20
|
-
const tranlation = getTranslationByDragging(draggedElement, event, config.direction, droppable);
|
21
|
-
const dropping = IsDropEvent(event);
|
22
|
-
if (!dropping) {
|
23
|
-
emitDraggingEventToSiblings(draggedElement, event, tranlation, droppableConfig);
|
24
|
-
}
|
25
|
-
else {
|
26
|
-
emitDroppingEventToSiblings(draggedElement, event, tranlation, initialWindowScroll, droppableConfig, positionOnSourceDroppable);
|
27
|
-
}
|
28
|
-
};
|
29
|
-
// #region Insert
|
30
|
-
const emitInsertEventToSiblings = (targetIndex, draggedElement, droppable, value, startInserting) => {
|
31
|
-
const translation = getTranslationByDragging(draggedElement, 'insert', currentConfig.direction, droppable);
|
32
|
-
const { onInsertEvent } = currentConfig;
|
33
|
-
const siblings = getParentDraggableChildren(droppable);
|
34
|
-
for (const [index, sibling] of siblings.entries()) {
|
35
|
-
if (!containClass(sibling, DRAGGABLE_CLASS)) {
|
36
|
-
continue;
|
37
|
-
}
|
38
|
-
if (index >= targetIndex) {
|
39
|
-
dragEventOverElement(sibling, translation);
|
40
|
-
}
|
41
|
-
}
|
42
|
-
startInserting();
|
43
|
-
setTimeout(() => {
|
44
|
-
onInsertEvent(targetIndex, value);
|
45
|
-
onFinishInsertElement(targetIndex, droppable, currentConfig);
|
46
|
-
removeElementDraggingStyles(draggedElement);
|
47
|
-
removeTranslateFromSiblings(draggedElement, parent);
|
48
|
-
removeTempChild(parent, 0, true);
|
49
|
-
}, delayBeforeInsert);
|
50
|
-
};
|
51
|
-
// #region Remove
|
52
|
-
const emitRemoveEventToSiblings = (targetIndex, draggedElement, droppableConfig, onFinishRemoveEvent) => {
|
53
|
-
if (!droppableConfig ||
|
54
|
-
!droppableConfig.droppable ||
|
55
|
-
!droppableConfig.config) {
|
56
|
-
return;
|
57
|
-
}
|
58
|
-
const { droppable, config } = droppableConfig;
|
59
|
-
let [siblings] = getSiblings(draggedElement, droppable);
|
60
|
-
siblings = [draggedElement, ...siblings].toReversed();
|
61
|
-
const translation = getTranslationByDragging(draggedElement, "remove", config.direction, droppable);
|
62
|
-
for (const [index, sibling] of siblings.entries()) {
|
63
|
-
if (index >= targetIndex) {
|
64
|
-
startDragEventOverElement(sibling, translation);
|
65
|
-
setTimeout(() => {
|
66
|
-
onFinishRemoveEvent(sibling);
|
67
|
-
}, animationDuration);
|
68
|
-
}
|
69
|
-
}
|
70
|
-
};
|
71
|
-
const emitFinishRemoveEventToSiblings = (draggedElement) => {
|
72
|
-
removeTempChild(parent, animationDuration, true);
|
73
|
-
setTimeout(() => {
|
74
|
-
removeElementDraggingStyles(draggedElement);
|
75
|
-
removeTranslateFromSiblings(draggedElement, parent);
|
76
|
-
}, animationDuration);
|
77
|
-
};
|
78
|
-
// #region Drag events
|
79
|
-
const emitDraggingEventToSiblings = (draggedElement, event, translation, droppableConfig) => {
|
80
|
-
const { config, droppable } = droppableConfig;
|
81
|
-
const [siblings] = getSiblings(draggedElement, droppable);
|
82
|
-
const isOutside = draggableIsOutside(draggedElement, droppable);
|
83
|
-
if (siblings.length == 0) {
|
84
|
-
updateActualIndexBaseOnTranslation(translation, 1, config.direction, siblings);
|
85
|
-
}
|
86
|
-
for (const [index, sibling] of siblings.entries()) {
|
87
|
-
if (!containClass(sibling, DRAGGABLE_CLASS)) {
|
88
|
-
continue;
|
89
|
-
}
|
90
|
-
const siblingTransition = canChangeDraggable(config.direction, draggedElement, sibling, translation);
|
91
|
-
if (!isOutside && siblingTransition) {
|
92
|
-
translation = siblingTransition;
|
93
|
-
}
|
94
|
-
else if (!isOutside) {
|
95
|
-
continue;
|
96
|
-
}
|
97
|
-
const siblingRealIndex = siblings.length - index;
|
98
|
-
updateActualIndexBaseOnTranslation(translation, siblingRealIndex, config.direction, siblings);
|
99
|
-
if (event === START_DRAG_EVENT) {
|
100
|
-
startDragEventOverElement(sibling, translation);
|
101
|
-
}
|
102
|
-
else if (event === DRAG_EVENT) {
|
103
|
-
dragEventOverElement(sibling, translation);
|
104
|
-
}
|
105
|
-
}
|
106
|
-
};
|
107
|
-
const canChangeDraggable = (direction, sourceElement, targetElement, translation) => {
|
108
|
-
const { before, distance, axis, getRect } = getPropByDirection(direction);
|
109
|
-
const currentBoundingClientRect = getRect(sourceElement);
|
110
|
-
const targetBoundingClientRect = getRect(targetElement);
|
111
|
-
const currentPosition = currentBoundingClientRect[before];
|
112
|
-
const targetPosition = targetBoundingClientRect[before];
|
113
|
-
const targetSize = targetBoundingClientRect[distance];
|
114
|
-
const targetMiddle = targetPosition + targetSize / 2;
|
115
|
-
const targetTransform = getTransform(targetElement)[axis];
|
116
|
-
const targetMiddleWithoutTransform = targetMiddle - targetTransform;
|
117
|
-
if (currentPosition > targetMiddleWithoutTransform) {
|
118
|
-
return { height: 0, width: 0 };
|
119
|
-
}
|
120
|
-
return translation;
|
121
|
-
};
|
122
|
-
const updateActualIndexBaseOnTranslation = (translation, siblingIndex, direction, siblings) => {
|
123
|
-
const itemsCount = siblings.filter((sibling) => containClass(sibling, DRAGGABLE_CLASS)).length;
|
124
|
-
const { distance } = getPropByDirection(direction);
|
125
|
-
if (translation[distance] == 0) {
|
126
|
-
actualIndex = Math.max(actualIndex, siblingIndex);
|
127
|
-
}
|
128
|
-
else {
|
129
|
-
actualIndex = Math.min(actualIndex, siblingIndex - 1);
|
130
|
-
}
|
131
|
-
actualIndex = Math.min(actualIndex, itemsCount);
|
132
|
-
};
|
133
|
-
const startDragEventOverElement = (element, translation) => {
|
134
|
-
const { width, height } = translation;
|
135
|
-
moveTranslate(element, height, width);
|
136
|
-
};
|
137
|
-
const dragEventOverElement = (element, translation) => {
|
138
|
-
const { width, height } = translation;
|
139
|
-
moveTranslate(element, height, width);
|
140
|
-
setTranistion(element, animationDuration, draggableTargetTimingFunction);
|
141
|
-
};
|
142
|
-
// #region Drop events
|
143
|
-
const emitDroppingEventToSiblings = (draggedElement, event, translation, initialWindowScroll, droppableConfig, positionOnSourceDroppable) => {
|
144
|
-
const { droppable, scroll, config } = droppableConfig;
|
145
|
-
const [siblings, positionOnDroppable] = getSiblings(draggedElement, droppable);
|
146
|
-
const allSiblings = siblings.toReversed();
|
147
|
-
const realPositionOnDroppable = (positionOnDroppable === -1) ? allSiblings.length : positionOnDroppable;
|
148
|
-
allSiblings.splice(realPositionOnDroppable, 0, draggedElement);
|
149
|
-
const [previousElement, nextElement, targetIndex] = getPreviousAndNextElement(draggedElement, positionOnDroppable, allSiblings, droppable);
|
150
|
-
translation = getTranslationByDragging(draggedElement, event, config.direction, parent, previousElement, nextElement);
|
151
|
-
const windowScroll = getWindowScroll();
|
152
|
-
const draggableTranslation = getTranslateBeforeDropping(config.direction, allSiblings, positionOnDroppable, targetIndex, windowScroll, scroll, initialWindowScroll, droppable, draggedElement);
|
153
|
-
if (siblings.length == 0) {
|
154
|
-
startDropEventOverElement(undefined, translation, draggedElement, draggableTranslation);
|
155
|
-
}
|
156
|
-
for (const [index, sibling] of siblings.toReversed().entries()) {
|
157
|
-
let newTranslation = translation;
|
158
|
-
if (targetIndex - 1 >= index) {
|
159
|
-
newTranslation = { height: 0, width: 0 };
|
160
|
-
}
|
161
|
-
if (event === START_DROP_EVENT &&
|
162
|
-
!containClass(sibling, TEMP_CHILD_CLASS)) {
|
163
|
-
startDropEventOverElement(sibling, newTranslation, draggedElement, draggableTranslation);
|
164
|
-
}
|
165
|
-
}
|
166
|
-
dropEventOverElement(targetIndex, draggedElement, config, droppable, positionOnSourceDroppable);
|
167
|
-
};
|
168
|
-
const getPreviousAndNextElement = (draggedElement, elementPosition, allSiblings, droppable) => {
|
169
|
-
const isOutside = draggableIsOutside(draggedElement, droppable);
|
170
|
-
const targetIndex = isOutside ? elementPosition : actualIndex;
|
171
|
-
const getPreviousAndNextElementIndex = () => {
|
172
|
-
if (elementPosition < targetIndex) {
|
173
|
-
return [targetIndex, targetIndex + 1];
|
174
|
-
}
|
175
|
-
else if (elementPosition > targetIndex) {
|
176
|
-
return [targetIndex - 1, targetIndex];
|
177
|
-
}
|
178
|
-
else {
|
179
|
-
return [targetIndex - 1, targetIndex + 1];
|
180
|
-
}
|
181
|
-
};
|
182
|
-
const [previousIndex, nextIndex] = getPreviousAndNextElementIndex();
|
183
|
-
const previousElement = allSiblings[previousIndex] ?? null;
|
184
|
-
const nextElement = allSiblings[nextIndex] ?? null;
|
185
|
-
return [
|
186
|
-
previousElement,
|
187
|
-
nextElement,
|
188
|
-
targetIndex,
|
189
|
-
];
|
190
|
-
};
|
191
|
-
const startDropEventOverElement = (targetElement, translation, element, sourceElementTranlation) => {
|
192
|
-
moveTranslate(targetElement, translation.height, translation.width);
|
193
|
-
moveTranslate(element, sourceElementTranlation.height, sourceElementTranlation.width);
|
194
|
-
};
|
195
|
-
const dropEventOverElement = (targetIndex, element, config, droppable, positionOnSourceDroppable) => {
|
196
|
-
const { onInsertEvent, onDragEnd } = config;
|
197
|
-
addClass(element, DROPPING_CLASS);
|
198
|
-
removeStytes(element, parent, droppable, () => {
|
199
|
-
removeClass(element, DROPPING_CLASS);
|
200
|
-
if (positionOnSourceDroppable != undefined) {
|
201
|
-
const value = onRemoveAtEvent(positionOnSourceDroppable, true);
|
202
|
-
if (value != undefined) {
|
203
|
-
onInsertEvent(targetIndex, value, true);
|
204
|
-
onDragEnd({ value, index: targetIndex });
|
205
|
-
}
|
206
|
-
manageDraggingClass(element);
|
207
|
-
clearExcessTranslateStyles();
|
208
|
-
}
|
209
|
-
});
|
210
|
-
};
|
211
|
-
const clearExcessTranslateStyles = () => {
|
212
|
-
if (!droppableGroupClass) {
|
213
|
-
return;
|
214
|
-
}
|
215
|
-
var children = document.querySelectorAll(`${getClassesSelector(droppableGroupClass)} > .${DRAGGABLE_CLASS}`);
|
216
|
-
for (const element of children) {
|
217
|
-
removeTranslateWhitoutTransition(element);
|
218
|
-
}
|
219
|
-
};
|
220
|
-
const manageDraggingClass = (element) => {
|
221
|
-
setTimeout(() => {
|
222
|
-
removeClass(element, draggingClass);
|
223
|
-
}, DELAY_TIME_TO_SWAP);
|
224
|
-
};
|
225
|
-
const removeStytes = (element, parent, droppable, func) => {
|
226
|
-
setTimeout(() => {
|
227
|
-
func && func();
|
228
|
-
removeTempChildOnDroppables(parent, droppable);
|
229
|
-
reduceTempchildSize(droppable);
|
230
|
-
removeElementDraggingStyles(element);
|
231
|
-
removeTranslateFromSiblings(element, parent);
|
232
|
-
removeTranslateFromSiblings(element, droppable);
|
233
|
-
}, animationDuration);
|
234
|
-
};
|
235
|
-
const removeTempChildOnDroppables = (parent, droppable) => {
|
236
|
-
if (parent.isSameNode(droppable)) {
|
237
|
-
removeTempChild(parent, animationDuration);
|
238
|
-
}
|
239
|
-
else {
|
240
|
-
removeTempChild(parent, animationDuration, true);
|
241
|
-
removeTempChild(droppable, animationDuration);
|
242
|
-
}
|
243
|
-
};
|
244
|
-
const reduceTempchildSize = (droppable) => {
|
245
|
-
if (parent.isSameNode(droppable)) {
|
246
|
-
return;
|
247
|
-
}
|
248
|
-
var [lastChildren] = parent.querySelectorAll(`.${TEMP_CHILD_CLASS}`);
|
249
|
-
if (!lastChildren) {
|
250
|
-
return;
|
251
|
-
}
|
252
|
-
const { distance } = getPropByDirection(direction);
|
253
|
-
if (IsHTMLElement(lastChildren)) {
|
254
|
-
lastChildren.style[distance] = "0px";
|
255
|
-
}
|
256
|
-
};
|
257
|
-
const removeTranslateFromSiblings = (element, parent) => {
|
258
|
-
const [siblings] = getSiblings(element, parent);
|
259
|
-
for (const sibling of [...siblings, element]) {
|
260
|
-
removeTranslateWhitoutTransition(sibling);
|
261
|
-
}
|
262
|
-
};
|
263
|
-
const removeTranslateWhitoutTransition = (element) => {
|
264
|
-
if (IsHTMLElement(element)) {
|
265
|
-
element.style.transition = "";
|
266
|
-
element.style.transform = "";
|
267
|
-
}
|
268
|
-
};
|
269
|
-
const removeElementDraggingStyles = (element) => {
|
270
|
-
endDraggingAction();
|
271
|
-
toggleDraggingClass(element, false);
|
272
|
-
element.style.transform = "";
|
273
|
-
element.style.transition = "";
|
274
|
-
element.style.top = "";
|
275
|
-
element.style.left = "";
|
276
|
-
setCustomFixedSize(element, {
|
277
|
-
fixedHeight: '',
|
278
|
-
fixedWidth: ''
|
279
|
-
});
|
280
|
-
};
|
281
|
-
const toogleHandlerDraggingClass = (force, element) => {
|
282
|
-
const handlerElement = element.querySelector(handlerSelector);
|
283
|
-
toggleClass(document.body, GRABBING_CLASS, force);
|
284
|
-
if (handlerElement) {
|
285
|
-
toggleClass(handlerElement, DRAGGING_HANDLER_CLASS, force);
|
286
|
-
}
|
287
|
-
else {
|
288
|
-
toggleClass(element, DRAGGING_HANDLER_CLASS, force);
|
289
|
-
}
|
290
|
-
};
|
291
|
-
const toggleDraggingClass = (element, force) => {
|
292
|
-
toggleClass(element, DRAGGING_CLASS, force);
|
293
|
-
toogleHandlerDraggingClass(force, element);
|
294
|
-
handlerPublisher.toggleGrabClass(!force);
|
295
|
-
};
|
296
|
-
return [
|
297
|
-
emitEventToSiblings,
|
298
|
-
emitRemoveEventToSiblings,
|
299
|
-
emitInsertEventToSiblings,
|
300
|
-
emitFinishRemoveEventToSiblings,
|
301
|
-
toggleDraggingClass,
|
302
|
-
];
|
303
|
-
}
|
304
|
-
const childrenMutationFilter = (mutation) => {
|
305
|
-
const addedNodes = mutation.addedNodes.values().filter((element) => !isTempElement(element)).toArray();
|
306
|
-
return addedNodes.length > 0;
|
307
|
-
};
|
308
|
-
const onFinishInsertElement = (targetIndex, droppable, config) => {
|
309
|
-
const { insertingFromClass, animationDuration } = config;
|
310
|
-
const observer = observeMutation(() => {
|
311
|
-
const siblings = getParentDraggableChildren(droppable);
|
312
|
-
const newElement = siblings[targetIndex];
|
313
|
-
addClass(newElement, insertingFromClass);
|
314
|
-
addClass(newElement, DISABLE_TRANSITION);
|
315
|
-
setTimeout(() => {
|
316
|
-
removeClass(newElement, DISABLE_TRANSITION);
|
317
|
-
removeClass(newElement, insertingFromClass);
|
318
|
-
observer.disconnect();
|
319
|
-
}, animationDuration);
|
320
|
-
}, droppable, {
|
321
|
-
childList: true,
|
322
|
-
}, childrenMutationFilter);
|
323
|
-
};
|
324
|
-
export const insertToListEmpty = (config, droppable, targetIndex, value) => {
|
325
|
-
if (!droppable) {
|
326
|
-
return;
|
327
|
-
}
|
328
|
-
const { onInsertEvent, delayBeforeInsert } = config;
|
329
|
-
setTimeout(() => {
|
330
|
-
onInsertEvent(targetIndex, value);
|
331
|
-
onFinishInsertElement(targetIndex, droppable, config);
|
332
|
-
}, delayBeforeInsert);
|
333
|
-
};
|
package/dist/index-BYT3HBbe.cjs
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";var Me=Object.defineProperty;var Be=(e,t,n)=>t in e?Me(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var V=(e,t,n)=>Be(e,typeof t!="symbol"?t+"":t,n);const _="horizontal",J="vertical",Z="draggable",Xt="droppable",Lt="handler-class",Ft="dragging",Wt="dragging-handler-class",_t="dropping",oe="grabbing",re="grab",Kt="disable-transition",we=(e,t)=>{const n=(c,f)=>e.removeAtEvent(c,f),s=(c,f,p)=>e.insertEvent(c,f,p),o=()=>e.getLength(),r=c=>e.getValue(c),a=c=>c;return{direction:(t==null?void 0:t.direction)??J,handlerSelector:(t==null?void 0:t.handlerSelector)??Z,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)??[c=>c]}},Re=(e,t)=>{const{config:n,droppable:s}=e,{onInsertEvent:o,onDragEnd:r}=n;return{...n,onDragEnd:f=>{const{index:p,value:S}=f;r({index:p,value:t(S,s)})},onInsertEvent:(f,p)=>o(f,t(p,s),!0)}},tt=(e,t)=>e.classList.contains(t),gt=(e,t,n=!1)=>{e.classList.toggle(t,n)},k=(e,t)=>{e.classList.add(t)},At=(e,t)=>{e.classList.remove(t)},Le=(e,t)=>Mt(t).every(n=>tt(e,n)),pt=e=>e?`.${Mt(e).join(".")}`:"",Oe=(e,t)=>{if(!t)return;const n=Mt(t);e.classList.add(...n)},Mt=e=>e?e.split(" ").filter(t=>t):[],Ne=()=>{const{scrollX:e,scrollY:t}=window;return{scrollX:e,scrollY:t}},zt=e=>!e||e.trim().length==0||e=="normal"?0:parseFloat(e),Fe=e=>e?parseInt(e):-1,Pe=e=>{const t=getComputedStyle(e),n=new DOMMatrixReadOnly(t.transform);return{x:n.m41,y:n.m42}},ie=(e,t)=>e.x1>t.x1?ie(t,e):e.x2<t.x1?0:e.x2>=t.x2?e.x2-e.x1:e.x2-t.x1,xt=(e,t)=>!$e(e,t),$e=(e,t)=>{const{intersectionX:n,intersectionY:s,rect1:o,rect2:r}=ce(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}=ce(e,t);return s>=0&&n>=0},ce=(e,t)=>{const n=Ot(e),s=Ot(t),o=Qt(n,s,J),r=Qt(n,s,_);return{rect1:n,rect2:s,intersectionX:r,intersectionY:o}},Qt=(e,t,n)=>{const{before:s,distance:o}=L(n);return ie({x1:e[s],x2:e[s]+e[o]},{x1:t[s],x2:t[s]+t[o]})},O=(e,t)=>e?zt(getComputedStyle(e)[t]):0,Ut=e=>{const{scrollLeft:t,scrollTop:n}=e;return{scrollLeft:t,scrollTop:n}},Ot=e=>e.getBoundingClientRect(),L=e=>{const t=e==_;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:Ot}},wt=(e,t)=>Ye(e,t),ae=e=>[...e.children].filter(n=>tt(n,Z)),Ye=(e,t)=>{const n=[...t.children].filter(o=>tt(o,Z)&&!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},le=(e,t)=>{const{before:n,borderBeforeWidth:s}=L(t),o=Xe(e);return o?Ot(o)[n]+O(o,s):0},yt=e=>window.TouchEvent&&e instanceof TouchEvent,st=e=>e instanceof HTMLElement,ue=e=>e instanceof MouseEvent,We=["onmouseup","onmousedown","onmousemove"],_e=(e,t,n)=>{e&&(e.style.height=`${t}px`,e.style.width=`${n}px`)},Et=(e,t,n)=>{!e||!st(e)||(n==0&&t==0?e.style.transform="":e.style.transform=`translate(${n}px,${t}px)`)},Ve=(e,t,n,s)=>{e[t]=o=>{if(o.defaultPrevented)return;s&&s(o);const r=Vt(o);n(r)}},It=(e,t,n,s)=>{n&&(He(t)?e[t]=n:Ve(e,t,n,s))},He=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(ue(e)){const{offsetX:s,offsetY:o}=e;return[s,o]}else{const s=e.target;return[n(s,_),n(s,J)]}},Vt=e=>{const t=je(e);if(!t)return qe(e);const[n,s]=ze(e,t),{clientX:o,clientY:r,pageX:a,pageY:c,screenX:f,screenY:p,target:S}=t;return{clientX:o,clientY:r,pageX:a,pageY:c,screenX:f,screenY:p,target:S,offsetX:n,offsetY:s}},je=e=>{if(yt(e))return e.touches[0]??e.changedTouches[0];if(ue(e))return e},Ze=(e,t,n,s)=>{const{page:o,scroll:r,before:a,borderBeforeWidth:c,getRect:f}=L(n),p=f(s);return e[o]-t[r]-p[a]-O(s,c)},Pt=(e,t,n="ease-out",s="transform")=>{st(e)&&(e.style.transitionDuration=`${t}ms`,e.style.transitionTimingFunction=`${n}`,e.style.transitionProperty=`${s}`)},fe=(e,t,n)=>{!e||!st(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))},de=(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,t,n)=>{const{scrollDistance:s,clientDistance:o,scrollElement:r}=L(e);return n[r]/(t[s]-t[o])},nn=e=>{let t=.5;const n=.03,s=(a,c,f,p)=>{const{before:S,distance:m,axis:x,getRect:R}=L(a),w=R(e)[m],N=R(c),D=f[S]-N[S]+p[x],v=N[m]-w,C=D/v,P=w/v,$=.25,G=.2,H=.8;let W=0;const I=Ge(e,c);!I&&C<G&&C>-P?W=o(C<0?0:C,G):!I&&C>H&&C<1+P&&(W=r(C,H));const Y=$*w*W;t=Math.sign(Y)*Math.min(Math.abs(Y),Math.abs(t)+n),tn(c,a,t)},o=(a,c)=>Math.pow(a/c,1/3)-1,r=(a,c)=>Math.pow(1/(1-c)*(a-c),3);return[s]},sn=(e,t)=>{let n={offsetX:0,offsetY:0},s={top:0,left:0},o={x:0,y:0};const[r]=nn(e),a=m=>{e.style.transform=`translate( ${m.x}px, ${m.y}px)`},c=m=>{e.style.top=`${m.top}px`,e.style.left=`${m.left}px`},f=(m,x,R,w)=>{const N=v=>{const{beforeMargin:C,borderBeforeWidth:P,before:$,offset:G,scroll:H,page:W,inner:I,distance:Y,axis:ot,getRect:rt}=L(v),et=R[W],K=window[H],Q=window[I],q=rt(m)[Y],U=O(m,P),it=O(m,C),nt=et-n[G],l=le(m,v);if(nt>=K-q/2&&nt<=K+Q){const d=nt-s[$]-U-it-K-l;return D(v),d}return o[ot]},D=v=>{m&&tt(m,Ft)&&v===w&&r(w,x,s,o)},E=v=>{const{axis:C}=L(v);o[C]=N(v),a(p())};E(_),E(J)},p=()=>{let m=o;for(const x of t)m=x(m,e);return m};return[f,(m,x)=>{const[R,w,N,D]=cn(m,x,e);s={top:R,left:w},c(s),n={offsetX:N,offsetY:D}}]},Rt=(e,t,n)=>{const{borderBeforeWidth:s,before:o,getRect:r}=L(e);return r(t)[o]-r(n)[o]-O(n,s)},on=(e,t)=>{let{offsetX:n,offsetY:s,target:o}=e,r=rn(o,t);const a=o;return a&&r&&!a.isSameNode(r)&&(n+=Rt(_,a,r),s+=Rt(J,a,r)),r&&t!=o&&(n+=Rt(_,r,t),s+=Rt(J,r,t)),[n,s]},rn=(e,t)=>{const n=e==null?void 0:e.closest(`.${Lt}`);return n&&n.isSameNode(t)?e:n},te=(e,t,n,s)=>{const{offset:o,beforeMargin:r,page:a,borderBeforeWidth:c,scroll:f}=L(e),p=le(n,e);return t[a]-s[o]-O(n,r)-O(n,c)-window[f]-p},cn=(e,t,n)=>{const[s,o]=on(e,n);return[te(J,e,t,{offsetX:s,offsetY:o}),te(_,e,t,{offsetX:s,offsetY:o}),s,o]},ge="startDrag",Nt="drag",jt="startDrop",an="drop",lt="temp-child",pe="cubic-bezier(0.2, 0, 0, 1)",ln=e=>e===an||e===jt,Ht=e=>!e||e.length==0?0:zt(e.replace("px","")),un=(e,t)=>{const n=getComputedStyle(e)[t];if(n.match("%")){const o=zt(n.replace("%","")),{width:r}=e.getBoundingClientRect();return r*(o/100)}return Ht(n)},Zt=(e,t)=>{if(!(e instanceof Element))return[0,!1];const n=un(e,t),s=getComputedStyle(e).display,o=n>0||s==="flex";return[n,o]},fn=e=>{const{top:t,left:n}=getComputedStyle(e);return[Ht(t),Ht(n)]},dn=(e,t)=>{const{gap:n}=L(t),[s,o]=Zt(e,n);return o?s:0};function Ct(e,t,n,s,o=e.previousElementSibling,r=e.nextElementSibling){let{height:a,width:c}=gn(n,e,o,r);return xt(e,s)&&t==Nt&&(a=0,c=0),{height:a,width:c}}const gn=(e,t,n,s)=>{const{afterMargin:o,beforeMargin:r,distance:a,gap:c,getRect:f}=L(e),p=O(t,o),S=O(t,r),m=O(s,r),[x,R]=Zt(t.parentElement,c),w=f(t)[a];if(R)return ee(w,S,p,x,0,e);const[N,D,E]=pn(n,m,p,S,o);return ee(w,D,N,0,E,e)},pn=(e,t,n,s,o)=>{const r=Math.max(t,n);let a=s,c=t;if(e){const f=O(e,o);a=Math.max(f,s),c=Math.max(c,f)}return[r,a,c]},ee=(e,t,n,s,o,r)=>hn(r,e+t+n+s-o),hn=(e,t)=>e==_?{width:t,height:0}:{width:0,height:t},ne=(e,t)=>{const{borderBeforeWidth:n,paddingBefore:s,axis:o,getRect:r}=L(e),a=O(t,n),c=O(t,s),f=r(t)[o];return a+c+f},mn=(e,t)=>{const[n,s]=fn(t),o=ne(J,e);return[ne(_,e)-s,o-n]};function Sn(e,t,n,s,o,r,a,c,f){let p=0,S=0;const m=!!(n<0&&f);if(n===s&&!m)return se({height:p,width:S},e,o,a,m);const[x,R,w,N]=Tn(t,n,s,f);if(m){const[U,it]=mn(c,f);p+=it,S+=U}const{scrollElement:D,beforeMargin:E,afterMargin:v,distance:C,gap:P}=L(e),[$,G]=Zt(c,P),[H,W,I]=yn(E,v,x,R==null?void 0:R.previousElementSibling,N,G,m),[Y,ot,rt]=bn(E,v,C,w,$,G),et=Dn(ot,Y,rt,W,H,$),K=m?c[D]:vn(D,c,r),q=(N?et-I:I-et)-K;return e===J?p+=q:e===_&&(S+=q),se({height:p,width:S},e,o,a,m)}const vn=(e,t,n)=>{const s=t[e],o=n[e];return s-o},Dn=(e,t,n,s,o,r)=>{const a=Math.max(t,o);return Math.max(n,s)+e+a+r},Tn=(e,t,n,s)=>{const o=t<n,[r,a]=[t,n].toSorted((S,m)=>S-m),c=e[t]??s,f=e[n];let p=o?e.slice(r+1,a+1):e.slice(r,a);return r<0&&s&&(p=e.slice(r+1,a)),[c,f,p,o]},bn=(e,t,n,s,o,r)=>{if(s.length==0)return[0,0,0];const a=O(s[0],e);let c=0,f=-a;for(const[p,S]of s.entries()){const m=S.getBoundingClientRect()[n],x=O(S,e);r&&(c+=x),r&&p>0?c+=o:c=Math.max(c,x),f+=c+m,c=O(S,t)}return[a,f,c]},se=(e,t,n,s,o)=>{const{scroll:r,distance:a}=L(t),c=window[r],f=n[r],p=o?0:f-2*c+s[r];return e[a]+=p,e},yn=(e,t,n,s,o,r,a)=>{const c=o?n.previousElementSibling:s;return En(e,t,c,n,r,a)},En=(e,t,n,s,o,r)=>{if(o)return[0,0,0];const a=O(r?null:n,t),c=O(s,e);let f=Math.max(a,c);return[a,c,f]},kt=(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},Cn="startDrag",he="cubic-bezier(0.2, 0, 0, 1)",me=50,qt=e=>st(e)?e.classList.contains(lt):!1,An=(e,t,n)=>{let s=Ct(t,Cn,n,e);const o=dn(e,n),{distance:r}=L(n);s[r]-=o;const[a,c]=xn(n,t);return s[c]=a,s},xn=(e,t)=>{const n=e==_?J:_,{distance:s,getRect:o}=L(n);return[o(t)[s],s]},ht=(e,t,n)=>{_e(e,t,n),e.style.minWidth=`${n}px`},Mn=(e,t,n)=>s=>{t.contains(e)&&(ht(e,n.height,n.width),s.disconnect())},Bn=(e,t)=>{if(!t)return;const{droppable:n,config:s,scroll:o}=e,{direction:r}=s,a=en(s.direction,n,o)>.99,{scrollDistance:c,clientDistance:f,scrollElement:p}=L(r);a&&(n[p]=n[c]-n[f])},Se=(e,t,n,s)=>{if(!n)return;const{droppable:o,config:r}=n,{direction:a,animationDuration:c}=r;if(Bn(n,t),o.querySelector(`.${lt}`)||!e)return;var f=e.tagName=="LI"?"DIV":e.tagName,p=document.createElement(f);k(p,lt),ht(p,0,0);const S=An(o,e,a);return Pt(p,c,he,"width, min-width, height"),[p,S,o]},Yt=(e,t,n,s,o)=>{const r=Se(e,n,s);if(!r)return;const[a,c,f]=r;t.isSameNode(f)&&ht(a,c.height,c.width),kt(Mn(a,f,c),f,{childList:!0,subtree:!0}),f.appendChild(a)},wn=(e,t,n)=>{const s=Se(e,t,n);if(!s)return;const[o,r,a]=s;a.appendChild(o),Rn(o,r)},Rn=(e,t)=>requestAnimationFrame(()=>{ht(e,t.height,t.width),requestAnimationFrame(()=>{Pt(e,0,he,"width, min-width, height")})}),Ln=(e,t,n,s,o=!0)=>{if(n){var r=document.querySelectorAll(`${pt(n)} > .${lt}`);r.forEach(a=>{const c=a.parentElement;if(c!=null&&c.isSameNode(t)||!o&&(c!=null&&c.isSameNode(e)))return;ht(a,0,0),setTimeout(()=>{var p;(p=a.parentNode)==null||p.removeChild(a)},s+me)})}},bt=(e,t,n=!1)=>{var s=e.querySelectorAll(`.${lt}`);s.forEach(o=>{const r=o;n?(ht(r,0,0),setTimeout(()=>{e.contains(r)&&e.removeChild(r)},t+me)):e.removeChild(o)})},On=50;function Nn(e,t,n,s,o,r){let a=t;const{direction:c,handlerSelector:f,onRemoveAtEvent:p,animationDuration:S,delayBeforeInsert:m,draggingClass:x}=e,R=(l,u,d,T,h)=>{if(!T)return;const{droppable:y,config:A}=T,M=Ct(l,u,A.direction,y);ln(u)?G(l,u,M,d,T,h):E(l,u,M,T)},w=(l,u,d,T,h)=>{const y=Ct(u,"insert",e.direction,d),{onInsertEvent:A}=e,M=ae(d);for(const[F,B]of M.entries())tt(B,Z)&&F>=l&&$(B,y);h(),setTimeout(()=>{A(l,T),ve(l,d,e),U(u),Q(u,n),bt(n,0,!0)},m)},N=(l,u,d,T)=>{if(!d||!d.droppable||!d.config)return;const{droppable:h,config:y}=d;let[A]=wt(u,h);A=[u,...A].toReversed();const M=Ct(u,"remove",y.direction,h);for(const[F,B]of A.entries())F>=l&&(P(B,M),setTimeout(()=>{T(B)},S))},D=l=>{bt(n,S,!0),setTimeout(()=>{U(l),Q(l,n)},S)},E=(l,u,d,T)=>{const{config:h,droppable:y}=T,[A]=wt(l,y),M=xt(l,y);A.length==0&&C(d,1,h.direction,A);for(const[F,B]of A.entries()){if(!tt(B,Z))continue;const X=v(h.direction,l,B,d);if(!M&&X)d=X;else if(!M)continue;const z=A.length-F;C(d,z,h.direction,A),u===ge?P(B,d):u===Nt&&$(B,d)}},v=(l,u,d,T)=>{const{before:h,distance:y,axis:A,getRect:M}=L(l),F=M(u),B=M(d),X=F[h],z=B[h],mt=B[y],St=z+mt/2,ft=Pe(d)[A],ct=St-ft;return X>ct?{height:0,width:0}:T},C=(l,u,d,T)=>{const h=T.filter(A=>tt(A,Z)).length,{distance:y}=L(d);l[y]==0?a=Math.max(a,u):a=Math.min(a,u-1),a=Math.min(a,h)},P=(l,u)=>{const{width:d,height:T}=u;Et(l,T,d)},$=(l,u)=>{const{width:d,height:T}=u;Et(l,T,d),Pt(l,S,pe)},G=(l,u,d,T,h,y)=>{const{droppable:A,scroll:M,config:F}=h,[B,X]=wt(l,A),z=B.toReversed(),mt=X===-1?z.length:X;z.splice(mt,0,l);const[St,ft,ct]=H(l,X,z,A);d=Ct(l,u,F.direction,n,St,ft);const $t=Ne(),vt=Sn(F.direction,z,X,ct,$t,M,T,A,l);B.length==0&&W(void 0,d,l,vt);for(const[Gt,Dt]of B.toReversed().entries()){let Bt=d;ct-1>=Gt&&(Bt={height:0,width:0}),u===jt&&!tt(Dt,lt)&&W(Dt,Bt,l,vt)}I(ct,l,F,A,y)},H=(l,u,d,T)=>{const y=xt(l,T)?u:a,A=()=>u<y?[y,y+1]:u>y?[y-1,y]:[y-1,y+1],[M,F]=A(),B=d[M]??null,X=d[F]??null;return[B,X,y]},W=(l,u,d,T)=>{Et(l,u.height,u.width),Et(d,T.height,T.width)},I=(l,u,d,T,h)=>{const{onInsertEvent:y,onDragEnd:A}=d;k(u,_t),rt(u,n,T,()=>{if(At(u,_t),h!=null){const M=p(h,!0);M!=null&&(y(l,M,!0),A({value:M,index:l})),ot(u),Y()}})},Y=()=>{if(s){var l=document.querySelectorAll(`${pt(s)} > .${Z}`);for(const u of l)q(u)}},ot=l=>{setTimeout(()=>{At(l,x)},On)},rt=(l,u,d,T)=>{setTimeout(()=>{T&&T(),et(u,d),K(d),U(l),Q(l,u),Q(l,d)},S)},et=(l,u)=>{l.isSameNode(u)?bt(l,S):(bt(l,S,!0),bt(u,S))},K=l=>{if(n.isSameNode(l))return;var[u]=n.querySelectorAll(`.${lt}`);if(!u)return;const{distance:d}=L(c);st(u)&&(u.style[d]="0px")},Q=(l,u)=>{const[d]=wt(l,u);for(const T of[...d,l])q(T)},q=l=>{st(l)&&(l.style.transition="",l.style.transform="")},U=l=>{r(),nt(l,!1),l.style.transform="",l.style.transition="",l.style.top="",l.style.left="",de(l,{fixedHeight:"",fixedWidth:""})},it=(l,u)=>{const d=u.querySelector(f);gt(document.body,oe,l),gt(d||u,Wt,l)},nt=(l,u)=>{gt(l,Ft,u),it(u,l),o.toggleGrabClass(!u)};return[R,N,w,D,nt]}const Fn=e=>e.addedNodes.values().filter(n=>!qt(n)).toArray().length>0,ve=(e,t,n)=>{const{insertingFromClass:s,animationDuration:o}=n,r=kt(()=>{const c=ae(t)[e];k(c,s),k(c,Kt),setTimeout(()=>{At(c,Kt),At(c,s),r.disconnect()},o)},t,{childList:!0},Fn)},Pn=(e,t,n,s)=>{if(!t)return;const{onInsertEvent:o,delayBeforeInsert:r}=e;setTimeout(()=>{o(n,s),ve(n,t,e)},r)},j=class j{static addConfig(t,n){const s=j.configs.filter(r=>!r.droppable.isSameNode(t)),o=Ut(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&&Le(o,n)||o.isSameNode(t))&&(s.scroll=Ut(o))}}static getConfig(t){return j.configs.find(({droppable:s})=>s.isSameNode(t))}};V(j,"configs",[]),V(j,"removeObsoleteConfigs",()=>{const t=j.configs.filter(({droppable:n})=>document.contains(n));j.configs=t});let ut=j;class $n{constructor(t,n,s,o,r,a){V(this,"initial");V(this,"current");V(this,"parent");V(this,"draggableElement");V(this,"groupClass");V(this,"dragEvent");V(this,"changeDroppable");V(this,"mapFrom");this.parent=s,this.draggableElement=t,this.groupClass=n,this.dragEvent=o,this.mapFrom=a,this.initial=s?ut.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[c]=a.getDraggableAncestor(n.clientX,n.clientY,t);return c};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(pt(this.groupClass))}isOutsideOfAllDroppables(t){return(this.groupClass?Array.from(document.querySelectorAll(pt(this.groupClass))):[this.parent]).every(s=>xt(t,s))}isNotInsideAnotherDroppable(t,n){return!xt(t,n)||this.isOutsideOfAllDroppables(t)}onScrollEvent(){this.dragEvent()}setOnScroll(t){fe(t,"onscroll",()=>{this.onScrollEvent()})}getConfigFrom(t){const n=ut.getConfig(t);if(n)return t.isSameNode(this.parent)?n:{...n,config:Re(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?(st(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)}}function Gn(e,t,n,s,o){const{handlerSelector:r,isDraggable:a,droppableGroup:c,animationDuration:f,delayBeforeRemove:p,draggingClass:S,removingClass:m,onRemoveAtEvent:x,droppableClass:R,onDragStart:w,delayBeforeTouchMoveEvent:N,coordinateTransform:D}=n,E=Mt(c).map(i=>`droppable-group-${i}`).join(" ");let v=0,C={scrollX:0,scrollY:0},P={pageX:0,pageY:0},$,G;const[H,W]=sn(e,D),I=()=>{v=0},[Y,ot,rt,et,K]=Nn(n,t,s,E,o,I),Q=()=>{k(e,Z)},q=i=>{k(i,Lt),o.addSubscriber(i)},U=()=>{if(a(e)){const i=e.querySelector(r);q(i||e)}},it=()=>{U(),Q()},nt=i=>{const g=i==null?void 0:i.querySelector(`.${Lt}`),b=g==null?void 0:g.parentElement;return g&&b&&tt(b,Xt)&&!b.isSameNode(s)?null:g},l=i=>{const g=nt(i)??i;g&&a(i)&&(It(g,"onmousedown",ft("mousemove","mouseup")),It(g,"ontouchstart",ft("touchmove","touchend"),b=>{G={x:b.touches[0].clientX,y:b.touches[0].clientY}}),u(g)),i!=null&&i.isSameNode(g)||It(i,"onmousedown",ct),k(s,Xt)},u=i=>{const g=i.querySelectorAll("img");Array.from(g).forEach(b=>{b.onmousedown=()=>!1})},d=()=>{if(P.pageX==0&&P.pageY==0||!h.current)return;const{droppable:i,config:g}=h.current;H(e,i,P,g.direction),Y(e,Nt,C,h.current)},T=(i,g)=>{g&&v==2&&!(i!=null&&i.droppable.isSameNode(g.droppable))&&Y(e,Nt,C,g)},h=new $n(e,E,s,d,T,n.mapFrom),y=i=>{if(!h.current)return;const g=E?Array.from(document.querySelectorAll(pt(E))):[s];for(const b of g)b.classList.toggle(R,!i&&b.isSameNode(h.current.droppable))},A=(i,g=!1)=>{h.updateConfig(i);const b=h.isOutside(i);y(b),v===1&&!g?Dt(i):v===2&&(M(b),De(i))},M=(i=!0)=>{if(!h.current)return;const{droppable:g}=h.current;Ln(g,s,E,f,i),!i&&Yt(e,s,v==1,h.current)},F=i=>{if(yt(i)&&G&&v==1){const g=Math.abs(i.touches[0].clientX-G.x),b=Math.abs(i.touches[0].clientY-G.y);if(Math.abs(g)>5&&Math.abs(b)>5)return clearTimeout($),!1}return!0},B=i=>{clearTimeout($);const g=Vt(i);if(yt(i)&&i.cancelable&&v==2&&i.preventDefault(),yt(i)&&!i.cancelable||!F(i)){vt("touchmove",i);return}A(g,yt(i))},X=(i,g)=>{i=="touchmove"?$=setTimeout(()=>{g()},N):g()},z=(i,g)=>{const{clientX:b,clientY:dt}=i,at=document.elementFromPoint(b,dt),Tt=at==null?void 0:at.closest(`.${Z}`);return Tt&&g.isSameNode(Tt)},mt=i=>{const g=n.onGetValue(t);return{index:t,element:i,value:g}},St=i=>{h.updateConfig(i),y(h.isOutside(i)),Dt(i)},ft=(i,g)=>b=>{if(!z(b,e))return;ut.updateScrolls(s,E);const{scrollX:dt,scrollY:at}=window;if(C={scrollX:dt,scrollY:at},v===0){v=1;const Tt=mt(e);Tt&&w(Tt),X(i,()=>{i=="touchmove"&&St(b)}),document.addEventListener(i,B,{passive:!1}),Te(s),document.addEventListener(g,$t(i),{once:!0})}},ct=i=>h.updateConfig(i),$t=i=>g=>{vt(i,g)},vt=(i,g)=>{y(!0);const b=Vt(g);ye(h.isOutside(b,!1)),clearTimeout($),document.removeEventListener(i,B),h.updateConfig(b);const dt=h.getCurrentConfig(b);if(dt){const{droppable:at}=dt;Gt(at)}s.onscroll=null,I()},Gt=i=>{if(i.onscroll=null,!E)return;const g=Array.from(document.querySelectorAll(pt(E)));for(const b of g)st(b)&&(b.onscroll=null)},Dt=i=>{Yt(e,s,v==1,h.current),Bt(),Y(e,ge,C,h.current),Ee(e),W(i,e)},Bt=()=>{v=2},De=i=>{const{pageX:g,pageY:b}=i;P={pageX:g,pageY:b},d()},Te=i=>fe(i,"onscroll",be),be=()=>d(),ye=i=>{if(v!==2&&v!==1){I();return}v=3,Jt(e),e.classList.contains(Ft)&&Y(e,jt,C,i?h.initial:h.current,t)},Jt=i=>{Pt(i,f,pe),Et(i,0,0)},Ee=i=>{const{height:g,width:b}=i.getBoundingClientRect();de(i,{fixedHeight:`${g}px`,fixedWidth:`${b}px`}),K(i,!0),gt(i,S,!0),i.style.transition=""},Ce=(i,g)=>{At(e,m),Yt(e,s,v==1,h.initial),ot(i,e,g,b=>{Jt(b),et(e)}),x(t,!0)},Ae=i=>{if(!h.initial)return;const g=h.initial;i==t&&(k(e,m),setTimeout(()=>{Ce(i,g)},p))},xe=(i,g)=>{(i===t||i===n.onGetLegth()&&t===i-1)&&rt(i,e,s,g,()=>{wn(e,v==1,h.initial)})};return it(),l(e),[Ae,xe]}const In=(e,t)=>{e&&Oe(t,e)},Yn=()=>{Ke(document.body,[`.${Z}{touch-action:manipulation;user-select:none;box-sizing:border-box!important;-webkit-user-select:none;}`,`.${Lt}{pointer-events:auto!important;}`,`.${re}{cursor:grab;}`,".temp-child{touch-action:none;pointer-events:none;box-sizing:border-box!important;}",".droppable{box-sizing:border-box!important;}",`.${Ft}{position:fixed;z-index:5000;width:var(--fixedWidth)!important;height:var(--fixedHeight)!important;}`,`.${Wt}{pointer-events:none!important;}`,`.${_t}{pointer-events:none!important;}`,`.${oe}{cursor:grabbing;}`,".disable-transition{transition:none!important;}"])};function Xn(e,t,n,s="index"){const o=s;let r=[],a=[];const{droppableGroup:c}=e;if(!n)return[r,a];const f=Mt(c).map(p=>`droppable-group-${p}`).join(" ");Yn(),In(f,n);for(const p of n.children){const S=p.getAttribute(o),m=Fe(S),x=p;if(x&&m>=0){const[R,w]=Gn(x,m,e,n,t);r.push(R),a.push(w)}}return[r,a]}function Wn(e,t,n,s="index"){let o=[],r=[],a;const c=we(e,n),f=D=>{for(const E of o)E(D)},p=(D,E)=>{if(c.onGetLegth()===0)e.insertToListEmpty(c,D,E);else for(const C of r)C(D,E)},S=D=>{const[E,v]=Xn(c,t,D,s);o=E,r=v},m=D=>{const E=D.addedNodes.values().filter(C=>!qt(C)).toArray(),v=D.removedNodes.values().filter(C=>!qt(C)).toArray();return E.length>0||v.length>0},x=D=>{a=kt(()=>{S(D)},D,{childList:!0},m)},R=D=>{k(D,Xt)},w=D=>{ut.addConfig(D,c)};return[f,p,D=>{if(D)return R(D),w(D),x(D),S(D),ut.removeObsoleteConfigs(),a}]}exports.GRAB_CLASS=re;exports.addClass=k;exports.dragAndDrop=Wn;exports.insertToListEmpty=Pn;exports.toggleClass=gt;
|