@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.
Files changed (77) hide show
  1. package/cjs/hierarchy/customCollisionDetection.js +50 -44
  2. package/cjs/hierarchy/getHierarchyKeyboardCoordinates.js +91 -78
  3. package/cjs/hierarchy/index.js +9 -28
  4. package/cjs/hierarchy/types.js +2 -27
  5. package/cjs/hierarchy/useHierarchyActionHandlers.js +35 -53
  6. package/cjs/hierarchy/useHierarchyAnnouncements.js +26 -45
  7. package/cjs/hierarchy/useHierarchyDndkitConfig.js +83 -77
  8. package/cjs/hierarchy/useHierarchyPreviewHandlers.js +27 -48
  9. package/cjs/index.js +11 -29
  10. package/cjs/tree/constants.js +12 -41
  11. package/cjs/tree/customCollisionDetection.js +95 -64
  12. package/cjs/tree/getTreeKeyboardCoordinates.js +101 -87
  13. package/cjs/tree/index.js +9 -28
  14. package/cjs/tree/types.js +2 -27
  15. package/cjs/tree/useTreeActionHandlers.js +56 -66
  16. package/cjs/tree/useTreeAnnouncements.js +40 -53
  17. package/cjs/tree/useTreeDndkitConfig.js +91 -95
  18. package/cjs/tree/useTreePreviewHandlers.js +37 -53
  19. package/cjs/tree/utilities.js +30 -44
  20. package/esm/hierarchy/customCollisionDetection.js +46 -15
  21. package/esm/hierarchy/getHierarchyKeyboardCoordinates.js +76 -42
  22. package/esm/hierarchy/index.js +1 -3
  23. package/esm/hierarchy/types.js +1 -2
  24. package/esm/hierarchy/useHierarchyActionHandlers.js +31 -24
  25. package/esm/hierarchy/useHierarchyAnnouncements.js +20 -14
  26. package/esm/hierarchy/useHierarchyDndkitConfig.js +66 -45
  27. package/esm/hierarchy/useHierarchyPreviewHandlers.js +19 -15
  28. package/esm/index.js +2 -4
  29. package/esm/tree/constants.js +10 -12
  30. package/esm/tree/customCollisionDetection.js +89 -33
  31. package/esm/tree/getTreeKeyboardCoordinates.js +84 -49
  32. package/esm/tree/index.js +1 -3
  33. package/esm/tree/types.js +1 -2
  34. package/esm/tree/useTreeActionHandlers.js +50 -35
  35. package/esm/tree/useTreeAnnouncements.js +30 -18
  36. package/esm/tree/useTreeDndkitConfig.js +70 -59
  37. package/esm/tree/useTreePreviewHandlers.js +28 -19
  38. package/esm/tree/utilities.js +23 -13
  39. package/package.json +1 -1
  40. package/cjs/hierarchy/customCollisionDetection.js.map +0 -7
  41. package/cjs/hierarchy/getHierarchyKeyboardCoordinates.js.map +0 -7
  42. package/cjs/hierarchy/index.js.map +0 -7
  43. package/cjs/hierarchy/types.js.map +0 -7
  44. package/cjs/hierarchy/useHierarchyActionHandlers.js.map +0 -7
  45. package/cjs/hierarchy/useHierarchyAnnouncements.js.map +0 -7
  46. package/cjs/hierarchy/useHierarchyDndkitConfig.js.map +0 -7
  47. package/cjs/hierarchy/useHierarchyPreviewHandlers.js.map +0 -7
  48. package/cjs/index.js.map +0 -7
  49. package/cjs/tree/constants.js.map +0 -7
  50. package/cjs/tree/customCollisionDetection.js.map +0 -7
  51. package/cjs/tree/getTreeKeyboardCoordinates.js.map +0 -7
  52. package/cjs/tree/index.js.map +0 -7
  53. package/cjs/tree/types.js.map +0 -7
  54. package/cjs/tree/useTreeActionHandlers.js.map +0 -7
  55. package/cjs/tree/useTreeAnnouncements.js.map +0 -7
  56. package/cjs/tree/useTreeDndkitConfig.js.map +0 -7
  57. package/cjs/tree/useTreePreviewHandlers.js.map +0 -7
  58. package/cjs/tree/utilities.js.map +0 -7
  59. package/esm/hierarchy/customCollisionDetection.js.map +0 -7
  60. package/esm/hierarchy/getHierarchyKeyboardCoordinates.js.map +0 -7
  61. package/esm/hierarchy/index.js.map +0 -7
  62. package/esm/hierarchy/types.js.map +0 -7
  63. package/esm/hierarchy/useHierarchyActionHandlers.js.map +0 -7
  64. package/esm/hierarchy/useHierarchyAnnouncements.js.map +0 -7
  65. package/esm/hierarchy/useHierarchyDndkitConfig.js.map +0 -7
  66. package/esm/hierarchy/useHierarchyPreviewHandlers.js.map +0 -7
  67. package/esm/index.js.map +0 -7
  68. package/esm/tree/constants.js.map +0 -7
  69. package/esm/tree/customCollisionDetection.js.map +0 -7
  70. package/esm/tree/getTreeKeyboardCoordinates.js.map +0 -7
  71. package/esm/tree/index.js.map +0 -7
  72. package/esm/tree/types.js.map +0 -7
  73. package/esm/tree/useTreeActionHandlers.js.map +0 -7
  74. package/esm/tree/useTreeAnnouncements.js.map +0 -7
  75. package/esm/tree/useTreeDndkitConfig.js.map +0 -7
  76. package/esm/tree/useTreePreviewHandlers.js.map +0 -7
  77. package/esm/tree/utilities.js.map +0 -7
