@elliemae/ds-drag-and-drop 3.0.0-alpha.3 → 3.0.0-next.11

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/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"],
4
+ "sourcesContent": ["export enum DropIndicatorPosition {\n None = 0,\n Before = 1,\n After = 2,\n Inside = 3,\n}\n", "import * as React from 'react';\nexport { React };\n"],
5
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
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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<T = unknown> = {\n uid: string;\n depth: number;\n parentId: string | null;\n realIndex: number;\n childrenCount: number;\n original: T;\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<T = unknown> = UseTreePreviewHandlersReturn & {\n dropIndicatorPosition: DropIndicatorPosition;\n flattenedItems: Item[];\n projected: {\n depth: number;\n parentId: string;\n } | null;\n onReorder: <S = T>(\n newData: Item<S>[],\n indexes: { targetIndex: number; fromIndex: number },\n considerExpanding: string,\n ) => void;\n isDropValid: boolean;\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<T> = {\n flattenedItems: Item[];\n visibleItems: Item[];\n isHorizontalDnD?: boolean;\n isExpandable: boolean;\n onReorder: <S = T>(\n newData: Item<S>[],\n indexes: { targetIndex: number; fromIndex: number },\n considerExpanding: string,\n ) => void;\n getIsDropValid: <S = T>(\n active: Item<S>,\n over: Item<S>,\n dropIndicatorPosition: 'none' | 'before' | 'after' | 'inside',\n ) => boolean;\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 isDropValid: boolean;\n visibleItems: Item[];\n};\n\nexport type UseTreeDndkitConfigType = <T = unknown>(args: UseTreeDndkitConfigArgs<T>) => 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"],
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<T = unknown> = {\n uid: string;\n depth: number;\n parentId: string | null;\n realIndex: number;\n childrenCount: number;\n original: T;\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\ntype UseTreeActionHandlersArgs<T = unknown> = UseTreePreviewHandlersReturn & {\n dropIndicatorPosition: DropIndicatorPosition;\n flattenedItems: Item<T>[];\n projected: {\n depth: number;\n parentId: string | null;\n } | null;\n onReorder: (\n newData: Item<T>[],\n indexes: { targetIndex: number; fromIndex: number },\n considerExpanding: string,\n ) => void;\n isDropValid: boolean;\n};\n\ntype 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 UseTreeActionHandlersType = <T = unknown>(\n args: UseTreeActionHandlersArgs<T>,\n) => UseTreeActionHandlersReturn;\n\nexport type UseTreeDndkitConfigArgs<T> = {\n flattenedItems: Item<T>[];\n visibleItems: Item<T>[];\n isHorizontalDnD?: boolean;\n isExpandable: boolean;\n onReorder: (\n newData: Item<T>[],\n indexes: { targetIndex: number; fromIndex: number },\n considerExpanding: string,\n ) => void;\n getIsDropValid: (\n active: Item<T>,\n over: Item<T>,\n dropIndicatorPosition: 'none' | 'before' | 'after' | 'inside',\n ) => boolean;\n maxDragAndDropLevel: number;\n};\n\nexport type UseTreeDndkitConfigReturn<T> = {\n dndContextProps: DndContextPropsType;\n sortableContextProps: SortableContextPropsType;\n activeId: string;\n activeIndex: number;\n overId: string;\n depth: number;\n dropIndicatorPosition: DropIndicatorPosition;\n isDropValid: boolean;\n visibleItems: Item<T>[];\n};\n\nexport type UseTreeDndkitConfigType = <T = unknown>(args: UseTreeDndkitConfigArgs<T>) => UseTreeDndkitConfigReturn<T>;\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
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA,YAAuB;",
6
6
  "names": []
7
7
  }
@@ -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": ["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,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,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,QAAQ,CAAC;AAAa;AAEnC,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,YAAY,eAAe,WAAW,gBAAgB;AAAA;AAI9F,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,aAAa,gBAAgB,uBAAuB,WAAW;AAGxF,QAAM,eAAe,8BACnB,CAAC,MAAuB;AACtB,4BAAwB;AAAA,KAE1B,CAAC;AAGH,SAAO,EAAE,aAAa,YAAY,YAAY,WAAW;AAAA;",
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 { UseTreeActionHandlersType } from './types';\n\nexport const useTreeActionHandlers: UseTreeActionHandlersType = ({\n handlePreviewDragStart,\n handlePreviewDragMove,\n handlePreviewDragOver,\n handlePreviewDragEnd,\n handlePreviewDragCancel,\n onReorder,\n flattenedItems,\n projected,\n dropIndicatorPosition,\n isDropValid,\n}) => {\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,mBAA4B;AAE5B,uBAAsC;AAG/B,MAAM,wBAAmD,CAAC;AAAA,EAC/D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,MACI;AACJ,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,QAAQ,CAAC;AAAa;AAEnC,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,YAAY,eAAe,WAAW,gBAAgB;AAAA;AAI9F,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,aAAa,gBAAgB,uBAAuB,WAAW;AAGxF,QAAM,eAAe,8BACnB,CAAC,MAAuB;AACtB,4BAAwB;AAAA,KAE1B,CAAC;AAGH,SAAO,EAAE,aAAa,YAAY,YAAY,WAAW;AAAA;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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;",
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 | null } => {\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 = <T,>(items: Item<T>[], id: string): Item<T>[] => {\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,iBAC+C;AAC/C,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,CAAK,OAAkB,OAA0B;AAC/E,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
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/constants.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export enum DropIndicatorPosition {\n None = 0,\n Before = 1,\n After = 2,\n Inside = 3,\n}"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export enum DropIndicatorPosition {\n None = 0,\n Before = 1,\n After = 2,\n Inside = 3,\n}\n"],
5
5
  "mappings": "AAAA;ACAO,IAAK,wBAAL,kBAAK,2BAAL;AACL,0DAAO,KAAP;AACA,4DAAS,KAAT;AACA,2DAAQ,KAAR;AACA,4DAAS,KAAT;AAJU;AAAA;",
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", "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"],
5
- "mappings": "AAAA;ACAA;AACA;AACA;AAEA;AAGO,MAAM,wBAAwB,CAAC;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,MAC4D;AAC5D,QAAM,cAAc,YAClB,CAAC,MAAsB;AACrB,2BAAuB;AAAA,KAEzB,CAAC;AAGH,QAAM,aAAa,YACjB,CAAC,MAAqB;AACpB,0BAAsB;AAAA,KAExB,CAAC;AAGH,QAAM,aAAa,YACjB,CAAC,MAAqB;AACpB,0BAAsB;AAAA,KAExB,CAAC;AAGH,QAAM,YAAY,YAChB,CAAC,MAAoB;AACnB,yBAAqB;AACrB,UAAM,EAAE,QAAQ,SAAS;AAEzB,QAAI,SAAS,QAAQ,CAAC;AAAa;AAEnC,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,sBAAsB,QAAQ;AAC1D,0BAAoB,KAAK;AACzB,kBAAY,eAAe,WAAW,YAAY,eAAe,WAAW,gBAAgB;AAAA;AAI9F,QAAI,aAAc,iBAAgB,aAAa,eAAe,aAAa,UAAU,UAAU,QAAQ;AAErG,qBAAe,aAAa,WAAW,UAAU;AACjD,qBAAe,aAAa,QAAQ,UAAU;AAG9C,YAAM,mBACJ,gBAAgB,YAAY,UAAU,gBAAgB,aAAa,aAAa,UAAU;AAE5F,gBACE,kBACA;AAAA,QACE,aAAa;AAAA,QACb,WAAW;AAAA,SAEb,qBAAqB;AAAA;AAAA,KAI3B,CAAC,sBAAsB,aAAa,gBAAgB,uBAAuB,WAAW;AAGxF,QAAM,eAAe,YACnB,CAAC,MAAuB;AACtB,4BAAwB;AAAA,KAE1B,CAAC;AAGH,SAAO,EAAE,aAAa,YAAY,YAAY,WAAW;AAAA;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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 { UseTreeActionHandlersType } from './types';\n\nexport const useTreeActionHandlers: UseTreeActionHandlersType = ({\n handlePreviewDragStart,\n handlePreviewDragMove,\n handlePreviewDragOver,\n handlePreviewDragEnd,\n handlePreviewDragCancel,\n onReorder,\n flattenedItems,\n projected,\n dropIndicatorPosition,\n isDropValid,\n}) => {\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"],
5
+ "mappings": "AAAA;ACAA;AACA;AACA;AAEA;AAGO,MAAM,wBAAmD,CAAC;AAAA,EAC/D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,MACI;AACJ,QAAM,cAAc,YAClB,CAAC,MAAsB;AACrB,2BAAuB;AAAA,KAEzB,CAAC;AAGH,QAAM,aAAa,YACjB,CAAC,MAAqB;AACpB,0BAAsB;AAAA,KAExB,CAAC;AAGH,QAAM,aAAa,YACjB,CAAC,MAAqB;AACpB,0BAAsB;AAAA,KAExB,CAAC;AAGH,QAAM,YAAY,YAChB,CAAC,MAAoB;AACnB,yBAAqB;AACrB,UAAM,EAAE,QAAQ,SAAS;AAEzB,QAAI,SAAS,QAAQ,CAAC;AAAa;AAEnC,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,sBAAsB,QAAQ;AAC1D,0BAAoB,KAAK;AACzB,kBAAY,eAAe,WAAW,YAAY,eAAe,WAAW,gBAAgB;AAAA;AAI9F,QAAI,aAAc,iBAAgB,aAAa,eAAe,aAAa,UAAU,UAAU,QAAQ;AAErG,qBAAe,aAAa,WAAW,UAAU;AACjD,qBAAe,aAAa,QAAQ,UAAU;AAG9C,YAAM,mBACJ,gBAAgB,YAAY,UAAU,gBAAgB,aAAa,aAAa,UAAU;AAE5F,gBACE,kBACA;AAAA,QACE,aAAa;AAAA,QACb,WAAW;AAAA,SAEb,qBAAqB;AAAA;AAAA,KAI3B,CAAC,sBAAsB,aAAa,gBAAgB,uBAAuB,WAAW;AAGxF,QAAM,eAAe,YACnB,CAAC,MAAuB;AACtB,4BAAwB;AAAA,KAE1B,CAAC;AAGH,SAAO,EAAE,aAAa,YAAY,YAAY,WAAW;AAAA;",
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/utilities.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* 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"],
5
- "mappings": "AAAA;ACCA;AAIA,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,sBAAsB,UAAU,cAAc;AAC1E,WAAO;AAAA,MACL,OAAO,uBAAuB,QAAQ,QAAQ;AAAA,MAC9C,UAAU;AAAA;AAAA;AAGd,MAAI,0BAA0B,sBAAsB,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;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* 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 | null } => {\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 = <T,>(items: Item<T>[], id: string): Item<T>[] => {\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"],
5
+ "mappings": "AAAA;ACCA;AAIA,MAAM,cAAc,CAAC,SAAe;AAClC,MAAI;AAAM,WAAO,KAAK;AACtB,SAAO;AAAA;AAGF,MAAM,gBAAgB,CAC3B,OACA,wBACA,QACA,uBACA,iBAC+C;AAC/C,QAAM,gBAAgB,uBAAuB,QAAQ;AAErD,QAAM,eAAe,MAAM;AAC3B,QAAM,WAAW,MAAM,gBAAgB;AAEvC,MAAI,0BAA0B,sBAAsB,UAAU,cAAc;AAC1E,WAAO;AAAA,MACL,OAAO,uBAAuB,QAAQ,QAAQ;AAAA,MAC9C,UAAU;AAAA;AAAA;AAGd,MAAI,0BAA0B,sBAAsB,QAAQ;AAC1D,WAAO,EAAE,OAAO,YAAY,eAAe,UAAU,aAAa;AAAA;AAEpE,SAAO,EAAE,OAAO,YAAY,WAAW,UAAU,UAAU;AAAA;AAGtD,MAAM,mBAAmB,CAAK,OAAkB,OAA0B;AAC/E,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
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.0.0-alpha.3",
3
+ "version": "3.0.0-next.11",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Drag And Drop",
6
6
  "files": [