@elliemae/ds-drag-and-drop 2.2.0 → 2.3.0-alpha.3

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 (82) hide show
  1. package/cjs/hierarchy/customCollisionDetection.js +44 -50
  2. package/cjs/hierarchy/customCollisionDetection.js.map +7 -0
  3. package/cjs/hierarchy/getHierarchyKeyboardCoordinates.js +78 -91
  4. package/cjs/hierarchy/getHierarchyKeyboardCoordinates.js.map +7 -0
  5. package/cjs/hierarchy/index.js +28 -9
  6. package/cjs/hierarchy/index.js.map +7 -0
  7. package/cjs/hierarchy/types.js +27 -2
  8. package/cjs/hierarchy/types.js.map +7 -0
  9. package/cjs/hierarchy/useHierarchyActionHandlers.js +53 -35
  10. package/cjs/hierarchy/useHierarchyActionHandlers.js.map +7 -0
  11. package/cjs/hierarchy/useHierarchyAnnouncements.js +45 -26
  12. package/cjs/hierarchy/useHierarchyAnnouncements.js.map +7 -0
  13. package/cjs/hierarchy/useHierarchyDndkitConfig.js +77 -83
  14. package/cjs/hierarchy/useHierarchyDndkitConfig.js.map +7 -0
  15. package/cjs/hierarchy/useHierarchyPreviewHandlers.js +48 -27
  16. package/cjs/hierarchy/useHierarchyPreviewHandlers.js.map +7 -0
  17. package/cjs/index.js +29 -11
  18. package/cjs/index.js.map +7 -0
  19. package/cjs/tree/constants.js +41 -12
  20. package/cjs/tree/constants.js.map +7 -0
  21. package/cjs/tree/customCollisionDetection.js +96 -124
  22. package/cjs/tree/customCollisionDetection.js.map +7 -0
  23. package/cjs/tree/getTreeKeyboardCoordinates.js +86 -101
  24. package/cjs/tree/getTreeKeyboardCoordinates.js.map +7 -0
  25. package/cjs/tree/index.js +28 -9
  26. package/cjs/tree/index.js.map +7 -0
  27. package/cjs/tree/types.js +27 -2
  28. package/cjs/tree/types.js.map +7 -0
  29. package/cjs/tree/useTreeActionHandlers.js +68 -57
  30. package/cjs/tree/useTreeActionHandlers.js.map +7 -0
  31. package/cjs/tree/useTreeAnnouncements.js +53 -40
  32. package/cjs/tree/useTreeAnnouncements.js.map +7 -0
  33. package/cjs/tree/useTreeDndkitConfig.js +112 -98
  34. package/cjs/tree/useTreeDndkitConfig.js.map +7 -0
  35. package/cjs/tree/useTreePreviewHandlers.js +53 -37
  36. package/cjs/tree/useTreePreviewHandlers.js.map +7 -0
  37. package/cjs/tree/utilities.js +44 -30
  38. package/cjs/tree/utilities.js.map +7 -0
  39. package/esm/hierarchy/customCollisionDetection.js +15 -46
  40. package/esm/hierarchy/customCollisionDetection.js.map +7 -0
  41. package/esm/hierarchy/getHierarchyKeyboardCoordinates.js +42 -76
  42. package/esm/hierarchy/getHierarchyKeyboardCoordinates.js.map +7 -0
  43. package/esm/hierarchy/index.js +3 -1
  44. package/esm/hierarchy/index.js.map +7 -0
  45. package/esm/hierarchy/types.js +2 -1
  46. package/esm/hierarchy/types.js.map +7 -0
  47. package/esm/hierarchy/useHierarchyActionHandlers.js +24 -31
  48. package/esm/hierarchy/useHierarchyActionHandlers.js.map +7 -0
  49. package/esm/hierarchy/useHierarchyAnnouncements.js +14 -20
  50. package/esm/hierarchy/useHierarchyAnnouncements.js.map +7 -0
  51. package/esm/hierarchy/useHierarchyDndkitConfig.js +45 -66
  52. package/esm/hierarchy/useHierarchyDndkitConfig.js.map +7 -0
  53. package/esm/hierarchy/useHierarchyPreviewHandlers.js +15 -19
  54. package/esm/hierarchy/useHierarchyPreviewHandlers.js.map +7 -0
  55. package/esm/index.js +4 -2
  56. package/esm/index.js.map +7 -0
  57. package/esm/tree/constants.js +12 -10
  58. package/esm/tree/constants.js.map +7 -0
  59. package/esm/tree/customCollisionDetection.js +67 -120
  60. package/esm/tree/customCollisionDetection.js.map +7 -0
  61. package/esm/tree/getTreeKeyboardCoordinates.js +48 -84
  62. package/esm/tree/getTreeKeyboardCoordinates.js.map +7 -0
  63. package/esm/tree/index.js +3 -1
  64. package/esm/tree/index.js.map +7 -0
  65. package/esm/tree/types.js +2 -1
  66. package/esm/tree/types.js.map +7 -0
  67. package/esm/tree/useTreeActionHandlers.js +37 -51
  68. package/esm/tree/useTreeActionHandlers.js.map +7 -0
  69. package/esm/tree/useTreeAnnouncements.js +18 -30
  70. package/esm/tree/useTreeAnnouncements.js.map +7 -0
  71. package/esm/tree/useTreeDndkitConfig.js +79 -80
  72. package/esm/tree/useTreeDndkitConfig.js.map +7 -0
  73. package/esm/tree/useTreePreviewHandlers.js +19 -28
  74. package/esm/tree/useTreePreviewHandlers.js.map +7 -0
  75. package/esm/tree/utilities.js +13 -23
  76. package/esm/tree/utilities.js.map +7 -0
  77. package/package.json +1 -1
  78. package/types/hierarchy/types.d.ts +1 -1
  79. package/types/tree/types.d.ts +17 -13
  80. package/types/tree/useTreeActionHandlers.d.ts +2 -2
  81. package/types/tree/useTreeDndkitConfig.d.ts +2 -2
  82. package/types/tree/useTreePreviewHandlers.d.ts +2 -2
