@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,146 +1,142 @@
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 useTreeDndkitConfig_exports = {};
29
- __export(useTreeDndkitConfig_exports, {
30
- useTreeDndkitConfig: () => useTreeDndkitConfig
31
- });
32
- var React = __toESM(require("react"));
33
- var import_react = __toESM(require("react"));
34
- var import_core = __toESM(require("@dnd-kit/core"));
35
- var import_sortable = __toESM(require("@dnd-kit/sortable"));
36
- var import_useTreePreviewHandlers = __toESM(require("./useTreePreviewHandlers"));
37
- var import_getTreeKeyboardCoordinates = __toESM(require("./getTreeKeyboardCoordinates"));
38
- var import_utilities = __toESM(require("./utilities"));
39
- var import_useTreeActionHandlers = __toESM(require("./useTreeActionHandlers"));
40
- var import_constants = __toESM(require("./constants"));
41
- var import_customCollisionDetection = __toESM(require("./customCollisionDetection"));
42
- var import_useTreeAnnouncements = __toESM(require("./useTreeAnnouncements"));
43
- const adjustTranslate = (isHorizontalDnD) => ({ transform }) => {
44
- const newTransform = {
45
- ...transform
46
- };
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
6
+ require('core-js/modules/web.dom-collections.iterator.js');
7
+ require('core-js/modules/esnext.async-iterator.map.js');
8
+ require('core-js/modules/esnext.iterator.map.js');
9
+ require('core-js/modules/esnext.async-iterator.for-each.js');
10
+ require('core-js/modules/esnext.iterator.constructor.js');
11
+ require('core-js/modules/esnext.iterator.for-each.js');
12
+ require('core-js/modules/esnext.async-iterator.filter.js');
13
+ require('core-js/modules/esnext.iterator.filter.js');
14
+ var react = require('react');
15
+ var core = require('@dnd-kit/core');
16
+ var sortable = require('@dnd-kit/sortable');
17
+ var useTreePreviewHandlers = require('./useTreePreviewHandlers.js');
18
+ var getTreeKeyboardCoordinates = require('./getTreeKeyboardCoordinates.js');
19
+ var utilities = require('./utilities.js');
20
+ var useTreeActionHandlers = require('./useTreeActionHandlers.js');
21
+ var constants = require('./constants.js');
22
+ var customCollisionDetection = require('./customCollisionDetection.js');
23
+ var useTreeAnnouncements = require('./useTreeAnnouncements.js');
24
+
25
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
26
+
27
+ var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
28
+
29
+ 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; }
30
+
31
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
32
+ // if second parameter is true, the space will be done on the horizontal axis
33
+
34
+ const adjustTranslate = isHorizontalDnD => _ref => {
35
+ let {
36
+ transform
37
+ } = _ref;
38
+
39
+ const newTransform = _objectSpread({}, transform);
40
+
47
41
  if (isHorizontalDnD) {
48
42
  newTransform.x = transform.x + 25;
49
43
  } else {
50
44
  newTransform.x = transform.x + 15;
51
45
  }
46
+
52
47
  return newTransform;
53
48
  };
49
+
54
50
  const measuring = {
55
51
  droppable: {
56
- strategy: import_core.MeasuringStrategy.BeforeDragging
52
+ strategy: core.MeasuringStrategy.BeforeDragging
57
53
  }
58
54
  };