@@ -1,61 +1,97 @@
1
- import * as React from "react";
2
- import { closestCorners, getViewRect, KeyboardCode } from "@dnd-kit/core";
1
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
+ import 'core-js/modules/esnext.async-iterator.find.js';
3
+ import 'core-js/modules/esnext.iterator.constructor.js';
4
+ import 'core-js/modules/esnext.iterator.find.js';
5
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
6
+ import 'core-js/modules/esnext.iterator.for-each.js';
7
+ import 'core-js/modules/esnext.async-iterator.filter.js';
8
+ import 'core-js/modules/esnext.iterator.filter.js';
9
+ import { KeyboardCode, getViewRect, closestCorners } from '@dnd-kit/core';
10
+
11
+ 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; }
12
+
13
+ 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(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; }
3
14
  const directions = [KeyboardCode.Down, KeyboardCode.Right, KeyboardCode.Up, KeyboardCode.Left];
4
15
  const vertical = [KeyboardCode.Up, KeyboardCode.Down];
5
- const getHorizontalKeyboardCoordinates = ({
6
- items,
7
- active,
8
- over,
9
- event,
10
- currentCoordinates,
11
- droppableContainers,
12
- collisionRect
13
- }) => {
14
- if (vertical.includes(event.code) || !active || !over)
15
- return void 0;
16
- const activeItem = items.find((item) => item.id === active.id);
16
+
17
+ const getHorizontalKeyboardCoordinates = _ref => {
18
+ var _droppableContainers$, _droppableContainers$2, _droppableContainers$3, _droppableContainers$4;
19
+
20
+ let {
21
+ items,
22
+ active,
23
+ over,
24
+ event,
25
+ currentCoordinates,
26
+ droppableContainers,
27
+ collisionRect
28
+ } = _ref;
29
+ if (vertical.includes(event.code) || !active || !over) return undefined;
30
+ const activeItem = items.find(item => item.id === active.id);
17
31
  const overRect = over.rect;
18
- const layoutRects = [];
19
- droppableContainers.forEach((container) => {
20
- if (container?.disabled || !overRect) {
32
+ const layoutRects = []; // Get the reacheable rects depending on the arrow key pressed
33
+
34
+ droppableContainers.forEach(container => {
35
+ var _items$find;
36
+
37
+ if (container !== null && container !== void 0 && container.disabled || !overRect) {
21
38
  return;
22
39
  }
23
- const node = container?.node.current;
40
+
41
+ const node = container === null || container === void 0 ? void 0 : container.node.current;
42
+
24
43
  if (!node) {
25
44
  return;
26
45
  }
27
- const itemParent = items.find((item) => item.id === container.id)?.parentId;
28
- if (itemParent !== activeItem?.parentId)
29
- return;
46
+
47
+ const itemParent = (_items$find = items.find(item => item.id === container.id)) === null || _items$find === void 0 ? void 0 : _items$find.parentId;
48
+ if (itemParent !== (activeItem === null || activeItem === void 0 ? void 0 : activeItem.parentId)) return;
30
49
  const rect = getViewRect(node);
50
+
31
51
  if (event.code === KeyboardCode.Left && collisionRect.left > rect.right - 10) {
32
52
  layoutRects.push(container);
33
53
  } else if (event.code === KeyboardCode.Right && collisionRect.left < rect.left) {
34
54
  layoutRects.push(container);
35
55
  }
36
56
  });
37
- const closestId = closestCorners({ droppableContainers: layoutRects, collisionRect, active });
38
- if (!closestId)
39
- return void 0;
40
- const closestDroppableContainer = droppableContainers.get(closestId)?.node?.current;
41
- const activeDroppableContainer = droppableContainers.get(active?.id)?.node?.current;
42
- if (!closestDroppableContainer || !activeDroppableContainer)
43
- return void 0;
57
+ const closestId = closestCorners({
58
+ droppableContainers: layoutRects,
59
+ collisionRect,
60
+ active
61
+ });
62
+ if (!closestId) return undefined;
63
+ 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;
64
+ 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;
65
+ if (!closestDroppableContainer || !activeDroppableContainer) return undefined;
44
66
  const closestRect = getViewRect(closestDroppableContainer);
45
67
  const activeRect = getViewRect(activeDroppableContainer);
46
- return {
47
- ...currentCoordinates,
68
+ return _objectSpread(_objectSpread({}, currentCoordinates), {}, {
48
69
  x: closestRect.left + (closestRect.width - collisionRect.width) / 2 + (closestRect.offsetLeft < activeRect.left ? -1 : 1)
49
- };
70
+ });
50
71
  };
51
- const getHierarchyKeyboardCoordinates = (context, dragOverlayDataTestid, isHorizontalDnD) => (event, { currentCoordinates, context: { active, over, collisionRect, droppableContainers } }) => {
72
+
73
+ const getHierarchyKeyboardCoordinates = (context, dragOverlayDataTestid, isHorizontalDnD) => (event, _ref2) => {
74
+ let {
75
+ currentCoordinates,
76
+ context: {
77
+ active,
78
+ over,
79
+ collisionRect,
80
+ droppableContainers
81
+ }
82
+ } = _ref2;
83
+
52
84
  if (directions.includes(event.code)) {
53
85
  event.preventDefault();
86
+
54
87
  if (!collisionRect) {
55
- return void 0;
88
+ return undefined;
56
89
  }
90
+
57
91
  const {
58
- current: { items }
92
+ current: {
93
+ items
94
+ }
59
95
  } = context;
60
96
  const args = {
61
97
  dragOverlayDataTestid,
@@ -67,13 +103,11 @@ const getHierarchyKeyboardCoordinates = (context, dragOverlayDataTestid, isHoriz
67
103
  droppableContainers,
68
104
  collisionRect
69
105
  };
70
- if (isHorizontalDnD)
71
- return getHorizontalKeyboardCoordinates(args);
72
- return void 0;
106
+ if (isHorizontalDnD) return getHorizontalKeyboardCoordinates(args);
107
+ return undefined;
73
108
  }
74
- return void 0;
75
- };
76
- export {
77
- getHierarchyKeyboardCoordinates
109
+
110
+ return undefined;
78
111
  };
79
- //# sourceMappingURL=getHierarchyKeyboardCoordinates.js.map
112
+
113
+ export { getHierarchyKeyboardCoordinates };
@@ -1,3 +1 @@
1
- import * as React from "react";
2
- export * from "./useHierarchyDndkitConfig";
3
- //# sourceMappingURL=index.js.map
1
+ export { useHierarchyDndkitConfig } from './useHierarchyDndkitConfig.js';
@@ -1,2 +1 @@
1
- import * as React from "react";
2
- //# sourceMappingURL=types.js.map
1
+
@@ -1,39 +1,46 @@
1
- import * as React from "react";
2
- import { useCallback } from "react";
3
- const useHierarchyActionHandlers = ({
4
- handlePreviewDragStart,
5
- handlePreviewDragMove,
6
- handlePreviewDragEnd,
7
- handlePreviewDragCancel,
8
- onReorder,
9
- dndItems
10
- }) => {
11
- const onDragStart = useCallback((e) => {
1
+ import { useCallback } from 'react';
2
+
3
+ const useHierarchyActionHandlers = _ref => {
4
+ let {
5
+ handlePreviewDragStart,
6
+ handlePreviewDragMove,
7
+ handlePreviewDragEnd,
8
+ handlePreviewDragCancel,
9
+ onReorder,
10
+ dndItems
11
+ } = _ref;
12
+ const onDragStart = useCallback(e => {
12
13
  handlePreviewDragStart(e);
13
14
  }, [handlePreviewDragStart]);
14
- const onDragMove = useCallback((e) => {
15
+ const onDragMove = useCallback(e => {
15
16
  handlePreviewDragMove(e);
16
17
  }, [handlePreviewDragMove]);
17
- const onDragEnd = useCallback((e) => {
18
+ const onDragEnd = useCallback(e => {
18
19
  handlePreviewDragEnd(e);
19
- const { active, over } = e;
20
- if (!over)
21
- return;
20
+ const {
21
+ active,
22
+ over
23
+ } = e;
24
+ if (!over) return;
25
+
22
26
  if (active.id !== over.id) {
23
- const activeIndex = dndItems.findIndex((item) => item.id === active.id);
24
- const overIndex = dndItems.findIndex((item) => item.id === over.id);
27
+ const activeIndex = dndItems.findIndex(item => item.id === active.id);
28
+ const overIndex = dndItems.findIndex(item => item.id === over.id);
25
29
  onReorder(dndItems[activeIndex], {
26
30
  targetIndex: overIndex,
27
31
  fromIndex: activeIndex
28
32
  });
29
33
  }
30
34
  }, [handlePreviewDragEnd, dndItems, onReorder]);
31
- const onDragCancel = useCallback((e) => {
35
+ const onDragCancel = useCallback(e => {
32
36
  handlePreviewDragCancel(e);
33
37
  }, [handlePreviewDragCancel]);
34
- return { onDragStart, onDragMove, onDragEnd, onDragCancel };
38
+ return {
39
+ onDragStart,
40
+ onDragMove,
41
+ onDragEnd,
42
+ onDragCancel
43
+ };
35
44
  };
36
- export {
37
- useHierarchyActionHandlers
38
- };
39
- //# sourceMappingURL=useHierarchyActionHandlers.js.map
45
+
46
+ export { useHierarchyActionHandlers };
@@ -1,26 +1,32 @@
1
- import * as React from "react";
2
- import { useCallback } from "react";
3
- const useHierarchyAnnouncements = (visibleItemsDictionary) => {
4
- const onDragStart = useCallback((id) => `Picked up draggable item from position ${visibleItemsDictionary[id].index + 1}.`, [visibleItemsDictionary]);
1
+ import { useCallback } from 'react';
2
+
3
+ const useHierarchyAnnouncements = visibleItemsDictionary => {
4
+ const onDragStart = useCallback(id => "Picked up draggable item from position ".concat(visibleItemsDictionary[id].index + 1, "."), [visibleItemsDictionary]);
5
5
  const onDragMove = useCallback((id, overId) => {
6
6
  if (overId) {
7
7
  const overIndex = visibleItemsDictionary[overId].index + 1;
8
- return `Draggable item was moved to position ${overIndex}.`;
8
+ return "Draggable item was moved to position ".concat(overIndex, ".");
9
9
  }
10
- return `Draggable item is no longer over a droppable area.`;
10
+
11
+ return "Draggable item is no longer over a droppable area.";
11
12
  }, [visibleItemsDictionary]);
12
13
  const onDragOver = onDragMove;
13
14
  const onDragEnd = useCallback((id, overId) => {
14
15
  if (overId) {
15
16
  const overIndex = visibleItemsDictionary[overId].index + 1;
16
- return `Draggable item was dropped over position ${overIndex}.`;
17
+ return "Draggable item was dropped over position ".concat(overIndex, ".");
17
18
  }
18
- return `Draggable item was dropped at it's original position.`;
19
+
20
+ return "Draggable item was dropped at it's original position.";
19
21
  }, [visibleItemsDictionary]);
20
- const onDragCancel = useCallback((id) => `Dragging was cancelled. Draggable item from position ${visibleItemsDictionary[id].index + 1} was dropped at it's initial position.`, [visibleItemsDictionary]);
21
- return { onDragStart, onDragOver, onDragMove, onDragEnd, onDragCancel };
22
+ const onDragCancel = useCallback(id => "Dragging was cancelled. Draggable item from position ".concat(visibleItemsDictionary[id].index + 1, " was dropped at it's initial position."), [visibleItemsDictionary]);
23
+ return {
24
+ onDragStart,
25
+ onDragOver,
26
+ onDragMove,
27
+ onDragEnd,
28
+ onDragCancel
29
+ };
22
30
  };
23
- export {
24
- useHierarchyAnnouncements
25
- };
26
- //# sourceMappingURL=useHierarchyAnnouncements.js.map
31
+
32
+ export { useHierarchyAnnouncements };
@@ -1,47 +1,68 @@
1
- import * as React from "react";
2
- import { useState, useEffect, useMemo, useRef } from "react";
3
- import {
4
- useSensor,
5
- useSensors,
6
- KeyboardSensor,
7
- PointerSensor,
8
- MeasuringStrategy
9
- } from "@dnd-kit/core";
10
- import { useHierarchyActionHandlers } from "./useHierarchyActionHandlers";
11
- import { useHierarchyPreviewHandlers } from "./useHierarchyPreviewHandlers";
12
- import { getHierarchyKeyboardCoordinates } from "./getHierarchyKeyboardCoordinates";
13
- import { customCollisionDetection } from "./customCollisionDetection";
14
- import { useHierarchyAnnouncements } from "./useHierarchyAnnouncements";
15
- const adjustTranslate = (isHorizontalDnD) => ({ transform }) => {
16
- const newTransform = {
17
- ...transform
18
- };
1
+ import 'core-js/modules/esnext.async-iterator.filter.js';
2
+ import 'core-js/modules/esnext.iterator.filter.js';
3
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
4
+ import 'core-js/modules/web.dom-collections.iterator.js';
5
+ import 'core-js/modules/esnext.async-iterator.map.js';
6
+ import 'core-js/modules/esnext.iterator.map.js';
7
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
8
+ import 'core-js/modules/esnext.iterator.constructor.js';
9
+ import 'core-js/modules/esnext.iterator.for-each.js';
10
+ import { useState, useMemo, useRef, useEffect } from 'react';
11
+ import { MeasuringStrategy, useSensors, useSensor, PointerSensor, KeyboardSensor } from '@dnd-kit/core';
12
+ import { useHierarchyActionHandlers } from './useHierarchyActionHandlers.js';
13
+ import { useHierarchyPreviewHandlers } from './useHierarchyPreviewHandlers.js';
14
+ import { getHierarchyKeyboardCoordinates } from './getHierarchyKeyboardCoordinates.js';
15
+ import { customCollisionDetection } from './customCollisionDetection.js';
16
+ import { useHierarchyAnnouncements } from './useHierarchyAnnouncements.js';
17
+
18
+ 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; }
19
+
20
+ 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(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; }
21
+ // if second parameter is true, the space will be done on the horizontal axis
22
+
23
+ const adjustTranslate = isHorizontalDnD => _ref => {
24
+ let {
25
+ transform
26
+ } = _ref;
27
+
28
+ const newTransform = _objectSpread({}, transform);
29
+
19
30
  if (isHorizontalDnD) {
20
31
  newTransform.y = transform.y + 15;
21
32
  } else {
22
33
  newTransform.y = transform.y - 35;
23
34
  }
35
+
24
36
  return newTransform;
25
37
  };
38
+
26
39
  const measuring = {
27
40
  droppable: {
28
41
  strategy: MeasuringStrategy.Always
29
42
  }
30
43
  };
44
+
31
45
  const noop = () => null;
32
- const useHierarchyDndkitConfig = ({
33
- flattenedItems,
34
- dragOverlayDataTestid,
35
- isHorizontalDnD = false,
36
- onReorder,
37
- onPreviewResetState = noop,
38
- onPreviewDragStart = noop
39
- }) => {
40
- const [activeId, setActiveId] = useState("");
41
- const dndItems = useMemo(() => flattenedItems.map(([item]) => item), [flattenedItems]);
46
+
47
+ const useHierarchyDndkitConfig = _ref2 => {
48
+ var _itemsDictionary$acti;
49
+
50
+ let {
51
+ flattenedItems,
52
+ dragOverlayDataTestid,
53
+ isHorizontalDnD = false,
54
+ onReorder,
55
+ onPreviewResetState = noop,
56
+ onPreviewDragStart = noop
57
+ } = _ref2;
58
+ const [activeId, setActiveId] = useState('');
59
+ const dndItems = useMemo(() => flattenedItems.map(_ref3 => {
60
+ let [item] = _ref3;
61
+ return item;
62
+ }), [flattenedItems]);
42
63
  const itemsDictionary = useMemo(() => {
43
64
  const dictionary = {};
44
- dndItems.forEach((item) => {
65
+ dndItems.forEach(item => {
45
66
  dictionary[item.id] = item;
46
67
  });
47
68
  return dictionary;
@@ -64,27 +85,27 @@ const useHierarchyDndkitConfig = ({
64
85
  onPreviewResetState,
65
86
  onPreviewDragStart
66
87
  });
67
- const dragActionHandlers = useHierarchyActionHandlers({
68
- ...dragPreviewHandlers,
88
+ const dragActionHandlers = useHierarchyActionHandlers(_objectSpread(_objectSpread({}, dragPreviewHandlers), {}, {
69
89
  dndItems,
70
90
  onReorder
71
- });
91
+ }));
72
92
  const announcements = useHierarchyAnnouncements(itemsDictionary);
73
- const dndContextProps = useMemo(() => ({
74
- announcements,
75
- modifiers,
76
- sensors,
77
- measuring,
78
- collisionDetection: customCollisionDetection(activeId, itemsDictionary[activeId ?? ""]?.parentId, dndItems),
79
- ...dragActionHandlers
80
- }), [announcements, modifiers, sensors, activeId, itemsDictionary, dndItems, dragActionHandlers]);
93
+ const dndContextProps = useMemo(() => {
94
+ var _itemsDictionary;
95
+
96
+ return _objectSpread({
97
+ announcements,
98
+ modifiers,
99
+ sensors,
100
+ measuring,
101
+ collisionDetection: customCollisionDetection(activeId, (_itemsDictionary = itemsDictionary[activeId !== null && activeId !== void 0 ? activeId : '']) === null || _itemsDictionary === void 0 ? void 0 : _itemsDictionary.parentId, dndItems)
102
+ }, dragActionHandlers);
103
+ }, [announcements, modifiers, sensors, activeId, itemsDictionary, dndItems, dragActionHandlers]);
81
104
  return {
82
105
  dndContextProps,
83
106
  activeId,
84
- activeIndex: activeId ? itemsDictionary[activeId]?.index : -1
107
+ activeIndex: activeId ? (_itemsDictionary$acti = itemsDictionary[activeId]) === null || _itemsDictionary$acti === void 0 ? void 0 : _itemsDictionary$acti.index : -1
85
108
  };
86
109
  };
87
- export {
88
- useHierarchyDndkitConfig
89
- };
90
- //# sourceMappingURL=useHierarchyDndkitConfig.js.map
110
+
111
+ export { useHierarchyDndkitConfig };
@@ -1,18 +1,24 @@
1
- import * as React from "react";
2
- import { useCallback } from "react";
3
- const useHierarchyPreviewHandlers = ({
4
- setActiveId,
5
- onPreviewResetState,
6
- onPreviewDragStart
7
- }) => {
1
+ import { useCallback } from 'react';
2
+
3
+ const useHierarchyPreviewHandlers = _ref => {
4
+ let {
5
+ setActiveId,
6
+ onPreviewResetState,
7
+ onPreviewDragStart
8
+ } = _ref;
8
9
  const resetState = useCallback(() => {
9
- setActiveId("");
10
+ setActiveId('');
10
11
  onPreviewResetState();
11
- document.body.style.setProperty("cursor", "");
12
+ document.body.style.setProperty('cursor', '');
12
13
  }, [setActiveId, onPreviewResetState]);
13
- const handlePreviewDragStart = useCallback(({ active: { id } }) => {
14
+ const handlePreviewDragStart = useCallback(_ref2 => {
15
+ let {
16
+ active: {
17
+ id
18
+ }
19
+ } = _ref2;
14
20
  setActiveId(id);
15
- document.body.style.setProperty("cursor", "grabbing");
21
+ document.body.style.setProperty('cursor', 'grabbing');
16
22
  onPreviewDragStart();
17
23
  }, [setActiveId, onPreviewDragStart]);
18
24
  const handlePreviewDragMove = useCallback(() => null, []);
@@ -29,7 +35,5 @@ const useHierarchyPreviewHandlers = ({
29
35
  handlePreviewDragCancel
30
36
  };
31
37
  };
32
- export {
33
- useHierarchyPreviewHandlers
34
- };
35
- //# sourceMappingURL=useHierarchyPreviewHandlers.js.map
38
+
39
+ export { useHierarchyPreviewHandlers };
package/esm/index.js CHANGED
@@ -1,4 +1,2 @@
1
- import * as React from "react";
2
- export * from "./hierarchy";
3
- export * from "./tree";
4
- //# sourceMappingURL=index.js.map
1
+ export { useHierarchyDndkitConfig } from './hierarchy/useHierarchyDndkitConfig.js';
2
+ export { useTreeDndkitConfig } from './tree/useTreeDndkitConfig.js';
@@ -1,12 +1,10 @@
1
- import * as React from "react";
2
- var DropIndicatorPosition = /* @__PURE__ */ ((DropIndicatorPosition2) => {
3
- DropIndicatorPosition2[DropIndicatorPosition2["None"] = 0] = "None";
4
- DropIndicatorPosition2[DropIndicatorPosition2["Before"] = 1] = "Before";
5
- DropIndicatorPosition2[DropIndicatorPosition2["After"] = 2] = "After";
6
- DropIndicatorPosition2[DropIndicatorPosition2["Inside"] = 3] = "Inside";
7
- return DropIndicatorPosition2;
8
- })(DropIndicatorPosition || {});
9
- export {
10
- DropIndicatorPosition
11
- };
12
- //# sourceMappingURL=constants.js.map
1
+ let DropIndicatorPosition;
2
+
3
+ (function (DropIndicatorPosition) {
4
+ DropIndicatorPosition[DropIndicatorPosition["None"] = 0] = "None";
5
+ DropIndicatorPosition[DropIndicatorPosition["Before"] = 1] = "Before";
6
+ DropIndicatorPosition[DropIndicatorPosition["After"] = 2] = "After";
7
+ DropIndicatorPosition[DropIndicatorPosition["Inside"] = 3] = "Inside";
8
+ })(DropIndicatorPosition || (DropIndicatorPosition = {}));
9
+
10
+ export { DropIndicatorPosition };