@elliemae/ds-drag-and-drop 2.2.1 → 2.3.0-alpha.4
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,137 +1,109 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
+
var import_constants = require("./constants");
|
|
34
|
+
const DUMMY_ID = "DUMMY_ID_INTERNAL_USE_ONLY";
|
|
14
35
|
const RECT_UP = {
|
|
15
36
|
offsetTop: -Infinity,
|
|
16
37
|
offsetLeft: 0,
|
|
17
|
-
// Doesn't matter,
|
|
18
38
|
width: 0,
|
|
19
|
-
|
|
20
|
-
height: 0 // Doesn't matter
|
|
21
|
-
|
|
39
|
+
height: 0
|
|
22
40
|
};
|
|
23
41
|
const RECT_DOWN = {
|
|
24
42
|
offsetTop: Infinity,
|
|
25
43
|
offsetLeft: 0,
|
|
26
|
-
// Doesn't matter,
|
|
27
44
|
width: 0,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}; // Percentage of height to take into consideration when looking for colliding rects
|
|
32
|
-
|
|
33
|
-
const thresholdRatio = 0.2; // Percentage to be inside
|
|
34
|
-
|
|
45
|
+
height: 0
|
|
46
|
+
};
|
|
47
|
+
const thresholdRatio = 0.2;
|
|
35
48
|
const insideThreshold = 0.7;
|
|
36
|
-
const customCollisionDetection = (activeId, visibleItemsDictionary, setDropIndicatorPosition, maxDragAndDropLevel, lastPosition, setLastPosition) =>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
isUp = originalRect.offsetTop > collisionRect.top;
|
|
56
|
-
} // Threshold
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const threshold = collisionRect.height * thresholdRatio;
|
|
60
|
-
let collidingContainer = null;
|
|
61
|
-
|
|
62
|
-
if (isUp) {
|
|
63
|
-
// Up -- We need to find the first rectangle downwards
|
|
64
|
-
collidingContainer = droppableContainers.reduce((firstRectDown, container) => {
|
|
65
|
-
const rect = container.rect.current;
|
|
66
|
-
|
|
67
|
-
if (rect && firstRectDown.rect.current) {
|
|
68
|
-
const {
|
|
69
|
-
offsetTop: rectOffsetTop
|
|
70
|
-
} = rect;
|
|
71
|
-
const {
|
|
72
|
-
offsetTop: firstRectDownOffsetTop
|
|
73
|
-
} = firstRectDown.rect.current;
|
|
74
|
-
|
|
75
|
-
if (rectOffsetTop + threshold > collisionRect.top && rectOffsetTop < firstRectDownOffsetTop) {
|
|
76
|
-
return container;
|
|
49
|
+
const customCollisionDetection = (activeId, visibleItemsDictionary, setDropIndicatorPosition, maxDragAndDropLevel, lastPosition, setLastPosition) => {
|
|
50
|
+
const func = ({ droppableContainers, collisionRect }) => {
|
|
51
|
+
const originalContainer = droppableContainers.find(({ id }) => id === activeId);
|
|
52
|
+
const originalRect = originalContainer?.rect?.current;
|
|
53
|
+
let isUp = lastPosition === "up";
|
|
54
|
+
if (originalRect) {
|
|
55
|
+
isUp = originalRect.offsetTop > collisionRect.top;
|
|
56
|
+
}
|
|
57
|
+
const threshold = collisionRect.height * thresholdRatio;
|
|
58
|
+
let collidingContainer = null;
|
|
59
|
+
if (isUp) {
|
|
60
|
+
collidingContainer = droppableContainers.reduce((firstRectDown, container) => {
|
|
61
|
+
const rect = container.rect.current;
|
|
62
|
+
if (rect && firstRectDown.rect.current) {
|
|
63
|
+
const { offsetTop: rectOffsetTop } = rect;
|
|
64
|
+
const { offsetTop: firstRectDownOffsetTop } = firstRectDown.rect.current;
|
|
65
|
+
if (rectOffsetTop + threshold > collisionRect.top && rectOffsetTop < firstRectDownOffsetTop) {
|
|
66
|
+
return container;
|
|
67
|
+
}
|
|
77
68
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
collidingContainer = droppableContainers.reduce((firstRectUp, container) => {
|
|
90
|
-
const rect = container.rect.current;
|
|
91
|
-
|
|
92
|
-
if (rect && firstRectUp.rect.current) {
|
|
93
|
-
const {
|
|
94
|
-
offsetTop: rectOffsetTop
|
|
95
|
-
} = rect;
|
|
96
|
-
const {
|
|
97
|
-
offsetTop: firstRectUpOffsetTop
|
|
98
|
-
} = firstRectUp.rect.current;
|
|
99
|
-
|
|
100
|
-
if (rectOffsetTop - threshold < collisionRect.top && rectOffsetTop > firstRectUpOffsetTop) {
|
|
101
|
-
return container;
|
|
69
|
+
return firstRectDown;
|
|
70
|
+
}, { id: DUMMY_ID, rect: { current: RECT_DOWN } });
|
|
71
|
+
} else {
|
|
72
|
+
collidingContainer = droppableContainers.reduce((firstRectUp, container) => {
|
|
73
|
+
const rect = container.rect.current;
|
|
74
|
+
if (rect && firstRectUp.rect.current) {
|
|
75
|
+
const { offsetTop: rectOffsetTop } = rect;
|
|
76
|
+
const { offsetTop: firstRectUpOffsetTop } = firstRectUp.rect.current;
|
|
77
|
+
if (rectOffsetTop - threshold < collisionRect.top && rectOffsetTop > firstRectUpOffsetTop) {
|
|
78
|
+
return container;
|
|
79
|
+
}
|
|
102
80
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
setDropIndicatorPosition(isUp ? constants.DropIndicatorPosition.Before : constants.DropIndicatorPosition.After);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (isUp && lastPosition !== 'up') setLastPosition('up');else if (!isUp && lastPosition !== 'down') setLastPosition('down'); // Return the id of the match rectangle
|
|
133
|
-
|
|
134
|
-
return collidingContainer.id;
|
|
81
|
+
return firstRectUp;
|
|
82
|
+
}, { id: DUMMY_ID, rect: { current: RECT_UP } });
|
|
83
|
+
}
|
|
84
|
+
if (collidingContainer.id === DUMMY_ID) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
const collidingRect = collidingContainer.rect.current;
|
|
88
|
+
if (!collidingRect)
|
|
89
|
+
return null;
|
|
90
|
+
const [top, bottom] = [
|
|
91
|
+
Math.max(collisionRect.top, collidingRect.offsetTop),
|
|
92
|
+
Math.min(collisionRect.top + collisionRect.height, collidingRect.offsetTop + collidingRect.height)
|
|
93
|
+
];
|
|
94
|
+
const intersectionPercentage = Math.abs(bottom - top) / collidingRect.height;
|
|
95
|
+
if (intersectionPercentage > insideThreshold && visibleItemsDictionary[collidingContainer.id].depth + 1 <= maxDragAndDropLevel && collidingContainer.id !== activeId) {
|
|
96
|
+
setDropIndicatorPosition(import_constants.DropIndicatorPosition.Inside);
|
|
97
|
+
} else {
|
|
98
|
+
setDropIndicatorPosition(isUp ? import_constants.DropIndicatorPosition.Before : import_constants.DropIndicatorPosition.After);
|
|
99
|
+
}
|
|
100
|
+
if (isUp && lastPosition !== "up")
|
|
101
|
+
setLastPosition("up");
|
|
102
|
+
else if (!isUp && lastPosition !== "down")
|
|
103
|
+
setLastPosition("down");
|
|
104
|
+
return collidingContainer.id;
|
|
105
|
+
};
|
|
106
|
+
return func;
|
|
135
107
|
};
|
|
136
|
-
|
|
137
|
-
|
|
108
|
+
module.exports = __toCommonJS(customCollisionDetection_exports);
|
|
109
|
+
//# sourceMappingURL=customCollisionDetection.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/tree/customCollisionDetection.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-statements */\n/* eslint-disable complexity */\n/* eslint-disable @typescript-eslint/indent */\n/* eslint-disable max-params */\nimport { CollisionDetection, DroppableContainer, LayoutRect } from '@dnd-kit/core';\nimport { DropIndicatorPosition } from './constants';\nimport { Item } from './types';\n\nconst DUMMY_ID = 'DUMMY_ID_INTERNAL_USE_ONLY';\nconst RECT_UP: LayoutRect = {\n offsetTop: -Infinity,\n offsetLeft: 0, // Doesn't matter,\n width: 0, // Doesn't matter\n height: 0, // Doesn't matter\n};\nconst RECT_DOWN: LayoutRect = {\n offsetTop: Infinity,\n offsetLeft: 0, // Doesn't matter,\n width: 0, // Doesn't matter\n height: 0, // Doesn't matter\n};\n\n// Percentage of height to take into consideration when looking for colliding rects\nconst thresholdRatio = 0.2;\n// Percentage to be inside\nconst insideThreshold = 0.7;\n\nexport const customCollisionDetection = (\n activeId: string,\n visibleItemsDictionary: Record<string, Item>,\n setDropIndicatorPosition: React.Dispatch<React.SetStateAction<DropIndicatorPosition>>,\n maxDragAndDropLevel: number,\n lastPosition: string,\n setLastPosition: React.Dispatch<React.SetStateAction<string>>,\n): CollisionDetection => {\n const func: CollisionDetection = ({ droppableContainers, collisionRect }) => {\n const originalContainer = droppableContainers.find(({ id }) => id === activeId);\n const originalRect = originalContainer?.rect?.current;\n\n // We first check if the item was moved up or down\n // This modifies how to search the matching colliding rect\n let isUp = lastPosition === 'up';\n if (originalRect) {\n isUp = originalRect.offsetTop > collisionRect.top;\n }\n\n // Threshold\n const threshold = collisionRect.height * thresholdRatio;\n\n let collidingContainer: DroppableContainer | null = null;\n\n if (isUp) {\n // Up -- We need to find the first rectangle downwards\n collidingContainer = droppableContainers.reduce(\n (firstRectDown, container) => {\n const rect = container.rect.current;\n if (rect && firstRectDown.rect.current) {\n const { offsetTop: rectOffsetTop } = rect;\n const { offsetTop: firstRectDownOffsetTop } = firstRectDown.rect.current;\n if (rectOffsetTop + threshold > collisionRect.top && rectOffsetTop < firstRectDownOffsetTop) {\n return container;\n }\n }\n return firstRectDown;\n },\n { id: DUMMY_ID, rect: { current: RECT_DOWN } } as DroppableContainer,\n );\n } else {\n // Down -- We need to find the first rectangle upwards\n collidingContainer = droppableContainers.reduce(\n (firstRectUp, container) => {\n const rect = container.rect.current;\n if (rect && firstRectUp.rect.current) {\n const { offsetTop: rectOffsetTop } = rect;\n const { offsetTop: firstRectUpOffsetTop } = firstRectUp.rect.current;\n if (rectOffsetTop - threshold < collisionRect.top && rectOffsetTop > firstRectUpOffsetTop) {\n return container;\n }\n }\n return firstRectUp;\n },\n { id: DUMMY_ID, rect: { current: RECT_UP } } as DroppableContainer,\n );\n }\n\n // If we didn't find a match, return null\n if (collidingContainer.id === DUMMY_ID) {\n return null;\n }\n\n const collidingRect = collidingContainer.rect.current;\n\n if (!collidingRect) return null;\n\n // Calculate the intersection interval\n const [top, bottom] = [\n Math.max(collisionRect.top, collidingRect.offsetTop),\n Math.min(collisionRect.top + collisionRect.height, collidingRect.offsetTop + collidingRect.height),\n ];\n\n // Calculate the percentage of intersection\n const intersectionPercentage = Math.abs(bottom - top) / collidingRect.height;\n\n if (\n intersectionPercentage > insideThreshold &&\n visibleItemsDictionary[collidingContainer.id].depth + 1 <= maxDragAndDropLevel &&\n collidingContainer.id !== activeId\n ) {\n setDropIndicatorPosition(DropIndicatorPosition.Inside);\n } else {\n setDropIndicatorPosition(isUp ? DropIndicatorPosition.Before : DropIndicatorPosition.After);\n }\n\n if (isUp && lastPosition !== 'up') setLastPosition('up');\n else if (!isUp && lastPosition !== 'down') setLastPosition('down');\n\n // Return the id of the match rectangle\n return collidingContainer.id;\n };\n return func;\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADKvB,uBAAsC;AAGtC,MAAM,WAAW;AACjB,MAAM,UAAsB;AAAA,EAC1B,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,QAAQ;AAAA;AAEV,MAAM,YAAwB;AAAA,EAC5B,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,QAAQ;AAAA;AAIV,MAAM,iBAAiB;AAEvB,MAAM,kBAAkB;AAEjB,MAAM,2BAA2B,CACtC,UACA,wBACA,0BACA,qBACA,cACA,oBACuB;AACvB,QAAM,OAA2B,CAAC,EAAE,qBAAqB,oBAAoB;AAC3E,UAAM,oBAAoB,oBAAoB,KAAK,CAAC,EAAE,SAAS,OAAO;AACtE,UAAM,eAAe,mBAAmB,MAAM;AAI9C,QAAI,OAAO,iBAAiB;AAC5B,QAAI,cAAc;AAChB,aAAO,aAAa,YAAY,cAAc;AAAA;AAIhD,UAAM,YAAY,cAAc,SAAS;AAEzC,QAAI,qBAAgD;AAEpD,QAAI,MAAM;AAER,2BAAqB,oBAAoB,OACvC,CAAC,eAAe,cAAc;AAC5B,cAAM,OAAO,UAAU,KAAK;AAC5B,YAAI,QAAQ,cAAc,KAAK,SAAS;AACtC,gBAAM,EAAE,WAAW,kBAAkB;AACrC,gBAAM,EAAE,WAAW,2BAA2B,cAAc,KAAK;AACjE,cAAI,gBAAgB,YAAY,cAAc,OAAO,gBAAgB,wBAAwB;AAC3F,mBAAO;AAAA;AAAA;AAGX,eAAO;AAAA,SAET,EAAE,IAAI,UAAU,MAAM,EAAE,SAAS;AAAA,WAE9B;AAEL,2BAAqB,oBAAoB,OACvC,CAAC,aAAa,cAAc;AAC1B,cAAM,OAAO,UAAU,KAAK;AAC5B,YAAI,QAAQ,YAAY,KAAK,SAAS;AACpC,gBAAM,EAAE,WAAW,kBAAkB;AACrC,gBAAM,EAAE,WAAW,yBAAyB,YAAY,KAAK;AAC7D,cAAI,gBAAgB,YAAY,cAAc,OAAO,gBAAgB,sBAAsB;AACzF,mBAAO;AAAA;AAAA;AAGX,eAAO;AAAA,SAET,EAAE,IAAI,UAAU,MAAM,EAAE,SAAS;AAAA;AAKrC,QAAI,mBAAmB,OAAO,UAAU;AACtC,aAAO;AAAA;AAGT,UAAM,gBAAgB,mBAAmB,KAAK;AAE9C,QAAI,CAAC;AAAe,aAAO;AAG3B,UAAM,CAAC,KAAK,UAAU;AAAA,MACpB,KAAK,IAAI,cAAc,KAAK,cAAc;AAAA,MAC1C,KAAK,IAAI,cAAc,MAAM,cAAc,QAAQ,cAAc,YAAY,cAAc;AAAA;AAI7F,UAAM,yBAAyB,KAAK,IAAI,SAAS,OAAO,cAAc;AAEtE,QACE,yBAAyB,mBACzB,uBAAuB,mBAAmB,IAAI,QAAQ,KAAK,uBAC3D,mBAAmB,OAAO,UAC1B;AACA,+BAAyB,uCAAsB;AAAA,WAC1C;AACL,+BAAyB,OAAO,uCAAsB,SAAS,uCAAsB;AAAA;AAGvF,QAAI,QAAQ,iBAAiB;AAAM,sBAAgB;AAAA,aAC1C,CAAC,QAAQ,iBAAiB;AAAQ,sBAAgB;AAG3D,WAAO,mBAAmB;AAAA;AAE5B,SAAO;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,123 +1,108 @@
|
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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 getTreeKeyboardCoordinates_exports = {};
|
|
29
|
+
__export(getTreeKeyboardCoordinates_exports, {
|
|
30
|
+
getTreeKeyboardCoordinates: () => getTreeKeyboardCoordinates
|
|
31
|
+
});
|
|
32
|
+
var React = __toESM(require("react"));
|
|
33
|
+
var import_core = require("@dnd-kit/core");
|
|
34
|
+
var import_constants = require("./constants");
|
|
35
|
+
const directions = [import_core.KeyboardCode.Down, import_core.KeyboardCode.Right, import_core.KeyboardCode.Up, import_core.KeyboardCode.Left];
|
|
36
|
+
const horizontal = [import_core.KeyboardCode.Left, import_core.KeyboardCode.Right];
|
|
37
|
+
const getVerticalKeyboardCoordinates = ({
|
|
38
|
+
items,
|
|
39
|
+
active,
|
|
40
|
+
over,
|
|
41
|
+
event,
|
|
42
|
+
currentCoordinates,
|
|
43
|
+
droppableContainers,
|
|
44
|
+
collisionRect,
|
|
45
|
+
dropIndicatorPosition,
|
|
46
|
+
maxDragAndDropLevel
|
|
47
|
+
}) => {
|
|
48
|
+
if (horizontal.includes(event.code))
|
|
49
|
+
return void 0;
|
|
42
50
|
const overRect = over.rect;
|
|
43
|
-
const layoutRects = [];
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (container !== null && container !== void 0 && container.disabled || !overRect) {
|
|
51
|
+
const layoutRects = [];
|
|
52
|
+
droppableContainers.forEach((container) => {
|
|
53
|
+
if (container?.disabled || !overRect) {
|
|
47
54
|
return;
|
|
48
55
|
}
|
|
49
|
-
|
|
50
56
|
const rect = container.rect.current;
|
|
51
|
-
|
|
52
|
-
if (rect && event.code === core.KeyboardCode.Down && collisionRect.top - 2 <= rect.offsetTop) {
|
|
57
|
+
if (rect && event.code === import_core.KeyboardCode.Down && collisionRect.top - 2 <= rect.offsetTop) {
|
|
53
58
|
layoutRects.push(container);
|
|
54
|
-
} else if (rect && event.code ===
|
|
59
|
+
} else if (rect && event.code === import_core.KeyboardCode.Up && collisionRect.top >= rect.offsetTop) {
|
|
55
60
|
layoutRects.push(container);
|
|
56
61
|
}
|
|
57
62
|
});
|
|
58
|
-
const closestId =
|
|
63
|
+
const closestId = (0, import_core.closestCorners)({
|
|
59
64
|
collisionRect,
|
|
60
65
|
droppableContainers: layoutRects,
|
|
61
66
|
active
|
|
62
67
|
});
|
|
63
|
-
const closestItem = items.find(item => item.uid === closestId);
|
|
64
|
-
const closestElement =
|
|
65
|
-
if (!closestId || !closestItem || !closestElement)
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (event.code ===
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (dropIndicatorPosition === constants.DropIndicatorPosition.Inside || closestId === active.id || closestItem.depth + 1 > maxDragAndDropLevel) {
|
|
73
|
-
return _objectSpread(_objectSpread({}, currentCoordinates), {}, {
|
|
68
|
+
const closestItem = items.find((item) => item.uid === closestId);
|
|
69
|
+
const closestElement = droppableContainers.get(closestId)?.node?.current;
|
|
70
|
+
if (!closestId || !closestItem || !closestElement)
|
|
71
|
+
return void 0;
|
|
72
|
+
const closestRect = (0, import_core.getViewRect)(closestElement);
|
|
73
|
+
if (event.code === import_core.KeyboardCode.Up) {
|
|
74
|
+
if (dropIndicatorPosition === import_constants.DropIndicatorPosition.Inside || closestId === active.id || closestItem.depth + 1 > maxDragAndDropLevel) {
|
|
75
|
+
return {
|
|
76
|
+
...currentCoordinates,
|
|
74
77
|
y: closestRect.top - collisionRect.height / 2
|
|
75
|
-
}
|
|
78
|
+
};
|
|
76
79
|
}
|
|
77
|
-
|
|
78
|
-
|
|
80
|
+
return {
|
|
81
|
+
...currentCoordinates,
|
|
79
82
|
y: closestRect.top + Math.abs(closestRect.height - collisionRect.height) / 2
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (dropIndicatorPosition === constants.DropIndicatorPosition.Inside || closestId === active.id || closestItem.depth + 1 > maxDragAndDropLevel) {
|
|
87
|
-
return _objectSpread(_objectSpread({}, currentCoordinates), {}, {
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
if (dropIndicatorPosition === import_constants.DropIndicatorPosition.Inside || closestId === active.id || closestItem.depth + 1 > maxDragAndDropLevel) {
|
|
86
|
+
return {
|
|
87
|
+
...currentCoordinates,
|
|
88
88
|
y: closestRect.top + collisionRect.height / 2
|
|
89
|
-
}
|
|
89
|
+
};
|
|
90
90
|
}
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
return {
|
|
92
|
+
...currentCoordinates,
|
|
93
93
|
y: closestRect.top + Math.abs(closestRect.height - collisionRect.height) / 2
|
|
94
|
-
}
|
|
94
|
+
};
|
|
95
95
|
};
|
|
96
|
-
|
|
97
|
-
const getTreeKeyboardCoordinates = (context, isHorizontalDnD, maxDragAndDropLevel) => (event, _ref2) => {
|
|
98
|
-
let {
|
|
99
|
-
currentCoordinates,
|
|
100
|
-
context: {
|
|
101
|
-
over,
|
|
102
|
-
translatedRect,
|
|
103
|
-
droppableContainers,
|
|
104
|
-
active,
|
|
105
|
-
collisionRect
|
|
106
|
-
}
|
|
107
|
-
} = _ref2;
|
|
108
|
-
|
|
96
|
+
const getTreeKeyboardCoordinates = (context, isHorizontalDnD, maxDragAndDropLevel) => (event, { currentCoordinates, context: { over, translatedRect, droppableContainers, active, collisionRect } }) => {
|
|
109
97
|
if (directions.includes(event.code)) {
|
|
110
98
|
if (!translatedRect) {
|
|
111
|
-
return
|
|
99
|
+
return void 0;
|
|
112
100
|
}
|
|
113
|
-
|
|
114
101
|
const {
|
|
115
|
-
current: {
|
|
116
|
-
items,
|
|
117
|
-
dropIndicatorPosition
|
|
118
|
-
}
|
|
102
|
+
current: { items, dropIndicatorPosition }
|
|
119
103
|
} = context;
|
|
120
|
-
if (!over || !active || !collisionRect)
|
|
104
|
+
if (!over || !active || !collisionRect)
|
|
105
|
+
return void 0;
|
|
121
106
|
const args = {
|
|
122
107
|
items,
|
|
123
108
|
active,
|
|
@@ -129,11 +114,11 @@ const getTreeKeyboardCoordinates = (context, isHorizontalDnD, maxDragAndDropLeve
|
|
|
129
114
|
dropIndicatorPosition,
|
|
130
115
|
maxDragAndDropLevel
|
|
131
116
|
};
|
|
132
|
-
if (isHorizontalDnD)
|
|
117
|
+
if (isHorizontalDnD)
|
|
118
|
+
return void 0;
|
|
133
119
|
return getVerticalKeyboardCoordinates(args);
|
|
134
120
|
}
|
|
135
|
-
|
|
136
|
-
return undefined;
|
|
121
|
+
return void 0;
|
|
137
122
|
};
|
|
138
|
-
|
|
139
|
-
|
|
123
|
+
module.exports = __toCommonJS(getTreeKeyboardCoordinates_exports);
|
|
124
|
+
//# sourceMappingURL=getTreeKeyboardCoordinates.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/tree/getTreeKeyboardCoordinates.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable complexity */\nimport { closestCorners, getViewRect, KeyboardCode, KeyboardCoordinateGetter, DroppableContainer } from '@dnd-kit/core';\nimport { Coordinates } from '@dnd-kit/core/dist/types';\nimport type { GetKeyboardCoordinatesArgs, SensorContext } from './types';\nimport { DropIndicatorPosition } from './constants';\n\nconst directions: string[] = [KeyboardCode.Down, KeyboardCode.Right, KeyboardCode.Up, KeyboardCode.Left];\n\nconst horizontal: string[] = [KeyboardCode.Left, KeyboardCode.Right];\n\nconst getVerticalKeyboardCoordinates = ({\n items,\n active,\n over,\n event,\n currentCoordinates,\n droppableContainers,\n collisionRect,\n dropIndicatorPosition,\n maxDragAndDropLevel,\n}: GetKeyboardCoordinatesArgs): Coordinates | undefined => {\n if (horizontal.includes(event.code)) return undefined;\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 rect = container.rect.current;\n if (rect && event.code === KeyboardCode.Down && collisionRect.top - 2 <= rect.offsetTop) {\n layoutRects.push(container);\n } else if (rect && event.code === KeyboardCode.Up && collisionRect.top >= rect.offsetTop) {\n layoutRects.push(container);\n }\n });\n\n const closestId = closestCorners({\n collisionRect,\n droppableContainers: layoutRects,\n active,\n });\n\n const closestItem = items.find((item) => item.uid === closestId);\n\n const closestElement = droppableContainers.get(closestId)?.node?.current;\n\n if (!closestId || !closestItem || !closestElement) return undefined;\n\n const closestRect = getViewRect(closestElement);\n\n if (event.code === KeyboardCode.Up) {\n // If the drop indicator is inside (or over ourselves)\n // We are gonna go to the before position\n // Else we are gonna go inside the over rect\n if (\n dropIndicatorPosition === DropIndicatorPosition.Inside ||\n closestId === active.id ||\n closestItem.depth + 1 > maxDragAndDropLevel\n ) {\n return {\n ...currentCoordinates,\n y: closestRect.top - collisionRect.height / 2,\n };\n }\n return {\n ...currentCoordinates,\n y: closestRect.top + Math.abs(closestRect.height - collisionRect.height) / 2,\n };\n }\n // If the drop indicator is inside (or over ourselves)\n // We are gonna go to the after position\n // Else we are gonna go inside the over rect\n if (\n dropIndicatorPosition === DropIndicatorPosition.Inside ||\n closestId === active.id ||\n closestItem.depth + 1 > maxDragAndDropLevel\n ) {\n return {\n ...currentCoordinates,\n y: closestRect.top + collisionRect.height / 2,\n };\n }\n return {\n ...currentCoordinates,\n y: closestRect.top + Math.abs(closestRect.height - collisionRect.height) / 2,\n };\n};\n\nexport const getTreeKeyboardCoordinates: (\n context: SensorContext,\n isHorizontalDnD: boolean,\n maxDragAndDropLevel: number,\n) => KeyboardCoordinateGetter =\n (context, isHorizontalDnD, maxDragAndDropLevel) =>\n (event, { currentCoordinates, context: { over, translatedRect, droppableContainers, active, collisionRect } }) => {\n if (directions.includes(event.code)) {\n if (!translatedRect) {\n return undefined;\n }\n\n const {\n current: { items, dropIndicatorPosition },\n } = context;\n\n if (!over || !active || !collisionRect) return undefined;\n\n const args = {\n items,\n active,\n over,\n event,\n currentCoordinates,\n droppableContainers,\n collisionRect,\n dropIndicatorPosition,\n maxDragAndDropLevel,\n };\n\n if (isHorizontalDnD) return undefined;\n return getVerticalKeyboardCoordinates(args);\n }\n return undefined;\n };\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,kBAAwG;AAGxG,uBAAsC;AAEtC,MAAM,aAAuB,CAAC,yBAAa,MAAM,yBAAa,OAAO,yBAAa,IAAI,yBAAa;AAEnG,MAAM,aAAuB,CAAC,yBAAa,MAAM,yBAAa;AAE9D,MAAM,iCAAiC,CAAC;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,MACyD;AACzD,MAAI,WAAW,SAAS,MAAM;AAAO,WAAO;AAE5C,QAAM,WAAW,KAAK;AAEtB,QAAM,cAAoC;AAG1C,sBAAoB,QAAQ,CAAC,cAAc;AACzC,QAAI,WAAW,YAAY,CAAC,UAAU;AACpC;AAAA;AAEF,UAAM,OAAO,UAAU,KAAK;AAC5B,QAAI,QAAQ,MAAM,SAAS,yBAAa,QAAQ,cAAc,MAAM,KAAK,KAAK,WAAW;AACvF,kBAAY,KAAK;AAAA,eACR,QAAQ,MAAM,SAAS,yBAAa,MAAM,cAAc,OAAO,KAAK,WAAW;AACxF,kBAAY,KAAK;AAAA;AAAA;AAIrB,QAAM,YAAY,gCAAe;AAAA,IAC/B;AAAA,IACA,qBAAqB;AAAA,IACrB;AAAA;AAGF,QAAM,cAAc,MAAM,KAAK,CAAC,SAAS,KAAK,QAAQ;AAEtD,QAAM,iBAAiB,oBAAoB,IAAI,YAAY,MAAM;AAEjE,MAAI,CAAC,aAAa,CAAC,eAAe,CAAC;AAAgB,WAAO;AAE1D,QAAM,cAAc,6BAAY;AAEhC,MAAI,MAAM,SAAS,yBAAa,IAAI;AAIlC,QACE,0BAA0B,uCAAsB,UAChD,cAAc,OAAO,MACrB,YAAY,QAAQ,IAAI,qBACxB;AACA,aAAO;AAAA,WACF;AAAA,QACH,GAAG,YAAY,MAAM,cAAc,SAAS;AAAA;AAAA;AAGhD,WAAO;AAAA,SACF;AAAA,MACH,GAAG,YAAY,MAAM,KAAK,IAAI,YAAY,SAAS,cAAc,UAAU;AAAA;AAAA;AAM/E,MACE,0BAA0B,uCAAsB,UAChD,cAAc,OAAO,MACrB,YAAY,QAAQ,IAAI,qBACxB;AACA,WAAO;AAAA,SACF;AAAA,MACH,GAAG,YAAY,MAAM,cAAc,SAAS;AAAA;AAAA;AAGhD,SAAO;AAAA,OACF;AAAA,IACH,GAAG,YAAY,MAAM,KAAK,IAAI,YAAY,SAAS,cAAc,UAAU;AAAA;AAAA;AAIxE,MAAM,6BAKX,CAAC,SAAS,iBAAiB,wBAC3B,CAAC,OAAO,EAAE,oBAAoB,SAAS,EAAE,MAAM,gBAAgB,qBAAqB,QAAQ,sBAAsB;AAChH,MAAI,WAAW,SAAS,MAAM,OAAO;AACnC,QAAI,CAAC,gBAAgB;AACnB,aAAO;AAAA;AAGT,UAAM;AAAA,MACJ,SAAS,EAAE,OAAO;AAAA,QAChB;AAEJ,QAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;AAAe,aAAO;AAE/C,UAAM,OAAO;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAGF,QAAI;AAAiB,aAAO;AAC5B,WAAO,+BAA+B;AAAA;AAExC,SAAO;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/cjs/tree/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 tree_exports = {};
|
|
25
|
+
var React = __toESM(require("react"));
|
|
26
|
+
__reExport(tree_exports, require("./useTreeDndkitConfig"));
|
|
27
|
+
module.exports = __toCommonJS(tree_exports);
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/tree/index.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["export * from './useTreeDndkitConfig';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA,YAAuB;ADAvB,yBAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/cjs/tree/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/tree/types.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import {\n Active,\n Announcements,\n CollisionDetection,\n DragCancelEvent,\n DragEndEvent,\n DragMoveEvent,\n DragOverEvent,\n DragStartEvent,\n DroppableContainers,\n MeasuringConfiguration,\n Modifier,\n Over,\n ViewRect,\n} from '@dnd-kit/core';\nimport type { SensorDescriptor, SensorOptions } from '@dnd-kit/core/dist/sensors';\nimport type { SortingStrategy } from '@dnd-kit/sortable';\nimport { Coordinates } from '@dnd-kit/core/dist/types';\nimport React, { MutableRefObject } from 'react';\nimport { DropIndicatorPosition } from './constants';\n\nexport type Item<T = unknown> = {\n uid: string;\n depth: number;\n parentId: string | null;\n realIndex: number;\n childrenCount: number;\n original: T;\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 SortableContextPropsType = {\n items: string[];\n strategy: SortingStrategy;\n};\n\nexport type UseTreePreviewHandlersReturn = {\n handlePreviewDragStart: (e: DragStartEvent) => void;\n handlePreviewDragMove: (e: DragMoveEvent) => void;\n handlePreviewDragOver: (e: DragOverEvent) => void;\n handlePreviewDragEnd: (e: DragEndEvent) => void;\n handlePreviewDragCancel: (e: DragCancelEvent) => void;\n};\nexport type UseTreePreviewHandlersArgs = {\n setOverId: React.Dispatch<React.SetStateAction<string>>;\n setActiveId: React.Dispatch<React.SetStateAction<string>>;\n setDropIndicatorPosition: React.Dispatch<React.SetStateAction<DropIndicatorPosition>>;\n};\n\nexport type UseTreeActionHandlersArgs<T = unknown> = UseTreePreviewHandlersReturn & {\n dropIndicatorPosition: DropIndicatorPosition;\n flattenedItems: Item[];\n projected: {\n depth: number;\n parentId: string;\n } | null;\n onReorder: <S = T>(\n newData: Item<S>[],\n indexes: { targetIndex: number; fromIndex: number },\n considerExpanding: string,\n ) => void;\n isDropValid: boolean;\n};\n\nexport type UseTreeActionHandlersReturn = {\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 UseTreeDndkitConfigArgs<T> = {\n flattenedItems: Item[];\n visibleItems: Item[];\n isHorizontalDnD?: boolean;\n isExpandable: boolean;\n onReorder: <S = T>(\n newData: Item<S>[],\n indexes: { targetIndex: number; fromIndex: number },\n considerExpanding: string,\n ) => void;\n getIsDropValid: <S = T>(\n active: Item<S>,\n over: Item<S>,\n dropIndicatorPosition: 'none' | 'before' | 'after' | 'inside',\n ) => boolean;\n maxDragAndDropLevel: number;\n};\n\nexport type UseTreeDndkitConfigReturn = {\n dndContextProps: DndContextPropsType;\n sortableContextProps: SortableContextPropsType;\n activeId: string;\n activeIndex: number;\n overId: string;\n depth: number;\n dropIndicatorPosition: DropIndicatorPosition;\n isDropValid: boolean;\n visibleItems: Item[];\n};\n\nexport type UseTreeDndkitConfigType = <T = unknown>(args: UseTreeDndkitConfigArgs<T>) => UseTreeDndkitConfigReturn;\n\nexport type GetKeyboardCoordinatesArgs = {\n items: Item[];\n active: Active;\n over: Over;\n event: KeyboardEvent;\n currentCoordinates: Coordinates;\n droppableContainers: DroppableContainers;\n collisionRect: ViewRect;\n dropIndicatorPosition: DropIndicatorPosition;\n maxDragAndDropLevel: number;\n};\n\nexport type SensorContext = MutableRefObject<{\n items: Item[];\n dropIndicatorPosition: DropIndicatorPosition;\n setDropIndicatorPosition: React.Dispatch<React.SetStateAction<DropIndicatorPosition>>;\n}>;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA,YAAuB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|