@elliemae/ds-drag-and-drop 2.2.0 → 2.3.0-alpha.3
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 +44 -50
- package/cjs/hierarchy/customCollisionDetection.js.map +7 -0
- package/cjs/hierarchy/getHierarchyKeyboardCoordinates.js +78 -91
- package/cjs/hierarchy/getHierarchyKeyboardCoordinates.js.map +7 -0
- package/cjs/hierarchy/index.js +28 -9
- package/cjs/hierarchy/index.js.map +7 -0
- package/cjs/hierarchy/types.js +27 -2
- package/cjs/hierarchy/types.js.map +7 -0
- package/cjs/hierarchy/useHierarchyActionHandlers.js +53 -35
- package/cjs/hierarchy/useHierarchyActionHandlers.js.map +7 -0
- package/cjs/hierarchy/useHierarchyAnnouncements.js +45 -26
- package/cjs/hierarchy/useHierarchyAnnouncements.js.map +7 -0
- package/cjs/hierarchy/useHierarchyDndkitConfig.js +77 -83
- package/cjs/hierarchy/useHierarchyDndkitConfig.js.map +7 -0
- package/cjs/hierarchy/useHierarchyPreviewHandlers.js +48 -27
- package/cjs/hierarchy/useHierarchyPreviewHandlers.js.map +7 -0
- package/cjs/index.js +29 -11
- package/cjs/index.js.map +7 -0
- package/cjs/tree/constants.js +41 -12
- package/cjs/tree/constants.js.map +7 -0
- package/cjs/tree/customCollisionDetection.js +96 -124
- package/cjs/tree/customCollisionDetection.js.map +7 -0
- package/cjs/tree/getTreeKeyboardCoordinates.js +86 -101
- package/cjs/tree/getTreeKeyboardCoordinates.js.map +7 -0
- package/cjs/tree/index.js +28 -9
- package/cjs/tree/index.js.map +7 -0
- package/cjs/tree/types.js +27 -2
- package/cjs/tree/types.js.map +7 -0
- package/cjs/tree/useTreeActionHandlers.js +68 -57
- package/cjs/tree/useTreeActionHandlers.js.map +7 -0
- package/cjs/tree/useTreeAnnouncements.js +53 -40
- package/cjs/tree/useTreeAnnouncements.js.map +7 -0
- package/cjs/tree/useTreeDndkitConfig.js +112 -98
- package/cjs/tree/useTreeDndkitConfig.js.map +7 -0
- package/cjs/tree/useTreePreviewHandlers.js +53 -37
- package/cjs/tree/useTreePreviewHandlers.js.map +7 -0
- package/cjs/tree/utilities.js +44 -30
- package/cjs/tree/utilities.js.map +7 -0
- package/esm/hierarchy/customCollisionDetection.js +15 -46
- package/esm/hierarchy/customCollisionDetection.js.map +7 -0
- package/esm/hierarchy/getHierarchyKeyboardCoordinates.js +42 -76
- package/esm/hierarchy/getHierarchyKeyboardCoordinates.js.map +7 -0
- package/esm/hierarchy/index.js +3 -1
- package/esm/hierarchy/index.js.map +7 -0
- package/esm/hierarchy/types.js +2 -1
- package/esm/hierarchy/types.js.map +7 -0
- package/esm/hierarchy/useHierarchyActionHandlers.js +24 -31
- package/esm/hierarchy/useHierarchyActionHandlers.js.map +7 -0
- package/esm/hierarchy/useHierarchyAnnouncements.js +14 -20
- package/esm/hierarchy/useHierarchyAnnouncements.js.map +7 -0
- package/esm/hierarchy/useHierarchyDndkitConfig.js +45 -66
- package/esm/hierarchy/useHierarchyDndkitConfig.js.map +7 -0
- package/esm/hierarchy/useHierarchyPreviewHandlers.js +15 -19
- package/esm/hierarchy/useHierarchyPreviewHandlers.js.map +7 -0
- package/esm/index.js +4 -2
- package/esm/index.js.map +7 -0
- package/esm/tree/constants.js +12 -10
- package/esm/tree/constants.js.map +7 -0
- package/esm/tree/customCollisionDetection.js +67 -120
- package/esm/tree/customCollisionDetection.js.map +7 -0
- package/esm/tree/getTreeKeyboardCoordinates.js +48 -84
- package/esm/tree/getTreeKeyboardCoordinates.js.map +7 -0
- package/esm/tree/index.js +3 -1
- package/esm/tree/index.js.map +7 -0
- package/esm/tree/types.js +2 -1
- package/esm/tree/types.js.map +7 -0
- package/esm/tree/useTreeActionHandlers.js +37 -51
- package/esm/tree/useTreeActionHandlers.js.map +7 -0
- package/esm/tree/useTreeAnnouncements.js +18 -30
- package/esm/tree/useTreeAnnouncements.js.map +7 -0
- package/esm/tree/useTreeDndkitConfig.js +79 -80
- package/esm/tree/useTreeDndkitConfig.js.map +7 -0
- package/esm/tree/useTreePreviewHandlers.js +19 -28
- package/esm/tree/useTreePreviewHandlers.js.map +7 -0
- package/esm/tree/utilities.js +13 -23
- package/esm/tree/utilities.js.map +7 -0
- package/package.json +1 -1
- package/types/hierarchy/types.d.ts +1 -1
- package/types/tree/types.d.ts +17 -13
- package/types/tree/useTreeActionHandlers.d.ts +2 -2
- package/types/tree/useTreeDndkitConfig.d.ts +2 -2
- package/types/tree/useTreePreviewHandlers.d.ts +2 -2
|
@@ -1,58 +1,53 @@
|
|
|
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
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
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 __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
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 customCollisionDetection_exports = {};
|
|
29
|
+
__export(customCollisionDetection_exports, {
|
|
30
|
+
customCollisionDetection: () => customCollisionDetection
|
|
31
|
+
});
|
|
32
|
+
var React = __toESM(require("react"));
|
|
33
|
+
const customCollisionDetection = (activeId, activeParent, dndItems) => ({ droppableContainers, collisionRect }) => {
|
|
34
|
+
const entriesWithSameParent = droppableContainers.filter(({ id }) => dndItems.find((item) => item.id === id)?.parentId === activeParent);
|
|
35
|
+
const originalContainer = entriesWithSameParent.find(({ id }) => id === activeId);
|
|
36
|
+
const originalRect = originalContainer?.rect?.current;
|
|
37
|
+
if (!originalRect)
|
|
38
|
+
return null;
|
|
37
39
|
if (originalRect.offsetLeft <= collisionRect.offsetLeft && collisionRect.offsetLeft <= originalRect.offsetLeft + originalRect.width) {
|
|
38
40
|
return originalContainer.id;
|
|
39
41
|
}
|
|
40
|
-
|
|
41
42
|
const isLeft = collisionRect.offsetLeft <= originalRect.offsetLeft + collisionRect.width / 2 + 5;
|
|
42
|
-
let match = null;
|
|
43
|
-
// Otherwise, get the closest offset right
|
|
44
|
-
|
|
43
|
+
let match = null;
|
|
45
44
|
const collisionPoint = collisionRect.offsetLeft + collisionRect.width / 2;
|
|
46
|
-
entriesWithSameParent.forEach(entry => {
|
|
45
|
+
entriesWithSameParent.forEach((entry) => {
|
|
47
46
|
const {
|
|
48
|
-
rect: {
|
|
49
|
-
current: rect
|
|
50
|
-
}
|
|
47
|
+
rect: { current: rect }
|
|
51
48
|
} = entry;
|
|
52
|
-
|
|
53
49
|
if (rect !== null) {
|
|
54
50
|
const offsetRight = rect.offsetLeft + rect.width;
|
|
55
|
-
|
|
56
51
|
if (!match) {
|
|
57
52
|
match = entry;
|
|
58
53
|
} else if (match && match.rect.current && isLeft && Math.abs(collisionPoint - rect.offsetLeft) <= Math.abs(collisionPoint - match.rect.current.offsetLeft)) {
|
|
@@ -61,10 +56,9 @@ const customCollisionDetection = (activeId, activeParent, dndItems) => _ref => {
|
|
|
61
56
|
match = entry;
|
|
62
57
|
}
|
|
63
58
|
}
|
|
64
|
-
});
|
|
65
|
-
|
|
59
|
+
});
|
|
66
60
|
const matchCastedForSomeReason = match;
|
|
67
61
|
return matchCastedForSomeReason === null ? null : matchCastedForSomeReason.id;
|
|
68
62
|
};
|
|
69
|
-
|
|
70
|
-
|
|
63
|
+
module.exports = __toCommonJS(customCollisionDetection_exports);
|
|
64
|
+
//# sourceMappingURL=customCollisionDetection.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hierarchy/customCollisionDetection.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import { CollisionDetection, DroppableContainer } from '@dnd-kit/core';\nimport { Item } from './types';\n\nexport const customCollisionDetection =\n (activeId: string | null, activeParent: string | undefined, dndItems: Item[]): CollisionDetection =>\n ({ droppableContainers, collisionRect }) => {\n const entriesWithSameParent = droppableContainers.filter(\n ({ id }) => dndItems.find((item) => item.id === id)?.parentId === activeParent,\n );\n\n const originalContainer = entriesWithSameParent.find(({ id }) => id === activeId);\n const originalRect = originalContainer?.rect?.current;\n\n if (!originalRect) return null;\n\n if (\n originalRect.offsetLeft <= collisionRect.offsetLeft &&\n collisionRect.offsetLeft <= originalRect.offsetLeft + originalRect.width\n ) {\n return originalContainer.id;\n }\n\n const isLeft = collisionRect.offsetLeft <= originalRect.offsetLeft + collisionRect.width / 2 + 5;\n\n let match: DroppableContainer | null = null;\n // If going to the left, search the closest offset left\n // Otherwise, get the closest offset right\n const collisionPoint = collisionRect.offsetLeft + collisionRect.width / 2;\n entriesWithSameParent.forEach((entry) => {\n const {\n rect: { current: rect },\n } = entry;\n\n if (rect !== null) {\n const offsetRight = rect.offsetLeft + rect.width;\n\n if (!match) {\n match = entry;\n } else if (\n match &&\n match.rect.current &&\n isLeft &&\n Math.abs(collisionPoint - rect.offsetLeft) <= Math.abs(collisionPoint - match.rect.current.offsetLeft)\n ) {\n match = entry;\n } else if (\n match &&\n match.rect.current &&\n !isLeft &&\n Math.abs(collisionPoint - offsetRight) <=\n Math.abs(collisionPoint - match.rect.current.offsetLeft - match.rect.current.width)\n ) {\n match = entry;\n }\n }\n });\n // Typescript believes match is always null for some reason\n const matchCastedForSomeReason = match as DroppableContainer | null;\n return matchCastedForSomeReason === null ? null : matchCastedForSomeReason.id;\n };\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGhB,MAAM,2BACX,CAAC,UAAyB,cAAkC,aAC5D,CAAC,EAAE,qBAAqB,oBAAoB;AAC1C,QAAM,wBAAwB,oBAAoB,OAChD,CAAC,EAAE,SAAS,SAAS,KAAK,CAAC,SAAS,KAAK,OAAO,KAAK,aAAa;AAGpE,QAAM,oBAAoB,sBAAsB,KAAK,CAAC,EAAE,SAAS,OAAO;AACxE,QAAM,eAAe,mBAAmB,MAAM;AAE9C,MAAI,CAAC;AAAc,WAAO;AAE1B,MACE,aAAa,cAAc,cAAc,cACzC,cAAc,cAAc,aAAa,aAAa,aAAa,OACnE;AACA,WAAO,kBAAkB;AAAA;AAG3B,QAAM,SAAS,cAAc,cAAc,aAAa,aAAa,cAAc,QAAQ,IAAI;AAE/F,MAAI,QAAmC;AAGvC,QAAM,iBAAiB,cAAc,aAAa,cAAc,QAAQ;AACxE,wBAAsB,QAAQ,CAAC,UAAU;AACvC,UAAM;AAAA,MACJ,MAAM,EAAE,SAAS;AAAA,QACf;AAEJ,QAAI,SAAS,MAAM;AACjB,YAAM,cAAc,KAAK,aAAa,KAAK;AAE3C,UAAI,CAAC,OAAO;AACV,gBAAQ;AAAA,iBAER,SACA,MAAM,KAAK,WACX,UACA,KAAK,IAAI,iBAAiB,KAAK,eAAe,KAAK,IAAI,iBAAiB,MAAM,KAAK,QAAQ,aAC3F;AACA,gBAAQ;AAAA,iBAER,SACA,MAAM,KAAK,WACX,CAAC,UACD,KAAK,IAAI,iBAAiB,gBACxB,KAAK,IAAI,iBAAiB,MAAM,KAAK,QAAQ,aAAa,MAAM,KAAK,QAAQ,QAC/E;AACA,gBAAQ;AAAA;AAAA;AAAA;AAKd,QAAM,2BAA2B;AACjC,SAAO,6BAA6B,OAAO,OAAO,yBAAyB;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,105 +1,92 @@
|
|
|
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
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
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 __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
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 getHierarchyKeyboardCoordinates_exports = {};
|
|
29
|
+
__export(getHierarchyKeyboardCoordinates_exports, {
|
|
30
|
+
getHierarchyKeyboardCoordinates: () => getHierarchyKeyboardCoordinates
|
|
31
|
+
});
|
|
32
|
+
var React = __toESM(require("react"));
|
|
33
|
+
var import_core = require("@dnd-kit/core");
|
|
34
|
+
const directions = [import_core.KeyboardCode.Down, import_core.KeyboardCode.Right, import_core.KeyboardCode.Up, import_core.KeyboardCode.Left];
|
|
35
|
+
const vertical = [import_core.KeyboardCode.Up, import_core.KeyboardCode.Down];
|
|
36
|
+
const getHorizontalKeyboardCoordinates = ({
|
|
37
|
+
items,
|
|
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);
|
|
39
48
|
const overRect = over.rect;
|
|
40
|
-
const layoutRects = [];
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
var _items$find;
|
|
44
|
-
|
|
45
|
-
if (container !== null && container !== void 0 && container.disabled || !overRect) {
|
|
49
|
+
const layoutRects = [];
|
|
50
|
+
droppableContainers.forEach((container) => {
|
|
51
|
+
if (container?.disabled || !overRect) {
|
|
46
52
|
return;
|
|
47
53
|
}
|
|
48
|
-
|
|
49
|
-
const node = container === null || container === void 0 ? void 0 : container.node.current;
|
|
50
|
-
|
|
54
|
+
const node = container?.node.current;
|
|
51
55
|
if (!node) {
|
|
52
56
|
return;
|
|
53
57
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const rect =
|
|
58
|
-
|
|
59
|
-
if (event.code === core.KeyboardCode.Left && collisionRect.left > rect.right - 10) {
|
|
58
|
+
const itemParent = items.find((item) => item.id === container.id)?.parentId;
|
|
59
|
+
if (itemParent !== activeItem?.parentId)
|
|
60
|
+
return;
|
|
61
|
+
const rect = (0, import_core.getViewRect)(node);
|
|
62
|
+
if (event.code === import_core.KeyboardCode.Left && collisionRect.left > rect.right - 10) {
|
|
60
63
|
layoutRects.push(container);
|
|
61
|
-
} else if (event.code ===
|
|
64
|
+
} else if (event.code === import_core.KeyboardCode.Right && collisionRect.left < rect.left) {
|
|
62
65
|
layoutRects.push(container);
|
|
63
66
|
}
|
|
64
67
|
});
|
|
65
|
-
const closestId =
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (!
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return _objectSpread(_objectSpread({}, currentCoordinates), {}, {
|
|
68
|
+
const closestId = (0, import_core.closestCorners)({ droppableContainers: layoutRects, collisionRect, active });
|
|
69
|
+
if (!closestId)
|
|
70
|
+
return void 0;
|
|
71
|
+
const closestDroppableContainer = droppableContainers.get(closestId)?.node?.current;
|
|
72
|
+
const activeDroppableContainer = droppableContainers.get(active?.id)?.node?.current;
|
|
73
|
+
if (!closestDroppableContainer || !activeDroppableContainer)
|
|
74
|
+
return void 0;
|
|
75
|
+
const closestRect = (0, import_core.getViewRect)(closestDroppableContainer);
|
|
76
|
+
const activeRect = (0, import_core.getViewRect)(activeDroppableContainer);
|
|
77
|
+
return {
|
|
78
|
+
...currentCoordinates,
|
|
77
79
|
x: closestRect.left + (closestRect.width - collisionRect.width) / 2 + (closestRect.offsetLeft < activeRect.left ? -1 : 1)
|
|
78
|
-
}
|
|
80
|
+
};
|
|
79
81
|
};
|
|
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
|
-
|
|
82
|
+
const getHierarchyKeyboardCoordinates = (context, dragOverlayDataTestid, isHorizontalDnD) => (event, { currentCoordinates, context: { active, over, collisionRect, droppableContainers } }) => {
|
|
92
83
|
if (directions.includes(event.code)) {
|
|
93
84
|
event.preventDefault();
|
|
94
|
-
|
|
95
85
|
if (!collisionRect) {
|
|
96
|
-
return
|
|
86
|
+
return void 0;
|
|
97
87
|
}
|
|
98
|
-
|
|
99
88
|
const {
|
|
100
|
-
current: {
|
|
101
|
-
items
|
|
102
|
-
}
|
|
89
|
+
current: { items }
|
|
103
90
|
} = context;
|
|
104
91
|
const args = {
|
|
105
92
|
dragOverlayDataTestid,
|
|
@@ -111,11 +98,11 @@ const getHierarchyKeyboardCoordinates = (context, dragOverlayDataTestid, isHoriz
|
|
|
111
98
|
droppableContainers,
|
|
112
99
|
collisionRect
|
|
113
100
|
};
|
|
114
|
-
if (isHorizontalDnD)
|
|
115
|
-
|
|
101
|
+
if (isHorizontalDnD)
|
|
102
|
+
return getHorizontalKeyboardCoordinates(args);
|
|
103
|
+
return void 0;
|
|
116
104
|
}
|
|
117
|
-
|
|
118
|
-
return undefined;
|
|
105
|
+
return void 0;
|
|
119
106
|
};
|
|
120
|
-
|
|
121
|
-
|
|
107
|
+
module.exports = __toCommonJS(getHierarchyKeyboardCoordinates_exports);
|
|
108
|
+
//# sourceMappingURL=getHierarchyKeyboardCoordinates.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hierarchy/getHierarchyKeyboardCoordinates.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import { closestCorners, getViewRect, KeyboardCode, KeyboardCoordinateGetter, DroppableContainer } from '@dnd-kit/core';\nimport { Coordinates } from '@dnd-kit/core/dist/types';\n\nimport { GetKeyboardCoordinatesArgs, SensorContext } from './types';\n\nconst directions: string[] = [KeyboardCode.Down, KeyboardCode.Right, KeyboardCode.Up, KeyboardCode.Left];\n\nconst vertical: string[] = [KeyboardCode.Up, KeyboardCode.Down];\n\nconst getHorizontalKeyboardCoordinates = ({\n items,\n active,\n over,\n event,\n currentCoordinates,\n droppableContainers,\n collisionRect,\n}: GetKeyboardCoordinatesArgs): Coordinates | undefined => {\n if (vertical.includes(event.code) || !active || !over) return undefined;\n\n const activeItem = items.find((item) => item.id === active.id);\n\n const overRect = over.rect;\n\n const layoutRects: DroppableContainer[] = [];\n\n // Get the reacheable rects depending on the arrow key pressed\n droppableContainers.forEach((container) => {\n if (container?.disabled || !overRect) {\n return;\n }\n const node = container?.node.current;\n if (!node) {\n return;\n }\n const itemParent = items.find((item) => item.id === container.id)?.parentId;\n if (itemParent !== activeItem?.parentId) return;\n const rect = getViewRect(node);\n if (event.code === KeyboardCode.Left && collisionRect.left > rect.right - 10) {\n layoutRects.push(container);\n } else if (event.code === KeyboardCode.Right && collisionRect.left < rect.left) {\n layoutRects.push(container);\n }\n });\n\n const closestId = closestCorners({ droppableContainers: layoutRects, collisionRect, active });\n\n if (!closestId) return undefined;\n\n const closestDroppableContainer = droppableContainers.get(closestId)?.node?.current;\n const activeDroppableContainer = droppableContainers.get(active?.id)?.node?.current;\n\n if (!closestDroppableContainer || !activeDroppableContainer) return undefined;\n\n const closestRect = getViewRect(closestDroppableContainer);\n const activeRect = getViewRect(activeDroppableContainer);\n return {\n ...currentCoordinates,\n x:\n closestRect.left +\n (closestRect.width - collisionRect.width) / 2 +\n (closestRect.offsetLeft < activeRect.left ? -1 : 1),\n };\n};\n\nexport const getHierarchyKeyboardCoordinates: (\n context: SensorContext,\n dragOverlayDataTestid: string,\n isHorizontalDnD: boolean,\n) => KeyboardCoordinateGetter =\n (context, dragOverlayDataTestid, isHorizontalDnD) =>\n (event, { currentCoordinates, context: { active, over, collisionRect, droppableContainers } }) => {\n if (directions.includes(event.code)) {\n event.preventDefault();\n if (!collisionRect) {\n return undefined;\n }\n\n const {\n current: { items },\n } = context;\n\n const args = {\n dragOverlayDataTestid,\n items,\n active,\n over,\n event,\n currentCoordinates,\n droppableContainers,\n collisionRect,\n };\n\n if (isHorizontalDnD) return getHorizontalKeyboardCoordinates(args);\n return undefined;\n }\n return undefined;\n };\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,kBAAwG;AAKxG,MAAM,aAAuB,CAAC,yBAAa,MAAM,yBAAa,OAAO,yBAAa,IAAI,yBAAa;AAEnG,MAAM,WAAqB,CAAC,yBAAa,IAAI,yBAAa;AAE1D,MAAM,mCAAmC,CAAC;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,MACyD;AACzD,MAAI,SAAS,SAAS,MAAM,SAAS,CAAC,UAAU,CAAC;AAAM,WAAO;AAE9D,QAAM,aAAa,MAAM,KAAK,CAAC,SAAS,KAAK,OAAO,OAAO;AAE3D,QAAM,WAAW,KAAK;AAEtB,QAAM,cAAoC;AAG1C,sBAAoB,QAAQ,CAAC,cAAc;AACzC,QAAI,WAAW,YAAY,CAAC,UAAU;AACpC;AAAA;AAEF,UAAM,OAAO,WAAW,KAAK;AAC7B,QAAI,CAAC,MAAM;AACT;AAAA;AAEF,UAAM,aAAa,MAAM,KAAK,CAAC,SAAS,KAAK,OAAO,UAAU,KAAK;AACnE,QAAI,eAAe,YAAY;AAAU;AACzC,UAAM,OAAO,6BAAY;AACzB,QAAI,MAAM,SAAS,yBAAa,QAAQ,cAAc,OAAO,KAAK,QAAQ,IAAI;AAC5E,kBAAY,KAAK;AAAA,eACR,MAAM,SAAS,yBAAa,SAAS,cAAc,OAAO,KAAK,MAAM;AAC9E,kBAAY,KAAK;AAAA;AAAA;AAIrB,QAAM,YAAY,gCAAe,EAAE,qBAAqB,aAAa,eAAe;AAEpF,MAAI,CAAC;AAAW,WAAO;AAEvB,QAAM,4BAA4B,oBAAoB,IAAI,YAAY,MAAM;AAC5E,QAAM,2BAA2B,oBAAoB,IAAI,QAAQ,KAAK,MAAM;AAE5E,MAAI,CAAC,6BAA6B,CAAC;AAA0B,WAAO;AAEpE,QAAM,cAAc,6BAAY;AAChC,QAAM,aAAa,6BAAY;AAC/B,SAAO;AAAA,OACF;AAAA,IACH,GACE,YAAY,OACX,aAAY,QAAQ,cAAc,SAAS,IAC3C,aAAY,aAAa,WAAW,OAAO,KAAK;AAAA;AAAA;AAIhD,MAAM,kCAKX,CAAC,SAAS,uBAAuB,oBACjC,CAAC,OAAO,EAAE,oBAAoB,SAAS,EAAE,QAAQ,MAAM,eAAe,4BAA4B;AAChG,MAAI,WAAW,SAAS,MAAM,OAAO;AACnC,UAAM;AACN,QAAI,CAAC,eAAe;AAClB,aAAO;AAAA;AAGT,UAAM;AAAA,MACJ,SAAS,EAAE;AAAA,QACT;AAEJ,UAAM,OAAO;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAGF,QAAI;AAAiB,aAAO,iCAAiC;AAC7D,WAAO;AAAA;AAET,SAAO;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/cjs/hierarchy/index.js
CHANGED
|
@@ -1,9 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
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 hierarchy_exports = {};
|
|
25
|
+
var React = __toESM(require("react"));
|
|
26
|
+
__reExport(hierarchy_exports, require("./useHierarchyDndkitConfig"));
|
|
27
|
+
module.exports = __toCommonJS(hierarchy_exports);
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hierarchy/index.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["export * from './useHierarchyDndkitConfig';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA,YAAuB;ADAvB,8BAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/cjs/hierarchy/types.js
CHANGED
|
@@ -1,2 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
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
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hierarchy/types.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import type {\n Active,\n Announcements,\n CollisionDetection,\n DragEndEvent,\n DragMoveEvent,\n DragOverEvent,\n DragStartEvent,\n MeasuringConfiguration,\n Modifier,\n Over,\n SensorDescriptor,\n SensorOptions,\n} from '@dnd-kit/core';\nimport { DroppableContainers } from '@dnd-kit/core/dist/store';\nimport { Coordinates, DragCancelEvent, ViewRect } from '@dnd-kit/core/dist/types';\nimport { MutableRefObject } from 'react';\n\nexport type Item = {\n id: string;\n depth: number;\n parentId: string;\n index: number;\n};\n\nexport type DndContextPropsType = {\n announcements: Announcements;\n modifiers: Modifier[];\n sensors: SensorDescriptor<SensorOptions>[];\n measuring: Partial<MeasuringConfiguration>;\n collisionDetection: CollisionDetection;\n onDragStart: (e: DragStartEvent) => void;\n onDragMove: (e: DragMoveEvent) => void;\n onDragOver: (e: DragOverEvent) => void;\n onDragEnd: (e: DragEndEvent) => void;\n onDragCancel: (e: DragCancelEvent) => void;\n};\n\nexport type useHierarchyPreviewHandlersReturn = {\n handlePreviewDragStart: (e: DragStartEvent) => void;\n handlePreviewDragMove: (e: DragMoveEvent) => void;\n handlePreviewDragEnd: (e: DragEndEvent) => void;\n handlePreviewDragCancel: (e: DragCancelEvent) => void;\n};\n\nexport type useHierarchyPreviewHandlersArgs = {\n setActiveId: React.Dispatch<React.SetStateAction<string>>;\n onPreviewResetState: () => void;\n onPreviewDragStart: () => void;\n};\n\nexport type useHierarchyActionHandlersArgs = useHierarchyPreviewHandlersReturn & {\n dndItems: Item[];\n onReorder: (movedItem: Item, indexes: { targetIndex: number; fromIndex: number }) => void;\n};\n\nexport type useHierarchyActionHandlersReturn = {\n onDragStart: (e: DragStartEvent) => void;\n onDragMove: (e: DragMoveEvent) => void;\n onDragOver: (e: DragOverEvent) => void;\n onDragEnd: (e: DragEndEvent) => void;\n onDragCancel: (e: DragCancelEvent) => void;\n};\n\nexport type useHierarchyDndkitConfigArgs = {\n indentationWidth?: number;\n dragOverlayDataTestid: string;\n flattenedItems: [Item, unknown][];\n isHorizontalDnD?: boolean;\n onReorder: (movedItem: Item, indexes: { targetIndex: number; fromIndex: number }) => void;\n onPreviewResetState: () => void;\n onPreviewDragStart: () => void;\n};\n\nexport type useHierarchyDndkitConfigType = (args: useHierarchyDndkitConfigArgs) => useHierarchyDndkitConfigReturn;\n\nexport type useHierarchyDndkitConfigReturn = {\n dndContextProps: DndContextPropsType;\n activeId: string | null;\n overId: string | null;\n activeIndex: number | undefined;\n};\n\nexport type GetKeyboardCoordinatesArgs = {\n items: Item[];\n active: Active | null;\n over: Over | null;\n event: KeyboardEvent;\n currentCoordinates: Coordinates;\n droppableContainers: DroppableContainers;\n collisionRect: ViewRect;\n dragOverlayDataTestid: string;\n};\n\nexport type SensorContext = MutableRefObject<{\n items: Item[];\n offset?: number;\n}>;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA,YAAuB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,50 +1,68 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
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 __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
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 useHierarchyActionHandlers_exports = {};
|
|
29
|
+
__export(useHierarchyActionHandlers_exports, {
|
|
30
|
+
useHierarchyActionHandlers: () => useHierarchyActionHandlers
|
|
31
|
+
});
|
|
32
|
+
var React = __toESM(require("react"));
|
|
33
|
+
var import_react = 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) => {
|
|
17
43
|
handlePreviewDragStart(e);
|
|
18
44
|
}, [handlePreviewDragStart]);
|
|
19
|
-
const onDragMove =
|
|
45
|
+
const onDragMove = (0, import_react.useCallback)((e) => {
|
|
20
46
|
handlePreviewDragMove(e);
|
|
21
47
|
}, [handlePreviewDragMove]);
|
|
22
|
-
const onDragEnd =
|
|
48
|
+
const onDragEnd = (0, import_react.useCallback)((e) => {
|
|
23
49
|
handlePreviewDragEnd(e);
|
|
24
|
-
const {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
} = e;
|
|
28
|
-
if (!over) return;
|
|
29
|
-
|
|
50
|
+
const { active, over } = e;
|
|
51
|
+
if (!over)
|
|
52
|
+
return;
|
|
30
53
|
if (active.id !== over.id) {
|
|
31
|
-
const activeIndex = dndItems.findIndex(item => item.id === active.id);
|
|
32
|
-
const overIndex = dndItems.findIndex(item => item.id === over.id);
|
|
54
|
+
const activeIndex = dndItems.findIndex((item) => item.id === active.id);
|
|
55
|
+
const overIndex = dndItems.findIndex((item) => item.id === over.id);
|
|
33
56
|
onReorder(dndItems[activeIndex], {
|
|
34
57
|
targetIndex: overIndex,
|
|
35
58
|
fromIndex: activeIndex
|
|
36
59
|
});
|
|
37
60
|
}
|
|
38
61
|
}, [handlePreviewDragEnd, dndItems, onReorder]);
|
|
39
|
-
const onDragCancel =
|
|
62
|
+
const onDragCancel = (0, import_react.useCallback)((e) => {
|
|
40
63
|
handlePreviewDragCancel(e);
|
|
41
64
|
}, [handlePreviewDragCancel]);
|
|
42
|
-
return {
|
|
43
|
-
onDragStart,
|
|
44
|
-
onDragMove,
|
|
45
|
-
onDragEnd,
|
|
46
|
-
onDragCancel
|
|
47
|
-
};
|
|
65
|
+
return { onDragStart, onDragMove, onDragEnd, onDragCancel };
|
|
48
66
|
};
|
|
49
|
-
|
|
50
|
-
|
|
67
|
+
module.exports = __toCommonJS(useHierarchyActionHandlers_exports);
|
|
68
|
+
//# sourceMappingURL=useHierarchyActionHandlers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hierarchy/useHierarchyActionHandlers.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import { useCallback } from 'react';\nimport { DragStartEvent, DragMoveEvent, DragEndEvent, DragCancelEvent } from '@dnd-kit/core';\nimport { UseHierarchyActionHandlersReturn, UseHierarchyActionHandlersArgs } from './types';\n\nexport const useHierarchyActionHandlers = ({\n handlePreviewDragStart,\n handlePreviewDragMove,\n handlePreviewDragEnd,\n handlePreviewDragCancel,\n onReorder,\n dndItems,\n}: UseHierarchyActionHandlersArgs): UseHierarchyActionHandlersReturn => {\n const onDragStart = useCallback(\n (e: DragStartEvent) => {\n handlePreviewDragStart(e);\n },\n [handlePreviewDragStart],\n );\n\n const onDragMove = useCallback(\n (e: DragMoveEvent) => {\n handlePreviewDragMove(e);\n },\n [handlePreviewDragMove],\n );\n\n const onDragEnd = useCallback(\n (e: DragEndEvent) => {\n handlePreviewDragEnd(e);\n const { active, over } = e;\n\n if (!over) return;\n\n if (active.id !== over.id) {\n const activeIndex = dndItems.findIndex((item) => item.id === active.id);\n const overIndex = dndItems.findIndex((item) => item.id === over.id);\n\n onReorder(dndItems[activeIndex], {\n targetIndex: overIndex,\n fromIndex: activeIndex,\n });\n }\n },\n [handlePreviewDragEnd, dndItems, onReorder],\n );\n\n const onDragCancel = useCallback(\n (e: DragCancelEvent) => {\n handlePreviewDragCancel(e);\n },\n [handlePreviewDragCancel],\n );\n\n return { onDragStart, onDragMove, onDragEnd, onDragCancel };\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA4B;AAIrB,MAAM,6BAA6B,CAAC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,MACsE;AACtE,QAAM,cAAc,8BAClB,CAAC,MAAsB;AACrB,2BAAuB;AAAA,KAEzB,CAAC;AAGH,QAAM,aAAa,8BACjB,CAAC,MAAqB;AACpB,0BAAsB;AAAA,KAExB,CAAC;AAGH,QAAM,YAAY,8BAChB,CAAC,MAAoB;AACnB,yBAAqB;AACrB,UAAM,EAAE,QAAQ,SAAS;AAEzB,QAAI,CAAC;AAAM;AAEX,QAAI,OAAO,OAAO,KAAK,IAAI;AACzB,YAAM,cAAc,SAAS,UAAU,CAAC,SAAS,KAAK,OAAO,OAAO;AACpE,YAAM,YAAY,SAAS,UAAU,CAAC,SAAS,KAAK,OAAO,KAAK;AAEhE,gBAAU,SAAS,cAAc;AAAA,QAC/B,aAAa;AAAA,QACb,WAAW;AAAA;AAAA;AAAA,KAIjB,CAAC,sBAAsB,UAAU;AAGnC,QAAM,eAAe,8BACnB,CAAC,MAAuB;AACtB,4BAAwB;AAAA,KAE1B,CAAC;AAGH,SAAO,EAAE,aAAa,YAAY,WAAW;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|