@elliemae/ds-drag-and-drop 2.4.2-rc.9 → 2.4.2

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.
@@ -11,19 +11,15 @@ require('core-js/modules/esnext.async-iterator.for-each.js');
11
11
  require('core-js/modules/esnext.iterator.for-each.js');
12
12
 
13
13
  const customCollisionDetection = (activeId, activeParent, dndItems) => _ref => {
14
- var _originalContainer$re;
15
-
16
14
  let {
17
15
  droppableContainers,
18
16
  collisionRect
19
17
  } = _ref;
20
18
  const entriesWithSameParent = droppableContainers.filter(_ref2 => {
21
- var _dndItems$find;
22
-
23
19
  let {
24
20
  id
25
21
  } = _ref2;
26
- return ((_dndItems$find = dndItems.find(item => item.id === id)) === null || _dndItems$find === void 0 ? void 0 : _dndItems$find.parentId) === activeParent;
22
+ return dndItems.find(item => item.id === id)?.parentId === activeParent;
27
23
  });
28
24
  const originalContainer = entriesWithSameParent.find(_ref3 => {
29
25
  let {
@@ -31,7 +27,7 @@ const customCollisionDetection = (activeId, activeParent, dndItems) => _ref => {
31
27
  } = _ref3;
32
28
  return id === activeId;
33
29
  });
34
- const originalRect = originalContainer === null || originalContainer === void 0 ? void 0 : (_originalContainer$re = originalContainer.rect) === null || _originalContainer$re === void 0 ? void 0 : _originalContainer$re.current;
30
+ const originalRect = originalContainer?.rect?.current;
35
31
  if (!originalRect) return null;
36
32
 
37
33
  if (originalRect.offsetLeft <= collisionRect.offsetLeft && collisionRect.offsetLeft <= originalRect.offsetLeft + originalRect.width) {
@@ -23,8 +23,6 @@ const directions = [core.KeyboardCode.Down, core.KeyboardCode.Right, core.Keyboa
23
23
  const vertical = [core.KeyboardCode.Up, core.KeyboardCode.Down];
24
24
 
25
25
  const getHorizontalKeyboardCoordinates = _ref => {
26
- var _droppableContainers$, _droppableContainers$2, _droppableContainers$3, _droppableContainers$4;
27
-
28
26
  let {
29
27
  items,
30
28
  active,
@@ -40,20 +38,18 @@ const getHorizontalKeyboardCoordinates = _ref => {
40
38
  const layoutRects = []; // Get the reacheable rects depending on the arrow key pressed
41
39
 
42
40
  droppableContainers.forEach(container => {
43
- var _items$find;
44
-
45
- if (container !== null && container !== void 0 && container.disabled || !overRect) {
41
+ if (container?.disabled || !overRect) {
46
42
  return;
47
43
  }
48
44
 
49
- const node = container === null || container === void 0 ? void 0 : container.node.current;
45
+ const node = container?.node.current;
50
46
 
51
47
  if (!node) {
52
48
  return;
53
49
  }
54
50
 
55
- const itemParent = (_items$find = items.find(item => item.id === container.id)) === null || _items$find === void 0 ? void 0 : _items$find.parentId;
56
- if (itemParent !== (activeItem === null || activeItem === void 0 ? void 0 : activeItem.parentId)) return;
51
+ const itemParent = items.find(item => item.id === container.id)?.parentId;
52
+ if (itemParent !== activeItem?.parentId) return;
57
53
  const rect = core.getViewRect(node);
58
54
 
59
55
  if (event.code === core.KeyboardCode.Left && collisionRect.left > rect.right - 10) {
@@ -68,8 +64,8 @@ const getHorizontalKeyboardCoordinates = _ref => {
68
64
  active
69
65
  });
70
66
  if (!closestId) return undefined;
71
- const closestDroppableContainer = (_droppableContainers$ = droppableContainers.get(closestId)) === null || _droppableContainers$ === void 0 ? void 0 : (_droppableContainers$2 = _droppableContainers$.node) === null || _droppableContainers$2 === void 0 ? void 0 : _droppableContainers$2.current;
72
- const activeDroppableContainer = (_droppableContainers$3 = droppableContainers.get(active === null || active === void 0 ? void 0 : active.id)) === null || _droppableContainers$3 === void 0 ? void 0 : (_droppableContainers$4 = _droppableContainers$3.node) === null || _droppableContainers$4 === void 0 ? void 0 : _droppableContainers$4.current;
67
+ const closestDroppableContainer = droppableContainers.get(closestId)?.node?.current;
68
+ const activeDroppableContainer = droppableContainers.get(active?.id)?.node?.current;
73
69
  if (!closestDroppableContainer || !activeDroppableContainer) return undefined;
74
70
  const closestRect = core.getViewRect(closestDroppableContainer);
75
71
  const activeRect = core.getViewRect(activeDroppableContainer);
@@ -5,25 +5,25 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var react = require('react');
6
6
 
7
7
  const useHierarchyAnnouncements = visibleItemsDictionary => {
8
- const onDragStart = react.useCallback(id => "Picked up draggable item from position ".concat(visibleItemsDictionary[id].index + 1, "."), [visibleItemsDictionary]);
8
+ const onDragStart = react.useCallback(id => `Picked up draggable item from position ${visibleItemsDictionary[id].index + 1}.`, [visibleItemsDictionary]);
9
9
  const onDragMove = react.useCallback((id, overId) => {
10
10
  if (overId) {
11
11
  const overIndex = visibleItemsDictionary[overId].index + 1;
12
- return "Draggable item was moved to position ".concat(overIndex, ".");
12
+ return `Draggable item was moved to position ${overIndex}.`;
13
13
  }
14
14
 
15
- return "Draggable item is no longer over a droppable area.";
15
+ return `Draggable item is no longer over a droppable area.`;
16
16
  }, [visibleItemsDictionary]);
17
17
  const onDragOver = onDragMove;
18
18
  const onDragEnd = react.useCallback((id, overId) => {
19
19
  if (overId) {
20
20
  const overIndex = visibleItemsDictionary[overId].index + 1;
21
- return "Draggable item was dropped over position ".concat(overIndex, ".");
21
+ return `Draggable item was dropped over position ${overIndex}.`;
22
22
  }
23
23
 
24
- return "Draggable item was dropped at it's original position.";
24
+ return `Draggable item was dropped at it's original position.`;
25
25
  }, [visibleItemsDictionary]);
26
- const onDragCancel = react.useCallback(id => "Dragging was cancelled. Draggable item from position ".concat(visibleItemsDictionary[id].index + 1, " was dropped at it's initial position."), [visibleItemsDictionary]);
26
+ const onDragCancel = react.useCallback(id => `Dragging was cancelled. Draggable item from position ${visibleItemsDictionary[id].index + 1} was dropped at it's initial position.`, [visibleItemsDictionary]);
27
27
  return {
28
28
  onDragStart,
29
29
  onDragOver,
@@ -3,7 +3,6 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _defineProperty = require('@babel/runtime/helpers/defineProperty');
6
- require('core-js/modules/web.dom-collections.iterator.js');
7
6
  require('core-js/modules/esnext.async-iterator.map.js');
8
7
  require('core-js/modules/esnext.iterator.map.js');
9
8
  require('core-js/modules/esnext.async-iterator.for-each.js');
@@ -53,8 +52,6 @@ const measuring = {
53
52
  const noop = () => null;
54
53
 
55
54
  const useHierarchyDndkitConfig = _ref2 => {
56
- var _itemsDictionary$acti;
57
-
58
55
  let {
59
56
  flattenedItems,
60
57
  dragOverlayDataTestid,
@@ -98,21 +95,17 @@ const useHierarchyDndkitConfig = _ref2 => {
98
95
  onReorder
99
96
  }));
100
97
  const announcements = useHierarchyAnnouncements.useHierarchyAnnouncements(itemsDictionary);
101
- const dndContextProps = react.useMemo(() => {
102
- var _itemsDictionary;
103
-
104
- return _objectSpread({
105
- announcements,
106
- modifiers,
107
- sensors,
108
- measuring,
109
- collisionDetection: customCollisionDetection.customCollisionDetection(activeId, (_itemsDictionary = itemsDictionary[activeId !== null && activeId !== void 0 ? activeId : '']) === null || _itemsDictionary === void 0 ? void 0 : _itemsDictionary.parentId, dndItems)
110
- }, dragActionHandlers);
111
- }, [announcements, modifiers, sensors, activeId, itemsDictionary, dndItems, dragActionHandlers]);
98
+ const dndContextProps = react.useMemo(() => _objectSpread({
99
+ announcements,
100
+ modifiers,
101
+ sensors,
102
+ measuring,
103
+ collisionDetection: customCollisionDetection.customCollisionDetection(activeId, itemsDictionary[activeId ?? '']?.parentId, dndItems)
104
+ }, dragActionHandlers), [announcements, modifiers, sensors, activeId, itemsDictionary, dndItems, dragActionHandlers]);
112
105
  return {
113
106
  dndContextProps,
114
107
  activeId,
115
- activeIndex: activeId ? (_itemsDictionary$acti = itemsDictionary[activeId]) === null || _itemsDictionary$acti === void 0 ? void 0 : _itemsDictionary$acti.index : -1
108
+ activeIndex: activeId ? itemsDictionary[activeId]?.index : -1
116
109
  };
117
110
  };
118
111
 
@@ -7,7 +7,6 @@ require('core-js/modules/esnext.iterator.constructor.js');
7
7
  require('core-js/modules/esnext.iterator.find.js');
8
8
  require('core-js/modules/esnext.async-iterator.reduce.js');
9
9
  require('core-js/modules/esnext.iterator.reduce.js');
10
- require('core-js/modules/web.dom-collections.iterator.js');
11
10
  var constants = require('./constants.js');
12
11
 
13
12
  const DUMMY_ID = 'DUMMY_ID_INTERNAL_USE_ONLY';
@@ -35,8 +34,6 @@ const thresholdRatio = 0.2; // Percentage to be inside
35
34
  const insideThreshold = 0.7;
36
35
  const customCollisionDetection = (activeId, visibleItemsDictionary, setDropIndicatorPosition, maxDragAndDropLevel, lastPosition, setLastPosition) => {
37
36
  const func = _ref => {
38
- var _originalContainer$re;
39
-
40
37
  let {
41
38
  droppableContainers,
42
39
  collisionRect
@@ -47,7 +44,7 @@ const customCollisionDetection = (activeId, visibleItemsDictionary, setDropIndic
47
44
  } = _ref2;
48
45
  return id === activeId;
49
46
  });
50
- const originalRect = originalContainer === null || originalContainer === void 0 ? void 0 : (_originalContainer$re = originalContainer.rect) === null || _originalContainer$re === void 0 ? void 0 : _originalContainer$re.current; // We first check if the item was moved up or down
47
+ const originalRect = originalContainer?.rect?.current; // We first check if the item was moved up or down
51
48
  // This modifies how to search the matching colliding rect
52
49
 
53
50
  let isUp = lastPosition === 'up';
@@ -24,8 +24,6 @@ const directions = [core.KeyboardCode.Down, core.KeyboardCode.Right, core.Keyboa
24
24
  const horizontal = [core.KeyboardCode.Left, core.KeyboardCode.Right];
25
25
 
26
26
  const getVerticalKeyboardCoordinates = _ref => {
27
- var _droppableContainers$, _droppableContainers$2;
28
-
29
27
  let {
30
28
  items,
31
29
  active,
@@ -42,7 +40,7 @@ const getVerticalKeyboardCoordinates = _ref => {
42
40
  const layoutRects = []; // Get the reacheable rects depending on the arrow key pressed
43
41
 
44
42
  droppableContainers.forEach(container => {
45
- if (container !== null && container !== void 0 && container.disabled || !overRect) {
43
+ if (container?.disabled || !overRect) {
46
44
  return;
47
45
  }
48
46
 
@@ -61,7 +59,7 @@ const getVerticalKeyboardCoordinates = _ref => {
61
59
  active
62
60
  });
63
61
  const closestItem = items.find(item => item.uid === closestId);
64
- const closestElement = (_droppableContainers$ = droppableContainers.get(closestId)) === null || _droppableContainers$ === void 0 ? void 0 : (_droppableContainers$2 = _droppableContainers$.node) === null || _droppableContainers$2 === void 0 ? void 0 : _droppableContainers$2.current; // If no rect is closest, do nothing
62
+ const closestElement = droppableContainers.get(closestId)?.node?.current; // If no rect is closest, do nothing
65
63
 
66
64
  if (!closestId || !closestItem || !closestElement) return undefined;
67
65
  const closestRect = core.getViewRect(closestElement);
@@ -6,23 +6,23 @@ var react = require('react');
6
6
  var constants = require('./constants.js');
7
7
 
8
8
  const useTreeAnnouncements = (visibleItemsDictionary, dropIndicatorPosition) => {
9
- const onDragStart = react.useCallback(id => "Picked up draggable item from position ".concat(visibleItemsDictionary[id].realIndex + 1, "."), [visibleItemsDictionary]);
9
+ const onDragStart = react.useCallback(id => `Picked up draggable item from position ${visibleItemsDictionary[id].realIndex + 1}.`, [visibleItemsDictionary]);
10
10
  const onDragMove = react.useCallback((id, overId) => {
11
11
  if (overId) {
12
12
  const overIndex = visibleItemsDictionary[overId].realIndex + 1;
13
13
 
14
14
  if (dropIndicatorPosition === constants.DropIndicatorPosition.Inside) {
15
- return "Draggable item was moved inside the item at position ".concat(overIndex, ".");
15
+ return `Draggable item was moved inside the item at position ${overIndex}.`;
16
16
  }
17
17
 
18
18
  if (dropIndicatorPosition === constants.DropIndicatorPosition.Before) {
19
- return "Draggable item was moved to position ".concat(overIndex - 1, ".");
19
+ return `Draggable item was moved to position ${overIndex - 1}.`;
20
20
  }
21
21
 
22
- return "Draggable item was moved to position ".concat(overIndex, ".");
22
+ return `Draggable item was moved to position ${overIndex}.`;
23
23
  }
24
24
 
25
- return "Draggable item is no longer over a droppable area.";
25
+ return `Draggable item is no longer over a droppable area.`;
26
26
  }, [visibleItemsDictionary, dropIndicatorPosition]);
27
27
  const onDragOver = onDragMove;
28
28
  const onDragEnd = react.useCallback((id, overId) => {
@@ -30,19 +30,19 @@ const useTreeAnnouncements = (visibleItemsDictionary, dropIndicatorPosition) =>
30
30
  const overIndex = visibleItemsDictionary[overId].realIndex + 1;
31
31
 
32
32
  if (dropIndicatorPosition === constants.DropIndicatorPosition.Inside) {
33
- return "Draggable item was dropped inside the item at position ".concat(overIndex, ".");
33
+ return `Draggable item was dropped inside the item at position ${overIndex}.`;
34
34
  }
35
35
 
36
36
  if (dropIndicatorPosition === constants.DropIndicatorPosition.Before) {
37
- return "Draggable item was dropped over position ".concat(overIndex - 1, ".");
37
+ return `Draggable item was dropped over position ${overIndex - 1}.`;
38
38
  }
39
39
 
40
- return "Draggable item was dropped over position ".concat(overIndex, ".");
40
+ return `Draggable item was dropped over position ${overIndex}.`;
41
41
  }
42
42
 
43
- return "Draggable item was dropped at it's original position.";
43
+ return `Draggable item was dropped at it's original position.`;
44
44
  }, [dropIndicatorPosition, visibleItemsDictionary]);
45
- const onDragCancel = react.useCallback(id => "Dragging was cancelled. Draggable item from position ".concat(visibleItemsDictionary[id].realIndex + 1, " was dropped at it's initial position."), [visibleItemsDictionary]);
45
+ const onDragCancel = react.useCallback(id => `Dragging was cancelled. Draggable item from position ${visibleItemsDictionary[id].realIndex + 1} was dropped at it's initial position.`, [visibleItemsDictionary]);
46
46
  return {
47
47
  onDragStart,
48
48
  onDragOver,
@@ -3,7 +3,6 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _defineProperty = require('@babel/runtime/helpers/defineProperty');
6
- require('core-js/modules/web.dom-collections.iterator.js');
7
6
  require('core-js/modules/esnext.async-iterator.map.js');
8
7
  require('core-js/modules/esnext.iterator.map.js');
9
8
  require('core-js/modules/esnext.async-iterator.for-each.js');
@@ -56,8 +55,6 @@ const measuring = {
56
55
  }
57
56
  };
58
57
  const useTreeDndkitConfig = _ref2 => {
59
- var _visibleItemsDictiona, _visibleItemsDictiona2;
60
-
61
58
  let {
62
59
  flattenedItems,
63
60
  visibleItems: preVisibleItems,
@@ -141,7 +138,7 @@ const useTreeDndkitConfig = _ref2 => {
141
138
  sortableContextProps,
142
139
  isDropValid,
143
140
  activeId,
144
- activeIndex: (_visibleItemsDictiona = (_visibleItemsDictiona2 = visibleItemsDictionary[activeId]) === null || _visibleItemsDictiona2 === void 0 ? void 0 : _visibleItemsDictiona2.realIndex) !== null && _visibleItemsDictiona !== void 0 ? _visibleItemsDictiona : -1,
141
+ activeIndex: visibleItemsDictionary[activeId]?.realIndex ?? -1,
145
142
  overId,
146
143
  depth: projected ? projected.depth : 0,
147
144
  dropIndicatorPosition,
@@ -29,12 +29,10 @@ const useTreePreviewHandlers = _ref => {
29
29
  }, [setActiveId, setDropIndicatorPosition, setOverId]);
30
30
  const handlePreviewDragMove = react.useCallback(() => null, []);
31
31
  const handlePreviewDragOver = react.useCallback(_ref3 => {
32
- var _over$id;
33
-
34
32
  let {
35
33
  over
36
34
  } = _ref3;
37
- setOverId((_over$id = over === null || over === void 0 ? void 0 : over.id) !== null && _over$id !== void 0 ? _over$id : '');
35
+ setOverId(over?.id ?? '');
38
36
  }, [setOverId]);
39
37
  const handlePreviewDragEnd = react.useCallback(() => {
40
38
  resetState();
@@ -33,7 +33,7 @@ const getProjection = (items, visibleItemsDictionary, overId, dropIndicatorPosit
33
33
 
34
34
  return {
35
35
  depth: getMinDepth(nextItem),
36
- parentId: nextItem === null || nextItem === void 0 ? void 0 : nextItem.parentId
36
+ parentId: nextItem?.parentId
37
37
  };
38
38
  };
39
39
  const removeChildrenOf = (items, id) => {
@@ -7,19 +7,15 @@ import 'core-js/modules/esnext.async-iterator.for-each.js';
7
7
  import 'core-js/modules/esnext.iterator.for-each.js';
8
8
 
9
9
  const customCollisionDetection = (activeId, activeParent, dndItems) => _ref => {
10
- var _originalContainer$re;
11
-
12
10
  let {
13
11
  droppableContainers,
14
12
  collisionRect
15
13
  } = _ref;
16
14
  const entriesWithSameParent = droppableContainers.filter(_ref2 => {
17
- var _dndItems$find;
18
-
19
15
  let {
20
16
  id
21
17
  } = _ref2;
22
- return ((_dndItems$find = dndItems.find(item => item.id === id)) === null || _dndItems$find === void 0 ? void 0 : _dndItems$find.parentId) === activeParent;
18
+ return dndItems.find(item => item.id === id)?.parentId === activeParent;
23
19
  });
24
20
  const originalContainer = entriesWithSameParent.find(_ref3 => {
25
21
  let {
@@ -27,7 +23,7 @@ const customCollisionDetection = (activeId, activeParent, dndItems) => _ref => {
27
23
  } = _ref3;
28
24
  return id === activeId;
29
25
  });
30
- const originalRect = originalContainer === null || originalContainer === void 0 ? void 0 : (_originalContainer$re = originalContainer.rect) === null || _originalContainer$re === void 0 ? void 0 : _originalContainer$re.current;
26
+ const originalRect = originalContainer?.rect?.current;
31
27
  if (!originalRect) return null;
32
28
 
33
29
  if (originalRect.offsetLeft <= collisionRect.offsetLeft && collisionRect.offsetLeft <= originalRect.offsetLeft + originalRect.width) {
@@ -15,8 +15,6 @@ const directions = [KeyboardCode.Down, KeyboardCode.Right, KeyboardCode.Up, Keyb
15
15
  const vertical = [KeyboardCode.Up, KeyboardCode.Down];
16
16
 
17
17
  const getHorizontalKeyboardCoordinates = _ref => {
18
- var _droppableContainers$, _droppableContainers$2, _droppableContainers$3, _droppableContainers$4;
19
-
20
18
  let {
21
19
  items,
22
20
  active,
@@ -32,20 +30,18 @@ const getHorizontalKeyboardCoordinates = _ref => {
32
30
  const layoutRects = []; // Get the reacheable rects depending on the arrow key pressed
33
31
 
34
32
  droppableContainers.forEach(container => {
35
- var _items$find;
36
-
37
- if (container !== null && container !== void 0 && container.disabled || !overRect) {
33
+ if (container?.disabled || !overRect) {
38
34
  return;
39
35
  }
40
36
 
41
- const node = container === null || container === void 0 ? void 0 : container.node.current;
37
+ const node = container?.node.current;
42
38
 
43
39
  if (!node) {
44
40
  return;
45
41
  }
46
42
 
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;
43
+ const itemParent = items.find(item => item.id === container.id)?.parentId;
44
+ if (itemParent !== activeItem?.parentId) return;
49
45
  const rect = getViewRect(node);
50
46
 
51
47
  if (event.code === KeyboardCode.Left && collisionRect.left > rect.right - 10) {
@@ -60,8 +56,8 @@ const getHorizontalKeyboardCoordinates = _ref => {
60
56
  active
61
57
  });
62
58
  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;
59
+ const closestDroppableContainer = droppableContainers.get(closestId)?.node?.current;
60
+ const activeDroppableContainer = droppableContainers.get(active?.id)?.node?.current;
65
61
  if (!closestDroppableContainer || !activeDroppableContainer) return undefined;
66
62
  const closestRect = getViewRect(closestDroppableContainer);
67
63
  const activeRect = getViewRect(activeDroppableContainer);
@@ -1,25 +1,25 @@
1
1
  import { useCallback } from 'react';
2
2
 
3
3
  const useHierarchyAnnouncements = visibleItemsDictionary => {
4
- const onDragStart = useCallback(id => "Picked up draggable item from position ".concat(visibleItemsDictionary[id].index + 1, "."), [visibleItemsDictionary]);
4
+ const onDragStart = useCallback(id => `Picked up draggable item from position ${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 ".concat(overIndex, ".");
8
+ return `Draggable item was moved to position ${overIndex}.`;
9
9
  }
10
10
 
11
- return "Draggable item is no longer over a droppable area.";
11
+ return `Draggable item is no longer over a droppable area.`;
12
12
  }, [visibleItemsDictionary]);
13
13
  const onDragOver = onDragMove;
14
14
  const onDragEnd = useCallback((id, overId) => {
15
15
  if (overId) {
16
16
  const overIndex = visibleItemsDictionary[overId].index + 1;
17
- return "Draggable item was dropped over position ".concat(overIndex, ".");
17
+ return `Draggable item was dropped over position ${overIndex}.`;
18
18
  }
19
19
 
20
- return "Draggable item was dropped at it's original position.";
20
+ return `Draggable item was dropped at it's original position.`;
21
21
  }, [visibleItemsDictionary]);
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]);
22
+ const onDragCancel = useCallback(id => `Dragging was cancelled. Draggable item from position ${visibleItemsDictionary[id].index + 1} was dropped at it's initial position.`, [visibleItemsDictionary]);
23
23
  return {
24
24
  onDragStart,
25
25
  onDragOver,
@@ -1,7 +1,6 @@
1
1
  import 'core-js/modules/esnext.async-iterator.filter.js';
2
2
  import 'core-js/modules/esnext.iterator.filter.js';
3
3
  import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
4
- import 'core-js/modules/web.dom-collections.iterator.js';
5
4
  import 'core-js/modules/esnext.async-iterator.map.js';
6
5
  import 'core-js/modules/esnext.iterator.map.js';
7
6
  import 'core-js/modules/esnext.async-iterator.for-each.js';
@@ -45,8 +44,6 @@ const measuring = {
45
44
  const noop = () => null;
46
45
 
47
46
  const useHierarchyDndkitConfig = _ref2 => {
48
- var _itemsDictionary$acti;
49
-
50
47
  let {
51
48
  flattenedItems,
52
49
  dragOverlayDataTestid,
@@ -90,21 +87,17 @@ const useHierarchyDndkitConfig = _ref2 => {
90
87
  onReorder
91
88
  }));
92
89
  const announcements = useHierarchyAnnouncements(itemsDictionary);
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]);
90
+ const dndContextProps = useMemo(() => _objectSpread({
91
+ announcements,
92
+ modifiers,
93
+ sensors,
94
+ measuring,
95
+ collisionDetection: customCollisionDetection(activeId, itemsDictionary[activeId ?? '']?.parentId, dndItems)
96
+ }, dragActionHandlers), [announcements, modifiers, sensors, activeId, itemsDictionary, dndItems, dragActionHandlers]);
104
97
  return {
105
98
  dndContextProps,
106
99
  activeId,
107
- activeIndex: activeId ? (_itemsDictionary$acti = itemsDictionary[activeId]) === null || _itemsDictionary$acti === void 0 ? void 0 : _itemsDictionary$acti.index : -1
100
+ activeIndex: activeId ? itemsDictionary[activeId]?.index : -1
108
101
  };
109
102
  };
110
103
 
@@ -3,7 +3,6 @@ import 'core-js/modules/esnext.iterator.constructor.js';
3
3
  import 'core-js/modules/esnext.iterator.find.js';
4
4
  import 'core-js/modules/esnext.async-iterator.reduce.js';
5
5
  import 'core-js/modules/esnext.iterator.reduce.js';
6
- import 'core-js/modules/web.dom-collections.iterator.js';
7
6
  import { DropIndicatorPosition } from './constants.js';
8
7
 
9
8
  const DUMMY_ID = 'DUMMY_ID_INTERNAL_USE_ONLY';
@@ -31,8 +30,6 @@ const thresholdRatio = 0.2; // Percentage to be inside
31
30
  const insideThreshold = 0.7;
32
31
  const customCollisionDetection = (activeId, visibleItemsDictionary, setDropIndicatorPosition, maxDragAndDropLevel, lastPosition, setLastPosition) => {
33
32
  const func = _ref => {
34
- var _originalContainer$re;
35
-
36
33
  let {
37
34
  droppableContainers,
38
35
  collisionRect
@@ -43,7 +40,7 @@ const customCollisionDetection = (activeId, visibleItemsDictionary, setDropIndic
43
40
  } = _ref2;
44
41
  return id === activeId;
45
42
  });
46
- const originalRect = originalContainer === null || originalContainer === void 0 ? void 0 : (_originalContainer$re = originalContainer.rect) === null || _originalContainer$re === void 0 ? void 0 : _originalContainer$re.current; // We first check if the item was moved up or down
43
+ const originalRect = originalContainer?.rect?.current; // We first check if the item was moved up or down
47
44
  // This modifies how to search the matching colliding rect
48
45
 
49
46
  let isUp = lastPosition === 'up';
@@ -16,8 +16,6 @@ const directions = [KeyboardCode.Down, KeyboardCode.Right, KeyboardCode.Up, Keyb
16
16
  const horizontal = [KeyboardCode.Left, KeyboardCode.Right];
17
17
 
18
18
  const getVerticalKeyboardCoordinates = _ref => {
19
- var _droppableContainers$, _droppableContainers$2;
20
-
21
19
  let {
22
20
  items,
23
21
  active,
@@ -34,7 +32,7 @@ const getVerticalKeyboardCoordinates = _ref => {
34
32
  const layoutRects = []; // Get the reacheable rects depending on the arrow key pressed
35
33
 
36
34
  droppableContainers.forEach(container => {
37
- if (container !== null && container !== void 0 && container.disabled || !overRect) {
35
+ if (container?.disabled || !overRect) {
38
36
  return;
39
37
  }
40
38
 
@@ -53,7 +51,7 @@ const getVerticalKeyboardCoordinates = _ref => {
53
51
  active
54
52
  });
55
53
  const closestItem = items.find(item => item.uid === closestId);
56
- const closestElement = (_droppableContainers$ = droppableContainers.get(closestId)) === null || _droppableContainers$ === void 0 ? void 0 : (_droppableContainers$2 = _droppableContainers$.node) === null || _droppableContainers$2 === void 0 ? void 0 : _droppableContainers$2.current; // If no rect is closest, do nothing
54
+ const closestElement = droppableContainers.get(closestId)?.node?.current; // If no rect is closest, do nothing
57
55
 
58
56
  if (!closestId || !closestItem || !closestElement) return undefined;
59
57
  const closestRect = getViewRect(closestElement);
@@ -2,23 +2,23 @@ import { useCallback } from 'react';
2
2
  import { DropIndicatorPosition } from './constants.js';
3
3
 
4
4
  const useTreeAnnouncements = (visibleItemsDictionary, dropIndicatorPosition) => {
5
- const onDragStart = useCallback(id => "Picked up draggable item from position ".concat(visibleItemsDictionary[id].realIndex + 1, "."), [visibleItemsDictionary]);
5
+ const onDragStart = useCallback(id => `Picked up draggable item from position ${visibleItemsDictionary[id].realIndex + 1}.`, [visibleItemsDictionary]);
6
6
  const onDragMove = useCallback((id, overId) => {
7
7
  if (overId) {
8
8
  const overIndex = visibleItemsDictionary[overId].realIndex + 1;
9
9
 
10
10
  if (dropIndicatorPosition === DropIndicatorPosition.Inside) {
11
- return "Draggable item was moved inside the item at position ".concat(overIndex, ".");
11
+ return `Draggable item was moved inside the item at position ${overIndex}.`;
12
12
  }
13
13
 
14
14
  if (dropIndicatorPosition === DropIndicatorPosition.Before) {
15
- return "Draggable item was moved to position ".concat(overIndex - 1, ".");
15
+ return `Draggable item was moved to position ${overIndex - 1}.`;
16
16
  }
17
17
 
18
- return "Draggable item was moved to position ".concat(overIndex, ".");
18
+ return `Draggable item was moved to position ${overIndex}.`;
19
19
  }
20
20
 
21
- return "Draggable item is no longer over a droppable area.";
21
+ return `Draggable item is no longer over a droppable area.`;
22
22
  }, [visibleItemsDictionary, dropIndicatorPosition]);
23
23
  const onDragOver = onDragMove;
24
24
  const onDragEnd = useCallback((id, overId) => {
@@ -26,19 +26,19 @@ const useTreeAnnouncements = (visibleItemsDictionary, dropIndicatorPosition) =>
26
26
  const overIndex = visibleItemsDictionary[overId].realIndex + 1;
27
27
 
28
28
  if (dropIndicatorPosition === DropIndicatorPosition.Inside) {
29
- return "Draggable item was dropped inside the item at position ".concat(overIndex, ".");
29
+ return `Draggable item was dropped inside the item at position ${overIndex}.`;
30
30
  }
31
31
 
32
32
  if (dropIndicatorPosition === DropIndicatorPosition.Before) {
33
- return "Draggable item was dropped over position ".concat(overIndex - 1, ".");
33
+ return `Draggable item was dropped over position ${overIndex - 1}.`;
34
34
  }
35
35
 
36
- return "Draggable item was dropped over position ".concat(overIndex, ".");
36
+ return `Draggable item was dropped over position ${overIndex}.`;
37
37
  }
38
38
 
39
- return "Draggable item was dropped at it's original position.";
39
+ return `Draggable item was dropped at it's original position.`;
40
40
  }, [dropIndicatorPosition, visibleItemsDictionary]);
41
- const onDragCancel = useCallback(id => "Dragging was cancelled. Draggable item from position ".concat(visibleItemsDictionary[id].realIndex + 1, " was dropped at it's initial position."), [visibleItemsDictionary]);
41
+ const onDragCancel = useCallback(id => `Dragging was cancelled. Draggable item from position ${visibleItemsDictionary[id].realIndex + 1} was dropped at it's initial position.`, [visibleItemsDictionary]);
42
42
  return {
43
43
  onDragStart,
44
44
  onDragOver,
@@ -1,7 +1,6 @@
1
1
  import 'core-js/modules/esnext.async-iterator.filter.js';
2
2
  import 'core-js/modules/esnext.iterator.filter.js';
3
3
  import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
4
- import 'core-js/modules/web.dom-collections.iterator.js';
5
4
  import 'core-js/modules/esnext.async-iterator.map.js';
6
5
  import 'core-js/modules/esnext.iterator.map.js';
7
6
  import 'core-js/modules/esnext.async-iterator.for-each.js';
@@ -48,8 +47,6 @@ const measuring = {
48
47
  }
49
48
  };
50
49
  const useTreeDndkitConfig = _ref2 => {
51
- var _visibleItemsDictiona, _visibleItemsDictiona2;
52
-
53
50
  let {
54
51
  flattenedItems,
55
52
  visibleItems: preVisibleItems,
@@ -133,7 +130,7 @@ const useTreeDndkitConfig = _ref2 => {
133
130
  sortableContextProps,
134
131
  isDropValid,
135
132
  activeId,
136
- activeIndex: (_visibleItemsDictiona = (_visibleItemsDictiona2 = visibleItemsDictionary[activeId]) === null || _visibleItemsDictiona2 === void 0 ? void 0 : _visibleItemsDictiona2.realIndex) !== null && _visibleItemsDictiona !== void 0 ? _visibleItemsDictiona : -1,
133
+ activeIndex: visibleItemsDictionary[activeId]?.realIndex ?? -1,
137
134
  overId,
138
135
  depth: projected ? projected.depth : 0,
139
136
  dropIndicatorPosition,
@@ -25,12 +25,10 @@ const useTreePreviewHandlers = _ref => {
25
25
  }, [setActiveId, setDropIndicatorPosition, setOverId]);
26
26
  const handlePreviewDragMove = useCallback(() => null, []);
27
27
  const handlePreviewDragOver = useCallback(_ref3 => {
28
- var _over$id;
29
-
30
28
  let {
31
29
  over
32
30
  } = _ref3;
33
- setOverId((_over$id = over === null || over === void 0 ? void 0 : over.id) !== null && _over$id !== void 0 ? _over$id : '');
31
+ setOverId(over?.id ?? '');
34
32
  }, [setOverId]);
35
33
  const handlePreviewDragEnd = useCallback(() => {
36
34
  resetState();
@@ -29,7 +29,7 @@ const getProjection = (items, visibleItemsDictionary, overId, dropIndicatorPosit
29
29
 
30
30
  return {
31
31
  depth: getMinDepth(nextItem),
32
- parentId: nextItem === null || nextItem === void 0 ? void 0 : nextItem.parentId
32
+ parentId: nextItem?.parentId
33
33
  };
34
34
  };
35
35
  const removeChildrenOf = (items, id) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-drag-and-drop",
3
- "version": "2.4.2-rc.9",
3
+ "version": "2.4.2",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Drag And Drop",
6
6
  "module": "./esm/index.js",