@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,53 +1,78 @@
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 { horizontalListSortingStrategy, verticalListSortingStrategy } from "@dnd-kit/sortable";
11
- import { useTreePreviewHandlers } from "./useTreePreviewHandlers";
12
- import { getTreeKeyboardCoordinates } from "./getTreeKeyboardCoordinates";
13
- import { getProjection, removeChildrenOf } from "./utilities";
14
- import { useTreeActionHandlers } from "./useTreeActionHandlers";
15
- import { DropIndicatorPosition } from "./constants";
16
- import { customCollisionDetection } from "./customCollisionDetection";
17
- import { useTreeAnnouncements } from "./useTreeAnnouncements";
18
- const adjustTranslate = (isHorizontalDnD) => ({ transform }) => {
19
- const newTransform = {
20
- ...transform
21
- };
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 { horizontalListSortingStrategy, verticalListSortingStrategy } from '@dnd-kit/sortable';
13
+ import { useTreePreviewHandlers } from './useTreePreviewHandlers.js';
14
+ import { getTreeKeyboardCoordinates } from './getTreeKeyboardCoordinates.js';
15
+ import { removeChildrenOf, getProjection } from './utilities.js';
16
+ import { useTreeActionHandlers } from './useTreeActionHandlers.js';
17
+ import { DropIndicatorPosition } from './constants.js';
18
+ import { customCollisionDetection } from './customCollisionDetection.js';
19
+ import { useTreeAnnouncements } from './useTreeAnnouncements.js';
20
+
21
+ 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; }
22
+
23
+ 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; }
24
+ // if second parameter is true, the space will be done on the horizontal axis
25
+
26
+ const adjustTranslate = isHorizontalDnD => _ref => {
27
+ let {
28
+ transform
29
+ } = _ref;
30
+
31
+ const newTransform = _objectSpread({}, transform);
32
+
22
33
  if (isHorizontalDnD) {
23
34
  newTransform.x = transform.x + 25;
24
35
  } else {
25
36
  newTransform.x = transform.x + 15;
26
37
  }
38
+
27
39
  return newTransform;
28
40
  };
41
+
29
42
  const measuring = {
30
43
  droppable: {
31
44
  strategy: MeasuringStrategy.BeforeDragging
32
45
  }
33
46
  };
