fluid-dnd 2.1.3 → 2.2.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-CVvTsXrJ.js → HandlerPublisher-CRBvk0J7.js} +1 -1
- package/dist/{HandlerPublisher-CsD6p60X.cjs → HandlerPublisher-DGYFIYDd.cjs} +1 -1
- package/dist/core/index.d.ts +37 -0
- package/dist/core/useDraggable.js +2 -2
- package/dist/core/utils/SetTransform.d.ts +3 -3
- package/dist/core/utils/SetTransform.js +20 -20
- package/dist/core/utils/config.d.ts +3 -3
- package/dist/core/utils/config.js +5 -4
- package/dist/index-Dc95WWpv.js +1271 -0
- package/dist/index-DxKyk1TO.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.mjs +2 -2
- package/dist/svelte/index.cjs +1 -1
- package/dist/svelte/index.mjs +2 -2
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.mjs +2 -2
- package/package.json +1 -1
- package/dist/index-C6IKL-bo.js +0 -1271
- package/dist/index-DE3X7xW4.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-Dc95WWpv.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-DxKyk1TO.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/index.d.ts
CHANGED
@@ -28,6 +28,17 @@ export declare const VERTICAL = "vertical";
|
|
28
28
|
* @public
|
29
29
|
*/
|
30
30
|
export type Direction = typeof HORIZONTAL | typeof VERTICAL;
|
31
|
+
/**
|
32
|
+
* The coordinate of the translate property of the draggred element.
|
33
|
+
*/
|
34
|
+
export type Coordinate = {
|
35
|
+
x: number;
|
36
|
+
y: number;
|
37
|
+
};
|
38
|
+
/**
|
39
|
+
* Mapping function that transforms the coordinates of the dragged element.
|
40
|
+
*/
|
41
|
+
export type CoordinateMap = (coordinate: Coordinate, currentElement: HTMLElement) => Coordinate;
|
31
42
|
/**
|
32
43
|
* Configuration of the drag and drop.
|
33
44
|
* @public
|
@@ -93,6 +104,19 @@ export interface Config<T> {
|
|
93
104
|
* The delay before the touchmove event is fired.
|
94
105
|
*/
|
95
106
|
delayBeforeTouchMoveEvent?: number;
|
107
|
+
/**
|
108
|
+
* List of mapping functions that transform the coordinates of the dragged element, which are applied one after another,
|
109
|
+
* where the output of one mapping function becomes the input of the next.
|
110
|
+
* @example
|
111
|
+
* [map1, map2, map3]
|
112
|
+
* means:
|
113
|
+
* let y1 = map1(y0)
|
114
|
+
* let y2 = map2(y1)
|
115
|
+
* let finalCoordinate = map3(y2)
|
116
|
+
* The default value is [(coordinate) => coordinate]
|
117
|
+
* @default [(coordinate) => coordinate]
|
118
|
+
*/
|
119
|
+
coordinateTransform?: CoordinateMap[];
|
96
120
|
}
|
97
121
|
/**
|
98
122
|
* onDrop event function.
|
@@ -168,4 +192,17 @@ export type CoreConfig<T> = {
|
|
168
192
|
* The delay before the touchmove event is fired.
|
169
193
|
*/
|
170
194
|
delayBeforeTouchMoveEvent: number;
|
195
|
+
/**
|
196
|
+
* List of mapping functions that transform the coordinates of the dragged element, which are applied one after another,
|
197
|
+
* where the output of one mapping function becomes the input of the next.
|
198
|
+
* @example
|
199
|
+
* [map1, map2, map3]
|
200
|
+
* means:
|
201
|
+
* let y1 = map1(y0)
|
202
|
+
* let y2 = map2(y1)
|
203
|
+
* let finalCoordinate = map3(y2)
|
204
|
+
* The default value is [(coordinate) => coordinate]
|
205
|
+
* @default [(coordinate) => coordinate]
|
206
|
+
*/
|
207
|
+
coordinateTransform: CoordinateMap[];
|
171
208
|
};
|
@@ -16,7 +16,7 @@ var DraggingState;
|
|
16
16
|
DraggingState[DraggingState["END_DRAGGING"] = 3] = "END_DRAGGING";
|
17
17
|
})(DraggingState || (DraggingState = {}));
|
18
18
|
export default function useDraggable(draggableElement, index, config, parent, handlerPublisher) {
|
19
|
-
const { handlerSelector, isDraggable, droppableGroup, animationDuration, delayBeforeRemove, draggingClass, removingClass, onRemoveAtEvent, droppableClass, onDragStart, delayBeforeTouchMoveEvent } = config;
|
19
|
+
const { handlerSelector, isDraggable, droppableGroup, animationDuration, delayBeforeRemove, draggingClass, removingClass, onRemoveAtEvent, droppableClass, onDragStart, delayBeforeTouchMoveEvent, coordinateTransform } = config;
|
20
20
|
const droppableGroupClass = getClassesList(droppableGroup)
|
21
21
|
.map((classGroup) => `droppable-group-${classGroup}`)
|
22
22
|
.join(' ');
|
@@ -28,7 +28,7 @@ export default function useDraggable(draggableElement, index, config, parent, ha
|
|
28
28
|
let pagePosition = { pageX: 0, pageY: 0 };
|
29
29
|
let delayTimeout;
|
30
30
|
let initialTouch;
|
31
|
-
const [setTransform, updateTransformState] = useTransform(draggableElement);
|
31
|
+
const [setTransform, updateTransformState] = useTransform(draggableElement, coordinateTransform);
|
32
32
|
const endDraggingState = () => {
|
33
33
|
draggingState = DraggingState.NOT_DRAGGING;
|
34
34
|
};
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { DragMouseTouchEvent, TransformEvent } from
|
2
|
-
import { Direction } from
|
3
|
-
export declare const useTransform: (draggedElement: HTMLElement) => readonly [(element: HTMLElement, parent: HTMLElement, pagePosition: {
|
1
|
+
import { DragMouseTouchEvent, TransformEvent } from '../../../index';
|
2
|
+
import { CoordinateMap, Direction } from '..';
|
3
|
+
export declare const useTransform: (draggedElement: HTMLElement, coordinateTransforms: CoordinateMap[]) => readonly [(element: HTMLElement, parent: HTMLElement, pagePosition: {
|
4
4
|
pageX: number;
|
5
5
|
pageY: number;
|
6
6
|
}, direction?: Direction) => void, (event: DragMouseTouchEvent, element: HTMLElement) => void];
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import { draggableIsOutside, getNearestFixedParentPosition, getPropByDirection, getValueFromProperty
|
2
|
-
import { HORIZONTAL, VERTICAL } from
|
3
|
-
import { scrollByDirection } from
|
4
|
-
import { HANDLER_CLASS, DRAGGING_CLASS } from
|
5
|
-
import { containClass } from
|
6
|
-
export const useTransform = (draggedElement) => {
|
1
|
+
import { draggableIsOutside, getNearestFixedParentPosition, getPropByDirection, getValueFromProperty } from './GetStyles';
|
2
|
+
import { HORIZONTAL, VERTICAL } from '..';
|
3
|
+
import { scrollByDirection } from './scroll';
|
4
|
+
import { HANDLER_CLASS, DRAGGING_CLASS } from './classes';
|
5
|
+
import { containClass } from './dom/classList';
|
6
|
+
export const useTransform = (draggedElement, coordinateTransforms) => {
|
7
7
|
let currentOffset = { offsetX: 0, offsetY: 0 };
|
8
8
|
let position = { top: 0, left: 0 };
|
9
9
|
let translate = { x: 0, y: 0 };
|
@@ -40,15 +40,11 @@ export const useTransform = (draggedElement) => {
|
|
40
40
|
return defaultTransalation;
|
41
41
|
};
|
42
42
|
const updateScroll = (translateDirection) => {
|
43
|
-
if (element &&
|
44
|
-
containClass(element, DRAGGING_CLASS) &&
|
45
|
-
translateDirection === direction) {
|
43
|
+
if (element && containClass(element, DRAGGING_CLASS) && translateDirection === direction) {
|
46
44
|
const { before, distance, axis, getRect } = getPropByDirection(direction);
|
47
45
|
const distanceValue = getRect(element)[distance];
|
48
46
|
const parentBoundingClientRect = getRect(parent);
|
49
|
-
const positionInsideParent = position[before] -
|
50
|
-
parentBoundingClientRect[before] +
|
51
|
-
translate[axis];
|
47
|
+
const positionInsideParent = position[before] - parentBoundingClientRect[before] + translate[axis];
|
52
48
|
const parentDistance = parentBoundingClientRect[distance];
|
53
49
|
const totalDistance = parentDistance - distanceValue;
|
54
50
|
const relativePosition = positionInsideParent / totalDistance;
|
@@ -75,24 +71,28 @@ export const useTransform = (draggedElement) => {
|
|
75
71
|
const updateTranlateByDirection = (direction) => {
|
76
72
|
const { axis } = getPropByDirection(direction);
|
77
73
|
translate[axis] = getTranslateWihtDirection(direction);
|
78
|
-
updateTranform(
|
74
|
+
updateTranform(mapCoordinate());
|
79
75
|
};
|
80
76
|
updateTranlateByDirection(HORIZONTAL);
|
81
77
|
updateTranlateByDirection(VERTICAL);
|
82
78
|
};
|
79
|
+
const mapCoordinate = () => {
|
80
|
+
let coordinate = translate;
|
81
|
+
for (const transform of coordinateTransforms) {
|
82
|
+
coordinate = transform(coordinate, draggedElement);
|
83
|
+
}
|
84
|
+
return coordinate;
|
85
|
+
};
|
83
86
|
const updateTransformState = (event, element) => {
|
84
87
|
const [top, left, offsetX, offsetY] = getTransformState(event, element, draggedElement);
|
85
88
|
position = {
|
86
89
|
top,
|
87
|
-
left
|
90
|
+
left
|
88
91
|
};
|
89
92
|
updatePosition(position);
|
90
93
|
currentOffset = { offsetX, offsetY };
|
91
94
|
};
|
92
|
-
return [
|
93
|
-
setTransform,
|
94
|
-
updateTransformState,
|
95
|
-
];
|
95
|
+
return [setTransform, updateTransformState];
|
96
96
|
};
|
97
97
|
const getOffsetWithDraggable = (direction, element, draggable) => {
|
98
98
|
const { borderBeforeWidth, before, getRect } = getPropByDirection(direction);
|
@@ -136,11 +136,11 @@ export const getTransformState = (event, element, draggable) => {
|
|
136
136
|
return [
|
137
137
|
getPositionByDistance(VERTICAL, event, element, {
|
138
138
|
offsetX,
|
139
|
-
offsetY
|
139
|
+
offsetY
|
140
140
|
}),
|
141
141
|
getPositionByDistance(HORIZONTAL, event, element, {
|
142
142
|
offsetX,
|
143
|
-
offsetY
|
143
|
+
offsetY
|
144
144
|
}),
|
145
145
|
offsetX,
|
146
146
|
offsetY
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { ListCondig, MapFrom } from
|
2
|
-
import { Config, CoreConfig } from
|
3
|
-
import { DroppableConfig } from
|
1
|
+
import { ListCondig, MapFrom } from '..';
|
2
|
+
import { Config, CoreConfig } from '..';
|
3
|
+
import { DroppableConfig } from '../configHandler';
|
4
4
|
export declare const getConfig: <T>(listCondig: ListCondig<T>, config?: Config<T>) => CoreConfig<T>;
|
5
5
|
export declare const MapConfig: <T>(coreConfig: DroppableConfig<any>, mapFrom: MapFrom<T>) => CoreConfig<any>;
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { VERTICAL
|
2
|
-
import { DRAGGABLE_CLASS } from
|
1
|
+
import { VERTICAL } from '..';
|
2
|
+
import { DRAGGABLE_CLASS } from './classes';
|
3
3
|
export const getConfig = (listCondig, config) => {
|
4
4
|
const onRemoveAtEvent = (index, sync) => {
|
5
5
|
return listCondig.removeAtEvent(index, sync);
|
@@ -19,7 +19,7 @@ export const getConfig = (listCondig, config) => {
|
|
19
19
|
return {
|
20
20
|
direction: config?.direction ?? VERTICAL,
|
21
21
|
handlerSelector: config?.handlerSelector ?? DRAGGABLE_CLASS,
|
22
|
-
draggingClass: config?.draggingClass ??
|
22
|
+
draggingClass: config?.draggingClass ?? 'dragging',
|
23
23
|
droppableClass: config?.droppableClass ?? 'droppable-hover',
|
24
24
|
isDraggable: config?.isDraggable ?? (() => true),
|
25
25
|
onDragStart: config?.onDragStart ?? (() => { }),
|
@@ -30,12 +30,13 @@ export const getConfig = (listCondig, config) => {
|
|
30
30
|
onGetLegth,
|
31
31
|
onGetValue,
|
32
32
|
animationDuration: config?.animationDuration ?? 200,
|
33
|
-
removingClass: config?.removingClass ??
|
33
|
+
removingClass: config?.removingClass ?? 'removing',
|
34
34
|
insertingFromClass: config?.insertingFromClass ?? 'from-inserting',
|
35
35
|
delayBeforeRemove: config?.delayBeforeRemove ?? 200,
|
36
36
|
delayBeforeInsert: config?.delayBeforeInsert ?? 200,
|
37
37
|
mapFrom: config?.mapFrom ?? defaultMapFrom,
|
38
38
|
delayBeforeTouchMoveEvent: config?.delayBeforeTouchMoveEvent ?? 150,
|
39
|
+
coordinateTransform: config?.coordinateTransform ?? [(coordinate) => coordinate]
|
39
40
|
};
|
40
41
|
};
|
41
42
|
export const MapConfig = (coreConfig, mapFrom) => {
|