@elliemae/ds-drag-and-drop 2.2.0-alpha.2 → 2.2.0-beta.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/cjs/hierarchy/customCollisionDetection.js +50 -44
- package/cjs/hierarchy/getHierarchyKeyboardCoordinates.js +91 -78
- package/cjs/hierarchy/index.js +9 -28
- package/cjs/hierarchy/types.js +2 -27
- package/cjs/hierarchy/useHierarchyActionHandlers.js +35 -53
- package/cjs/hierarchy/useHierarchyAnnouncements.js +26 -45
- package/cjs/hierarchy/useHierarchyDndkitConfig.js +83 -77
- package/cjs/hierarchy/useHierarchyPreviewHandlers.js +27 -48
- package/cjs/index.js +11 -29
- package/cjs/tree/constants.js +12 -41
- package/cjs/tree/customCollisionDetection.js +95 -64
- package/cjs/tree/getTreeKeyboardCoordinates.js +101 -87
- package/cjs/tree/index.js +9 -28
- package/cjs/tree/types.js +2 -27
- package/cjs/tree/useTreeActionHandlers.js +56 -66
- package/cjs/tree/useTreeAnnouncements.js +40 -53
- package/cjs/tree/useTreeDndkitConfig.js +91 -95
- package/cjs/tree/useTreePreviewHandlers.js +37 -53
- package/cjs/tree/utilities.js +30 -44
- package/esm/hierarchy/customCollisionDetection.js +46 -15
- package/esm/hierarchy/getHierarchyKeyboardCoordinates.js +76 -42
- package/esm/hierarchy/index.js +1 -3
- package/esm/hierarchy/types.js +1 -2
- package/esm/hierarchy/useHierarchyActionHandlers.js +31 -24
- package/esm/hierarchy/useHierarchyAnnouncements.js +20 -14
- package/esm/hierarchy/useHierarchyDndkitConfig.js +66 -45
- package/esm/hierarchy/useHierarchyPreviewHandlers.js +19 -15
- package/esm/index.js +2 -4
- package/esm/tree/constants.js +10 -12
- package/esm/tree/customCollisionDetection.js +89 -33
- package/esm/tree/getTreeKeyboardCoordinates.js +84 -49
- package/esm/tree/index.js +1 -3
- package/esm/tree/types.js +1 -2
- package/esm/tree/useTreeActionHandlers.js +50 -35
- package/esm/tree/useTreeAnnouncements.js +30 -18
- package/esm/tree/useTreeDndkitConfig.js +70 -59
- package/esm/tree/useTreePreviewHandlers.js +28 -19
- package/esm/tree/utilities.js +23 -13
- package/package.json +1 -1
- package/cjs/hierarchy/customCollisionDetection.js.map +0 -7
- package/cjs/hierarchy/getHierarchyKeyboardCoordinates.js.map +0 -7
- package/cjs/hierarchy/index.js.map +0 -7
- package/cjs/hierarchy/types.js.map +0 -7
- package/cjs/hierarchy/useHierarchyActionHandlers.js.map +0 -7
- package/cjs/hierarchy/useHierarchyAnnouncements.js.map +0 -7
- package/cjs/hierarchy/useHierarchyDndkitConfig.js.map +0 -7
- package/cjs/hierarchy/useHierarchyPreviewHandlers.js.map +0 -7
- package/cjs/index.js.map +0 -7
- package/cjs/tree/constants.js.map +0 -7
- package/cjs/tree/customCollisionDetection.js.map +0 -7
- package/cjs/tree/getTreeKeyboardCoordinates.js.map +0 -7
- package/cjs/tree/index.js.map +0 -7
- package/cjs/tree/types.js.map +0 -7
- package/cjs/tree/useTreeActionHandlers.js.map +0 -7
- package/cjs/tree/useTreeAnnouncements.js.map +0 -7
- package/cjs/tree/useTreeDndkitConfig.js.map +0 -7
- package/cjs/tree/useTreePreviewHandlers.js.map +0 -7
- package/cjs/tree/utilities.js.map +0 -7
- package/esm/hierarchy/customCollisionDetection.js.map +0 -7
- package/esm/hierarchy/getHierarchyKeyboardCoordinates.js.map +0 -7
- package/esm/hierarchy/index.js.map +0 -7
- package/esm/hierarchy/types.js.map +0 -7
- package/esm/hierarchy/useHierarchyActionHandlers.js.map +0 -7
- package/esm/hierarchy/useHierarchyAnnouncements.js.map +0 -7
- package/esm/hierarchy/useHierarchyDndkitConfig.js.map +0 -7
- package/esm/hierarchy/useHierarchyPreviewHandlers.js.map +0 -7
- package/esm/index.js.map +0 -7
- package/esm/tree/constants.js.map +0 -7
- package/esm/tree/customCollisionDetection.js.map +0 -7
- package/esm/tree/getTreeKeyboardCoordinates.js.map +0 -7
- package/esm/tree/index.js.map +0 -7
- package/esm/tree/types.js.map +0 -7
- package/esm/tree/useTreeActionHandlers.js.map +0 -7
- package/esm/tree/useTreeAnnouncements.js.map +0 -7
- package/esm/tree/useTreeDndkitConfig.js.map +0 -7
- package/esm/tree/useTreePreviewHandlers.js.map +0 -7
- package/esm/tree/utilities.js.map +0 -7
|
@@ -1,53 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (!originalRect)
|
|
38
|
-
return null;
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
8
|
+
require('core-js/modules/esnext.async-iterator.find.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.find.js');
|
|
10
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
11
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
12
|
+
|
|
13
|
+
const customCollisionDetection = (activeId, activeParent, dndItems) => _ref => {
|
|
14
|
+
var _originalContainer$re;
|
|
15
|
+
|
|
16
|
+
let {
|
|
17
|
+
droppableContainers,
|
|
18
|
+
collisionRect
|
|
19
|
+
} = _ref;
|
|
20
|
+
const entriesWithSameParent = droppableContainers.filter(_ref2 => {
|
|
21
|
+
var _dndItems$find;
|
|
22
|
+
|
|
23
|
+
let {
|
|
24
|
+
id
|
|
25
|
+
} = _ref2;
|
|
26
|
+
return ((_dndItems$find = dndItems.find(item => item.id === id)) === null || _dndItems$find === void 0 ? void 0 : _dndItems$find.parentId) === activeParent;
|
|
27
|
+
});
|
|
28
|
+
const originalContainer = entriesWithSameParent.find(_ref3 => {
|
|
29
|
+
let {
|
|
30
|
+
id
|
|
31
|
+
} = _ref3;
|
|
32
|
+
return id === activeId;
|
|
33
|
+
});
|
|
34
|
+
const originalRect = originalContainer === null || originalContainer === void 0 ? void 0 : (_originalContainer$re = originalContainer.rect) === null || _originalContainer$re === void 0 ? void 0 : _originalContainer$re.current;
|
|
35
|
+
if (!originalRect) return null;
|
|
36
|
+
|
|
39
37
|
if (originalRect.offsetLeft <= collisionRect.offsetLeft && collisionRect.offsetLeft <= originalRect.offsetLeft + originalRect.width) {
|
|
40
38
|
return originalContainer.id;
|
|
41
39
|
}
|
|
40
|
+
|
|
42
41
|
const isLeft = collisionRect.offsetLeft <= originalRect.offsetLeft + collisionRect.width / 2 + 5;
|
|
43
|
-
let match = null;
|
|
42
|
+
let match = null; // If going to the left, search the closest offset left
|
|
43
|
+
// Otherwise, get the closest offset right
|
|
44
|
+
|
|
44
45
|
const collisionPoint = collisionRect.offsetLeft + collisionRect.width / 2;
|
|
45
|
-
entriesWithSameParent.forEach(
|
|
46
|
+
entriesWithSameParent.forEach(entry => {
|
|
46
47
|
const {
|
|
47
|
-
rect: {
|
|
48
|
+
rect: {
|
|
49
|
+
current: rect
|
|
50
|
+
}
|
|
48
51
|
} = entry;
|
|
52
|
+
|
|
49
53
|
if (rect !== null) {
|
|
50
54
|
const offsetRight = rect.offsetLeft + rect.width;
|
|
55
|
+
|
|
51
56
|
if (!match) {
|
|
52
57
|
match = entry;
|
|
53
58
|
} else if (match && match.rect.current && isLeft && Math.abs(collisionPoint - rect.offsetLeft) <= Math.abs(collisionPoint - match.rect.current.offsetLeft)) {
|
|
@@ -56,9 +61,10 @@ const customCollisionDetection = (activeId, activeParent, dndItems) => ({ droppa
|
|
|
56
61
|
match = entry;
|
|
57
62
|
}
|
|
58
63
|
}
|
|
59
|
-
});
|
|
64
|
+
}); // Typescript believes match is always null for some reason
|
|
65
|
+
|
|
60
66
|
const matchCastedForSomeReason = match;
|
|
61
67
|
return matchCastedForSomeReason === null ? null : matchCastedForSomeReason.id;
|
|
62
68
|
};
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
|
|
70
|
+
exports.customCollisionDetection = customCollisionDetection;
|
|
@@ -1,92 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
active
|
|
39
|
-
over,
|
|
40
|
-
event,
|
|
41
|
-
currentCoordinates,
|
|
42
|
-
droppableContainers,
|
|
43
|
-
collisionRect
|
|
44
|
-
}) => {
|
|
45
|
-
if (vertical.includes(event.code) || !active || !over)
|
|
46
|
-
return void 0;
|
|
47
|
-
const activeItem = items.find((item) => item.id === active.id);
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
|
+
require('core-js/modules/esnext.async-iterator.find.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
8
|
+
require('core-js/modules/esnext.iterator.find.js');
|
|
9
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
10
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
11
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
12
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
13
|
+
var core = require('@dnd-kit/core');
|
|
14
|
+
|
|
15
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
16
|
+
|
|
17
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
18
|
+
|
|
19
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
20
|
+
|
|
21
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
22
|
+
const directions = [core.KeyboardCode.Down, core.KeyboardCode.Right, core.KeyboardCode.Up, core.KeyboardCode.Left];
|
|
23
|
+
const vertical = [core.KeyboardCode.Up, core.KeyboardCode.Down];
|
|
24
|
+
|
|
25
|
+
const getHorizontalKeyboardCoordinates = _ref => {
|
|
26
|
+
var _droppableContainers$, _droppableContainers$2, _droppableContainers$3, _droppableContainers$4;
|
|
27
|
+
|
|
28
|
+
let {
|
|
29
|
+
items,
|
|
30
|
+
active,
|
|
31
|
+
over,
|
|
32
|
+
event,
|
|
33
|
+
currentCoordinates,
|
|
34
|
+
droppableContainers,
|
|
35
|
+
collisionRect
|
|
36
|
+
} = _ref;
|
|
37
|
+
if (vertical.includes(event.code) || !active || !over) return undefined;
|
|
38
|
+
const activeItem = items.find(item => item.id === active.id);
|
|
48
39
|
const overRect = over.rect;
|
|
49
|
-
const layoutRects = [];
|
|
50
|
-
|
|
51
|
-
|
|
40
|
+
const layoutRects = []; // Get the reacheable rects depending on the arrow key pressed
|
|
41
|
+
|
|
42
|
+
droppableContainers.forEach(container => {
|
|
43
|
+
var _items$find;
|
|
44
|
+
|
|
45
|
+
if (container !== null && container !== void 0 && container.disabled || !overRect) {
|
|
52
46
|
return;
|
|
53
47
|
}
|
|
54
|
-
|
|
48
|
+
|
|
49
|
+
const node = container === null || container === void 0 ? void 0 : container.node.current;
|
|
50
|
+
|
|
55
51
|
if (!node) {
|
|
56
52
|
return;
|
|
57
53
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const rect =
|
|
62
|
-
|
|
54
|
+
|
|
55
|
+
const itemParent = (_items$find = items.find(item => item.id === container.id)) === null || _items$find === void 0 ? void 0 : _items$find.parentId;
|
|
56
|
+
if (itemParent !== (activeItem === null || activeItem === void 0 ? void 0 : activeItem.parentId)) return;
|
|
57
|
+
const rect = core.getViewRect(node);
|
|
58
|
+
|
|
59
|
+
if (event.code === core.KeyboardCode.Left && collisionRect.left > rect.right - 10) {
|
|
63
60
|
layoutRects.push(container);
|
|
64
|
-
} else if (event.code ===
|
|
61
|
+
} else if (event.code === core.KeyboardCode.Right && collisionRect.left < rect.left) {
|
|
65
62
|
layoutRects.push(container);
|
|
66
63
|
}
|
|
67
64
|
});
|
|
68
|
-
const closestId =
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if (!
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
65
|
+
const closestId = core.closestCorners({
|
|
66
|
+
droppableContainers: layoutRects,
|
|
67
|
+
collisionRect,
|
|
68
|
+
active
|
|
69
|
+
});
|
|
70
|
+
if (!closestId) return undefined;
|
|
71
|
+
const closestDroppableContainer = (_droppableContainers$ = droppableContainers.get(closestId)) === null || _droppableContainers$ === void 0 ? void 0 : (_droppableContainers$2 = _droppableContainers$.node) === null || _droppableContainers$2 === void 0 ? void 0 : _droppableContainers$2.current;
|
|
72
|
+
const activeDroppableContainer = (_droppableContainers$3 = droppableContainers.get(active === null || active === void 0 ? void 0 : active.id)) === null || _droppableContainers$3 === void 0 ? void 0 : (_droppableContainers$4 = _droppableContainers$3.node) === null || _droppableContainers$4 === void 0 ? void 0 : _droppableContainers$4.current;
|
|
73
|
+
if (!closestDroppableContainer || !activeDroppableContainer) return undefined;
|
|
74
|
+
const closestRect = core.getViewRect(closestDroppableContainer);
|
|
75
|
+
const activeRect = core.getViewRect(activeDroppableContainer);
|
|
76
|
+
return _objectSpread(_objectSpread({}, currentCoordinates), {}, {
|
|
79
77
|
x: closestRect.left + (closestRect.width - collisionRect.width) / 2 + (closestRect.offsetLeft < activeRect.left ? -1 : 1)
|
|
80
|
-
};
|
|
78
|
+
});
|
|
81
79
|
};
|
|
82
|
-
|
|
80
|
+
|
|
81
|
+
const getHierarchyKeyboardCoordinates = (context, dragOverlayDataTestid, isHorizontalDnD) => (event, _ref2) => {
|
|
82
|
+
let {
|
|
83
|
+
currentCoordinates,
|
|
84
|
+
context: {
|
|
85
|
+
active,
|
|
86
|
+
over,
|
|
87
|
+
collisionRect,
|
|
88
|
+
droppableContainers
|
|
89
|
+
}
|
|
90
|
+
} = _ref2;
|
|
91
|
+
|
|
83
92
|
if (directions.includes(event.code)) {
|
|
84
93
|
event.preventDefault();
|
|
94
|
+
|
|
85
95
|
if (!collisionRect) {
|
|
86
|
-
return
|
|
96
|
+
return undefined;
|
|
87
97
|
}
|
|
98
|
+
|
|
88
99
|
const {
|
|
89
|
-
current: {
|
|
100
|
+
current: {
|
|
101
|
+
items
|
|
102
|
+
}
|
|
90
103
|
} = context;
|
|
91
104
|
const args = {
|
|
92
105
|
dragOverlayDataTestid,
|
|
@@ -98,11 +111,11 @@ const getHierarchyKeyboardCoordinates = (context, dragOverlayDataTestid, isHoriz
|
|
|
98
111
|
droppableContainers,
|
|
99
112
|
collisionRect
|
|
100
113
|
};
|
|
101
|
-
if (isHorizontalDnD)
|
|
102
|
-
|
|
103
|
-
return void 0;
|
|
114
|
+
if (isHorizontalDnD) return getHorizontalKeyboardCoordinates(args);
|
|
115
|
+
return undefined;
|
|
104
116
|
}
|
|
105
|
-
|
|
117
|
+
|
|
118
|
+
return undefined;
|
|
106
119
|
};
|
|
107
|
-
|
|
108
|
-
|
|
120
|
+
|
|
121
|
+
exports.getHierarchyKeyboardCoordinates = getHierarchyKeyboardCoordinates;
|
package/cjs/hierarchy/index.js
CHANGED
|
@@ -1,28 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
for (let key of __getOwnPropNames(module2))
|
|
11
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
12
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
13
|
-
}
|
|
14
|
-
return target;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (module2, isNodeMode) => {
|
|
17
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
20
|
-
return (module2, temp) => {
|
|
21
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
22
|
-
};
|
|
23
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
24
|
-
var hierarchy_exports = {};
|
|
25
|
-
var React = __toESM(require("react"));
|
|
26
|
-
__reExport(hierarchy_exports, __toESM(require("./useHierarchyDndkitConfig")));
|
|
27
|
-
module.exports = __toCommonJS(hierarchy_exports);
|
|
28
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var useHierarchyDndkitConfig = require('./useHierarchyDndkitConfig.js');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.useHierarchyDndkitConfig = useHierarchyDndkitConfig.useHierarchyDndkitConfig;
|
package/cjs/hierarchy/types.js
CHANGED
|
@@ -1,27 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
-
var __reExport = (target, module2, copyDefault, desc) => {
|
|
9
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
10
|
-
for (let key of __getOwnPropNames(module2))
|
|
11
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
12
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
13
|
-
}
|
|
14
|
-
return target;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (module2, isNodeMode) => {
|
|
17
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
20
|
-
return (module2, temp) => {
|
|
21
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
22
|
-
};
|
|
23
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
24
|
-
var types_exports = {};
|
|
25
|
-
var React = __toESM(require("react"));
|
|
26
|
-
module.exports = __toCommonJS(types_exports);
|
|
27
|
-
//# sourceMappingURL=types.js.map
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
@@ -1,68 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (module2, isNodeMode) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var useHierarchyActionHandlers_exports = {};
|
|
29
|
-
__export(useHierarchyActionHandlers_exports, {
|
|
30
|
-
useHierarchyActionHandlers: () => useHierarchyActionHandlers
|
|
31
|
-
});
|
|
32
|
-
var React = __toESM(require("react"));
|
|
33
|
-
var import_react = __toESM(require("react"));
|
|
34
|
-
const useHierarchyActionHandlers = ({
|
|
35
|
-
handlePreviewDragStart,
|
|
36
|
-
handlePreviewDragMove,
|
|
37
|
-
handlePreviewDragEnd,
|
|
38
|
-
handlePreviewDragCancel,
|
|
39
|
-
onReorder,
|
|
40
|
-
dndItems
|
|
41
|
-
}) => {
|
|
42
|
-
const onDragStart = (0, import_react.useCallback)((e) => {
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var react = require('react');
|
|
6
|
+
|
|
7
|
+
const useHierarchyActionHandlers = _ref => {
|
|
8
|
+
let {
|
|
9
|
+
handlePreviewDragStart,
|
|
10
|
+
handlePreviewDragMove,
|
|
11
|
+
handlePreviewDragEnd,
|
|
12
|
+
handlePreviewDragCancel,
|
|
13
|
+
onReorder,
|
|
14
|
+
dndItems
|
|
15
|
+
} = _ref;
|
|
16
|
+
const onDragStart = react.useCallback(e => {
|
|
43
17
|
handlePreviewDragStart(e);
|
|
44
18
|
}, [handlePreviewDragStart]);
|
|
45
|
-
const onDragMove =
|
|
19
|
+
const onDragMove = react.useCallback(e => {
|
|
46
20
|
handlePreviewDragMove(e);
|
|
47
21
|
}, [handlePreviewDragMove]);
|
|
48
|
-
const onDragEnd =
|
|
22
|
+
const onDragEnd = react.useCallback(e => {
|
|
49
23
|
handlePreviewDragEnd(e);
|
|
50
|
-
const {
|
|
51
|
-
|
|
52
|
-
|
|
24
|
+
const {
|
|
25
|
+
active,
|
|
26
|
+
over
|
|
27
|
+
} = e;
|
|
28
|
+
if (!over) return;
|
|
29
|
+
|
|
53
30
|
if (active.id !== over.id) {
|
|
54
|
-
const activeIndex = dndItems.findIndex(
|
|
55
|
-
const overIndex = dndItems.findIndex(
|
|
31
|
+
const activeIndex = dndItems.findIndex(item => item.id === active.id);
|
|
32
|
+
const overIndex = dndItems.findIndex(item => item.id === over.id);
|
|
56
33
|
onReorder(dndItems[activeIndex], {
|
|
57
34
|
targetIndex: overIndex,
|
|
58
35
|
fromIndex: activeIndex
|
|
59
36
|
});
|
|
60
37
|
}
|
|
61
38
|
}, [handlePreviewDragEnd, dndItems, onReorder]);
|
|
62
|
-
const onDragCancel =
|
|
39
|
+
const onDragCancel = react.useCallback(e => {
|
|
63
40
|
handlePreviewDragCancel(e);
|
|
64
41
|
}, [handlePreviewDragCancel]);
|
|
65
|
-
return {
|
|
42
|
+
return {
|
|
43
|
+
onDragStart,
|
|
44
|
+
onDragMove,
|
|
45
|
+
onDragEnd,
|
|
46
|
+
onDragCancel
|
|
47
|
+
};
|
|
66
48
|
};
|
|
67
|
-
|
|
68
|
-
|
|
49
|
+
|
|
50
|
+
exports.useHierarchyActionHandlers = useHierarchyActionHandlers;
|
|
@@ -1,55 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (module2, isNodeMode) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var useHierarchyAnnouncements_exports = {};
|
|
29
|
-
__export(useHierarchyAnnouncements_exports, {
|
|
30
|
-
useHierarchyAnnouncements: () => useHierarchyAnnouncements
|
|
31
|
-
});
|
|
32
|
-
var React = __toESM(require("react"));
|
|
33
|
-
var import_react = __toESM(require("react"));
|
|
34
|
-
const useHierarchyAnnouncements = (visibleItemsDictionary) => {
|
|
35
|
-
const onDragStart = (0, import_react.useCallback)((id) => `Picked up draggable item from position ${visibleItemsDictionary[id].index + 1}.`, [visibleItemsDictionary]);
|
|
36
|
-
const onDragMove = (0, import_react.useCallback)((id, overId) => {
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var react = require('react');
|
|
6
|
+
|
|
7
|
+
const useHierarchyAnnouncements = visibleItemsDictionary => {
|
|
8
|
+
const onDragStart = react.useCallback(id => "Picked up draggable item from position ".concat(visibleItemsDictionary[id].index + 1, "."), [visibleItemsDictionary]);
|
|
9
|
+
const onDragMove = react.useCallback((id, overId) => {
|
|
37
10
|
if (overId) {
|
|
38
11
|
const overIndex = visibleItemsDictionary[overId].index + 1;
|
|
39
|
-
return
|
|
12
|
+
return "Draggable item was moved to position ".concat(overIndex, ".");
|
|
40
13
|
}
|
|
41
|
-
|
|
14
|
+
|
|
15
|
+
return "Draggable item is no longer over a droppable area.";
|
|
42
16
|
}, [visibleItemsDictionary]);
|
|
43
17
|
const onDragOver = onDragMove;
|
|
44
|
-
const onDragEnd =
|
|
18
|
+
const onDragEnd = react.useCallback((id, overId) => {
|
|
45
19
|
if (overId) {
|
|
46
20
|
const overIndex = visibleItemsDictionary[overId].index + 1;
|
|
47
|
-
return
|
|
21
|
+
return "Draggable item was dropped over position ".concat(overIndex, ".");
|
|
48
22
|
}
|
|
49
|
-
|
|
23
|
+
|
|
24
|
+
return "Draggable item was dropped at it's original position.";
|
|
50
25
|
}, [visibleItemsDictionary]);
|
|
51
|
-
const onDragCancel =
|
|
52
|
-
return {
|
|
26
|
+
const onDragCancel = react.useCallback(id => "Dragging was cancelled. Draggable item from position ".concat(visibleItemsDictionary[id].index + 1, " was dropped at it's initial position."), [visibleItemsDictionary]);
|
|
27
|
+
return {
|
|
28
|
+
onDragStart,
|
|
29
|
+
onDragOver,
|
|
30
|
+
onDragMove,
|
|
31
|
+
onDragEnd,
|
|
32
|
+
onDragCancel
|
|
33
|
+
};
|
|
53
34
|
};
|
|
54
|
-
|
|
55
|
-
|
|
35
|
+
|
|
36
|
+
exports.useHierarchyAnnouncements = useHierarchyAnnouncements;
|