34
- const useTreeDndkitConfig = ({
35
- flattenedItems,
36
- visibleItems: preVisibleItems,
37
- isHorizontalDnD = false,
38
- isExpandable = false,
39
- onReorder,
40
- maxDragAndDropLevel
41
- }) => {
42
- const [activeId, setActiveId] = useState("");
43
- const [overId, setOverId] = useState("");
47
+ const useTreeDndkitConfig = _ref2 => {
48
+ var _visibleItemsDictiona, _visibleItemsDictiona2;
49
+
50
+ let {
51
+ flattenedItems,
52
+ visibleItems: preVisibleItems,
53
+ isHorizontalDnD = false,
54
+ isExpandable = false,
55
+ onReorder,
56
+ maxDragAndDropLevel
57
+ } = _ref2;
58
+ const [activeId, setActiveId] = useState('');
59
+ const [overId, setOverId] = useState('');
44
60
  const [dropIndicatorPosition, setDropIndicatorPosition] = useState(DropIndicatorPosition.None);
45
- const [lastPosition, setLastPosition] = useState("");
46
- const visibleItems = useMemo(() => removeChildrenOf(preVisibleItems, activeId), [preVisibleItems, activeId]);
47
- const sortedIds = useMemo(() => visibleItems.map((item) => item.uid), [visibleItems]);
61
+ const [lastPosition, setLastPosition] = useState(''); // Remove activeId's children
62
+
63
+ const visibleItems = useMemo(() => removeChildrenOf(preVisibleItems, activeId), [preVisibleItems, activeId]); // Sorted ids for the library
64
+
65
+ const sortedIds = useMemo(() => visibleItems.map(item => item.uid), [visibleItems]);
66
+ /**
67
+ * Dictionary from UID to ITEM
68
+ * This dictionary is computed since on every DnD move, I need to know the
69
+ * depth of a particular row, so O(1) per DnD move instead of O(#ITEMS)
70
+ */
71
+
48
72
  const visibleItemsDictionary = useMemo(() => {
73
+ // Using plain for to achieve O(#ITEMS) performance
49
74
  const dictionary = {};
50
- visibleItems.forEach((item) => {
75
+ visibleItems.forEach(item => {
51
76
  dictionary[item.uid] = item;
52
77
  });
53
78
  return dictionary;
@@ -68,40 +93,28 @@ const useTreeDndkitConfig = ({
68
93
  const coordinateGetter = useMemo(() => getTreeKeyboardCoordinates(sensorContext, isHorizontalDnD, maxDragAndDropLevel), [sensorContext, isHorizontalDnD, maxDragAndDropLevel]);
69
94
  const sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, {
70
95
  coordinateGetter
71
- }));
96
+ })); // where is the activeItem being positioned (depth and parent)
97
+
72
98
  const projected = useMemo(() => overId ? getProjection(visibleItems, visibleItemsDictionary, overId, dropIndicatorPosition, isExpandable) : null, [overId, visibleItems, visibleItemsDictionary, dropIndicatorPosition, isExpandable]);
73
99
  const dragPreviewHandlers = useTreePreviewHandlers({
74
100
  setActiveId,
75
101
  setOverId,
76
102
  setDropIndicatorPosition
77
103
  });
78
- const dragActionHandlers = useTreeActionHandlers({
79
- ...dragPreviewHandlers,
104
+ const dragActionHandlers = useTreeActionHandlers(_objectSpread(_objectSpread({}, dragPreviewHandlers), {}, {
80
105
  onReorder,
81
106
  projected,
82
107
  flattenedItems,
83
108
  dropIndicatorPosition
84
- });
109
+ }));
85
110
  const announcements = useTreeAnnouncements(visibleItemsDictionary, dropIndicatorPosition);
86
- const dndContextProps = useMemo(() => ({
111
+ const dndContextProps = useMemo(() => _objectSpread({
87
112
  announcements,
88
113
  modifiers,
89
114
  sensors,
90
115
  measuring,
91
- collisionDetection: customCollisionDetection(activeId, visibleItemsDictionary, setDropIndicatorPosition, maxDragAndDropLevel, lastPosition, setLastPosition),
92
- ...dragActionHandlers
93
- }), [
94
- announcements,
95
- modifiers,
96
- sensors,
97
- dragActionHandlers,
98
- visibleItemsDictionary,
99
- setDropIndicatorPosition,
100
- activeId,
101
- maxDragAndDropLevel,
102
- lastPosition,
103
- setLastPosition
104
- ]);
116
+ collisionDetection: customCollisionDetection(activeId, visibleItemsDictionary, setDropIndicatorPosition, maxDragAndDropLevel, lastPosition, setLastPosition)
117
+ }, dragActionHandlers), [announcements, modifiers, sensors, dragActionHandlers, visibleItemsDictionary, setDropIndicatorPosition, activeId, maxDragAndDropLevel, lastPosition, setLastPosition]);
105
118
  const sortableContextProps = useMemo(() => ({
106
119
  items: sortedIds,
107
120
  strategy: isHorizontalDnD ? horizontalListSortingStrategy : verticalListSortingStrategy
@@ -110,14 +123,12 @@ const useTreeDndkitConfig = ({
110
123
  dndContextProps,
111
124
  sortableContextProps,
112
125
  activeId,
113
- activeIndex: visibleItemsDictionary[activeId]?.realIndex ?? -1,
126
+ activeIndex: (_visibleItemsDictiona = (_visibleItemsDictiona2 = visibleItemsDictionary[activeId]) === null || _visibleItemsDictiona2 === void 0 ? void 0 : _visibleItemsDictiona2.realIndex) !== null && _visibleItemsDictiona !== void 0 ? _visibleItemsDictiona : -1,
114
127
  overId,
115
128
  depth: projected ? projected.depth : 0,
116
129
  dropIndicatorPosition,
117
130
  visibleItems
118
131
  };
119
132
  };
120
- export {
121
- useTreeDndkitConfig
122
- };
123
- //# sourceMappingURL=useTreeDndkitConfig.js.map
133
+
134
+ export { useTreeDndkitConfig };
@@ -1,25 +1,36 @@
1
- import * as React from "react";
2
- import { useCallback } from "react";
3
- import { DropIndicatorPosition } from "./constants";
4
- const useTreePreviewHandlers = ({
5
- setOverId,
6
- setActiveId,
7
- setDropIndicatorPosition
8
- }) => {
1
+ import { useCallback } from 'react';
2
+ import { DropIndicatorPosition } from './constants.js';
3
+
4
+ const useTreePreviewHandlers = _ref => {
5
+ let {
6
+ setOverId,
7
+ setActiveId,
8
+ setDropIndicatorPosition
9
+ } = _ref;
9
10
  const resetState = useCallback(() => {
10
- setOverId("");
11
- setActiveId("");
12
- document.body.style.setProperty("cursor", "");
11
+ setOverId('');
12
+ setActiveId('');
13
+ document.body.style.setProperty('cursor', '');
13
14
  }, [setOverId, setActiveId]);
14
- const handlePreviewDragStart = useCallback(({ active: { id } }) => {
15
+ const handlePreviewDragStart = useCallback(_ref2 => {
16
+ let {
17
+ active: {
18
+ id
19
+ }
20
+ } = _ref2;
15
21
  setActiveId(id);
16
22
  setOverId(id);
17
23
  setDropIndicatorPosition(DropIndicatorPosition.Inside);
18
- document.body.style.setProperty("cursor", "grabbing");
24
+ document.body.style.setProperty('cursor', 'grabbing');
19
25
  }, [setActiveId, setDropIndicatorPosition, setOverId]);
20
26
  const handlePreviewDragMove = useCallback(() => null, []);
21
- const handlePreviewDragOver = useCallback(({ over }) => {
22
- setOverId(over?.id ?? "");
27
+ const handlePreviewDragOver = useCallback(_ref3 => {
28
+ var _over$id;
29
+
30
+ let {
31
+ over
32
+ } = _ref3;
33
+ setOverId((_over$id = over === null || over === void 0 ? void 0 : over.id) !== null && _over$id !== void 0 ? _over$id : '');
23
34
  }, [setOverId]);
24
35
  const handlePreviewDragEnd = useCallback(() => {
25
36
  resetState();
@@ -35,7 +46,5 @@ const useTreePreviewHandlers = ({
35
46
  handlePreviewDragCancel
36
47
  };
37
48
  };
38
- export {
39
- useTreePreviewHandlers
40
- };
41
- //# sourceMappingURL=useTreePreviewHandlers.js.map
49
+
50
+ export { useTreePreviewHandlers };
@@ -1,37 +1,47 @@
1
- import * as React from "react";
2
- import { DropIndicatorPosition } from "./constants";
3
- const getMinDepth = (item) => {
4
- if (item)
5
- return item.depth;
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 { DropIndicatorPosition } from './constants.js';
5
+
6
+ const getMinDepth = item => {
7
+ if (item) return item.depth;
6
8
  return 0;
7
9
  };
10
+
8
11
  const getProjection = (items, visibleItemsDictionary, overId, dropIndicatorPosition, isExpandable) => {
9
12
  const overItemIndex = visibleItemsDictionary[overId].realIndex;
10
13
  const previousItem = items[overItemIndex];
11
14
  const nextItem = items[overItemIndex + 1];
15
+
12
16
  if (dropIndicatorPosition === DropIndicatorPosition.Inside && isExpandable) {
13
17
  return {
14
18
  depth: visibleItemsDictionary[overId].depth + 1,
15
19
  parentId: overId
16
20
  };
17
21
  }
22
+
18
23
  if (dropIndicatorPosition === DropIndicatorPosition.Before) {
19
- return { depth: getMinDepth(previousItem), parentId: previousItem.parentId };
24
+ return {
25
+ depth: getMinDepth(previousItem),
26
+ parentId: previousItem.parentId
27
+ };
20
28
  }
21
- return { depth: getMinDepth(nextItem), parentId: nextItem?.parentId };
29
+
30
+ return {
31
+ depth: getMinDepth(nextItem),
32
+ parentId: nextItem === null || nextItem === void 0 ? void 0 : nextItem.parentId
33
+ };
22
34
  };
23
35
  const removeChildrenOf = (items, id) => {
24
36
  const excludeParentIds = [id];
25
- return items.filter((item) => {
37
+ return items.filter(item => {
26
38
  if (item.parentId !== null && excludeParentIds.includes(item.parentId)) {
27
39
  excludeParentIds.push(item.uid);
28
40
  return false;
29
41
  }
42
+
30
43
  return true;
31
44
  });
32
45
  };
33
- export {
34
- getProjection,
35
- removeChildrenOf
36
- };
37
- //# sourceMappingURL=utilities.js.map
46
+
47
+ export { getProjection, removeChildrenOf };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-drag-and-drop",
3
- "version": "2.2.0-alpha.2",
3
+ "version": "2.2.0-beta.0",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Drag And Drop",
6
6
  "module": "./esm/index.js",
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/hierarchy/customCollisionDetection.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import { CollisionDetection, DroppableContainer } from '@dnd-kit/core';\nimport { Item } from './types';\n\nexport const customCollisionDetection =\n (activeId: string | null, activeParent: string | undefined, dndItems: Item[]): CollisionDetection =>\n ({ droppableContainers, collisionRect }) => {\n const entriesWithSameParent = droppableContainers.filter(\n ({ id }) => dndItems.find((item) => item.id === id)?.parentId === activeParent,\n );\n\n const originalContainer = entriesWithSameParent.find(({ id }) => id === activeId);\n const originalRect = originalContainer?.rect?.current;\n\n if (!originalRect) return null;\n\n if (\n originalRect.offsetLeft <= collisionRect.offsetLeft &&\n collisionRect.offsetLeft <= originalRect.offsetLeft + originalRect.width\n ) {\n return originalContainer.id;\n }\n\n const isLeft = collisionRect.offsetLeft <= originalRect.offsetLeft + collisionRect.width / 2 + 5;\n\n let match: DroppableContainer | null = null;\n // If going to the left, search the closest offset left\n // Otherwise, get the closest offset right\n const collisionPoint = collisionRect.offsetLeft + collisionRect.width / 2;\n entriesWithSameParent.forEach((entry) => {\n const {\n rect: { current: rect },\n } = entry;\n\n if (rect !== null) {\n const offsetRight = rect.offsetLeft + rect.width;\n\n if (!match) {\n match = entry;\n } else if (\n match &&\n match.rect.current &&\n isLeft &&\n Math.abs(collisionPoint - rect.offsetLeft) <= Math.abs(collisionPoint - match.rect.current.offsetLeft)\n ) {\n match = entry;\n } else if (\n match &&\n match.rect.current &&\n !isLeft &&\n Math.abs(collisionPoint - offsetRight) <=\n Math.abs(collisionPoint - match.rect.current.offsetLeft - match.rect.current.width)\n ) {\n match = entry;\n }\n }\n });\n // Typescript believes match is always null for some reason\n const matchCastedForSomeReason = match as DroppableContainer | null;\n return matchCastedForSomeReason === null ? null : matchCastedForSomeReason.id;\n };\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGhB,MAAM,2BACX,CAAC,UAAyB,cAAkC,aAC5D,CAAC,EAAE,qBAAqB,oBAAoB;AAC1C,QAAM,wBAAwB,oBAAoB,OAChD,CAAC,EAAE,SAAS,SAAS,KAAK,CAAC,SAAS,KAAK,OAAO,KAAK,aAAa;AAGpE,QAAM,oBAAoB,sBAAsB,KAAK,CAAC,EAAE,SAAS,OAAO;AACxE,QAAM,eAAe,mBAAmB,MAAM;AAE9C,MAAI,CAAC;AAAc,WAAO;AAE1B,MACE,aAAa,cAAc,cAAc,cACzC,cAAc,cAAc,aAAa,aAAa,aAAa,OACnE;AACA,WAAO,kBAAkB;AAAA;AAG3B,QAAM,SAAS,cAAc,cAAc,aAAa,aAAa,cAAc,QAAQ,IAAI;AAE/F,MAAI,QAAmC;AAGvC,QAAM,iBAAiB,cAAc,aAAa,cAAc,QAAQ;AACxE,wBAAsB,QAAQ,CAAC,UAAU;AACvC,UAAM;AAAA,MACJ,MAAM,EAAE,SAAS;AAAA,QACf;AAEJ,QAAI,SAAS,MAAM;AACjB,YAAM,cAAc,KAAK,aAAa,KAAK;AAE3C,UAAI,CAAC,OAAO;AACV,gBAAQ;AAAA,iBAER,SACA,MAAM,KAAK,WACX,UACA,KAAK,IAAI,iBAAiB,KAAK,eAAe,KAAK,IAAI,iBAAiB,MAAM,KAAK,QAAQ,aAC3F;AACA,gBAAQ;AAAA,iBAER,SACA,MAAM,KAAK,WACX,CAAC,UACD,KAAK,IAAI,iBAAiB,gBACxB,KAAK,IAAI,iBAAiB,MAAM,KAAK,QAAQ,aAAa,MAAM,KAAK,QAAQ,QAC/E;AACA,gBAAQ;AAAA;AAAA;AAAA;AAKd,QAAM,2BAA2B;AACjC,SAAO,6BAA6B,OAAO,OAAO,yBAAyB;AAAA;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/hierarchy/getHierarchyKeyboardCoordinates.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import { closestCorners, getViewRect, KeyboardCode, KeyboardCoordinateGetter, DroppableContainer } from '@dnd-kit/core';\nimport { Coordinates } from '@dnd-kit/core/dist/types';\n\nimport { GetKeyboardCoordinatesArgs, SensorContext } from './types';\n\nconst directions: string[] = [KeyboardCode.Down, KeyboardCode.Right, KeyboardCode.Up, KeyboardCode.Left];\n\nconst vertical: string[] = [KeyboardCode.Up, KeyboardCode.Down];\n\nconst getHorizontalKeyboardCoordinates = ({\n items,\n active,\n over,\n event,\n currentCoordinates,\n droppableContainers,\n collisionRect,\n}: GetKeyboardCoordinatesArgs): Coordinates | undefined => {\n if (vertical.includes(event.code) || !active || !over) return undefined;\n\n const activeItem = items.find((item) => item.id === active.id);\n\n const overRect = over.rect;\n\n const layoutRects: DroppableContainer[] = [];\n\n // Get the reacheable rects depending on the arrow key pressed\n droppableContainers.forEach((container) => {\n if (container?.disabled || !overRect) {\n return;\n }\n const node = container?.node.current;\n if (!node) {\n return;\n }\n const itemParent = items.find((item) => item.id === container.id)?.parentId;\n if (itemParent !== activeItem?.parentId) return;\n const rect = getViewRect(node);\n if (event.code === KeyboardCode.Left && collisionRect.left > rect.right - 10) {\n layoutRects.push(container);\n } else if (event.code === KeyboardCode.Right && collisionRect.left < rect.left) {\n layoutRects.push(container);\n }\n });\n\n const closestId = closestCorners({ droppableContainers: layoutRects, collisionRect, active });\n\n if (!closestId) return undefined;\n\n const closestDroppableContainer = droppableContainers.get(closestId)?.node?.current;\n const activeDroppableContainer = droppableContainers.get(active?.id)?.node?.current;\n\n if (!closestDroppableContainer || !activeDroppableContainer) return undefined;\n\n const closestRect = getViewRect(closestDroppableContainer);\n const activeRect = getViewRect(activeDroppableContainer);\n return {\n ...currentCoordinates,\n x:\n closestRect.left +\n (closestRect.width - collisionRect.width) / 2 +\n (closestRect.offsetLeft < activeRect.left ? -1 : 1),\n };\n};\n\nexport const getHierarchyKeyboardCoordinates: (\n context: SensorContext,\n dragOverlayDataTestid: string,\n isHorizontalDnD: boolean,\n) => KeyboardCoordinateGetter =\n (context, dragOverlayDataTestid, isHorizontalDnD) =>\n (event, { currentCoordinates, context: { active, over, collisionRect, droppableContainers } }) => {\n if (directions.includes(event.code)) {\n event.preventDefault();\n if (!collisionRect) {\n return undefined;\n }\n\n const {\n current: { items },\n } = context;\n\n const args = {\n dragOverlayDataTestid,\n items,\n active,\n over,\n event,\n currentCoordinates,\n droppableContainers,\n collisionRect,\n };\n\n if (isHorizontalDnD) return getHorizontalKeyboardCoordinates(args);\n return undefined;\n }\n return undefined;\n };\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,kBAAwG;AAKxG,MAAM,aAAuB,CAAC,yBAAa,MAAM,yBAAa,OAAO,yBAAa,IAAI,yBAAa;AAEnG,MAAM,WAAqB,CAAC,yBAAa,IAAI,yBAAa;AAE1D,MAAM,mCAAmC,CAAC;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,MACyD;AACzD,MAAI,SAAS,SAAS,MAAM,SAAS,CAAC,UAAU,CAAC;AAAM,WAAO;AAE9D,QAAM,aAAa,MAAM,KAAK,CAAC,SAAS,KAAK,OAAO,OAAO;AAE3D,QAAM,WAAW,KAAK;AAEtB,QAAM,cAAoC;AAG1C,sBAAoB,QAAQ,CAAC,cAAc;AACzC,QAAI,WAAW,YAAY,CAAC,UAAU;AACpC;AAAA;AAEF,UAAM,OAAO,WAAW,KAAK;AAC7B,QAAI,CAAC,MAAM;AACT;AAAA;AAEF,UAAM,aAAa,MAAM,KAAK,CAAC,SAAS,KAAK,OAAO,UAAU,KAAK;AACnE,QAAI,eAAe,YAAY;AAAU;AACzC,UAAM,OAAO,6BAAY;AACzB,QAAI,MAAM,SAAS,yBAAa,QAAQ,cAAc,OAAO,KAAK,QAAQ,IAAI;AAC5E,kBAAY,KAAK;AAAA,eACR,MAAM,SAAS,yBAAa,SAAS,cAAc,OAAO,KAAK,MAAM;AAC9E,kBAAY,KAAK;AAAA;AAAA;AAIrB,QAAM,YAAY,gCAAe,EAAE,qBAAqB,aAAa,eAAe;AAEpF,MAAI,CAAC;AAAW,WAAO;AAEvB,QAAM,4BAA4B,oBAAoB,IAAI,YAAY,MAAM;AAC5E,QAAM,2BAA2B,oBAAoB,IAAI,QAAQ,KAAK,MAAM;AAE5E,MAAI,CAAC,6BAA6B,CAAC;AAA0B,WAAO;AAEpE,QAAM,cAAc,6BAAY;AAChC,QAAM,aAAa,6BAAY;AAC/B,SAAO;AAAA,OACF;AAAA,IACH,GACE,YAAY,OACX,aAAY,QAAQ,cAAc,SAAS,IAC3C,aAAY,aAAa,WAAW,OAAO,KAAK;AAAA;AAAA;AAIhD,MAAM,kCAKX,CAAC,SAAS,uBAAuB,oBACjC,CAAC,OAAO,EAAE,oBAAoB,SAAS,EAAE,QAAQ,MAAM,eAAe,4BAA4B;AAChG,MAAI,WAAW,SAAS,MAAM,OAAO;AACnC,UAAM;AACN,QAAI,CAAC,eAAe;AAClB,aAAO;AAAA;AAGT,UAAM;AAAA,MACJ,SAAS,EAAE;AAAA,QACT;AAEJ,UAAM,OAAO;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAGF,QAAI;AAAiB,aAAO,iCAAiC;AAC7D,WAAO;AAAA;AAET,SAAO;AAAA;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/hierarchy/index.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["export * from './useHierarchyDndkitConfig';\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA,YAAuB;ADAvB,8BAAc;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/hierarchy/types.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import type {\n Active,\n Announcements,\n CollisionDetection,\n DragEndEvent,\n DragMoveEvent,\n DragOverEvent,\n DragStartEvent,\n MeasuringConfiguration,\n Modifier,\n Over,\n SensorDescriptor,\n SensorOptions,\n} from '@dnd-kit/core';\nimport { DroppableContainers } from '@dnd-kit/core/dist/store';\nimport { Coordinates, DragCancelEvent, ViewRect } from '@dnd-kit/core/dist/types';\nimport { MutableRefObject } from 'react';\n\nexport type Item = {\n id: string;\n depth: number;\n parentId: string;\n index: number;\n};\n\nexport type DndContextPropsType = {\n announcements: Announcements;\n modifiers: Modifier[];\n sensors: SensorDescriptor<SensorOptions>[];\n measuring: Partial<MeasuringConfiguration>;\n collisionDetection: CollisionDetection;\n onDragStart: (e: DragStartEvent) => void;\n onDragMove: (e: DragMoveEvent) => void;\n onDragOver: (e: DragOverEvent) => void;\n onDragEnd: (e: DragEndEvent) => void;\n onDragCancel: (e: DragCancelEvent) => void;\n};\n\nexport type useHierarchyPreviewHandlersReturn = {\n handlePreviewDragStart: (e: DragStartEvent) => void;\n handlePreviewDragMove: (e: DragMoveEvent) => void;\n handlePreviewDragEnd: (e: DragEndEvent) => void;\n handlePreviewDragCancel: (e: DragCancelEvent) => void;\n};\n\nexport type useHierarchyPreviewHandlersArgs = {\n setActiveId: React.Dispatch<React.SetStateAction<string>>;\n onPreviewResetState: () => void;\n onPreviewDragStart: () => void;\n};\n\nexport type useHierarchyActionHandlersArgs = useHierarchyPreviewHandlersReturn & {\n dndItems: Item[];\n onReorder: (movedItem: Item, indexes: { targetIndex: number; fromIndex: number }) => void;\n};\n\nexport type useHierarchyActionHandlersReturn = {\n onDragStart: (e: DragStartEvent) => void;\n onDragMove: (e: DragMoveEvent) => void;\n onDragOver: (e: DragOverEvent) => void;\n onDragEnd: (e: DragEndEvent) => void;\n onDragCancel: (e: DragCancelEvent) => void;\n};\n\nexport type useHierarchyDndkitConfigArgs = {\n indentationWidth?: number;\n dragOverlayDataTestid: string;\n flattenedItems: [Item, unknown][];\n isHorizontalDnD?: boolean;\n onReorder: (movedItem: Item, indexes: { targetIndex: number; fromIndex: number }) => void;\n onPreviewResetState: () => void;\n onPreviewDragStart: () => void;\n};\n\nexport type useHierarchyDndkitConfigType = (args: useHierarchyDndkitConfigArgs) => useHierarchyDndkitConfigReturn;\n\nexport type useHierarchyDndkitConfigReturn = {\n dndContextProps: DndContextPropsType;\n activeId: string | null;\n overId: string | null;\n activeIndex: number | undefined;\n};\n\nexport type getKeyboardCoordinatesArgs = {\n items: Item[];\n active: Active | null;\n over: Over | null;\n event: KeyboardEvent;\n currentCoordinates: Coordinates;\n droppableContainers: DroppableContainers;\n collisionRect: ViewRect;\n dragOverlayDataTestid: string;\n};\n\nexport type SensorContext = MutableRefObject<{\n items: Item[];\n offset?: number;\n}>;\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA,YAAuB;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/hierarchy/useHierarchyActionHandlers.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import { useCallback } from 'react';\nimport { DragStartEvent, DragMoveEvent, DragEndEvent, DragCancelEvent } from '@dnd-kit/core';\nimport { UseHierarchyActionHandlersReturn, UseHierarchyActionHandlersArgs } from './types';\n\nexport const useHierarchyActionHandlers = ({\n handlePreviewDragStart,\n handlePreviewDragMove,\n handlePreviewDragEnd,\n handlePreviewDragCancel,\n onReorder,\n dndItems,\n}: UseHierarchyActionHandlersArgs): UseHierarchyActionHandlersReturn => {\n const onDragStart = useCallback(\n (e: DragStartEvent) => {\n handlePreviewDragStart(e);\n },\n [handlePreviewDragStart],\n );\n\n const onDragMove = useCallback(\n (e: DragMoveEvent) => {\n handlePreviewDragMove(e);\n },\n [handlePreviewDragMove],\n );\n\n const onDragEnd = useCallback(\n (e: DragEndEvent) => {\n handlePreviewDragEnd(e);\n const { active, over } = e;\n\n if (!over) return;\n\n if (active.id !== over.id) {\n const activeIndex = dndItems.findIndex((item) => item.id === active.id);\n const overIndex = dndItems.findIndex((item) => item.id === over.id);\n\n onReorder(dndItems[activeIndex], {\n targetIndex: overIndex,\n fromIndex: activeIndex,\n });\n }\n },\n [handlePreviewDragEnd, dndItems, onReorder],\n );\n\n const onDragCancel = useCallback(\n (e: DragCancelEvent) => {\n handlePreviewDragCancel(e);\n },\n [handlePreviewDragCancel],\n );\n\n return { onDragStart, onDragMove, onDragEnd, onDragCancel };\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA4B;AAIrB,MAAM,6BAA6B,CAAC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,MACsE;AACtE,QAAM,cAAc,8BAClB,CAAC,MAAsB;AACrB,2BAAuB;AAAA,KAEzB,CAAC;AAGH,QAAM,aAAa,8BACjB,CAAC,MAAqB;AACpB,0BAAsB;AAAA,KAExB,CAAC;AAGH,QAAM,YAAY,8BAChB,CAAC,MAAoB;AACnB,yBAAqB;AACrB,UAAM,EAAE,QAAQ,SAAS;AAEzB,QAAI,CAAC;AAAM;AAEX,QAAI,OAAO,OAAO,KAAK,IAAI;AACzB,YAAM,cAAc,SAAS,UAAU,CAAC,SAAS,KAAK,OAAO,OAAO;AACpE,YAAM,YAAY,SAAS,UAAU,CAAC,SAAS,KAAK,OAAO,KAAK;AAEhE,gBAAU,SAAS,cAAc;AAAA,QAC/B,aAAa;AAAA,QACb,WAAW;AAAA;AAAA;AAAA,KAIjB,CAAC,sBAAsB,UAAU;AAGnC,QAAM,eAAe,8BACnB,CAAC,MAAuB;AACtB,4BAAwB;AAAA,KAE1B,CAAC;AAGH,SAAO,EAAE,aAAa,YAAY,WAAW;AAAA;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/hierarchy/useHierarchyAnnouncements.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import { Announcements } from '@dnd-kit/core';\nimport { useCallback } from 'react';\nimport { Item } from './types';\n\nexport const useHierarchyAnnouncements = (visibleItemsDictionary: Record<string, Item>): Announcements => {\n const onDragStart = useCallback(\n (id: string) => `Picked up draggable item from position ${visibleItemsDictionary[id].index + 1}.`,\n [visibleItemsDictionary],\n );\n\n const onDragMove = useCallback(\n (id: string, overId: string) => {\n if (overId) {\n const overIndex = visibleItemsDictionary[overId].index + 1;\n return `Draggable item was moved to position ${overIndex}.`;\n }\n\n return `Draggable item is no longer over a droppable area.`;\n },\n [visibleItemsDictionary],\n );\n\n const onDragOver = onDragMove;\n\n const onDragEnd = useCallback(\n (id: string, overId: string) => {\n if (overId) {\n const overIndex = visibleItemsDictionary[overId].index + 1;\n return `Draggable item was dropped over position ${overIndex}.`;\n }\n\n return `Draggable item was dropped at it's original position.`;\n },\n [visibleItemsDictionary],\n );\n\n const onDragCancel = useCallback(\n (id: string) =>\n `Dragging was cancelled. Draggable item from position ${\n visibleItemsDictionary[id].index + 1\n } was dropped at it's initial position.`,\n [visibleItemsDictionary],\n );\n\n return { onDragStart, onDragOver, onDragMove, onDragEnd, onDragCancel };\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAA4B;AAGrB,MAAM,4BAA4B,CAAC,2BAAgE;AACxG,QAAM,cAAc,8BAClB,CAAC,OAAe,0CAA0C,uBAAuB,IAAI,QAAQ,MAC7F,CAAC;AAGH,QAAM,aAAa,8BACjB,CAAC,IAAY,WAAmB;AAC9B,QAAI,QAAQ;AACV,YAAM,YAAY,uBAAuB,QAAQ,QAAQ;AACzD,aAAO,wCAAwC;AAAA;AAGjD,WAAO;AAAA,KAET,CAAC;AAGH,QAAM,aAAa;AAEnB,QAAM,YAAY,8BAChB,CAAC,IAAY,WAAmB;AAC9B,QAAI,QAAQ;AACV,YAAM,YAAY,uBAAuB,QAAQ,QAAQ;AACzD,aAAO,4CAA4C;AAAA;AAGrD,WAAO;AAAA,KAET,CAAC;AAGH,QAAM,eAAe,8BACnB,CAAC,OACC,wDACE,uBAAuB,IAAI,QAAQ,2CAEvC,CAAC;AAGH,SAAO,EAAE,aAAa,YAAY,YAAY,WAAW;AAAA;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/hierarchy/useHierarchyDndkitConfig.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["/* eslint-disable max-lines */\nimport { useState, useEffect, useMemo, useRef } from 'react';\nimport {\n useSensor,\n useSensors,\n KeyboardSensor,\n PointerSensor,\n MeasuringConfiguration,\n MeasuringStrategy,\n Modifier,\n} from '@dnd-kit/core';\nimport { useHierarchyActionHandlers } from './useHierarchyActionHandlers';\nimport { useHierarchyPreviewHandlers } from './useHierarchyPreviewHandlers';\nimport type { UseHierarchyDndkitConfigType, SensorContext, Item } from './types';\nimport { getHierarchyKeyboardCoordinates } from './getHierarchyKeyboardCoordinates';\nimport { customCollisionDetection } from './customCollisionDetection';\nimport { useHierarchyAnnouncements } from './useHierarchyAnnouncements';\n\n// we make space for the drop indicator\n// if second parameter is true, the space will be done on the horizontal axis\nconst adjustTranslate =\n (isHorizontalDnD: boolean): Modifier =>\n ({ transform }) => {\n const newTransform = {\n ...transform,\n };\n if (isHorizontalDnD) {\n newTransform.y = transform.y + 15;\n } else {\n newTransform.y = transform.y - 35;\n }\n return newTransform;\n };\n\nconst measuring: Partial<MeasuringConfiguration> = {\n droppable: {\n strategy: MeasuringStrategy.Always,\n },\n};\n\nconst noop = () => null;\n\nexport const useHierarchyDndkitConfig: UseHierarchyDndkitConfigType = ({\n flattenedItems,\n dragOverlayDataTestid,\n isHorizontalDnD = false,\n onReorder,\n onPreviewResetState = noop,\n onPreviewDragStart = noop,\n}) => {\n const [activeId, setActiveId] = useState('');\n\n const dndItems = useMemo(() => flattenedItems.map(([item]) => item), [flattenedItems]);\n\n const itemsDictionary = useMemo(() => {\n const dictionary: Record<string, Item> = {};\n dndItems.forEach((item) => {\n dictionary[item.id] = item;\n });\n return dictionary;\n }, [dndItems]);\n\n const modifiers: Modifier[] = useMemo(() => [adjustTranslate(isHorizontalDnD)], [isHorizontalDnD]);\n\n const sensorContext: SensorContext = useRef({\n items: dndItems,\n });\n\n useEffect(() => {\n sensorContext.current = {\n items: dndItems,\n };\n }, [dndItems]);\n\n const coordinateGetter = useMemo(\n () => getHierarchyKeyboardCoordinates(sensorContext, dragOverlayDataTestid, isHorizontalDnD),\n [isHorizontalDnD],\n );\n\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor, {\n coordinateGetter,\n }),\n );\n\n const dragPreviewHandlers = useHierarchyPreviewHandlers({\n setActiveId,\n onPreviewResetState,\n onPreviewDragStart,\n });\n\n const dragActionHandlers = useHierarchyActionHandlers({\n ...dragPreviewHandlers,\n dndItems,\n onReorder,\n });\n\n const announcements = useHierarchyAnnouncements(itemsDictionary);\n\n const dndContextProps = useMemo(\n () => ({\n announcements,\n modifiers,\n sensors,\n measuring,\n collisionDetection: customCollisionDetection(activeId, itemsDictionary[activeId ?? '']?.parentId, dndItems),\n ...dragActionHandlers,\n }),\n [announcements, modifiers, sensors, activeId, itemsDictionary, dndItems, dragActionHandlers],\n );\n\n return {\n dndContextProps,\n activeId,\n activeIndex: activeId ? itemsDictionary[activeId]?.index : -1,\n };\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAAqD;AACrD,kBAQO;AACP,wCAA2C;AAC3C,yCAA4C;AAE5C,6CAAgD;AAChD,sCAAyC;AACzC,uCAA0C;AAI1C,MAAM,kBACJ,CAAC,oBACD,CAAC,EAAE,gBAAgB;AACjB,QAAM,eAAe;AAAA,OAChB;AAAA;AAEL,MAAI,iBAAiB;AACnB,iBAAa,IAAI,UAAU,IAAI;AAAA,SAC1B;AACL,iBAAa,IAAI,UAAU,IAAI;AAAA;AAEjC,SAAO;AAAA;AAGX,MAAM,YAA6C;AAAA,EACjD,WAAW;AAAA,IACT,UAAU,8BAAkB;AAAA;AAAA;AAIhC,MAAM,OAAO,MAAM;AAEZ,MAAM,2BAAyD,CAAC;AAAA,EACrE;AAAA,EACA;AAAA,EACA,kBAAkB;AAAA,EAClB;AAAA,EACA,sBAAsB;AAAA,EACtB,qBAAqB;AAAA,MACjB;AACJ,QAAM,CAAC,UAAU,eAAe,2BAAS;AAEzC,QAAM,WAAW,0BAAQ,MAAM,eAAe,IAAI,CAAC,CAAC,UAAU,OAAO,CAAC;AAEtE,QAAM,kBAAkB,0BAAQ,MAAM;AACpC,UAAM,aAAmC;AACzC,aAAS,QAAQ,CAAC,SAAS;AACzB,iBAAW,KAAK,MAAM;AAAA;AAExB,WAAO;AAAA,KACN,CAAC;AAEJ,QAAM,YAAwB,0BAAQ,MAAM,CAAC,gBAAgB,mBAAmB,CAAC;AAEjF,QAAM,gBAA+B,yBAAO;AAAA,IAC1C,OAAO;AAAA;AAGT,8BAAU,MAAM;AACd,kBAAc,UAAU;AAAA,MACtB,OAAO;AAAA;AAAA,KAER,CAAC;AAEJ,QAAM,mBAAmB,0BACvB,MAAM,4EAAgC,eAAe,uBAAuB,kBAC5E,CAAC;AAGH,QAAM,UAAU,4BACd,2BAAU,4BACV,2BAAU,4BAAgB;AAAA,IACxB;AAAA;AAIJ,QAAM,sBAAsB,oEAA4B;AAAA,IACtD;AAAA,IACA;AAAA,IACA;AAAA;AAGF,QAAM,qBAAqB,kEAA2B;AAAA,OACjD;AAAA,IACH;AAAA,IACA;AAAA;AAGF,QAAM,gBAAgB,gEAA0B;AAEhD,QAAM,kBAAkB,0BACtB,MAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,oBAAoB,8DAAyB,UAAU,gBAAgB,YAAY,KAAK,UAAU;AAAA,OAC/F;AAAA,MAEL,CAAC,eAAe,WAAW,SAAS,UAAU,iBAAiB,UAAU;AAG3E,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,aAAa,WAAW,gBAAgB,WAAW,QAAQ;AAAA;AAAA;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/hierarchy/useHierarchyPreviewHandlers.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import { useCallback } from 'react';\nimport { DragStartEvent, DragOverEvent } from '@dnd-kit/core';\nimport type { useHierarchyPreviewHandlersReturn, useHierarchyPreviewHandlersArgs } from './types';\n\nexport const useHierarchyPreviewHandlers = ({\n setActiveId,\n onPreviewResetState,\n onPreviewDragStart,\n}: useHierarchyPreviewHandlersArgs): useHierarchyPreviewHandlersReturn => {\n const resetState = useCallback(() => {\n setActiveId('');\n onPreviewResetState();\n\n document.body.style.setProperty('cursor', '');\n }, [setActiveId, onPreviewResetState]);\n\n const handlePreviewDragStart = useCallback(\n ({ active: { id } }: DragStartEvent) => {\n setActiveId(id);\n document.body.style.setProperty('cursor', 'grabbing');\n onPreviewDragStart();\n },\n [setActiveId, onPreviewDragStart],\n );\n\n const handlePreviewDragMove = useCallback(() => null, []);\n\n const handlePreviewDragEnd = useCallback(() => {\n resetState();\n }, [resetState]);\n\n const handlePreviewDragCancel = useCallback(() => {\n resetState();\n }, [resetState]);\n\n return {\n handlePreviewDragStart,\n handlePreviewDragMove,\n handlePreviewDragEnd,\n handlePreviewDragCancel,\n };\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA4B;AAIrB,MAAM,8BAA8B,CAAC;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,MACwE;AACxE,QAAM,aAAa,8BAAY,MAAM;AACnC,gBAAY;AACZ;AAEA,aAAS,KAAK,MAAM,YAAY,UAAU;AAAA,KACzC,CAAC,aAAa;AAEjB,QAAM,yBAAyB,8BAC7B,CAAC,EAAE,QAAQ,EAAE,WAA2B;AACtC,gBAAY;AACZ,aAAS,KAAK,MAAM,YAAY,UAAU;AAC1C;AAAA,KAEF,CAAC,aAAa;AAGhB,QAAM,wBAAwB,8BAAY,MAAM,MAAM;AAEtD,QAAM,uBAAuB,8BAAY,MAAM;AAC7C;AAAA,KACC,CAAC;AAEJ,QAAM,0BAA0B,8BAAY,MAAM;AAChD;AAAA,KACC,CAAC;AAEJ,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA;",
6
- "names": []
7
- }
package/cjs/index.js.map DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/index.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["export * from './hierarchy';\nexport * from './tree';\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA,YAAuB;ADAvB,wBAAc;AACd,wBAAc;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/tree/constants.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["export enum DropIndicatorPosition {\n None = 0,\n Before = 1,\n After = 2,\n Inside = 3,\n}", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAhB,IAAK,wBAAL,kBAAK,2BAAL;AACL,0DAAO,KAAP;AACA,4DAAS,KAAT;AACA,2DAAQ,KAAR;AACA,4DAAS,KAAT;AAJU;AAAA;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/tree/customCollisionDetection.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["/* 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 (\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 ({ 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.bottom, 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", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADIvB,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,2BACX,CACE,UACA,wBACA,0BACA,qBACA,cACA,oBAEF,CAAC,EAAE,qBAAqB,oBAAoB;AAC1C,QAAM,oBAAoB,oBAAoB,KAAK,CAAC,EAAE,SAAS,OAAO;AACtE,QAAM,eAAe,mBAAmB,MAAM;AAI9C,MAAI,OAAO,iBAAiB;AAC5B,MAAI,cAAc;AAChB,WAAO,aAAa,YAAY,cAAc;AAAA;AAIhD,QAAM,YAAY,cAAc,SAAS;AAEzC,MAAI,qBAAgD;AAEpD,MAAI,MAAM;AAER,yBAAqB,oBAAoB,OACvC,CAAC,eAAe,cAAc;AAC5B,YAAM,OAAO,UAAU,KAAK;AAC5B,UAAI,QAAQ,cAAc,KAAK,SAAS;AACtC,cAAM,EAAE,WAAW,kBAAkB;AACrC,cAAM,EAAE,WAAW,2BAA2B,cAAc,KAAK;AACjE,YAAI,gBAAgB,YAAY,cAAc,OAAO,gBAAgB,wBAAwB;AAC3F,iBAAO;AAAA;AAAA;AAGX,aAAO;AAAA,OAET,EAAE,IAAI,UAAU,MAAM,EAAE,SAAS;AAAA,SAE9B;AAEL,yBAAqB,oBAAoB,OACvC,CAAC,aAAa,cAAc;AAC1B,YAAM,OAAO,UAAU,KAAK;AAC5B,UAAI,QAAQ,YAAY,KAAK,SAAS;AACpC,cAAM,EAAE,WAAW,kBAAkB;AACrC,cAAM,EAAE,WAAW,yBAAyB,YAAY,KAAK;AAC7D,YAAI,gBAAgB,YAAY,cAAc,OAAO,gBAAgB,sBAAsB;AACzF,iBAAO;AAAA;AAAA;AAGX,aAAO;AAAA,OAET,EAAE,IAAI,UAAU,MAAM,EAAE,SAAS;AAAA;AAKrC,MAAI,mBAAmB,OAAO,UAAU;AACtC,WAAO;AAAA;AAGT,QAAM,gBAAgB,mBAAmB,KAAK;AAE9C,MAAI,CAAC;AAAe,WAAO;AAG3B,QAAM,CAAC,KAAK,UAAU;AAAA,IACpB,KAAK,IAAI,cAAc,KAAK,cAAc;AAAA,IAC1C,KAAK,IAAI,cAAc,QAAQ,cAAc,YAAY,cAAc;AAAA;AAIzE,QAAM,yBAAyB,KAAK,IAAI,SAAS,OAAO,cAAc;AAEtE,MACE,yBAAyB,mBACzB,uBAAuB,mBAAmB,IAAI,QAAQ,KAAK,uBAC3D,mBAAmB,OAAO,UAC1B;AACA,6BAAyB,uCAAsB;AAAA,SAC1C;AACL,6BAAyB,OAAO,uCAAsB,SAAS,uCAAsB;AAAA;AAGvF,MAAI,QAAQ,iBAAiB;AAAM,oBAAgB;AAAA,WAC1C,CAAC,QAAQ,iBAAiB;AAAQ,oBAAgB;AAG3D,SAAO,mBAAmB;AAAA;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/tree/getTreeKeyboardCoordinates.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import { closestCorners, getViewRect, KeyboardCode, KeyboardCoordinateGetter, DroppableContainer } from '@dnd-kit/core';\nimport { Coordinates } from '@dnd-kit/core/dist/types';\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];\nconst vertical: string[] = [KeyboardCode.Up, KeyboardCode.Down];\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;ADAvB,kBAAwG;AAGxG,uBAAsC;AAEtC,MAAM,aAAuB,CAAC,yBAAa,MAAM,yBAAa,OAAO,yBAAa,IAAI,yBAAa;AAEnG,MAAM,aAAuB,CAAC,yBAAa,MAAM,yBAAa;AAC9D,MAAM,WAAqB,CAAC,yBAAa,IAAI,yBAAa;AAE1D,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
- }
@@ -1,7 +0,0 @@
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
- }
@@ -1,7 +0,0 @@
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 = {\n uid: string;\n depth: number;\n parentId: string;\n realIndex: number;\n original: Record<string, Record<string, any>>;\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 = useTreePreviewHandlersReturn & {\n dropIndicatorPosition: DropIndicatorPosition;\n flattenedItems: Item[];\n projected: {\n depth: number;\n parentId: string;\n } | null;\n onReorder: (newData: Item[], indexes: { targetIndex: number; fromIndex: number }, considerExpanding: string) => void;\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 = {\n flattenedItems: Item[];\n visibleItems: Item[];\n isHorizontalDnD?: boolean;\n isExpandable: boolean;\n onReorder: (newData: Item[], indexes: { targetIndex: number; fromIndex: number }, considerExpanding: string) => void;\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 visibleItems: Item[];\n};\n\nexport type useTreeDndkitConfigType = (args: useTreeDndkitConfigArgs) => 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
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/tree/useTreeActionHandlers.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import { arrayMove } from '@dnd-kit/sortable';\nimport { cloneDeep } from 'lodash';\nimport { useCallback } from 'react';\nimport type { DragStartEvent, DragMoveEvent, DragEndEvent, DragOverEvent, DragCancelEvent } from '@dnd-kit/core';\nimport { DropIndicatorPosition } from './constants';\nimport type { useTreeActionHandlersReturn, useTreeActionHandlersArgs } from './types';\n\nexport const useTreeActionHandlers = ({\n handlePreviewDragStart,\n handlePreviewDragMove,\n handlePreviewDragOver,\n handlePreviewDragEnd,\n handlePreviewDragCancel,\n onReorder,\n flattenedItems,\n projected,\n dropIndicatorPosition,\n}: useTreeActionHandlersArgs): useTreeActionHandlersReturn => {\n const onDragStart = useCallback(\n (e: DragStartEvent) => {\n handlePreviewDragStart(e);\n },\n [handlePreviewDragStart],\n );\n\n const onDragMove = useCallback(\n (e: DragMoveEvent) => {\n handlePreviewDragMove(e);\n },\n [handlePreviewDragMove],\n );\n\n const onDragOver = useCallback(\n (e: DragOverEvent) => {\n handlePreviewDragOver(e);\n },\n [handlePreviewDragOver],\n );\n\n const onDragEnd = useCallback(\n (e: DragEndEvent) => {\n handlePreviewDragEnd(e);\n const { active, over } = e;\n\n if (over === null) return;\n\n const activeIndex = flattenedItems.findIndex((item) => item.uid === active.id);\n\n let considerExpanding = null;\n\n let overIndex = flattenedItems.findIndex((item) => item.uid === over.id);\n // If drop indicator is inside, then put it last,\n // It will be reconstructed well later\n if (dropIndicatorPosition === DropIndicatorPosition.Inside) {\n considerExpanding = over.id;\n overIndex = flattenedItems[overIndex].realIndex + (flattenedItems[overIndex].original.subRows?.length ?? 0) + 1;\n }\n\n // If we are dropping the item in a new position, or new depth\n if (projected && (activeIndex !== overIndex || flattenedItems[activeIndex].depth !== projected.depth)) {\n // Change parent and depth from projected data\n flattenedItems[activeIndex].parentId = projected.parentId;\n flattenedItems[activeIndex].depth = projected.depth;\n\n // If same index, don't move the array, just copy it\n const newFlattenedData =\n activeIndex !== overIndex ? arrayMove(flattenedItems, activeIndex, overIndex) : cloneDeep(flattenedItems);\n\n onReorder(\n newFlattenedData,\n {\n targetIndex: overIndex,\n fromIndex: activeIndex,\n },\n considerExpanding || '',\n );\n }\n },\n [handlePreviewDragEnd, flattenedItems, projected, onReorder, dropIndicatorPosition],\n );\n\n const onDragCancel = useCallback(\n (e: DragCancelEvent) => {\n handlePreviewDragCancel(e);\n },\n [handlePreviewDragCancel],\n );\n\n return { onDragStart, onDragMove, onDragOver, onDragEnd, onDragCancel };\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,sBAA0B;AAC1B,oBAA0B;AAC1B,mBAA4B;AAE5B,uBAAsC;AAG/B,MAAM,wBAAwB,CAAC;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,MAC4D;AAC5D,QAAM,cAAc,8BAClB,CAAC,MAAsB;AACrB,2BAAuB;AAAA,KAEzB,CAAC;AAGH,QAAM,aAAa,8BACjB,CAAC,MAAqB;AACpB,0BAAsB;AAAA,KAExB,CAAC;AAGH,QAAM,aAAa,8BACjB,CAAC,MAAqB;AACpB,0BAAsB;AAAA,KAExB,CAAC;AAGH,QAAM,YAAY,8BAChB,CAAC,MAAoB;AACnB,yBAAqB;AACrB,UAAM,EAAE,QAAQ,SAAS;AAEzB,QAAI,SAAS;AAAM;AAEnB,UAAM,cAAc,eAAe,UAAU,CAAC,SAAS,KAAK,QAAQ,OAAO;AAE3E,QAAI,oBAAoB;AAExB,QAAI,YAAY,eAAe,UAAU,CAAC,SAAS,KAAK,QAAQ,KAAK;AAGrE,QAAI,0BAA0B,uCAAsB,QAAQ;AAC1D,0BAAoB,KAAK;AACzB,kBAAY,eAAe,WAAW,YAAa,gBAAe,WAAW,SAAS,SAAS,UAAU,KAAK;AAAA;AAIhH,QAAI,aAAc,iBAAgB,aAAa,eAAe,aAAa,UAAU,UAAU,QAAQ;AAErG,qBAAe,aAAa,WAAW,UAAU;AACjD,qBAAe,aAAa,QAAQ,UAAU;AAG9C,YAAM,mBACJ,gBAAgB,YAAY,+BAAU,gBAAgB,aAAa,aAAa,6BAAU;AAE5F,gBACE,kBACA;AAAA,QACE,aAAa;AAAA,QACb,WAAW;AAAA,SAEb,qBAAqB;AAAA;AAAA,KAI3B,CAAC,sBAAsB,gBAAgB,WAAW,WAAW;AAG/D,QAAM,eAAe,8BACnB,CAAC,MAAuB;AACtB,4BAAwB;AAAA,KAE1B,CAAC;AAGH,SAAO,EAAE,aAAa,YAAY,YAAY,WAAW;AAAA;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/tree/useTreeAnnouncements.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import { Announcements } from '@dnd-kit/core';\nimport { useCallback } from 'react';\nimport { DropIndicatorPosition } from './constants';\nimport { Item } from './types';\n\nexport const useTreeAnnouncements = (\n visibleItemsDictionary: Record<string, Item>,\n dropIndicatorPosition: DropIndicatorPosition,\n): Announcements => {\n const onDragStart = useCallback(\n (id: string) => `Picked up draggable item from position ${visibleItemsDictionary[id].realIndex + 1}.`,\n [visibleItemsDictionary],\n );\n\n const onDragMove = useCallback(\n (id: string, overId: string) => {\n if (overId) {\n const overIndex = visibleItemsDictionary[overId].realIndex + 1;\n if (dropIndicatorPosition === DropIndicatorPosition.Inside) {\n return `Draggable item was moved inside the item at position ${overIndex}.`;\n }\n if (dropIndicatorPosition === DropIndicatorPosition.Before) {\n return `Draggable item was moved to position ${overIndex - 1}.`;\n }\n return `Draggable item was moved to position ${overIndex}.`;\n }\n\n return `Draggable item is no longer over a droppable area.`;\n },\n [visibleItemsDictionary, dropIndicatorPosition],\n );\n\n const onDragOver = onDragMove;\n\n const onDragEnd = useCallback(\n (id: string, overId: string) => {\n if (overId) {\n const overIndex = visibleItemsDictionary[overId].realIndex + 1;\n if (dropIndicatorPosition === DropIndicatorPosition.Inside) {\n return `Draggable item was dropped inside the item at position ${overIndex}.`;\n }\n if (dropIndicatorPosition === DropIndicatorPosition.Before) {\n return `Draggable item was dropped over position ${overIndex - 1}.`;\n }\n return `Draggable item was dropped over position ${overIndex}.`;\n }\n\n return `Draggable item was dropped at it's original position.`;\n },\n [dropIndicatorPosition, visibleItemsDictionary],\n );\n\n const onDragCancel = useCallback(\n (id: string) =>\n `Dragging was cancelled. Draggable item from position ${\n visibleItemsDictionary[id].realIndex + 1\n } was dropped at it's initial position.`,\n [visibleItemsDictionary],\n );\n\n return { onDragStart, onDragOver, onDragMove, onDragEnd, onDragCancel };\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAA4B;AAC5B,uBAAsC;AAG/B,MAAM,uBAAuB,CAClC,wBACA,0BACkB;AAClB,QAAM,cAAc,8BAClB,CAAC,OAAe,0CAA0C,uBAAuB,IAAI,YAAY,MACjG,CAAC;AAGH,QAAM,aAAa,8BACjB,CAAC,IAAY,WAAmB;AAC9B,QAAI,QAAQ;AACV,YAAM,YAAY,uBAAuB,QAAQ,YAAY;AAC7D,UAAI,0BAA0B,uCAAsB,QAAQ;AAC1D,eAAO,wDAAwD;AAAA;AAEjE,UAAI,0BAA0B,uCAAsB,QAAQ;AAC1D,eAAO,wCAAwC,YAAY;AAAA;AAE7D,aAAO,wCAAwC;AAAA;AAGjD,WAAO;AAAA,KAET,CAAC,wBAAwB;AAG3B,QAAM,aAAa;AAEnB,QAAM,YAAY,8BAChB,CAAC,IAAY,WAAmB;AAC9B,QAAI,QAAQ;AACV,YAAM,YAAY,uBAAuB,QAAQ,YAAY;AAC7D,UAAI,0BAA0B,uCAAsB,QAAQ;AAC1D,eAAO,0DAA0D;AAAA;AAEnE,UAAI,0BAA0B,uCAAsB,QAAQ;AAC1D,eAAO,4CAA4C,YAAY;AAAA;AAEjE,aAAO,4CAA4C;AAAA;AAGrD,WAAO;AAAA,KAET,CAAC,uBAAuB;AAG1B,QAAM,eAAe,8BACnB,CAAC,OACC,wDACE,uBAAuB,IAAI,YAAY,2CAE3C,CAAC;AAGH,SAAO,EAAE,aAAa,YAAY,YAAY,WAAW;AAAA;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/tree/useTreeDndkitConfig.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["/* eslint-disable max-lines */\nimport { useState, useEffect, useMemo, useRef } from 'react';\nimport {\n useSensor,\n useSensors,\n KeyboardSensor,\n PointerSensor,\n MeasuringConfiguration,\n MeasuringStrategy,\n Modifier,\n} from '@dnd-kit/core';\nimport { horizontalListSortingStrategy, verticalListSortingStrategy } from '@dnd-kit/sortable';\nimport { useTreePreviewHandlers } from './useTreePreviewHandlers';\nimport { getTreeKeyboardCoordinates } from './getTreeKeyboardCoordinates';\nimport { getProjection, removeChildrenOf } from './utilities';\nimport { useTreeActionHandlers } from './useTreeActionHandlers';\nimport type { useTreeDndkitConfigType, SensorContext, Item } from './types';\nimport { DropIndicatorPosition } from './constants';\nimport { customCollisionDetection } from './customCollisionDetection';\nimport { useTreeAnnouncements } from './useTreeAnnouncements';\n\n// we make space for the drop indicator\n// if second parameter is true, the space will be done on the horizontal axis\nconst adjustTranslate =\n (isHorizontalDnD: boolean): Modifier =>\n ({ transform }) => {\n const newTransform = {\n ...transform,\n };\n if (isHorizontalDnD) {\n newTransform.x = transform.x + 25;\n } else {\n newTransform.x = transform.x + 15;\n }\n return newTransform;\n };\n\nconst measuring: Partial<MeasuringConfiguration> = {\n droppable: {\n strategy: MeasuringStrategy.BeforeDragging,\n },\n};\n\nexport const useTreeDndkitConfig: useTreeDndkitConfigType = ({\n flattenedItems,\n visibleItems: preVisibleItems,\n isHorizontalDnD = false,\n isExpandable = false,\n onReorder,\n maxDragAndDropLevel,\n}) => {\n const [activeId, setActiveId] = useState<string>('');\n const [overId, setOverId] = useState<string>('');\n const [dropIndicatorPosition, setDropIndicatorPosition] = useState<DropIndicatorPosition>(DropIndicatorPosition.None);\n const [lastPosition, setLastPosition] = useState<string>('');\n\n // Remove activeId's children\n const visibleItems = useMemo(() => removeChildrenOf(preVisibleItems, activeId), [preVisibleItems, activeId]);\n\n // Sorted ids for the library\n const sortedIds = useMemo(() => visibleItems.map((item) => item.uid), [visibleItems]);\n\n /**\n * Dictionary from UID to ITEM\n * This dictionary is computed since on every DnD move, I need to know the\n * depth of a particular row, so O(1) per DnD move instead of O(#ITEMS)\n */\n const visibleItemsDictionary = useMemo(() => {\n // Using plain for to achieve O(#ITEMS) performance\n const dictionary: Record<string, Item> = {};\n visibleItems.forEach((item) => {\n dictionary[item.uid] = item;\n });\n return dictionary;\n }, [visibleItems]);\n\n const modifiers: Modifier[] = useMemo(() => [adjustTranslate(isHorizontalDnD)], [isHorizontalDnD]);\n\n const sensorContext: SensorContext = useRef({\n items: visibleItems,\n dropIndicatorPosition,\n setDropIndicatorPosition,\n });\n\n useEffect(() => {\n sensorContext.current = {\n items: visibleItems,\n dropIndicatorPosition,\n setDropIndicatorPosition,\n };\n }, [visibleItems, dropIndicatorPosition, setDropIndicatorPosition]);\n\n const coordinateGetter = useMemo(\n () => getTreeKeyboardCoordinates(sensorContext, isHorizontalDnD, maxDragAndDropLevel),\n [sensorContext, isHorizontalDnD, maxDragAndDropLevel],\n );\n\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor, {\n coordinateGetter,\n }),\n );\n\n // where is the activeItem being positioned (depth and parent)\n const projected = useMemo(\n () =>\n overId ? getProjection(visibleItems, visibleItemsDictionary, overId, dropIndicatorPosition, isExpandable) : null,\n [overId, visibleItems, visibleItemsDictionary, dropIndicatorPosition, isExpandable],\n );\n\n const dragPreviewHandlers = useTreePreviewHandlers({\n setActiveId,\n setOverId,\n setDropIndicatorPosition,\n });\n\n const dragActionHandlers = useTreeActionHandlers({\n ...dragPreviewHandlers,\n onReorder,\n projected,\n flattenedItems,\n dropIndicatorPosition,\n });\n\n const announcements = useTreeAnnouncements(visibleItemsDictionary, dropIndicatorPosition);\n\n const dndContextProps = useMemo(\n () => ({\n announcements,\n modifiers,\n sensors,\n measuring,\n collisionDetection: customCollisionDetection(\n activeId,\n visibleItemsDictionary,\n setDropIndicatorPosition,\n maxDragAndDropLevel,\n lastPosition,\n setLastPosition,\n ),\n ...dragActionHandlers,\n }),\n [\n announcements,\n modifiers,\n sensors,\n dragActionHandlers,\n visibleItemsDictionary,\n setDropIndicatorPosition,\n activeId,\n maxDragAndDropLevel,\n lastPosition,\n setLastPosition,\n ],\n );\n\n const sortableContextProps = useMemo(\n () => ({\n items: sortedIds,\n strategy: isHorizontalDnD ? horizontalListSortingStrategy : verticalListSortingStrategy,\n }),\n [sortedIds, isHorizontalDnD],\n );\n\n return {\n dndContextProps,\n sortableContextProps,\n activeId,\n activeIndex: visibleItemsDictionary[activeId]?.realIndex ?? -1,\n overId,\n depth: projected ? projected.depth : 0,\n dropIndicatorPosition,\n visibleItems,\n };\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAAqD;AACrD,kBAQO;AACP,sBAA2E;AAC3E,oCAAuC;AACvC,wCAA2C;AAC3C,uBAAgD;AAChD,mCAAsC;AAEtC,uBAAsC;AACtC,sCAAyC;AACzC,kCAAqC;AAIrC,MAAM,kBACJ,CAAC,oBACD,CAAC,EAAE,gBAAgB;AACjB,QAAM,eAAe;AAAA,OAChB;AAAA;AAEL,MAAI,iBAAiB;AACnB,iBAAa,IAAI,UAAU,IAAI;AAAA,SAC1B;AACL,iBAAa,IAAI,UAAU,IAAI;AAAA;AAEjC,SAAO;AAAA;AAGX,MAAM,YAA6C;AAAA,EACjD,WAAW;AAAA,IACT,UAAU,8BAAkB;AAAA;AAAA;AAIzB,MAAM,sBAA+C,CAAC;AAAA,EAC3D;AAAA,EACA,cAAc;AAAA,EACd,kBAAkB;AAAA,EAClB,eAAe;AAAA,EACf;AAAA,EACA;AAAA,MACI;AACJ,QAAM,CAAC,UAAU,eAAe,2BAAiB;AACjD,QAAM,CAAC,QAAQ,aAAa,2BAAiB;AAC7C,QAAM,CAAC,uBAAuB,4BAA4B,2BAAgC,uCAAsB;AAChH,QAAM,CAAC,cAAc,mBAAmB,2BAAiB;AAGzD,QAAM,eAAe,0BAAQ,MAAM,uCAAiB,iBAAiB,WAAW,CAAC,iBAAiB;AAGlG,QAAM,YAAY,0BAAQ,MAAM,aAAa,IAAI,CAAC,SAAS,KAAK,MAAM,CAAC;AAOvE,QAAM,yBAAyB,0BAAQ,MAAM;AAE3C,UAAM,aAAmC;AACzC,iBAAa,QAAQ,CAAC,SAAS;AAC7B,iBAAW,KAAK,OAAO;AAAA;AAEzB,WAAO;AAAA,KACN,CAAC;AAEJ,QAAM,YAAwB,0BAAQ,MAAM,CAAC,gBAAgB,mBAAmB,CAAC;AAEjF,QAAM,gBAA+B,yBAAO;AAAA,IAC1C,OAAO;AAAA,IACP;AAAA,IACA;AAAA;AAGF,8BAAU,MAAM;AACd,kBAAc,UAAU;AAAA,MACtB,OAAO;AAAA,MACP;AAAA,MACA;AAAA;AAAA,KAED,CAAC,cAAc,uBAAuB;AAEzC,QAAM,mBAAmB,0BACvB,MAAM,kEAA2B,eAAe,iBAAiB,sBACjE,CAAC,eAAe,iBAAiB;AAGnC,QAAM,UAAU,4BACd,2BAAU,4BACV,2BAAU,4BAAgB;AAAA,IACxB;AAAA;AAKJ,QAAM,YAAY,0BAChB,MACE,SAAS,oCAAc,cAAc,wBAAwB,QAAQ,uBAAuB,gBAAgB,MAC9G,CAAC,QAAQ,cAAc,wBAAwB,uBAAuB;AAGxE,QAAM,sBAAsB,0DAAuB;AAAA,IACjD;AAAA,IACA;AAAA,IACA;AAAA;AAGF,QAAM,qBAAqB,wDAAsB;AAAA,OAC5C;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAGF,QAAM,gBAAgB,sDAAqB,wBAAwB;AAEnE,QAAM,kBAAkB,0BACtB,MAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,oBAAoB,8DAClB,UACA,wBACA,0BACA,qBACA,cACA;AAAA,OAEC;AAAA,MAEL;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAIJ,QAAM,uBAAuB,0BAC3B,MAAO;AAAA,IACL,OAAO;AAAA,IACP,UAAU,kBAAkB,gDAAgC;AAAA,MAE9D,CAAC,WAAW;AAGd,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa,uBAAuB,WAAW,aAAa;AAAA,IAC5D;AAAA,IACA,OAAO,YAAY,UAAU,QAAQ;AAAA,IACrC;AAAA,IACA;AAAA;AAAA;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/tree/useTreePreviewHandlers.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import { useCallback } from 'react';\nimport { DragStartEvent, DragOverEvent } from '@dnd-kit/core';\nimport type { useTreePreviewHandlersReturn, useTreePreviewHandlersArgs } from './types';\nimport { DropIndicatorPosition } from './constants';\n\nexport const useTreePreviewHandlers = ({\n setOverId,\n setActiveId,\n setDropIndicatorPosition,\n}: useTreePreviewHandlersArgs): useTreePreviewHandlersReturn => {\n const resetState = useCallback(() => {\n setOverId('');\n setActiveId('');\n\n document.body.style.setProperty('cursor', '');\n }, [setOverId, setActiveId]);\n\n const handlePreviewDragStart = useCallback(\n ({ active: { id } }: DragStartEvent) => {\n setActiveId(id);\n setOverId(id);\n setDropIndicatorPosition(DropIndicatorPosition.Inside);\n\n document.body.style.setProperty('cursor', 'grabbing');\n },\n [setActiveId, setDropIndicatorPosition, setOverId],\n );\n\n const handlePreviewDragMove = useCallback(() => null, []);\n\n const handlePreviewDragOver = useCallback(\n ({ over }: DragOverEvent) => {\n setOverId(over?.id ?? '');\n },\n [setOverId],\n );\n\n const handlePreviewDragEnd = useCallback(() => {\n resetState();\n }, [resetState]);\n\n const handlePreviewDragCancel = useCallback(() => {\n resetState();\n }, [resetState]);\n\n return {\n handlePreviewDragStart,\n handlePreviewDragMove,\n handlePreviewDragOver,\n handlePreviewDragEnd,\n handlePreviewDragCancel,\n };\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA4B;AAG5B,uBAAsC;AAE/B,MAAM,yBAAyB,CAAC;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,MAC8D;AAC9D,QAAM,aAAa,8BAAY,MAAM;AACnC,cAAU;AACV,gBAAY;AAEZ,aAAS,KAAK,MAAM,YAAY,UAAU;AAAA,KACzC,CAAC,WAAW;AAEf,QAAM,yBAAyB,8BAC7B,CAAC,EAAE,QAAQ,EAAE,WAA2B;AACtC,gBAAY;AACZ,cAAU;AACV,6BAAyB,uCAAsB;AAE/C,aAAS,KAAK,MAAM,YAAY,UAAU;AAAA,KAE5C,CAAC,aAAa,0BAA0B;AAG1C,QAAM,wBAAwB,8BAAY,MAAM,MAAM;AAEtD,QAAM,wBAAwB,8BAC5B,CAAC,EAAE,WAA0B;AAC3B,cAAU,MAAM,MAAM;AAAA,KAExB,CAAC;AAGH,QAAM,uBAAuB,8BAAY,MAAM;AAC7C;AAAA,KACC,CAAC;AAEJ,QAAM,0BAA0B,8BAAY,MAAM;AAChD;AAAA,KACC,CAAC;AAEJ,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/tree/utilities.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["/* eslint-disable max-params */\nimport { DropIndicatorPosition } from './constants';\n\nimport { Item } from './types';\n\nconst getMinDepth = (item: Item) => {\n if (item) return item.depth;\n return 0;\n};\n\nexport const getProjection = (\n items: Item[],\n visibleItemsDictionary: Record<string, Item>,\n overId: string,\n dropIndicatorPosition: DropIndicatorPosition,\n isExpandable: boolean,\n): { depth: number; parentId: string } => {\n const overItemIndex = visibleItemsDictionary[overId].realIndex;\n\n const previousItem = items[overItemIndex];\n const nextItem = items[overItemIndex + 1];\n\n if (dropIndicatorPosition === DropIndicatorPosition.Inside && isExpandable) {\n return {\n depth: visibleItemsDictionary[overId].depth + 1,\n parentId: overId,\n };\n }\n if (dropIndicatorPosition === DropIndicatorPosition.Before) {\n return { depth: getMinDepth(previousItem), parentId: previousItem.parentId };\n }\n return { depth: getMinDepth(nextItem), parentId: nextItem?.parentId };\n};\n\nexport const removeChildrenOf = (items: Item[], id: string): Item[] => {\n const excludeParentIds = [id];\n\n return items.filter((item) => {\n if (item.parentId !== null && excludeParentIds.includes(item.parentId)) {\n excludeParentIds.push(item.uid);\n return false;\n }\n return true;\n });\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,uBAAsC;AAItC,MAAM,cAAc,CAAC,SAAe;AAClC,MAAI;AAAM,WAAO,KAAK;AACtB,SAAO;AAAA;AAGF,MAAM,gBAAgB,CAC3B,OACA,wBACA,QACA,uBACA,iBACwC;AACxC,QAAM,gBAAgB,uBAAuB,QAAQ;AAErD,QAAM,eAAe,MAAM;AAC3B,QAAM,WAAW,MAAM,gBAAgB;AAEvC,MAAI,0BAA0B,uCAAsB,UAAU,cAAc;AAC1E,WAAO;AAAA,MACL,OAAO,uBAAuB,QAAQ,QAAQ;AAAA,MAC9C,UAAU;AAAA;AAAA;AAGd,MAAI,0BAA0B,uCAAsB,QAAQ;AAC1D,WAAO,EAAE,OAAO,YAAY,eAAe,UAAU,aAAa;AAAA;AAEpE,SAAO,EAAE,OAAO,YAAY,WAAW,UAAU,UAAU;AAAA;AAGtD,MAAM,mBAAmB,CAAC,OAAe,OAAuB;AACrE,QAAM,mBAAmB,CAAC;AAE1B,SAAO,MAAM,OAAO,CAAC,SAAS;AAC5B,QAAI,KAAK,aAAa,QAAQ,iBAAiB,SAAS,KAAK,WAAW;AACtE,uBAAiB,KAAK,KAAK;AAC3B,aAAO;AAAA;AAET,WAAO;AAAA;AAAA;",
6
- "names": []
7
- }