@@ -1,75 +1,86 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var sortable = require('@dnd-kit/sortable');
6
- var lodash = require('lodash');
7
- var react = require('react');
8
- var constants = require('./constants.js');
9
-
10
- const useTreeActionHandlers = _ref => {
11
- let {
12
- handlePreviewDragStart,
13
- handlePreviewDragMove,
14
- handlePreviewDragOver,
15
- handlePreviewDragEnd,
16
- handlePreviewDragCancel,
17
- onReorder,
18
- flattenedItems,
19
- projected,
20
- dropIndicatorPosition
21
- } = _ref;
22
- const onDragStart = react.useCallback(e => {
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 useTreeActionHandlers_exports = {};
29
+ __export(useTreeActionHandlers_exports, {
30
+ useTreeActionHandlers: () => useTreeActionHandlers
31
+ });
32
+ var React = __toESM(require("react"));
33
+ var import_sortable = require("@dnd-kit/sortable");
34
+ var import_lodash = require("lodash");
35
+ var import_react = require("react");
36
+ var import_constants = require("./constants");
37
+ const useTreeActionHandlers = ({
38
+ handlePreviewDragStart,
39
+ handlePreviewDragMove,
40
+ handlePreviewDragOver,
41
+ handlePreviewDragEnd,
42
+ handlePreviewDragCancel,
43
+ onReorder,
44
+ flattenedItems,
45
+ projected,
46
+ dropIndicatorPosition,
47
+ isDropValid
48
+ }) => {
49
+ const onDragStart = (0, import_react.useCallback)((e) => {
23
50
  handlePreviewDragStart(e);
24
51
  }, [handlePreviewDragStart]);
25
- const onDragMove = react.useCallback(e => {
52
+ const onDragMove = (0, import_react.useCallback)((e) => {
26
53
  handlePreviewDragMove(e);
27
54
  }, [handlePreviewDragMove]);
28
- const onDragOver = react.useCallback(e => {
55
+ const onDragOver = (0, import_react.useCallback)((e) => {
29
56
  handlePreviewDragOver(e);
30
57
  }, [handlePreviewDragOver]);
31
- const onDragEnd = react.useCallback(e => {
58
+ const onDragEnd = (0, import_react.useCallback)((e) => {
32
59
  handlePreviewDragEnd(e);
33
- const {
34
- active,
35
- over
36
- } = e;
37
- if (over === null) return;
38
- const activeIndex = flattenedItems.findIndex(item => item.uid === active.id);
60
+ const { active, over } = e;
61
+ if (over === null || !isDropValid)
62
+ return;
63
+ const activeIndex = flattenedItems.findIndex((item) => item.uid === active.id);
39
64
  let considerExpanding = null;
40
- let overIndex = flattenedItems.findIndex(item => item.uid === over.id); // If drop indicator is inside, then put it last,
41
- // It will be reconstructed well later
42
-
43
- if (dropIndicatorPosition === constants.DropIndicatorPosition.Inside) {
44
- var _flattenedItems$overI, _flattenedItems$overI2;
45
-
65
+ let overIndex = flattenedItems.findIndex((item) => item.uid === over.id);
66
+ if (dropIndicatorPosition === import_constants.DropIndicatorPosition.Inside) {
46
67
  considerExpanding = over.id;
47
- overIndex = flattenedItems[overIndex].realIndex + ((_flattenedItems$overI = (_flattenedItems$overI2 = flattenedItems[overIndex].original.subRows) === null || _flattenedItems$overI2 === void 0 ? void 0 : _flattenedItems$overI2.length) !== null && _flattenedItems$overI !== void 0 ? _flattenedItems$overI : 0) + 1;
48
- } // If we are dropping the item in a new position, or new depth
49
-
50
-
68
+ overIndex = flattenedItems[overIndex].realIndex + flattenedItems[overIndex].childrenCount + 1;
69
+ }
51
70
  if (projected && (activeIndex !== overIndex || flattenedItems[activeIndex].depth !== projected.depth)) {
52
- // Change parent and depth from projected data
53
71
  flattenedItems[activeIndex].parentId = projected.parentId;
54
- flattenedItems[activeIndex].depth = projected.depth; // If same index, don't move the array, just copy it
55
-
56
- const newFlattenedData = activeIndex !== overIndex ? sortable.arrayMove(flattenedItems, activeIndex, overIndex) : lodash.cloneDeep(flattenedItems);
72
+ flattenedItems[activeIndex].depth = projected.depth;
73
+ const newFlattenedData = activeIndex !== overIndex ? (0, import_sortable.arrayMove)(flattenedItems, activeIndex, overIndex) : (0, import_lodash.cloneDeep)(flattenedItems);
57
74
  onReorder(newFlattenedData, {
58
75
  targetIndex: overIndex,
59
76
  fromIndex: activeIndex
60
- }, considerExpanding || '');
77
+ }, considerExpanding || "");
61
78
  }
62
- }, [handlePreviewDragEnd, flattenedItems, projected, onReorder, dropIndicatorPosition]);
63
- const onDragCancel = react.useCallback(e => {
79
+ }, [handlePreviewDragEnd, isDropValid, flattenedItems, dropIndicatorPosition, projected, onReorder]);
80
+ const onDragCancel = (0, import_react.useCallback)((e) => {
64
81
  handlePreviewDragCancel(e);
65
82
  }, [handlePreviewDragCancel]);
66
- return {
67
- onDragStart,
68
- onDragMove,
69
- onDragOver,
70
- onDragEnd,
71
- onDragCancel
72
- };
83
+ return { onDragStart, onDragMove, onDragOver, onDragEnd, onDragCancel };
73
84
  };
74
-
75
- exports.useTreeActionHandlers = useTreeActionHandlers;
85
+ module.exports = __toCommonJS(useTreeActionHandlers_exports);
86
+ //# sourceMappingURL=useTreeActionHandlers.js.map
@@ -0,0 +1,7 @@
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 isDropValid,\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 || !isDropValid) 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].childrenCount + 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, isDropValid, flattenedItems, dropIndicatorPosition, projected, onReorder],\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,mB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
+ "names": []
7
+ }
@@ -1,55 +1,68 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var react = require('react');
6
- var constants = require('./constants.js');
7
-
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 useTreeAnnouncements_exports = {};
29
+ __export(useTreeAnnouncements_exports, {
30
+ useTreeAnnouncements: () => useTreeAnnouncements
31
+ });
32
+ var React = __toESM(require("react"));
33
+ var import_react = require("react");
34
+ var import_constants = require("./constants");
8
35
  const useTreeAnnouncements = (visibleItemsDictionary, dropIndicatorPosition) => {
9
- const onDragStart = react.useCallback(id => "Picked up draggable item from position ".concat(visibleItemsDictionary[id].realIndex + 1, "."), [visibleItemsDictionary]);
10
- const onDragMove = react.useCallback((id, overId) => {
36
+ const onDragStart = (0, import_react.useCallback)((id) => `Picked up draggable item from position ${visibleItemsDictionary[id].realIndex + 1}.`, [visibleItemsDictionary]);
37
+ const onDragMove = (0, import_react.useCallback)((id, overId) => {
11
38
  if (overId) {
12
39
  const overIndex = visibleItemsDictionary[overId].realIndex + 1;
13
-
14
- if (dropIndicatorPosition === constants.DropIndicatorPosition.Inside) {
15
- return "Draggable item was moved inside the item at position ".concat(overIndex, ".");
40
+ if (dropIndicatorPosition === import_constants.DropIndicatorPosition.Inside) {
41
+ return `Draggable item was moved inside the item at position ${overIndex}.`;
16
42
  }
17
-
18
- if (dropIndicatorPosition === constants.DropIndicatorPosition.Before) {
19
- return "Draggable item was moved to position ".concat(overIndex - 1, ".");
43
+ if (dropIndicatorPosition === import_constants.DropIndicatorPosition.Before) {
44
+ return `Draggable item was moved to position ${overIndex - 1}.`;
20
45
  }
21
-
22
- return "Draggable item was moved to position ".concat(overIndex, ".");
46
+ return `Draggable item was moved to position ${overIndex}.`;
23
47
  }
24
-
25
- return "Draggable item is no longer over a droppable area.";
48
+ return `Draggable item is no longer over a droppable area.`;
26
49
  }, [visibleItemsDictionary, dropIndicatorPosition]);
27
50
  const onDragOver = onDragMove;
28
- const onDragEnd = react.useCallback((id, overId) => {
51
+ const onDragEnd = (0, import_react.useCallback)((id, overId) => {
29
52
  if (overId) {
30
53
  const overIndex = visibleItemsDictionary[overId].realIndex + 1;
31
-
32
- if (dropIndicatorPosition === constants.DropIndicatorPosition.Inside) {
33
- return "Draggable item was dropped inside the item at position ".concat(overIndex, ".");
54
+ if (dropIndicatorPosition === import_constants.DropIndicatorPosition.Inside) {
55
+ return `Draggable item was dropped inside the item at position ${overIndex}.`;
34
56
  }
35
-
36
- if (dropIndicatorPosition === constants.DropIndicatorPosition.Before) {
37
- return "Draggable item was dropped over position ".concat(overIndex - 1, ".");
57
+ if (dropIndicatorPosition === import_constants.DropIndicatorPosition.Before) {
58
+ return `Draggable item was dropped over position ${overIndex - 1}.`;
38
59
  }
39
-
40
- return "Draggable item was dropped over position ".concat(overIndex, ".");
60
+ return `Draggable item was dropped over position ${overIndex}.`;
41
61
  }
42
-
43
- return "Draggable item was dropped at it's original position.";
62
+ return `Draggable item was dropped at it's original position.`;
44
63
  }, [dropIndicatorPosition, visibleItemsDictionary]);
45
- const onDragCancel = react.useCallback(id => "Dragging was cancelled. Draggable item from position ".concat(visibleItemsDictionary[id].realIndex + 1, " was dropped at it's initial position."), [visibleItemsDictionary]);
46
- return {
47
- onDragStart,
48
- onDragOver,
49
- onDragMove,
50
- onDragEnd,
51
- onDragCancel
52
- };
64
+ const onDragCancel = (0, import_react.useCallback)((id) => `Dragging was cancelled. Draggable item from position ${visibleItemsDictionary[id].realIndex + 1} was dropped at it's initial position.`, [visibleItemsDictionary]);
65
+ return { onDragStart, onDragOver, onDragMove, onDragEnd, onDragCancel };
53
66
  };
54
-
55
- exports.useTreeAnnouncements = useTreeAnnouncements;
67
+ module.exports = __toCommonJS(useTreeAnnouncements_exports);
68
+ //# sourceMappingURL=useTreeAnnouncements.js.map
@@ -0,0 +1,7 @@
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,142 +1,156 @@
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
-
41
- if (isHorizontalDnD) {
42
- newTransform.x = transform.x + 25;
43
- } else {
44
- newTransform.x = transform.x + 15;
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 });
45
17
  }
46
-
47
- return newTransform;
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 = require("react");
34
+ var import_core = require("@dnd-kit/core");
35
+ var import_useTreePreviewHandlers = require("./useTreePreviewHandlers");
36
+ var import_getTreeKeyboardCoordinates = require("./getTreeKeyboardCoordinates");
37
+ var import_utilities = require("./utilities");
38
+ var import_useTreeActionHandlers = require("./useTreeActionHandlers");
39
+ var import_constants = require("./constants");
40
+ var import_customCollisionDetection = require("./customCollisionDetection");
41
+ var import_useTreeAnnouncements = require("./useTreeAnnouncements");
42
+ const adjustTranslate = (isHorizontalDnD) => {
43
+ const func = ({ transform }) => {
44
+ const newTransform = {
45
+ ...transform
46
+ };
47
+ if (isHorizontalDnD) {
48
+ newTransform.x = transform.x + 25;
49
+ } else {
50
+ newTransform.x = transform.x + 15;
51
+ }
52
+ return newTransform;
53
+ };
54
+ return func;
48
55
  };
49
-
50
56
  const measuring = {
51
57
  droppable: {
52
- strategy: core.MeasuringStrategy.BeforeDragging
58
+ strategy: import_core.MeasuringStrategy.Always
53
59
  }
54
60
  };
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
61
+ const useTreeDndkitConfig = ({
62
+ flattenedItems,
63
+ visibleItems: preVisibleItems,
64
+ isHorizontalDnD = false,
65
+ isExpandable = false,
66
+ onReorder,
67
+ getIsDropValid = () => true,
68
+ maxDragAndDropLevel
69
+ }) => {
70
+ const [activeId, setActiveId] = (0, import_react.useState)("");
71
+ const [overId, setOverId] = (0, import_react.useState)("");
72
+ const [dropIndicatorPosition, setDropIndicatorPosition] = (0, import_react.useState)(import_constants.DropIndicatorPosition.None);
73
+ const [lastPosition, setLastPosition] = (0, import_react.useState)("");
74
+ const visibleItems = (0, import_react.useMemo)(() => (0, import_utilities.removeChildrenOf)(preVisibleItems, activeId), [preVisibleItems, activeId]);
75
+ const sortedIds = (0, import_react.useMemo)(() => visibleItems.map((item) => item.uid), [visibleItems]);
76
+ const visibleItemsDictionary = (0, import_react.useMemo)(() => {
82
77
  const dictionary = {};
83
- visibleItems.forEach(item => {
78
+ visibleItems.forEach((item) => {
84
79
  dictionary[item.uid] = item;
85
80
  });
86
81
  return dictionary;
87
82
  }, [visibleItems]);
88
- const modifiers = react.useMemo(() => [adjustTranslate(isHorizontalDnD)], [isHorizontalDnD]);
89
- const sensorContext = react.useRef({
83
+ const isDropValid = (0, import_react.useMemo)(() => {
84
+ if (!activeId || !overId)
85
+ return true;
86
+ return getIsDropValid(visibleItemsDictionary[activeId], visibleItemsDictionary[overId], ["none", "before", "after", "inside"][dropIndicatorPosition]);
87
+ }, [getIsDropValid, visibleItemsDictionary, activeId, overId, dropIndicatorPosition]);
88
+ const modifiers = (0, import_react.useMemo)(() => [adjustTranslate(isHorizontalDnD)], [isHorizontalDnD]);
89
+ const sensorContext = (0, import_react.useRef)({
90
90
  items: visibleItems,
91
91
  dropIndicatorPosition,
92
92
  setDropIndicatorPosition
93
93
  });
94
- react.useEffect(() => {
94
+ (0, import_react.useEffect)(() => {
95
95
  sensorContext.current = {
96
96
  items: visibleItems,
97
97
  dropIndicatorPosition,
98
98
  setDropIndicatorPosition
99
99
  };
100
100
  }, [visibleItems, dropIndicatorPosition, setDropIndicatorPosition]);
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, {
101
+ const coordinateGetter = (0, import_react.useMemo)(() => (0, import_getTreeKeyboardCoordinates.getTreeKeyboardCoordinates)(sensorContext, isHorizontalDnD, maxDragAndDropLevel), [sensorContext, isHorizontalDnD, maxDragAndDropLevel]);
102
+ const sensors = (0, import_core.useSensors)((0, import_core.useSensor)(import_core.PointerSensor), (0, import_core.useSensor)(import_core.KeyboardSensor, {
103
103
  coordinateGetter
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({
104
+ }));
105
+ const projected = (0, import_react.useMemo)(() => overId ? (0, import_utilities.getProjection)(visibleItems, visibleItemsDictionary, overId, dropIndicatorPosition, isExpandable) : null, [overId, visibleItems, visibleItemsDictionary, dropIndicatorPosition, isExpandable]);
106
+ const dragPreviewHandlers = (0, import_useTreePreviewHandlers.useTreePreviewHandlers)({
108
107
  setActiveId,
109
108
  setOverId,
110
109
  setDropIndicatorPosition
111
110
  });
112
- const dragActionHandlers = useTreeActionHandlers.useTreeActionHandlers(_objectSpread(_objectSpread({}, dragPreviewHandlers), {}, {
111
+ const dragActionHandlers = (0, import_useTreeActionHandlers.useTreeActionHandlers)({
112
+ ...dragPreviewHandlers,
113
113
  onReorder,
114
114
  projected,
115
115
  flattenedItems,
116
- dropIndicatorPosition
117
- }));
118
- const announcements = useTreeAnnouncements.useTreeAnnouncements(visibleItemsDictionary, dropIndicatorPosition);
119
- const dndContextProps = react.useMemo(() => _objectSpread({
116
+ dropIndicatorPosition,
117
+ isDropValid
118
+ });
119
+ const announcements = (0, import_useTreeAnnouncements.useTreeAnnouncements)(visibleItemsDictionary, dropIndicatorPosition);
120
+ const dndContextProps = (0, import_react.useMemo)(() => ({
120
121
  announcements,
121
122
  modifiers,
122
123
  sensors,
123
124
  measuring,
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(() => ({
125
+ collisionDetection: (0, import_customCollisionDetection.customCollisionDetection)(activeId, visibleItemsDictionary, setDropIndicatorPosition, maxDragAndDropLevel, lastPosition, setLastPosition),
126
+ ...dragActionHandlers
127
+ }), [
128
+ announcements,
129
+ modifiers,
130
+ sensors,
131
+ dragActionHandlers,
132
+ visibleItemsDictionary,
133
+ setDropIndicatorPosition,
134
+ activeId,
135
+ maxDragAndDropLevel,
136
+ lastPosition,
137
+ setLastPosition
138
+ ]);
139
+ const sortableContextProps = (0, import_react.useMemo)(() => ({
127
140
  items: sortedIds,
128
- strategy: isHorizontalDnD ? sortable.horizontalListSortingStrategy : sortable.verticalListSortingStrategy
129
- }), [sortedIds, isHorizontalDnD]);
141
+ strategy: () => null
142
+ }), [sortedIds]);
130
143
  return {
131
144
  dndContextProps,
132
145
  sortableContextProps,
146
+ isDropValid,
133
147
  activeId,
134
- activeIndex: (_visibleItemsDictiona = (_visibleItemsDictiona2 = visibleItemsDictionary[activeId]) === null || _visibleItemsDictiona2 === void 0 ? void 0 : _visibleItemsDictiona2.realIndex) !== null && _visibleItemsDictiona !== void 0 ? _visibleItemsDictiona : -1,
148
+ activeIndex: visibleItemsDictionary[activeId]?.realIndex ?? -1,
135
149
  overId,
136
150
  depth: projected ? projected.depth : 0,
137
151
  dropIndicatorPosition,
138
152
  visibleItems
139
153
  };
140
154
  };
141
-
142
- exports.useTreeDndkitConfig = useTreeDndkitConfig;
155
+ module.exports = __toCommonJS(useTreeDndkitConfig_exports);
156
+ //# sourceMappingURL=useTreeDndkitConfig.js.map
@@ -0,0 +1,7 @@
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 { useTreePreviewHandlers } from './useTreePreviewHandlers';\nimport { getTreeKeyboardCoordinates } from './getTreeKeyboardCoordinates';\nimport { getProjection, removeChildrenOf } from './utilities';\nimport { useTreeActionHandlers } from './useTreeActionHandlers';\nimport type { UseTreeDndkitConfigType, SensorContext } 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 = (isHorizontalDnD: boolean): Modifier => {\n const func: Modifier = ({ 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 return func;\n};\n\nconst measuring: Partial<MeasuringConfiguration> = {\n droppable: {\n strategy: MeasuringStrategy.Always,\n },\n};\n\nexport const useTreeDndkitConfig: UseTreeDndkitConfigType = ({\n flattenedItems,\n visibleItems: preVisibleItems,\n isHorizontalDnD = false,\n isExpandable = false,\n onReorder,\n getIsDropValid = () => true,\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, typeof visibleItems[0]> = {};\n visibleItems.forEach((item) => {\n dictionary[item.uid] = item;\n });\n return dictionary;\n }, [visibleItems]);\n\n const isDropValid = useMemo(() => {\n if (!activeId || !overId) return true;\n return getIsDropValid(\n visibleItemsDictionary[activeId],\n visibleItemsDictionary[overId],\n ['none', 'before', 'after', 'inside'][dropIndicatorPosition] as Parameters<typeof getIsDropValid>[2],\n );\n }, [getIsDropValid, visibleItemsDictionary, activeId, overId, dropIndicatorPosition]);\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 isDropValid,\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: () => null,\n }),\n [sortedIds],\n );\n\n return {\n dndContextProps,\n sortableContextProps,\n isDropValid,\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,oCAAuC;AACvC,wCAA2C;AAC3C,uBAAgD;AAChD,mCAAsC;AAEtC,uBAAsC;AACtC,sCAAyC;AACzC,kCAAqC;AAIrC,MAAM,kBAAkB,CAAC,oBAAuC;AAC9D,QAAM,OAAiB,CAAC,EAAE,gBAAgB;AACxC,UAAM,eAAe;AAAA,SAChB;AAAA;AAEL,QAAI,iBAAiB;AACnB,mBAAa,IAAI,UAAU,IAAI;AAAA,WAC1B;AACL,mBAAa,IAAI,UAAU,IAAI;AAAA;AAEjC,WAAO;AAAA;AAET,SAAO;AAAA;AAGT,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,iBAAiB,MAAM;AAAA,EACvB;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,0BA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