59
- const useTreeDndkitConfig = ({
60
- flattenedItems,
61
- visibleItems: preVisibleItems,
62
- isHorizontalDnD = false,
63
- isExpandable = false,
64
- onReorder,
65
- maxDragAndDropLevel
66
- }) => {
67
- const [activeId, setActiveId] = (0, import_react.useState)("");
68
- const [overId, setOverId] = (0, import_react.useState)("");
69
- const [dropIndicatorPosition, setDropIndicatorPosition] = (0, import_react.useState)(import_constants.DropIndicatorPosition.None);
70
- const [lastPosition, setLastPosition] = (0, import_react.useState)("");
71
- const visibleItems = (0, import_react.useMemo)(() => (0, import_utilities.removeChildrenOf)(preVisibleItems, activeId), [preVisibleItems, activeId]);
72
- const sortedIds = (0, import_react.useMemo)(() => visibleItems.map((item) => item.uid), [visibleItems]);
73
- const visibleItemsDictionary = (0, import_react.useMemo)(() => {
55
+ const useTreeDndkitConfig = _ref2 => {
56
+ var _visibleItemsDictiona, _visibleItemsDictiona2;
57
+
58
+ let {
59
+ flattenedItems,
60
+ visibleItems: preVisibleItems,
61
+ isHorizontalDnD = false,
62
+ isExpandable = false,
63
+ onReorder,
64
+ maxDragAndDropLevel
65
+ } = _ref2;
66
+ const [activeId, setActiveId] = react.useState('');
67
+ const [overId, setOverId] = react.useState('');
68
+ const [dropIndicatorPosition, setDropIndicatorPosition] = react.useState(constants.DropIndicatorPosition.None);
69
+ const [lastPosition, setLastPosition] = react.useState(''); // Remove activeId's children
70
+
71
+ const visibleItems = react.useMemo(() => utilities.removeChildrenOf(preVisibleItems, activeId), [preVisibleItems, activeId]); // Sorted ids for the library
72
+
73
+ const sortedIds = react.useMemo(() => visibleItems.map(item => item.uid), [visibleItems]);
74
+ /**
75
+ * Dictionary from UID to ITEM
76
+ * This dictionary is computed since on every DnD move, I need to know the
77
+ * depth of a particular row, so O(1) per DnD move instead of O(#ITEMS)
78
+ */
79
+
80
+ const visibleItemsDictionary = react.useMemo(() => {
81
+ // Using plain for to achieve O(#ITEMS) performance
74
82
  const dictionary = {};
75
- visibleItems.forEach((item) => {
83
+ visibleItems.forEach(item => {
76
84
  dictionary[item.uid] = item;
77
85
  });
78
86
  return dictionary;
79
87
  }, [visibleItems]);
80
- const modifiers = (0, import_react.useMemo)(() => [adjustTranslate(isHorizontalDnD)], [isHorizontalDnD]);
81
- const sensorContext = (0, import_react.useRef)({
88
+ const modifiers = react.useMemo(() => [adjustTranslate(isHorizontalDnD)], [isHorizontalDnD]);
89
+ const sensorContext = react.useRef({
82
90
  items: visibleItems,
83
91
  dropIndicatorPosition,
84
92
  setDropIndicatorPosition
85
93
  });
86
- (0, import_react.useEffect)(() => {
94
+ react.useEffect(() => {
87
95
  sensorContext.current = {
88
96
  items: visibleItems,
89
97
  dropIndicatorPosition,
90
98
  setDropIndicatorPosition
91
99
  };
92
100
  }, [visibleItems, dropIndicatorPosition, setDropIndicatorPosition]);
93
- const coordinateGetter = (0, import_react.useMemo)(() => (0, import_getTreeKeyboardCoordinates.getTreeKeyboardCoordinates)(sensorContext, isHorizontalDnD, maxDragAndDropLevel), [sensorContext, isHorizontalDnD, maxDragAndDropLevel]);
94
- const sensors = (0, import_core.useSensors)((0, import_core.useSensor)(import_core.PointerSensor), (0, import_core.useSensor)(import_core.KeyboardSensor, {
101
+ const coordinateGetter = react.useMemo(() => getTreeKeyboardCoordinates.getTreeKeyboardCoordinates(sensorContext, isHorizontalDnD, maxDragAndDropLevel), [sensorContext, isHorizontalDnD, maxDragAndDropLevel]);
102
+ const sensors = core.useSensors(core.useSensor(core.PointerSensor), core.useSensor(core.KeyboardSensor, {
95
103
  coordinateGetter
96
- }));
97
- const projected = (0, import_react.useMemo)(() => overId ? (0, import_utilities.getProjection)(visibleItems, visibleItemsDictionary, overId, dropIndicatorPosition, isExpandable) : null, [overId, visibleItems, visibleItemsDictionary, dropIndicatorPosition, isExpandable]);
98
- const dragPreviewHandlers = (0, import_useTreePreviewHandlers.useTreePreviewHandlers)({
104
+ })); // where is the activeItem being positioned (depth and parent)
105
+
106
+ const projected = react.useMemo(() => overId ? utilities.getProjection(visibleItems, visibleItemsDictionary, overId, dropIndicatorPosition, isExpandable) : null, [overId, visibleItems, visibleItemsDictionary, dropIndicatorPosition, isExpandable]);
107
+ const dragPreviewHandlers = useTreePreviewHandlers.useTreePreviewHandlers({
99
108
  setActiveId,
100
109
  setOverId,
101
110
  setDropIndicatorPosition
102
111
  });
103
- const dragActionHandlers = (0, import_useTreeActionHandlers.useTreeActionHandlers)({
104
- ...dragPreviewHandlers,
112
+ const dragActionHandlers = useTreeActionHandlers.useTreeActionHandlers(_objectSpread(_objectSpread({}, dragPreviewHandlers), {}, {
105
113
  onReorder,
106
114
  projected,
107
115
  flattenedItems,
108
116
  dropIndicatorPosition
109
- });
110
- const announcements = (0, import_useTreeAnnouncements.useTreeAnnouncements)(visibleItemsDictionary, dropIndicatorPosition);
111
- const dndContextProps = (0, import_react.useMemo)(() => ({
117
+ }));
118
+ const announcements = useTreeAnnouncements.useTreeAnnouncements(visibleItemsDictionary, dropIndicatorPosition);
119
+ const dndContextProps = react.useMemo(() => _objectSpread({
112
120
  announcements,
113
121
  modifiers,
114
122
  sensors,
115
123
  measuring,
116
- collisionDetection: (0, import_customCollisionDetection.customCollisionDetection)(activeId, visibleItemsDictionary, setDropIndicatorPosition, maxDragAndDropLevel, lastPosition, setLastPosition),
117
- ...dragActionHandlers
118
- }), [
119
- announcements,
120
- modifiers,
121
- sensors,
122
- dragActionHandlers,
123
- visibleItemsDictionary,
124
- setDropIndicatorPosition,
125
- activeId,
126
- maxDragAndDropLevel,
127
- lastPosition,
128
- setLastPosition
129
- ]);
130
- const sortableContextProps = (0, import_react.useMemo)(() => ({
124
+ collisionDetection: customCollisionDetection.customCollisionDetection(activeId, visibleItemsDictionary, setDropIndicatorPosition, maxDragAndDropLevel, lastPosition, setLastPosition)
125
+ }, dragActionHandlers), [announcements, modifiers, sensors, dragActionHandlers, visibleItemsDictionary, setDropIndicatorPosition, activeId, maxDragAndDropLevel, lastPosition, setLastPosition]);
126
+ const sortableContextProps = react.useMemo(() => ({
131
127
  items: sortedIds,
132
- strategy: isHorizontalDnD ? import_sortable.horizontalListSortingStrategy : import_sortable.verticalListSortingStrategy
128
+ strategy: isHorizontalDnD ? sortable.horizontalListSortingStrategy : sortable.verticalListSortingStrategy
133
129
  }), [sortedIds, isHorizontalDnD]);
134
130
  return {
135
131
  dndContextProps,
136
132
  sortableContextProps,
137
133
  activeId,
138
- activeIndex: visibleItemsDictionary[activeId]?.realIndex ?? -1,
134
+ activeIndex: (_visibleItemsDictiona = (_visibleItemsDictiona2 = visibleItemsDictionary[activeId]) === null || _visibleItemsDictiona2 === void 0 ? void 0 : _visibleItemsDictiona2.realIndex) !== null && _visibleItemsDictiona !== void 0 ? _visibleItemsDictiona : -1,
139
135
  overId,
140
136
  depth: projected ? projected.depth : 0,
141
137
  dropIndicatorPosition,
142
138
  visibleItems
143
139
  };
144
140
  };
145
- module.exports = __toCommonJS(useTreeDndkitConfig_exports);
146
- //# sourceMappingURL=useTreeDndkitConfig.js.map
141
+
142
+ exports.useTreeDndkitConfig = useTreeDndkitConfig;
@@ -1,61 +1,45 @@
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 useTreePreviewHandlers_exports = {};
29
- __export(useTreePreviewHandlers_exports, {
30
- useTreePreviewHandlers: () => useTreePreviewHandlers
31
- });
32
- var React = __toESM(require("react"));
33
- var import_react = __toESM(require("react"));
34
- var import_constants = __toESM(require("./constants"));
35
- const useTreePreviewHandlers = ({
36
- setOverId,
37
- setActiveId,
38
- setDropIndicatorPosition
39
- }) => {
40
- const resetState = (0, import_react.useCallback)(() => {
41
- setOverId("");
42
- setActiveId("");
43
- document.body.style.setProperty("cursor", "");
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var react = require('react');
6
+ var constants = require('./constants.js');
7
+
8
+ const useTreePreviewHandlers = _ref => {
9
+ let {
10
+ setOverId,
11
+ setActiveId,
12
+ setDropIndicatorPosition
13
+ } = _ref;
14
+ const resetState = react.useCallback(() => {
15
+ setOverId('');
16
+ setActiveId('');
17
+ document.body.style.setProperty('cursor', '');
44
18
  }, [setOverId, setActiveId]);
45
- const handlePreviewDragStart = (0, import_react.useCallback)(({ active: { id } }) => {
19
+ const handlePreviewDragStart = react.useCallback(_ref2 => {
20
+ let {
21
+ active: {
22
+ id
23
+ }
24
+ } = _ref2;
46
25
  setActiveId(id);
47
26
  setOverId(id);
48
- setDropIndicatorPosition(import_constants.DropIndicatorPosition.Inside);
49
- document.body.style.setProperty("cursor", "grabbing");
27
+ setDropIndicatorPosition(constants.DropIndicatorPosition.Inside);
28
+ document.body.style.setProperty('cursor', 'grabbing');
50
29
  }, [setActiveId, setDropIndicatorPosition, setOverId]);
51
- const handlePreviewDragMove = (0, import_react.useCallback)(() => null, []);
52
- const handlePreviewDragOver = (0, import_react.useCallback)(({ over }) => {
53
- setOverId(over?.id ?? "");
30
+ const handlePreviewDragMove = react.useCallback(() => null, []);
31
+ const handlePreviewDragOver = react.useCallback(_ref3 => {
32
+ var _over$id;
33
+
34
+ let {
35
+ over
36
+ } = _ref3;
37
+ setOverId((_over$id = over === null || over === void 0 ? void 0 : over.id) !== null && _over$id !== void 0 ? _over$id : '');
54
38
  }, [setOverId]);
55
- const handlePreviewDragEnd = (0, import_react.useCallback)(() => {
39
+ const handlePreviewDragEnd = react.useCallback(() => {
56
40
  resetState();
57
41
  }, [resetState]);
58
- const handlePreviewDragCancel = (0, import_react.useCallback)(() => {
42
+ const handlePreviewDragCancel = react.useCallback(() => {
59
43
  resetState();
60
44
  }, [resetState]);
61
45
  return {
@@ -66,5 +50,5 @@ const useTreePreviewHandlers = ({
66
50
  handlePreviewDragCancel
67
51
  };
68
52
  };
69
- module.exports = __toCommonJS(useTreePreviewHandlers_exports);
70
- //# sourceMappingURL=useTreePreviewHandlers.js.map
53
+
54
+ exports.useTreePreviewHandlers = useTreePreviewHandlers;
@@ -1,66 +1,52 @@
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 utilities_exports = {};
29
- __export(utilities_exports, {
30
- getProjection: () => getProjection,
31
- removeChildrenOf: () => removeChildrenOf
32
- });
33
- var React = __toESM(require("react"));
34
- var import_constants = __toESM(require("./constants"));
35
- const getMinDepth = (item) => {
36
- if (item)
37
- return item.depth;
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ require('core-js/modules/esnext.async-iterator.filter.js');
6
+ require('core-js/modules/esnext.iterator.constructor.js');
7
+ require('core-js/modules/esnext.iterator.filter.js');
8
+ var constants = require('./constants.js');
9
+
10
+ const getMinDepth = item => {
11
+ if (item) return item.depth;
38
12
  return 0;
39
13
  };
14
+
40
15
  const getProjection = (items, visibleItemsDictionary, overId, dropIndicatorPosition, isExpandable) => {
41
16
  const overItemIndex = visibleItemsDictionary[overId].realIndex;
42
17
  const previousItem = items[overItemIndex];
43
18
  const nextItem = items[overItemIndex + 1];
44
- if (dropIndicatorPosition === import_constants.DropIndicatorPosition.Inside && isExpandable) {
19
+
20
+ if (dropIndicatorPosition === constants.DropIndicatorPosition.Inside && isExpandable) {
45
21
  return {
46
22
  depth: visibleItemsDictionary[overId].depth + 1,
47
23
  parentId: overId
48
24
  };
49
25
  }
50
- if (dropIndicatorPosition === import_constants.DropIndicatorPosition.Before) {
51
- return { depth: getMinDepth(previousItem), parentId: previousItem.parentId };
26
+
27
+ if (dropIndicatorPosition === constants.DropIndicatorPosition.Before) {
28
+ return {
29
+ depth: getMinDepth(previousItem),
30
+ parentId: previousItem.parentId
31
+ };
52
32
  }
53
- return { depth: getMinDepth(nextItem), parentId: nextItem?.parentId };
33
+
34
+ return {
35
+ depth: getMinDepth(nextItem),
36
+ parentId: nextItem === null || nextItem === void 0 ? void 0 : nextItem.parentId
37
+ };
54
38
  };
55
39
  const removeChildrenOf = (items, id) => {
56
40
  const excludeParentIds = [id];
57
- return items.filter((item) => {
41
+ return items.filter(item => {
58
42
  if (item.parentId !== null && excludeParentIds.includes(item.parentId)) {
59
43
  excludeParentIds.push(item.uid);
60
44
  return false;
61
45
  }
46
+
62
47
  return true;
63
48
  });
64
49
  };
65
- module.exports = __toCommonJS(utilities_exports);
66
- //# sourceMappingURL=utilities.js.map
50
+
51
+ exports.getProjection = getProjection;
52
+ exports.removeChildrenOf = removeChildrenOf;
@@ -1,22 +1,54 @@
1
- import * as React from "react";
2
- const customCollisionDetection = (activeId, activeParent, dndItems) => ({ droppableContainers, collisionRect }) => {
3
- const entriesWithSameParent = droppableContainers.filter(({ id }) => dndItems.find((item) => item.id === id)?.parentId === activeParent);
4
- const originalContainer = entriesWithSameParent.find(({ id }) => id === activeId);
5
- const originalRect = originalContainer?.rect?.current;
6
- if (!originalRect)
7
- return null;
1
+ import 'core-js/modules/esnext.async-iterator.filter.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.filter.js';
4
+ import 'core-js/modules/esnext.async-iterator.find.js';
5
+ import 'core-js/modules/esnext.iterator.find.js';
6
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
7
+ import 'core-js/modules/esnext.iterator.for-each.js';
8
+
9
+ const customCollisionDetection = (activeId, activeParent, dndItems) => _ref => {
10
+ var _originalContainer$re;
11
+
12
+ let {
13
+ droppableContainers,
14
+ collisionRect
15
+ } = _ref;
16
+ const entriesWithSameParent = droppableContainers.filter(_ref2 => {
17
+ var _dndItems$find;
18
+
19
+ let {
20
+ id
21
+ } = _ref2;
22
+ return ((_dndItems$find = dndItems.find(item => item.id === id)) === null || _dndItems$find === void 0 ? void 0 : _dndItems$find.parentId) === activeParent;
23
+ });
24
+ const originalContainer = entriesWithSameParent.find(_ref3 => {
25
+ let {
26
+ id
27
+ } = _ref3;
28
+ return id === activeId;
29
+ });
30
+ const originalRect = originalContainer === null || originalContainer === void 0 ? void 0 : (_originalContainer$re = originalContainer.rect) === null || _originalContainer$re === void 0 ? void 0 : _originalContainer$re.current;
31
+ if (!originalRect) return null;
32
+
8
33
  if (originalRect.offsetLeft <= collisionRect.offsetLeft && collisionRect.offsetLeft <= originalRect.offsetLeft + originalRect.width) {
9
34
  return originalContainer.id;
10
35
  }
36
+
11
37
  const isLeft = collisionRect.offsetLeft <= originalRect.offsetLeft + collisionRect.width / 2 + 5;
12
- let match = null;
38
+ let match = null; // If going to the left, search the closest offset left
39
+ // Otherwise, get the closest offset right
40
+
13
41
  const collisionPoint = collisionRect.offsetLeft + collisionRect.width / 2;
14
- entriesWithSameParent.forEach((entry) => {
42
+ entriesWithSameParent.forEach(entry => {
15
43
  const {
16
- rect: { current: rect }
44
+ rect: {
45
+ current: rect
46
+ }
17
47
  } = entry;
48
+
18
49
  if (rect !== null) {
19
50
  const offsetRight = rect.offsetLeft + rect.width;
51
+
20
52
  if (!match) {
21
53
  match = entry;
22
54
  } else if (match && match.rect.current && isLeft && Math.abs(collisionPoint - rect.offsetLeft) <= Math.abs(collisionPoint - match.rect.current.offsetLeft)) {
@@ -25,11 +57,10 @@ const customCollisionDetection = (activeId, activeParent, dndItems) => ({ droppa
25
57
  match = entry;
26
58
  }
27
59
  }
28
- });
60
+ }); // Typescript believes match is always null for some reason
61
+
29
62
  const matchCastedForSomeReason = match;
30
63
  return matchCastedForSomeReason === null ? null : matchCastedForSomeReason.id;
31
64
  };
32
- export {
33
- customCollisionDetection
34
- };
35
- //# sourceMappingURL=customCollisionDetection.js.map
65
+
66
+ export { customCollisionDetection };