fluid-dnd 2.5.1 → 2.6.1
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/dist/{HandlerPublisher-CRu7xI9p.js → HandlerPublisher-CGKPF_jz.js} +1 -1
- package/dist/{HandlerPublisher-CrUNmzg-.cjs → HandlerPublisher-DBjTX_j6.cjs} +1 -1
- package/dist/core/dragAndDrop.js +4 -3
- package/dist/core/events/dragAndDrop/dragAndDrop.js +8 -1
- package/dist/core/events/insert.js +1 -1
- package/dist/core/index.d.ts +16 -0
- package/dist/core/positioning/usePositioning.js +3 -3
- package/dist/core/utils/GetStyles.d.ts +1 -1
- package/dist/core/utils/GetStyles.js +5 -5
- package/dist/{index-CJpjY7r7.js → index-B_TA81tq.js} +271 -263
- package/dist/index-rI7KLmXk.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{insert--mO_a1mv.js → insert-BXGi8i8T.js} +9 -9
- package/dist/insert-Be2OwrVW.cjs +1 -0
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.mjs +3 -3
- package/dist/{remove-C4YcWK2S.js → remove-Dg1WsaSC.js} +1 -1
- package/dist/{remove-dSzXNYxs.cjs → remove-FDZxr31Z.cjs} +1 -1
- package/dist/svelte/index.cjs +1 -1
- package/dist/svelte/index.mjs +3 -3
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.mjs +3 -3
- package/package.json +1 -1
- package/dist/index-BOqB07mI.cjs +0 -1
- package/dist/insert-CEcy9QNd.cjs +0 -1
@@ -1,7 +1,7 @@
|
|
1
1
|
var d = Object.defineProperty;
|
2
2
|
var e = (a, s, l) => s in a ? d(a, s, { enumerable: !0, configurable: !0, writable: !0, value: l }) : a[s] = l;
|
3
3
|
var r = (a, s, l) => e(a, typeof s != "symbol" ? s + "" : s, l);
|
4
|
-
import { a as h, t as n, G as t } from "./index-
|
4
|
+
import { a as h, t as n, G as t } from "./index-B_TA81tq.js";
|
5
5
|
class c {
|
6
6
|
constructor() {
|
7
7
|
r(this, "handlers");
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";var d=Object.defineProperty;var n=(e,s,l)=>s in e?d(e,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[s]=l;var a=(e,s,l)=>n(e,typeof s!="symbol"?s+"":s,l);const r=require("./index-
|
1
|
+
"use strict";var d=Object.defineProperty;var n=(e,s,l)=>s in e?d(e,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[s]=l;var a=(e,s,l)=>n(e,typeof s!="symbol"?s+"":s,l);const r=require("./index-rI7KLmXk.cjs");class h{constructor(){a(this,"handlers");this.handlers=[]}addSubscriber(s){this.handlers.includes(s)||(this.handlers.push(s),r.addClass(s,r.GRAB_CLASS))}toggleGrabClass(s){for(const l of this.handlers)r.toggleClass(l,r.GRAB_CLASS,s)}}exports.HandlerPublisher=h;
|
package/dist/core/dragAndDrop.js
CHANGED
@@ -28,6 +28,7 @@ const getConfig = (listCondig, config) => {
|
|
28
28
|
isDraggable: config?.isDraggable ?? (() => true),
|
29
29
|
onDragStart: config?.onDragStart ?? (() => { }),
|
30
30
|
onDragEnd: config?.onDragEnd ?? (() => { }),
|
31
|
+
onDragOver: config?.onDragOver ?? (() => { }),
|
31
32
|
droppableGroup: config?.droppableGroup,
|
32
33
|
onRemoveAtEvent,
|
33
34
|
onInsertEvent,
|
@@ -40,7 +41,7 @@ const getConfig = (listCondig, config) => {
|
|
40
41
|
delayBeforeInsert: config?.delayBeforeInsert ?? 200,
|
41
42
|
mapFrom: config?.mapFrom ?? defaultMapFrom,
|
42
43
|
delayBeforeTouchMoveEvent: config?.delayBeforeTouchMoveEvent ?? 150,
|
43
|
-
coordinateTransform: config?.coordinateTransform ?? [(coordinate) => coordinate]
|
44
|
+
coordinateTransform: config?.coordinateTransform ?? [(coordinate) => coordinate],
|
44
45
|
};
|
45
46
|
};
|
46
47
|
export default function dragAndDrop(listCondig, handlerPublisher, config, indexAttr = 'index') {
|
@@ -70,11 +71,11 @@ export default function dragAndDrop(listCondig, handlerPublisher, config, indexA
|
|
70
71
|
insertAtFromElements = insertAtFromElementList;
|
71
72
|
};
|
72
73
|
const childrenMutationFilter = (mutation) => {
|
73
|
-
const addedNodes = mutation.addedNodes
|
74
|
+
const addedNodes = Array.from(mutation.addedNodes ?? [])
|
74
75
|
.values()
|
75
76
|
.filter((element) => !isTempElement(element))
|
76
77
|
.toArray();
|
77
|
-
const removedNodes = mutation.removedNodes
|
78
|
+
const removedNodes = Array.from(mutation.removedNodes ?? [])
|
78
79
|
.values()
|
79
80
|
.filter((element) => !isTempElement(element))
|
80
81
|
.toArray();
|
@@ -29,7 +29,14 @@ export default function useDragAndDropEvents(currentConfig, index, parent, dropp
|
|
29
29
|
const emitDraggingEventToSiblings = (draggedElement, event, translation, droppable, config) => {
|
30
30
|
const [siblings] = getSiblings(draggedElement, droppable);
|
31
31
|
const isOutside = draggableIsOutside(draggedElement, droppable);
|
32
|
-
const { direction } = config;
|
32
|
+
const { direction, onDragOver } = config;
|
33
|
+
onDragOver({
|
34
|
+
element: draggedElement,
|
35
|
+
index,
|
36
|
+
targetIndex: actualIndex,
|
37
|
+
value: currentConfig.onGetValue(index),
|
38
|
+
droppable
|
39
|
+
});
|
33
40
|
if (siblings.length == 0) {
|
34
41
|
updateActualIndexBaseOnTranslation(translation, 1, direction, siblings);
|
35
42
|
}
|
@@ -40,7 +40,7 @@ export default function useInsertEvents(currentConfig, parent, handlerPublisher,
|
|
40
40
|
return [emitInsertEventToSiblings];
|
41
41
|
}
|
42
42
|
const childrenMutationFilter = (mutation) => {
|
43
|
-
const addedNodes = mutation.addedNodes
|
43
|
+
const addedNodes = Array.from(mutation.addedNodes ?? [])
|
44
44
|
.values()
|
45
45
|
.filter((element) => !isTempElement(element))
|
46
46
|
.toArray();
|
package/dist/core/index.d.ts
CHANGED
@@ -21,6 +21,13 @@ export interface DragEndEventData<T> {
|
|
21
21
|
index: number;
|
22
22
|
value: T;
|
23
23
|
}
|
24
|
+
export interface DragOverEventData<T> {
|
25
|
+
index: number;
|
26
|
+
targetIndex: number;
|
27
|
+
element: Element;
|
28
|
+
value: T;
|
29
|
+
droppable: Element;
|
30
|
+
}
|
24
31
|
export declare const HORIZONTAL = "horizontal";
|
25
32
|
export declare const VERTICAL = "vertical";
|
26
33
|
/**
|
@@ -88,6 +95,10 @@ export interface Config<T> {
|
|
88
95
|
* A function that returns whether a given element of the list is draggable.
|
89
96
|
*/
|
90
97
|
onDragEnd?: (element: DragEndEventData<T>) => void;
|
98
|
+
/**
|
99
|
+
* A function that is called when the draggable element is dragged over a droppable.
|
100
|
+
*/
|
101
|
+
onDragOver?: (element: DragOverEventData<T>) => void;
|
91
102
|
/**
|
92
103
|
* Name of the group of the share droppables.
|
93
104
|
*/
|
@@ -123,6 +134,7 @@ export interface Config<T> {
|
|
123
134
|
* @public
|
124
135
|
*/
|
125
136
|
export type OnDropEvent = (source: DraggableElement, destination: DraggableElement) => void;
|
137
|
+
export type OnDragOverEvent = (source: DraggableElement) => void;
|
126
138
|
export type OnRemoveAtEvent<T> = (index: number, sync?: boolean) => T | undefined;
|
127
139
|
export type OnInsertEvent<T> = (index: number, value: T, sync?: boolean) => void;
|
128
140
|
export type OnGetLength = () => number;
|
@@ -172,6 +184,10 @@ export type CoreConfig<T> = {
|
|
172
184
|
* A function that is called when the draggable element is dropped.
|
173
185
|
*/
|
174
186
|
onDragEnd: (element: DragEndEventData<T>) => void;
|
187
|
+
/**
|
188
|
+
* A function that is called when the draggable element is dragged over a droppable.
|
189
|
+
*/
|
190
|
+
onDragOver: (element: DragOverEventData<T>) => void;
|
175
191
|
/**
|
176
192
|
* Name of the group of the share droppables
|
177
193
|
*/
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { getAxisValue, getBefore, getBeforeMarginValue, getBorderBeforeWidthValue, getDistanceValue, getInnerDistance,
|
1
|
+
import { getAxisValue, getBefore, getBeforeMarginValue, getBorderBeforeWidthValue, getDistanceValue, getInnerDistance, getNearestParentPositionWithTranslate, getOffsetValue, getPageValue, getPropByDirection, getRect, getScrollValue, hasTransform, isSameNode } from '../utils/GetStyles';
|
2
2
|
import { HORIZONTAL, VERTICAL } from '..';
|
3
3
|
import { useScroll } from './autoScroll';
|
4
4
|
import { HANDLER_CLASS, DRAGGING_CLASS } from '../utils/classes';
|
@@ -24,7 +24,7 @@ export const usePositioning = (draggedElement, coordinateTransforms) => {
|
|
24
24
|
const border = getBorderBeforeWidthValue(translateDirection, element);
|
25
25
|
const margin = getBeforeMarginValue(translateDirection, element);
|
26
26
|
const elementPosittion = pageValue - getOffsetValue(translateDirection, currentOffset);
|
27
|
-
const beforefixecParentValue =
|
27
|
+
const beforefixecParentValue = getNearestParentPositionWithTranslate(element, translateDirection);
|
28
28
|
if (elementPosittion >= scrollValue - distanceValue / 2 &&
|
29
29
|
elementPosittion <= scrollValue + innerDistance) {
|
30
30
|
const parentPosition = getParentPosition(translateDirection, parent);
|
@@ -96,7 +96,7 @@ const getHandlerElementAncestor = (target, draggable) => {
|
|
96
96
|
return targetHandler;
|
97
97
|
};
|
98
98
|
const getPositionByDistance = (direction, event, element, offsetEvent) => {
|
99
|
-
const beforefixecParentValue =
|
99
|
+
const beforefixecParentValue = getNearestParentPositionWithTranslate(element, direction);
|
100
100
|
const parent = element.parentElement;
|
101
101
|
const parentPosition = getParentPosition(direction, parent);
|
102
102
|
return (getPageValue(direction, event) -
|
@@ -61,6 +61,6 @@ export declare const getSiblings: (current: HTMLElement, parent: HTMLElement) =>
|
|
61
61
|
export declare const getGroupDroppables: (currentDroppable: HTMLElement, droppableGroup?: string) => Element[];
|
62
62
|
export declare const getParentDraggableChildren: (parent: HTMLElement) => Element[];
|
63
63
|
export declare const getSiblingsByParent: (current: HTMLElement, parent: HTMLElement) => readonly [Element[], number, HTMLElement];
|
64
|
-
export declare const
|
64
|
+
export declare const getNearestParentPositionWithTranslate: (element: Element, direction: Direction) => number;
|
65
65
|
export declare const isSameNode: (element1: Element | null | undefined, element2: Element | null) => boolean | undefined;
|
66
66
|
export declare const hasTransform: (element: HTMLElement | null) => boolean | null;
|
@@ -176,19 +176,19 @@ export const getSiblingsByParent = (current, parent) => {
|
|
176
176
|
const positionOnDroppable = [...parent.children].findLastIndex((child) => child.isEqualNode(current));
|
177
177
|
return [siblings, positionOnDroppable, parent];
|
178
178
|
};
|
179
|
-
const
|
179
|
+
const getNearestParentWithTranslate = (element) => {
|
180
180
|
let parent = element.parentElement;
|
181
181
|
while (parent) {
|
182
|
-
const
|
183
|
-
if (
|
182
|
+
const transformValue = window.getComputedStyle(parent).translate;
|
183
|
+
if (transformValue !== 'none') {
|
184
184
|
return parent;
|
185
185
|
}
|
186
186
|
parent = parent.parentElement;
|
187
187
|
}
|
188
188
|
return null; // No fixed parent found
|
189
189
|
};
|
190
|
-
export const
|
191
|
-
const fixedParent =
|
190
|
+
export const getNearestParentPositionWithTranslate = (element, direction) => {
|
191
|
+
const fixedParent = getNearestParentWithTranslate(element);
|
192
192
|
return fixedParent
|
193
193
|
? getBefore(direction, getRect(fixedParent)) + getBorderBeforeWidthValue(direction, fixedParent)
|
194
194
|
: 0;
|