geostyler 10.3.0 → 10.3.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/browser/geostyler.css +1 -1
- package/browser/geostyler.js +1 -1
- package/dist/Component/{Removable/RemovableItem → RemovableItem}/RemovableItem.css +0 -0
- package/dist/Component/{Removable/RemovableItem → RemovableItem}/RemovableItem.d.ts +1 -1
- package/dist/Component/{Removable/RemovableItem → RemovableItem}/RemovableItem.js +2 -7
- package/dist/Component/RemovableItem/RemovableItem.js.map +1 -0
- package/dist/Component/RuleCard/RuleCard.d.ts +2 -2
- package/dist/Component/RuleCard/RuleCard.js +4 -3
- package/dist/Component/RuleCard/RuleCard.js.map +1 -1
- package/dist/Component/Rules/Rules.js +31 -41
- package/dist/Component/Rules/Rules.js.map +1 -1
- package/dist/Component/{Removable/Removable.css → SortableItem/SortableItem.css} +0 -0
- package/dist/Component/SortableItem/SortableItem.d.ts +7 -0
- package/dist/Component/{Removable/Removable.js → SortableItem/SortableItem.js} +30 -23
- package/dist/Component/SortableItem/SortableItem.js.map +1 -0
- package/dist/Component/SymbolizerCard/SymbolizerCard.d.ts +1 -1
- package/dist/Component/SymbolizerCard/SymbolizerCard.js +4 -3
- package/dist/Component/SymbolizerCard/SymbolizerCard.js.map +1 -1
- package/dist/Component/Symbolizers/Symbolizers.css +1 -9
- package/dist/Component/Symbolizers/Symbolizers.js +45 -41
- package/dist/Component/Symbolizers/Symbolizers.js.map +1 -1
- package/dist/hook/UseDragDropSensors.d.ts +6 -0
- package/dist/{Component/DropIndicator/DropIndicator.js → hook/UseDragDropSensors.js} +21 -11
- package/dist/hook/UseDragDropSensors.js.map +1 -0
- package/dist/index.d.ts +3 -5
- package/dist/index.js +6 -10
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
- package/dist/Component/CompositionContext/CompositionContext.d.ts +0 -85
- package/dist/Component/CompositionContext/CompositionContext.js +0 -52
- package/dist/Component/CompositionContext/CompositionContext.js.map +0 -1
- package/dist/Component/DefaultValueContext/DefaultValueContext.d.ts +0 -60
- package/dist/Component/DefaultValueContext/DefaultValueContext.js +0 -52
- package/dist/Component/DefaultValueContext/DefaultValueContext.js.map +0 -1
- package/dist/Component/DragDroppable/DragDroppable.css +0 -36
- package/dist/Component/DragDroppable/DragDroppable.d.ts +0 -13
- package/dist/Component/DragDroppable/DragDroppable.js +0 -68
- package/dist/Component/DragDroppable/DragDroppable.js.map +0 -1
- package/dist/Component/DropIndicator/DropIndicator.css +0 -30
- package/dist/Component/DropIndicator/DropIndicator.d.ts +0 -6
- package/dist/Component/DropIndicator/DropIndicator.js.map +0 -1
- package/dist/Component/Legacy/CodeEditor/CodeEditor.css +0 -59
- package/dist/Component/Legacy/CodeEditor/CodeEditor.d.ts +0 -131
- package/dist/Component/Legacy/CodeEditor/CodeEditor.js +0 -317
- package/dist/Component/Legacy/CodeEditor/CodeEditor.js.map +0 -1
- package/dist/Component/Removable/Removable.d.ts +0 -10
- package/dist/Component/Removable/Removable.js.map +0 -1
- package/dist/Component/Removable/RemovableItem/RemovableItem.js.map +0 -1
- package/dist/Component/Rule/TitleField/TitleField.css +0 -30
- package/dist/Component/Rule/TitleField/TitleField.d.ts +0 -25
- package/dist/Component/Rule/TitleField/TitleField.js +0 -100
- package/dist/Component/Rule/TitleField/TitleField.js.map +0 -1
- package/dist/Component/Symbolizer/Field/ColorField/BaseColorField/BaseColorField.css +0 -34
- package/dist/Component/Symbolizer/Field/ColorField/BaseColorField/BaseColorField.d.ts +0 -88
- package/dist/Component/Symbolizer/Field/ColorField/BaseColorField/BaseColorField.js +0 -136
- package/dist/Component/Symbolizer/Field/ColorField/BaseColorField/BaseColorField.js.map +0 -1
- package/dist/Component/Symbolizer/Field/ExpressionField/ExpressionField.d.ts +0 -13
- package/dist/Component/Symbolizer/Field/ExpressionField/ExpressionField.js +0 -73
- package/dist/Component/Symbolizer/Field/ExpressionField/ExpressionField.js.map +0 -1
- package/dist/Util/DndUtil.d.ts +0 -114
- package/dist/Util/DndUtil.js +0 -159
- package/dist/Util/DndUtil.js.map +0 -1
- package/dist/hook/UseDragDrop.d.ts +0 -20
- package/dist/hook/UseDragDrop.js +0 -238
- package/dist/hook/UseDragDrop.js.map +0 -1
package/dist/Util/DndUtil.d.ts
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Properties of a drag item.
|
|
3
|
-
*/
|
|
4
|
-
export type DragItem = {
|
|
5
|
-
index: number;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* The drag orientation. Either dragging vertically or horizontally.
|
|
9
|
-
*/
|
|
10
|
-
export type DragOrientation = 'vertical' | 'horizontal';
|
|
11
|
-
/**
|
|
12
|
-
* The drag item type. Used for specifiying which
|
|
13
|
-
* items can be dropped at which targets.
|
|
14
|
-
*/
|
|
15
|
-
export declare enum ItemType {
|
|
16
|
-
SYMBOLIZER = "SYMBOLIZER",
|
|
17
|
-
RULE = "RULE"
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* The direction in which an item is being dragged.
|
|
21
|
-
*/
|
|
22
|
-
export declare enum Direction {
|
|
23
|
-
/** Dragging to the left. */
|
|
24
|
-
LEFT = 0,
|
|
25
|
-
/** Dragging to the right. */
|
|
26
|
-
RIGHT = 1,
|
|
27
|
-
/** Dragging upwards. */
|
|
28
|
-
UP = 2,
|
|
29
|
-
/** Dragging downwards. */
|
|
30
|
-
DOWN = 3
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* The side on which an element was dropped.
|
|
34
|
-
*/
|
|
35
|
-
export declare enum Side {
|
|
36
|
-
/** Dropping an element at the further away side in dragging direction. */
|
|
37
|
-
BEHIND = 0,
|
|
38
|
-
/** Dropping an element at the nearer side in dragging direction. */
|
|
39
|
-
BEFORE = 1
|
|
40
|
-
}
|
|
41
|
-
type GetDropSideParams = {
|
|
42
|
-
/** The index of the drag item. */
|
|
43
|
-
dragIndex: number;
|
|
44
|
-
/** The index of the drop target. */
|
|
45
|
-
dropIndex: number;
|
|
46
|
-
/** The source of the drag item. */
|
|
47
|
-
dragSource: number;
|
|
48
|
-
/** The pixel ordinate of the drop target in drag orientation. */
|
|
49
|
-
dropMiddle: number;
|
|
50
|
-
};
|
|
51
|
-
type GetDragDirectionParams = {
|
|
52
|
-
/** The index of the drag item. */
|
|
53
|
-
dragIndex: number;
|
|
54
|
-
/** The index of the drop target. */
|
|
55
|
-
dropIndex: number;
|
|
56
|
-
/** The orientation of the dragdrop. */
|
|
57
|
-
dragOrientation: DragOrientation;
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* @class DndUtil
|
|
61
|
-
*/
|
|
62
|
-
declare class DndUtil {
|
|
63
|
-
/**
|
|
64
|
-
* Move an element within an array in-place.
|
|
65
|
-
*
|
|
66
|
-
* @param from Index of the element to move.
|
|
67
|
-
* @param to Target index.
|
|
68
|
-
* @param arr Array in which the element is moved.
|
|
69
|
-
*/
|
|
70
|
-
static moveElementInPlace: (from: number, to: number, arr: any[]) => void;
|
|
71
|
-
/**
|
|
72
|
-
* Get the drop side of a drop event.
|
|
73
|
-
*
|
|
74
|
-
* @returns The side on which was dropped.
|
|
75
|
-
*/
|
|
76
|
-
static getDropSide: ({ dragIndex, dropIndex, dragSource, dropMiddle }: GetDropSideParams) => Side;
|
|
77
|
-
/**
|
|
78
|
-
* Get the direction of the dragging event.
|
|
79
|
-
*
|
|
80
|
-
* @returns The direction.
|
|
81
|
-
*/
|
|
82
|
-
static getDragDirection: ({ dragIndex, dropIndex, dragOrientation }: GetDragDirectionParams) => Direction;
|
|
83
|
-
/**
|
|
84
|
-
* Get the x value of the middle of the drop target.
|
|
85
|
-
*
|
|
86
|
-
* @param dropTargetBoundingRect The bounding rectangle of the drop target.
|
|
87
|
-
* @returns The x value of the middle of the drop target.
|
|
88
|
-
*/
|
|
89
|
-
static getDropMiddleX: (dropTargetBoundingRect: any) => number;
|
|
90
|
-
/**
|
|
91
|
-
* Get the y value of the middle of the drop target.
|
|
92
|
-
*
|
|
93
|
-
* @param dropTargetBoundingRect The bounding rectangle of the drop target.
|
|
94
|
-
* @returns The y value of the middle of the drop target.
|
|
95
|
-
*/
|
|
96
|
-
static getDropMiddleY: (dropTargetBoundingRect: any) => number;
|
|
97
|
-
/**
|
|
98
|
-
* Get the x value of the dragged element.
|
|
99
|
-
*
|
|
100
|
-
* @param clientOffset The client offset.
|
|
101
|
-
* @param dropTargetBoundingRect The bounding rectangle of the drop target.
|
|
102
|
-
* @returns The x value of the drag source.
|
|
103
|
-
*/
|
|
104
|
-
static getDragSourceX: (clientOffset: any, dropTargetBoundingRect: any) => number;
|
|
105
|
-
/**
|
|
106
|
-
* Get the y value of the dragged element.
|
|
107
|
-
*
|
|
108
|
-
* @param clientOffset The client offset.
|
|
109
|
-
* @param dropTargetBoundingRect The bounding rectangle of the drop target.
|
|
110
|
-
* @returns The y value of the drag source.
|
|
111
|
-
*/
|
|
112
|
-
static getDragSourceY: (clientOffset: any, dropTargetBoundingRect: any) => number;
|
|
113
|
-
}
|
|
114
|
-
export default DndUtil;
|
package/dist/Util/DndUtil.js
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* Released under the BSD 2-Clause License
|
|
3
|
-
*
|
|
4
|
-
* Copyright © 2022-present, terrestris GmbH & Co. KG and GeoStyler contributors
|
|
5
|
-
* All rights reserved.
|
|
6
|
-
*
|
|
7
|
-
* Redistribution and use in source and binary forms, with or without
|
|
8
|
-
* modification, are permitted provided that the following conditions are met:
|
|
9
|
-
*
|
|
10
|
-
* * Redistributions of source code must retain the above copyright notice,
|
|
11
|
-
* this list of conditions and the following disclaimer.
|
|
12
|
-
*
|
|
13
|
-
* * Redistributions in binary form must reproduce the above copyright notice,
|
|
14
|
-
* this list of conditions and the following disclaimer in the documentation
|
|
15
|
-
* and/or other materials provided with the distribution.
|
|
16
|
-
*
|
|
17
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
18
|
-
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
19
|
-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
20
|
-
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
21
|
-
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
22
|
-
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
23
|
-
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
24
|
-
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
25
|
-
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
26
|
-
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
27
|
-
* POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
-
*/
|
|
29
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.Side = exports.Direction = exports.ItemType = void 0;
|
|
31
|
-
/**
|
|
32
|
-
* The drag item type. Used for specifiying which
|
|
33
|
-
* items can be dropped at which targets.
|
|
34
|
-
*/
|
|
35
|
-
var ItemType;
|
|
36
|
-
(function (ItemType) {
|
|
37
|
-
ItemType["SYMBOLIZER"] = "SYMBOLIZER";
|
|
38
|
-
ItemType["RULE"] = "RULE";
|
|
39
|
-
})(ItemType = exports.ItemType || (exports.ItemType = {}));
|
|
40
|
-
/**
|
|
41
|
-
* The direction in which an item is being dragged.
|
|
42
|
-
*/
|
|
43
|
-
var Direction;
|
|
44
|
-
(function (Direction) {
|
|
45
|
-
/** Dragging to the left. */
|
|
46
|
-
Direction[Direction["LEFT"] = 0] = "LEFT";
|
|
47
|
-
/** Dragging to the right. */
|
|
48
|
-
Direction[Direction["RIGHT"] = 1] = "RIGHT";
|
|
49
|
-
/** Dragging upwards. */
|
|
50
|
-
Direction[Direction["UP"] = 2] = "UP";
|
|
51
|
-
/** Dragging downwards. */
|
|
52
|
-
Direction[Direction["DOWN"] = 3] = "DOWN";
|
|
53
|
-
})(Direction = exports.Direction || (exports.Direction = {}));
|
|
54
|
-
/**
|
|
55
|
-
* The side on which an element was dropped.
|
|
56
|
-
*/
|
|
57
|
-
var Side;
|
|
58
|
-
(function (Side) {
|
|
59
|
-
/** Dropping an element at the further away side in dragging direction. */
|
|
60
|
-
Side[Side["BEHIND"] = 0] = "BEHIND";
|
|
61
|
-
/** Dropping an element at the nearer side in dragging direction. */
|
|
62
|
-
Side[Side["BEFORE"] = 1] = "BEFORE";
|
|
63
|
-
})(Side = exports.Side || (exports.Side = {}));
|
|
64
|
-
/**
|
|
65
|
-
* @class DndUtil
|
|
66
|
-
*/
|
|
67
|
-
var DndUtil = /** @class */ (function () {
|
|
68
|
-
function DndUtil() {
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Move an element within an array in-place.
|
|
72
|
-
*
|
|
73
|
-
* @param from Index of the element to move.
|
|
74
|
-
* @param to Target index.
|
|
75
|
-
* @param arr Array in which the element is moved.
|
|
76
|
-
*/
|
|
77
|
-
DndUtil.moveElementInPlace = function (from, to, arr) {
|
|
78
|
-
if (to >= arr.length) {
|
|
79
|
-
var k = to - arr.length + 1;
|
|
80
|
-
while (k--) {
|
|
81
|
-
arr.push(undefined);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
arr.splice(to, 0, arr.splice(from, 1)[0]);
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
* Get the drop side of a drop event.
|
|
88
|
-
*
|
|
89
|
-
* @returns The side on which was dropped.
|
|
90
|
-
*/
|
|
91
|
-
DndUtil.getDropSide = function (_a) {
|
|
92
|
-
var dragIndex = _a.dragIndex, dropIndex = _a.dropIndex, dragSource = _a.dragSource, dropMiddle = _a.dropMiddle;
|
|
93
|
-
var behind = true;
|
|
94
|
-
// dragging right/down
|
|
95
|
-
if (dragIndex < dropIndex && dragSource < dropMiddle) {
|
|
96
|
-
behind = false;
|
|
97
|
-
}
|
|
98
|
-
// dragging left/up
|
|
99
|
-
if (dragIndex > dropIndex && dragSource > dropMiddle) {
|
|
100
|
-
behind = false;
|
|
101
|
-
}
|
|
102
|
-
return behind ? Side.BEHIND : Side.BEFORE;
|
|
103
|
-
};
|
|
104
|
-
/**
|
|
105
|
-
* Get the direction of the dragging event.
|
|
106
|
-
*
|
|
107
|
-
* @returns The direction.
|
|
108
|
-
*/
|
|
109
|
-
DndUtil.getDragDirection = function (_a) {
|
|
110
|
-
var dragIndex = _a.dragIndex, dropIndex = _a.dropIndex, dragOrientation = _a.dragOrientation;
|
|
111
|
-
if (dragOrientation === 'horizontal') {
|
|
112
|
-
return dragIndex > dropIndex ? Direction.LEFT : Direction.RIGHT;
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
return dragIndex > dropIndex ? Direction.UP : Direction.DOWN;
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
/**
|
|
119
|
-
* Get the x value of the middle of the drop target.
|
|
120
|
-
*
|
|
121
|
-
* @param dropTargetBoundingRect The bounding rectangle of the drop target.
|
|
122
|
-
* @returns The x value of the middle of the drop target.
|
|
123
|
-
*/
|
|
124
|
-
DndUtil.getDropMiddleX = function (dropTargetBoundingRect) {
|
|
125
|
-
return (dropTargetBoundingRect.right - dropTargetBoundingRect.left) / 2;
|
|
126
|
-
};
|
|
127
|
-
/**
|
|
128
|
-
* Get the y value of the middle of the drop target.
|
|
129
|
-
*
|
|
130
|
-
* @param dropTargetBoundingRect The bounding rectangle of the drop target.
|
|
131
|
-
* @returns The y value of the middle of the drop target.
|
|
132
|
-
*/
|
|
133
|
-
DndUtil.getDropMiddleY = function (dropTargetBoundingRect) {
|
|
134
|
-
return (dropTargetBoundingRect.bottom - dropTargetBoundingRect.top) / 2;
|
|
135
|
-
};
|
|
136
|
-
/**
|
|
137
|
-
* Get the x value of the dragged element.
|
|
138
|
-
*
|
|
139
|
-
* @param clientOffset The client offset.
|
|
140
|
-
* @param dropTargetBoundingRect The bounding rectangle of the drop target.
|
|
141
|
-
* @returns The x value of the drag source.
|
|
142
|
-
*/
|
|
143
|
-
DndUtil.getDragSourceX = function (clientOffset, dropTargetBoundingRect) {
|
|
144
|
-
return clientOffset.x - dropTargetBoundingRect.left;
|
|
145
|
-
};
|
|
146
|
-
/**
|
|
147
|
-
* Get the y value of the dragged element.
|
|
148
|
-
*
|
|
149
|
-
* @param clientOffset The client offset.
|
|
150
|
-
* @param dropTargetBoundingRect The bounding rectangle of the drop target.
|
|
151
|
-
* @returns The y value of the drag source.
|
|
152
|
-
*/
|
|
153
|
-
DndUtil.getDragSourceY = function (clientOffset, dropTargetBoundingRect) {
|
|
154
|
-
return clientOffset.y - dropTargetBoundingRect.top;
|
|
155
|
-
};
|
|
156
|
-
return DndUtil;
|
|
157
|
-
}());
|
|
158
|
-
exports.default = DndUtil;
|
|
159
|
-
//# sourceMappingURL=DndUtil.js.map
|
package/dist/Util/DndUtil.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DndUtil.js","sourceRoot":"","sources":["../../src/Util/DndUtil.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;;AAcH;;;GAGG;AACH,IAAY,QAGX;AAHD,WAAY,QAAQ;IAClB,qCAAyB,CAAA;IACzB,yBAAa,CAAA;AACf,CAAC,EAHW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAGnB;AAED;;GAEG;AACH,IAAY,SASX;AATD,WAAY,SAAS;IACnB,4BAA4B;IAC5B,yCAAI,CAAA;IACJ,6BAA6B;IAC7B,2CAAK,CAAA;IACL,wBAAwB;IACx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CAAC;IAEF;;;;OAIG;IACI,wBAAgB,GAAG,UAAC,EAA+D;YAA9D,SAAS,eAAA,EAAE,SAAS,eAAA,EAAE,eAAe,qBAAA;QAC/D,IAAI,eAAe,KAAK,YAAY,EAAE;YACpC,OAAO,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC;SACjE;aAAM;YACL,OAAO,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC;SAC9D;IACH,CAAC,CAAC;IAEF;;;;;OAKG;IACI,sBAAc,GAAG,UAAC,sBAA2B;QAClD,OAAA,CAAC,sBAAsB,CAAC,KAAK,GAAG,sBAAsB,CAAC,IAAI,CAAC,GAAG,CAAC;IAAhE,CAAgE,CAAC;IAEnE;;;;;OAKG;IACI,sBAAc,GAAG,UAAC,sBAA2B;QAClD,OAAA,CAAC,sBAAsB,CAAC,MAAM,GAAG,sBAAsB,CAAC,GAAG,CAAC,GAAG,CAAC;IAAhE,CAAgE,CAAC;IAEnE;;;;;;OAMG;IACI,sBAAc,GAAG,UAAC,YAAiB,EAAE,sBAA2B;QACrE,OAAA,YAAY,CAAC,CAAC,GAAG,sBAAsB,CAAC,IAAI;IAA5C,CAA4C,CAAC;IAE/C;;;;;;OAMG;IACI,sBAAc,GAAG,UAAC,YAAiB,EAAE,sBAA2B;QACrE,OAAA,YAAY,CAAC,CAAC,GAAG,sBAAsB,CAAC,GAAG;IAA3C,CAA2C,CAAC;IAEhD,cAAC;CAAA,AA1FD,IA0FC;AAED,kBAAe,OAAO,CAAC","sourcesContent":["/* Released under the BSD 2-Clause License\n *\n * Copyright © 2022-present, terrestris GmbH & Co. KG and GeoStyler contributors\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * * Redistributions of source code must retain the above copyright notice,\n * this list of conditions and the following disclaimer.\n *\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation\n * and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\n/**\n * Properties of a drag item.\n */\nexport type DragItem = {\n index: number;\n};\n\n/**\n * The drag orientation. Either dragging vertically or horizontally.\n */\nexport type DragOrientation = 'vertical' | 'horizontal';\n\n/**\n * The drag item type. Used for specifiying which\n * items can be dropped at which targets.\n */\nexport enum ItemType {\n SYMBOLIZER = 'SYMBOLIZER',\n RULE = 'RULE'\n}\n\n/**\n * The direction in which an item is being dragged.\n */\nexport enum Direction {\n /** Dragging to the left. */\n LEFT,\n /** Dragging to the right. */\n RIGHT,\n /** Dragging upwards. */\n UP,\n /** Dragging downwards. */\n DOWN\n}\n\n/**\n * The side on which an element was dropped.\n */\nexport enum Side {\n /** Dropping an element at the further away side in dragging direction. */\n BEHIND,\n /** Dropping an element at the nearer side in dragging direction. */\n BEFORE\n}\n\ntype GetDropSideParams = {\n /** The index of the drag item. */\n dragIndex: number;\n /** The index of the drop target. */\n dropIndex: number;\n /** The source of the drag item. */\n dragSource: number;\n /** The pixel ordinate of the drop target in drag orientation. */\n dropMiddle: number;\n};\n\ntype GetDragDirectionParams = {\n /** The index of the drag item. */\n dragIndex: number;\n /** The index of the drop target. */\n dropIndex: number;\n /** The orientation of the dragdrop. */\n dragOrientation: DragOrientation;\n};\n\n/**\n * @class DndUtil\n */\nclass DndUtil {\n\n /**\n * Move an element within an array in-place.\n *\n * @param from Index of the element to move.\n * @param to Target index.\n * @param arr Array in which the element is moved.\n */\n static moveElementInPlace = (from: number, to: number, arr: any[]) => {\n if (to >= arr.length) {\n var k = to - arr.length + 1;\n while (k--) {\n arr.push(undefined);\n }\n }\n arr.splice(to, 0, arr.splice(from, 1)[0]);\n };\n\n /**\n * Get the drop side of a drop event.\n *\n * @returns The side on which was dropped.\n */\n static getDropSide = ({dragIndex, dropIndex, dragSource, dropMiddle}: GetDropSideParams) => {\n let behind = true;\n // dragging right/down\n if (dragIndex < dropIndex && dragSource < dropMiddle) {\n behind = false;\n }\n\n // dragging left/up\n if (dragIndex > dropIndex && dragSource > dropMiddle) {\n behind = false;\n }\n\n return behind ? Side.BEHIND : Side.BEFORE;\n };\n\n /**\n * Get the direction of the dragging event.\n *\n * @returns The direction.\n */\n static getDragDirection = ({dragIndex, dropIndex, dragOrientation}: GetDragDirectionParams) => {\n if (dragOrientation === 'horizontal') {\n return dragIndex > dropIndex ? Direction.LEFT : Direction.RIGHT;\n } else {\n return dragIndex > dropIndex ? Direction.UP : Direction.DOWN;\n }\n };\n\n /**\n * Get the x value of the middle of the drop target.\n *\n * @param dropTargetBoundingRect The bounding rectangle of the drop target.\n * @returns The x value of the middle of the drop target.\n */\n static getDropMiddleX = (dropTargetBoundingRect: any) =>\n (dropTargetBoundingRect.right - dropTargetBoundingRect.left) / 2;\n\n /**\n * Get the y value of the middle of the drop target.\n *\n * @param dropTargetBoundingRect The bounding rectangle of the drop target.\n * @returns The y value of the middle of the drop target.\n */\n static getDropMiddleY = (dropTargetBoundingRect: any) =>\n (dropTargetBoundingRect.bottom - dropTargetBoundingRect.top) / 2;\n\n /**\n * Get the x value of the dragged element.\n *\n * @param clientOffset The client offset.\n * @param dropTargetBoundingRect The bounding rectangle of the drop target.\n * @returns The x value of the drag source.\n */\n static getDragSourceX = (clientOffset: any, dropTargetBoundingRect: any) =>\n clientOffset.x - dropTargetBoundingRect.left;\n\n /**\n * Get the y value of the dragged element.\n *\n * @param clientOffset The client offset.\n * @param dropTargetBoundingRect The bounding rectangle of the drop target.\n * @returns The y value of the drag source.\n */\n static getDragSourceY = (clientOffset: any, dropTargetBoundingRect: any) =>\n clientOffset.y - dropTargetBoundingRect.top;\n\n}\n\nexport default DndUtil;\n"]}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { Direction, DragOrientation, ItemType, Side } from '../Util/DndUtil';
|
|
3
|
-
export type OnDropParams = {
|
|
4
|
-
dragIndex: number;
|
|
5
|
-
dropIndex: number;
|
|
6
|
-
side: Side;
|
|
7
|
-
direction: Direction;
|
|
8
|
-
};
|
|
9
|
-
export interface UseDragDropParams {
|
|
10
|
-
itemType: ItemType;
|
|
11
|
-
position: number;
|
|
12
|
-
onDrop?: (opts: OnDropParams) => void;
|
|
13
|
-
showIndicator?: boolean;
|
|
14
|
-
dragOrientation?: DragOrientation;
|
|
15
|
-
}
|
|
16
|
-
export declare const useDragDrop: ({ position, itemType, onDrop, showIndicator, dragOrientation }: UseDragDropParams) => {
|
|
17
|
-
side: Side;
|
|
18
|
-
direction: Direction;
|
|
19
|
-
ref: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
20
|
-
}[];
|
package/dist/hook/UseDragDrop.js
DELETED
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.useDragDrop = void 0;
|
|
7
|
-
/* Released under the BSD 2-Clause License
|
|
8
|
-
*
|
|
9
|
-
* Copyright © 2022-present, terrestris GmbH & Co. KG and GeoStyler contributors
|
|
10
|
-
* All rights reserved.
|
|
11
|
-
*
|
|
12
|
-
* Redistribution and use in source and binary forms, with or without
|
|
13
|
-
* modification, are permitted provided that the following conditions are met:
|
|
14
|
-
*
|
|
15
|
-
* * Redistributions of source code must retain the above copyright notice,
|
|
16
|
-
* this list of conditions and the following disclaimer.
|
|
17
|
-
*
|
|
18
|
-
* * Redistributions in binary form must reproduce the above copyright notice,
|
|
19
|
-
* this list of conditions and the following disclaimer in the documentation
|
|
20
|
-
* and/or other materials provided with the distribution.
|
|
21
|
-
*
|
|
22
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
23
|
-
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
24
|
-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
25
|
-
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
26
|
-
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
27
|
-
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
28
|
-
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
29
|
-
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
30
|
-
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
31
|
-
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
32
|
-
* POSSIBILITY OF SUCH DAMAGE.
|
|
33
|
-
*/
|
|
34
|
-
var react_1 = require("react");
|
|
35
|
-
var react_dnd_1 = require("react-dnd");
|
|
36
|
-
var DndUtil_1 = __importDefault(require("../Util/DndUtil"));
|
|
37
|
-
var useDragDrop = function (_a) {
|
|
38
|
-
var position = _a.position, itemType = _a.itemType, _b = _a.onDrop, onDrop = _b === void 0 ? function () { } : _b, _c = _a.showIndicator, showIndicator = _c === void 0 ? true : _c, _d = _a.dragOrientation, dragOrientation = _d === void 0 ? 'horizontal' : _d;
|
|
39
|
-
var ref = (0, react_1.useRef)(null);
|
|
40
|
-
var _e = (0, react_dnd_1.useDrag)(function () { return ({
|
|
41
|
-
type: itemType,
|
|
42
|
-
item: {
|
|
43
|
-
index: position
|
|
44
|
-
}
|
|
45
|
-
}); }), drag = _e[1];
|
|
46
|
-
/**
|
|
47
|
-
* Handler for the horizontal drop event.
|
|
48
|
-
* Computes the dragging direction and drop side and calls onMove
|
|
49
|
-
* with given arguments.
|
|
50
|
-
*
|
|
51
|
-
* @param item The dragged item.
|
|
52
|
-
* @param monitor The dnd monitor.
|
|
53
|
-
*/
|
|
54
|
-
var dropHandlerHorizontal = function (item, monitor) {
|
|
55
|
-
if (!ref.current) {
|
|
56
|
-
return item;
|
|
57
|
-
}
|
|
58
|
-
var dragIndex = item.index;
|
|
59
|
-
var dropIndex = position;
|
|
60
|
-
if (dragIndex === dropIndex) {
|
|
61
|
-
return item;
|
|
62
|
-
}
|
|
63
|
-
var dropTargetBoundingRect = ref.current.getBoundingClientRect();
|
|
64
|
-
var clientOffset = monitor.getClientOffset();
|
|
65
|
-
var dropMiddleX = DndUtil_1.default.getDropMiddleX(dropTargetBoundingRect);
|
|
66
|
-
var dragSourceX = DndUtil_1.default.getDragSourceX(clientOffset, dropTargetBoundingRect);
|
|
67
|
-
var dropSide = DndUtil_1.default.getDropSide({
|
|
68
|
-
dragIndex: dragIndex,
|
|
69
|
-
dropIndex: dropIndex,
|
|
70
|
-
dragSource: dragSourceX,
|
|
71
|
-
dropMiddle: dropMiddleX
|
|
72
|
-
});
|
|
73
|
-
var dragDirection = DndUtil_1.default.getDragDirection({
|
|
74
|
-
dragIndex: dragIndex,
|
|
75
|
-
dropIndex: dropIndex,
|
|
76
|
-
dragOrientation: dragOrientation
|
|
77
|
-
});
|
|
78
|
-
onDrop({ dragIndex: dragIndex, dropIndex: dropIndex, side: dropSide, direction: dragDirection });
|
|
79
|
-
return item;
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* Handler for the vertical drop event.
|
|
83
|
-
* Computes the dragging direction and drop side and calls onMove
|
|
84
|
-
* with given arguments.
|
|
85
|
-
*
|
|
86
|
-
* @param item The dragged item.
|
|
87
|
-
* @param monitor The dnd monitor.
|
|
88
|
-
*/
|
|
89
|
-
var dropHandlerVertical = function (item, monitor) {
|
|
90
|
-
if (!ref.current) {
|
|
91
|
-
return item;
|
|
92
|
-
}
|
|
93
|
-
var dragIndex = item.index;
|
|
94
|
-
var dropIndex = position;
|
|
95
|
-
if (dragIndex === dropIndex) {
|
|
96
|
-
return item;
|
|
97
|
-
}
|
|
98
|
-
var dropTargetBoundingRect = ref.current.getBoundingClientRect();
|
|
99
|
-
var clientOffset = monitor.getClientOffset();
|
|
100
|
-
var dropMiddleY = DndUtil_1.default.getDropMiddleY(dropTargetBoundingRect);
|
|
101
|
-
var dragSourceY = DndUtil_1.default.getDragSourceY(clientOffset, dropTargetBoundingRect);
|
|
102
|
-
var dropSide = DndUtil_1.default.getDropSide({
|
|
103
|
-
dragIndex: dragIndex,
|
|
104
|
-
dropIndex: dropIndex,
|
|
105
|
-
dragSource: dragSourceY,
|
|
106
|
-
dropMiddle: dropMiddleY
|
|
107
|
-
});
|
|
108
|
-
var dragDirection = DndUtil_1.default.getDragDirection({
|
|
109
|
-
dragIndex: dragIndex,
|
|
110
|
-
dropIndex: dropIndex,
|
|
111
|
-
dragOrientation: dragOrientation
|
|
112
|
-
});
|
|
113
|
-
onDrop({ dragIndex: dragIndex, dropIndex: dropIndex, side: dropSide, direction: dragDirection });
|
|
114
|
-
return item;
|
|
115
|
-
};
|
|
116
|
-
/**
|
|
117
|
-
* Collect handler for vertical dragging event.
|
|
118
|
-
*
|
|
119
|
-
* Updates the props for dragging direction and drop side.
|
|
120
|
-
* This function will be called while dragging is still ongoing.
|
|
121
|
-
*
|
|
122
|
-
* @param monitor The dnd monitor.
|
|
123
|
-
* @returns The updated props for dragging direction and drop side.
|
|
124
|
-
*/
|
|
125
|
-
var collectHandlerIndicatorVertical = function (monitor) {
|
|
126
|
-
if (!ref.current || !monitor.isOver()) {
|
|
127
|
-
return {
|
|
128
|
-
direction: undefined,
|
|
129
|
-
side: undefined
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
var item = monitor.getItem();
|
|
133
|
-
if (!item) {
|
|
134
|
-
return {
|
|
135
|
-
direction: undefined,
|
|
136
|
-
side: undefined
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
var dragIndex = item.index;
|
|
140
|
-
var dropIndex = position;
|
|
141
|
-
if (dragIndex === dropIndex) {
|
|
142
|
-
return {
|
|
143
|
-
direction: undefined,
|
|
144
|
-
side: undefined
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
var dropTargetBoundingRect = ref.current.getBoundingClientRect();
|
|
148
|
-
var clientOffset = monitor.getClientOffset();
|
|
149
|
-
var dropMiddleY = DndUtil_1.default.getDropMiddleY(dropTargetBoundingRect);
|
|
150
|
-
var dragSourceY = DndUtil_1.default.getDragSourceY(clientOffset, dropTargetBoundingRect);
|
|
151
|
-
var dropSide = DndUtil_1.default.getDropSide({
|
|
152
|
-
dragIndex: dragIndex,
|
|
153
|
-
dropIndex: dropIndex,
|
|
154
|
-
dragSource: dragSourceY,
|
|
155
|
-
dropMiddle: dropMiddleY
|
|
156
|
-
});
|
|
157
|
-
var dragDirection = DndUtil_1.default.getDragDirection({
|
|
158
|
-
dragIndex: dragIndex,
|
|
159
|
-
dropIndex: dropIndex,
|
|
160
|
-
dragOrientation: dragOrientation
|
|
161
|
-
});
|
|
162
|
-
return {
|
|
163
|
-
direction: dragDirection,
|
|
164
|
-
side: dropSide
|
|
165
|
-
};
|
|
166
|
-
};
|
|
167
|
-
/**
|
|
168
|
-
* Collect handler for horizontal dragging event.
|
|
169
|
-
*
|
|
170
|
-
* Updates the props for dragging direction and drop side.
|
|
171
|
-
* This function will be called while dragging is still ongoing.
|
|
172
|
-
*
|
|
173
|
-
* @param monitor The dnd monitor.
|
|
174
|
-
* @returns The updated props for dragging direction and drop side.
|
|
175
|
-
*/
|
|
176
|
-
var collectHandlerIndicatorHorizontal = function (monitor) {
|
|
177
|
-
if (!ref.current || !monitor.isOver()) {
|
|
178
|
-
return {
|
|
179
|
-
direction: undefined,
|
|
180
|
-
side: undefined
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
var item = monitor.getItem();
|
|
184
|
-
if (!item) {
|
|
185
|
-
return {
|
|
186
|
-
direction: undefined,
|
|
187
|
-
side: undefined
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
var dragIndex = item.index;
|
|
191
|
-
var dropIndex = position;
|
|
192
|
-
if (dragIndex === dropIndex) {
|
|
193
|
-
return {
|
|
194
|
-
direction: undefined,
|
|
195
|
-
side: undefined
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
var dropTargetBoundingRect = ref.current.getBoundingClientRect();
|
|
199
|
-
var clientOffset = monitor.getClientOffset();
|
|
200
|
-
var dropMiddleX = DndUtil_1.default.getDropMiddleX(dropTargetBoundingRect);
|
|
201
|
-
var dragSourceX = DndUtil_1.default.getDragSourceX(clientOffset, dropTargetBoundingRect);
|
|
202
|
-
var dropSide = DndUtil_1.default.getDropSide({
|
|
203
|
-
dragIndex: dragIndex,
|
|
204
|
-
dropIndex: dropIndex,
|
|
205
|
-
dragSource: dragSourceX,
|
|
206
|
-
dropMiddle: dropMiddleX
|
|
207
|
-
});
|
|
208
|
-
var dragDirection = DndUtil_1.default.getDragDirection({
|
|
209
|
-
dragIndex: dragIndex,
|
|
210
|
-
dropIndex: dropIndex,
|
|
211
|
-
dragOrientation: dragOrientation
|
|
212
|
-
});
|
|
213
|
-
return {
|
|
214
|
-
direction: dragDirection,
|
|
215
|
-
side: dropSide
|
|
216
|
-
};
|
|
217
|
-
};
|
|
218
|
-
var _f = (0, react_dnd_1.useDrop)(function () {
|
|
219
|
-
var dropHandler = dragOrientation === 'horizontal' ? dropHandlerHorizontal : dropHandlerVertical;
|
|
220
|
-
var dropConfig = {
|
|
221
|
-
accept: itemType,
|
|
222
|
-
drop: dropHandler
|
|
223
|
-
};
|
|
224
|
-
if (showIndicator) {
|
|
225
|
-
var collectHandler = dragOrientation === 'horizontal' ?
|
|
226
|
-
collectHandlerIndicatorHorizontal : collectHandlerIndicatorVertical;
|
|
227
|
-
dropConfig.collect = collectHandler;
|
|
228
|
-
}
|
|
229
|
-
return dropConfig;
|
|
230
|
-
}), _g = _f[0], side = _g.side, direction = _g.direction, drop = _f[1];
|
|
231
|
-
return [{
|
|
232
|
-
side: side,
|
|
233
|
-
direction: direction,
|
|
234
|
-
ref: drag(drop(ref))
|
|
235
|
-
}];
|
|
236
|
-
};
|
|
237
|
-
exports.useDragDrop = useDragDrop;
|
|
238
|
-
//# sourceMappingURL=UseDragDrop.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UseDragDrop.js","sourceRoot":"","sources":["../../src/hook/UseDragDrop.tsx"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,+BAA+B;AAC/B,uCAAoF;AACpF,4DAAgG;AAiBzF,IAAM,WAAW,GAAG,UAAC,EAMR;QALlB,QAAQ,cAAA,EACR,QAAQ,cAAA,EACR,cAAiB,EAAjB,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qB,CAAC,CAAC,CAAC,mBAAmB,CAAC;QAEnG,IAAM,UAAU,GAA+E;YAC7F,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,WAAW;SAClB,CAAC;QAEF,IAAI,aAAa,EAAE;YACjB,IAAM,cAAc,GAAG,eAAe,KAAK,YAAY,CAAC,CAAC;gBACvD,iCAAiC,CAAC,CAAC,CAAC,+BAA+B,CAAC;YAEtE,UAAU,CAAC,OAAO,GAAG,cAAc,CAAC;SACrC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC,EAhBK,UAAiB,EAAhB,IAAI,UAAA,EAAE,SAAS,eAAA,EAAG,IAAI,QAgB5B,CAAC;IAEH,OAAO,CAAC;YACN,IAAI,MAAA;YACJ,SAAS,WAAA;YACT,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACrB,CAAC,CAAC;AACL,CAAC,CAAC;AAnPW,QAAA,WAAW,eAmPtB","sourcesContent":["/* Released under the BSD 2-Clause License\n *\n * Copyright © 2022-present, terrestris GmbH & Co. KG and GeoStyler contributors\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * * Redistributions of source code must retain the above copyright notice,\n * this list of conditions and the following disclaimer.\n *\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation\n * and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\nimport { useRef } from 'react';\nimport { useDrag, useDrop, DropTargetMonitor, DropTargetHookSpec } from 'react-dnd';\nimport DndUtil, { Direction, DragOrientation, DragItem, ItemType, Side } from '../Util/DndUtil';\n\nexport type OnDropParams = {\n dragIndex: number;\n dropIndex: number;\n side: Side;\n direction: Direction;\n};\n\nexport interface UseDragDropParams {\n itemType: ItemType;\n position: number;\n onDrop?: (opts: OnDropParams) => void;\n showIndicator?: boolean;\n dragOrientation?: DragOrientation;\n}\n\nexport const useDragDrop = ({\n position,\n itemType,\n onDrop = () => {},\n showIndicator = true,\n dragOrientation = 'horizontal'\n}: UseDragDropParams) => {\n\n const ref = useRef(null);\n\n const [, drag] = useDrag(() => ({\n type: itemType,\n item: {\n index: position\n }\n }));\n\n /**\n * Handler for the horizontal drop event.\n * Computes the dragging direction and drop side and calls onMove\n * with given arguments.\n *\n * @param item The dragged item.\n * @param monitor The dnd monitor.\n */\n const dropHandlerHorizontal = (item: DragItem, monitor: DropTargetMonitor<DragItem, DragItem>) => {\n if (!ref.current) {\n return item;\n }\n\n const dragIndex = item.index;\n const dropIndex = position;\n\n if (dragIndex === dropIndex) {\n return item;\n }\n\n const dropTargetBoundingRect = ref.current.getBoundingClientRect();\n const clientOffset = monitor.getClientOffset();\n\n const dropMiddleX = DndUtil.getDropMiddleX(dropTargetBoundingRect);\n const dragSourceX = DndUtil.getDragSourceX(clientOffset, dropTargetBoundingRect);\n\n const dropSide = DndUtil.getDropSide({\n dragIndex,\n dropIndex,\n dragSource: dragSourceX,\n dropMiddle: dropMiddleX\n });\n const dragDirection = DndUtil.getDragDirection({\n dragIndex,\n dropIndex,\n dragOrientation\n });\n\n onDrop({dragIndex, dropIndex, side: dropSide, direction: dragDirection});\n return item;\n };\n\n /**\n * Handler for the vertical drop event.\n * Computes the dragging direction and drop side and calls onMove\n * with given arguments.\n *\n * @param item The dragged item.\n * @param monitor The dnd monitor.\n */\n const dropHandlerVertical = (item: DragItem, monitor: DropTargetMonitor<DragItem, DragItem>) => {\n if (!ref.current) {\n return item;\n }\n\n const dragIndex = item.index;\n const dropIndex = position;\n\n if (dragIndex === dropIndex) {\n return item;\n }\n\n const dropTargetBoundingRect = ref.current.getBoundingClientRect();\n const clientOffset = monitor.getClientOffset();\n\n const dropMiddleY = DndUtil.getDropMiddleY(dropTargetBoundingRect);\n const dragSourceY = DndUtil.getDragSourceY(clientOffset, dropTargetBoundingRect);\n\n const dropSide = DndUtil.getDropSide({\n dragIndex,\n dropIndex,\n dragSource: dragSourceY,\n dropMiddle: dropMiddleY\n });\n const dragDirection = DndUtil.getDragDirection({\n dragIndex,\n dropIndex,\n dragOrientation\n });\n\n onDrop({dragIndex, dropIndex, side: dropSide, direction: dragDirection});\n return item;\n };\n\n /**\n * Collect handler for vertical dragging event.\n *\n * Updates the props for dragging direction and drop side.\n * This function will be called while dragging is still ongoing.\n *\n * @param monitor The dnd monitor.\n * @returns The updated props for dragging direction and drop side.\n */\n const collectHandlerIndicatorVertical = (monitor: DropTargetMonitor<DragItem, unknown>) => {\n if (!ref.current || !monitor.isOver()) {\n return {\n direction: undefined,\n side: undefined\n };\n }\n\n const item = monitor.getItem();\n if (!item) {\n return {\n direction: undefined,\n side: undefined\n };\n }\n\n const dragIndex = item.index;\n const dropIndex = position;\n\n if (dragIndex === dropIndex) {\n return {\n direction: undefined,\n side: undefined\n };\n }\n\n const dropTargetBoundingRect = ref.current.getBoundingClientRect();\n const clientOffset = monitor.getClientOffset();\n\n const dropMiddleY = DndUtil.getDropMiddleY(dropTargetBoundingRect);\n const dragSourceY = DndUtil.getDragSourceY(clientOffset, dropTargetBoundingRect);\n\n const dropSide = DndUtil.getDropSide({\n dragIndex,\n dropIndex,\n dragSource: dragSourceY,\n dropMiddle: dropMiddleY\n });\n const dragDirection = DndUtil.getDragDirection({\n dragIndex,\n dropIndex,\n dragOrientation\n });\n\n return {\n direction: dragDirection,\n side: dropSide\n };\n };\n\n /**\n * Collect handler for horizontal dragging event.\n *\n * Updates the props for dragging direction and drop side.\n * This function will be called while dragging is still ongoing.\n *\n * @param monitor The dnd monitor.\n * @returns The updated props for dragging direction and drop side.\n */\n const collectHandlerIndicatorHorizontal = (monitor: DropTargetMonitor<DragItem, unknown>) => {\n if (!ref.current || !monitor.isOver()) {\n return {\n direction: undefined,\n side: undefined\n };\n }\n\n const item = monitor.getItem();\n if (!item) {\n return {\n direction: undefined,\n side: undefined\n };\n }\n\n const dragIndex = item.index;\n const dropIndex = position;\n\n if (dragIndex === dropIndex) {\n return {\n direction: undefined,\n side: undefined\n };\n }\n\n const dropTargetBoundingRect = ref.current.getBoundingClientRect();\n const clientOffset = monitor.getClientOffset();\n\n const dropMiddleX = DndUtil.getDropMiddleX(dropTargetBoundingRect);\n const dragSourceX = DndUtil.getDragSourceX(clientOffset, dropTargetBoundingRect);\n\n const dropSide = DndUtil.getDropSide({\n dragIndex,\n dropIndex,\n dragSource: dragSourceX,\n dropMiddle: dropMiddleX\n });\n const dragDirection = DndUtil.getDragDirection({\n dragIndex,\n dropIndex,\n dragOrientation\n });\n\n return {\n direction: dragDirection,\n side: dropSide\n };\n };\n\n\n const [{side, direction}, drop] = useDrop(() => {\n const dropHandler = dragOrientation === 'horizontal' ? dropHandlerHorizontal : dropHandlerVertical;\n\n const dropConfig: DropTargetHookSpec<DragItem, DragItem, {side: Side; direction: Direction}> = {\n accept: itemType,\n drop: dropHandler\n };\n\n if (showIndicator) {\n const collectHandler = dragOrientation === 'horizontal' ?\n collectHandlerIndicatorHorizontal : collectHandlerIndicatorVertical;\n\n dropConfig.collect = collectHandler;\n }\n\n return dropConfig;\n });\n\n return [{\n side,\n direction,\n ref: drag(drop(ref))\n }];\n};\n"]}
|