@elliemae/ds-drag-and-drop 3.34.0-rc.0 → 3.34.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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/tree/useTreeActionHandlers.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["/* eslint-disable complexity */\n/* eslint-disable max-statements */\nimport { 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.js';\nimport type { DnDKitTree } from './types.js';\n\nexport const useTreeActionHandlers = <T,>({\n handlePreviewDragStart,\n handlePreviewDragMove,\n handlePreviewDragOver,\n handlePreviewDragEnd,\n handlePreviewDragCancel,\n onReorder,\n flattenedItems,\n projected,\n dropIndicatorPosition,\n isDropValid,\n flattenedItemsDictionary,\n containersRef,\n}: DnDKitTree.UseTreeActionHandlersArgs<T>): DnDKitTree.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 if (over.id === active.id) return;\n\n const isOverContainerOfContainer = containersRef.current.includes(over.id);\n const overContainer = isOverContainerOfContainer\n ? over.id\n : flattenedItemsDictionary[over.id]?.container || 'root';\n const activeContainer = flattenedItemsDictionary[active.id].container || 'root';\n\n const activeIndex = flattenedItems[activeContainer].findIndex((item) => item.uid === active.id);\n\n let considerExpanding = null;\n\n let overIndex = flattenedItems[overContainer].findIndex((item) => item.uid === over.id);\n const isUp = overIndex < activeIndex;\n\n if (dropIndicatorPosition === 'after' && (isUp || activeContainer !== overContainer)) overIndex += 1;\n // If drop indicator is inside, then put it last,\n // It will be reconstructed well later\n if (dropIndicatorPosition === DropIndicatorPosition.Inside && !isOverContainerOfContainer) {\n considerExpanding = over.id;\n overIndex =\n flattenedItems[overContainer][overIndex].realIndex +\n flattenedItems[overContainer][overIndex].childrenCount +\n 1;\n }\n\n // If we are dropping the item in a new position, or new depth or new container\n if (\n projected &&\n (activeIndex !== overIndex ||\n flattenedItems[activeContainer][activeIndex].depth !== projected.depth ||\n activeContainer !== overContainer)\n ) {\n // Change parent and depth from projected data\n flattenedItems[activeContainer][activeIndex].parentId = projected.parentId;\n flattenedItems[activeContainer][activeIndex].depth = projected.depth;\n\n // If same index, don't move the array, just copy it\n\n const newFlattenedData = cloneDeep(flattenedItems);\n\n if (isOverContainerOfContainer) {\n if (newFlattenedData[overContainer].length === 0) {\n newFlattenedData[overContainer][0] = { ...flattenedItems[activeContainer][activeIndex] };\n } else {\n newFlattenedData[overContainer].push({ ...flattenedItems[activeContainer][activeIndex] });\n }\n newFlattenedData[activeContainer].splice(activeIndex, 1);\n } else if (activeContainer !== overContainer) {\n newFlattenedData[overContainer].splice(overIndex, 0, newFlattenedData[activeContainer][activeIndex]);\n newFlattenedData[activeContainer].splice(activeIndex, 1);\n } else {\n newFlattenedData[activeContainer] = arrayMove(flattenedItems[activeContainer], activeIndex, overIndex);\n }\n\n onReorder(flattenedItems[activeContainer][activeIndex], overIndex, {\n over: flattenedItems[activeContainer][overIndex],\n fromIndex: activeIndex,\n considerExpanding: considerExpanding,\n movedData: newFlattenedData,\n flattenedItems,\n overContainer,\n projectedMove: projected,\n });\n }\n },\n [\n handlePreviewDragEnd,\n isDropValid,\n containersRef,\n flattenedItemsDictionary,\n flattenedItems,\n dropIndicatorPosition,\n projected,\n onReorder,\n ],\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;AAAA;ACAA,YAAuB;ADEvB,sBAA0B;AAC1B,oBAA0B;AAC1B,mBAA4B;AAE5B,uBAAsC;AAG/B,MAAM,wBAAwB,CAAK;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAuF;AACrF,QAAM,kBAAc;AAAA,IAClB,CAAC,MAAsB;AACrB,6BAAuB,CAAC;AAAA,IAC1B;AAAA,IACA,CAAC,sBAAsB;AAAA,EACzB;AAEA,QAAM,iBAAa;AAAA,IACjB,CAAC,MAAqB;AACpB,4BAAsB,CAAC;AAAA,IACzB;AAAA,IACA,CAAC,qBAAqB;AAAA,EACxB;AAEA,QAAM,iBAAa;AAAA,IACjB,CAAC,MAAqB;AACpB,4BAAsB,CAAC;AAAA,IACzB;AAAA,IACA,CAAC,qBAAqB;AAAA,EACxB;AAEA,QAAM,gBAAY;AAAA,IAChB,CAAC,MAAoB;AACnB,2BAAqB,CAAC;AACtB,YAAM,EAAE,QAAQ,KAAK,IAAI;AAEzB,UAAI,SAAS,QAAQ,CAAC;AAAa;AACnC,UAAI,KAAK,OAAO,OAAO;AAAI;AAE3B,YAAM,6BAA6B,cAAc,QAAQ,SAAS,KAAK,EAAE;AACzE,YAAM,gBAAgB,6BAClB,KAAK,KACL,yBAAyB,KAAK,EAAE,GAAG,aAAa;AACpD,YAAM,kBAAkB,yBAAyB,OAAO,EAAE,EAAE,aAAa;AAEzE,YAA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AW,GAAG,WAAW;AAAA,UACjE,MAAM,eAAe,eAAe,EAAE,SAAS;AAAA,UAC/C,WAAW;AAAA,UACX;AAAA,UACA,WAAW;AAAA,UACX;AAAA,UACA;AAAA,UACA,eAAe;AAAA,QACjB,CAAC;AAAA,MACH;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,QAAM,mBAAe;AAAA,IACnB,CAAC,MAAuB;AACtB,8BAAwB,CAAC;AAAA,IAC3B;AAAA,IACA,CAAC,uBAAuB;AAAA,EAC1B;AAEA,SAAO,EAAE,aAAa,YAAY,YAAY,WAAW,aAAa;AACxE;",
4
+ "sourcesContent": ["/* eslint-disable complexity */\n/* eslint-disable max-statements */\nimport { 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.js';\nimport type { DnDKitTree } from './types.js';\n\nexport const useTreeActionHandlers = <T,>({\n handlePreviewDragStart,\n handlePreviewDragMove,\n handlePreviewDragOver,\n handlePreviewDragEnd,\n handlePreviewDragCancel,\n onReorder,\n flattenedItems,\n projected,\n dropIndicatorPosition,\n isDropValid,\n flattenedItemsDictionary,\n containersRef,\n}: DnDKitTree.UseTreeActionHandlersArgs<T>): DnDKitTree.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 if (over.id === active.id) return;\n\n const isOverContainerOfContainer = containersRef.current.includes(over.id);\n const overContainer = isOverContainerOfContainer\n ? over.id\n : flattenedItemsDictionary[over.id]?.container || 'root';\n const activeContainer = flattenedItemsDictionary[active.id].container || 'root';\n\n const activeIndex = flattenedItems[activeContainer].findIndex((item) => item.uid === active.id);\n\n let considerExpanding = null;\n\n let overIndex = flattenedItems[overContainer].findIndex((item) => item.uid === over.id);\n const isUp = overIndex < activeIndex;\n\n if (dropIndicatorPosition === 'after' && (isUp || activeContainer !== overContainer)) overIndex += 1;\n // If drop indicator is inside, then put it last,\n // It will be reconstructed well later\n if (dropIndicatorPosition === DropIndicatorPosition.Inside && !isOverContainerOfContainer) {\n considerExpanding = over.id;\n overIndex =\n flattenedItems[overContainer][overIndex].realIndex +\n flattenedItems[overContainer][overIndex].childrenCount +\n 1;\n }\n\n // If we are dropping the item in a new position, or new depth or new container\n if (\n projected &&\n (activeIndex !== overIndex ||\n flattenedItems[activeContainer][activeIndex].depth !== projected.depth ||\n activeContainer !== overContainer)\n ) {\n // Change parent and depth from projected data\n flattenedItems[activeContainer][activeIndex].parentId = projected.parentId;\n flattenedItems[activeContainer][activeIndex].depth = projected.depth;\n\n // If same index, don't move the array, just copy it\n\n // not deep cloning here would break data-table\n const newFlattenedData = cloneDeep(flattenedItems);\n\n if (isOverContainerOfContainer) {\n if (newFlattenedData[overContainer].length === 0) {\n newFlattenedData[overContainer][0] = { ...flattenedItems[activeContainer][activeIndex] };\n } else {\n newFlattenedData[overContainer].push({ ...flattenedItems[activeContainer][activeIndex] });\n }\n newFlattenedData[activeContainer].splice(activeIndex, 1);\n } else if (activeContainer !== overContainer) {\n newFlattenedData[overContainer].splice(overIndex, 0, newFlattenedData[activeContainer][activeIndex]);\n newFlattenedData[activeContainer].splice(activeIndex, 1);\n } else {\n newFlattenedData[activeContainer] = arrayMove(flattenedItems[activeContainer], activeIndex, overIndex);\n }\n\n onReorder(flattenedItems[activeContainer][activeIndex], overIndex, {\n over: flattenedItems[activeContainer][overIndex],\n fromIndex: activeIndex,\n considerExpanding: considerExpanding,\n movedData: newFlattenedData,\n flattenedItems,\n overContainer,\n projectedMove: projected,\n });\n }\n },\n [\n handlePreviewDragEnd,\n isDropValid,\n containersRef,\n flattenedItemsDictionary,\n flattenedItems,\n dropIndicatorPosition,\n projected,\n onReorder,\n ],\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;AAAA;ACAA,YAAuB;ADEvB,sBAA0B;AAC1B,oBAA0B;AAC1B,mBAA4B;AAE5B,uBAAsC;AAG/B,MAAM,wBAAwB,CAAK;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAuF;AACrF,QAAM,kBAAc;AAAA,IAClB,CAAC,MAAsB;AACrB,6BAAuB,CAAC;AAAA,IAC1B;AAAA,IACA,CAAC,sBAAsB;AAAA,EACzB;AAEA,QAAM,iBAAa;AAAA,IACjB,CAAC,MAAqB;AACpB,4BAAsB,CAAC;AAAA,IACzB;AAAA,IACA,CAAC,qBAAqB;AAAA,EACxB;AAEA,QAAM,iBAAa;AAAA,IACjB,CAAC,MAAqB;AACpB,4BAAsB,CAAC;AAAA,IACzB;AAAA,IACA,CAAC,qBAAqB;AAAA,EACxB;AAEA,QAAM,gBAAY;AAAA,IAChB,CAAC,MAAoB;AACnB,2BAAqB,CAAC;AACtB,YAAM,EAAE,QAAQ,KAAK,IAAI;AAEzB,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eAAe;AAC5C,2BAAiB,aAAa,EAAE,OAAO,WAAW,GAAG,iBAAiB,eAAe,EAAE,WAAW,CAAC;AACnG,2BAAiB,eAAe,EAAE,OAAO,aAAa,CAAC;AAAA,QACzD,OAAO;AACL,2BAAiB,eAAe,QAAI,2BAAU,eAAe,eAAe,GAAG,aAAa,SAAS;AAAA,QACvG;AAEA,kBAAU,eAAe,eAAe,EAAE,WAAW,GAAG,WAAW;AAAA,UACjE,MAAM,eAAe,eAAe,EAAE,SAAS;AAAA,UAC/C,WAAW;AAAA,UACX;AAAA,UACA,WAAW;AAAA,UACX;AAAA,UACA;AAAA,UACA,eAAe;AAAA,QACjB,CAAC;AAAA,MACH;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,QAAM,mBAAe;AAAA,IACnB,CAAC,MAAuB;AACtB,8BAAwB,CAAC;AAAA,IAC3B;AAAA,IACA,CAAC,uBAAuB;AAAA,EAC1B;AAEA,SAAO,EAAE,aAAa,YAAY,YAAY,WAAW,aAAa;AACxE;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/tree/useTreeActionHandlers.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\n/* eslint-disable max-statements */\nimport { 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.js';\nimport type { DnDKitTree } from './types.js';\n\nexport const useTreeActionHandlers = <T,>({\n handlePreviewDragStart,\n handlePreviewDragMove,\n handlePreviewDragOver,\n handlePreviewDragEnd,\n handlePreviewDragCancel,\n onReorder,\n flattenedItems,\n projected,\n dropIndicatorPosition,\n isDropValid,\n flattenedItemsDictionary,\n containersRef,\n}: DnDKitTree.UseTreeActionHandlersArgs<T>): DnDKitTree.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 if (over.id === active.id) return;\n\n const isOverContainerOfContainer = containersRef.current.includes(over.id);\n const overContainer = isOverContainerOfContainer\n ? over.id\n : flattenedItemsDictionary[over.id]?.container || 'root';\n const activeContainer = flattenedItemsDictionary[active.id].container || 'root';\n\n const activeIndex = flattenedItems[activeContainer].findIndex((item) => item.uid === active.id);\n\n let considerExpanding = null;\n\n let overIndex = flattenedItems[overContainer].findIndex((item) => item.uid === over.id);\n const isUp = overIndex < activeIndex;\n\n if (dropIndicatorPosition === 'after' && (isUp || activeContainer !== overContainer)) overIndex += 1;\n // If drop indicator is inside, then put it last,\n // It will be reconstructed well later\n if (dropIndicatorPosition === DropIndicatorPosition.Inside && !isOverContainerOfContainer) {\n considerExpanding = over.id;\n overIndex =\n flattenedItems[overContainer][overIndex].realIndex +\n flattenedItems[overContainer][overIndex].childrenCount +\n 1;\n }\n\n // If we are dropping the item in a new position, or new depth or new container\n if (\n projected &&\n (activeIndex !== overIndex ||\n flattenedItems[activeContainer][activeIndex].depth !== projected.depth ||\n activeContainer !== overContainer)\n ) {\n // Change parent and depth from projected data\n flattenedItems[activeContainer][activeIndex].parentId = projected.parentId;\n flattenedItems[activeContainer][activeIndex].depth = projected.depth;\n\n // If same index, don't move the array, just copy it\n\n const newFlattenedData = cloneDeep(flattenedItems);\n\n if (isOverContainerOfContainer) {\n if (newFlattenedData[overContainer].length === 0) {\n newFlattenedData[overContainer][0] = { ...flattenedItems[activeContainer][activeIndex] };\n } else {\n newFlattenedData[overContainer].push({ ...flattenedItems[activeContainer][activeIndex] });\n }\n newFlattenedData[activeContainer].splice(activeIndex, 1);\n } else if (activeContainer !== overContainer) {\n newFlattenedData[overContainer].splice(overIndex, 0, newFlattenedData[activeContainer][activeIndex]);\n newFlattenedData[activeContainer].splice(activeIndex, 1);\n } else {\n newFlattenedData[activeContainer] = arrayMove(flattenedItems[activeContainer], activeIndex, overIndex);\n }\n\n onReorder(flattenedItems[activeContainer][activeIndex], overIndex, {\n over: flattenedItems[activeContainer][overIndex],\n fromIndex: activeIndex,\n considerExpanding: considerExpanding,\n movedData: newFlattenedData,\n flattenedItems,\n overContainer,\n projectedMove: projected,\n });\n }\n },\n [\n handlePreviewDragEnd,\n isDropValid,\n containersRef,\n flattenedItemsDictionary,\n flattenedItems,\n dropIndicatorPosition,\n projected,\n onReorder,\n ],\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"],
5
- "mappings": "AAAA,YAAY,WAAW;ACEvB,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAE5B,SAAS,6BAA6B;AAG/B,MAAM,wBAAwB,CAAK;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAuF;AACrF,QAAM,cAAc;AAAA,IAClB,CAAC,MAAsB;AACrB,6BAAuB,CAAC;AAAA,IAC1B;AAAA,IACA,CAAC,sBAAsB;AAAA,EACzB;AAEA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AAEjD,YAAI,4BAA4B;AAC9B,cAAI,iBAAiB,aAAa,EAAE,WAAW,GAAG;AAChD,6BAAiB,aAAa,EAAE,CAAC,IAAI,EAAE,GAAG,eAAe,eAAe,EAAE,WAAW,EAAE;AAAA,UACzF,OAAO;AACL,6BAAiB,aAAa,EAAE,KAAK,EAAE,GAAG,eAAe,eAAe,EAAE,WAAW,EAAE,CAAC;AAAA,UAC1F;AACA,2BAAiB,eAAe,EAAE,OAAO,aAAa,CAAC;AAAA,QACzD,WAAW,oBAAoB,eAAe;AAC5C,2BAAiB,aAAa,EAAE,OAAO,WAAW,GAAG,iBAAiB,eAAe,EAAE,WAAW,CAAC;AACnG,2BAAiB,eAAe,EAAE,OAAO,aAAa,CAAC;AAAA,QACzD,OAAO;AACL,2BAAiB,eAAe,IAAI,UAAU,eAAe,eAAe,GAAG,aAAa,SAAS;AAAA,QACvG;AAEA,kBAAU,eAAe,eAAe,EAAE,WAAW,GAAG,WAAW;AAAA,UACjE,MAAM,eAAe,eAAe,EAAE,SAAS;AAAA,UAC/C,WAAW;AAAA,UACX;AAAA,UACA,WAAW;AAAA,UACX;AAAA,UACA;AAAA,UACA,eAAe;AAAA,QACjB,CAAC;AAAA,MACH;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,QAAM,eAAe;AAAA,IACnB,CAAC,MAAuB;AACtB,8BAAwB,CAAC;AAAA,IAC3B;AAAA,IACA,CAAC,uBAAuB;AAAA,EAC1B;AAEA,SAAO,EAAE,aAAa,YAAY,YAAY,WAAW,aAAa;AACxE;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\n/* eslint-disable max-statements */\nimport { 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.js';\nimport type { DnDKitTree } from './types.js';\n\nexport const useTreeActionHandlers = <T,>({\n handlePreviewDragStart,\n handlePreviewDragMove,\n handlePreviewDragOver,\n handlePreviewDragEnd,\n handlePreviewDragCancel,\n onReorder,\n flattenedItems,\n projected,\n dropIndicatorPosition,\n isDropValid,\n flattenedItemsDictionary,\n containersRef,\n}: DnDKitTree.UseTreeActionHandlersArgs<T>): DnDKitTree.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 if (over.id === active.id) return;\n\n const isOverContainerOfContainer = containersRef.current.includes(over.id);\n const overContainer = isOverContainerOfContainer\n ? over.id\n : flattenedItemsDictionary[over.id]?.container || 'root';\n const activeContainer = flattenedItemsDictionary[active.id].container || 'root';\n\n const activeIndex = flattenedItems[activeContainer].findIndex((item) => item.uid === active.id);\n\n let considerExpanding = null;\n\n let overIndex = flattenedItems[overContainer].findIndex((item) => item.uid === over.id);\n const isUp = overIndex < activeIndex;\n\n if (dropIndicatorPosition === 'after' && (isUp || activeContainer !== overContainer)) overIndex += 1;\n // If drop indicator is inside, then put it last,\n // It will be reconstructed well later\n if (dropIndicatorPosition === DropIndicatorPosition.Inside && !isOverContainerOfContainer) {\n considerExpanding = over.id;\n overIndex =\n flattenedItems[overContainer][overIndex].realIndex +\n flattenedItems[overContainer][overIndex].childrenCount +\n 1;\n }\n\n // If we are dropping the item in a new position, or new depth or new container\n if (\n projected &&\n (activeIndex !== overIndex ||\n flattenedItems[activeContainer][activeIndex].depth !== projected.depth ||\n activeContainer !== overContainer)\n ) {\n // Change parent and depth from projected data\n flattenedItems[activeContainer][activeIndex].parentId = projected.parentId;\n flattenedItems[activeContainer][activeIndex].depth = projected.depth;\n\n // If same index, don't move the array, just copy it\n\n // not deep cloning here would break data-table\n const newFlattenedData = cloneDeep(flattenedItems);\n\n if (isOverContainerOfContainer) {\n if (newFlattenedData[overContainer].length === 0) {\n newFlattenedData[overContainer][0] = { ...flattenedItems[activeContainer][activeIndex] };\n } else {\n newFlattenedData[overContainer].push({ ...flattenedItems[activeContainer][activeIndex] });\n }\n newFlattenedData[activeContainer].splice(activeIndex, 1);\n } else if (activeContainer !== overContainer) {\n newFlattenedData[overContainer].splice(overIndex, 0, newFlattenedData[activeContainer][activeIndex]);\n newFlattenedData[activeContainer].splice(activeIndex, 1);\n } else {\n newFlattenedData[activeContainer] = arrayMove(flattenedItems[activeContainer], activeIndex, overIndex);\n }\n\n onReorder(flattenedItems[activeContainer][activeIndex], overIndex, {\n over: flattenedItems[activeContainer][overIndex],\n fromIndex: activeIndex,\n considerExpanding: considerExpanding,\n movedData: newFlattenedData,\n flattenedItems,\n overContainer,\n projectedMove: projected,\n });\n }\n },\n [\n handlePreviewDragEnd,\n isDropValid,\n containersRef,\n flattenedItemsDictionary,\n flattenedItems,\n dropIndicatorPosition,\n projected,\n onReorder,\n ],\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"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACEvB,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAE5B,SAAS,6BAA6B;AAG/B,MAAM,wBAAwB,CAAK;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,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Aa,YAAY,YAAY,WAAW,aAAa;AACxE;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-drag-and-drop",
3
- "version": "3.34.0-rc.0",
3
+ "version": "3.34.0",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Drag And Drop",
6
6
  "files": [
@@ -111,15 +111,15 @@
111
111
  "@dnd-kit/core": "~6.0.8",
112
112
  "@dnd-kit/modifiers": "~6.0.1",
113
113
  "@dnd-kit/sortable": "~7.0.2",
114
- "@elliemae/ds-fast-list": "3.34.0-rc.0",
115
- "@elliemae/ds-system": "3.34.0-rc.0",
116
- "@elliemae/ds-tree-model": "3.34.0-rc.0",
117
- "@elliemae/ds-typescript-helpers": "3.34.0-rc.0"
114
+ "@elliemae/ds-fast-list": "3.34.0",
115
+ "@elliemae/ds-system": "3.34.0",
116
+ "@elliemae/ds-tree-model": "3.34.0",
117
+ "@elliemae/ds-typescript-helpers": "3.34.0"
118
118
  },
119
119
  "devDependencies": {
120
120
  "@elliemae/pui-cli": "~9.0.0-next.31",
121
121
  "styled-components": "~5.3.9",
122
- "@elliemae/ds-monorepo-devops": "3.34.0-rc.0"
122
+ "@elliemae/ds-monorepo-devops": "3.34.0"
123
123
  },
124
124
  "peerDependencies": {
125
125
  "lodash": "^4.17.21",