From 9ef1d2954ebbd86c853fcef8a65db6d8309f2a75 Mon Sep 17 00:00:00 2001 From: Sasha Milenkovic Date: Wed, 2 Oct 2024 13:36:24 -0400 Subject: [PATCH] wip of consolidating swap and drop into same plugin, working on callback function to either swap or place --- dist/index.cjs | 208 ++++++++++++-- dist/index.cjs.map | 2 +- dist/index.mjs | 208 ++++++++++++-- dist/index.mjs.map | 2 +- playwright.config.ts | 60 ++--- playwright/tests/drag/swap.spec.ts | 14 +- src/index.ts | 42 ++- src/plugins/drop-or-swap/index.ts | 420 +++++++++++++++++++++++++++++ src/types.ts | 31 ++- tests/pages/place/index.vue | 2 + tests/pages/swap/index.vue | 18 +- 11 files changed, 906 insertions(+), 101 deletions(-) create mode 100644 src/plugins/drop-or-swap/index.ts diff --git a/dist/index.cjs b/dist/index.cjs index f1b1302..6e31e10 100644 --- a/dist/index.cjs +++ b/dist/index.cjs @@ -47,7 +47,7 @@ __export(src_exports, { handleNodeKeydown: () => handleNodeKeydown, handleNodePointerdown: () => handleNodePointerdown, handleNodePointermove: () => handleNodePointermove, - handleNodePointerover: () => handleNodePointerover2, + handleNodePointerover: () => handleNodePointerover3, handleNodePointerup: () => handleNodePointerup, handleNodeTouchstart: () => handleNodeTouchstart, handleParentBlur: () => handleParentBlur, @@ -257,7 +257,6 @@ function insertion(insertionConfig = {}) { observer.observe(parent); parentData.config = insertionParentConfig; state.on("dragStarted", () => { - console.log("drag started"); defineRanges(parent); }); const insertionPointConfig = insertionConfig.insertionPoint || {}; @@ -857,6 +856,11 @@ function handleEnd3(state2) { state2.initialParent.data, newInitialValues ); + setParentValues( + state2.currentParent.el, + state2.currentParent.data, + newValues + ); } else if (state2.initialParent.el === state2.currentParent.el && placeState.draggedOverNodes.length) { setParentValues( state2.currentParent.el, @@ -868,12 +872,16 @@ function handleEnd3(state2) { placeState.draggedOverNodes.map((node) => node.el), isSynth ? state2.currentParent.data.config.synthDropZoneClass : state2.currentParent.data.config.dropZoneClass ); + placeState.draggedOverNodes = []; } // src/plugins/swap/index.ts -var swapState = { - draggedOverNodes: Array() +var placeState2 = { + draggedOverNodes: Array(), + initialDraggedIndex: 0, + transferred: false }; +var dragoverEventListeneerSet2 = false; function swap(swapConfig = {}) { return (parent) => { const parentData = parents.get(parent); @@ -882,44 +890,188 @@ function swap(swapConfig = {}) { ...parentData.config, swapConfig }; + if (!dragoverEventListeneerSet2) { + document.addEventListener("dragover", rootDragover2); + document.addEventListener( + "handleRootPointerover", + (e) => rootPointerover2(e) + ); + } return { setup() { - swapParentConfig.handleDragoverParent = swapConfig.handleDragoverParent || handleDragoverParent3; - swapParentConfig.handleDragoverNode = swapConfig.handleDragoverNode || handleDragoverNode3; - swapParentConfig.handlePointeroverNode = swapConfig.handlePointeroverNode || handlePointeroverNode; - swapParentConfig.handlePointeroverParent = swapConfig.handlePointeroverParent || handlePointeroverParent3; + swapParentConfig.handleNodeDragover = swapConfig.handleNodeDragover || handleDragoverNode3; + swapParentConfig.handleParentDragover = swapConfig.handleParentDragover || handleDragoverParent3; + swapParentConfig.handleNodePointerover = swapConfig.handleNodePointerover || handleNodePointerover2; + swapParentConfig.handleParentPointerover = swapConfig.handleParentPointerover || handeParentPointerover; + const originalHandleend = swapParentConfig.handleEnd; + swapParentConfig.handleEnd = (state2) => { + handleEnd4(state2); + originalHandleend(state2); + }; parentData.config = swapParentConfig; } }; }; } -function handleDragoverNode3(data) { - data.e.preventDefault(); -} -function handleDragoverParent3(_data) { +function rootDragover2(_e) { + if (!isDragState(state)) return; + removeClass( + [state.currentParent.el], + state.currentParent.data.config.dropZoneParentClass + ); + state.currentParent = state.initialParent; } -function handlePointeroverParent3(_data) { +function rootPointerover2(_e) { + if (!isSynthDragState(state)) return; + removeClass( + [state.currentParent.el], + state.currentParent.data.config.synthDropZoneParentClass + ); + state.currentParent = state.initialParent; } -function handlePointeroverNode(data) { - if (!isDragState(state)) return; - if (data.detail.targetData.parent.el !== state.currentParent.el) return; - const dropZoneClass = data.detail.targetData.parent.data.config.synthDropZoneClass; +function updateDraggedOverNodes2(data, state2) { + const targetData = "detail" in data ? data.detail.targetData : data.targetData; + const config = targetData.parent.data.config; + const dropZoneClass = isSynthDragState(state2) ? config.synthDropZoneClass : config.dropZoneClass; removeClass( - swapState.draggedOverNodes.map((node) => node.el), + placeState2.draggedOverNodes.map((node) => node.el), dropZoneClass ); - const enabledNodes = data.detail.targetData.parent.data.enabledNodes; - swapState.draggedOverNodes = enabledNodes.slice( - data.detail.targetData.node.data.index, - data.detail.targetData.node.data.index + state.draggedNodes.length + const enabledNodes = targetData.parent.data.enabledNodes; + if (!enabledNodes) return; + placeState2.draggedOverNodes = enabledNodes.slice( + targetData.node.data.index, + targetData.node.data.index + state2.draggedNodes.length ); addNodeClass( - swapState.draggedOverNodes.map((node) => node.el), + placeState2.draggedOverNodes.map((node) => node.el), dropZoneClass, true ); - state.currentTargetValue = data.detail.targetData.node.data.value; - state.currentParent = data.detail.targetData.parent; + state2.currentTargetValue = targetData.node.data.value; + state2.currentParent = targetData.parent; + addClass( + state2.currentParent.el, + isSynthDragState(state2) ? config.synthDropZoneParentClass : config.dropZoneParentClass, + state2.currentParent.data, + true + ); +} +function handleDragoverNode3(data, state2) { + data.e.preventDefault(); + data.e.stopPropagation(); + updateDraggedOverNodes2(data, state2); +} +function handleDragoverParent3(data, state2) { + data.e.preventDefault(); + data.e.stopPropagation(); + const currentConfig = state2.currentParent.data.config; + removeClass( + placeState2.draggedOverNodes.map((node) => node.el), + currentConfig.dropZoneClass + ); + removeClass([state2.currentParent.el], currentConfig.dropZoneParentClass); + const config = data.targetData.parent.data.config; + addClass( + data.targetData.parent.el, + config.dropZoneParentClass, + data.targetData.parent.data, + true + ); + placeState2.draggedOverNodes = []; + state2.currentParent = data.targetData.parent; +} +function handeParentPointerover(data) { + const currentConfig = data.detail.state.currentParent.data.config; + removeClass( + placeState2.draggedOverNodes.map((node) => node.el), + currentConfig.synthDropZoneClass + ); + removeClass( + [data.detail.state.currentParent.el], + currentConfig.synthDropZoneParentClass + ); + const config = data.detail.targetData.parent.data.config; + addClass( + data.detail.targetData.parent.el, + config.synthDropZoneParentClass, + data.detail.targetData.parent.data, + true + ); + placeState2.draggedOverNodes = []; + data.detail.state.currentParent = data.detail.targetData.parent; +} +function handleNodePointerover2(data) { + if (!isSynthDragState(data.detail.state)) return; + updateDraggedOverNodes2(data, data.detail.state); +} +function handleEnd4(state2) { + const isSynth = isSynthDragState(state2); + removeClass( + [state2.currentParent.el], + isSynth ? state2.currentParent.data.config.synthDropZoneParentClass : state2.currentParent.data.config.dropZoneParentClass + ); + const values = parentValues(state2.currentParent.el, state2.currentParent.data); + const draggedValues = state2.draggedNodes.map((node) => node.data.value); + const newValues = values.filter((x) => !draggedValues.includes(x)); + const targetIndex = placeState2.draggedOverNodes[0]?.data.index; + let newTargetParentValues = []; + if (state2.initialParent.el == state2.currentParent.el) { + if (targetIndex !== void 0) { + newValues.splice(targetIndex, 0, ...draggedValues); + setParentValues( + state2.currentParent.el, + state2.currentParent.data, + newValues + ); + } + } else if (state2.initialParent.el !== state2.currentParent.el) { + const initialParentValues = parentValues( + state2.initialParent.el, + state2.initialParent.data + ); + if (targetIndex === void 0) { + newTargetParentValues = newValues.concat(draggedValues); + setParentValues( + state2.currentParent.el, + state2.currentParent.data, + newTargetParentValues + ); + setParentValues( + state2.initialParent.el, + state2.initialParent.data, + initialParentValues.filter((x) => !draggedValues.includes(x)) + ); + } else { + const targetedNodeValues = state2.currentParent.data.enabledNodes.slice(targetIndex, targetIndex + draggedValues.length).map((node) => node.data.value); + const newInitialParentValues = initialParentValues.filter( + (x) => !draggedValues.includes(x) + ); + newInitialParentValues.splice( + state2.initialIndex, + 0, + ...targetedNodeValues + ); + setParentValues( + state2.initialParent.el, + state2.initialParent.data, + newInitialParentValues + ); + const newTargetParentValues2 = newValues.filter( + (x) => !targetedNodeValues.includes(x) + ); + newTargetParentValues2.splice(targetIndex, 0, ...draggedValues); + setParentValues( + state2.currentParent.el, + state2.currentParent.data, + newTargetParentValues2 + ); + } + } + removeClass( + placeState2.draggedOverNodes.map((node) => node.el), + isSynth ? state2.currentParent.data.config.synthDropZoneClass : state2.currentParent.data.config.dropZoneClass + ); } // src/index.ts @@ -1059,7 +1211,7 @@ function dragAndDrop({ handleParentFocus, handleNodePointerup, handleNodeTouchstart, - handleNodePointerover: handleNodePointerover2, + handleNodePointerover: handleNodePointerover3, handleParentPointerover, handleNodePointerdown, handleNodePointermove, @@ -1481,6 +1633,7 @@ function setupNode(data) { dragend: nodeEventData(config.handleDragend), drop: nodeEventData(config.handleNodeDrop), touchstart: nodeEventData(config.handleNodeTouchstart), + pointercancel: nodeEventData(config.handleDragend), pointerdown: nodeEventData(config.handleNodePointerdown), pointerup: nodeEventData(config.handleNodePointerup), pointermove: nodeEventData(config.handleNodePointermove), @@ -1717,7 +1870,6 @@ function handleDragstart(data, state2) { ); } function handleNodePointerdown(data, state2) { - console.log("pointerdown", synthNodePointerDown); if (!validateDragHandle(data)) return; data.e.stopPropagation(); synthNodePointerDown = true; @@ -1982,7 +2134,7 @@ function preventSortOnScroll() { }, 100); }; } -function handleNodePointerover2(e) { +function handleNodePointerover3(e) { if (e.detail.targetData.parent.el === e.detail.state.currentParent.el) sort(e.detail, e.detail.state); else transfer(e.detail, e.detail.state); diff --git a/dist/index.cjs.map b/dist/index.cjs.map index e977a0b..6fd74ec 100644 --- a/dist/index.cjs.map +++ b/dist/index.cjs.map @@ -1 +1 @@ -{"version":3,"sources":["../src/index.ts","../src/plugins/animations/index.ts","../src/plugins/insertion/index.ts","../src/plugins/place/index.ts","../src/plugins/swap/index.ts"],"sourcesContent":["import type {\n DNDPlugin,\n DragAndDrop,\n DragState,\n DragStateProps,\n Node,\n NodeData,\n NodeDragEventData,\n NodeEventData,\n NodePointerEventData,\n NodeRecord,\n NodeTargetData,\n NodesData,\n ParentConfig,\n ParentData,\n ParentEventData,\n ParentTargetData,\n ParentsData,\n PointeroverNodeEvent,\n PointeroverParentEvent,\n ScrollData,\n SetupNodeData,\n TearDownNodeData,\n BaseDragState,\n SynthDragState,\n ParentKeydownEventData,\n SynthDragStateProps,\n ParentRecord,\n EventHandlers,\n NodeFromPoint,\n ParentFromPoint,\n Coordinates,\n} from \"./types\";\n\nexport * from \"./types\";\nexport { animations } from \"./plugins/animations\";\nexport { insertion } from \"./plugins/insertion\";\nexport { place } from \"./plugins/place\";\nexport { swap } from \"./plugins/swap\";\n\n/**\n * Check to see if code is running in a browser.\n *\n * @internal\n */\nexport const isBrowser = typeof window !== \"undefined\";\n\nexport const touchDevice = window && \"ontouchstart\" in window;\n\nlet dropped = false;\n\n/**\n * Abort controller for the document.\n */\nlet documentController: AbortController | undefined;\n\nlet isNative = false;\n\nlet animationFrameId: number | null = null;\n\nconst scrollConfig: {\n [key: string]: [number, number];\n} = {\n up: [0, -1],\n down: [0, 1],\n left: [-1, 0],\n right: [1, 0],\n};\n\nexport const nodes: NodesData = new WeakMap>();\n\nexport const parents: ParentsData = new WeakMap<\n HTMLElement,\n ParentData\n>();\n\nexport const treeAncestors: Record = {};\n\nlet synthNodePointerDown = false;\n\nexport function createEmitter() {\n const callbacks = new Map();\n\n const emit = function (eventName: string, data: any) {\n if (!callbacks.get(eventName)) return;\n callbacks.get(eventName)!.forEach((cb) => {\n cb(data);\n });\n };\n\n const on = function (eventName: string, callback: any) {\n const cbs = callbacks.get(eventName) ?? [];\n\n cbs.push(callback);\n\n callbacks.set(eventName, cbs);\n };\n\n return [emit, on];\n}\n\nexport const [emit, on] = createEmitter();\n\nconst baseDragState = {\n activeDescendant: undefined,\n affectedNodes: [],\n currentTargetValue: undefined,\n on,\n emit,\n newActiveDescendant: undefined,\n originalZIndex: undefined,\n pointerSelection: false,\n preventEnter: false,\n remapJustFinished: false,\n selectednodes: [],\n selectedParent: undefined,\n};\n\n/**\n * The state of the drag and drop.\n */\nexport let state: BaseDragState = baseDragState;\n\nexport function resetState() {\n const baseDragState = {\n activeDescendant: undefined,\n affectedNodes: [],\n on,\n emit,\n currentTargetValue: undefined,\n originalZIndex: undefined,\n pointerId: undefined,\n preventEnter: false,\n remapJustFinished: false,\n selectednodes: [],\n selectedParent: undefined,\n pointerSelection: false,\n synthScrollDirection: undefined,\n draggedNodeDisplay: undefined,\n synthDragScrolling: false,\n };\n\n state = { ...baseDragState } as BaseDragState;\n}\n\n/**\n * @param {DragStateProps} dragStateProps - Attributes to update state with.\n *\n * @mutation - Updates state with node values.\n *\n * @returns void\n */\nexport function setDragState(\n dragStateProps:\n | (SynthDragStateProps & DragStateProps)\n | DragStateProps\n | undefined\n): DragState | SynthDragState {\n Object.assign(state, dragStateProps);\n\n dropped = false;\n\n state.emit(\"dragStarted\", state);\n\n return state as DragState | SynthDragState;\n}\n\n/**\n *\n */\nfunction handlePointerdownRoot(_e: PointerEvent) {\n if (state.activeState) setActive(state.activeState.parent, undefined, state);\n\n if (state.selectedState)\n deselect(state.selectedState.nodes, state.selectedState.parent, state);\n\n state.selectedState = state.activeState = undefined;\n}\n\nfunction handlePointerupRoot(_e: PointerEvent) {\n if (!isSynthDragState(state)) return;\n\n const config = state.currentParent.data.config;\n\n if (isSynthDragState(state)) config.handleEnd(state);\n}\n\n/**\n * Handles the keydown event on the root element.\n *\n * @param {KeyboardEvent} e - The keyboard event.\n */\nfunction handleRootKeydown(e: KeyboardEvent) {\n if (e.key === \"Escape\") {\n if (state.selectedState)\n deselect(state.selectedState.nodes, state.selectedState.parent, state);\n\n if (state.activeState)\n setActive(state.activeState.parent, undefined, state);\n\n state.selectedState = state.activeState = undefined;\n }\n}\n\nfunction handleRootDrop(_e: DragEvent) {\n //e.preventDefault();\n}\n\n/**\n * If we are currently dragging, then let's prevent default on dragover to avoid\n * the default behavior of the browser on drop.\n */\nfunction handleRootDragover(e: DragEvent) {\n if (!isDragState(state)) return;\n\n e.preventDefault();\n}\n\n/**\n * Initializes the drag and drop functionality for a given parent.\n *\n * @param {DragAndDrop} dragAndDrop - The drag and drop configuration.\n *\n * @returns void\n */\nexport function dragAndDrop({\n parent,\n getValues,\n setValues,\n config = {},\n}: DragAndDrop): void {\n if (!isBrowser) return;\n\n if (!documentController)\n documentController = addEvents(document, {\n dragover: handleRootDragover,\n pointerdown: handlePointerdownRoot,\n pointerup: handlePointerupRoot,\n keydown: handleRootKeydown,\n drop: handleRootDrop,\n });\n\n tearDown(parent);\n\n const parentData: ParentData = {\n getValues,\n setValues,\n config: {\n dragDropEffect: config.dragDropEffect ?? \"move\",\n dragEffectAllowed: config.dragEffectAllowed ?? \"move\",\n draggedNodes,\n dragstartClasses,\n deepCopyStyles: config.deepCopyStyles ?? false,\n handleNodeKeydown,\n handleParentKeydown,\n handleDragstart,\n handleNodeDragover,\n handleParentDragover,\n handleNodeDrop,\n handleDragend,\n handleEnd,\n handleParentBlur,\n handleParentFocus,\n handleNodePointerup,\n handleNodeTouchstart,\n handleNodePointerover,\n handleParentPointerover,\n handleNodePointerdown,\n handleNodePointermove,\n handleNodeDragenter,\n handleNodeDragleave,\n handleParentDrop,\n multiDrag: config.multiDrag ?? false,\n nativeDrag: config.nativeDrag ?? true,\n performSort,\n performTransfer,\n root: config.root ?? document,\n setupNode,\n setupNodeRemap,\n reapplyDragClasses,\n tearDownNode,\n tearDownNodeRemap,\n remapFinished,\n scrollBehavior: {\n x: 0.95,\n y: 0.95,\n },\n threshold: {\n horizontal: 0,\n vertical: 0,\n },\n ...config,\n },\n enabledNodes: [],\n abortControllers: {},\n privateClasses: [],\n };\n\n const nodesObserver = new MutationObserver(nodesMutated);\n\n nodesObserver.observe(parent, { childList: true });\n\n parents.set(parent, parentData);\n\n if (config.treeAncestor && config.treeGroup)\n treeAncestors[config.treeGroup] = parent;\n\n config.plugins?.forEach((plugin) => {\n plugin(parent)?.tearDown?.();\n });\n\n config.plugins?.forEach((plugin) => {\n plugin(parent)?.tearDown?.();\n });\n\n config.plugins?.forEach((plugin: DNDPlugin) => {\n plugin(parent)?.setup?.();\n });\n\n setup(parent, parentData);\n\n remapNodes(parent, true);\n}\n\nexport function dragStateProps(\n data: NodeDragEventData | NodePointerEventData,\n draggedNodes: Array>,\n nativeDrag = true\n): DragStateProps {\n const { x, y } = eventCoordinates(data.e);\n\n const rect = data.targetData.node.el.getBoundingClientRect();\n\n const scrollEls: Array<[HTMLElement, AbortController]> = [];\n\n for (const scrollable of getScrollables()) {\n scrollEls.push([\n scrollable,\n nativeDrag\n ? addEvents(scrollable, {\n scroll: preventSortOnScroll(),\n })\n : addEvents(scrollable, {\n pointermove: handleScroll,\n }),\n ]);\n }\n\n return {\n affectedNodes: [],\n ascendingDirection: false,\n clonedDraggedEls: [],\n dynamicValues: [],\n coordinates: {\n x,\n y,\n },\n draggedNode: {\n el: data.targetData.node.el,\n data: data.targetData.node.data,\n },\n draggedNodes,\n incomingDirection: undefined,\n initialIndex: data.targetData.node.data.index,\n initialParent: {\n el: data.targetData.parent.el,\n data: data.targetData.parent.data,\n },\n currentParent: {\n el: data.targetData.parent.el,\n data: data.targetData.parent.data,\n },\n longPress: data.targetData.parent.data.config.longPress ?? false,\n longPressTimeout: 0,\n currentTargetValue: data.targetData.node.data.value,\n scrollEls,\n startLeft: x - rect.left,\n startTop: y - rect.top,\n targetIndex: data.targetData.node.data.index,\n transferred: false,\n };\n}\n\nexport function performSort({\n parent,\n draggedNodes,\n targetNode,\n}: {\n parent: ParentRecord;\n draggedNodes: Array>;\n targetNode: NodeRecord;\n}) {\n const draggedValues = draggedNodes.map((x) => x.data.value);\n\n const targetParentValues = parentValues(parent.el, parent.data);\n\n const originalIndex = draggedNodes[0].data.index;\n\n const enabledNodes = [...parent.data.enabledNodes];\n\n const newParentValues = [\n ...targetParentValues.filter((x) => !draggedValues.includes(x)),\n ];\n\n newParentValues.splice(targetNode.data.index, 0, ...draggedValues);\n\n if (\"draggedNode\" in state) state.currentTargetValue = targetNode.data.value;\n\n setParentValues(parent.el, parent.data, [...newParentValues]);\n\n if (parent.data.config.onSort)\n parent.data.config.onSort({\n parent: {\n el: parent.el,\n data: parent.data,\n },\n previousValues: [...targetParentValues],\n previousNodes: [...enabledNodes],\n nodes: [...parent.data.enabledNodes],\n values: [...newParentValues],\n draggedNode: draggedNodes[0],\n previousPosition: originalIndex,\n position: targetNode.data.index,\n });\n}\n\n/**\n * This function sets the active node as well as removing any classes or\n * attribute set.\n *\n * @param {ParentEventData} data - The parent event data.\n * @param {NodeRecord} newActiveNode - The new active node.\n * @param {BaseDragState} state - The current drag state.\n */\nfunction setActive(\n parent: ParentRecord,\n newActiveNode: NodeRecord | undefined,\n state: BaseDragState\n) {\n const activeDescendantClass = parent.data.config.activeDescendantClass;\n\n if (state.activeState) {\n {\n removeClass([state.activeState.node.el], activeDescendantClass);\n\n if (state.activeState.parent.el !== parent.el)\n state.activeState.parent.el.setAttribute(\"aria-activedescendant\", \"\");\n }\n }\n\n if (!newActiveNode) {\n state.activeState?.parent.el.setAttribute(\"aria-activedescendant\", \"\");\n\n state.activeState = undefined;\n\n return;\n }\n\n state.activeState = {\n node: newActiveNode,\n parent,\n };\n\n addNodeClass([newActiveNode.el], activeDescendantClass);\n\n state.activeState.parent.el.setAttribute(\n \"aria-activedescendant\",\n state.activeState.node.el.id\n );\n}\n\nfunction deselect(\n nodes: Array>,\n parent: ParentRecord,\n state: BaseDragState\n) {\n const selectedClass = parent.data.config.selectedClass;\n\n if (!state.selectedState) return;\n\n const iterativeNodes = Array.from(nodes);\n\n removeClass(\n nodes.map((x) => x.el),\n selectedClass\n );\n\n for (const node of iterativeNodes) {\n node.el.setAttribute(\"aria-selected\", \"false\");\n\n const index = state.selectedState.nodes.findIndex((x) => x.el === node.el);\n\n if (index === -1) continue;\n\n state.selectedState.nodes.splice(index, 1);\n }\n\n clearLiveRegion(parent);\n}\n\n/**\n * This function sets the selected nodes. This will clean the prior selected state\n * as well as removing any classes or attributes set.\n */\nfunction setSelected(\n parent: ParentRecord,\n selectedNodes: Array>,\n newActiveNode: NodeRecord | undefined,\n state: BaseDragState,\n pointerdown = false\n) {\n state.pointerSelection = pointerdown;\n\n for (const node of selectedNodes) {\n node.el.setAttribute(\"aria-selected\", \"true\");\n\n addNodeClass([node.el], parent.data.config.selectedClass, true);\n }\n\n state.selectedState = {\n nodes: selectedNodes,\n parent,\n };\n\n const selectedItems = selectedNodes.map((x) =>\n x.el.getAttribute(\"aria-label\")\n );\n\n if (selectedItems.length === 0) {\n state.selectedState = undefined;\n\n clearLiveRegion(parent);\n\n return;\n }\n\n setActive(parent, newActiveNode, state);\n\n updateLiveRegion(\n parent,\n `${selectedItems.join(\n \", \"\n )} ready for dragging. Use arrow keys to navigate. Press enter to drop ${selectedItems.join(\n \", \"\n )}.`\n );\n}\n\nfunction updateLiveRegion(parent: ParentRecord, message: string) {\n const parentId = parent.el.id;\n\n const liveRegion = document.getElementById(parentId + \"-live-region\");\n\n if (!liveRegion) return;\n\n liveRegion.textContent = message;\n}\n\nfunction clearLiveRegion(parent: ParentRecord) {\n const liveRegion = document.getElementById(parent.el.id + \"-live-region\");\n\n if (!liveRegion) return;\n\n liveRegion.textContent = \"\";\n}\n\nexport function handleParentBlur(\n _data: ParentEventData,\n _state: BaseDragState | DragState | SynthDragState\n) {}\n\nexport function handleParentFocus(\n data: ParentEventData,\n state: BaseDragState | DragState | SynthDragState\n) {\n const firstEnabledNode = data.targetData.parent.data.enabledNodes[0];\n\n if (!firstEnabledNode) return;\n\n if (\n state.selectedState &&\n state.selectedState.parent.el !== data.targetData.parent.el\n ) {\n setActive(data.targetData.parent, firstEnabledNode, state);\n } else if (!state.selectedState) {\n setActive(data.targetData.parent, firstEnabledNode, state);\n }\n}\n\nexport function performTransfer({\n currentParent,\n targetParent,\n initialParent,\n draggedNodes,\n initialIndex,\n targetNode,\n state,\n}: {\n currentParent: ParentRecord;\n targetParent: ParentRecord;\n initialParent: ParentRecord;\n draggedNodes: Array>;\n initialIndex: number;\n state: BaseDragState | DragState | SynthDragState;\n targetNode?: NodeRecord;\n}) {\n const draggedValues = draggedNodes.map((x) => x.data.value);\n\n const currentParentValues = parentValues(\n currentParent.el,\n currentParent.data\n ).filter((x: any) => !draggedValues.includes(x));\n\n const targetParentValues = parentValues(targetParent.el, targetParent.data);\n\n const reset =\n initialParent.el === targetParent.el &&\n targetParent.data.config.sortable === false;\n\n let targetIndex: number;\n\n if (targetNode) {\n if (reset) {\n targetIndex = initialIndex;\n } else if (targetParent.data.config.sortable === false) {\n targetIndex = targetParent.data.enabledNodes.length;\n } else {\n targetIndex = targetNode.data.index;\n }\n\n targetParentValues.splice(targetIndex, 0, ...draggedValues);\n } else {\n targetIndex = reset ? initialIndex : targetParent.data.enabledNodes.length;\n\n targetParentValues.splice(targetIndex, 0, ...draggedValues);\n }\n\n setParentValues(currentParent.el, currentParent.data, currentParentValues);\n\n setParentValues(targetParent.el, targetParent.data, targetParentValues);\n\n if (targetParent.data.config.onTransfer) {\n targetParent.data.config.onTransfer({\n sourceParent: currentParent,\n targetParent,\n initialParent,\n draggedNodes,\n targetIndex,\n state,\n });\n }\n\n if (currentParent.data.config.onTransfer) {\n currentParent.data.config.onTransfer({\n sourceParent: currentParent,\n targetParent,\n initialParent,\n draggedNodes,\n targetIndex,\n state,\n });\n }\n}\n\nexport function parentValues(\n parent: HTMLElement,\n parentData: ParentData\n): Array {\n return [...parentData.getValues(parent)];\n}\n\nfunction findArrayCoordinates(\n obj: any,\n targetArray: Array,\n path: Array = []\n) {\n let result: Array = [];\n\n if (obj === targetArray) result.push(path);\n\n if (Array.isArray(obj)) {\n const index = obj.findIndex((el) => el === targetArray);\n\n if (index !== -1) {\n result.push([...path, index]);\n } else {\n for (let i = 0; i < obj.length; i++) {\n result = result.concat(\n findArrayCoordinates(obj[i], targetArray, [...path, i])\n );\n }\n }\n } else if (typeof obj === \"object\" && obj !== null) {\n for (const key in obj) {\n result = result.concat(\n findArrayCoordinates(obj[key], targetArray, [...path, key])\n );\n }\n }\n\n return result;\n}\n\nfunction setValueAtCoordinatesUsingFindIndex(\n obj: Array,\n targetArray: Array,\n newArray: Array\n) {\n const coordinates = findArrayCoordinates(obj, targetArray);\n\n let newValues;\n\n coordinates.forEach((coords) => {\n let current = obj;\n for (let i = 0; i < coords.length - 1; i++) {\n const index = coords[i];\n current = current[index];\n }\n const lastIndex = coords[coords.length - 1];\n\n current[lastIndex] = newArray;\n\n // We want to access getter of object we are setting to set the new values\n // of the nested parent element (should be a part of the original structure of\n // ancestor values).\n newValues = current[lastIndex];\n });\n\n return newValues;\n}\n\nexport function setParentValues(\n parent: HTMLElement,\n parentData: ParentData,\n values: Array\n): void {\n const treeGroup = parentData.config.treeGroup;\n\n if (treeGroup) {\n const ancestorEl = treeAncestors[treeGroup];\n\n const ancestorData = parents.get(ancestorEl);\n\n if (!ancestorData) return;\n\n const ancestorValues = ancestorData.getValues(ancestorEl);\n\n const initialParentValues = parentData.getValues(parent);\n\n const updatedValues = setValueAtCoordinatesUsingFindIndex(\n ancestorValues,\n initialParentValues,\n values\n );\n\n if (!updatedValues) {\n console.warn(\"No updated value found\");\n\n return;\n }\n\n parentData.setValues(updatedValues, parent);\n\n return;\n }\n\n parentData.setValues(values, parent);\n}\n\nexport function dragValues(state: DragState): Array {\n return [...state.draggedNodes.map((x) => x.data.value)];\n}\n\n/**\n * Utility function to update parent config.\n */\nexport function updateConfig(\n parent: HTMLElement,\n config: Partial>\n) {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n parents.set(parent, {\n ...parentData,\n config: { ...parentData.config, ...config },\n });\n\n dragAndDrop({\n parent,\n getValues: parentData.getValues,\n setValues: parentData.setValues,\n config,\n });\n}\n\nexport function handleParentDrop(\n data: ParentEventData,\n state: DragState\n) {\n dropped = true;\n\n const config = data.targetData.parent.data.config;\n\n config.handleEnd(state);\n}\n\nexport function tearDown(parent: HTMLElement) {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n if (parentData.abortControllers.mainParent)\n parentData.abortControllers.mainParent.abort();\n}\n\nexport function isDragState(\n state: BaseDragState\n): state is DragState | SynthDragState {\n return \"draggedNode\" in state && !!state.draggedNode;\n}\n\nexport function isSynthDragState(\n state: BaseDragState\n): state is SynthDragState {\n return \"pointerId\" in state && !!state.pointerId;\n}\n\nfunction setup(parent: HTMLElement, parentData: ParentData): void {\n parentData.abortControllers.mainParent = addEvents(parent, {\n keydown: parentEventData(parentData.config.handleParentKeydown),\n dragover: parentEventData(parentData.config.handleParentDragover),\n handleParentPointerover: parentData.config.handleParentPointerover,\n drop: parentEventData(parentData.config.handleParentDrop),\n hasNestedParent: (e: CustomEvent) => {\n const parent = parents.get(e.target as HTMLElement);\n\n if (!parent) return;\n\n parent.nestedParent = e.detail.parent;\n },\n blur: parentEventData(parentData.config.handleParentBlur),\n focus: parentEventData(parentData.config.handleParentFocus),\n });\n\n setAttrs(parent, {\n role: \"listbox\",\n tabindex: \"0\",\n \"aria-multiselectable\": parentData.config.multiDrag ? \"true\" : \"false\",\n \"aria-activedescendant\": \"\",\n \"aria-describedby\": parent.id + \"-live-region\",\n });\n\n const liveRegion = document.createElement(\"div\");\n\n setAttrs(liveRegion, {\n \"aria-live\": \"polite\",\n \"aria-atomic\": \"true\",\n \"data-drag-and-drop-live-region\": \"true\",\n id: parent.id.toString() + \"-live-region\",\n });\n\n Object.assign(liveRegion.style, {\n position: \"absolute\",\n width: \"1px\",\n height: \"1px\",\n padding: \"0\",\n overflow: \"hidden\",\n clip: \"rect(0, 0, 0, 0)\",\n whiteSpace: \"nowrap\",\n border: \"0\",\n });\n\n document.body.appendChild(liveRegion);\n}\n\nexport function setAttrs(el: HTMLElement, attrs: Record) {\n for (const key in attrs) el.setAttribute(key, attrs[key]);\n}\n\nexport function setupNode(data: SetupNodeData) {\n const config = data.parent.data.config;\n\n data.node.el.draggable = true;\n\n data.node.data.abortControllers.mainNode = addEvents(data.node.el, {\n keydown: nodeEventData(config.handleNodeKeydown),\n dragstart: nodeEventData(config.handleDragstart),\n dragover: nodeEventData(config.handleNodeDragover),\n dragenter: nodeEventData(config.handleNodeDragenter),\n dragleave: nodeEventData(config.handleNodeDragleave),\n dragend: nodeEventData(config.handleDragend),\n drop: nodeEventData(config.handleNodeDrop),\n touchstart: nodeEventData(config.handleNodeTouchstart),\n pointerdown: nodeEventData(config.handleNodePointerdown),\n pointerup: nodeEventData(config.handleNodePointerup),\n pointermove: nodeEventData(config.handleNodePointermove),\n handleNodePointerover: config.handleNodePointerover,\n mousedown: () => {\n if (!config.nativeDrag) isNative = false;\n else isNative = true;\n },\n });\n\n data.node.el.setAttribute(\"role\", \"option\");\n\n data.node.el.setAttribute(\"aria-selected\", \"false\");\n\n config.reapplyDragClasses(data.node.el, data.parent.data);\n\n data.parent.data.config.plugins?.forEach((plugin: DNDPlugin) => {\n plugin(data.parent.el)?.setupNode?.(data);\n });\n}\n\nexport function setupNodeRemap(data: SetupNodeData) {\n nodes.set(data.node.el, data.node.data);\n\n data.parent.data.config.plugins?.forEach((plugin: DNDPlugin) => {\n plugin(data.parent.el)?.setupNodeRemap?.(data);\n });\n}\n\nfunction reapplyDragClasses(node: Node, parentData: ParentData) {\n if (!isDragState(state)) return;\n\n const dropZoneClass = isSynthDragState(state)\n ? parentData.config.synthDropZoneClass\n : parentData.config.dropZoneClass;\n\n if (state.draggedNode.el !== node) return;\n\n addNodeClass([node], dropZoneClass, true);\n}\n\nexport function tearDownNodeRemap(data: TearDownNodeData) {\n data.parent.data.config.plugins?.forEach((plugin: DNDPlugin) => {\n plugin(data.parent.el)?.tearDownNodeRemap?.(data);\n });\n}\n\nexport function tearDownNode(data: TearDownNodeData) {\n data.parent.data.config.plugins?.forEach((plugin: DNDPlugin) => {\n plugin(data.parent.el)?.tearDownNode?.(data);\n });\n\n data.node.el.draggable = false;\n\n if (data.node.data?.abortControllers?.mainNode)\n data.node.data?.abortControllers?.mainNode.abort();\n}\n\n/**\n * Called when the nodes of a given parent element are mutated.\n *\n * @param mutationList - The list of mutations.\n *\n * @returns void\n *\n * @internal\n */\nfunction nodesMutated(mutationList: MutationRecord[]) {\n const parentEl = mutationList[0].target;\n\n if (!(parentEl instanceof HTMLElement)) return;\n\n const allSelectedAndActiveNodes = document.querySelectorAll(\n `[aria-selected=\"true\"]`\n );\n\n const parentData = parents.get(parentEl);\n\n if (!parentData) return;\n\n for (let x = 0; x < allSelectedAndActiveNodes.length; x++) {\n const node = allSelectedAndActiveNodes[x];\n\n node.setAttribute(\"aria-selected\", \"false\");\n\n removeClass([node], parentData.config.selectedClass);\n }\n\n remapNodes(parentEl);\n}\n\n/**\n * Remaps the data of the parent element's children.\n *\n * @param parent - The parent element.\n *\n * @returns void\n *\n * @internal\n */\nexport function remapNodes(parent: HTMLElement, force?: boolean) {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n parentData.privateClasses = Array.from(parent.classList);\n\n const enabledNodes: Array = [];\n\n const config = parentData.config;\n\n for (let x = 0; x < parent.children.length; x++) {\n const node = parent.children[x];\n\n if (!isNode(node)) continue;\n\n const nodeData = nodes.get(node);\n\n // Only tear down the node if we have explicitly called dragAndDrop\n if (force || !nodeData)\n config.tearDownNode({\n parent: {\n el: parent,\n data: parentData,\n },\n node: {\n el: node,\n data: nodeData,\n },\n });\n\n if (config.disabled) continue;\n\n if (!config.draggable || (config.draggable && config.draggable(node))) {\n enabledNodes.push(node);\n }\n }\n\n if (\n enabledNodes.length !== parentData.getValues(parent).length &&\n !config.disabled\n ) {\n console.warn(\n \"The number of draggable items defined in the parent element does not match the number of values. This may cause unexpected behavior.\"\n );\n\n return;\n }\n\n if (parentData.config.treeGroup && !parentData.config.treeAncestor) {\n let nextAncestorEl = parent.parentElement;\n\n let eventDispatched = false;\n\n while (nextAncestorEl) {\n if (!parents.has(nextAncestorEl as HTMLElement)) {\n nextAncestorEl = nextAncestorEl.parentElement;\n\n continue;\n }\n\n nextAncestorEl.dispatchEvent(\n new CustomEvent(\"hasNestedParent\", {\n detail: {\n parent: { data: parentData, el: parent },\n },\n })\n );\n\n eventDispatched = true;\n\n nextAncestorEl = null;\n }\n\n if (!eventDispatched) console.warn(\"No ancestor found for tree group\");\n }\n\n const values = parentData.getValues(parent);\n\n const enabledNodeRecords: Array> = [];\n\n for (let x = 0; x < enabledNodes.length; x++) {\n const node = enabledNodes[x];\n\n const prevNodeData = nodes.get(node);\n\n const nodeData = Object.assign(\n prevNodeData ?? {\n privateClasses: [],\n abortControllers: {},\n },\n {\n value: values[x],\n index: x,\n }\n );\n\n if (\n !isDragState(state) &&\n state.newActiveDescendant &&\n state.newActiveDescendant.data.value === nodeData.value\n ) {\n setActive(\n {\n data: parentData,\n el: parent,\n },\n {\n el: node,\n data: nodeData,\n },\n state\n );\n }\n\n if (\n !isDragState(state) &&\n state.activeState &&\n state.activeState.node.data.value === nodeData.value\n ) {\n setActive(\n {\n data: parentData,\n el: parent,\n },\n {\n el: node,\n data: nodeData,\n },\n state\n );\n }\n\n if (isDragState(state) && nodeData.value === state.draggedNode.data.value) {\n state.draggedNode.data = nodeData;\n\n state.draggedNode.el = node;\n const draggedNode = state.draggedNodes.find(\n (x) => x.data.value === nodeData.value\n );\n\n if (draggedNode) draggedNode.el = node;\n\n if (isSynthDragState(state))\n state.draggedNode.el.setPointerCapture(state.pointerId);\n }\n\n enabledNodeRecords.push({\n el: node,\n data: nodeData,\n });\n\n if (force || !prevNodeData)\n config.setupNode({\n parent: {\n el: parent,\n data: parentData,\n },\n node: {\n el: node,\n data: nodeData,\n },\n });\n\n setupNodeRemap({\n parent: {\n el: parent,\n data: parentData,\n },\n node: {\n el: node,\n data: nodeData,\n },\n });\n }\n\n parents.set(parent, { ...parentData, enabledNodes: enabledNodeRecords });\n\n config.remapFinished(parentData);\n\n parentData.config.plugins?.forEach((plugin: DNDPlugin) => {\n plugin(parent)?.remapFinished?.();\n });\n}\n\nexport function remapFinished() {\n state.remapJustFinished = true;\n\n if (\"draggedNode\" in state) state.affectedNodes = [];\n}\n\nexport function validateDragstart(data: NodeEventData): boolean {\n return !!data.targetData.parent.data.config.nativeDrag;\n}\n\nfunction draggedNodes(data: NodeEventData): Array> {\n if (!data.targetData.parent.data.config.multiDrag) {\n return [data.targetData.node];\n } else if (state.selectedState) {\n return [\n data.targetData.node,\n ...(state.selectedState?.nodes.filter(\n (x) => x.el !== data.targetData.node.el\n ) as Array>),\n ];\n }\n\n return [];\n}\n\n/**\n * Responsible for assigning dragstart classes to the dragged nodes.\n */\nexport function handleDragstart(\n data: NodeDragEventData,\n state: BaseDragState\n) {\n if (!validateDragstart(data) || !validateDragHandle(data)) {\n data.e.preventDefault();\n\n return;\n }\n\n const config = data.targetData.parent.data.config;\n\n const nodes = config.draggedNodes(data);\n\n config.dragstartClasses(data.targetData.node, nodes, config);\n\n const dragState = initDrag(data, nodes);\n\n if (config.onDragstart)\n config.onDragstart(\n {\n parent: data.targetData.parent,\n values: parentValues(\n data.targetData.parent.el,\n data.targetData.parent.data\n ),\n draggedNode: dragState.draggedNode,\n draggedNodes: dragState.draggedNodes,\n position: dragState.initialIndex,\n },\n state as DragState\n );\n}\n\nexport function handleNodePointerdown(\n data: NodePointerEventData,\n state: BaseDragState\n) {\n console.log(\"pointerdown\", synthNodePointerDown);\n\n if (!validateDragHandle(data)) return;\n\n data.e.stopPropagation();\n\n synthNodePointerDown = true;\n\n const parentData = data.targetData.parent.data;\n\n let selectedNodes = [data.targetData.node];\n\n const commandKey = data.e.ctrlKey || data.e.metaKey;\n const shiftKey = data.e.shiftKey;\n\n const targetNode = data.targetData.node;\n\n if (commandKey && parentData.config.multiDrag) {\n if (state.selectedState) {\n const idx = state.selectedState.nodes.findIndex(\n (x) => x.el === targetNode.el\n );\n\n if (idx === -1) {\n selectedNodes = [...state.selectedState.nodes, targetNode];\n } else {\n selectedNodes = state.selectedState.nodes.filter(\n (x) => x.el !== targetNode.el\n );\n }\n } else {\n selectedNodes = [targetNode];\n }\n\n setSelected(\n data.targetData.parent,\n selectedNodes,\n data.targetData.node,\n state,\n true\n );\n\n return;\n }\n\n if (shiftKey && parentData.config.multiDrag) {\n const nodes = data.targetData.parent.data.enabledNodes;\n if (state.selectedState && state.activeState) {\n if (state.selectedState.parent.el !== data.targetData.parent.el) {\n deselect(state.selectedState.nodes, state.selectedState.parent, state);\n state.selectedState = undefined;\n for (let x = 0; x <= targetNode.data.index; x++)\n selectedNodes.push(nodes[x]);\n } else {\n const [minIndex, maxIndex] =\n state.activeState.node.data.index < data.targetData.node.data.index\n ? [\n state.activeState.node.data.index,\n data.targetData.node.data.index,\n ]\n : [\n data.targetData.node.data.index,\n state.activeState.node.data.index,\n ];\n selectedNodes = nodes.slice(minIndex, maxIndex + 1);\n }\n } else {\n for (let x = 0; x <= targetNode.data.index; x++)\n selectedNodes.push(nodes[x]);\n }\n setSelected(\n data.targetData.parent,\n selectedNodes,\n data.targetData.node,\n state,\n true\n );\n\n return;\n }\n\n if (state.selectedState?.nodes?.length) {\n const idx = state.selectedState.nodes.findIndex(\n (x) => x.el === data.targetData.node.el\n );\n\n if (idx === -1) {\n if (state.selectedState.parent.el !== data.targetData.parent.el) {\n deselect(state.selectedState.nodes, data.targetData.parent, state);\n } else if (parentData.config.multiDrag && (touchDevice || !isNative)) {\n selectedNodes.push(...state.selectedState.nodes);\n } else {\n deselect(state.selectedState.nodes, data.targetData.parent, state);\n }\n setSelected(\n data.targetData.parent,\n selectedNodes,\n data.targetData.node,\n state,\n true\n );\n }\n } else {\n setSelected(\n data.targetData.parent,\n [data.targetData.node],\n data.targetData.node,\n state,\n true\n );\n }\n}\n\nexport function dragstartClasses(\n _node: NodeRecord,\n nodes: Array>,\n config: ParentConfig,\n isSynth = false\n) {\n addNodeClass(\n nodes.map((x) => x.el),\n isSynth ? config.synthDraggingClass : config.draggingClass\n );\n\n setTimeout(() => {\n removeClass(\n nodes.map((x) => x.el),\n isSynth ? config.synthDraggingClass : config.draggingClass\n );\n\n addNodeClass(\n nodes.map((x) => x.el),\n isSynth ? config.synthDragPlaceholderClass : config.dragPlaceholderClass\n );\n\n addNodeClass(\n nodes.map((x) => x.el),\n isSynth ? config.synthDropZoneClass : config.dropZoneClass\n );\n\n removeClass(\n nodes.map((x) => x.el),\n config.activeDescendantClass\n );\n\n removeClass(\n nodes.map((x) => x.el),\n config.selectedClass\n );\n });\n}\n\nexport function initDrag(\n data: NodeDragEventData,\n draggedNodes: Array>\n): DragState {\n const dragState = setDragState(dragStateProps(data, draggedNodes));\n\n data.e.stopPropagation();\n\n if (data.e.dataTransfer) {\n const config = data.targetData.parent.data.config;\n\n data.e.dataTransfer.dropEffect = config.dragDropEffect;\n\n data.e.dataTransfer.effectAllowed = config.dragEffectAllowed;\n\n let dragImage: HTMLElement | undefined;\n\n if (config.dragImage) {\n dragImage = config.dragImage(data, draggedNodes);\n } else {\n if (!config.multiDrag) {\n data.e.dataTransfer.setDragImage(\n data.targetData.node.el,\n data.e.offsetX,\n data.e.offsetY\n );\n\n return dragState;\n } else {\n const wrapper = document.createElement(\"div\");\n\n for (const node of draggedNodes) {\n const clonedNode = node.el.cloneNode(true) as HTMLElement;\n\n clonedNode.style.pointerEvents = \"none\";\n\n clonedNode.id = node.el.id + \"-clone\";\n\n copyNodeStyle(node.el, clonedNode, true);\n\n wrapper.append(clonedNode);\n }\n\n const { width } = draggedNodes[0].el.getBoundingClientRect();\n\n Object.assign(wrapper.style, {\n display: \"flex\",\n flexDirection: \"column\",\n width: `${width}px`,\n position: \"absolute\",\n pointerEvents: \"none\",\n zIndex: \"9999\",\n left: \"-9999px\",\n });\n\n dragImage = wrapper;\n }\n\n document.body.appendChild(dragImage);\n }\n\n data.e.dataTransfer.setDragImage(dragImage, data.e.offsetX, data.e.offsetY);\n\n setTimeout(() => {\n dragImage?.remove();\n });\n }\n\n return dragState;\n}\n\nexport function validateDragHandle(\n data: NodeDragEventData | NodePointerEventData\n): boolean {\n const config = data.targetData.parent.data.config;\n\n if (!config.dragHandle) return true;\n\n const dragHandles = data.targetData.node.el.querySelectorAll(\n config.dragHandle\n );\n\n if (!dragHandles) return false;\n\n const coordinates = data.e;\n\n const elFromPoint = config.root.elementFromPoint(\n coordinates.x,\n coordinates.y\n );\n\n if (!elFromPoint) return false;\n\n for (const handle of Array.from(dragHandles))\n if (elFromPoint === handle || handle.contains(elFromPoint)) return true;\n\n return false;\n}\n\nexport function handleClickNode(_data: NodeEventData) {}\n\nexport function handleClickParent(_data: ParentEventData) {}\n\nexport function handleNodeKeydown(_data: NodeEventData) {}\n\nexport function handleParentKeydown(\n data: ParentKeydownEventData,\n state: BaseDragState\n) {\n const activeDescendant = state.activeState?.node;\n\n if (!activeDescendant) return;\n\n const parentData = data.targetData.parent.data;\n\n const enabledNodes = parentData.enabledNodes;\n\n const index = enabledNodes.findIndex((x) => x.el === activeDescendant.el);\n\n if (index === -1) return;\n\n if (\n [\"ArrowDown\", \"ArrowUp\", \"ArrowRight\", \"ArrowLeft\"].includes(data.e.key)\n ) {\n data.e.preventDefault();\n\n const nextIndex =\n data.e.key === \"ArrowDown\" || data.e.key === \"ArrowRight\"\n ? index + 1\n : index - 1;\n\n if (nextIndex < 0 || nextIndex >= enabledNodes.length) return;\n\n const nextNode = enabledNodes[nextIndex];\n\n setActive(data.targetData.parent, nextNode, state);\n } else if (data.e.key === \" \") {\n data.e.preventDefault();\n\n state.selectedState && state.selectedState.nodes.includes(activeDescendant)\n ? setSelected(\n data.targetData.parent,\n state.selectedState.nodes.filter((x) => x.el !== activeDescendant.el),\n activeDescendant,\n state\n )\n : setSelected(\n data.targetData.parent,\n [activeDescendant],\n activeDescendant,\n state\n );\n\n //if (!state.selectedState)\n // updateLiveRegion(data.targetData.parent, \"\", true);\n } else if (data.e.key === \"Enter\" && state.selectedState) {\n if (\n state.selectedState.parent.el === data.targetData.parent.el &&\n state.activeState\n ) {\n if (state.selectedState.nodes[0].el === state.activeState.node.el) {\n updateLiveRegion(data.targetData.parent, \"Cannot drop item on itself\");\n\n return;\n }\n\n state.newActiveDescendant = state.selectedState.nodes[0];\n\n parentData.config.performSort({\n parent: data.targetData.parent,\n draggedNodes: state.selectedState.nodes,\n targetNode: state.activeState.node,\n });\n\n deselect([], data.targetData.parent, state);\n\n updateLiveRegion(data.targetData.parent, \"Drop successful\");\n } else if (\n state.activeState &&\n state.selectedState.parent.el !== data.targetData.parent.el &&\n validateTransfer({\n currentParent: data.targetData.parent,\n targetParent: state.selectedState.parent,\n initialParent: state.selectedState.parent,\n draggedNodes: state.selectedState.nodes,\n state,\n })\n ) {\n parentData.config.performTransfer({\n currentParent: state.selectedState.parent,\n targetParent: data.targetData.parent,\n initialParent: state.selectedState.parent,\n draggedNodes: state.selectedState.nodes,\n initialIndex: state.selectedState.nodes[0].data.index,\n state,\n targetNode: state.activeState.node,\n });\n\n state.newActiveDescendant = state.selectedState.nodes[0];\n\n setSelected(data.targetData.parent, [], undefined, state);\n\n updateLiveRegion(data.targetData.parent, \"Drop successful\");\n }\n }\n}\n\nexport function preventSortOnScroll() {\n let scrollTimeout: number;\n\n return () => {\n clearTimeout(scrollTimeout);\n\n if (state) state.preventEnter = true;\n\n scrollTimeout = setTimeout(() => {\n if (state) state.preventEnter = false;\n }, 100);\n };\n}\n\nexport function handleNodePointerover(e: PointeroverNodeEvent) {\n if (e.detail.targetData.parent.el === e.detail.state.currentParent.el)\n sort(e.detail, e.detail.state);\n else transfer(e.detail, e.detail.state);\n}\n\nexport function handleNodeDrop(\n data: NodeDragEventData,\n state: DragState | SynthDragState\n) {\n data.e.stopPropagation();\n\n dropped = true;\n\n const config = data.targetData.parent.data.config;\n\n config.handleEnd(state);\n}\n\nexport function handleDragend(\n data: NodeEventData,\n state: DragState | SynthDragState\n) {\n data.e.preventDefault();\n\n if (dropped) {\n dropped = false;\n\n return;\n }\n\n const config = parents.get(state.initialParent.el)?.config;\n config?.handleEnd(state);\n\n if (config?.onDragend) {\n config.onDragend({\n parent: state.currentParent,\n values: parentValues(state.currentParent.el, state.currentParent.data),\n draggedNode: state.draggedNode,\n draggedNodes: state.draggedNodes,\n position: state.initialIndex,\n });\n }\n}\n\nexport function handleEnd(state: DragState | SynthDragState) {\n cancelSynthScroll();\n\n for (const [_el, controller] of state.scrollEls) controller.abort();\n\n if (\"longPressTimeout\" in state && state.longPressTimeout)\n clearTimeout(state.longPressTimeout);\n\n const config = parents.get(state.initialParent.el)?.config;\n\n const isSynth = \"clonedDraggedNode\" in state && state.clonedDraggedNode;\n\n const dropZoneClass = isSynth\n ? config?.synthDropZoneClass\n : config?.dropZoneClass;\n\n if (state.originalZIndex !== undefined)\n state.draggedNode.el.style.zIndex = state.originalZIndex;\n\n removeClass(\n state.draggedNodes.map((x) => x.el),\n dropZoneClass\n );\n\n removeClass(\n state.draggedNodes.map((x) => x.el),\n state.initialParent.data?.config?.longPressClass\n );\n\n removeClass(\n state.draggedNodes.map((x) => x.el),\n isSynth\n ? state.initialParent.data.config.synthDragPlaceholderClass\n : state.initialParent.data?.config?.dragPlaceholderClass\n );\n\n if (isSynth) state.clonedDraggedNode.remove();\n\n deselect(state.draggedNodes, state.currentParent, state);\n\n setActive(state.currentParent, undefined, state);\n\n resetState();\n\n state.selectedState = undefined;\n\n synthNodePointerDown = false;\n\n state.emit(\"dragend\", state);\n}\n\nexport function handleNodeTouchstart(\n data: NodeEventData,\n _state: BaseDragState\n) {\n if (data.e.cancelable) data.e.preventDefault();\n}\n\nexport function handleNodePointerup(\n data: NodePointerEventData,\n state: DragState | SynthDragState | BaseDragState\n) {\n if (!state.pointerSelection && state.selectedState)\n deselect(state.selectedState.nodes, data.targetData.parent, state);\n\n const config = data.targetData.parent.data.config;\n\n state.pointerSelection = false;\n\n synthNodePointerDown = false;\n\n if (!isDragState(state)) return;\n\n config.handleEnd(state as DragState | SynthDragState);\n}\n\nexport function handleNodePointermove(\n data: NodePointerEventData,\n state: SynthDragState | BaseDragState\n) {\n // TODO: I think this is OK but not sure.\n //data.e.stopPropagation();\n\n if (isNative || !synthNodePointerDown || !validateDragHandle(data)) return;\n\n if (!isSynthDragState(state)) {\n const config = data.targetData.parent.data.config;\n\n const nodes = config.draggedNodes(data);\n\n config.dragstartClasses(data.targetData.node, nodes, config, true);\n\n const synthDragState = initSynthDrag(data, state, nodes);\n\n synthDragState.clonedDraggedNode.style.display =\n synthDragState.draggedNodeDisplay || \"\";\n\n synthMove(data, synthDragState);\n\n if (config.onDragstart)\n config.onDragstart(\n {\n parent: data.targetData.parent,\n values: parentValues(\n data.targetData.parent.el,\n data.targetData.parent.data\n ),\n draggedNode: synthDragState.draggedNode,\n draggedNodes: synthDragState.draggedNodes,\n position: synthDragState.initialIndex,\n },\n synthDragState\n );\n\n synthDragState.draggedNode.el.setPointerCapture(data.e.pointerId);\n\n synthDragState.pointerId = data.e.pointerId;\n\n return;\n }\n\n synthMove(data, state as SynthDragState);\n}\n\nfunction initSynthDrag(\n data: NodePointerEventData,\n _state: BaseDragState,\n draggedNodes: Array>\n): SynthDragState {\n const config = data.targetData.parent.data.config;\n\n let dragImage: HTMLElement | undefined;\n\n if (config.synthDragImage) {\n dragImage = config.synthDragImage(data, draggedNodes);\n } else {\n if (!config.multiDrag || draggedNodes.length === 1) {\n dragImage = data.targetData.node.el.cloneNode(true) as HTMLElement;\n\n dragImage.id = data.targetData.node.el.id + \"-clone\";\n\n copyNodeStyle(data.targetData.node.el, dragImage);\n\n Object.assign(dragImage.style, {\n width: data.targetData.node.el.getBoundingClientRect().width,\n zIndex: 9999,\n pointerEvents: \"none\",\n });\n\n document.body.appendChild(dragImage);\n } else {\n const wrapper = document.createElement(\"div\");\n\n for (const node of draggedNodes) {\n const clonedNode = node.el.cloneNode(true) as HTMLElement;\n\n copyNodeStyle(node.el, clonedNode);\n\n clonedNode.style.pointerEvents = \"none\";\n\n clonedNode.id = node.el.id + \"-clone\";\n\n wrapper.append(clonedNode);\n }\n\n const { width } = draggedNodes[0].el.getBoundingClientRect();\n\n Object.assign(wrapper.style, {\n display: \"flex\",\n flexDirection: \"column\",\n width: `${width}px`,\n position: \"fixed\",\n pointerEvents: \"none\",\n zIndex: \"9999\",\n left: \"-9999px\",\n });\n\n dragImage = wrapper;\n }\n }\n\n const display = dragImage.style.display;\n\n dragImage.style.display = \"none\";\n\n document.body.append(dragImage);\n\n dragImage.style.position = \"absolute\";\n\n const synthDragStateProps = {\n clonedDraggedEls: [],\n clonedDraggedNode: dragImage,\n draggedNodeDisplay: display,\n synthDragScrolling: false,\n };\n\n addEvents(document, {\n contextmenu: noDefault,\n });\n\n const synthDragState = setDragState({\n ...dragStateProps(data, draggedNodes, false),\n ...synthDragStateProps,\n }) as SynthDragState;\n\n return synthDragState;\n}\n\nexport function handleLongPress(\n data: NodePointerEventData,\n dragState: DragState\n) {\n const config = data.targetData.parent.data.config;\n\n if (!config.longPress) return;\n\n dragState.longPressTimeout = setTimeout(() => {\n if (!dragState) return;\n\n dragState.longPress = true;\n\n if (config.longPressClass && data.e.cancelable)\n addNodeClass(\n dragState.draggedNodes.map((x) => x.el),\n config.longPressClass\n );\n\n data.e.preventDefault();\n }, config.longPressTimeout || 200);\n}\n\nfunction pointermoveClasses(\n state: SynthDragState,\n config: ParentConfig\n) {\n if (config.longPressClass)\n removeClass(\n state.draggedNodes.map((x) => x.el),\n config?.longPressClass\n );\n}\n\nfunction getScrollData(\n e: DragEvent | PointerEvent,\n state: DragState | SynthDragState\n): ScrollData | undefined {\n if (!(e.currentTarget instanceof HTMLElement)) return;\n\n const {\n x: xThresh,\n y: yThresh,\n scrollOutside,\n } = state.initialParent.data.config.scrollBehavior;\n\n const coordinates = getRealCoords(e.currentTarget);\n\n return {\n xThresh,\n yThresh,\n scrollOutside,\n scrollParent: e.currentTarget,\n x: coordinates.left,\n y: coordinates.top,\n clientWidth: e.currentTarget.clientWidth,\n clientHeight: e.currentTarget.clientHeight,\n scrollWidth: e.currentTarget.scrollWidth,\n scrollHeight: e.currentTarget.scrollHeight,\n };\n}\n\nfunction cancelSynthScroll() {\n if (animationFrameId !== null) {\n cancelAnimationFrame(animationFrameId);\n\n animationFrameId = null;\n }\n}\n\nfunction setSynthScrollDirection(\n direction: \"up\" | \"down\" | \"left\" | \"right\" | undefined,\n el: HTMLElement,\n state: SynthDragState\n) {\n if (state.synthScrollDirection === direction) return;\n\n state.synthScrollDirection = direction;\n\n // Cancel any ongoing animation frame when direction changes\n cancelSynthScroll();\n\n if (direction === \"up\" && el.scrollTop === 0) return;\n\n if (direction === \"down\" && el.scrollTop + el.clientHeight >= el.scrollHeight)\n return;\n\n if (direction === \"left\" && el.scrollLeft === 0) return;\n\n if (direction === \"right\" && el.scrollLeft + el.clientWidth >= el.scrollWidth)\n return;\n\n let lastTimestamp: number | null = null;\n\n // Function to perform the scrolling based on the current direction\n const scroll = (timestamp: number) => {\n if (lastTimestamp === null) lastTimestamp = timestamp;\n\n const elapsed = timestamp - lastTimestamp;\n\n // Base scroll speed in pixels per second\n const baseSpeed = 500;\n\n const distance = (baseSpeed * elapsed) / 1000; // Pixels to scroll\n\n if (state.synthScrollDirection === undefined && animationFrameId) {\n cancelAnimationFrame(animationFrameId);\n\n animationFrameId = null;\n\n return;\n }\n\n switch (direction) {\n case \"up\":\n el.scrollBy(0, -distance);\n state.clonedDraggedNode.style.top = `${\n state.coordinates.y + el.scrollTop\n }px`;\n\n break;\n case \"down\":\n el.scrollBy(0, distance);\n state.clonedDraggedNode.style.top = `${\n state.coordinates.y + el.scrollTop - state.startTop\n }px`;\n\n break;\n case \"left\":\n el.scrollBy(-distance, 0);\n\n state.clonedDraggedNode.style.left = `${\n state.coordinates.x + el.scrollLeft\n }px`;\n\n break;\n case \"right\":\n state.clonedDraggedNode.style.left = `${\n state.coordinates.x + el.scrollLeft\n }px`;\n\n el.scrollBy(distance, 0);\n }\n\n lastTimestamp = timestamp;\n\n animationFrameId = requestAnimationFrame(scroll);\n };\n\n animationFrameId = requestAnimationFrame(scroll);\n}\n\nfunction shouldScroll(\n direction: string,\n e: DragEvent | PointerEvent,\n state: DragState | SynthDragState\n): boolean {\n const dataScrollData = getScrollData(e, state);\n\n if (!dataScrollData) return false;\n\n switch (direction) {\n case \"down\":\n return !!shouldScrollDown(state, dataScrollData);\n\n case \"up\":\n return !!shouldScrollUp(state, dataScrollData);\n\n case \"right\":\n return !!shouldScrollRight(state, dataScrollData);\n\n case \"left\":\n return !!shouldScrollLeft(state, dataScrollData);\n\n default:\n return false;\n }\n}\n\nfunction shouldScrollRight(\n state: DragState | SynthDragState,\n data: ScrollData\n): DragState | DragState | void {\n return;\n const diff = data.scrollParent.clientWidth + data.x - state.coordinates.x;\n\n if (!data.scrollOutside && diff < 0) return;\n\n if (\n diff < (1 - data.xThresh) * data.scrollParent.clientWidth &&\n !(\n data.scrollParent.scrollLeft + data.scrollParent.clientWidth >=\n data.scrollParent.scrollWidth\n )\n )\n return state;\n}\n\nfunction shouldScrollLeft(\n state: DragState,\n data: ScrollData\n): DragState | void {\n return;\n const diff = data.scrollParent.clientWidth + data.x - state.coordinates.x;\n\n if (!data.scrollOutside && diff > data.scrollParent.clientWidth) return;\n\n if (\n diff > data.xThresh * data.scrollParent.clientWidth &&\n data.scrollParent.scrollLeft !== 0\n )\n return state;\n}\n\nfunction shouldScrollUp(state: DragState, data: ScrollData): boolean {\n return (\n state.coordinates.y <= 0.1 * data.scrollParent.clientHeight &&\n data.scrollParent.scrollTop !== 0\n );\n}\n\nfunction shouldScrollDown(state: DragState, data: ScrollData): boolean {\n return (\n state.coordinates.y > data.clientHeight * data.yThresh &&\n data.scrollParent.scrollTop !== data.scrollParent.clientHeight\n );\n}\n\nfunction moveNode(data: NodePointerEventData, state: SynthDragState) {\n const { x, y } = eventCoordinates(data.e);\n\n state.coordinates.y = y;\n\n state.coordinates.x = x;\n\n const startLeft = state.startLeft ?? 0;\n\n const startTop = state.startTop ?? 0;\n\n state.clonedDraggedNode.style.top = `${y - startTop + window.scrollY}px`;\n\n state.clonedDraggedNode.style.left = `${x - startLeft + window.scrollX}px`;\n\n if (data.e.cancelable) data.e.preventDefault();\n\n pointermoveClasses(state, data.targetData.parent.data.config);\n}\n\nexport function synthMove(\n data: NodePointerEventData,\n state: SynthDragState\n) {\n const config = data.targetData.parent.data.config;\n\n if (config.longPress && !state.longPress) {\n clearTimeout(state.longPressTimeout);\n\n return;\n }\n\n moveNode(data, state);\n\n const elFromPoint = getElFromPoint(eventCoordinates(data.e));\n\n if (!elFromPoint) {\n document.dispatchEvent(\n new CustomEvent(\"handleRootPointerover\", {\n detail: {\n e: data.e,\n state,\n },\n })\n );\n\n return;\n }\n const pointerMoveEventData = {\n e: data.e,\n targetData: elFromPoint,\n state,\n };\n\n if (\"node\" in elFromPoint) {\n elFromPoint.node.el.dispatchEvent(\n new CustomEvent(\"handleNodePointerover\", {\n detail: pointerMoveEventData,\n })\n );\n } else {\n elFromPoint.parent.el.dispatchEvent(\n new CustomEvent(\"handleParentPointerover\", {\n detail: pointerMoveEventData,\n })\n );\n }\n}\n\nexport function handleScroll(e: DragEvent | PointerEvent) {\n e.stopPropagation();\n\n if (!isSynthDragState(state)) return;\n let directionSet = false;\n\n for (const direction of Object.keys(scrollConfig)) {\n if (shouldScroll(direction, e, state)) {\n setSynthScrollDirection(\n direction as \"up\" | \"down\" | \"left\" | \"right\" | undefined,\n e.currentTarget as HTMLElement,\n state\n );\n\n directionSet = true;\n\n break;\n }\n }\n\n if (!directionSet) state.synthScrollDirection = undefined;\n}\n\nexport function handleNodeDragover(\n data: NodeDragEventData,\n state: DragState\n) {\n const { x, y } = eventCoordinates(data.e);\n\n state.coordinates.y = y;\n\n state.coordinates.x = x;\n\n //data.e.preventDefault();\n\n //data.e.stopPropagation();\n\n data.targetData.parent.el === state.currentParent?.el\n ? sort(data, state)\n : transfer(data, state);\n}\n\nexport function handleParentDragover(\n data: ParentEventData,\n state: DragState\n) {\n if (!state) return;\n\n Object.assign(eventCoordinates(data.e as DragEvent));\n\n transfer(data, state);\n}\n\nexport function handleParentPointerover(e: PointeroverParentEvent) {\n if (e.detail.targetData.parent.el !== e.detail.state.currentParent.el)\n transfer(e.detail, e.detail.state);\n}\n\nexport function validateTransfer({\n currentParent,\n targetParent,\n initialParent,\n draggedNodes,\n state,\n}: {\n currentParent: ParentRecord;\n targetParent: ParentRecord;\n initialParent: ParentRecord;\n draggedNodes: Array>;\n state: BaseDragState;\n}) {\n if (targetParent.el === currentParent.el) return false;\n\n const targetConfig = targetParent.data.config;\n\n // Not checking for contains among all dragged nodes, should do this.\n if (targetConfig.treeGroup && draggedNodes[0].el.contains(targetParent.el))\n return false;\n\n if (targetConfig.dropZone === false) return false;\n\n const initialParentConfig = initialParent.data.config;\n\n if (targetConfig.accepts) {\n return targetConfig.accepts(\n targetParent,\n initialParent,\n currentParent,\n state\n );\n } else if (\n !targetConfig.group ||\n targetConfig.group !== initialParentConfig.group\n ) {\n return false;\n }\n\n return true;\n}\n\nfunction handleNodeDragenter(\n data: NodeDragEventData,\n _state: DragState\n) {\n data.e.preventDefault();\n}\n\nfunction handleNodeDragleave(\n data: NodeDragEventData,\n _state: DragState\n) {\n data.e.preventDefault();\n}\n\nexport function validateSort(\n data: NodeDragEventData | NodePointerEventData,\n state: DragState,\n x: number,\n y: number\n): boolean {\n if (\n state.affectedNodes\n .map((x) => x.data.value)\n .includes(data.targetData.node.data.value)\n ) {\n return false;\n }\n\n if (state.remapJustFinished) {\n state.remapJustFinished = false;\n\n if (\n data.targetData.node.data.value === state.currentTargetValue ||\n state.draggedNodes.map((x) => x.el).includes(data.targetData.node.el)\n ) {\n state.currentTargetValue = data.targetData.node.data.value;\n }\n\n return false;\n }\n\n if (state.preventEnter) return false;\n\n if (state.draggedNodes.map((x) => x.el).includes(data.targetData.node.el)) {\n state.currentTargetValue = undefined;\n\n return false;\n }\n\n if (data.targetData.node.data.value === state.currentTargetValue)\n return false;\n\n if (\n data.targetData.parent.el !== state.currentParent?.el ||\n data.targetData.parent.data.config.sortable === false\n )\n return false;\n\n const targetRect = data.targetData.node.el.getBoundingClientRect();\n\n const dragRect = state.draggedNode.el.getBoundingClientRect();\n\n const yDiff = targetRect.y - dragRect.y;\n\n const xDiff = targetRect.x - dragRect.x;\n\n let incomingDirection: \"above\" | \"below\" | \"left\" | \"right\";\n\n if (Math.abs(yDiff) > Math.abs(xDiff)) {\n incomingDirection = yDiff > 0 ? \"above\" : \"below\";\n } else {\n incomingDirection = xDiff > 0 ? \"left\" : \"right\";\n }\n\n const threshold = state.currentParent.data.config.threshold;\n\n switch (incomingDirection) {\n case \"left\":\n if (x > targetRect.x + targetRect.width * threshold.horizontal) {\n state.incomingDirection = \"left\";\n\n return true;\n }\n break;\n\n case \"right\":\n if (x < targetRect.x + targetRect.width * (1 - threshold.horizontal)) {\n state.incomingDirection = \"right\";\n\n return true;\n }\n break;\n\n case \"above\":\n if (y > targetRect.y + targetRect.height * threshold.vertical) {\n state.incomingDirection = \"above\";\n\n return true;\n }\n break;\n\n case \"below\":\n if (y < targetRect.y + targetRect.height * (1 - threshold.vertical)) {\n state.incomingDirection = \"below\";\n\n return true;\n }\n break;\n\n default:\n break;\n }\n\n return false;\n}\n\nexport function sort(\n data: NodeDragEventData | NodePointerEventData,\n state: DragState\n) {\n const { x, y } = eventCoordinates(data.e);\n\n if (!validateSort(data, state, x, y)) return;\n\n const range =\n state.draggedNode.data.index > data.targetData.node.data.index\n ? [data.targetData.node.data.index, state.draggedNode.data.index]\n : [state.draggedNode.data.index, data.targetData.node.data.index];\n\n state.targetIndex = data.targetData.node.data.index;\n\n state.affectedNodes = data.targetData.parent.data.enabledNodes.filter(\n (node) => {\n return (\n range[0] <= node.data.index &&\n node.data.index <= range[1] &&\n node.el !== state.draggedNode.el\n );\n }\n );\n\n data.targetData.parent.data.config.performSort({\n parent: data.targetData.parent,\n draggedNodes: state.draggedNodes,\n targetNode: data.targetData.node,\n });\n}\n\n/**\n * Event listener used for all nodes.\n *\n * @param e - The event.\n *\n */\nexport function nodeEventData(\n callback: any\n): (e: Event) => NodeEventData | undefined {\n function nodeTargetData(node: Node): NodeTargetData | undefined {\n const nodeData = nodes.get(node);\n\n if (!nodeData) return;\n\n const parentData = parents.get(node.parentNode);\n\n if (!parentData) return;\n\n return {\n node: {\n el: node,\n data: nodeData,\n },\n parent: {\n el: node.parentNode,\n data: parentData,\n },\n };\n }\n\n return (e: Event) => {\n const targetData = nodeTargetData(e.currentTarget as Node);\n\n if (!targetData) return;\n\n return callback(\n {\n e,\n targetData,\n },\n state\n );\n };\n}\n\n/**\n * Used when the dragged element enters into a parent other than its own.\n */\nexport function transfer(\n data: NodeEventData | ParentEventData,\n state: DragState\n): void {\n if (\n !validateTransfer({\n currentParent: state.currentParent,\n targetParent: data.targetData.parent,\n initialParent: state.initialParent,\n draggedNodes: state.draggedNodes,\n state,\n })\n )\n return;\n\n data.targetData.parent.data.config.performTransfer({\n currentParent: state.currentParent,\n targetParent: data.targetData.parent,\n initialParent: state.initialParent,\n draggedNodes: state.draggedNodes,\n initialIndex: state.initialIndex,\n state,\n targetNode: \"node\" in data.targetData ? data.targetData.node : undefined,\n });\n\n state.currentParent = data.targetData.parent;\n\n state.transferred = true;\n}\n\nexport function parentEventData(\n callback: any\n): (e: Event) => NodeEventData | undefined {\n function parentTargetData(\n parent: HTMLElement\n ): ParentTargetData | undefined {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n return {\n parent: {\n el: parent,\n data: parentData as ParentData,\n },\n };\n }\n\n return (e: Event) => {\n const targetData = parentTargetData(e.currentTarget as HTMLElement);\n\n if (!targetData) return;\n\n return callback(\n {\n e,\n targetData,\n },\n state\n );\n };\n}\n\nexport function noDefault(e: Event) {\n e.preventDefault();\n}\n\nexport function throttle(callback: any, limit: number) {\n var wait = false;\n return function (...args: any[]) {\n if (!wait) {\n callback.call(null, ...args);\n wait = true;\n setTimeout(function () {\n wait = false;\n }, limit);\n }\n };\n}\n\nfunction splitClass(className: string): Array {\n return className.split(\" \").filter((x) => x);\n}\n\nexport function addNodeClass(\n els: Array,\n className: string | undefined,\n omitAppendPrivateClass = false\n) {\n function nodeSetter(node: Node, nodeData: NodeData) {\n nodes.set(node, nodeData);\n }\n\n for (const el of els) {\n const nodeData = nodes.get(el as Node);\n\n const newData = addClass(el, className, nodeData, omitAppendPrivateClass);\n\n if (!newData) continue;\n\n nodeSetter(el as Node, newData as NodeData);\n }\n}\n\nexport function addParentClass(\n els: Array,\n className: string | undefined,\n omitAppendPrivateClass = false\n) {\n function parentSetter(parent: HTMLElement, parentData: ParentData) {\n parents.set(parent, parentData);\n }\n\n for (const el of els) {\n const parentData = parents.get(el);\n\n const newData = addClass(el, className, parentData, omitAppendPrivateClass);\n\n if (!newData) continue;\n\n parentSetter(el, newData as ParentData);\n }\n}\n\nexport function addClass(\n el: Node | HTMLElement | Element,\n className: string | undefined,\n data: NodeData | ParentData | undefined,\n omitAppendPrivateClass = false\n) {\n if (!className) return;\n\n const classNames = splitClass(className);\n\n if (!classNames.length) return;\n\n if (classNames.includes(\"longPress\")) return;\n\n if (!data) {\n el.classList.add(...classNames);\n\n return;\n }\n\n const privateClasses = [];\n\n for (const className of classNames) {\n if (!el.classList.contains(className)) {\n el.classList.add(className);\n } else if (\n el.classList.contains(className) &&\n omitAppendPrivateClass === false\n ) {\n privateClasses.push(className);\n }\n }\n\n data.privateClasses = privateClasses;\n\n return data;\n}\n\nexport function removeClass(\n els: Array,\n className: string | undefined\n) {\n if (!className) return;\n\n const classNames = splitClass(className);\n\n if (!classNames.length) return;\n\n for (const node of els) {\n if (!isNode(node)) {\n node.classList.remove(...classNames);\n continue;\n }\n\n const nodeData = nodes.get(node) || parents.get(node);\n\n if (!nodeData) continue;\n\n for (const className of classNames) {\n if (!nodeData.privateClasses.includes(className)) {\n node.classList.remove(className);\n }\n }\n }\n}\n\nfunction isScrollable(element: HTMLElement) {\n if (element === document.documentElement) {\n return (\n element.scrollHeight > element.clientHeight ||\n element.scrollWidth > element.clientWidth\n );\n }\n\n const style = window.getComputedStyle(element);\n\n return (\n ((style.overflowY === \"auto\" || style.overflowY === \"scroll\") &&\n element.scrollHeight > element.clientHeight) ||\n ((style.overflowX === \"auto\" || style.overflowX === \"scroll\") &&\n element.scrollWidth > element.clientWidth)\n );\n}\n\n/**\n * Used for getting the closest scrollable parent of a given element.\n *\n * @param node - The parent element to start the search from.\n *\n * @returns The closest scrollable parent or the document's root element.\n *\n * @internal\n */\nexport function getScrollables(): Array {\n return Array.from(document.querySelectorAll(\"*\")).filter(\n (el) => el instanceof HTMLElement && isScrollable(el)\n ) as Array;\n}\n\nexport function getElFromPoint(coordinates: {\n x: number;\n y: number;\n}): NodeFromPoint | ParentFromPoint | undefined {\n let target = document.elementFromPoint(coordinates.x, coordinates.y);\n\n if (!isNode(target)) return;\n\n let isParent;\n\n let invalidEl = true;\n\n while (target && invalidEl) {\n if (nodes.has(target as Node) || parents.has(target as HTMLElement)) {\n invalidEl = false;\n\n isParent = parents.has(target as HTMLElement);\n\n break;\n }\n\n target = target.parentNode as Node;\n }\n\n if (!isParent) {\n const targetNodeData = nodes.get(target as Node);\n\n if (!targetNodeData) return;\n\n const targetParentData = parents.get(target.parentNode as Node);\n\n if (!targetParentData) return;\n\n return {\n node: {\n el: target as Node,\n data: targetNodeData,\n },\n parent: {\n el: target.parentNode as Node,\n data: targetParentData as ParentData,\n },\n };\n } else {\n const parentData = parents.get(target as HTMLElement);\n\n if (!parentData) return;\n\n return {\n parent: {\n el: target as HTMLElement,\n data: parentData as ParentData,\n },\n };\n }\n}\n\n/**\n * Checks to see that a given element and its parent node are instances of\n * HTML Elements.\n *\n * @param {unknown} el - The element to check.\n *\n * @returns {boolean} - Whether or not provided element is of type Node.\n */\nexport function isNode(el: unknown): el is Node {\n return el instanceof HTMLElement && el.parentNode instanceof HTMLElement;\n}\n\n/**\n * Takes a given el and event handlers, assigns them, and returns the used abort\n * controller.\n *\n * @param el - The element to add the event listeners to.\n * @param events - The events to add to the element.\n * @returns - The abort controller used for the event listeners.\n */\nexport function addEvents(\n el: Document | ShadowRoot | Node | HTMLElement,\n events: EventHandlers | any\n): AbortController {\n const abortController = new AbortController();\n\n for (const eventName in events) {\n const handler = events[eventName];\n\n el.addEventListener(eventName, handler, {\n signal: abortController.signal,\n passive: false,\n });\n }\n\n return abortController;\n}\n\nexport function copyNodeStyle(\n sourceNode: HTMLElement,\n targetNode: HTMLElement,\n omitKeys = false\n) {\n const computedStyle = window.getComputedStyle(sourceNode);\n\n const omittedKeys = [\n \"position\",\n \"z-index\",\n \"top\",\n \"left\",\n \"x\",\n \"pointer-events\",\n \"y\",\n \"transform-origin\",\n \"filter\",\n \"-webkit-text-fill-color\",\n ];\n\n for (const key of Array.from(computedStyle)) {\n if (omitKeys === false && key && omittedKeys.includes(key)) continue;\n\n targetNode.style.setProperty(\n key,\n computedStyle.getPropertyValue(key),\n computedStyle.getPropertyPriority(key)\n );\n }\n\n for (const child of Array.from(sourceNode.children)) {\n if (!isNode(child)) continue;\n\n const targetChild = targetNode.children[\n Array.from(sourceNode.children).indexOf(child)\n ] as Node;\n\n copyNodeStyle(child, targetChild, omitKeys);\n }\n}\n\nexport function eventCoordinates(data: DragEvent | PointerEvent) {\n return { x: data.clientX, y: data.clientY };\n}\n\nexport function getRealCoords(el: HTMLElement): Coordinates {\n const { top, bottom, left, right, height, width } =\n el.getBoundingClientRect();\n\n const scrollLeft = window.scrollX || document.documentElement.scrollLeft;\n const scrollTop = window.scrollY || document.documentElement.scrollTop;\n\n const adjustedTop = top + scrollTop;\n const adjustedBottom = bottom + scrollTop;\n const adjustedLeft = left + scrollLeft;\n const adjustedRight = right + scrollLeft;\n\n return {\n top: adjustedTop,\n bottom: adjustedBottom,\n left: adjustedLeft,\n right: adjustedRight,\n height,\n width,\n };\n}\n","import type { SetupNodeData, Node } from \"../../types\";\nimport type { AnimationsConfig } from \"./types\";\nimport { state, parents, isDragState } from \"../../index\";\n\nexport function animations(animationsConfig: Partial = {}) {\n const slideUp = [\n {\n transform: `translateY(${animationsConfig.yScale || 50}%)`,\n },\n {\n transform: `translateY(${animationsConfig.yScale || 0}%)`,\n },\n ];\n\n const slideDown = [\n {\n transform: `translateY(-${animationsConfig.yScale || 50}%)`,\n },\n {\n transform: `translateY(${animationsConfig.yScale || 0}%)`,\n },\n ];\n\n const slideLeft = [\n {\n transform: `translateX(${animationsConfig.xScale || 50}%)`,\n },\n {\n transform: `translateX(${animationsConfig.xScale || 0}%)`,\n },\n ];\n\n const slideRight = [\n {\n transform: `translateX(-${animationsConfig.xScale || 50}%)`,\n },\n {\n transform: `translateX(${animationsConfig.xScale || 0}%)`,\n },\n ];\n return (parent: HTMLElement) => {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n return {\n setup() {\n if (document.head.querySelector(\"[data-drag-and-drop]\")) return;\n },\n\n setupNodeRemap(data: SetupNodeData) {\n if (!isDragState(state)) return;\n\n const duration = animationsConfig.duration || 150;\n\n if (data.node.data.value === state.draggedNode.data.value) {\n switch (state.incomingDirection) {\n case \"below\":\n animate(data.node.el, slideUp, duration);\n\n break;\n case \"above\":\n animate(data.node.el, slideDown, duration);\n\n break;\n case \"left\":\n animate(data.node.el, slideRight, duration);\n\n break;\n case \"right\":\n animate(data.node.el, slideLeft, duration);\n\n break;\n }\n\n return;\n }\n\n if (\n !state.affectedNodes\n .map((x) => x.data.value)\n .includes(data.node.data.value)\n )\n return;\n\n const nodeRect = data.node.el.getBoundingClientRect();\n\n const nodeIndex = state.affectedNodes.findIndex(\n (x) => x.data.value === data.node.data.value\n );\n\n const draggedNodeIndex = state.draggedNode.data.index;\n\n const ascendingDirection = draggedNodeIndex >= state.targetIndex;\n\n let adjacentNode;\n\n if (ascendingDirection) {\n adjacentNode = state.affectedNodes[nodeIndex + 1]\n ? state.affectedNodes[nodeIndex + 1]\n : state.affectedNodes[nodeIndex - 1];\n } else {\n adjacentNode = state.affectedNodes[nodeIndex - 1]\n ? state.affectedNodes[nodeIndex - 1]\n : state.affectedNodes[nodeIndex + 1];\n }\n\n if (adjacentNode) {\n const xDiff = Math.abs(\n nodeRect.x - adjacentNode.el.getBoundingClientRect().x\n );\n\n const yDiff = Math.abs(\n nodeRect.y - adjacentNode.el.getBoundingClientRect().y\n );\n\n if (xDiff > yDiff && ascendingDirection) {\n animate(data.node.el, slideRight, duration);\n } else if (xDiff > yDiff && !ascendingDirection) {\n animate(data.node.el, slideLeft, duration);\n }\n } else {\n switch (state.incomingDirection) {\n case \"below\":\n animate(data.node.el, slideDown, duration);\n\n break;\n case \"above\":\n animate(data.node.el, slideUp, duration);\n\n break;\n case \"left\":\n animate(data.node.el, slideLeft, duration);\n\n break;\n case \"right\":\n animate(data.node.el, slideRight, duration);\n\n break;\n }\n }\n },\n };\n };\n}\n\nfunction animate(\n node: Node,\n animation: Keyframe[] | PropertyIndexedKeyframes,\n duration: number\n) {\n if (!state) return;\n\n state.preventEnter = true;\n\n node.animate(animation, {\n duration: duration,\n easing: \"ease-in-out\",\n });\n\n setTimeout(() => {\n if (!state) return;\n\n state.preventEnter = false;\n }, duration);\n}\n","import type { InsertionConfig, InsertionParentConfig } from \"./types\";\nimport type {\n DragState,\n NodeDragEventData,\n NodeRecord,\n ParentEventData,\n NodePointerEventData,\n PointeroverParentEvent,\n ParentRecord,\n Coordinates,\n} from \"../../types\";\n\nimport {\n handleEnd as originalHandleEnd,\n parents,\n parentValues,\n setParentValues,\n state,\n addParentClass,\n isDragState,\n eventCoordinates,\n removeClass,\n getRealCoords,\n} from \"../../index\";\n\nexport const insertionState = {\n draggedOverNodes: Array>(),\n draggedOverParent: null as ParentRecord | null,\n targetIndex: 0,\n ascending: false,\n};\n\n// WIP: This is a work in progress and not yet fully functional\nexport function insertion(\n insertionConfig: Partial> = {}\n) {\n return (parent: HTMLElement) => {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n const insertionParentConfig = {\n ...parentData.config,\n insertionConfig: insertionConfig,\n } as InsertionParentConfig;\n\n return {\n teardown() {\n if (parentData.abortControllers.root) {\n parentData.abortControllers.root.abort();\n }\n },\n setup() {\n insertionParentConfig.handleDragoverNode =\n insertionConfig.handleDragoverNode || handleDragoverNode;\n\n insertionParentConfig.handlePointeroverParent =\n insertionConfig.handlePointeroverParent || handlePointeroverParent;\n\n insertionParentConfig.handlePointeroverNode =\n insertionConfig.handlePointeroverNode || handlePointeroverParent;\n\n insertionParentConfig.handleDragoverParent =\n insertionConfig.handleDragoverParent || handleDragoverParent;\n\n insertionParentConfig.handleEnd =\n insertionConfig.handleEnd || handleEnd;\n\n document.body.addEventListener(\"dragover\", checkPosition);\n\n document.body.addEventListener(\"pointermove\", checkPosition);\n\n const observer = new ResizeObserver(() => {\n defineRanges(parent);\n });\n\n observer.observe(parent);\n\n parentData.config = insertionParentConfig;\n\n state.on(\"dragStarted\", () => {\n console.log(\"drag started\");\n defineRanges(parent);\n });\n\n const insertionPointConfig = insertionConfig.insertionPoint || {};\n\n const div = document.createElement(insertionPointConfig.tag || \"div\");\n\n div.id = insertionPointConfig.id || \"insertion-point\";\n\n div.classList.add(\n ...(insertionPointConfig.classes || [\"insertion-point\"])\n );\n\n div.style.position = \"absolute\";\n\n div.style.display = \"none\";\n\n document.body.appendChild(div);\n\n window.addEventListener(\"scroll\", defineRanges.bind(null, parent));\n\n window.addEventListener(\"resize\", defineRanges.bind(null, parent));\n },\n\n remapFinished() {\n defineRanges(parent);\n },\n };\n };\n}\n\nfunction checkPosition(e: DragEvent | PointerEvent) {\n if (!isDragState(state)) return;\n\n const el = document.elementFromPoint(e.clientX, e.clientY);\n\n if (!(el instanceof HTMLElement)) return;\n\n if (!parents.has(el)) {\n const insertionPoint = document.getElementById(\"insertion-point\");\n\n if (insertionPoint && insertionPoint === el) return;\n\n if (insertionPoint) insertionPoint.style.display = \"none\";\n\n if (insertionState.draggedOverParent) {\n removeClass(\n [insertionState.draggedOverParent.el],\n insertionState.draggedOverParent.data.config.dropZoneClass\n );\n }\n\n insertionState.draggedOverNodes = [];\n\n insertionState.draggedOverParent = null;\n\n state.currentParent = state.initialParent;\n }\n}\n\nfunction ascendingVertical(\n nodeCoords: Coordinates,\n nextNodeCoords?: Coordinates\n) {\n const center = nodeCoords.top + nodeCoords.height / 2;\n\n if (!nextNodeCoords) {\n return {\n y: [center, center + nodeCoords.height / 2 + 10],\n x: [nodeCoords.left, nodeCoords.right],\n vertical: true,\n };\n }\n\n return {\n y: [\n center,\n nodeCoords.bottom + Math.abs(nodeCoords.bottom - nextNodeCoords.top) / 2,\n ],\n x: [nodeCoords.left, nodeCoords.right],\n vertical: true,\n };\n}\n\nfunction descendingVertical(\n nodeCoords: Coordinates,\n prevNodeCoords?: Coordinates\n) {\n const center = nodeCoords.top + nodeCoords.height / 2;\n\n if (!prevNodeCoords) {\n return {\n y: [center - nodeCoords.height / 2 - 10, center],\n x: [nodeCoords.left, nodeCoords.right],\n vertical: true,\n };\n }\n\n return {\n y: [\n prevNodeCoords.bottom +\n Math.abs(prevNodeCoords.bottom - nodeCoords.top) / 2,\n center,\n ],\n x: [nodeCoords.left, nodeCoords.right],\n vertical: true,\n };\n}\n\nfunction ascendingHorizontal(\n nodeCoords: Coordinates,\n nextNodeCoords?: Coordinates,\n lastInRow = false\n) {\n const center = nodeCoords.left + nodeCoords.width / 2;\n\n if (!nextNodeCoords) {\n return {\n x: [center, center + nodeCoords.width],\n y: [nodeCoords.top, nodeCoords.bottom],\n vertical: false,\n };\n }\n\n if (lastInRow) {\n return {\n x: [center, nodeCoords.right + 10],\n y: [nodeCoords.top, nodeCoords.bottom],\n vertical: false,\n };\n } else {\n const nextNodeCenter = nextNodeCoords.left + nextNodeCoords.width / 2;\n\n return {\n x: [center, center + Math.abs(center - nextNodeCenter) / 2],\n y: [nodeCoords.top, nodeCoords.bottom],\n vertical: false,\n };\n }\n}\n\nfunction descendingHorizontal(\n nodeCoords: Coordinates,\n prevNodeCoords?: Coordinates\n) {\n const center = nodeCoords.left + nodeCoords.width / 2;\n\n if (!prevNodeCoords) {\n return {\n x: [nodeCoords.left - 10, center],\n y: [nodeCoords.top, nodeCoords.bottom],\n vertical: false,\n };\n }\n\n return {\n x: [\n prevNodeCoords.right +\n Math.abs(prevNodeCoords.right - nodeCoords.left) / 2,\n center,\n ],\n y: [nodeCoords.top, nodeCoords.bottom],\n vertical: false,\n };\n}\n\nfunction defineRanges(parent: HTMLElement) {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n const enabledNodes = parentData.enabledNodes;\n\n enabledNodes.forEach((node, index) => {\n let aboveOrBelowPrevious = false;\n\n let aboveOrBelowAfter = false;\n\n let prevNodeCoords = undefined;\n\n let nextNodeCoords = undefined;\n\n if (enabledNodes[index - 1])\n prevNodeCoords = getRealCoords(enabledNodes[index - 1].el);\n\n if (enabledNodes[index + 1])\n nextNodeCoords = getRealCoords(enabledNodes[index + 1].el);\n\n const nodeCoords = getRealCoords(node.el);\n\n if (prevNodeCoords) {\n aboveOrBelowPrevious =\n nodeCoords.top > prevNodeCoords.bottom ||\n nodeCoords.bottom < prevNodeCoords.top;\n }\n\n if (nextNodeCoords) {\n aboveOrBelowAfter =\n nodeCoords.top > nextNodeCoords.bottom ||\n nodeCoords.bottom < nextNodeCoords.top;\n }\n\n const fullishWidth =\n parent.getBoundingClientRect().width * 0.8 < nodeCoords.width;\n\n if (!node.data.range) return;\n\n if (fullishWidth) {\n node.data.range.ascending = ascendingVertical(nodeCoords, nextNodeCoords);\n node.data.range.descending = descendingVertical(\n nodeCoords,\n prevNodeCoords\n );\n } else if (aboveOrBelowAfter && !aboveOrBelowPrevious) {\n node.data.range.ascending = ascendingHorizontal(\n nodeCoords,\n nextNodeCoords,\n true\n );\n node.data.range.descending = descendingHorizontal(\n nodeCoords,\n prevNodeCoords\n );\n } else if (!aboveOrBelowPrevious && !aboveOrBelowAfter) {\n node.data.range.ascending = ascendingHorizontal(\n nodeCoords,\n nextNodeCoords\n );\n node.data.range.descending = descendingHorizontal(\n nodeCoords,\n prevNodeCoords\n );\n } else if (aboveOrBelowPrevious && !nextNodeCoords) {\n node.data.range.ascending = ascendingHorizontal(nodeCoords);\n } else if (aboveOrBelowPrevious && !aboveOrBelowAfter) {\n node.data.range.ascending = ascendingHorizontal(\n nodeCoords,\n nextNodeCoords\n );\n\n node.data.range.descending = descendingHorizontal(nodeCoords);\n }\n });\n}\n\nexport function handleDragoverNode(data: NodeDragEventData) {\n data.e.preventDefault();\n}\n\nexport function handleDragoverParent(\n data: ParentEventData,\n state: DragState\n) {\n if (!insertionState) return;\n\n data.e.stopPropagation();\n\n data.e.preventDefault();\n\n const { x, y } = eventCoordinates(data.e as DragEvent | PointerEvent);\n\n // Get the client coordinates\n const clientX = x;\n const clientY = y;\n\n // Get the scroll positions\n const scrollLeft = window.scrollX || document.documentElement.scrollLeft;\n const scrollTop = window.scrollY || document.documentElement.scrollTop;\n\n // Calculate the coordinates relative to the entire document\n state.coordinates.x = clientX + scrollLeft;\n state.coordinates.y = clientY + scrollTop;\n\n const nestedParent = data.targetData.parent.data.nestedParent;\n\n let realTargetParent = data.targetData.parent;\n\n if (nestedParent) {\n const rect = nestedParent.el.getBoundingClientRect();\n\n if (state.coordinates.y > rect.top && state.coordinates.y < rect.bottom)\n realTargetParent = nestedParent;\n }\n\n realTargetParent.el === state.currentParent?.el\n ? moveBetween(realTargetParent)\n : moveOutside(realTargetParent, state);\n\n state.currentParent = realTargetParent;\n}\n\nexport function moveBetween(data: ParentRecord) {\n if (data.data.config.sortable === false) return;\n\n if (\n data.el === insertionState.draggedOverParent?.el &&\n insertionState.draggedOverParent.data.getValues(data.el).length === 0\n ) {\n return;\n } else if (insertionState.draggedOverParent?.el) {\n removeClass(\n [insertionState.draggedOverParent.el],\n insertionState.draggedOverParent.data.config.dropZoneClass\n );\n insertionState.draggedOverParent = null;\n }\n\n const foundRange = findClosest(data.data.enabledNodes);\n\n if (!foundRange) return;\n\n const position =\n foundRange[0].data.range![foundRange[1] as \"ascending\" | \"descending\"];\n\n if (!position) return;\n\n positionInsertionPoint(\n position,\n foundRange[1] === \"ascending\",\n foundRange[0]\n );\n}\n\nfunction moveOutside(data: ParentRecord, state: DragState) {\n if (data.el === state.currentParent.el) return false;\n\n const targetConfig = data.data.config;\n\n if (targetConfig.treeGroup && state.draggedNode.el.contains(data.el))\n return false;\n\n if (targetConfig.dropZone === false) return false;\n\n const initialParentConfig = state.initialParent.data.config;\n\n if (targetConfig.accepts) {\n return targetConfig.accepts(\n data,\n state.initialParent,\n state.currentParent,\n state\n );\n } else if (\n !targetConfig.group ||\n targetConfig.group !== initialParentConfig.group\n ) {\n return false;\n }\n\n const values = data.data.getValues(data.el);\n\n if (!values.length) {\n addParentClass([data.el], targetConfig.dropZoneClass);\n\n insertionState.draggedOverParent = data;\n\n const insertionPoint = document.getElementById(\"insertion-point\");\n\n if (insertionPoint) insertionPoint.style.display = \"none\";\n } else {\n removeClass([state.currentParent.el], targetConfig.dropZoneClass);\n\n const enabledNodes = data.data.enabledNodes;\n\n const foundRange = findClosest(enabledNodes);\n\n if (!foundRange) return;\n\n const position =\n foundRange[0].data.range![foundRange[1] as \"ascending\" | \"descending\"];\n\n if (!position) return;\n\n positionInsertionPoint(\n position,\n foundRange[1] === \"ascending\",\n foundRange[0]\n );\n }\n}\n\nfunction findClosest(enabledNodes: NodeRecord[]) {\n let foundRange: [NodeRecord, string] | null = null;\n\n for (let x = 0; x < enabledNodes.length; x++) {\n if (!isDragState(state) || !enabledNodes[x].data.range) continue;\n\n const ascending = enabledNodes[x].data.range!.ascending;\n\n const descending = enabledNodes[x].data.range!.descending;\n\n if (!ascending && !descending) continue;\n\n if (ascending) {\n if (\n state.coordinates.y > ascending.y[0] &&\n state.coordinates.y < ascending.y[1] &&\n state.coordinates.x > ascending.x[0] &&\n state.coordinates.x < ascending.x[1]\n ) {\n foundRange = [enabledNodes[x], \"ascending\"];\n\n return foundRange;\n }\n }\n\n if (descending) {\n if (\n state.coordinates.y > descending.y[0] &&\n state.coordinates.y < descending.y[1] &&\n state.coordinates.x > descending.x[0] &&\n state.coordinates.x < descending.x[1]\n ) {\n foundRange = [enabledNodes[x], \"descending\"];\n\n return foundRange;\n }\n }\n }\n}\n\nexport function handlePointeroverParent(\n data: PointeroverParentEvent,\n state: DragState\n) {\n if (!insertionState) return;\n\n data.detail.e.stopPropagation();\n\n const { x, y } = eventCoordinates(data.detail.e as PointerEvent);\n\n state.coordinates.y = y;\n\n state.coordinates.x = x;\n\n const nestedParent = data.detail.targetData.parent.data.nestedParent;\n\n let realTargetParent = data.detail.targetData.parent;\n\n if (nestedParent) {\n const rect = nestedParent.el.getBoundingClientRect();\n\n if (state.coordinates.y > rect.top && state.coordinates.y < rect.bottom)\n realTargetParent = nestedParent;\n }\n\n const enabledNodes = realTargetParent.data.enabledNodes;\n\n const foundRange = findClosest(enabledNodes);\n\n if (!foundRange) return;\n\n const position =\n foundRange[0].data.range![foundRange[1] as \"ascending\" | \"descending\"];\n\n positionInsertionPoint(\n position,\n foundRange[1] === \"ascending\",\n foundRange[0]\n );\n\n data.detail.targetData.parent.el === state.currentParent?.el\n ? moveBetween(realTargetParent)\n : moveOutside(realTargetParent, state);\n}\n\nfunction positionInsertionPoint(\n position: { x: number[]; y: number[]; vertical: boolean },\n ascending: boolean,\n node: NodeRecord\n) {\n if (!state) return;\n\n const div = document.getElementById(\"insertion-point\");\n\n if (!div) return;\n\n insertionState.draggedOverNodes = [node];\n\n if (position.vertical) {\n const topPosition =\n position.y[ascending ? 1 : 0] - div.getBoundingClientRect().height / 2;\n\n div.style.top = `${topPosition}px`;\n\n const leftCoordinate = position.x[0];\n\n const rightCoordinate = position.x[1];\n\n div.style.left = `${leftCoordinate}px`;\n\n div.style.right = `${rightCoordinate}px`;\n\n div.style.height = \"4px\";\n\n div.style.width = rightCoordinate - leftCoordinate + \"px\";\n } else {\n const leftPosition =\n position.x[ascending ? 1 : 0] - div.getBoundingClientRect().width / 2;\n div.style.left = `${leftPosition}px`;\n\n const topCoordinate = position.y[0];\n\n const bottomCoordinate = position.y[1];\n\n div.style.top = `${topCoordinate}px`;\n\n div.style.bottom = `${bottomCoordinate}px`;\n\n div.style.width = \"4px\";\n\n div.style.height = bottomCoordinate - topCoordinate + \"px\";\n }\n\n insertionState.targetIndex = node.data.index;\n\n insertionState.ascending = ascending;\n\n div.style.display = \"block\";\n}\n\nexport function handleParentDrop(_data: NodeDragEventData) {}\n\nexport function handleEnd(\n data: NodeDragEventData | NodePointerEventData,\n state: DragState\n) {\n data.e.stopPropagation();\n\n const insertionPoint = document.getElementById(\"insertion-point\");\n\n if (!insertionState.draggedOverParent) {\n const draggedParentValues = parentValues(\n state.initialParent.el,\n state.initialParent.data\n );\n\n const transferred = state.initialParent.el !== state.currentParent.el;\n\n const draggedValues = state.draggedNodes.map((node) => node.data.value);\n\n const enabledNodes = [...data.targetData.parent.data.enabledNodes];\n\n const originalIndex = state.draggedNodes[0].data.index;\n\n if (\n !transferred &&\n insertionState.draggedOverNodes[0] &&\n insertionState.draggedOverNodes[0].el !== state.draggedNodes[0].el\n ) {\n const newParentValues = [\n ...draggedParentValues.filter((x) => !draggedValues.includes(x)),\n ];\n\n let index = insertionState.draggedOverNodes[0].data.index;\n\n if (\n insertionState.targetIndex > state.draggedNodes[0].data.index &&\n !insertionState.ascending\n ) {\n index--;\n } else if (\n insertionState.targetIndex < state.draggedNodes[0].data.index &&\n insertionState.ascending\n ) {\n index++;\n }\n\n newParentValues.splice(index, 0, ...draggedValues);\n\n setParentValues(data.targetData.parent.el, data.targetData.parent.data, [\n ...newParentValues,\n ]);\n\n if (data.targetData.parent.data.config.onSort) {\n const sortEventData = {\n parent: {\n el: data.targetData.parent.el,\n data: data.targetData.parent.data,\n },\n previousValues: [...draggedParentValues],\n previousNodes: [...enabledNodes],\n nodes: [...data.targetData.parent.data.enabledNodes],\n values: [...newParentValues],\n draggedNode: state.draggedNode,\n previousPosition: originalIndex,\n position: index,\n };\n\n data.targetData.parent.data.config.onSort(sortEventData);\n }\n } else if (transferred && insertionState.draggedOverNodes.length) {\n const targetParentValues = parentValues(\n state.currentParent.el,\n state.currentParent.data\n );\n const draggedParentValues = parentValues(\n state.initialParent.el,\n state.initialParent.data\n );\n\n // For the time being, we will not be remoing the value of the original dragged parent.\n let index = insertionState.draggedOverNodes[0].data.index || 0;\n\n if (insertionState.ascending) index++;\n\n const insertValues = state.dynamicValues.length\n ? state.dynamicValues\n : draggedValues;\n targetParentValues.splice(index, 0, ...insertValues);\n setParentValues(state.currentParent.el, state.currentParent.data, [\n ...targetParentValues,\n ]);\n draggedParentValues.splice(state.initialIndex, draggedValues.length);\n setParentValues(state.initialParent.el, state.initialParent.data, [\n ...draggedParentValues,\n ]);\n\n const transferEventData = {\n sourceParent: state.currentParent,\n targetParent: data.targetData.parent,\n initialParent: state.initialParent,\n draggedNodes: state.draggedNodes,\n targetIndex: index,\n state,\n };\n if (data.targetData.parent.data.config.onTransfer)\n data.targetData.parent.data.config.onTransfer(transferEventData);\n if (state.currentParent.data.config.onTransfer)\n state.currentParent.data.config.onTransfer(transferEventData);\n }\n } else if (insertionState.draggedOverParent) {\n const draggedOverParentValues = parentValues(\n insertionState.draggedOverParent.el,\n insertionState.draggedOverParent.data\n );\n\n const draggedValues = state.draggedNodes.map((node) => node.data.value);\n\n const insertValues = state.dynamicValues.length\n ? state.dynamicValues\n : draggedValues;\n\n draggedOverParentValues.push(...insertValues);\n\n setParentValues(\n insertionState.draggedOverParent.el,\n insertionState.draggedOverParent.data,\n [...draggedOverParentValues]\n );\n\n const transferEventData = {\n sourceParent: state.currentParent,\n targetParent: insertionState.draggedOverParent,\n initialParent: state.initialParent,\n draggedNodes: state.draggedNodes,\n targetIndex: draggedOverParentValues.length - 1,\n state,\n };\n if (data.targetData.parent.data.config.onTransfer)\n data.targetData.parent.data.config.onTransfer(transferEventData);\n if (state.currentParent.data.config.onTransfer)\n state.currentParent.data.config.onTransfer(transferEventData);\n\n removeClass(\n [insertionState.draggedOverParent.el],\n insertionState.draggedOverParent.data.config.dropZoneClass\n );\n }\n\n if (insertionPoint) insertionPoint.style.display = \"none\";\n\n const dropZoneClass =\n \"clonedDraggedNode\" in state\n ? data.targetData.parent.data.config.synthDropZoneClass\n : data.targetData.parent.data.config.dropZoneClass;\n\n removeClass(\n insertionState.draggedOverNodes.map((node) => node.el),\n dropZoneClass\n );\n\n const dragPlaceholderClass =\n data.targetData.parent.data.config.dragPlaceholderClass;\n\n removeClass(\n state.draggedNodes.map((node) => node.el),\n dragPlaceholderClass\n );\n\n insertionState.draggedOverNodes = [];\n\n originalHandleEnd(data, state);\n}\n","import type {\n NodeDragEventData,\n ParentConfig,\n DragState,\n SynthDragState,\n NodeRecord,\n PointeroverNodeEvent,\n ParentDragEventData,\n PointeroverParentEvent,\n} from \"../../types\";\nimport {\n parents,\n parentValues,\n setParentValues,\n addNodeClass,\n isSynthDragState,\n removeClass,\n addClass,\n state,\n isDragState,\n} from \"../../index\";\n\nexport const placeState = {\n draggedOverNodes: Array>(),\n};\n\nlet dragoverEventListeneerSet = false;\n\ninterface PlaceConfig extends ParentConfig {}\n\nexport function place(placeConfig: Partial> = {}) {\n return (parent: HTMLElement) => {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n const placeParentConfig = {\n ...parentData.config,\n placeConfig: placeConfig,\n } as PlaceConfig;\n\n if (!dragoverEventListeneerSet) {\n document.addEventListener(\"dragover\", rootDragover);\n document.addEventListener(\n \"handleRootPointerover\" as keyof DocumentEventMap,\n (e) => rootPointerover(e as CustomEvent)\n );\n }\n\n return {\n setup() {\n placeParentConfig.handleNodeDragover =\n placeConfig.handleNodeDragover || handleDragoverNode;\n\n placeParentConfig.handleParentDragover =\n placeConfig.handleParentDragover || handleDragoverParent;\n\n placeParentConfig.handleNodePointerover =\n placeConfig.handleNodePointerover || handleNodePointerover;\n\n placeParentConfig.handleParentPointerover =\n placeConfig.handleParentPointerover || handlePointeroverParent;\n\n const originalHandleend = placeParentConfig.handleEnd;\n placeParentConfig.handleEnd = (state) => {\n handleEnd(state);\n\n originalHandleend(state);\n };\n\n parentData.config = placeParentConfig;\n },\n };\n };\n}\n\nfunction rootDragover(_e: DragEvent) {\n if (!isDragState(state)) return;\n\n removeClass(\n [state.currentParent.el],\n state.currentParent.data.config.dropZoneParentClass\n );\n}\n\nfunction rootPointerover(_e: CustomEvent) {\n if (!isSynthDragState(state)) return;\n\n removeClass(\n [state.currentParent.el],\n state.currentParent.data.config.synthDropZoneParentClass\n );\n}\n\nfunction updateDraggedOverNodes(\n data: PointeroverNodeEvent | NodeDragEventData,\n state: DragState | SynthDragState\n) {\n const targetData =\n \"detail\" in data ? data.detail.targetData : data.targetData;\n\n const config = targetData.parent.data.config;\n\n const dropZoneClass = isSynthDragState(state)\n ? config.synthDropZoneClass\n : config.dropZoneClass;\n\n removeClass(\n placeState.draggedOverNodes.map((node) => node.el),\n dropZoneClass\n );\n\n const enabledNodes = targetData.parent.data.enabledNodes;\n\n if (!enabledNodes) return;\n\n placeState.draggedOverNodes = enabledNodes.slice(\n targetData.node.data.index,\n targetData.node.data.index + state.draggedNodes.length\n );\n\n addNodeClass(\n placeState.draggedOverNodes.map((node) => node.el),\n dropZoneClass,\n true\n );\n\n state.currentTargetValue = targetData.node.data.value;\n\n state.currentParent = targetData.parent;\n\n addClass(\n state.currentParent.el,\n isSynthDragState(state)\n ? config.synthDropZoneParentClass\n : config.dropZoneParentClass,\n state.currentParent.data,\n true\n );\n}\n\nfunction handleDragoverNode(\n data: NodeDragEventData,\n state: DragState\n) {\n data.e.preventDefault();\n\n data.e.stopPropagation();\n\n updateDraggedOverNodes(data, state);\n}\n\nexport function handleDragoverParent(\n data: ParentDragEventData,\n state: DragState\n) {\n data.e.preventDefault();\n\n data.e.stopPropagation();\n\n const currentConfig = state.currentParent.data.config;\n\n removeClass(\n placeState.draggedOverNodes.map((node) => node.el),\n currentConfig.dropZoneClass\n );\n\n removeClass([state.currentParent.el], currentConfig.dropZoneParentClass);\n\n const config = data.targetData.parent.data.config;\n\n addClass(\n data.targetData.parent.el,\n config.dropZoneParentClass,\n data.targetData.parent.data,\n true\n );\n\n placeState.draggedOverNodes = [];\n\n state.currentParent = data.targetData.parent;\n}\n\nexport function handlePointeroverParent(data: PointeroverParentEvent) {\n const currentConfig = data.detail.state.currentParent.data.config;\n\n removeClass(\n placeState.draggedOverNodes.map((node) => node.el),\n currentConfig.synthDropZoneClass\n );\n\n removeClass(\n [data.detail.state.currentParent.el],\n currentConfig.synthDropZoneParentClass\n );\n\n const config = data.detail.targetData.parent.data.config;\n\n addClass(\n data.detail.targetData.parent.el,\n config.synthDropZoneParentClass,\n data.detail.targetData.parent.data,\n true\n );\n\n placeState.draggedOverNodes = [];\n}\n\nfunction handleNodePointerover(data: PointeroverNodeEvent) {\n if (!isSynthDragState(data.detail.state)) return;\n\n updateDraggedOverNodes(data, data.detail.state);\n}\n\nfunction handleEnd(state: DragState | SynthDragState) {\n const isSynth = isSynthDragState(state);\n\n removeClass(\n [state.currentParent.el],\n isSynth\n ? state.currentParent.data.config.synthDropZoneParentClass\n : state.currentParent.data.config.dropZoneParentClass\n );\n\n const values = parentValues(state.currentParent.el, state.currentParent.data);\n\n const draggedValues = state.draggedNodes.map((node) => node.data.value);\n\n const newValues = values.filter((x) => !draggedValues.includes(x));\n\n const index = placeState.draggedOverNodes[0]?.data.index;\n\n // If we do not have dragged over nodes, then we know that we are appending\n // items to the end of the list/\n index !== undefined\n ? newValues.splice(index, 0, ...draggedValues)\n : newValues.push(...draggedValues);\n\n if (state.initialParent.el !== state.currentParent.el) {\n const initialParentValues = parentValues(\n state.initialParent.el,\n state.initialParent.data\n );\n\n const newInitialValues = initialParentValues.filter(\n (x) => !draggedValues.includes(x)\n );\n\n setParentValues(\n state.initialParent.el,\n state.initialParent.data,\n newInitialValues\n );\n } else if (\n state.initialParent.el === state.currentParent.el &&\n placeState.draggedOverNodes.length\n ) {\n setParentValues(\n state.currentParent.el,\n state.currentParent.data,\n newValues\n );\n }\n\n removeClass(\n placeState.draggedOverNodes.map((node) => node.el),\n isSynth\n ? state.currentParent.data.config.synthDropZoneClass\n : state.currentParent.data.config.dropZoneClass\n );\n}\n","import type {\n NodeDragEventData,\n ParentConfig,\n NodeRecord,\n ParentEventData,\n PointeroverParentEvent,\n PointeroverNodeEvent,\n} from \"../../types\";\nimport {\n state,\n parents,\n addNodeClass,\n removeClass,\n isDragState,\n} from \"../../index\";\n\nexport const swapState = {\n draggedOverNodes: Array>(),\n};\n\ninterface SwapConfig extends ParentConfig {}\n\nexport function swap(swapConfig: Partial> = {}) {\n return (parent: HTMLElement) => {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n const swapParentConfig = {\n ...parentData.config,\n swapConfig: swapConfig,\n } as SwapConfig;\n\n return {\n setup() {\n swapParentConfig.handleDragoverParent =\n swapConfig.handleDragoverParent || handleDragoverParent;\n\n swapParentConfig.handleDragoverNode =\n swapConfig.handleDragoverNode || handleDragoverNode;\n\n swapParentConfig.handlePointeroverNode =\n swapConfig.handlePointeroverNode || handlePointeroverNode;\n\n swapParentConfig.handlePointeroverParent =\n swapConfig.handlePointeroverParent || handlePointeroverParent;\n\n parentData.config = swapParentConfig;\n },\n };\n };\n}\n\nfunction handleDragoverNode(data: NodeDragEventData) {\n data.e.preventDefault();\n}\n\nexport function handleDragoverParent(_data: ParentEventData) {}\n\nexport function handlePointeroverParent(_data: PointeroverParentEvent) {}\n\nfunction handlePointeroverNode(data: PointeroverNodeEvent) {\n if (!isDragState(state)) return;\n\n if (data.detail.targetData.parent.el !== state.currentParent.el) return;\n\n const dropZoneClass =\n data.detail.targetData.parent.data.config.synthDropZoneClass;\n\n removeClass(\n swapState.draggedOverNodes.map((node) => node.el),\n dropZoneClass\n );\n\n const enabledNodes = data.detail.targetData.parent.data.enabledNodes;\n\n swapState.draggedOverNodes = enabledNodes.slice(\n data.detail.targetData.node.data.index,\n data.detail.targetData.node.data.index + state.draggedNodes.length\n );\n\n addNodeClass(\n swapState.draggedOverNodes.map((node) => node.el),\n dropZoneClass,\n true\n );\n\n state.currentTargetValue = data.detail.targetData.node.data.value;\n\n state.currentParent = data.detail.targetData.parent as any;\n}\n//function handleEnd(data: NodeDragEventData | NodePointerEventData) {\n// if (!state) return;\n\n// if (!state.transferred) {\n// const draggedParentValues = parentValues(\n// state.initialParent.el,\n// state.initialParent.data\n// );\n\n// let targetParentValues = parentValues(\n// state.lastParent.el,\n// state.lastParent.data\n// );\n\n// const draggedValues = state.draggedNodes.map((node) => node.data.value);\n\n// const draggedOverNodeValues = swapState.draggedOverNodes.map(\n// (node) => node.data.value\n// );\n\n// const draggedIndex = state.draggedNodes[0].data.index;\n\n// const draggedOverIndex = swapState.draggedOverNodes[0].data.index;\n\n// targetParentValues.splice(\n// draggedOverIndex,\n// draggedValues.length,\n// ...draggedValues\n// );\n\n// if (state.initialParent.el === state.lastParent.el) {\n// targetParentValues.splice(\n// draggedIndex,\n// draggedValues.length,\n// ...draggedOverNodeValues\n// );\n\n// setParentValues(state.initialParent.el, state.initialParent.data, [\n// ...targetParentValues,\n// ]);\n// } else {\n// draggedParentValues.splice(\n// draggedIndex,\n// draggedValues.length,\n// ...draggedOverNodeValues\n// );\n\n// setParentValues(state.lastParent.el, state.lastParent.data, [\n// ...targetParentValues,\n// ]);\n\n// setParentValues(state.initialParent.el, state.initialParent.data, [\n// ...draggedParentValues,\n// ]);\n// }\n// }\n\n// const dropZoneClass =\n// \"clonedDraggedNode\" in state\n// ? data.targetData.parent.data.config.touchDropZoneClass\n// : data.targetData.parent.data.config.dropZoneClass;\n\n// removeClass(\n// swapState.draggedOverNodes.map((node) => node.el),\n// dropZoneClass\n// );\n\n// originalHandleEnd(data);\n//}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIO,SAAS,WAAW,mBAA8C,CAAC,GAAG;AAC3E,QAAM,UAAU;AAAA,IACd;AAAA,MACE,WAAW,cAAc,iBAAiB,UA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AAiB,SAAS;AAChC,QAAM,eAAe,OAAO;AAC5B,QAAM,gBAAgB,QAAQ;AAE9B,SAAO;AAAA,IACL,KAAK;AAAA,IACL,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,OAAO;AAAA,IACP;AAAA,IACA;AAAA,EACF;AACF;","names":["handleNodePointerover","handleEnd","state","handleEnd","state","draggedParentValues","handleDragoverNode","handleDragoverParent","handlePointeroverParent","state","handleEnd","handleDragoverParent","handleDragoverNode","handlePointeroverParent","emit","on","baseDragState","dragStateProps","handleNodePointerover","draggedNodes","state","nodes","parent","x","className"]} \ No newline at end of file +{"version":3,"sources":["../src/index.ts","../src/plugins/animations/index.ts","../src/plugins/insertion/index.ts","../src/plugins/place/index.ts","../src/plugins/swap/index.ts"],"sourcesContent":["import type {\n DNDPlugin,\n DragAndDrop,\n DragState,\n DragStateProps,\n Node,\n NodeData,\n NodeDragEventData,\n NodeEventData,\n NodePointerEventData,\n NodeRecord,\n NodeTargetData,\n NodesData,\n ParentConfig,\n ParentData,\n ParentEventData,\n ParentTargetData,\n ParentsData,\n PointeroverNodeEvent,\n PointeroverParentEvent,\n ScrollData,\n SetupNodeData,\n TearDownNodeData,\n BaseDragState,\n SynthDragState,\n ParentKeydownEventData,\n SynthDragStateProps,\n ParentRecord,\n EventHandlers,\n NodeFromPoint,\n ParentFromPoint,\n Coordinates,\n} from \"./types\";\n\nexport * from \"./types\";\nexport { animations } from \"./plugins/animations\";\nexport { insertion } from \"./plugins/insertion\";\nexport { place } from \"./plugins/place\";\nexport { swap } from \"./plugins/swap\";\n\n/**\n * Check to see if code is running in a browser.\n *\n * @internal\n */\nexport const isBrowser = typeof window !== \"undefined\";\n\nexport const touchDevice = window && \"ontouchstart\" in window;\n\nlet dropped = false;\n\n/**\n * Abort controller for the document.\n */\nlet documentController: AbortController | undefined;\n\nlet isNative = false;\n\nlet animationFrameId: number | null = null;\n\nconst scrollConfig: {\n [key: string]: [number, number];\n} = {\n up: [0, -1],\n down: [0, 1],\n left: [-1, 0],\n right: [1, 0],\n};\n\nexport const nodes: NodesData = new WeakMap>();\n\nexport const parents: ParentsData = new WeakMap<\n HTMLElement,\n ParentData\n>();\n\nexport const treeAncestors: Record = {};\n\nlet synthNodePointerDown = false;\n\nexport function createEmitter() {\n const callbacks = new Map();\n\n const emit = function (eventName: string, data: any) {\n if (!callbacks.get(eventName)) return;\n callbacks.get(eventName)!.forEach((cb) => {\n cb(data);\n });\n };\n\n const on = function (eventName: string, callback: any) {\n const cbs = callbacks.get(eventName) ?? [];\n\n cbs.push(callback);\n\n callbacks.set(eventName, cbs);\n };\n\n return [emit, on];\n}\n\nexport const [emit, on] = createEmitter();\n\nconst baseDragState = {\n activeDescendant: undefined,\n affectedNodes: [],\n currentTargetValue: undefined,\n on,\n emit,\n newActiveDescendant: undefined,\n originalZIndex: undefined,\n pointerSelection: false,\n preventEnter: false,\n remapJustFinished: false,\n selectednodes: [],\n selectedParent: undefined,\n};\n\n/**\n * The state of the drag and drop.\n */\nexport let state: BaseDragState = baseDragState;\n\nexport function resetState() {\n const baseDragState = {\n activeDescendant: undefined,\n affectedNodes: [],\n on,\n emit,\n currentTargetValue: undefined,\n originalZIndex: undefined,\n pointerId: undefined,\n preventEnter: false,\n remapJustFinished: false,\n selectednodes: [],\n selectedParent: undefined,\n pointerSelection: false,\n synthScrollDirection: undefined,\n draggedNodeDisplay: undefined,\n synthDragScrolling: false,\n };\n\n state = { ...baseDragState } as BaseDragState;\n}\n\n/**\n * @param {DragStateProps} dragStateProps - Attributes to update state with.\n *\n * @mutation - Updates state with node values.\n *\n * @returns void\n */\nexport function setDragState(\n dragStateProps:\n | (SynthDragStateProps & DragStateProps)\n | DragStateProps\n | undefined\n): DragState | SynthDragState {\n Object.assign(state, dragStateProps);\n\n dropped = false;\n\n state.emit(\"dragStarted\", state);\n\n return state as DragState | SynthDragState;\n}\n\n/**\n *\n */\nfunction handlePointerdownRoot(_e: PointerEvent) {\n if (state.activeState) setActive(state.activeState.parent, undefined, state);\n\n if (state.selectedState)\n deselect(state.selectedState.nodes, state.selectedState.parent, state);\n\n state.selectedState = state.activeState = undefined;\n}\n\nfunction handlePointerupRoot(_e: PointerEvent) {\n if (!isSynthDragState(state)) return;\n\n const config = state.currentParent.data.config;\n\n if (isSynthDragState(state)) config.handleEnd(state);\n}\n\n/**\n * Handles the keydown event on the root element.\n *\n * @param {KeyboardEvent} e - The keyboard event.\n */\nfunction handleRootKeydown(e: KeyboardEvent) {\n if (e.key === \"Escape\") {\n if (state.selectedState)\n deselect(state.selectedState.nodes, state.selectedState.parent, state);\n\n if (state.activeState)\n setActive(state.activeState.parent, undefined, state);\n\n state.selectedState = state.activeState = undefined;\n }\n}\n\nfunction handleRootDrop(_e: DragEvent) {\n //e.preventDefault();\n}\n\n/**\n * If we are currently dragging, then let's prevent default on dragover to avoid\n * the default behavior of the browser on drop.\n */\nfunction handleRootDragover(e: DragEvent) {\n if (!isDragState(state)) return;\n\n e.preventDefault();\n}\n\n/**\n * Initializes the drag and drop functionality for a given parent.\n *\n * @param {DragAndDrop} dragAndDrop - The drag and drop configuration.\n *\n * @returns void\n */\nexport function dragAndDrop({\n parent,\n getValues,\n setValues,\n config = {},\n}: DragAndDrop): void {\n if (!isBrowser) return;\n\n if (!documentController)\n documentController = addEvents(document, {\n dragover: handleRootDragover,\n pointerdown: handlePointerdownRoot,\n pointerup: handlePointerupRoot,\n keydown: handleRootKeydown,\n drop: handleRootDrop,\n });\n\n tearDown(parent);\n\n const parentData: ParentData = {\n getValues,\n setValues,\n config: {\n dragDropEffect: config.dragDropEffect ?? \"move\",\n dragEffectAllowed: config.dragEffectAllowed ?? \"move\",\n draggedNodes,\n dragstartClasses,\n deepCopyStyles: config.deepCopyStyles ?? false,\n handleNodeKeydown,\n handleParentKeydown,\n handleDragstart,\n handleNodeDragover,\n handleParentDragover,\n handleNodeDrop,\n handleDragend,\n handleEnd,\n handleParentBlur,\n handleParentFocus,\n handleNodePointerup,\n handleNodeTouchstart,\n handleNodePointerover,\n handleParentPointerover,\n handleNodePointerdown,\n handleNodePointermove,\n handleNodeDragenter,\n handleNodeDragleave,\n handleParentDrop,\n multiDrag: config.multiDrag ?? false,\n nativeDrag: config.nativeDrag ?? true,\n performSort,\n performTransfer,\n root: config.root ?? document,\n setupNode,\n setupNodeRemap,\n reapplyDragClasses,\n tearDownNode,\n tearDownNodeRemap,\n remapFinished,\n scrollBehavior: {\n x: 0.95,\n y: 0.95,\n },\n threshold: {\n horizontal: 0,\n vertical: 0,\n },\n ...config,\n },\n enabledNodes: [],\n abortControllers: {},\n privateClasses: [],\n };\n\n const nodesObserver = new MutationObserver(nodesMutated);\n\n nodesObserver.observe(parent, { childList: true });\n\n parents.set(parent, parentData);\n\n if (config.treeAncestor && config.treeGroup)\n treeAncestors[config.treeGroup] = parent;\n\n config.plugins?.forEach((plugin) => {\n plugin(parent)?.tearDown?.();\n });\n\n config.plugins?.forEach((plugin) => {\n plugin(parent)?.tearDown?.();\n });\n\n config.plugins?.forEach((plugin: DNDPlugin) => {\n plugin(parent)?.setup?.();\n });\n\n setup(parent, parentData);\n\n remapNodes(parent, true);\n}\n\nexport function dragStateProps(\n data: NodeDragEventData | NodePointerEventData,\n draggedNodes: Array>,\n nativeDrag = true\n): DragStateProps {\n const { x, y } = eventCoordinates(data.e);\n\n const rect = data.targetData.node.el.getBoundingClientRect();\n\n const scrollEls: Array<[HTMLElement, AbortController]> = [];\n\n for (const scrollable of getScrollables()) {\n scrollEls.push([\n scrollable,\n nativeDrag\n ? addEvents(scrollable, {\n scroll: preventSortOnScroll(),\n })\n : addEvents(scrollable, {\n pointermove: handleScroll,\n }),\n ]);\n }\n\n return {\n affectedNodes: [],\n ascendingDirection: false,\n clonedDraggedEls: [],\n dynamicValues: [],\n coordinates: {\n x,\n y,\n },\n draggedNode: {\n el: data.targetData.node.el,\n data: data.targetData.node.data,\n },\n draggedNodes,\n incomingDirection: undefined,\n initialIndex: data.targetData.node.data.index,\n initialParent: {\n el: data.targetData.parent.el,\n data: data.targetData.parent.data,\n },\n currentParent: {\n el: data.targetData.parent.el,\n data: data.targetData.parent.data,\n },\n longPress: data.targetData.parent.data.config.longPress ?? false,\n longPressTimeout: 0,\n currentTargetValue: data.targetData.node.data.value,\n scrollEls,\n startLeft: x - rect.left,\n startTop: y - rect.top,\n targetIndex: data.targetData.node.data.index,\n transferred: false,\n };\n}\n\nexport function performSort({\n parent,\n draggedNodes,\n targetNode,\n}: {\n parent: ParentRecord;\n draggedNodes: Array>;\n targetNode: NodeRecord;\n}) {\n const draggedValues = draggedNodes.map((x) => x.data.value);\n\n const targetParentValues = parentValues(parent.el, parent.data);\n\n const originalIndex = draggedNodes[0].data.index;\n\n const enabledNodes = [...parent.data.enabledNodes];\n\n const newParentValues = [\n ...targetParentValues.filter((x) => !draggedValues.includes(x)),\n ];\n\n newParentValues.splice(targetNode.data.index, 0, ...draggedValues);\n\n if (\"draggedNode\" in state) state.currentTargetValue = targetNode.data.value;\n\n setParentValues(parent.el, parent.data, [...newParentValues]);\n\n if (parent.data.config.onSort)\n parent.data.config.onSort({\n parent: {\n el: parent.el,\n data: parent.data,\n },\n previousValues: [...targetParentValues],\n previousNodes: [...enabledNodes],\n nodes: [...parent.data.enabledNodes],\n values: [...newParentValues],\n draggedNode: draggedNodes[0],\n previousPosition: originalIndex,\n position: targetNode.data.index,\n });\n}\n\n/**\n * This function sets the active node as well as removing any classes or\n * attribute set.\n *\n * @param {ParentEventData} data - The parent event data.\n * @param {NodeRecord} newActiveNode - The new active node.\n * @param {BaseDragState} state - The current drag state.\n */\nfunction setActive(\n parent: ParentRecord,\n newActiveNode: NodeRecord | undefined,\n state: BaseDragState\n) {\n const activeDescendantClass = parent.data.config.activeDescendantClass;\n\n if (state.activeState) {\n {\n removeClass([state.activeState.node.el], activeDescendantClass);\n\n if (state.activeState.parent.el !== parent.el)\n state.activeState.parent.el.setAttribute(\"aria-activedescendant\", \"\");\n }\n }\n\n if (!newActiveNode) {\n state.activeState?.parent.el.setAttribute(\"aria-activedescendant\", \"\");\n\n state.activeState = undefined;\n\n return;\n }\n\n state.activeState = {\n node: newActiveNode,\n parent,\n };\n\n addNodeClass([newActiveNode.el], activeDescendantClass);\n\n state.activeState.parent.el.setAttribute(\n \"aria-activedescendant\",\n state.activeState.node.el.id\n );\n}\n\nfunction deselect(\n nodes: Array>,\n parent: ParentRecord,\n state: BaseDragState\n) {\n const selectedClass = parent.data.config.selectedClass;\n\n if (!state.selectedState) return;\n\n const iterativeNodes = Array.from(nodes);\n\n removeClass(\n nodes.map((x) => x.el),\n selectedClass\n );\n\n for (const node of iterativeNodes) {\n node.el.setAttribute(\"aria-selected\", \"false\");\n\n const index = state.selectedState.nodes.findIndex((x) => x.el === node.el);\n\n if (index === -1) continue;\n\n state.selectedState.nodes.splice(index, 1);\n }\n\n clearLiveRegion(parent);\n}\n\n/**\n * This function sets the selected nodes. This will clean the prior selected state\n * as well as removing any classes or attributes set.\n */\nfunction setSelected(\n parent: ParentRecord,\n selectedNodes: Array>,\n newActiveNode: NodeRecord | undefined,\n state: BaseDragState,\n pointerdown = false\n) {\n state.pointerSelection = pointerdown;\n\n for (const node of selectedNodes) {\n node.el.setAttribute(\"aria-selected\", \"true\");\n\n addNodeClass([node.el], parent.data.config.selectedClass, true);\n }\n\n state.selectedState = {\n nodes: selectedNodes,\n parent,\n };\n\n const selectedItems = selectedNodes.map((x) =>\n x.el.getAttribute(\"aria-label\")\n );\n\n if (selectedItems.length === 0) {\n state.selectedState = undefined;\n\n clearLiveRegion(parent);\n\n return;\n }\n\n setActive(parent, newActiveNode, state);\n\n updateLiveRegion(\n parent,\n `${selectedItems.join(\n \", \"\n )} ready for dragging. Use arrow keys to navigate. Press enter to drop ${selectedItems.join(\n \", \"\n )}.`\n );\n}\n\nfunction updateLiveRegion(parent: ParentRecord, message: string) {\n const parentId = parent.el.id;\n\n const liveRegion = document.getElementById(parentId + \"-live-region\");\n\n if (!liveRegion) return;\n\n liveRegion.textContent = message;\n}\n\nfunction clearLiveRegion(parent: ParentRecord) {\n const liveRegion = document.getElementById(parent.el.id + \"-live-region\");\n\n if (!liveRegion) return;\n\n liveRegion.textContent = \"\";\n}\n\nexport function handleParentBlur(\n _data: ParentEventData,\n _state: BaseDragState | DragState | SynthDragState\n) {}\n\nexport function handleParentFocus(\n data: ParentEventData,\n state: BaseDragState | DragState | SynthDragState\n) {\n const firstEnabledNode = data.targetData.parent.data.enabledNodes[0];\n\n if (!firstEnabledNode) return;\n\n if (\n state.selectedState &&\n state.selectedState.parent.el !== data.targetData.parent.el\n ) {\n setActive(data.targetData.parent, firstEnabledNode, state);\n } else if (!state.selectedState) {\n setActive(data.targetData.parent, firstEnabledNode, state);\n }\n}\n\nexport function performTransfer({\n currentParent,\n targetParent,\n initialParent,\n draggedNodes,\n initialIndex,\n targetNode,\n state,\n}: {\n currentParent: ParentRecord;\n targetParent: ParentRecord;\n initialParent: ParentRecord;\n draggedNodes: Array>;\n initialIndex: number;\n state: BaseDragState | DragState | SynthDragState;\n targetNode?: NodeRecord;\n}) {\n const draggedValues = draggedNodes.map((x) => x.data.value);\n\n const currentParentValues = parentValues(\n currentParent.el,\n currentParent.data\n ).filter((x: any) => !draggedValues.includes(x));\n\n const targetParentValues = parentValues(targetParent.el, targetParent.data);\n\n const reset =\n initialParent.el === targetParent.el &&\n targetParent.data.config.sortable === false;\n\n let targetIndex: number;\n\n if (targetNode) {\n if (reset) {\n targetIndex = initialIndex;\n } else if (targetParent.data.config.sortable === false) {\n targetIndex = targetParent.data.enabledNodes.length;\n } else {\n targetIndex = targetNode.data.index;\n }\n\n targetParentValues.splice(targetIndex, 0, ...draggedValues);\n } else {\n targetIndex = reset ? initialIndex : targetParent.data.enabledNodes.length;\n\n targetParentValues.splice(targetIndex, 0, ...draggedValues);\n }\n\n setParentValues(currentParent.el, currentParent.data, currentParentValues);\n\n setParentValues(targetParent.el, targetParent.data, targetParentValues);\n\n if (targetParent.data.config.onTransfer) {\n targetParent.data.config.onTransfer({\n sourceParent: currentParent,\n targetParent,\n initialParent,\n draggedNodes,\n targetIndex,\n state,\n });\n }\n\n if (currentParent.data.config.onTransfer) {\n currentParent.data.config.onTransfer({\n sourceParent: currentParent,\n targetParent,\n initialParent,\n draggedNodes,\n targetIndex,\n state,\n });\n }\n}\n\nexport function parentValues(\n parent: HTMLElement,\n parentData: ParentData\n): Array {\n return [...parentData.getValues(parent)];\n}\n\nfunction findArrayCoordinates(\n obj: any,\n targetArray: Array,\n path: Array = []\n) {\n let result: Array = [];\n\n if (obj === targetArray) result.push(path);\n\n if (Array.isArray(obj)) {\n const index = obj.findIndex((el) => el === targetArray);\n\n if (index !== -1) {\n result.push([...path, index]);\n } else {\n for (let i = 0; i < obj.length; i++) {\n result = result.concat(\n findArrayCoordinates(obj[i], targetArray, [...path, i])\n );\n }\n }\n } else if (typeof obj === \"object\" && obj !== null) {\n for (const key in obj) {\n result = result.concat(\n findArrayCoordinates(obj[key], targetArray, [...path, key])\n );\n }\n }\n\n return result;\n}\n\nfunction setValueAtCoordinatesUsingFindIndex(\n obj: Array,\n targetArray: Array,\n newArray: Array\n) {\n const coordinates = findArrayCoordinates(obj, targetArray);\n\n let newValues;\n\n coordinates.forEach((coords) => {\n let current = obj;\n for (let i = 0; i < coords.length - 1; i++) {\n const index = coords[i];\n current = current[index];\n }\n const lastIndex = coords[coords.length - 1];\n\n current[lastIndex] = newArray;\n\n // We want to access getter of object we are setting to set the new values\n // of the nested parent element (should be a part of the original structure of\n // ancestor values).\n newValues = current[lastIndex];\n });\n\n return newValues;\n}\n\nexport function setParentValues(\n parent: HTMLElement,\n parentData: ParentData,\n values: Array\n): void {\n const treeGroup = parentData.config.treeGroup;\n\n if (treeGroup) {\n const ancestorEl = treeAncestors[treeGroup];\n\n const ancestorData = parents.get(ancestorEl);\n\n if (!ancestorData) return;\n\n const ancestorValues = ancestorData.getValues(ancestorEl);\n\n const initialParentValues = parentData.getValues(parent);\n\n const updatedValues = setValueAtCoordinatesUsingFindIndex(\n ancestorValues,\n initialParentValues,\n values\n );\n\n if (!updatedValues) {\n console.warn(\"No updated value found\");\n\n return;\n }\n\n parentData.setValues(updatedValues, parent);\n\n return;\n }\n\n parentData.setValues(values, parent);\n}\n\nexport function dragValues(state: DragState): Array {\n return [...state.draggedNodes.map((x) => x.data.value)];\n}\n\n/**\n * Utility function to update parent config.\n */\nexport function updateConfig(\n parent: HTMLElement,\n config: Partial>\n) {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n parents.set(parent, {\n ...parentData,\n config: { ...parentData.config, ...config },\n });\n\n dragAndDrop({\n parent,\n getValues: parentData.getValues,\n setValues: parentData.setValues,\n config,\n });\n}\n\nexport function handleParentDrop(\n data: ParentEventData,\n state: DragState\n) {\n dropped = true;\n\n const config = data.targetData.parent.data.config;\n\n config.handleEnd(state);\n}\n\nexport function tearDown(parent: HTMLElement) {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n if (parentData.abortControllers.mainParent)\n parentData.abortControllers.mainParent.abort();\n}\n\nexport function isDragState(\n state: BaseDragState\n): state is DragState | SynthDragState {\n return \"draggedNode\" in state && !!state.draggedNode;\n}\n\nexport function isSynthDragState(\n state: BaseDragState\n): state is SynthDragState {\n return \"pointerId\" in state && !!state.pointerId;\n}\n\nfunction setup(parent: HTMLElement, parentData: ParentData): void {\n parentData.abortControllers.mainParent = addEvents(parent, {\n keydown: parentEventData(parentData.config.handleParentKeydown),\n dragover: parentEventData(parentData.config.handleParentDragover),\n handleParentPointerover: parentData.config.handleParentPointerover,\n drop: parentEventData(parentData.config.handleParentDrop),\n hasNestedParent: (e: CustomEvent) => {\n const parent = parents.get(e.target as HTMLElement);\n\n if (!parent) return;\n\n parent.nestedParent = e.detail.parent;\n },\n blur: parentEventData(parentData.config.handleParentBlur),\n focus: parentEventData(parentData.config.handleParentFocus),\n });\n\n setAttrs(parent, {\n role: \"listbox\",\n tabindex: \"0\",\n \"aria-multiselectable\": parentData.config.multiDrag ? \"true\" : \"false\",\n \"aria-activedescendant\": \"\",\n \"aria-describedby\": parent.id + \"-live-region\",\n });\n\n const liveRegion = document.createElement(\"div\");\n\n setAttrs(liveRegion, {\n \"aria-live\": \"polite\",\n \"aria-atomic\": \"true\",\n \"data-drag-and-drop-live-region\": \"true\",\n id: parent.id.toString() + \"-live-region\",\n });\n\n Object.assign(liveRegion.style, {\n position: \"absolute\",\n width: \"1px\",\n height: \"1px\",\n padding: \"0\",\n overflow: \"hidden\",\n clip: \"rect(0, 0, 0, 0)\",\n whiteSpace: \"nowrap\",\n border: \"0\",\n });\n\n document.body.appendChild(liveRegion);\n}\n\nexport function setAttrs(el: HTMLElement, attrs: Record) {\n for (const key in attrs) el.setAttribute(key, attrs[key]);\n}\n\nexport function setupNode(data: SetupNodeData) {\n const config = data.parent.data.config;\n\n data.node.el.draggable = true;\n\n data.node.data.abortControllers.mainNode = addEvents(data.node.el, {\n keydown: nodeEventData(config.handleNodeKeydown),\n dragstart: nodeEventData(config.handleDragstart),\n dragover: nodeEventData(config.handleNodeDragover),\n dragenter: nodeEventData(config.handleNodeDragenter),\n dragleave: nodeEventData(config.handleNodeDragleave),\n dragend: nodeEventData(config.handleDragend),\n drop: nodeEventData(config.handleNodeDrop),\n touchstart: nodeEventData(config.handleNodeTouchstart),\n pointercancel: nodeEventData(config.handleDragend),\n pointerdown: nodeEventData(config.handleNodePointerdown),\n pointerup: nodeEventData(config.handleNodePointerup),\n pointermove: nodeEventData(config.handleNodePointermove),\n handleNodePointerover: config.handleNodePointerover,\n mousedown: () => {\n if (!config.nativeDrag) isNative = false;\n else isNative = true;\n },\n });\n\n data.node.el.setAttribute(\"role\", \"option\");\n\n data.node.el.setAttribute(\"aria-selected\", \"false\");\n\n config.reapplyDragClasses(data.node.el, data.parent.data);\n\n data.parent.data.config.plugins?.forEach((plugin: DNDPlugin) => {\n plugin(data.parent.el)?.setupNode?.(data);\n });\n}\n\nexport function setupNodeRemap(data: SetupNodeData) {\n nodes.set(data.node.el, data.node.data);\n\n data.parent.data.config.plugins?.forEach((plugin: DNDPlugin) => {\n plugin(data.parent.el)?.setupNodeRemap?.(data);\n });\n}\n\nfunction reapplyDragClasses(node: Node, parentData: ParentData) {\n if (!isDragState(state)) return;\n\n const dropZoneClass = isSynthDragState(state)\n ? parentData.config.synthDropZoneClass\n : parentData.config.dropZoneClass;\n\n if (state.draggedNode.el !== node) return;\n\n addNodeClass([node], dropZoneClass, true);\n}\n\nexport function tearDownNodeRemap(data: TearDownNodeData) {\n data.parent.data.config.plugins?.forEach((plugin: DNDPlugin) => {\n plugin(data.parent.el)?.tearDownNodeRemap?.(data);\n });\n}\n\nexport function tearDownNode(data: TearDownNodeData) {\n data.parent.data.config.plugins?.forEach((plugin: DNDPlugin) => {\n plugin(data.parent.el)?.tearDownNode?.(data);\n });\n\n data.node.el.draggable = false;\n\n if (data.node.data?.abortControllers?.mainNode)\n data.node.data?.abortControllers?.mainNode.abort();\n}\n\n/**\n * Called when the nodes of a given parent element are mutated.\n *\n * @param mutationList - The list of mutations.\n *\n * @returns void\n *\n * @internal\n */\nfunction nodesMutated(mutationList: MutationRecord[]) {\n const parentEl = mutationList[0].target;\n\n if (!(parentEl instanceof HTMLElement)) return;\n\n const allSelectedAndActiveNodes = document.querySelectorAll(\n `[aria-selected=\"true\"]`\n );\n\n const parentData = parents.get(parentEl);\n\n if (!parentData) return;\n\n for (let x = 0; x < allSelectedAndActiveNodes.length; x++) {\n const node = allSelectedAndActiveNodes[x];\n\n node.setAttribute(\"aria-selected\", \"false\");\n\n removeClass([node], parentData.config.selectedClass);\n }\n\n remapNodes(parentEl);\n}\n\n/**\n * Remaps the data of the parent element's children.\n *\n * @param parent - The parent element.\n *\n * @returns void\n *\n * @internal\n */\nexport function remapNodes(parent: HTMLElement, force?: boolean) {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n parentData.privateClasses = Array.from(parent.classList);\n\n const enabledNodes: Array = [];\n\n const config = parentData.config;\n\n for (let x = 0; x < parent.children.length; x++) {\n const node = parent.children[x];\n\n if (!isNode(node)) continue;\n\n const nodeData = nodes.get(node);\n\n // Only tear down the node if we have explicitly called dragAndDrop\n if (force || !nodeData)\n config.tearDownNode({\n parent: {\n el: parent,\n data: parentData,\n },\n node: {\n el: node,\n data: nodeData,\n },\n });\n\n if (config.disabled) continue;\n\n if (!config.draggable || (config.draggable && config.draggable(node))) {\n enabledNodes.push(node);\n }\n }\n\n if (\n enabledNodes.length !== parentData.getValues(parent).length &&\n !config.disabled\n ) {\n console.warn(\n \"The number of draggable items defined in the parent element does not match the number of values. This may cause unexpected behavior.\"\n );\n\n return;\n }\n\n if (parentData.config.treeGroup && !parentData.config.treeAncestor) {\n let nextAncestorEl = parent.parentElement;\n\n let eventDispatched = false;\n\n while (nextAncestorEl) {\n if (!parents.has(nextAncestorEl as HTMLElement)) {\n nextAncestorEl = nextAncestorEl.parentElement;\n\n continue;\n }\n\n nextAncestorEl.dispatchEvent(\n new CustomEvent(\"hasNestedParent\", {\n detail: {\n parent: { data: parentData, el: parent },\n },\n })\n );\n\n eventDispatched = true;\n\n nextAncestorEl = null;\n }\n\n if (!eventDispatched) console.warn(\"No ancestor found for tree group\");\n }\n\n const values = parentData.getValues(parent);\n\n const enabledNodeRecords: Array> = [];\n\n for (let x = 0; x < enabledNodes.length; x++) {\n const node = enabledNodes[x];\n\n const prevNodeData = nodes.get(node);\n\n const nodeData = Object.assign(\n prevNodeData ?? {\n privateClasses: [],\n abortControllers: {},\n },\n {\n value: values[x],\n index: x,\n }\n );\n\n if (\n !isDragState(state) &&\n state.newActiveDescendant &&\n state.newActiveDescendant.data.value === nodeData.value\n ) {\n setActive(\n {\n data: parentData,\n el: parent,\n },\n {\n el: node,\n data: nodeData,\n },\n state\n );\n }\n\n if (\n !isDragState(state) &&\n state.activeState &&\n state.activeState.node.data.value === nodeData.value\n ) {\n setActive(\n {\n data: parentData,\n el: parent,\n },\n {\n el: node,\n data: nodeData,\n },\n state\n );\n }\n\n if (isDragState(state) && nodeData.value === state.draggedNode.data.value) {\n state.draggedNode.data = nodeData;\n\n state.draggedNode.el = node;\n const draggedNode = state.draggedNodes.find(\n (x) => x.data.value === nodeData.value\n );\n\n if (draggedNode) draggedNode.el = node;\n\n if (isSynthDragState(state))\n state.draggedNode.el.setPointerCapture(state.pointerId);\n }\n\n enabledNodeRecords.push({\n el: node,\n data: nodeData,\n });\n\n if (force || !prevNodeData)\n config.setupNode({\n parent: {\n el: parent,\n data: parentData,\n },\n node: {\n el: node,\n data: nodeData,\n },\n });\n\n setupNodeRemap({\n parent: {\n el: parent,\n data: parentData,\n },\n node: {\n el: node,\n data: nodeData,\n },\n });\n }\n\n parents.set(parent, { ...parentData, enabledNodes: enabledNodeRecords });\n\n config.remapFinished(parentData);\n\n parentData.config.plugins?.forEach((plugin: DNDPlugin) => {\n plugin(parent)?.remapFinished?.();\n });\n}\n\nexport function remapFinished() {\n state.remapJustFinished = true;\n\n if (\"draggedNode\" in state) state.affectedNodes = [];\n}\n\nexport function validateDragstart(data: NodeEventData): boolean {\n return !!data.targetData.parent.data.config.nativeDrag;\n}\n\nfunction draggedNodes(data: NodeEventData): Array> {\n if (!data.targetData.parent.data.config.multiDrag) {\n return [data.targetData.node];\n } else if (state.selectedState) {\n return [\n data.targetData.node,\n ...(state.selectedState?.nodes.filter(\n (x) => x.el !== data.targetData.node.el\n ) as Array>),\n ];\n }\n\n return [];\n}\n\n/**\n * Responsible for assigning dragstart classes to the dragged nodes.\n */\nexport function handleDragstart(\n data: NodeDragEventData,\n state: BaseDragState\n) {\n if (!validateDragstart(data) || !validateDragHandle(data)) {\n data.e.preventDefault();\n\n return;\n }\n\n const config = data.targetData.parent.data.config;\n\n const nodes = config.draggedNodes(data);\n\n config.dragstartClasses(data.targetData.node, nodes, config);\n\n const dragState = initDrag(data, nodes);\n\n if (config.onDragstart)\n config.onDragstart(\n {\n parent: data.targetData.parent,\n values: parentValues(\n data.targetData.parent.el,\n data.targetData.parent.data\n ),\n draggedNode: dragState.draggedNode,\n draggedNodes: dragState.draggedNodes,\n position: dragState.initialIndex,\n },\n state as DragState\n );\n}\n\nexport function handleNodePointerdown(\n data: NodePointerEventData,\n state: BaseDragState\n) {\n if (!validateDragHandle(data)) return;\n\n data.e.stopPropagation();\n\n synthNodePointerDown = true;\n\n const parentData = data.targetData.parent.data;\n\n let selectedNodes = [data.targetData.node];\n\n const commandKey = data.e.ctrlKey || data.e.metaKey;\n const shiftKey = data.e.shiftKey;\n\n const targetNode = data.targetData.node;\n\n if (commandKey && parentData.config.multiDrag) {\n if (state.selectedState) {\n const idx = state.selectedState.nodes.findIndex(\n (x) => x.el === targetNode.el\n );\n\n if (idx === -1) {\n selectedNodes = [...state.selectedState.nodes, targetNode];\n } else {\n selectedNodes = state.selectedState.nodes.filter(\n (x) => x.el !== targetNode.el\n );\n }\n } else {\n selectedNodes = [targetNode];\n }\n\n setSelected(\n data.targetData.parent,\n selectedNodes,\n data.targetData.node,\n state,\n true\n );\n\n return;\n }\n\n if (shiftKey && parentData.config.multiDrag) {\n const nodes = data.targetData.parent.data.enabledNodes;\n if (state.selectedState && state.activeState) {\n if (state.selectedState.parent.el !== data.targetData.parent.el) {\n deselect(state.selectedState.nodes, state.selectedState.parent, state);\n state.selectedState = undefined;\n for (let x = 0; x <= targetNode.data.index; x++)\n selectedNodes.push(nodes[x]);\n } else {\n const [minIndex, maxIndex] =\n state.activeState.node.data.index < data.targetData.node.data.index\n ? [\n state.activeState.node.data.index,\n data.targetData.node.data.index,\n ]\n : [\n data.targetData.node.data.index,\n state.activeState.node.data.index,\n ];\n selectedNodes = nodes.slice(minIndex, maxIndex + 1);\n }\n } else {\n for (let x = 0; x <= targetNode.data.index; x++)\n selectedNodes.push(nodes[x]);\n }\n setSelected(\n data.targetData.parent,\n selectedNodes,\n data.targetData.node,\n state,\n true\n );\n\n return;\n }\n\n if (state.selectedState?.nodes?.length) {\n const idx = state.selectedState.nodes.findIndex(\n (x) => x.el === data.targetData.node.el\n );\n\n if (idx === -1) {\n if (state.selectedState.parent.el !== data.targetData.parent.el) {\n deselect(state.selectedState.nodes, data.targetData.parent, state);\n } else if (parentData.config.multiDrag && (touchDevice || !isNative)) {\n selectedNodes.push(...state.selectedState.nodes);\n } else {\n deselect(state.selectedState.nodes, data.targetData.parent, state);\n }\n setSelected(\n data.targetData.parent,\n selectedNodes,\n data.targetData.node,\n state,\n true\n );\n }\n } else {\n setSelected(\n data.targetData.parent,\n [data.targetData.node],\n data.targetData.node,\n state,\n true\n );\n }\n}\n\nexport function dragstartClasses(\n _node: NodeRecord,\n nodes: Array>,\n config: ParentConfig,\n isSynth = false\n) {\n addNodeClass(\n nodes.map((x) => x.el),\n isSynth ? config.synthDraggingClass : config.draggingClass\n );\n\n setTimeout(() => {\n removeClass(\n nodes.map((x) => x.el),\n isSynth ? config.synthDraggingClass : config.draggingClass\n );\n\n addNodeClass(\n nodes.map((x) => x.el),\n isSynth ? config.synthDragPlaceholderClass : config.dragPlaceholderClass\n );\n\n addNodeClass(\n nodes.map((x) => x.el),\n isSynth ? config.synthDropZoneClass : config.dropZoneClass\n );\n\n removeClass(\n nodes.map((x) => x.el),\n config.activeDescendantClass\n );\n\n removeClass(\n nodes.map((x) => x.el),\n config.selectedClass\n );\n });\n}\n\nexport function initDrag(\n data: NodeDragEventData,\n draggedNodes: Array>\n): DragState {\n const dragState = setDragState(dragStateProps(data, draggedNodes));\n\n data.e.stopPropagation();\n\n if (data.e.dataTransfer) {\n const config = data.targetData.parent.data.config;\n\n data.e.dataTransfer.dropEffect = config.dragDropEffect;\n\n data.e.dataTransfer.effectAllowed = config.dragEffectAllowed;\n\n let dragImage: HTMLElement | undefined;\n\n if (config.dragImage) {\n dragImage = config.dragImage(data, draggedNodes);\n } else {\n if (!config.multiDrag) {\n data.e.dataTransfer.setDragImage(\n data.targetData.node.el,\n data.e.offsetX,\n data.e.offsetY\n );\n\n return dragState;\n } else {\n const wrapper = document.createElement(\"div\");\n\n for (const node of draggedNodes) {\n const clonedNode = node.el.cloneNode(true) as HTMLElement;\n\n clonedNode.style.pointerEvents = \"none\";\n\n clonedNode.id = node.el.id + \"-clone\";\n\n copyNodeStyle(node.el, clonedNode, true);\n\n wrapper.append(clonedNode);\n }\n\n const { width } = draggedNodes[0].el.getBoundingClientRect();\n\n Object.assign(wrapper.style, {\n display: \"flex\",\n flexDirection: \"column\",\n width: `${width}px`,\n position: \"absolute\",\n pointerEvents: \"none\",\n zIndex: \"9999\",\n left: \"-9999px\",\n });\n\n dragImage = wrapper;\n }\n\n document.body.appendChild(dragImage);\n }\n\n data.e.dataTransfer.setDragImage(dragImage, data.e.offsetX, data.e.offsetY);\n\n setTimeout(() => {\n dragImage?.remove();\n });\n }\n\n return dragState;\n}\n\nexport function validateDragHandle(\n data: NodeDragEventData | NodePointerEventData\n): boolean {\n const config = data.targetData.parent.data.config;\n\n if (!config.dragHandle) return true;\n\n const dragHandles = data.targetData.node.el.querySelectorAll(\n config.dragHandle\n );\n\n if (!dragHandles) return false;\n\n const coordinates = data.e;\n\n const elFromPoint = config.root.elementFromPoint(\n coordinates.x,\n coordinates.y\n );\n\n if (!elFromPoint) return false;\n\n for (const handle of Array.from(dragHandles))\n if (elFromPoint === handle || handle.contains(elFromPoint)) return true;\n\n return false;\n}\n\nexport function handleClickNode(_data: NodeEventData) {}\n\nexport function handleClickParent(_data: ParentEventData) {}\n\nexport function handleNodeKeydown(_data: NodeEventData) {}\n\nexport function handleParentKeydown(\n data: ParentKeydownEventData,\n state: BaseDragState\n) {\n const activeDescendant = state.activeState?.node;\n\n if (!activeDescendant) return;\n\n const parentData = data.targetData.parent.data;\n\n const enabledNodes = parentData.enabledNodes;\n\n const index = enabledNodes.findIndex((x) => x.el === activeDescendant.el);\n\n if (index === -1) return;\n\n if (\n [\"ArrowDown\", \"ArrowUp\", \"ArrowRight\", \"ArrowLeft\"].includes(data.e.key)\n ) {\n data.e.preventDefault();\n\n const nextIndex =\n data.e.key === \"ArrowDown\" || data.e.key === \"ArrowRight\"\n ? index + 1\n : index - 1;\n\n if (nextIndex < 0 || nextIndex >= enabledNodes.length) return;\n\n const nextNode = enabledNodes[nextIndex];\n\n setActive(data.targetData.parent, nextNode, state);\n } else if (data.e.key === \" \") {\n data.e.preventDefault();\n\n state.selectedState && state.selectedState.nodes.includes(activeDescendant)\n ? setSelected(\n data.targetData.parent,\n state.selectedState.nodes.filter((x) => x.el !== activeDescendant.el),\n activeDescendant,\n state\n )\n : setSelected(\n data.targetData.parent,\n [activeDescendant],\n activeDescendant,\n state\n );\n\n //if (!state.selectedState)\n // updateLiveRegion(data.targetData.parent, \"\", true);\n } else if (data.e.key === \"Enter\" && state.selectedState) {\n if (\n state.selectedState.parent.el === data.targetData.parent.el &&\n state.activeState\n ) {\n if (state.selectedState.nodes[0].el === state.activeState.node.el) {\n updateLiveRegion(data.targetData.parent, \"Cannot drop item on itself\");\n\n return;\n }\n\n state.newActiveDescendant = state.selectedState.nodes[0];\n\n parentData.config.performSort({\n parent: data.targetData.parent,\n draggedNodes: state.selectedState.nodes,\n targetNode: state.activeState.node,\n });\n\n deselect([], data.targetData.parent, state);\n\n updateLiveRegion(data.targetData.parent, \"Drop successful\");\n } else if (\n state.activeState &&\n state.selectedState.parent.el !== data.targetData.parent.el &&\n validateTransfer({\n currentParent: data.targetData.parent,\n targetParent: state.selectedState.parent,\n initialParent: state.selectedState.parent,\n draggedNodes: state.selectedState.nodes,\n state,\n })\n ) {\n parentData.config.performTransfer({\n currentParent: state.selectedState.parent,\n targetParent: data.targetData.parent,\n initialParent: state.selectedState.parent,\n draggedNodes: state.selectedState.nodes,\n initialIndex: state.selectedState.nodes[0].data.index,\n state,\n targetNode: state.activeState.node,\n });\n\n state.newActiveDescendant = state.selectedState.nodes[0];\n\n setSelected(data.targetData.parent, [], undefined, state);\n\n updateLiveRegion(data.targetData.parent, \"Drop successful\");\n }\n }\n}\n\nexport function preventSortOnScroll() {\n let scrollTimeout: number;\n\n return () => {\n clearTimeout(scrollTimeout);\n\n if (state) state.preventEnter = true;\n\n scrollTimeout = setTimeout(() => {\n if (state) state.preventEnter = false;\n }, 100);\n };\n}\n\nexport function handleNodePointerover(e: PointeroverNodeEvent) {\n if (e.detail.targetData.parent.el === e.detail.state.currentParent.el)\n sort(e.detail, e.detail.state);\n else transfer(e.detail, e.detail.state);\n}\n\nexport function handleNodeDrop(\n data: NodeDragEventData,\n state: DragState | SynthDragState\n) {\n data.e.stopPropagation();\n\n dropped = true;\n\n const config = data.targetData.parent.data.config;\n\n config.handleEnd(state);\n}\n\nexport function handleDragend(\n data: NodeEventData,\n state: DragState | SynthDragState\n) {\n data.e.preventDefault();\n\n if (dropped) {\n dropped = false;\n\n return;\n }\n\n const config = parents.get(state.initialParent.el)?.config;\n config?.handleEnd(state);\n\n if (config?.onDragend) {\n config.onDragend({\n parent: state.currentParent,\n values: parentValues(state.currentParent.el, state.currentParent.data),\n draggedNode: state.draggedNode,\n draggedNodes: state.draggedNodes,\n position: state.initialIndex,\n });\n }\n}\n\nexport function handleEnd(state: DragState | SynthDragState) {\n cancelSynthScroll();\n\n for (const [_el, controller] of state.scrollEls) controller.abort();\n\n if (\"longPressTimeout\" in state && state.longPressTimeout)\n clearTimeout(state.longPressTimeout);\n\n const config = parents.get(state.initialParent.el)?.config;\n\n const isSynth = \"clonedDraggedNode\" in state && state.clonedDraggedNode;\n\n const dropZoneClass = isSynth\n ? config?.synthDropZoneClass\n : config?.dropZoneClass;\n\n if (state.originalZIndex !== undefined)\n state.draggedNode.el.style.zIndex = state.originalZIndex;\n\n removeClass(\n state.draggedNodes.map((x) => x.el),\n dropZoneClass\n );\n\n removeClass(\n state.draggedNodes.map((x) => x.el),\n state.initialParent.data?.config?.longPressClass\n );\n\n removeClass(\n state.draggedNodes.map((x) => x.el),\n isSynth\n ? state.initialParent.data.config.synthDragPlaceholderClass\n : state.initialParent.data?.config?.dragPlaceholderClass\n );\n\n if (isSynth) state.clonedDraggedNode.remove();\n\n deselect(state.draggedNodes, state.currentParent, state);\n\n setActive(state.currentParent, undefined, state);\n\n resetState();\n\n state.selectedState = undefined;\n\n synthNodePointerDown = false;\n\n state.emit(\"dragend\", state);\n}\n\nexport function handleNodeTouchstart(\n data: NodeEventData,\n _state: BaseDragState\n) {\n if (data.e.cancelable) data.e.preventDefault();\n}\n\nexport function handleNodePointerup(\n data: NodePointerEventData,\n state: DragState | SynthDragState | BaseDragState\n) {\n if (!state.pointerSelection && state.selectedState)\n deselect(state.selectedState.nodes, data.targetData.parent, state);\n\n const config = data.targetData.parent.data.config;\n\n state.pointerSelection = false;\n\n synthNodePointerDown = false;\n\n if (!isDragState(state)) return;\n\n config.handleEnd(state as DragState | SynthDragState);\n}\n\nexport function handleNodePointermove(\n data: NodePointerEventData,\n state: SynthDragState | BaseDragState\n) {\n // TODO: I think this is OK but not sure.\n //data.e.stopPropagation();\n\n if (isNative || !synthNodePointerDown || !validateDragHandle(data)) return;\n\n if (!isSynthDragState(state)) {\n const config = data.targetData.parent.data.config;\n\n const nodes = config.draggedNodes(data);\n\n config.dragstartClasses(data.targetData.node, nodes, config, true);\n\n const synthDragState = initSynthDrag(data, state, nodes);\n\n synthDragState.clonedDraggedNode.style.display =\n synthDragState.draggedNodeDisplay || \"\";\n\n synthMove(data, synthDragState);\n\n if (config.onDragstart)\n config.onDragstart(\n {\n parent: data.targetData.parent,\n values: parentValues(\n data.targetData.parent.el,\n data.targetData.parent.data\n ),\n draggedNode: synthDragState.draggedNode,\n draggedNodes: synthDragState.draggedNodes,\n position: synthDragState.initialIndex,\n },\n synthDragState\n );\n\n synthDragState.draggedNode.el.setPointerCapture(data.e.pointerId);\n\n synthDragState.pointerId = data.e.pointerId;\n\n return;\n }\n\n synthMove(data, state as SynthDragState);\n}\n\nfunction initSynthDrag(\n data: NodePointerEventData,\n _state: BaseDragState,\n draggedNodes: Array>\n): SynthDragState {\n const config = data.targetData.parent.data.config;\n\n let dragImage: HTMLElement | undefined;\n\n if (config.synthDragImage) {\n dragImage = config.synthDragImage(data, draggedNodes);\n } else {\n if (!config.multiDrag || draggedNodes.length === 1) {\n dragImage = data.targetData.node.el.cloneNode(true) as HTMLElement;\n\n dragImage.id = data.targetData.node.el.id + \"-clone\";\n\n copyNodeStyle(data.targetData.node.el, dragImage);\n\n Object.assign(dragImage.style, {\n width: data.targetData.node.el.getBoundingClientRect().width,\n zIndex: 9999,\n pointerEvents: \"none\",\n });\n\n document.body.appendChild(dragImage);\n } else {\n const wrapper = document.createElement(\"div\");\n\n for (const node of draggedNodes) {\n const clonedNode = node.el.cloneNode(true) as HTMLElement;\n\n copyNodeStyle(node.el, clonedNode);\n\n clonedNode.style.pointerEvents = \"none\";\n\n clonedNode.id = node.el.id + \"-clone\";\n\n wrapper.append(clonedNode);\n }\n\n const { width } = draggedNodes[0].el.getBoundingClientRect();\n\n Object.assign(wrapper.style, {\n display: \"flex\",\n flexDirection: \"column\",\n width: `${width}px`,\n position: \"fixed\",\n pointerEvents: \"none\",\n zIndex: \"9999\",\n left: \"-9999px\",\n });\n\n dragImage = wrapper;\n }\n }\n\n const display = dragImage.style.display;\n\n dragImage.style.display = \"none\";\n\n document.body.append(dragImage);\n\n dragImage.style.position = \"absolute\";\n\n const synthDragStateProps = {\n clonedDraggedEls: [],\n clonedDraggedNode: dragImage,\n draggedNodeDisplay: display,\n synthDragScrolling: false,\n };\n\n addEvents(document, {\n contextmenu: noDefault,\n });\n\n const synthDragState = setDragState({\n ...dragStateProps(data, draggedNodes, false),\n ...synthDragStateProps,\n }) as SynthDragState;\n\n return synthDragState;\n}\n\nexport function handleLongPress(\n data: NodePointerEventData,\n dragState: DragState\n) {\n const config = data.targetData.parent.data.config;\n\n if (!config.longPress) return;\n\n dragState.longPressTimeout = setTimeout(() => {\n if (!dragState) return;\n\n dragState.longPress = true;\n\n if (config.longPressClass && data.e.cancelable)\n addNodeClass(\n dragState.draggedNodes.map((x) => x.el),\n config.longPressClass\n );\n\n data.e.preventDefault();\n }, config.longPressTimeout || 200);\n}\n\nfunction pointermoveClasses(\n state: SynthDragState,\n config: ParentConfig\n) {\n if (config.longPressClass)\n removeClass(\n state.draggedNodes.map((x) => x.el),\n config?.longPressClass\n );\n}\n\nfunction getScrollData(\n e: DragEvent | PointerEvent,\n state: DragState | SynthDragState\n): ScrollData | undefined {\n if (!(e.currentTarget instanceof HTMLElement)) return;\n\n const {\n x: xThresh,\n y: yThresh,\n scrollOutside,\n } = state.initialParent.data.config.scrollBehavior;\n\n const coordinates = getRealCoords(e.currentTarget);\n\n return {\n xThresh,\n yThresh,\n scrollOutside,\n scrollParent: e.currentTarget,\n x: coordinates.left,\n y: coordinates.top,\n clientWidth: e.currentTarget.clientWidth,\n clientHeight: e.currentTarget.clientHeight,\n scrollWidth: e.currentTarget.scrollWidth,\n scrollHeight: e.currentTarget.scrollHeight,\n };\n}\n\nfunction cancelSynthScroll() {\n if (animationFrameId !== null) {\n cancelAnimationFrame(animationFrameId);\n\n animationFrameId = null;\n }\n}\n\nfunction setSynthScrollDirection(\n direction: \"up\" | \"down\" | \"left\" | \"right\" | undefined,\n el: HTMLElement,\n state: SynthDragState\n) {\n if (state.synthScrollDirection === direction) return;\n\n state.synthScrollDirection = direction;\n\n // Cancel any ongoing animation frame when direction changes\n cancelSynthScroll();\n\n if (direction === \"up\" && el.scrollTop === 0) return;\n\n if (direction === \"down\" && el.scrollTop + el.clientHeight >= el.scrollHeight)\n return;\n\n if (direction === \"left\" && el.scrollLeft === 0) return;\n\n if (direction === \"right\" && el.scrollLeft + el.clientWidth >= el.scrollWidth)\n return;\n\n let lastTimestamp: number | null = null;\n\n // Function to perform the scrolling based on the current direction\n const scroll = (timestamp: number) => {\n if (lastTimestamp === null) lastTimestamp = timestamp;\n\n const elapsed = timestamp - lastTimestamp;\n\n // Base scroll speed in pixels per second\n const baseSpeed = 500;\n\n const distance = (baseSpeed * elapsed) / 1000; // Pixels to scroll\n\n if (state.synthScrollDirection === undefined && animationFrameId) {\n cancelAnimationFrame(animationFrameId);\n\n animationFrameId = null;\n\n return;\n }\n\n switch (direction) {\n case \"up\":\n el.scrollBy(0, -distance);\n state.clonedDraggedNode.style.top = `${\n state.coordinates.y + el.scrollTop\n }px`;\n\n break;\n case \"down\":\n el.scrollBy(0, distance);\n state.clonedDraggedNode.style.top = `${\n state.coordinates.y + el.scrollTop - state.startTop\n }px`;\n\n break;\n case \"left\":\n el.scrollBy(-distance, 0);\n\n state.clonedDraggedNode.style.left = `${\n state.coordinates.x + el.scrollLeft\n }px`;\n\n break;\n case \"right\":\n state.clonedDraggedNode.style.left = `${\n state.coordinates.x + el.scrollLeft\n }px`;\n\n el.scrollBy(distance, 0);\n }\n\n lastTimestamp = timestamp;\n\n animationFrameId = requestAnimationFrame(scroll);\n };\n\n animationFrameId = requestAnimationFrame(scroll);\n}\n\nfunction shouldScroll(\n direction: string,\n e: DragEvent | PointerEvent,\n state: DragState | SynthDragState\n): boolean {\n const dataScrollData = getScrollData(e, state);\n\n if (!dataScrollData) return false;\n\n switch (direction) {\n case \"down\":\n return !!shouldScrollDown(state, dataScrollData);\n\n case \"up\":\n return !!shouldScrollUp(state, dataScrollData);\n\n case \"right\":\n return !!shouldScrollRight(state, dataScrollData);\n\n case \"left\":\n return !!shouldScrollLeft(state, dataScrollData);\n\n default:\n return false;\n }\n}\n\nfunction shouldScrollRight(\n state: DragState | SynthDragState,\n data: ScrollData\n): DragState | DragState | void {\n return;\n const diff = data.scrollParent.clientWidth + data.x - state.coordinates.x;\n\n if (!data.scrollOutside && diff < 0) return;\n\n if (\n diff < (1 - data.xThresh) * data.scrollParent.clientWidth &&\n !(\n data.scrollParent.scrollLeft + data.scrollParent.clientWidth >=\n data.scrollParent.scrollWidth\n )\n )\n return state;\n}\n\nfunction shouldScrollLeft(\n state: DragState,\n data: ScrollData\n): DragState | void {\n return;\n const diff = data.scrollParent.clientWidth + data.x - state.coordinates.x;\n\n if (!data.scrollOutside && diff > data.scrollParent.clientWidth) return;\n\n if (\n diff > data.xThresh * data.scrollParent.clientWidth &&\n data.scrollParent.scrollLeft !== 0\n )\n return state;\n}\n\nfunction shouldScrollUp(state: DragState, data: ScrollData): boolean {\n return (\n state.coordinates.y <= 0.1 * data.scrollParent.clientHeight &&\n data.scrollParent.scrollTop !== 0\n );\n}\n\nfunction shouldScrollDown(state: DragState, data: ScrollData): boolean {\n return (\n state.coordinates.y > data.clientHeight * data.yThresh &&\n data.scrollParent.scrollTop !== data.scrollParent.clientHeight\n );\n}\n\nfunction moveNode(data: NodePointerEventData, state: SynthDragState) {\n const { x, y } = eventCoordinates(data.e);\n\n state.coordinates.y = y;\n\n state.coordinates.x = x;\n\n const startLeft = state.startLeft ?? 0;\n\n const startTop = state.startTop ?? 0;\n\n state.clonedDraggedNode.style.top = `${y - startTop + window.scrollY}px`;\n\n state.clonedDraggedNode.style.left = `${x - startLeft + window.scrollX}px`;\n\n if (data.e.cancelable) data.e.preventDefault();\n\n pointermoveClasses(state, data.targetData.parent.data.config);\n}\n\nexport function synthMove(\n data: NodePointerEventData,\n state: SynthDragState\n) {\n const config = data.targetData.parent.data.config;\n\n if (config.longPress && !state.longPress) {\n clearTimeout(state.longPressTimeout);\n\n return;\n }\n\n moveNode(data, state);\n\n const elFromPoint = getElFromPoint(eventCoordinates(data.e));\n\n if (!elFromPoint) {\n document.dispatchEvent(\n new CustomEvent(\"handleRootPointerover\", {\n detail: {\n e: data.e,\n state,\n },\n })\n );\n\n return;\n }\n const pointerMoveEventData = {\n e: data.e,\n targetData: elFromPoint,\n state,\n };\n\n if (\"node\" in elFromPoint) {\n elFromPoint.node.el.dispatchEvent(\n new CustomEvent(\"handleNodePointerover\", {\n detail: pointerMoveEventData,\n })\n );\n } else {\n elFromPoint.parent.el.dispatchEvent(\n new CustomEvent(\"handleParentPointerover\", {\n detail: pointerMoveEventData,\n })\n );\n }\n}\n\nexport function handleScroll(e: DragEvent | PointerEvent) {\n e.stopPropagation();\n\n if (!isSynthDragState(state)) return;\n let directionSet = false;\n\n for (const direction of Object.keys(scrollConfig)) {\n if (shouldScroll(direction, e, state)) {\n setSynthScrollDirection(\n direction as \"up\" | \"down\" | \"left\" | \"right\" | undefined,\n e.currentTarget as HTMLElement,\n state\n );\n\n directionSet = true;\n\n break;\n }\n }\n\n if (!directionSet) state.synthScrollDirection = undefined;\n}\n\nexport function handleNodeDragover(\n data: NodeDragEventData,\n state: DragState\n) {\n const { x, y } = eventCoordinates(data.e);\n\n state.coordinates.y = y;\n\n state.coordinates.x = x;\n\n //data.e.preventDefault();\n\n //data.e.stopPropagation();\n\n data.targetData.parent.el === state.currentParent?.el\n ? sort(data, state)\n : transfer(data, state);\n}\n\nexport function handleParentDragover(\n data: ParentEventData,\n state: DragState\n) {\n if (!state) return;\n\n Object.assign(eventCoordinates(data.e as DragEvent));\n\n transfer(data, state);\n}\n\nexport function handleParentPointerover(e: PointeroverParentEvent) {\n if (e.detail.targetData.parent.el !== e.detail.state.currentParent.el)\n transfer(e.detail, e.detail.state);\n}\n\nexport function validateTransfer({\n currentParent,\n targetParent,\n initialParent,\n draggedNodes,\n state,\n}: {\n currentParent: ParentRecord;\n targetParent: ParentRecord;\n initialParent: ParentRecord;\n draggedNodes: Array>;\n state: BaseDragState;\n}) {\n if (targetParent.el === currentParent.el) return false;\n\n const targetConfig = targetParent.data.config;\n\n // Not checking for contains among all dragged nodes, should do this.\n if (targetConfig.treeGroup && draggedNodes[0].el.contains(targetParent.el))\n return false;\n\n if (targetConfig.dropZone === false) return false;\n\n const initialParentConfig = initialParent.data.config;\n\n if (targetConfig.accepts) {\n return targetConfig.accepts(\n targetParent,\n initialParent,\n currentParent,\n state\n );\n } else if (\n !targetConfig.group ||\n targetConfig.group !== initialParentConfig.group\n ) {\n return false;\n }\n\n return true;\n}\n\nfunction handleNodeDragenter(\n data: NodeDragEventData,\n _state: DragState\n) {\n data.e.preventDefault();\n}\n\nfunction handleNodeDragleave(\n data: NodeDragEventData,\n _state: DragState\n) {\n data.e.preventDefault();\n}\n\nexport function validateSort(\n data: NodeDragEventData | NodePointerEventData,\n state: DragState,\n x: number,\n y: number\n): boolean {\n if (\n state.affectedNodes\n .map((x) => x.data.value)\n .includes(data.targetData.node.data.value)\n ) {\n return false;\n }\n\n if (state.remapJustFinished) {\n state.remapJustFinished = false;\n\n if (\n data.targetData.node.data.value === state.currentTargetValue ||\n state.draggedNodes.map((x) => x.el).includes(data.targetData.node.el)\n ) {\n state.currentTargetValue = data.targetData.node.data.value;\n }\n\n return false;\n }\n\n if (state.preventEnter) return false;\n\n if (state.draggedNodes.map((x) => x.el).includes(data.targetData.node.el)) {\n state.currentTargetValue = undefined;\n\n return false;\n }\n\n if (data.targetData.node.data.value === state.currentTargetValue)\n return false;\n\n if (\n data.targetData.parent.el !== state.currentParent?.el ||\n data.targetData.parent.data.config.sortable === false\n )\n return false;\n\n const targetRect = data.targetData.node.el.getBoundingClientRect();\n\n const dragRect = state.draggedNode.el.getBoundingClientRect();\n\n const yDiff = targetRect.y - dragRect.y;\n\n const xDiff = targetRect.x - dragRect.x;\n\n let incomingDirection: \"above\" | \"below\" | \"left\" | \"right\";\n\n if (Math.abs(yDiff) > Math.abs(xDiff)) {\n incomingDirection = yDiff > 0 ? \"above\" : \"below\";\n } else {\n incomingDirection = xDiff > 0 ? \"left\" : \"right\";\n }\n\n const threshold = state.currentParent.data.config.threshold;\n\n switch (incomingDirection) {\n case \"left\":\n if (x > targetRect.x + targetRect.width * threshold.horizontal) {\n state.incomingDirection = \"left\";\n\n return true;\n }\n break;\n\n case \"right\":\n if (x < targetRect.x + targetRect.width * (1 - threshold.horizontal)) {\n state.incomingDirection = \"right\";\n\n return true;\n }\n break;\n\n case \"above\":\n if (y > targetRect.y + targetRect.height * threshold.vertical) {\n state.incomingDirection = \"above\";\n\n return true;\n }\n break;\n\n case \"below\":\n if (y < targetRect.y + targetRect.height * (1 - threshold.vertical)) {\n state.incomingDirection = \"below\";\n\n return true;\n }\n break;\n\n default:\n break;\n }\n\n return false;\n}\n\nexport function sort(\n data: NodeDragEventData | NodePointerEventData,\n state: DragState\n) {\n const { x, y } = eventCoordinates(data.e);\n\n if (!validateSort(data, state, x, y)) return;\n\n const range =\n state.draggedNode.data.index > data.targetData.node.data.index\n ? [data.targetData.node.data.index, state.draggedNode.data.index]\n : [state.draggedNode.data.index, data.targetData.node.data.index];\n\n state.targetIndex = data.targetData.node.data.index;\n\n state.affectedNodes = data.targetData.parent.data.enabledNodes.filter(\n (node) => {\n return (\n range[0] <= node.data.index &&\n node.data.index <= range[1] &&\n node.el !== state.draggedNode.el\n );\n }\n );\n\n data.targetData.parent.data.config.performSort({\n parent: data.targetData.parent,\n draggedNodes: state.draggedNodes,\n targetNode: data.targetData.node,\n });\n}\n\n/**\n * Event listener used for all nodes.\n *\n * @param e - The event.\n *\n */\nexport function nodeEventData(\n callback: any\n): (e: Event) => NodeEventData | undefined {\n function nodeTargetData(node: Node): NodeTargetData | undefined {\n const nodeData = nodes.get(node);\n\n if (!nodeData) return;\n\n const parentData = parents.get(node.parentNode);\n\n if (!parentData) return;\n\n return {\n node: {\n el: node,\n data: nodeData,\n },\n parent: {\n el: node.parentNode,\n data: parentData,\n },\n };\n }\n\n return (e: Event) => {\n const targetData = nodeTargetData(e.currentTarget as Node);\n\n if (!targetData) return;\n\n return callback(\n {\n e,\n targetData,\n },\n state\n );\n };\n}\n\n/**\n * Used when the dragged element enters into a parent other than its own.\n */\nexport function transfer(\n data: NodeEventData | ParentEventData,\n state: DragState\n): void {\n if (\n !validateTransfer({\n currentParent: state.currentParent,\n targetParent: data.targetData.parent,\n initialParent: state.initialParent,\n draggedNodes: state.draggedNodes,\n state,\n })\n )\n return;\n\n data.targetData.parent.data.config.performTransfer({\n currentParent: state.currentParent,\n targetParent: data.targetData.parent,\n initialParent: state.initialParent,\n draggedNodes: state.draggedNodes,\n initialIndex: state.initialIndex,\n state,\n targetNode: \"node\" in data.targetData ? data.targetData.node : undefined,\n });\n\n state.currentParent = data.targetData.parent;\n\n state.transferred = true;\n}\n\nexport function parentEventData(\n callback: any\n): (e: Event) => NodeEventData | undefined {\n function parentTargetData(\n parent: HTMLElement\n ): ParentTargetData | undefined {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n return {\n parent: {\n el: parent,\n data: parentData as ParentData,\n },\n };\n }\n\n return (e: Event) => {\n const targetData = parentTargetData(e.currentTarget as HTMLElement);\n\n if (!targetData) return;\n\n return callback(\n {\n e,\n targetData,\n },\n state\n );\n };\n}\n\nexport function noDefault(e: Event) {\n e.preventDefault();\n}\n\nexport function throttle(callback: any, limit: number) {\n var wait = false;\n return function (...args: any[]) {\n if (!wait) {\n callback.call(null, ...args);\n wait = true;\n setTimeout(function () {\n wait = false;\n }, limit);\n }\n };\n}\n\nfunction splitClass(className: string): Array {\n return className.split(\" \").filter((x) => x);\n}\n\nexport function addNodeClass(\n els: Array,\n className: string | undefined,\n omitAppendPrivateClass = false\n) {\n function nodeSetter(node: Node, nodeData: NodeData) {\n nodes.set(node, nodeData);\n }\n\n for (const el of els) {\n const nodeData = nodes.get(el as Node);\n\n const newData = addClass(el, className, nodeData, omitAppendPrivateClass);\n\n if (!newData) continue;\n\n nodeSetter(el as Node, newData as NodeData);\n }\n}\n\nexport function addParentClass(\n els: Array,\n className: string | undefined,\n omitAppendPrivateClass = false\n) {\n function parentSetter(parent: HTMLElement, parentData: ParentData) {\n parents.set(parent, parentData);\n }\n\n for (const el of els) {\n const parentData = parents.get(el);\n\n const newData = addClass(el, className, parentData, omitAppendPrivateClass);\n\n if (!newData) continue;\n\n parentSetter(el, newData as ParentData);\n }\n}\n\nexport function addClass(\n el: Node | HTMLElement | Element,\n className: string | undefined,\n data: NodeData | ParentData | undefined,\n omitAppendPrivateClass = false\n) {\n if (!className) return;\n\n const classNames = splitClass(className);\n\n if (!classNames.length) return;\n\n if (classNames.includes(\"longPress\")) return;\n\n if (!data) {\n el.classList.add(...classNames);\n\n return;\n }\n\n const privateClasses = [];\n\n for (const className of classNames) {\n if (!el.classList.contains(className)) {\n el.classList.add(className);\n } else if (\n el.classList.contains(className) &&\n omitAppendPrivateClass === false\n ) {\n privateClasses.push(className);\n }\n }\n\n data.privateClasses = privateClasses;\n\n return data;\n}\n\nexport function removeClass(\n els: Array,\n className: string | undefined\n) {\n if (!className) return;\n\n const classNames = splitClass(className);\n\n if (!classNames.length) return;\n\n for (const node of els) {\n if (!isNode(node)) {\n node.classList.remove(...classNames);\n continue;\n }\n\n const nodeData = nodes.get(node) || parents.get(node);\n\n if (!nodeData) continue;\n\n for (const className of classNames) {\n if (!nodeData.privateClasses.includes(className)) {\n node.classList.remove(className);\n }\n }\n }\n}\n\nfunction isScrollable(element: HTMLElement) {\n if (element === document.documentElement) {\n return (\n element.scrollHeight > element.clientHeight ||\n element.scrollWidth > element.clientWidth\n );\n }\n\n const style = window.getComputedStyle(element);\n\n return (\n ((style.overflowY === \"auto\" || style.overflowY === \"scroll\") &&\n element.scrollHeight > element.clientHeight) ||\n ((style.overflowX === \"auto\" || style.overflowX === \"scroll\") &&\n element.scrollWidth > element.clientWidth)\n );\n}\n\n/**\n * Used for getting the closest scrollable parent of a given element.\n *\n * @param node - The parent element to start the search from.\n *\n * @returns The closest scrollable parent or the document's root element.\n *\n * @internal\n */\nexport function getScrollables(): Array {\n return Array.from(document.querySelectorAll(\"*\")).filter(\n (el) => el instanceof HTMLElement && isScrollable(el)\n ) as Array;\n}\n\nexport function getElFromPoint(coordinates: {\n x: number;\n y: number;\n}): NodeFromPoint | ParentFromPoint | undefined {\n let target = document.elementFromPoint(coordinates.x, coordinates.y);\n\n if (!isNode(target)) return;\n\n let isParent;\n\n let invalidEl = true;\n\n while (target && invalidEl) {\n if (nodes.has(target as Node) || parents.has(target as HTMLElement)) {\n invalidEl = false;\n\n isParent = parents.has(target as HTMLElement);\n\n break;\n }\n\n target = target.parentNode as Node;\n }\n\n if (!isParent) {\n const targetNodeData = nodes.get(target as Node);\n\n if (!targetNodeData) return;\n\n const targetParentData = parents.get(target.parentNode as Node);\n\n if (!targetParentData) return;\n\n return {\n node: {\n el: target as Node,\n data: targetNodeData,\n },\n parent: {\n el: target.parentNode as Node,\n data: targetParentData as ParentData,\n },\n };\n } else {\n const parentData = parents.get(target as HTMLElement);\n\n if (!parentData) return;\n\n return {\n parent: {\n el: target as HTMLElement,\n data: parentData as ParentData,\n },\n };\n }\n}\n\n/**\n * Checks to see that a given element and its parent node are instances of\n * HTML Elements.\n *\n * @param {unknown} el - The element to check.\n *\n * @returns {boolean} - Whether or not provided element is of type Node.\n */\nexport function isNode(el: unknown): el is Node {\n return el instanceof HTMLElement && el.parentNode instanceof HTMLElement;\n}\n\n/**\n * Takes a given el and event handlers, assigns them, and returns the used abort\n * controller.\n *\n * @param el - The element to add the event listeners to.\n * @param events - The events to add to the element.\n * @returns - The abort controller used for the event listeners.\n */\nexport function addEvents(\n el: Document | ShadowRoot | Node | HTMLElement,\n events: EventHandlers | any\n): AbortController {\n const abortController = new AbortController();\n\n for (const eventName in events) {\n const handler = events[eventName];\n\n el.addEventListener(eventName, handler, {\n signal: abortController.signal,\n passive: false,\n });\n }\n\n return abortController;\n}\n\nexport function copyNodeStyle(\n sourceNode: HTMLElement,\n targetNode: HTMLElement,\n omitKeys = false\n) {\n const computedStyle = window.getComputedStyle(sourceNode);\n\n const omittedKeys = [\n \"position\",\n \"z-index\",\n \"top\",\n \"left\",\n \"x\",\n \"pointer-events\",\n \"y\",\n \"transform-origin\",\n \"filter\",\n \"-webkit-text-fill-color\",\n ];\n\n for (const key of Array.from(computedStyle)) {\n if (omitKeys === false && key && omittedKeys.includes(key)) continue;\n\n targetNode.style.setProperty(\n key,\n computedStyle.getPropertyValue(key),\n computedStyle.getPropertyPriority(key)\n );\n }\n\n for (const child of Array.from(sourceNode.children)) {\n if (!isNode(child)) continue;\n\n const targetChild = targetNode.children[\n Array.from(sourceNode.children).indexOf(child)\n ] as Node;\n\n copyNodeStyle(child, targetChild, omitKeys);\n }\n}\n\nexport function eventCoordinates(data: DragEvent | PointerEvent) {\n return { x: data.clientX, y: data.clientY };\n}\n\nexport function getRealCoords(el: HTMLElement): Coordinates {\n const { top, bottom, left, right, height, width } =\n el.getBoundingClientRect();\n\n const scrollLeft = window.scrollX || document.documentElement.scrollLeft;\n const scrollTop = window.scrollY || document.documentElement.scrollTop;\n\n const adjustedTop = top + scrollTop;\n const adjustedBottom = bottom + scrollTop;\n const adjustedLeft = left + scrollLeft;\n const adjustedRight = right + scrollLeft;\n\n return {\n top: adjustedTop,\n bottom: adjustedBottom,\n left: adjustedLeft,\n right: adjustedRight,\n height,\n width,\n };\n}\n","import type { SetupNodeData, Node } from \"../../types\";\nimport type { AnimationsConfig } from \"./types\";\nimport { state, parents, isDragState } from \"../../index\";\n\nexport function animations(animationsConfig: Partial = {}) {\n const slideUp = [\n {\n transform: `translateY(${animationsConfig.yScale || 50}%)`,\n },\n {\n transform: `translateY(${animationsConfig.yScale || 0}%)`,\n },\n ];\n\n const slideDown = [\n {\n transform: `translateY(-${animationsConfig.yScale || 50}%)`,\n },\n {\n transform: `translateY(${animationsConfig.yScale || 0}%)`,\n },\n ];\n\n const slideLeft = [\n {\n transform: `translateX(${animationsConfig.xScale || 50}%)`,\n },\n {\n transform: `translateX(${animationsConfig.xScale || 0}%)`,\n },\n ];\n\n const slideRight = [\n {\n transform: `translateX(-${animationsConfig.xScale || 50}%)`,\n },\n {\n transform: `translateX(${animationsConfig.xScale || 0}%)`,\n },\n ];\n return (parent: HTMLElement) => {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n return {\n setup() {\n if (document.head.querySelector(\"[data-drag-and-drop]\")) return;\n },\n\n setupNodeRemap(data: SetupNodeData) {\n if (!isDragState(state)) return;\n\n const duration = animationsConfig.duration || 150;\n\n if (data.node.data.value === state.draggedNode.data.value) {\n switch (state.incomingDirection) {\n case \"below\":\n animate(data.node.el, slideUp, duration);\n\n break;\n case \"above\":\n animate(data.node.el, slideDown, duration);\n\n break;\n case \"left\":\n animate(data.node.el, slideRight, duration);\n\n break;\n case \"right\":\n animate(data.node.el, slideLeft, duration);\n\n break;\n }\n\n return;\n }\n\n if (\n !state.affectedNodes\n .map((x) => x.data.value)\n .includes(data.node.data.value)\n )\n return;\n\n const nodeRect = data.node.el.getBoundingClientRect();\n\n const nodeIndex = state.affectedNodes.findIndex(\n (x) => x.data.value === data.node.data.value\n );\n\n const draggedNodeIndex = state.draggedNode.data.index;\n\n const ascendingDirection = draggedNodeIndex >= state.targetIndex;\n\n let adjacentNode;\n\n if (ascendingDirection) {\n adjacentNode = state.affectedNodes[nodeIndex + 1]\n ? state.affectedNodes[nodeIndex + 1]\n : state.affectedNodes[nodeIndex - 1];\n } else {\n adjacentNode = state.affectedNodes[nodeIndex - 1]\n ? state.affectedNodes[nodeIndex - 1]\n : state.affectedNodes[nodeIndex + 1];\n }\n\n if (adjacentNode) {\n const xDiff = Math.abs(\n nodeRect.x - adjacentNode.el.getBoundingClientRect().x\n );\n\n const yDiff = Math.abs(\n nodeRect.y - adjacentNode.el.getBoundingClientRect().y\n );\n\n if (xDiff > yDiff && ascendingDirection) {\n animate(data.node.el, slideRight, duration);\n } else if (xDiff > yDiff && !ascendingDirection) {\n animate(data.node.el, slideLeft, duration);\n }\n } else {\n switch (state.incomingDirection) {\n case \"below\":\n animate(data.node.el, slideDown, duration);\n\n break;\n case \"above\":\n animate(data.node.el, slideUp, duration);\n\n break;\n case \"left\":\n animate(data.node.el, slideLeft, duration);\n\n break;\n case \"right\":\n animate(data.node.el, slideRight, duration);\n\n break;\n }\n }\n },\n };\n };\n}\n\nfunction animate(\n node: Node,\n animation: Keyframe[] | PropertyIndexedKeyframes,\n duration: number\n) {\n if (!state) return;\n\n state.preventEnter = true;\n\n node.animate(animation, {\n duration: duration,\n easing: \"ease-in-out\",\n });\n\n setTimeout(() => {\n if (!state) return;\n\n state.preventEnter = false;\n }, duration);\n}\n","import type { InsertionConfig, InsertionParentConfig } from \"./types\";\nimport type {\n DragState,\n NodeDragEventData,\n NodeRecord,\n ParentEventData,\n NodePointerEventData,\n PointeroverParentEvent,\n ParentRecord,\n Coordinates,\n} from \"../../types\";\n\nimport {\n handleEnd as originalHandleEnd,\n parents,\n parentValues,\n setParentValues,\n state,\n addParentClass,\n isDragState,\n eventCoordinates,\n removeClass,\n getRealCoords,\n} from \"../../index\";\n\nexport const insertionState = {\n draggedOverNodes: Array>(),\n draggedOverParent: null as ParentRecord | null,\n targetIndex: 0,\n ascending: false,\n};\n\n// WIP: This is a work in progress and not yet fully functional\nexport function insertion(\n insertionConfig: Partial> = {}\n) {\n return (parent: HTMLElement) => {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n const insertionParentConfig = {\n ...parentData.config,\n insertionConfig: insertionConfig,\n } as InsertionParentConfig;\n\n return {\n teardown() {\n if (parentData.abortControllers.root) {\n parentData.abortControllers.root.abort();\n }\n },\n setup() {\n insertionParentConfig.handleDragoverNode =\n insertionConfig.handleDragoverNode || handleDragoverNode;\n\n insertionParentConfig.handlePointeroverParent =\n insertionConfig.handlePointeroverParent || handlePointeroverParent;\n\n insertionParentConfig.handlePointeroverNode =\n insertionConfig.handlePointeroverNode || handlePointeroverParent;\n\n insertionParentConfig.handleDragoverParent =\n insertionConfig.handleDragoverParent || handleDragoverParent;\n\n insertionParentConfig.handleEnd =\n insertionConfig.handleEnd || handleEnd;\n\n document.body.addEventListener(\"dragover\", checkPosition);\n\n document.body.addEventListener(\"pointermove\", checkPosition);\n\n const observer = new ResizeObserver(() => {\n defineRanges(parent);\n });\n\n observer.observe(parent);\n\n parentData.config = insertionParentConfig;\n\n state.on(\"dragStarted\", () => {\n defineRanges(parent);\n });\n\n const insertionPointConfig = insertionConfig.insertionPoint || {};\n\n const div = document.createElement(insertionPointConfig.tag || \"div\");\n\n div.id = insertionPointConfig.id || \"insertion-point\";\n\n div.classList.add(\n ...(insertionPointConfig.classes || [\"insertion-point\"])\n );\n\n div.style.position = \"absolute\";\n\n div.style.display = \"none\";\n\n document.body.appendChild(div);\n\n window.addEventListener(\"scroll\", defineRanges.bind(null, parent));\n\n window.addEventListener(\"resize\", defineRanges.bind(null, parent));\n },\n\n remapFinished() {\n defineRanges(parent);\n },\n };\n };\n}\n\nfunction checkPosition(e: DragEvent | PointerEvent) {\n if (!isDragState(state)) return;\n\n const el = document.elementFromPoint(e.clientX, e.clientY);\n\n if (!(el instanceof HTMLElement)) return;\n\n if (!parents.has(el)) {\n const insertionPoint = document.getElementById(\"insertion-point\");\n\n if (insertionPoint && insertionPoint === el) return;\n\n if (insertionPoint) insertionPoint.style.display = \"none\";\n\n if (insertionState.draggedOverParent) {\n removeClass(\n [insertionState.draggedOverParent.el],\n insertionState.draggedOverParent.data.config.dropZoneClass\n );\n }\n\n insertionState.draggedOverNodes = [];\n\n insertionState.draggedOverParent = null;\n\n state.currentParent = state.initialParent;\n }\n}\n\nfunction ascendingVertical(\n nodeCoords: Coordinates,\n nextNodeCoords?: Coordinates\n) {\n const center = nodeCoords.top + nodeCoords.height / 2;\n\n if (!nextNodeCoords) {\n return {\n y: [center, center + nodeCoords.height / 2 + 10],\n x: [nodeCoords.left, nodeCoords.right],\n vertical: true,\n };\n }\n\n return {\n y: [\n center,\n nodeCoords.bottom + Math.abs(nodeCoords.bottom - nextNodeCoords.top) / 2,\n ],\n x: [nodeCoords.left, nodeCoords.right],\n vertical: true,\n };\n}\n\nfunction descendingVertical(\n nodeCoords: Coordinates,\n prevNodeCoords?: Coordinates\n) {\n const center = nodeCoords.top + nodeCoords.height / 2;\n\n if (!prevNodeCoords) {\n return {\n y: [center - nodeCoords.height / 2 - 10, center],\n x: [nodeCoords.left, nodeCoords.right],\n vertical: true,\n };\n }\n\n return {\n y: [\n prevNodeCoords.bottom +\n Math.abs(prevNodeCoords.bottom - nodeCoords.top) / 2,\n center,\n ],\n x: [nodeCoords.left, nodeCoords.right],\n vertical: true,\n };\n}\n\nfunction ascendingHorizontal(\n nodeCoords: Coordinates,\n nextNodeCoords?: Coordinates,\n lastInRow = false\n) {\n const center = nodeCoords.left + nodeCoords.width / 2;\n\n if (!nextNodeCoords) {\n return {\n x: [center, center + nodeCoords.width],\n y: [nodeCoords.top, nodeCoords.bottom],\n vertical: false,\n };\n }\n\n if (lastInRow) {\n return {\n x: [center, nodeCoords.right + 10],\n y: [nodeCoords.top, nodeCoords.bottom],\n vertical: false,\n };\n } else {\n const nextNodeCenter = nextNodeCoords.left + nextNodeCoords.width / 2;\n\n return {\n x: [center, center + Math.abs(center - nextNodeCenter) / 2],\n y: [nodeCoords.top, nodeCoords.bottom],\n vertical: false,\n };\n }\n}\n\nfunction descendingHorizontal(\n nodeCoords: Coordinates,\n prevNodeCoords?: Coordinates\n) {\n const center = nodeCoords.left + nodeCoords.width / 2;\n\n if (!prevNodeCoords) {\n return {\n x: [nodeCoords.left - 10, center],\n y: [nodeCoords.top, nodeCoords.bottom],\n vertical: false,\n };\n }\n\n return {\n x: [\n prevNodeCoords.right +\n Math.abs(prevNodeCoords.right - nodeCoords.left) / 2,\n center,\n ],\n y: [nodeCoords.top, nodeCoords.bottom],\n vertical: false,\n };\n}\n\nfunction defineRanges(parent: HTMLElement) {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n const enabledNodes = parentData.enabledNodes;\n\n enabledNodes.forEach((node, index) => {\n let aboveOrBelowPrevious = false;\n\n let aboveOrBelowAfter = false;\n\n let prevNodeCoords = undefined;\n\n let nextNodeCoords = undefined;\n\n if (enabledNodes[index - 1])\n prevNodeCoords = getRealCoords(enabledNodes[index - 1].el);\n\n if (enabledNodes[index + 1])\n nextNodeCoords = getRealCoords(enabledNodes[index + 1].el);\n\n const nodeCoords = getRealCoords(node.el);\n\n if (prevNodeCoords) {\n aboveOrBelowPrevious =\n nodeCoords.top > prevNodeCoords.bottom ||\n nodeCoords.bottom < prevNodeCoords.top;\n }\n\n if (nextNodeCoords) {\n aboveOrBelowAfter =\n nodeCoords.top > nextNodeCoords.bottom ||\n nodeCoords.bottom < nextNodeCoords.top;\n }\n\n const fullishWidth =\n parent.getBoundingClientRect().width * 0.8 < nodeCoords.width;\n\n if (!node.data.range) return;\n\n if (fullishWidth) {\n node.data.range.ascending = ascendingVertical(nodeCoords, nextNodeCoords);\n node.data.range.descending = descendingVertical(\n nodeCoords,\n prevNodeCoords\n );\n } else if (aboveOrBelowAfter && !aboveOrBelowPrevious) {\n node.data.range.ascending = ascendingHorizontal(\n nodeCoords,\n nextNodeCoords,\n true\n );\n node.data.range.descending = descendingHorizontal(\n nodeCoords,\n prevNodeCoords\n );\n } else if (!aboveOrBelowPrevious && !aboveOrBelowAfter) {\n node.data.range.ascending = ascendingHorizontal(\n nodeCoords,\n nextNodeCoords\n );\n node.data.range.descending = descendingHorizontal(\n nodeCoords,\n prevNodeCoords\n );\n } else if (aboveOrBelowPrevious && !nextNodeCoords) {\n node.data.range.ascending = ascendingHorizontal(nodeCoords);\n } else if (aboveOrBelowPrevious && !aboveOrBelowAfter) {\n node.data.range.ascending = ascendingHorizontal(\n nodeCoords,\n nextNodeCoords\n );\n\n node.data.range.descending = descendingHorizontal(nodeCoords);\n }\n });\n}\n\nexport function handleDragoverNode(data: NodeDragEventData) {\n data.e.preventDefault();\n}\n\nexport function handleDragoverParent(\n data: ParentEventData,\n state: DragState\n) {\n if (!insertionState) return;\n\n data.e.stopPropagation();\n\n data.e.preventDefault();\n\n const { x, y } = eventCoordinates(data.e as DragEvent | PointerEvent);\n\n // Get the client coordinates\n const clientX = x;\n const clientY = y;\n\n // Get the scroll positions\n const scrollLeft = window.scrollX || document.documentElement.scrollLeft;\n const scrollTop = window.scrollY || document.documentElement.scrollTop;\n\n // Calculate the coordinates relative to the entire document\n state.coordinates.x = clientX + scrollLeft;\n state.coordinates.y = clientY + scrollTop;\n\n const nestedParent = data.targetData.parent.data.nestedParent;\n\n let realTargetParent = data.targetData.parent;\n\n if (nestedParent) {\n const rect = nestedParent.el.getBoundingClientRect();\n\n if (state.coordinates.y > rect.top && state.coordinates.y < rect.bottom)\n realTargetParent = nestedParent;\n }\n\n realTargetParent.el === state.currentParent?.el\n ? moveBetween(realTargetParent)\n : moveOutside(realTargetParent, state);\n\n state.currentParent = realTargetParent;\n}\n\nexport function moveBetween(data: ParentRecord) {\n if (data.data.config.sortable === false) return;\n\n if (\n data.el === insertionState.draggedOverParent?.el &&\n insertionState.draggedOverParent.data.getValues(data.el).length === 0\n ) {\n return;\n } else if (insertionState.draggedOverParent?.el) {\n removeClass(\n [insertionState.draggedOverParent.el],\n insertionState.draggedOverParent.data.config.dropZoneClass\n );\n insertionState.draggedOverParent = null;\n }\n\n const foundRange = findClosest(data.data.enabledNodes);\n\n if (!foundRange) return;\n\n const position =\n foundRange[0].data.range![foundRange[1] as \"ascending\" | \"descending\"];\n\n if (!position) return;\n\n positionInsertionPoint(\n position,\n foundRange[1] === \"ascending\",\n foundRange[0]\n );\n}\n\nfunction moveOutside(data: ParentRecord, state: DragState) {\n if (data.el === state.currentParent.el) return false;\n\n const targetConfig = data.data.config;\n\n if (targetConfig.treeGroup && state.draggedNode.el.contains(data.el))\n return false;\n\n if (targetConfig.dropZone === false) return false;\n\n const initialParentConfig = state.initialParent.data.config;\n\n if (targetConfig.accepts) {\n return targetConfig.accepts(\n data,\n state.initialParent,\n state.currentParent,\n state\n );\n } else if (\n !targetConfig.group ||\n targetConfig.group !== initialParentConfig.group\n ) {\n return false;\n }\n\n const values = data.data.getValues(data.el);\n\n if (!values.length) {\n addParentClass([data.el], targetConfig.dropZoneClass);\n\n insertionState.draggedOverParent = data;\n\n const insertionPoint = document.getElementById(\"insertion-point\");\n\n if (insertionPoint) insertionPoint.style.display = \"none\";\n } else {\n removeClass([state.currentParent.el], targetConfig.dropZoneClass);\n\n const enabledNodes = data.data.enabledNodes;\n\n const foundRange = findClosest(enabledNodes);\n\n if (!foundRange) return;\n\n const position =\n foundRange[0].data.range![foundRange[1] as \"ascending\" | \"descending\"];\n\n if (!position) return;\n\n positionInsertionPoint(\n position,\n foundRange[1] === \"ascending\",\n foundRange[0]\n );\n }\n}\n\nfunction findClosest(enabledNodes: NodeRecord[]) {\n let foundRange: [NodeRecord, string] | null = null;\n\n for (let x = 0; x < enabledNodes.length; x++) {\n if (!isDragState(state) || !enabledNodes[x].data.range) continue;\n\n const ascending = enabledNodes[x].data.range!.ascending;\n\n const descending = enabledNodes[x].data.range!.descending;\n\n if (!ascending && !descending) continue;\n\n if (ascending) {\n if (\n state.coordinates.y > ascending.y[0] &&\n state.coordinates.y < ascending.y[1] &&\n state.coordinates.x > ascending.x[0] &&\n state.coordinates.x < ascending.x[1]\n ) {\n foundRange = [enabledNodes[x], \"ascending\"];\n\n return foundRange;\n }\n }\n\n if (descending) {\n if (\n state.coordinates.y > descending.y[0] &&\n state.coordinates.y < descending.y[1] &&\n state.coordinates.x > descending.x[0] &&\n state.coordinates.x < descending.x[1]\n ) {\n foundRange = [enabledNodes[x], \"descending\"];\n\n return foundRange;\n }\n }\n }\n}\n\nexport function handlePointeroverParent(\n data: PointeroverParentEvent,\n state: DragState\n) {\n if (!insertionState) return;\n\n data.detail.e.stopPropagation();\n\n const { x, y } = eventCoordinates(data.detail.e as PointerEvent);\n\n state.coordinates.y = y;\n\n state.coordinates.x = x;\n\n const nestedParent = data.detail.targetData.parent.data.nestedParent;\n\n let realTargetParent = data.detail.targetData.parent;\n\n if (nestedParent) {\n const rect = nestedParent.el.getBoundingClientRect();\n\n if (state.coordinates.y > rect.top && state.coordinates.y < rect.bottom)\n realTargetParent = nestedParent;\n }\n\n const enabledNodes = realTargetParent.data.enabledNodes;\n\n const foundRange = findClosest(enabledNodes);\n\n if (!foundRange) return;\n\n const position =\n foundRange[0].data.range![foundRange[1] as \"ascending\" | \"descending\"];\n\n positionInsertionPoint(\n position,\n foundRange[1] === \"ascending\",\n foundRange[0]\n );\n\n data.detail.targetData.parent.el === state.currentParent?.el\n ? moveBetween(realTargetParent)\n : moveOutside(realTargetParent, state);\n}\n\nfunction positionInsertionPoint(\n position: { x: number[]; y: number[]; vertical: boolean },\n ascending: boolean,\n node: NodeRecord\n) {\n if (!state) return;\n\n const div = document.getElementById(\"insertion-point\");\n\n if (!div) return;\n\n insertionState.draggedOverNodes = [node];\n\n if (position.vertical) {\n const topPosition =\n position.y[ascending ? 1 : 0] - div.getBoundingClientRect().height / 2;\n\n div.style.top = `${topPosition}px`;\n\n const leftCoordinate = position.x[0];\n\n const rightCoordinate = position.x[1];\n\n div.style.left = `${leftCoordinate}px`;\n\n div.style.right = `${rightCoordinate}px`;\n\n div.style.height = \"4px\";\n\n div.style.width = rightCoordinate - leftCoordinate + \"px\";\n } else {\n const leftPosition =\n position.x[ascending ? 1 : 0] - div.getBoundingClientRect().width / 2;\n div.style.left = `${leftPosition}px`;\n\n const topCoordinate = position.y[0];\n\n const bottomCoordinate = position.y[1];\n\n div.style.top = `${topCoordinate}px`;\n\n div.style.bottom = `${bottomCoordinate}px`;\n\n div.style.width = \"4px\";\n\n div.style.height = bottomCoordinate - topCoordinate + \"px\";\n }\n\n insertionState.targetIndex = node.data.index;\n\n insertionState.ascending = ascending;\n\n div.style.display = \"block\";\n}\n\nexport function handleParentDrop(_data: NodeDragEventData) {}\n\nexport function handleEnd(\n data: NodeDragEventData | NodePointerEventData,\n state: DragState\n) {\n data.e.stopPropagation();\n\n const insertionPoint = document.getElementById(\"insertion-point\");\n\n if (!insertionState.draggedOverParent) {\n const draggedParentValues = parentValues(\n state.initialParent.el,\n state.initialParent.data\n );\n\n const transferred = state.initialParent.el !== state.currentParent.el;\n\n const draggedValues = state.draggedNodes.map((node) => node.data.value);\n\n const enabledNodes = [...data.targetData.parent.data.enabledNodes];\n\n const originalIndex = state.draggedNodes[0].data.index;\n\n if (\n !transferred &&\n insertionState.draggedOverNodes[0] &&\n insertionState.draggedOverNodes[0].el !== state.draggedNodes[0].el\n ) {\n const newParentValues = [\n ...draggedParentValues.filter((x) => !draggedValues.includes(x)),\n ];\n\n let index = insertionState.draggedOverNodes[0].data.index;\n\n if (\n insertionState.targetIndex > state.draggedNodes[0].data.index &&\n !insertionState.ascending\n ) {\n index--;\n } else if (\n insertionState.targetIndex < state.draggedNodes[0].data.index &&\n insertionState.ascending\n ) {\n index++;\n }\n\n newParentValues.splice(index, 0, ...draggedValues);\n\n setParentValues(data.targetData.parent.el, data.targetData.parent.data, [\n ...newParentValues,\n ]);\n\n if (data.targetData.parent.data.config.onSort) {\n const sortEventData = {\n parent: {\n el: data.targetData.parent.el,\n data: data.targetData.parent.data,\n },\n previousValues: [...draggedParentValues],\n previousNodes: [...enabledNodes],\n nodes: [...data.targetData.parent.data.enabledNodes],\n values: [...newParentValues],\n draggedNode: state.draggedNode,\n previousPosition: originalIndex,\n position: index,\n };\n\n data.targetData.parent.data.config.onSort(sortEventData);\n }\n } else if (transferred && insertionState.draggedOverNodes.length) {\n const targetParentValues = parentValues(\n state.currentParent.el,\n state.currentParent.data\n );\n const draggedParentValues = parentValues(\n state.initialParent.el,\n state.initialParent.data\n );\n\n // For the time being, we will not be remoing the value of the original dragged parent.\n let index = insertionState.draggedOverNodes[0].data.index || 0;\n\n if (insertionState.ascending) index++;\n\n const insertValues = state.dynamicValues.length\n ? state.dynamicValues\n : draggedValues;\n targetParentValues.splice(index, 0, ...insertValues);\n setParentValues(state.currentParent.el, state.currentParent.data, [\n ...targetParentValues,\n ]);\n draggedParentValues.splice(state.initialIndex, draggedValues.length);\n setParentValues(state.initialParent.el, state.initialParent.data, [\n ...draggedParentValues,\n ]);\n\n const transferEventData = {\n sourceParent: state.currentParent,\n targetParent: data.targetData.parent,\n initialParent: state.initialParent,\n draggedNodes: state.draggedNodes,\n targetIndex: index,\n state,\n };\n if (data.targetData.parent.data.config.onTransfer)\n data.targetData.parent.data.config.onTransfer(transferEventData);\n if (state.currentParent.data.config.onTransfer)\n state.currentParent.data.config.onTransfer(transferEventData);\n }\n } else if (insertionState.draggedOverParent) {\n const draggedOverParentValues = parentValues(\n insertionState.draggedOverParent.el,\n insertionState.draggedOverParent.data\n );\n\n const draggedValues = state.draggedNodes.map((node) => node.data.value);\n\n const insertValues = state.dynamicValues.length\n ? state.dynamicValues\n : draggedValues;\n\n draggedOverParentValues.push(...insertValues);\n\n setParentValues(\n insertionState.draggedOverParent.el,\n insertionState.draggedOverParent.data,\n [...draggedOverParentValues]\n );\n\n const transferEventData = {\n sourceParent: state.currentParent,\n targetParent: insertionState.draggedOverParent,\n initialParent: state.initialParent,\n draggedNodes: state.draggedNodes,\n targetIndex: draggedOverParentValues.length - 1,\n state,\n };\n if (data.targetData.parent.data.config.onTransfer)\n data.targetData.parent.data.config.onTransfer(transferEventData);\n if (state.currentParent.data.config.onTransfer)\n state.currentParent.data.config.onTransfer(transferEventData);\n\n removeClass(\n [insertionState.draggedOverParent.el],\n insertionState.draggedOverParent.data.config.dropZoneClass\n );\n }\n\n if (insertionPoint) insertionPoint.style.display = \"none\";\n\n const dropZoneClass =\n \"clonedDraggedNode\" in state\n ? data.targetData.parent.data.config.synthDropZoneClass\n : data.targetData.parent.data.config.dropZoneClass;\n\n removeClass(\n insertionState.draggedOverNodes.map((node) => node.el),\n dropZoneClass\n );\n\n const dragPlaceholderClass =\n data.targetData.parent.data.config.dragPlaceholderClass;\n\n removeClass(\n state.draggedNodes.map((node) => node.el),\n dragPlaceholderClass\n );\n\n insertionState.draggedOverNodes = [];\n\n originalHandleEnd(data, state);\n}\n","import type {\n NodeDragEventData,\n ParentConfig,\n DragState,\n SynthDragState,\n NodeRecord,\n PointeroverNodeEvent,\n ParentDragEventData,\n PointeroverParentEvent,\n} from \"../../types\";\nimport {\n parents,\n parentValues,\n setParentValues,\n addNodeClass,\n isSynthDragState,\n removeClass,\n addClass,\n state,\n isDragState,\n} from \"../../index\";\n\nexport const placeState = {\n draggedOverNodes: Array>(),\n};\n\nlet dragoverEventListeneerSet = false;\n\ninterface PlaceConfig extends ParentConfig {}\n\nexport function place(placeConfig: Partial> = {}) {\n return (parent: HTMLElement) => {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n const placeParentConfig = {\n ...parentData.config,\n placeConfig: placeConfig,\n } as PlaceConfig;\n\n if (!dragoverEventListeneerSet) {\n document.addEventListener(\"dragover\", rootDragover);\n document.addEventListener(\n \"handleRootPointerover\" as keyof DocumentEventMap,\n (e) => rootPointerover(e as CustomEvent)\n );\n }\n\n return {\n setup() {\n placeParentConfig.handleNodeDragover =\n placeConfig.handleNodeDragover || handleDragoverNode;\n\n placeParentConfig.handleParentDragover =\n placeConfig.handleParentDragover || handleDragoverParent;\n\n placeParentConfig.handleNodePointerover =\n placeConfig.handleNodePointerover || handleNodePointerover;\n\n placeParentConfig.handleParentPointerover =\n placeConfig.handleParentPointerover || handlePointeroverParent;\n\n const originalHandleend = placeParentConfig.handleEnd;\n placeParentConfig.handleEnd = (state) => {\n handleEnd(state);\n\n originalHandleend(state);\n };\n\n parentData.config = placeParentConfig;\n },\n };\n };\n}\n\nfunction rootDragover(_e: DragEvent) {\n if (!isDragState(state)) return;\n\n removeClass(\n [state.currentParent.el],\n state.currentParent.data.config.dropZoneParentClass\n );\n}\n\nfunction rootPointerover(_e: CustomEvent) {\n if (!isSynthDragState(state)) return;\n\n removeClass(\n [state.currentParent.el],\n state.currentParent.data.config.synthDropZoneParentClass\n );\n}\n\nfunction updateDraggedOverNodes(\n data: PointeroverNodeEvent | NodeDragEventData,\n state: DragState | SynthDragState\n) {\n const targetData =\n \"detail\" in data ? data.detail.targetData : data.targetData;\n\n const config = targetData.parent.data.config;\n\n const dropZoneClass = isSynthDragState(state)\n ? config.synthDropZoneClass\n : config.dropZoneClass;\n\n removeClass(\n placeState.draggedOverNodes.map((node) => node.el),\n dropZoneClass\n );\n\n const enabledNodes = targetData.parent.data.enabledNodes;\n\n if (!enabledNodes) return;\n\n placeState.draggedOverNodes = enabledNodes.slice(\n targetData.node.data.index,\n targetData.node.data.index + state.draggedNodes.length\n );\n\n addNodeClass(\n placeState.draggedOverNodes.map((node) => node.el),\n dropZoneClass,\n true\n );\n\n state.currentTargetValue = targetData.node.data.value;\n\n state.currentParent = targetData.parent;\n\n addClass(\n state.currentParent.el,\n isSynthDragState(state)\n ? config.synthDropZoneParentClass\n : config.dropZoneParentClass,\n state.currentParent.data,\n true\n );\n}\n\nfunction handleDragoverNode(\n data: NodeDragEventData,\n state: DragState\n) {\n data.e.preventDefault();\n\n data.e.stopPropagation();\n\n updateDraggedOverNodes(data, state);\n}\n\nexport function handleDragoverParent(\n data: ParentDragEventData,\n state: DragState\n) {\n data.e.preventDefault();\n\n data.e.stopPropagation();\n\n const currentConfig = state.currentParent.data.config;\n\n removeClass(\n placeState.draggedOverNodes.map((node) => node.el),\n currentConfig.dropZoneClass\n );\n\n removeClass([state.currentParent.el], currentConfig.dropZoneParentClass);\n\n const config = data.targetData.parent.data.config;\n\n addClass(\n data.targetData.parent.el,\n config.dropZoneParentClass,\n data.targetData.parent.data,\n true\n );\n\n placeState.draggedOverNodes = [];\n\n state.currentParent = data.targetData.parent;\n}\n\nexport function handlePointeroverParent(data: PointeroverParentEvent) {\n const currentConfig = data.detail.state.currentParent.data.config;\n\n removeClass(\n placeState.draggedOverNodes.map((node) => node.el),\n currentConfig.synthDropZoneClass\n );\n\n removeClass(\n [data.detail.state.currentParent.el],\n currentConfig.synthDropZoneParentClass\n );\n\n const config = data.detail.targetData.parent.data.config;\n\n addClass(\n data.detail.targetData.parent.el,\n config.synthDropZoneParentClass,\n data.detail.targetData.parent.data,\n true\n );\n\n placeState.draggedOverNodes = [];\n}\n\nfunction handleNodePointerover(data: PointeroverNodeEvent) {\n if (!isSynthDragState(data.detail.state)) return;\n\n updateDraggedOverNodes(data, data.detail.state);\n}\n\nfunction handleEnd(state: DragState | SynthDragState) {\n const isSynth = isSynthDragState(state);\n\n removeClass(\n [state.currentParent.el],\n isSynth\n ? state.currentParent.data.config.synthDropZoneParentClass\n : state.currentParent.data.config.dropZoneParentClass\n );\n\n const values = parentValues(state.currentParent.el, state.currentParent.data);\n\n const draggedValues = state.draggedNodes.map((node) => node.data.value);\n\n const newValues = values.filter((x) => !draggedValues.includes(x));\n\n const index = placeState.draggedOverNodes[0]?.data.index;\n\n // If we do not have dragged over nodes, then we know that we are appending\n // items to the end of the list/\n index !== undefined\n ? newValues.splice(index, 0, ...draggedValues)\n : newValues.push(...draggedValues);\n\n if (state.initialParent.el !== state.currentParent.el) {\n const initialParentValues = parentValues(\n state.initialParent.el,\n state.initialParent.data\n );\n\n const newInitialValues = initialParentValues.filter(\n (x) => !draggedValues.includes(x)\n );\n setParentValues(\n state.initialParent.el,\n state.initialParent.data,\n newInitialValues\n );\n\n setParentValues(\n state.currentParent.el,\n state.currentParent.data,\n newValues\n );\n } else if (\n state.initialParent.el === state.currentParent.el &&\n placeState.draggedOverNodes.length\n ) {\n setParentValues(\n state.currentParent.el,\n state.currentParent.data,\n newValues\n );\n }\n\n removeClass(\n placeState.draggedOverNodes.map((node) => node.el),\n isSynth\n ? state.currentParent.data.config.synthDropZoneClass\n : state.currentParent.data.config.dropZoneClass\n );\n\n placeState.draggedOverNodes = [];\n}\n","import type {\n NodeDragEventData,\n ParentConfig,\n DragState,\n SynthDragState,\n NodeRecord,\n PointeroverNodeEvent,\n ParentDragEventData,\n PointeroverParentEvent,\n} from \"../../types\";\nimport {\n parents,\n parentValues,\n setParentValues,\n addNodeClass,\n isSynthDragState,\n removeClass,\n addClass,\n state,\n isDragState,\n} from \"../../index\";\n\nexport const placeState = {\n draggedOverNodes: Array>(),\n initialDraggedIndex: 0,\n transferred: false,\n};\n\nlet dragoverEventListeneerSet = false;\n\ninterface SwapConfig extends ParentConfig {}\n\nexport function swap(swapConfig: Partial> = {}) {\n return (parent: HTMLElement) => {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n const swapParentConfig = {\n ...parentData.config,\n swapConfig: swapConfig,\n } as SwapConfig;\n\n if (!dragoverEventListeneerSet) {\n document.addEventListener(\"dragover\", rootDragover);\n document.addEventListener(\n \"handleRootPointerover\" as keyof DocumentEventMap,\n (e) => rootPointerover(e as CustomEvent)\n );\n }\n\n return {\n setup() {\n swapParentConfig.handleNodeDragover =\n swapConfig.handleNodeDragover || handleDragoverNode;\n\n swapParentConfig.handleParentDragover =\n swapConfig.handleParentDragover || handleDragoverParent;\n\n swapParentConfig.handleNodePointerover =\n swapConfig.handleNodePointerover || handleNodePointerover;\n\n swapParentConfig.handleParentPointerover =\n swapConfig.handleParentPointerover || handeParentPointerover;\n\n const originalHandleend = swapParentConfig.handleEnd;\n swapParentConfig.handleEnd = (state) => {\n handleEnd(state);\n\n originalHandleend(state);\n };\n\n parentData.config = swapParentConfig;\n },\n };\n };\n}\n\nfunction rootDragover(_e: DragEvent) {\n if (!isDragState(state)) return;\n\n removeClass(\n [state.currentParent.el],\n state.currentParent.data.config.dropZoneParentClass\n );\n\n state.currentParent = state.initialParent;\n}\n\nfunction rootPointerover(_e: CustomEvent) {\n if (!isSynthDragState(state)) return;\n\n removeClass(\n [state.currentParent.el],\n state.currentParent.data.config.synthDropZoneParentClass\n );\n\n state.currentParent = state.initialParent;\n}\n\nfunction updateDraggedOverNodes(\n data: PointeroverNodeEvent | NodeDragEventData,\n state: DragState | SynthDragState\n) {\n const targetData =\n \"detail\" in data ? data.detail.targetData : data.targetData;\n\n const config = targetData.parent.data.config;\n\n const dropZoneClass = isSynthDragState(state)\n ? config.synthDropZoneClass\n : config.dropZoneClass;\n\n removeClass(\n placeState.draggedOverNodes.map((node) => node.el),\n dropZoneClass\n );\n\n const enabledNodes = targetData.parent.data.enabledNodes;\n\n if (!enabledNodes) return;\n\n placeState.draggedOverNodes = enabledNodes.slice(\n targetData.node.data.index,\n targetData.node.data.index + state.draggedNodes.length\n );\n\n addNodeClass(\n placeState.draggedOverNodes.map((node) => node.el),\n dropZoneClass,\n true\n );\n\n state.currentTargetValue = targetData.node.data.value;\n\n state.currentParent = targetData.parent;\n\n addClass(\n state.currentParent.el,\n isSynthDragState(state)\n ? config.synthDropZoneParentClass\n : config.dropZoneParentClass,\n state.currentParent.data,\n true\n );\n}\n\nfunction handleDragoverNode(\n data: NodeDragEventData,\n state: DragState\n) {\n data.e.preventDefault();\n\n data.e.stopPropagation();\n\n updateDraggedOverNodes(data, state);\n}\n\nexport function handleDragoverParent(\n data: ParentDragEventData,\n state: DragState\n) {\n data.e.preventDefault();\n\n data.e.stopPropagation();\n\n const currentConfig = state.currentParent.data.config;\n\n removeClass(\n placeState.draggedOverNodes.map((node) => node.el),\n currentConfig.dropZoneClass\n );\n\n removeClass([state.currentParent.el], currentConfig.dropZoneParentClass);\n\n const config = data.targetData.parent.data.config;\n\n addClass(\n data.targetData.parent.el,\n config.dropZoneParentClass,\n data.targetData.parent.data,\n true\n );\n\n placeState.draggedOverNodes = [];\n\n state.currentParent = data.targetData.parent;\n}\n\nexport function handeParentPointerover(data: PointeroverParentEvent) {\n const currentConfig = data.detail.state.currentParent.data.config;\n\n removeClass(\n placeState.draggedOverNodes.map((node) => node.el),\n currentConfig.synthDropZoneClass\n );\n\n removeClass(\n [data.detail.state.currentParent.el],\n currentConfig.synthDropZoneParentClass\n );\n\n const config = data.detail.targetData.parent.data.config;\n\n addClass(\n data.detail.targetData.parent.el,\n config.synthDropZoneParentClass,\n data.detail.targetData.parent.data,\n true\n );\n\n placeState.draggedOverNodes = [];\n\n data.detail.state.currentParent = data.detail.targetData.parent;\n}\n\nfunction handleNodePointerover(data: PointeroverNodeEvent) {\n if (!isSynthDragState(data.detail.state)) return;\n\n updateDraggedOverNodes(data, data.detail.state);\n}\n\nfunction handleEnd(state: DragState | SynthDragState) {\n const isSynth = isSynthDragState(state);\n removeClass(\n [state.currentParent.el],\n isSynth\n ? state.currentParent.data.config.synthDropZoneParentClass\n : state.currentParent.data.config.dropZoneParentClass\n );\n\n const values = parentValues(state.currentParent.el, state.currentParent.data);\n\n const draggedValues = state.draggedNodes.map((node) => node.data.value);\n\n const newValues = values.filter((x) => !draggedValues.includes(x));\n\n const targetIndex = placeState.draggedOverNodes[0]?.data.index;\n\n let newTargetParentValues: Array = [];\n\n if (state.initialParent.el == state.currentParent.el) {\n if (targetIndex !== undefined) {\n newValues.splice(targetIndex, 0, ...draggedValues);\n\n setParentValues(\n state.currentParent.el,\n state.currentParent.data,\n newValues\n );\n }\n } else if (state.initialParent.el !== state.currentParent.el) {\n const initialParentValues = parentValues(\n state.initialParent.el,\n state.initialParent.data\n );\n\n if (targetIndex === undefined) {\n newTargetParentValues = newValues.concat(draggedValues);\n\n setParentValues(\n state.currentParent.el,\n state.currentParent.data,\n newTargetParentValues\n );\n\n setParentValues(\n state.initialParent.el,\n state.initialParent.data,\n initialParentValues.filter((x) => !draggedValues.includes(x))\n );\n } else {\n const targetedNodeValues = state.currentParent.data.enabledNodes\n .slice(targetIndex, targetIndex + draggedValues.length)\n .map((node) => node.data.value);\n\n const newInitialParentValues = initialParentValues.filter(\n (x) => !draggedValues.includes(x)\n );\n\n newInitialParentValues.splice(\n state.initialIndex,\n 0,\n ...targetedNodeValues\n );\n\n setParentValues(\n state.initialParent.el,\n state.initialParent.data,\n newInitialParentValues\n );\n\n const newTargetParentValues = newValues.filter(\n (x) => !targetedNodeValues.includes(x)\n );\n\n newTargetParentValues.splice(targetIndex, 0, ...draggedValues);\n\n setParentValues(\n state.currentParent.el,\n state.currentParent.data,\n newTargetParentValues\n );\n }\n }\n\n removeClass(\n placeState.draggedOverNodes.map((node) => node.el),\n isSynth\n ? state.currentParent.data.config.synthDropZoneClass\n : state.currentParent.data.config.dropZoneClass\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIO,SAAS,WAAW,mB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AAC/D,SAAO,EAAE,GAAG,KAAK,SAAS,GAAG,KAAK,QAAQ;AAC5C;AAEO,SAAS,cAAc,IAA8B;AAC1D,QAAM,EAAE,KAAK,QAAQ,MAAM,OAAO,QAAQ,MAAM,IAC9C,GAAG,sBAAsB;AAE3B,QAAM,aAAa,OAAO,WAAW,SAAS,gBAAgB;AAC9D,QAAM,YAAY,OAAO,WAAW,SAAS,gBAAgB;AAE7D,QAAM,cAAc,MAAM;AAC1B,QAAM,iBAAiB,SAAS;AAChC,QAAM,eAAe,OAAO;AAC5B,QAAM,gBAAgB,QAAQ;AAE9B,SAAO;AAAA,IACL,KAAK;AAAA,IACL,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,OAAO;AAAA,IACP;AAAA,IACA;AAAA,EACF;AACF;","names":["handleNodePointerover","handleEnd","state","handleEnd","state","draggedParentValues","handleDragoverNode","handleDragoverParent","handlePointeroverParent","state","handleEnd","placeState","dragoverEventListeneerSet","rootDragover","rootPointerover","handleDragoverNode","handleDragoverParent","handleNodePointerover","state","handleEnd","updateDraggedOverNodes","newTargetParentValues","emit","on","baseDragState","dragStateProps","handleNodePointerover","draggedNodes","state","nodes","parent","x","className"]} \ No newline at end of file diff --git a/dist/index.mjs b/dist/index.mjs index b51ef3c..2924032 100644 --- a/dist/index.mjs +++ b/dist/index.mjs @@ -153,7 +153,6 @@ function insertion(insertionConfig = {}) { observer.observe(parent); parentData.config = insertionParentConfig; state.on("dragStarted", () => { - console.log("drag started"); defineRanges(parent); }); const insertionPointConfig = insertionConfig.insertionPoint || {}; @@ -753,6 +752,11 @@ function handleEnd3(state2) { state2.initialParent.data, newInitialValues ); + setParentValues( + state2.currentParent.el, + state2.currentParent.data, + newValues + ); } else if (state2.initialParent.el === state2.currentParent.el && placeState.draggedOverNodes.length) { setParentValues( state2.currentParent.el, @@ -764,12 +768,16 @@ function handleEnd3(state2) { placeState.draggedOverNodes.map((node) => node.el), isSynth ? state2.currentParent.data.config.synthDropZoneClass : state2.currentParent.data.config.dropZoneClass ); + placeState.draggedOverNodes = []; } // src/plugins/swap/index.ts -var swapState = { - draggedOverNodes: Array() +var placeState2 = { + draggedOverNodes: Array(), + initialDraggedIndex: 0, + transferred: false }; +var dragoverEventListeneerSet2 = false; function swap(swapConfig = {}) { return (parent) => { const parentData = parents.get(parent); @@ -778,44 +786,188 @@ function swap(swapConfig = {}) { ...parentData.config, swapConfig }; + if (!dragoverEventListeneerSet2) { + document.addEventListener("dragover", rootDragover2); + document.addEventListener( + "handleRootPointerover", + (e) => rootPointerover2(e) + ); + } return { setup() { - swapParentConfig.handleDragoverParent = swapConfig.handleDragoverParent || handleDragoverParent3; - swapParentConfig.handleDragoverNode = swapConfig.handleDragoverNode || handleDragoverNode3; - swapParentConfig.handlePointeroverNode = swapConfig.handlePointeroverNode || handlePointeroverNode; - swapParentConfig.handlePointeroverParent = swapConfig.handlePointeroverParent || handlePointeroverParent3; + swapParentConfig.handleNodeDragover = swapConfig.handleNodeDragover || handleDragoverNode3; + swapParentConfig.handleParentDragover = swapConfig.handleParentDragover || handleDragoverParent3; + swapParentConfig.handleNodePointerover = swapConfig.handleNodePointerover || handleNodePointerover2; + swapParentConfig.handleParentPointerover = swapConfig.handleParentPointerover || handeParentPointerover; + const originalHandleend = swapParentConfig.handleEnd; + swapParentConfig.handleEnd = (state2) => { + handleEnd4(state2); + originalHandleend(state2); + }; parentData.config = swapParentConfig; } }; }; } -function handleDragoverNode3(data) { - data.e.preventDefault(); -} -function handleDragoverParent3(_data) { +function rootDragover2(_e) { + if (!isDragState(state)) return; + removeClass( + [state.currentParent.el], + state.currentParent.data.config.dropZoneParentClass + ); + state.currentParent = state.initialParent; } -function handlePointeroverParent3(_data) { +function rootPointerover2(_e) { + if (!isSynthDragState(state)) return; + removeClass( + [state.currentParent.el], + state.currentParent.data.config.synthDropZoneParentClass + ); + state.currentParent = state.initialParent; } -function handlePointeroverNode(data) { - if (!isDragState(state)) return; - if (data.detail.targetData.parent.el !== state.currentParent.el) return; - const dropZoneClass = data.detail.targetData.parent.data.config.synthDropZoneClass; +function updateDraggedOverNodes2(data, state2) { + const targetData = "detail" in data ? data.detail.targetData : data.targetData; + const config = targetData.parent.data.config; + const dropZoneClass = isSynthDragState(state2) ? config.synthDropZoneClass : config.dropZoneClass; removeClass( - swapState.draggedOverNodes.map((node) => node.el), + placeState2.draggedOverNodes.map((node) => node.el), dropZoneClass ); - const enabledNodes = data.detail.targetData.parent.data.enabledNodes; - swapState.draggedOverNodes = enabledNodes.slice( - data.detail.targetData.node.data.index, - data.detail.targetData.node.data.index + state.draggedNodes.length + const enabledNodes = targetData.parent.data.enabledNodes; + if (!enabledNodes) return; + placeState2.draggedOverNodes = enabledNodes.slice( + targetData.node.data.index, + targetData.node.data.index + state2.draggedNodes.length ); addNodeClass( - swapState.draggedOverNodes.map((node) => node.el), + placeState2.draggedOverNodes.map((node) => node.el), dropZoneClass, true ); - state.currentTargetValue = data.detail.targetData.node.data.value; - state.currentParent = data.detail.targetData.parent; + state2.currentTargetValue = targetData.node.data.value; + state2.currentParent = targetData.parent; + addClass( + state2.currentParent.el, + isSynthDragState(state2) ? config.synthDropZoneParentClass : config.dropZoneParentClass, + state2.currentParent.data, + true + ); +} +function handleDragoverNode3(data, state2) { + data.e.preventDefault(); + data.e.stopPropagation(); + updateDraggedOverNodes2(data, state2); +} +function handleDragoverParent3(data, state2) { + data.e.preventDefault(); + data.e.stopPropagation(); + const currentConfig = state2.currentParent.data.config; + removeClass( + placeState2.draggedOverNodes.map((node) => node.el), + currentConfig.dropZoneClass + ); + removeClass([state2.currentParent.el], currentConfig.dropZoneParentClass); + const config = data.targetData.parent.data.config; + addClass( + data.targetData.parent.el, + config.dropZoneParentClass, + data.targetData.parent.data, + true + ); + placeState2.draggedOverNodes = []; + state2.currentParent = data.targetData.parent; +} +function handeParentPointerover(data) { + const currentConfig = data.detail.state.currentParent.data.config; + removeClass( + placeState2.draggedOverNodes.map((node) => node.el), + currentConfig.synthDropZoneClass + ); + removeClass( + [data.detail.state.currentParent.el], + currentConfig.synthDropZoneParentClass + ); + const config = data.detail.targetData.parent.data.config; + addClass( + data.detail.targetData.parent.el, + config.synthDropZoneParentClass, + data.detail.targetData.parent.data, + true + ); + placeState2.draggedOverNodes = []; + data.detail.state.currentParent = data.detail.targetData.parent; +} +function handleNodePointerover2(data) { + if (!isSynthDragState(data.detail.state)) return; + updateDraggedOverNodes2(data, data.detail.state); +} +function handleEnd4(state2) { + const isSynth = isSynthDragState(state2); + removeClass( + [state2.currentParent.el], + isSynth ? state2.currentParent.data.config.synthDropZoneParentClass : state2.currentParent.data.config.dropZoneParentClass + ); + const values = parentValues(state2.currentParent.el, state2.currentParent.data); + const draggedValues = state2.draggedNodes.map((node) => node.data.value); + const newValues = values.filter((x) => !draggedValues.includes(x)); + const targetIndex = placeState2.draggedOverNodes[0]?.data.index; + let newTargetParentValues = []; + if (state2.initialParent.el == state2.currentParent.el) { + if (targetIndex !== void 0) { + newValues.splice(targetIndex, 0, ...draggedValues); + setParentValues( + state2.currentParent.el, + state2.currentParent.data, + newValues + ); + } + } else if (state2.initialParent.el !== state2.currentParent.el) { + const initialParentValues = parentValues( + state2.initialParent.el, + state2.initialParent.data + ); + if (targetIndex === void 0) { + newTargetParentValues = newValues.concat(draggedValues); + setParentValues( + state2.currentParent.el, + state2.currentParent.data, + newTargetParentValues + ); + setParentValues( + state2.initialParent.el, + state2.initialParent.data, + initialParentValues.filter((x) => !draggedValues.includes(x)) + ); + } else { + const targetedNodeValues = state2.currentParent.data.enabledNodes.slice(targetIndex, targetIndex + draggedValues.length).map((node) => node.data.value); + const newInitialParentValues = initialParentValues.filter( + (x) => !draggedValues.includes(x) + ); + newInitialParentValues.splice( + state2.initialIndex, + 0, + ...targetedNodeValues + ); + setParentValues( + state2.initialParent.el, + state2.initialParent.data, + newInitialParentValues + ); + const newTargetParentValues2 = newValues.filter( + (x) => !targetedNodeValues.includes(x) + ); + newTargetParentValues2.splice(targetIndex, 0, ...draggedValues); + setParentValues( + state2.currentParent.el, + state2.currentParent.data, + newTargetParentValues2 + ); + } + } + removeClass( + placeState2.draggedOverNodes.map((node) => node.el), + isSynth ? state2.currentParent.data.config.synthDropZoneClass : state2.currentParent.data.config.dropZoneClass + ); } // src/index.ts @@ -955,7 +1107,7 @@ function dragAndDrop({ handleParentFocus, handleNodePointerup, handleNodeTouchstart, - handleNodePointerover: handleNodePointerover2, + handleNodePointerover: handleNodePointerover3, handleParentPointerover, handleNodePointerdown, handleNodePointermove, @@ -1377,6 +1529,7 @@ function setupNode(data) { dragend: nodeEventData(config.handleDragend), drop: nodeEventData(config.handleNodeDrop), touchstart: nodeEventData(config.handleNodeTouchstart), + pointercancel: nodeEventData(config.handleDragend), pointerdown: nodeEventData(config.handleNodePointerdown), pointerup: nodeEventData(config.handleNodePointerup), pointermove: nodeEventData(config.handleNodePointermove), @@ -1613,7 +1766,6 @@ function handleDragstart(data, state2) { ); } function handleNodePointerdown(data, state2) { - console.log("pointerdown", synthNodePointerDown); if (!validateDragHandle(data)) return; data.e.stopPropagation(); synthNodePointerDown = true; @@ -1878,7 +2030,7 @@ function preventSortOnScroll() { }, 100); }; } -function handleNodePointerover2(e) { +function handleNodePointerover3(e) { if (e.detail.targetData.parent.el === e.detail.state.currentParent.el) sort(e.detail, e.detail.state); else transfer(e.detail, e.detail.state); @@ -2643,7 +2795,7 @@ export { handleNodeKeydown, handleNodePointerdown, handleNodePointermove, - handleNodePointerover2 as handleNodePointerover, + handleNodePointerover3 as handleNodePointerover, handleNodePointerup, handleNodeTouchstart, handleParentBlur, diff --git a/dist/index.mjs.map b/dist/index.mjs.map index f06e82d..cbb3477 100644 --- a/dist/index.mjs.map +++ b/dist/index.mjs.map @@ -1 +1 @@ -{"version":3,"sources":["../src/plugins/animations/index.ts","../src/plugins/insertion/index.ts","../src/plugins/place/index.ts","../src/plugins/swap/index.ts","../src/index.ts"],"sourcesContent":["import type { SetupNodeData, Node } from \"../../types\";\nimport type { AnimationsConfig } from \"./types\";\nimport { state, parents, isDragState } from \"../../index\";\n\nexport function animations(animationsConfig: Partial = {}) {\n const slideUp = [\n {\n transform: `translateY(${animationsConfig.yScale || 50}%)`,\n },\n {\n transform: `translateY(${animationsConfig.yScale || 0}%)`,\n },\n ];\n\n const slideDown = [\n {\n transform: `translateY(-${animationsConfig.yScale || 50}%)`,\n },\n {\n transform: `translateY(${animationsConfig.yScale || 0}%)`,\n },\n ];\n\n const slideLeft = [\n {\n transform: `translateX(${animationsConfig.xScale || 50}%)`,\n },\n {\n transform: `translateX(${animationsConfig.xScale || 0}%)`,\n },\n ];\n\n const slideRight = [\n {\n transform: `translateX(-${animationsConfig.xScale || 50}%)`,\n },\n {\n transform: `translateX(${animationsConfig.xScale || 0}%)`,\n },\n ];\n return (parent: HTMLElement) => {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n return {\n setup() {\n if (document.head.querySelector(\"[data-drag-and-drop]\")) return;\n },\n\n setupNodeRemap(data: SetupNodeData) {\n if (!isDragState(state)) return;\n\n const duration = animationsConfig.duration || 150;\n\n if (data.node.data.value === state.draggedNode.data.value) {\n switch (state.incomingDirection) {\n case \"below\":\n animate(data.node.el, slideUp, duration);\n\n break;\n case \"above\":\n animate(data.node.el, slideDown, duration);\n\n break;\n case \"left\":\n animate(data.node.el, slideRight, duration);\n\n break;\n case \"right\":\n animate(data.node.el, slideLeft, duration);\n\n break;\n }\n\n return;\n }\n\n if (\n !state.affectedNodes\n .map((x) => x.data.value)\n .includes(data.node.data.value)\n )\n return;\n\n const nodeRect = data.node.el.getBoundingClientRect();\n\n const nodeIndex = state.affectedNodes.findIndex(\n (x) => x.data.value === data.node.data.value\n );\n\n const draggedNodeIndex = state.draggedNode.data.index;\n\n const ascendingDirection = draggedNodeIndex >= state.targetIndex;\n\n let adjacentNode;\n\n if (ascendingDirection) {\n adjacentNode = state.affectedNodes[nodeIndex + 1]\n ? state.affectedNodes[nodeIndex + 1]\n : state.affectedNodes[nodeIndex - 1];\n } else {\n adjacentNode = state.affectedNodes[nodeIndex - 1]\n ? state.affectedNodes[nodeIndex - 1]\n : state.affectedNodes[nodeIndex + 1];\n }\n\n if (adjacentNode) {\n const xDiff = Math.abs(\n nodeRect.x - adjacentNode.el.getBoundingClientRect().x\n );\n\n const yDiff = Math.abs(\n nodeRect.y - adjacentNode.el.getBoundingClientRect().y\n );\n\n if (xDiff > yDiff && ascendingDirection) {\n animate(data.node.el, slideRight, duration);\n } else if (xDiff > yDiff && !ascendingDirection) {\n animate(data.node.el, slideLeft, duration);\n }\n } else {\n switch (state.incomingDirection) {\n case \"below\":\n animate(data.node.el, slideDown, duration);\n\n break;\n case \"above\":\n animate(data.node.el, slideUp, duration);\n\n break;\n case \"left\":\n animate(data.node.el, slideLeft, duration);\n\n break;\n case \"right\":\n animate(data.node.el, slideRight, duration);\n\n break;\n }\n }\n },\n };\n };\n}\n\nfunction animate(\n node: Node,\n animation: Keyframe[] | PropertyIndexedKeyframes,\n duration: number\n) {\n if (!state) return;\n\n state.preventEnter = true;\n\n node.animate(animation, {\n duration: duration,\n easing: \"ease-in-out\",\n });\n\n setTimeout(() => {\n if (!state) return;\n\n state.preventEnter = false;\n }, duration);\n}\n","import type { InsertionConfig, InsertionParentConfig } from \"./types\";\nimport type {\n DragState,\n NodeDragEventData,\n NodeRecord,\n ParentEventData,\n NodePointerEventData,\n PointeroverParentEvent,\n ParentRecord,\n Coordinates,\n} from \"../../types\";\n\nimport {\n handleEnd as originalHandleEnd,\n parents,\n parentValues,\n setParentValues,\n state,\n addParentClass,\n isDragState,\n eventCoordinates,\n removeClass,\n getRealCoords,\n} from \"../../index\";\n\nexport const insertionState = {\n draggedOverNodes: Array>(),\n draggedOverParent: null as ParentRecord | null,\n targetIndex: 0,\n ascending: false,\n};\n\n// WIP: This is a work in progress and not yet fully functional\nexport function insertion(\n insertionConfig: Partial> = {}\n) {\n return (parent: HTMLElement) => {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n const insertionParentConfig = {\n ...parentData.config,\n insertionConfig: insertionConfig,\n } as InsertionParentConfig;\n\n return {\n teardown() {\n if (parentData.abortControllers.root) {\n parentData.abortControllers.root.abort();\n }\n },\n setup() {\n insertionParentConfig.handleDragoverNode =\n insertionConfig.handleDragoverNode || handleDragoverNode;\n\n insertionParentConfig.handlePointeroverParent =\n insertionConfig.handlePointeroverParent || handlePointeroverParent;\n\n insertionParentConfig.handlePointeroverNode =\n insertionConfig.handlePointeroverNode || handlePointeroverParent;\n\n insertionParentConfig.handleDragoverParent =\n insertionConfig.handleDragoverParent || handleDragoverParent;\n\n insertionParentConfig.handleEnd =\n insertionConfig.handleEnd || handleEnd;\n\n document.body.addEventListener(\"dragover\", checkPosition);\n\n document.body.addEventListener(\"pointermove\", checkPosition);\n\n const observer = new ResizeObserver(() => {\n defineRanges(parent);\n });\n\n observer.observe(parent);\n\n parentData.config = insertionParentConfig;\n\n state.on(\"dragStarted\", () => {\n console.log(\"drag started\");\n defineRanges(parent);\n });\n\n const insertionPointConfig = insertionConfig.insertionPoint || {};\n\n const div = document.createElement(insertionPointConfig.tag || \"div\");\n\n div.id = insertionPointConfig.id || \"insertion-point\";\n\n div.classList.add(\n ...(insertionPointConfig.classes || [\"insertion-point\"])\n );\n\n div.style.position = \"absolute\";\n\n div.style.display = \"none\";\n\n document.body.appendChild(div);\n\n window.addEventListener(\"scroll\", defineRanges.bind(null, parent));\n\n window.addEventListener(\"resize\", defineRanges.bind(null, parent));\n },\n\n remapFinished() {\n defineRanges(parent);\n },\n };\n };\n}\n\nfunction checkPosition(e: DragEvent | PointerEvent) {\n if (!isDragState(state)) return;\n\n const el = document.elementFromPoint(e.clientX, e.clientY);\n\n if (!(el instanceof HTMLElement)) return;\n\n if (!parents.has(el)) {\n const insertionPoint = document.getElementById(\"insertion-point\");\n\n if (insertionPoint && insertionPoint === el) return;\n\n if (insertionPoint) insertionPoint.style.display = \"none\";\n\n if (insertionState.draggedOverParent) {\n removeClass(\n [insertionState.draggedOverParent.el],\n insertionState.draggedOverParent.data.config.dropZoneClass\n );\n }\n\n insertionState.draggedOverNodes = [];\n\n insertionState.draggedOverParent = null;\n\n state.currentParent = state.initialParent;\n }\n}\n\nfunction ascendingVertical(\n nodeCoords: Coordinates,\n nextNodeCoords?: Coordinates\n) {\n const center = nodeCoords.top + nodeCoords.height / 2;\n\n if (!nextNodeCoords) {\n return {\n y: [center, center + nodeCoords.height / 2 + 10],\n x: [nodeCoords.left, nodeCoords.right],\n vertical: true,\n };\n }\n\n return {\n y: [\n center,\n nodeCoords.bottom + Math.abs(nodeCoords.bottom - nextNodeCoords.top) / 2,\n ],\n x: [nodeCoords.left, nodeCoords.right],\n vertical: true,\n };\n}\n\nfunction descendingVertical(\n nodeCoords: Coordinates,\n prevNodeCoords?: Coordinates\n) {\n const center = nodeCoords.top + nodeCoords.height / 2;\n\n if (!prevNodeCoords) {\n return {\n y: [center - nodeCoords.height / 2 - 10, center],\n x: [nodeCoords.left, nodeCoords.right],\n vertical: true,\n };\n }\n\n return {\n y: [\n prevNodeCoords.bottom +\n Math.abs(prevNodeCoords.bottom - nodeCoords.top) / 2,\n center,\n ],\n x: [nodeCoords.left, nodeCoords.right],\n vertical: true,\n };\n}\n\nfunction ascendingHorizontal(\n nodeCoords: Coordinates,\n nextNodeCoords?: Coordinates,\n lastInRow = false\n) {\n const center = nodeCoords.left + nodeCoords.width / 2;\n\n if (!nextNodeCoords) {\n return {\n x: [center, center + nodeCoords.width],\n y: [nodeCoords.top, nodeCoords.bottom],\n vertical: false,\n };\n }\n\n if (lastInRow) {\n return {\n x: [center, nodeCoords.right + 10],\n y: [nodeCoords.top, nodeCoords.bottom],\n vertical: false,\n };\n } else {\n const nextNodeCenter = nextNodeCoords.left + nextNodeCoords.width / 2;\n\n return {\n x: [center, center + Math.abs(center - nextNodeCenter) / 2],\n y: [nodeCoords.top, nodeCoords.bottom],\n vertical: false,\n };\n }\n}\n\nfunction descendingHorizontal(\n nodeCoords: Coordinates,\n prevNodeCoords?: Coordinates\n) {\n const center = nodeCoords.left + nodeCoords.width / 2;\n\n if (!prevNodeCoords) {\n return {\n x: [nodeCoords.left - 10, center],\n y: [nodeCoords.top, nodeCoords.bottom],\n vertical: false,\n };\n }\n\n return {\n x: [\n prevNodeCoords.right +\n Math.abs(prevNodeCoords.right - nodeCoords.left) / 2,\n center,\n ],\n y: [nodeCoords.top, nodeCoords.bottom],\n vertical: false,\n };\n}\n\nfunction defineRanges(parent: HTMLElement) {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n const enabledNodes = parentData.enabledNodes;\n\n enabledNodes.forEach((node, index) => {\n let aboveOrBelowPrevious = false;\n\n let aboveOrBelowAfter = false;\n\n let prevNodeCoords = undefined;\n\n let nextNodeCoords = undefined;\n\n if (enabledNodes[index - 1])\n prevNodeCoords = getRealCoords(enabledNodes[index - 1].el);\n\n if (enabledNodes[index + 1])\n nextNodeCoords = getRealCoords(enabledNodes[index + 1].el);\n\n const nodeCoords = getRealCoords(node.el);\n\n if (prevNodeCoords) {\n aboveOrBelowPrevious =\n nodeCoords.top > prevNodeCoords.bottom ||\n nodeCoords.bottom < prevNodeCoords.top;\n }\n\n if (nextNodeCoords) {\n aboveOrBelowAfter =\n nodeCoords.top > nextNodeCoords.bottom ||\n nodeCoords.bottom < nextNodeCoords.top;\n }\n\n const fullishWidth =\n parent.getBoundingClientRect().width * 0.8 < nodeCoords.width;\n\n if (!node.data.range) return;\n\n if (fullishWidth) {\n node.data.range.ascending = ascendingVertical(nodeCoords, nextNodeCoords);\n node.data.range.descending = descendingVertical(\n nodeCoords,\n prevNodeCoords\n );\n } else if (aboveOrBelowAfter && !aboveOrBelowPrevious) {\n node.data.range.ascending = ascendingHorizontal(\n nodeCoords,\n nextNodeCoords,\n true\n );\n node.data.range.descending = descendingHorizontal(\n nodeCoords,\n prevNodeCoords\n );\n } else if (!aboveOrBelowPrevious && !aboveOrBelowAfter) {\n node.data.range.ascending = ascendingHorizontal(\n nodeCoords,\n nextNodeCoords\n );\n node.data.range.descending = descendingHorizontal(\n nodeCoords,\n prevNodeCoords\n );\n } else if (aboveOrBelowPrevious && !nextNodeCoords) {\n node.data.range.ascending = ascendingHorizontal(nodeCoords);\n } else if (aboveOrBelowPrevious && !aboveOrBelowAfter) {\n node.data.range.ascending = ascendingHorizontal(\n nodeCoords,\n nextNodeCoords\n );\n\n node.data.range.descending = descendingHorizontal(nodeCoords);\n }\n });\n}\n\nexport function handleDragoverNode(data: NodeDragEventData) {\n data.e.preventDefault();\n}\n\nexport function handleDragoverParent(\n data: ParentEventData,\n state: DragState\n) {\n if (!insertionState) return;\n\n data.e.stopPropagation();\n\n data.e.preventDefault();\n\n const { x, y } = eventCoordinates(data.e as DragEvent | PointerEvent);\n\n // Get the client coordinates\n const clientX = x;\n const clientY = y;\n\n // Get the scroll positions\n const scrollLeft = window.scrollX || document.documentElement.scrollLeft;\n const scrollTop = window.scrollY || document.documentElement.scrollTop;\n\n // Calculate the coordinates relative to the entire document\n state.coordinates.x = clientX + scrollLeft;\n state.coordinates.y = clientY + scrollTop;\n\n const nestedParent = data.targetData.parent.data.nestedParent;\n\n let realTargetParent = data.targetData.parent;\n\n if (nestedParent) {\n const rect = nestedParent.el.getBoundingClientRect();\n\n if (state.coordinates.y > rect.top && state.coordinates.y < rect.bottom)\n realTargetParent = nestedParent;\n }\n\n realTargetParent.el === state.currentParent?.el\n ? moveBetween(realTargetParent)\n : moveOutside(realTargetParent, state);\n\n state.currentParent = realTargetParent;\n}\n\nexport function moveBetween(data: ParentRecord) {\n if (data.data.config.sortable === false) return;\n\n if (\n data.el === insertionState.draggedOverParent?.el &&\n insertionState.draggedOverParent.data.getValues(data.el).length === 0\n ) {\n return;\n } else if (insertionState.draggedOverParent?.el) {\n removeClass(\n [insertionState.draggedOverParent.el],\n insertionState.draggedOverParent.data.config.dropZoneClass\n );\n insertionState.draggedOverParent = null;\n }\n\n const foundRange = findClosest(data.data.enabledNodes);\n\n if (!foundRange) return;\n\n const position =\n foundRange[0].data.range![foundRange[1] as \"ascending\" | \"descending\"];\n\n if (!position) return;\n\n positionInsertionPoint(\n position,\n foundRange[1] === \"ascending\",\n foundRange[0]\n );\n}\n\nfunction moveOutside(data: ParentRecord, state: DragState) {\n if (data.el === state.currentParent.el) return false;\n\n const targetConfig = data.data.config;\n\n if (targetConfig.treeGroup && state.draggedNode.el.contains(data.el))\n return false;\n\n if (targetConfig.dropZone === false) return false;\n\n const initialParentConfig = state.initialParent.data.config;\n\n if (targetConfig.accepts) {\n return targetConfig.accepts(\n data,\n state.initialParent,\n state.currentParent,\n state\n );\n } else if (\n !targetConfig.group ||\n targetConfig.group !== initialParentConfig.group\n ) {\n return false;\n }\n\n const values = data.data.getValues(data.el);\n\n if (!values.length) {\n addParentClass([data.el], targetConfig.dropZoneClass);\n\n insertionState.draggedOverParent = data;\n\n const insertionPoint = document.getElementById(\"insertion-point\");\n\n if (insertionPoint) insertionPoint.style.display = \"none\";\n } else {\n removeClass([state.currentParent.el], targetConfig.dropZoneClass);\n\n const enabledNodes = data.data.enabledNodes;\n\n const foundRange = findClosest(enabledNodes);\n\n if (!foundRange) return;\n\n const position =\n foundRange[0].data.range![foundRange[1] as \"ascending\" | \"descending\"];\n\n if (!position) return;\n\n positionInsertionPoint(\n position,\n foundRange[1] === \"ascending\",\n foundRange[0]\n );\n }\n}\n\nfunction findClosest(enabledNodes: NodeRecord[]) {\n let foundRange: [NodeRecord, string] | null = null;\n\n for (let x = 0; x < enabledNodes.length; x++) {\n if (!isDragState(state) || !enabledNodes[x].data.range) continue;\n\n const ascending = enabledNodes[x].data.range!.ascending;\n\n const descending = enabledNodes[x].data.range!.descending;\n\n if (!ascending && !descending) continue;\n\n if (ascending) {\n if (\n state.coordinates.y > ascending.y[0] &&\n state.coordinates.y < ascending.y[1] &&\n state.coordinates.x > ascending.x[0] &&\n state.coordinates.x < ascending.x[1]\n ) {\n foundRange = [enabledNodes[x], \"ascending\"];\n\n return foundRange;\n }\n }\n\n if (descending) {\n if (\n state.coordinates.y > descending.y[0] &&\n state.coordinates.y < descending.y[1] &&\n state.coordinates.x > descending.x[0] &&\n state.coordinates.x < descending.x[1]\n ) {\n foundRange = [enabledNodes[x], \"descending\"];\n\n return foundRange;\n }\n }\n }\n}\n\nexport function handlePointeroverParent(\n data: PointeroverParentEvent,\n state: DragState\n) {\n if (!insertionState) return;\n\n data.detail.e.stopPropagation();\n\n const { x, y } = eventCoordinates(data.detail.e as PointerEvent);\n\n state.coordinates.y = y;\n\n state.coordinates.x = x;\n\n const nestedParent = data.detail.targetData.parent.data.nestedParent;\n\n let realTargetParent = data.detail.targetData.parent;\n\n if (nestedParent) {\n const rect = nestedParent.el.getBoundingClientRect();\n\n if (state.coordinates.y > rect.top && state.coordinates.y < rect.bottom)\n realTargetParent = nestedParent;\n }\n\n const enabledNodes = realTargetParent.data.enabledNodes;\n\n const foundRange = findClosest(enabledNodes);\n\n if (!foundRange) return;\n\n const position =\n foundRange[0].data.range![foundRange[1] as \"ascending\" | \"descending\"];\n\n positionInsertionPoint(\n position,\n foundRange[1] === \"ascending\",\n foundRange[0]\n );\n\n data.detail.targetData.parent.el === state.currentParent?.el\n ? moveBetween(realTargetParent)\n : moveOutside(realTargetParent, state);\n}\n\nfunction positionInsertionPoint(\n position: { x: number[]; y: number[]; vertical: boolean },\n ascending: boolean,\n node: NodeRecord\n) {\n if (!state) return;\n\n const div = document.getElementById(\"insertion-point\");\n\n if (!div) return;\n\n insertionState.draggedOverNodes = [node];\n\n if (position.vertical) {\n const topPosition =\n position.y[ascending ? 1 : 0] - div.getBoundingClientRect().height / 2;\n\n div.style.top = `${topPosition}px`;\n\n const leftCoordinate = position.x[0];\n\n const rightCoordinate = position.x[1];\n\n div.style.left = `${leftCoordinate}px`;\n\n div.style.right = `${rightCoordinate}px`;\n\n div.style.height = \"4px\";\n\n div.style.width = rightCoordinate - leftCoordinate + \"px\";\n } else {\n const leftPosition =\n position.x[ascending ? 1 : 0] - div.getBoundingClientRect().width / 2;\n div.style.left = `${leftPosition}px`;\n\n const topCoordinate = position.y[0];\n\n const bottomCoordinate = position.y[1];\n\n div.style.top = `${topCoordinate}px`;\n\n div.style.bottom = `${bottomCoordinate}px`;\n\n div.style.width = \"4px\";\n\n div.style.height = bottomCoordinate - topCoordinate + \"px\";\n }\n\n insertionState.targetIndex = node.data.index;\n\n insertionState.ascending = ascending;\n\n div.style.display = \"block\";\n}\n\nexport function handleParentDrop(_data: NodeDragEventData) {}\n\nexport function handleEnd(\n data: NodeDragEventData | NodePointerEventData,\n state: DragState\n) {\n data.e.stopPropagation();\n\n const insertionPoint = document.getElementById(\"insertion-point\");\n\n if (!insertionState.draggedOverParent) {\n const draggedParentValues = parentValues(\n state.initialParent.el,\n state.initialParent.data\n );\n\n const transferred = state.initialParent.el !== state.currentParent.el;\n\n const draggedValues = state.draggedNodes.map((node) => node.data.value);\n\n const enabledNodes = [...data.targetData.parent.data.enabledNodes];\n\n const originalIndex = state.draggedNodes[0].data.index;\n\n if (\n !transferred &&\n insertionState.draggedOverNodes[0] &&\n insertionState.draggedOverNodes[0].el !== state.draggedNodes[0].el\n ) {\n const newParentValues = [\n ...draggedParentValues.filter((x) => !draggedValues.includes(x)),\n ];\n\n let index = insertionState.draggedOverNodes[0].data.index;\n\n if (\n insertionState.targetIndex > state.draggedNodes[0].data.index &&\n !insertionState.ascending\n ) {\n index--;\n } else if (\n insertionState.targetIndex < state.draggedNodes[0].data.index &&\n insertionState.ascending\n ) {\n index++;\n }\n\n newParentValues.splice(index, 0, ...draggedValues);\n\n setParentValues(data.targetData.parent.el, data.targetData.parent.data, [\n ...newParentValues,\n ]);\n\n if (data.targetData.parent.data.config.onSort) {\n const sortEventData = {\n parent: {\n el: data.targetData.parent.el,\n data: data.targetData.parent.data,\n },\n previousValues: [...draggedParentValues],\n previousNodes: [...enabledNodes],\n nodes: [...data.targetData.parent.data.enabledNodes],\n values: [...newParentValues],\n draggedNode: state.draggedNode,\n previousPosition: originalIndex,\n position: index,\n };\n\n data.targetData.parent.data.config.onSort(sortEventData);\n }\n } else if (transferred && insertionState.draggedOverNodes.length) {\n const targetParentValues = parentValues(\n state.currentParent.el,\n state.currentParent.data\n );\n const draggedParentValues = parentValues(\n state.initialParent.el,\n state.initialParent.data\n );\n\n // For the time being, we will not be remoing the value of the original dragged parent.\n let index = insertionState.draggedOverNodes[0].data.index || 0;\n\n if (insertionState.ascending) index++;\n\n const insertValues = state.dynamicValues.length\n ? state.dynamicValues\n : draggedValues;\n targetParentValues.splice(index, 0, ...insertValues);\n setParentValues(state.currentParent.el, state.currentParent.data, [\n ...targetParentValues,\n ]);\n draggedParentValues.splice(state.initialIndex, draggedValues.length);\n setParentValues(state.initialParent.el, state.initialParent.data, [\n ...draggedParentValues,\n ]);\n\n const transferEventData = {\n sourceParent: state.currentParent,\n targetParent: data.targetData.parent,\n initialParent: state.initialParent,\n draggedNodes: state.draggedNodes,\n targetIndex: index,\n state,\n };\n if (data.targetData.parent.data.config.onTransfer)\n data.targetData.parent.data.config.onTransfer(transferEventData);\n if (state.currentParent.data.config.onTransfer)\n state.currentParent.data.config.onTransfer(transferEventData);\n }\n } else if (insertionState.draggedOverParent) {\n const draggedOverParentValues = parentValues(\n insertionState.draggedOverParent.el,\n insertionState.draggedOverParent.data\n );\n\n const draggedValues = state.draggedNodes.map((node) => node.data.value);\n\n const insertValues = state.dynamicValues.length\n ? state.dynamicValues\n : draggedValues;\n\n draggedOverParentValues.push(...insertValues);\n\n setParentValues(\n insertionState.draggedOverParent.el,\n insertionState.draggedOverParent.data,\n [...draggedOverParentValues]\n );\n\n const transferEventData = {\n sourceParent: state.currentParent,\n targetParent: insertionState.draggedOverParent,\n initialParent: state.initialParent,\n draggedNodes: state.draggedNodes,\n targetIndex: draggedOverParentValues.length - 1,\n state,\n };\n if (data.targetData.parent.data.config.onTransfer)\n data.targetData.parent.data.config.onTransfer(transferEventData);\n if (state.currentParent.data.config.onTransfer)\n state.currentParent.data.config.onTransfer(transferEventData);\n\n removeClass(\n [insertionState.draggedOverParent.el],\n insertionState.draggedOverParent.data.config.dropZoneClass\n );\n }\n\n if (insertionPoint) insertionPoint.style.display = \"none\";\n\n const dropZoneClass =\n \"clonedDraggedNode\" in state\n ? data.targetData.parent.data.config.synthDropZoneClass\n : data.targetData.parent.data.config.dropZoneClass;\n\n removeClass(\n insertionState.draggedOverNodes.map((node) => node.el),\n dropZoneClass\n );\n\n const dragPlaceholderClass =\n data.targetData.parent.data.config.dragPlaceholderClass;\n\n removeClass(\n state.draggedNodes.map((node) => node.el),\n dragPlaceholderClass\n );\n\n insertionState.draggedOverNodes = [];\n\n originalHandleEnd(data, state);\n}\n","import type {\n NodeDragEventData,\n ParentConfig,\n DragState,\n SynthDragState,\n NodeRecord,\n PointeroverNodeEvent,\n ParentDragEventData,\n PointeroverParentEvent,\n} from \"../../types\";\nimport {\n parents,\n parentValues,\n setParentValues,\n addNodeClass,\n isSynthDragState,\n removeClass,\n addClass,\n state,\n isDragState,\n} from \"../../index\";\n\nexport const placeState = {\n draggedOverNodes: Array>(),\n};\n\nlet dragoverEventListeneerSet = false;\n\ninterface PlaceConfig extends ParentConfig {}\n\nexport function place(placeConfig: Partial> = {}) {\n return (parent: HTMLElement) => {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n const placeParentConfig = {\n ...parentData.config,\n placeConfig: placeConfig,\n } as PlaceConfig;\n\n if (!dragoverEventListeneerSet) {\n document.addEventListener(\"dragover\", rootDragover);\n document.addEventListener(\n \"handleRootPointerover\" as keyof DocumentEventMap,\n (e) => rootPointerover(e as CustomEvent)\n );\n }\n\n return {\n setup() {\n placeParentConfig.handleNodeDragover =\n placeConfig.handleNodeDragover || handleDragoverNode;\n\n placeParentConfig.handleParentDragover =\n placeConfig.handleParentDragover || handleDragoverParent;\n\n placeParentConfig.handleNodePointerover =\n placeConfig.handleNodePointerover || handleNodePointerover;\n\n placeParentConfig.handleParentPointerover =\n placeConfig.handleParentPointerover || handlePointeroverParent;\n\n const originalHandleend = placeParentConfig.handleEnd;\n placeParentConfig.handleEnd = (state) => {\n handleEnd(state);\n\n originalHandleend(state);\n };\n\n parentData.config = placeParentConfig;\n },\n };\n };\n}\n\nfunction rootDragover(_e: DragEvent) {\n if (!isDragState(state)) return;\n\n removeClass(\n [state.currentParent.el],\n state.currentParent.data.config.dropZoneParentClass\n );\n}\n\nfunction rootPointerover(_e: CustomEvent) {\n if (!isSynthDragState(state)) return;\n\n removeClass(\n [state.currentParent.el],\n state.currentParent.data.config.synthDropZoneParentClass\n );\n}\n\nfunction updateDraggedOverNodes(\n data: PointeroverNodeEvent | NodeDragEventData,\n state: DragState | SynthDragState\n) {\n const targetData =\n \"detail\" in data ? data.detail.targetData : data.targetData;\n\n const config = targetData.parent.data.config;\n\n const dropZoneClass = isSynthDragState(state)\n ? config.synthDropZoneClass\n : config.dropZoneClass;\n\n removeClass(\n placeState.draggedOverNodes.map((node) => node.el),\n dropZoneClass\n );\n\n const enabledNodes = targetData.parent.data.enabledNodes;\n\n if (!enabledNodes) return;\n\n placeState.draggedOverNodes = enabledNodes.slice(\n targetData.node.data.index,\n targetData.node.data.index + state.draggedNodes.length\n );\n\n addNodeClass(\n placeState.draggedOverNodes.map((node) => node.el),\n dropZoneClass,\n true\n );\n\n state.currentTargetValue = targetData.node.data.value;\n\n state.currentParent = targetData.parent;\n\n addClass(\n state.currentParent.el,\n isSynthDragState(state)\n ? config.synthDropZoneParentClass\n : config.dropZoneParentClass,\n state.currentParent.data,\n true\n );\n}\n\nfunction handleDragoverNode(\n data: NodeDragEventData,\n state: DragState\n) {\n data.e.preventDefault();\n\n data.e.stopPropagation();\n\n updateDraggedOverNodes(data, state);\n}\n\nexport function handleDragoverParent(\n data: ParentDragEventData,\n state: DragState\n) {\n data.e.preventDefault();\n\n data.e.stopPropagation();\n\n const currentConfig = state.currentParent.data.config;\n\n removeClass(\n placeState.draggedOverNodes.map((node) => node.el),\n currentConfig.dropZoneClass\n );\n\n removeClass([state.currentParent.el], currentConfig.dropZoneParentClass);\n\n const config = data.targetData.parent.data.config;\n\n addClass(\n data.targetData.parent.el,\n config.dropZoneParentClass,\n data.targetData.parent.data,\n true\n );\n\n placeState.draggedOverNodes = [];\n\n state.currentParent = data.targetData.parent;\n}\n\nexport function handlePointeroverParent(data: PointeroverParentEvent) {\n const currentConfig = data.detail.state.currentParent.data.config;\n\n removeClass(\n placeState.draggedOverNodes.map((node) => node.el),\n currentConfig.synthDropZoneClass\n );\n\n removeClass(\n [data.detail.state.currentParent.el],\n currentConfig.synthDropZoneParentClass\n );\n\n const config = data.detail.targetData.parent.data.config;\n\n addClass(\n data.detail.targetData.parent.el,\n config.synthDropZoneParentClass,\n data.detail.targetData.parent.data,\n true\n );\n\n placeState.draggedOverNodes = [];\n}\n\nfunction handleNodePointerover(data: PointeroverNodeEvent) {\n if (!isSynthDragState(data.detail.state)) return;\n\n updateDraggedOverNodes(data, data.detail.state);\n}\n\nfunction handleEnd(state: DragState | SynthDragState) {\n const isSynth = isSynthDragState(state);\n\n removeClass(\n [state.currentParent.el],\n isSynth\n ? state.currentParent.data.config.synthDropZoneParentClass\n : state.currentParent.data.config.dropZoneParentClass\n );\n\n const values = parentValues(state.currentParent.el, state.currentParent.data);\n\n const draggedValues = state.draggedNodes.map((node) => node.data.value);\n\n const newValues = values.filter((x) => !draggedValues.includes(x));\n\n const index = placeState.draggedOverNodes[0]?.data.index;\n\n // If we do not have dragged over nodes, then we know that we are appending\n // items to the end of the list/\n index !== undefined\n ? newValues.splice(index, 0, ...draggedValues)\n : newValues.push(...draggedValues);\n\n if (state.initialParent.el !== state.currentParent.el) {\n const initialParentValues = parentValues(\n state.initialParent.el,\n state.initialParent.data\n );\n\n const newInitialValues = initialParentValues.filter(\n (x) => !draggedValues.includes(x)\n );\n\n setParentValues(\n state.initialParent.el,\n state.initialParent.data,\n newInitialValues\n );\n } else if (\n state.initialParent.el === state.currentParent.el &&\n placeState.draggedOverNodes.length\n ) {\n setParentValues(\n state.currentParent.el,\n state.currentParent.data,\n newValues\n );\n }\n\n removeClass(\n placeState.draggedOverNodes.map((node) => node.el),\n isSynth\n ? state.currentParent.data.config.synthDropZoneClass\n : state.currentParent.data.config.dropZoneClass\n );\n}\n","import type {\n NodeDragEventData,\n ParentConfig,\n NodeRecord,\n ParentEventData,\n PointeroverParentEvent,\n PointeroverNodeEvent,\n} from \"../../types\";\nimport {\n state,\n parents,\n addNodeClass,\n removeClass,\n isDragState,\n} from \"../../index\";\n\nexport const swapState = {\n draggedOverNodes: Array>(),\n};\n\ninterface SwapConfig extends ParentConfig {}\n\nexport function swap(swapConfig: Partial> = {}) {\n return (parent: HTMLElement) => {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n const swapParentConfig = {\n ...parentData.config,\n swapConfig: swapConfig,\n } as SwapConfig;\n\n return {\n setup() {\n swapParentConfig.handleDragoverParent =\n swapConfig.handleDragoverParent || handleDragoverParent;\n\n swapParentConfig.handleDragoverNode =\n swapConfig.handleDragoverNode || handleDragoverNode;\n\n swapParentConfig.handlePointeroverNode =\n swapConfig.handlePointeroverNode || handlePointeroverNode;\n\n swapParentConfig.handlePointeroverParent =\n swapConfig.handlePointeroverParent || handlePointeroverParent;\n\n parentData.config = swapParentConfig;\n },\n };\n };\n}\n\nfunction handleDragoverNode(data: NodeDragEventData) {\n data.e.preventDefault();\n}\n\nexport function handleDragoverParent(_data: ParentEventData) {}\n\nexport function handlePointeroverParent(_data: PointeroverParentEvent) {}\n\nfunction handlePointeroverNode(data: PointeroverNodeEvent) {\n if (!isDragState(state)) return;\n\n if (data.detail.targetData.parent.el !== state.currentParent.el) return;\n\n const dropZoneClass =\n data.detail.targetData.parent.data.config.synthDropZoneClass;\n\n removeClass(\n swapState.draggedOverNodes.map((node) => node.el),\n dropZoneClass\n );\n\n const enabledNodes = data.detail.targetData.parent.data.enabledNodes;\n\n swapState.draggedOverNodes = enabledNodes.slice(\n data.detail.targetData.node.data.index,\n data.detail.targetData.node.data.index + state.draggedNodes.length\n );\n\n addNodeClass(\n swapState.draggedOverNodes.map((node) => node.el),\n dropZoneClass,\n true\n );\n\n state.currentTargetValue = data.detail.targetData.node.data.value;\n\n state.currentParent = data.detail.targetData.parent as any;\n}\n//function handleEnd(data: NodeDragEventData | NodePointerEventData) {\n// if (!state) return;\n\n// if (!state.transferred) {\n// const draggedParentValues = parentValues(\n// state.initialParent.el,\n// state.initialParent.data\n// );\n\n// let targetParentValues = parentValues(\n// state.lastParent.el,\n// state.lastParent.data\n// );\n\n// const draggedValues = state.draggedNodes.map((node) => node.data.value);\n\n// const draggedOverNodeValues = swapState.draggedOverNodes.map(\n// (node) => node.data.value\n// );\n\n// const draggedIndex = state.draggedNodes[0].data.index;\n\n// const draggedOverIndex = swapState.draggedOverNodes[0].data.index;\n\n// targetParentValues.splice(\n// draggedOverIndex,\n// draggedValues.length,\n// ...draggedValues\n// );\n\n// if (state.initialParent.el === state.lastParent.el) {\n// targetParentValues.splice(\n// draggedIndex,\n// draggedValues.length,\n// ...draggedOverNodeValues\n// );\n\n// setParentValues(state.initialParent.el, state.initialParent.data, [\n// ...targetParentValues,\n// ]);\n// } else {\n// draggedParentValues.splice(\n// draggedIndex,\n// draggedValues.length,\n// ...draggedOverNodeValues\n// );\n\n// setParentValues(state.lastParent.el, state.lastParent.data, [\n// ...targetParentValues,\n// ]);\n\n// setParentValues(state.initialParent.el, state.initialParent.data, [\n// ...draggedParentValues,\n// ]);\n// }\n// }\n\n// const dropZoneClass =\n// \"clonedDraggedNode\" in state\n// ? data.targetData.parent.data.config.touchDropZoneClass\n// : data.targetData.parent.data.config.dropZoneClass;\n\n// removeClass(\n// swapState.draggedOverNodes.map((node) => node.el),\n// dropZoneClass\n// );\n\n// originalHandleEnd(data);\n//}\n","import type {\n DNDPlugin,\n DragAndDrop,\n DragState,\n DragStateProps,\n Node,\n NodeData,\n NodeDragEventData,\n NodeEventData,\n NodePointerEventData,\n NodeRecord,\n NodeTargetData,\n NodesData,\n ParentConfig,\n ParentData,\n ParentEventData,\n ParentTargetData,\n ParentsData,\n PointeroverNodeEvent,\n PointeroverParentEvent,\n ScrollData,\n SetupNodeData,\n TearDownNodeData,\n BaseDragState,\n SynthDragState,\n ParentKeydownEventData,\n SynthDragStateProps,\n ParentRecord,\n EventHandlers,\n NodeFromPoint,\n ParentFromPoint,\n Coordinates,\n} from \"./types\";\n\nexport * from \"./types\";\nexport { animations } from \"./plugins/animations\";\nexport { insertion } from \"./plugins/insertion\";\nexport { place } from \"./plugins/place\";\nexport { swap } from \"./plugins/swap\";\n\n/**\n * Check to see if code is running in a browser.\n *\n * @internal\n */\nexport const isBrowser = typeof window !== \"undefined\";\n\nexport const touchDevice = window && \"ontouchstart\" in window;\n\nlet dropped = false;\n\n/**\n * Abort controller for the document.\n */\nlet documentController: AbortController | undefined;\n\nlet isNative = false;\n\nlet animationFrameId: number | null = null;\n\nconst scrollConfig: {\n [key: string]: [number, number];\n} = {\n up: [0, -1],\n down: [0, 1],\n left: [-1, 0],\n right: [1, 0],\n};\n\nexport const nodes: NodesData = new WeakMap>();\n\nexport const parents: ParentsData = new WeakMap<\n HTMLElement,\n ParentData\n>();\n\nexport const treeAncestors: Record = {};\n\nlet synthNodePointerDown = false;\n\nexport function createEmitter() {\n const callbacks = new Map();\n\n const emit = function (eventName: string, data: any) {\n if (!callbacks.get(eventName)) return;\n callbacks.get(eventName)!.forEach((cb) => {\n cb(data);\n });\n };\n\n const on = function (eventName: string, callback: any) {\n const cbs = callbacks.get(eventName) ?? [];\n\n cbs.push(callback);\n\n callbacks.set(eventName, cbs);\n };\n\n return [emit, on];\n}\n\nexport const [emit, on] = createEmitter();\n\nconst baseDragState = {\n activeDescendant: undefined,\n affectedNodes: [],\n currentTargetValue: undefined,\n on,\n emit,\n newActiveDescendant: undefined,\n originalZIndex: undefined,\n pointerSelection: false,\n preventEnter: false,\n remapJustFinished: false,\n selectednodes: [],\n selectedParent: undefined,\n};\n\n/**\n * The state of the drag and drop.\n */\nexport let state: BaseDragState = baseDragState;\n\nexport function resetState() {\n const baseDragState = {\n activeDescendant: undefined,\n affectedNodes: [],\n on,\n emit,\n currentTargetValue: undefined,\n originalZIndex: undefined,\n pointerId: undefined,\n preventEnter: false,\n remapJustFinished: false,\n selectednodes: [],\n selectedParent: undefined,\n pointerSelection: false,\n synthScrollDirection: undefined,\n draggedNodeDisplay: undefined,\n synthDragScrolling: false,\n };\n\n state = { ...baseDragState } as BaseDragState;\n}\n\n/**\n * @param {DragStateProps} dragStateProps - Attributes to update state with.\n *\n * @mutation - Updates state with node values.\n *\n * @returns void\n */\nexport function setDragState(\n dragStateProps:\n | (SynthDragStateProps & DragStateProps)\n | DragStateProps\n | undefined\n): DragState | SynthDragState {\n Object.assign(state, dragStateProps);\n\n dropped = false;\n\n state.emit(\"dragStarted\", state);\n\n return state as DragState | SynthDragState;\n}\n\n/**\n *\n */\nfunction handlePointerdownRoot(_e: PointerEvent) {\n if (state.activeState) setActive(state.activeState.parent, undefined, state);\n\n if (state.selectedState)\n deselect(state.selectedState.nodes, state.selectedState.parent, state);\n\n state.selectedState = state.activeState = undefined;\n}\n\nfunction handlePointerupRoot(_e: PointerEvent) {\n if (!isSynthDragState(state)) return;\n\n const config = state.currentParent.data.config;\n\n if (isSynthDragState(state)) config.handleEnd(state);\n}\n\n/**\n * Handles the keydown event on the root element.\n *\n * @param {KeyboardEvent} e - The keyboard event.\n */\nfunction handleRootKeydown(e: KeyboardEvent) {\n if (e.key === \"Escape\") {\n if (state.selectedState)\n deselect(state.selectedState.nodes, state.selectedState.parent, state);\n\n if (state.activeState)\n setActive(state.activeState.parent, undefined, state);\n\n state.selectedState = state.activeState = undefined;\n }\n}\n\nfunction handleRootDrop(_e: DragEvent) {\n //e.preventDefault();\n}\n\n/**\n * If we are currently dragging, then let's prevent default on dragover to avoid\n * the default behavior of the browser on drop.\n */\nfunction handleRootDragover(e: DragEvent) {\n if (!isDragState(state)) return;\n\n e.preventDefault();\n}\n\n/**\n * Initializes the drag and drop functionality for a given parent.\n *\n * @param {DragAndDrop} dragAndDrop - The drag and drop configuration.\n *\n * @returns void\n */\nexport function dragAndDrop({\n parent,\n getValues,\n setValues,\n config = {},\n}: DragAndDrop): void {\n if (!isBrowser) return;\n\n if (!documentController)\n documentController = addEvents(document, {\n dragover: handleRootDragover,\n pointerdown: handlePointerdownRoot,\n pointerup: handlePointerupRoot,\n keydown: handleRootKeydown,\n drop: handleRootDrop,\n });\n\n tearDown(parent);\n\n const parentData: ParentData = {\n getValues,\n setValues,\n config: {\n dragDropEffect: config.dragDropEffect ?? \"move\",\n dragEffectAllowed: config.dragEffectAllowed ?? \"move\",\n draggedNodes,\n dragstartClasses,\n deepCopyStyles: config.deepCopyStyles ?? false,\n handleNodeKeydown,\n handleParentKeydown,\n handleDragstart,\n handleNodeDragover,\n handleParentDragover,\n handleNodeDrop,\n handleDragend,\n handleEnd,\n handleParentBlur,\n handleParentFocus,\n handleNodePointerup,\n handleNodeTouchstart,\n handleNodePointerover,\n handleParentPointerover,\n handleNodePointerdown,\n handleNodePointermove,\n handleNodeDragenter,\n handleNodeDragleave,\n handleParentDrop,\n multiDrag: config.multiDrag ?? false,\n nativeDrag: config.nativeDrag ?? true,\n performSort,\n performTransfer,\n root: config.root ?? document,\n setupNode,\n setupNodeRemap,\n reapplyDragClasses,\n tearDownNode,\n tearDownNodeRemap,\n remapFinished,\n scrollBehavior: {\n x: 0.95,\n y: 0.95,\n },\n threshold: {\n horizontal: 0,\n vertical: 0,\n },\n ...config,\n },\n enabledNodes: [],\n abortControllers: {},\n privateClasses: [],\n };\n\n const nodesObserver = new MutationObserver(nodesMutated);\n\n nodesObserver.observe(parent, { childList: true });\n\n parents.set(parent, parentData);\n\n if (config.treeAncestor && config.treeGroup)\n treeAncestors[config.treeGroup] = parent;\n\n config.plugins?.forEach((plugin) => {\n plugin(parent)?.tearDown?.();\n });\n\n config.plugins?.forEach((plugin) => {\n plugin(parent)?.tearDown?.();\n });\n\n config.plugins?.forEach((plugin: DNDPlugin) => {\n plugin(parent)?.setup?.();\n });\n\n setup(parent, parentData);\n\n remapNodes(parent, true);\n}\n\nexport function dragStateProps(\n data: NodeDragEventData | NodePointerEventData,\n draggedNodes: Array>,\n nativeDrag = true\n): DragStateProps {\n const { x, y } = eventCoordinates(data.e);\n\n const rect = data.targetData.node.el.getBoundingClientRect();\n\n const scrollEls: Array<[HTMLElement, AbortController]> = [];\n\n for (const scrollable of getScrollables()) {\n scrollEls.push([\n scrollable,\n nativeDrag\n ? addEvents(scrollable, {\n scroll: preventSortOnScroll(),\n })\n : addEvents(scrollable, {\n pointermove: handleScroll,\n }),\n ]);\n }\n\n return {\n affectedNodes: [],\n ascendingDirection: false,\n clonedDraggedEls: [],\n dynamicValues: [],\n coordinates: {\n x,\n y,\n },\n draggedNode: {\n el: data.targetData.node.el,\n data: data.targetData.node.data,\n },\n draggedNodes,\n incomingDirection: undefined,\n initialIndex: data.targetData.node.data.index,\n initialParent: {\n el: data.targetData.parent.el,\n data: data.targetData.parent.data,\n },\n currentParent: {\n el: data.targetData.parent.el,\n data: data.targetData.parent.data,\n },\n longPress: data.targetData.parent.data.config.longPress ?? false,\n longPressTimeout: 0,\n currentTargetValue: data.targetData.node.data.value,\n scrollEls,\n startLeft: x - rect.left,\n startTop: y - rect.top,\n targetIndex: data.targetData.node.data.index,\n transferred: false,\n };\n}\n\nexport function performSort({\n parent,\n draggedNodes,\n targetNode,\n}: {\n parent: ParentRecord;\n draggedNodes: Array>;\n targetNode: NodeRecord;\n}) {\n const draggedValues = draggedNodes.map((x) => x.data.value);\n\n const targetParentValues = parentValues(parent.el, parent.data);\n\n const originalIndex = draggedNodes[0].data.index;\n\n const enabledNodes = [...parent.data.enabledNodes];\n\n const newParentValues = [\n ...targetParentValues.filter((x) => !draggedValues.includes(x)),\n ];\n\n newParentValues.splice(targetNode.data.index, 0, ...draggedValues);\n\n if (\"draggedNode\" in state) state.currentTargetValue = targetNode.data.value;\n\n setParentValues(parent.el, parent.data, [...newParentValues]);\n\n if (parent.data.config.onSort)\n parent.data.config.onSort({\n parent: {\n el: parent.el,\n data: parent.data,\n },\n previousValues: [...targetParentValues],\n previousNodes: [...enabledNodes],\n nodes: [...parent.data.enabledNodes],\n values: [...newParentValues],\n draggedNode: draggedNodes[0],\n previousPosition: originalIndex,\n position: targetNode.data.index,\n });\n}\n\n/**\n * This function sets the active node as well as removing any classes or\n * attribute set.\n *\n * @param {ParentEventData} data - The parent event data.\n * @param {NodeRecord} newActiveNode - The new active node.\n * @param {BaseDragState} state - The current drag state.\n */\nfunction setActive(\n parent: ParentRecord,\n newActiveNode: NodeRecord | undefined,\n state: BaseDragState\n) {\n const activeDescendantClass = parent.data.config.activeDescendantClass;\n\n if (state.activeState) {\n {\n removeClass([state.activeState.node.el], activeDescendantClass);\n\n if (state.activeState.parent.el !== parent.el)\n state.activeState.parent.el.setAttribute(\"aria-activedescendant\", \"\");\n }\n }\n\n if (!newActiveNode) {\n state.activeState?.parent.el.setAttribute(\"aria-activedescendant\", \"\");\n\n state.activeState = undefined;\n\n return;\n }\n\n state.activeState = {\n node: newActiveNode,\n parent,\n };\n\n addNodeClass([newActiveNode.el], activeDescendantClass);\n\n state.activeState.parent.el.setAttribute(\n \"aria-activedescendant\",\n state.activeState.node.el.id\n );\n}\n\nfunction deselect(\n nodes: Array>,\n parent: ParentRecord,\n state: BaseDragState\n) {\n const selectedClass = parent.data.config.selectedClass;\n\n if (!state.selectedState) return;\n\n const iterativeNodes = Array.from(nodes);\n\n removeClass(\n nodes.map((x) => x.el),\n selectedClass\n );\n\n for (const node of iterativeNodes) {\n node.el.setAttribute(\"aria-selected\", \"false\");\n\n const index = state.selectedState.nodes.findIndex((x) => x.el === node.el);\n\n if (index === -1) continue;\n\n state.selectedState.nodes.splice(index, 1);\n }\n\n clearLiveRegion(parent);\n}\n\n/**\n * This function sets the selected nodes. This will clean the prior selected state\n * as well as removing any classes or attributes set.\n */\nfunction setSelected(\n parent: ParentRecord,\n selectedNodes: Array>,\n newActiveNode: NodeRecord | undefined,\n state: BaseDragState,\n pointerdown = false\n) {\n state.pointerSelection = pointerdown;\n\n for (const node of selectedNodes) {\n node.el.setAttribute(\"aria-selected\", \"true\");\n\n addNodeClass([node.el], parent.data.config.selectedClass, true);\n }\n\n state.selectedState = {\n nodes: selectedNodes,\n parent,\n };\n\n const selectedItems = selectedNodes.map((x) =>\n x.el.getAttribute(\"aria-label\")\n );\n\n if (selectedItems.length === 0) {\n state.selectedState = undefined;\n\n clearLiveRegion(parent);\n\n return;\n }\n\n setActive(parent, newActiveNode, state);\n\n updateLiveRegion(\n parent,\n `${selectedItems.join(\n \", \"\n )} ready for dragging. Use arrow keys to navigate. Press enter to drop ${selectedItems.join(\n \", \"\n )}.`\n );\n}\n\nfunction updateLiveRegion(parent: ParentRecord, message: string) {\n const parentId = parent.el.id;\n\n const liveRegion = document.getElementById(parentId + \"-live-region\");\n\n if (!liveRegion) return;\n\n liveRegion.textContent = message;\n}\n\nfunction clearLiveRegion(parent: ParentRecord) {\n const liveRegion = document.getElementById(parent.el.id + \"-live-region\");\n\n if (!liveRegion) return;\n\n liveRegion.textContent = \"\";\n}\n\nexport function handleParentBlur(\n _data: ParentEventData,\n _state: BaseDragState | DragState | SynthDragState\n) {}\n\nexport function handleParentFocus(\n data: ParentEventData,\n state: BaseDragState | DragState | SynthDragState\n) {\n const firstEnabledNode = data.targetData.parent.data.enabledNodes[0];\n\n if (!firstEnabledNode) return;\n\n if (\n state.selectedState &&\n state.selectedState.parent.el !== data.targetData.parent.el\n ) {\n setActive(data.targetData.parent, firstEnabledNode, state);\n } else if (!state.selectedState) {\n setActive(data.targetData.parent, firstEnabledNode, state);\n }\n}\n\nexport function performTransfer({\n currentParent,\n targetParent,\n initialParent,\n draggedNodes,\n initialIndex,\n targetNode,\n state,\n}: {\n currentParent: ParentRecord;\n targetParent: ParentRecord;\n initialParent: ParentRecord;\n draggedNodes: Array>;\n initialIndex: number;\n state: BaseDragState | DragState | SynthDragState;\n targetNode?: NodeRecord;\n}) {\n const draggedValues = draggedNodes.map((x) => x.data.value);\n\n const currentParentValues = parentValues(\n currentParent.el,\n currentParent.data\n ).filter((x: any) => !draggedValues.includes(x));\n\n const targetParentValues = parentValues(targetParent.el, targetParent.data);\n\n const reset =\n initialParent.el === targetParent.el &&\n targetParent.data.config.sortable === false;\n\n let targetIndex: number;\n\n if (targetNode) {\n if (reset) {\n targetIndex = initialIndex;\n } else if (targetParent.data.config.sortable === false) {\n targetIndex = targetParent.data.enabledNodes.length;\n } else {\n targetIndex = targetNode.data.index;\n }\n\n targetParentValues.splice(targetIndex, 0, ...draggedValues);\n } else {\n targetIndex = reset ? initialIndex : targetParent.data.enabledNodes.length;\n\n targetParentValues.splice(targetIndex, 0, ...draggedValues);\n }\n\n setParentValues(currentParent.el, currentParent.data, currentParentValues);\n\n setParentValues(targetParent.el, targetParent.data, targetParentValues);\n\n if (targetParent.data.config.onTransfer) {\n targetParent.data.config.onTransfer({\n sourceParent: currentParent,\n targetParent,\n initialParent,\n draggedNodes,\n targetIndex,\n state,\n });\n }\n\n if (currentParent.data.config.onTransfer) {\n currentParent.data.config.onTransfer({\n sourceParent: currentParent,\n targetParent,\n initialParent,\n draggedNodes,\n targetIndex,\n state,\n });\n }\n}\n\nexport function parentValues(\n parent: HTMLElement,\n parentData: ParentData\n): Array {\n return [...parentData.getValues(parent)];\n}\n\nfunction findArrayCoordinates(\n obj: any,\n targetArray: Array,\n path: Array = []\n) {\n let result: Array = [];\n\n if (obj === targetArray) result.push(path);\n\n if (Array.isArray(obj)) {\n const index = obj.findIndex((el) => el === targetArray);\n\n if (index !== -1) {\n result.push([...path, index]);\n } else {\n for (let i = 0; i < obj.length; i++) {\n result = result.concat(\n findArrayCoordinates(obj[i], targetArray, [...path, i])\n );\n }\n }\n } else if (typeof obj === \"object\" && obj !== null) {\n for (const key in obj) {\n result = result.concat(\n findArrayCoordinates(obj[key], targetArray, [...path, key])\n );\n }\n }\n\n return result;\n}\n\nfunction setValueAtCoordinatesUsingFindIndex(\n obj: Array,\n targetArray: Array,\n newArray: Array\n) {\n const coordinates = findArrayCoordinates(obj, targetArray);\n\n let newValues;\n\n coordinates.forEach((coords) => {\n let current = obj;\n for (let i = 0; i < coords.length - 1; i++) {\n const index = coords[i];\n current = current[index];\n }\n const lastIndex = coords[coords.length - 1];\n\n current[lastIndex] = newArray;\n\n // We want to access getter of object we are setting to set the new values\n // of the nested parent element (should be a part of the original structure of\n // ancestor values).\n newValues = current[lastIndex];\n });\n\n return newValues;\n}\n\nexport function setParentValues(\n parent: HTMLElement,\n parentData: ParentData,\n values: Array\n): void {\n const treeGroup = parentData.config.treeGroup;\n\n if (treeGroup) {\n const ancestorEl = treeAncestors[treeGroup];\n\n const ancestorData = parents.get(ancestorEl);\n\n if (!ancestorData) return;\n\n const ancestorValues = ancestorData.getValues(ancestorEl);\n\n const initialParentValues = parentData.getValues(parent);\n\n const updatedValues = setValueAtCoordinatesUsingFindIndex(\n ancestorValues,\n initialParentValues,\n values\n );\n\n if (!updatedValues) {\n console.warn(\"No updated value found\");\n\n return;\n }\n\n parentData.setValues(updatedValues, parent);\n\n return;\n }\n\n parentData.setValues(values, parent);\n}\n\nexport function dragValues(state: DragState): Array {\n return [...state.draggedNodes.map((x) => x.data.value)];\n}\n\n/**\n * Utility function to update parent config.\n */\nexport function updateConfig(\n parent: HTMLElement,\n config: Partial>\n) {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n parents.set(parent, {\n ...parentData,\n config: { ...parentData.config, ...config },\n });\n\n dragAndDrop({\n parent,\n getValues: parentData.getValues,\n setValues: parentData.setValues,\n config,\n });\n}\n\nexport function handleParentDrop(\n data: ParentEventData,\n state: DragState\n) {\n dropped = true;\n\n const config = data.targetData.parent.data.config;\n\n config.handleEnd(state);\n}\n\nexport function tearDown(parent: HTMLElement) {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n if (parentData.abortControllers.mainParent)\n parentData.abortControllers.mainParent.abort();\n}\n\nexport function isDragState(\n state: BaseDragState\n): state is DragState | SynthDragState {\n return \"draggedNode\" in state && !!state.draggedNode;\n}\n\nexport function isSynthDragState(\n state: BaseDragState\n): state is SynthDragState {\n return \"pointerId\" in state && !!state.pointerId;\n}\n\nfunction setup(parent: HTMLElement, parentData: ParentData): void {\n parentData.abortControllers.mainParent = addEvents(parent, {\n keydown: parentEventData(parentData.config.handleParentKeydown),\n dragover: parentEventData(parentData.config.handleParentDragover),\n handleParentPointerover: parentData.config.handleParentPointerover,\n drop: parentEventData(parentData.config.handleParentDrop),\n hasNestedParent: (e: CustomEvent) => {\n const parent = parents.get(e.target as HTMLElement);\n\n if (!parent) return;\n\n parent.nestedParent = e.detail.parent;\n },\n blur: parentEventData(parentData.config.handleParentBlur),\n focus: parentEventData(parentData.config.handleParentFocus),\n });\n\n setAttrs(parent, {\n role: \"listbox\",\n tabindex: \"0\",\n \"aria-multiselectable\": parentData.config.multiDrag ? \"true\" : \"false\",\n \"aria-activedescendant\": \"\",\n \"aria-describedby\": parent.id + \"-live-region\",\n });\n\n const liveRegion = document.createElement(\"div\");\n\n setAttrs(liveRegion, {\n \"aria-live\": \"polite\",\n \"aria-atomic\": \"true\",\n \"data-drag-and-drop-live-region\": \"true\",\n id: parent.id.toString() + \"-live-region\",\n });\n\n Object.assign(liveRegion.style, {\n position: \"absolute\",\n width: \"1px\",\n height: \"1px\",\n padding: \"0\",\n overflow: \"hidden\",\n clip: \"rect(0, 0, 0, 0)\",\n whiteSpace: \"nowrap\",\n border: \"0\",\n });\n\n document.body.appendChild(liveRegion);\n}\n\nexport function setAttrs(el: HTMLElement, attrs: Record) {\n for (const key in attrs) el.setAttribute(key, attrs[key]);\n}\n\nexport function setupNode(data: SetupNodeData) {\n const config = data.parent.data.config;\n\n data.node.el.draggable = true;\n\n data.node.data.abortControllers.mainNode = addEvents(data.node.el, {\n keydown: nodeEventData(config.handleNodeKeydown),\n dragstart: nodeEventData(config.handleDragstart),\n dragover: nodeEventData(config.handleNodeDragover),\n dragenter: nodeEventData(config.handleNodeDragenter),\n dragleave: nodeEventData(config.handleNodeDragleave),\n dragend: nodeEventData(config.handleDragend),\n drop: nodeEventData(config.handleNodeDrop),\n touchstart: nodeEventData(config.handleNodeTouchstart),\n pointerdown: nodeEventData(config.handleNodePointerdown),\n pointerup: nodeEventData(config.handleNodePointerup),\n pointermove: nodeEventData(config.handleNodePointermove),\n handleNodePointerover: config.handleNodePointerover,\n mousedown: () => {\n if (!config.nativeDrag) isNative = false;\n else isNative = true;\n },\n });\n\n data.node.el.setAttribute(\"role\", \"option\");\n\n data.node.el.setAttribute(\"aria-selected\", \"false\");\n\n config.reapplyDragClasses(data.node.el, data.parent.data);\n\n data.parent.data.config.plugins?.forEach((plugin: DNDPlugin) => {\n plugin(data.parent.el)?.setupNode?.(data);\n });\n}\n\nexport function setupNodeRemap(data: SetupNodeData) {\n nodes.set(data.node.el, data.node.data);\n\n data.parent.data.config.plugins?.forEach((plugin: DNDPlugin) => {\n plugin(data.parent.el)?.setupNodeRemap?.(data);\n });\n}\n\nfunction reapplyDragClasses(node: Node, parentData: ParentData) {\n if (!isDragState(state)) return;\n\n const dropZoneClass = isSynthDragState(state)\n ? parentData.config.synthDropZoneClass\n : parentData.config.dropZoneClass;\n\n if (state.draggedNode.el !== node) return;\n\n addNodeClass([node], dropZoneClass, true);\n}\n\nexport function tearDownNodeRemap(data: TearDownNodeData) {\n data.parent.data.config.plugins?.forEach((plugin: DNDPlugin) => {\n plugin(data.parent.el)?.tearDownNodeRemap?.(data);\n });\n}\n\nexport function tearDownNode(data: TearDownNodeData) {\n data.parent.data.config.plugins?.forEach((plugin: DNDPlugin) => {\n plugin(data.parent.el)?.tearDownNode?.(data);\n });\n\n data.node.el.draggable = false;\n\n if (data.node.data?.abortControllers?.mainNode)\n data.node.data?.abortControllers?.mainNode.abort();\n}\n\n/**\n * Called when the nodes of a given parent element are mutated.\n *\n * @param mutationList - The list of mutations.\n *\n * @returns void\n *\n * @internal\n */\nfunction nodesMutated(mutationList: MutationRecord[]) {\n const parentEl = mutationList[0].target;\n\n if (!(parentEl instanceof HTMLElement)) return;\n\n const allSelectedAndActiveNodes = document.querySelectorAll(\n `[aria-selected=\"true\"]`\n );\n\n const parentData = parents.get(parentEl);\n\n if (!parentData) return;\n\n for (let x = 0; x < allSelectedAndActiveNodes.length; x++) {\n const node = allSelectedAndActiveNodes[x];\n\n node.setAttribute(\"aria-selected\", \"false\");\n\n removeClass([node], parentData.config.selectedClass);\n }\n\n remapNodes(parentEl);\n}\n\n/**\n * Remaps the data of the parent element's children.\n *\n * @param parent - The parent element.\n *\n * @returns void\n *\n * @internal\n */\nexport function remapNodes(parent: HTMLElement, force?: boolean) {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n parentData.privateClasses = Array.from(parent.classList);\n\n const enabledNodes: Array = [];\n\n const config = parentData.config;\n\n for (let x = 0; x < parent.children.length; x++) {\n const node = parent.children[x];\n\n if (!isNode(node)) continue;\n\n const nodeData = nodes.get(node);\n\n // Only tear down the node if we have explicitly called dragAndDrop\n if (force || !nodeData)\n config.tearDownNode({\n parent: {\n el: parent,\n data: parentData,\n },\n node: {\n el: node,\n data: nodeData,\n },\n });\n\n if (config.disabled) continue;\n\n if (!config.draggable || (config.draggable && config.draggable(node))) {\n enabledNodes.push(node);\n }\n }\n\n if (\n enabledNodes.length !== parentData.getValues(parent).length &&\n !config.disabled\n ) {\n console.warn(\n \"The number of draggable items defined in the parent element does not match the number of values. This may cause unexpected behavior.\"\n );\n\n return;\n }\n\n if (parentData.config.treeGroup && !parentData.config.treeAncestor) {\n let nextAncestorEl = parent.parentElement;\n\n let eventDispatched = false;\n\n while (nextAncestorEl) {\n if (!parents.has(nextAncestorEl as HTMLElement)) {\n nextAncestorEl = nextAncestorEl.parentElement;\n\n continue;\n }\n\n nextAncestorEl.dispatchEvent(\n new CustomEvent(\"hasNestedParent\", {\n detail: {\n parent: { data: parentData, el: parent },\n },\n })\n );\n\n eventDispatched = true;\n\n nextAncestorEl = null;\n }\n\n if (!eventDispatched) console.warn(\"No ancestor found for tree group\");\n }\n\n const values = parentData.getValues(parent);\n\n const enabledNodeRecords: Array> = [];\n\n for (let x = 0; x < enabledNodes.length; x++) {\n const node = enabledNodes[x];\n\n const prevNodeData = nodes.get(node);\n\n const nodeData = Object.assign(\n prevNodeData ?? {\n privateClasses: [],\n abortControllers: {},\n },\n {\n value: values[x],\n index: x,\n }\n );\n\n if (\n !isDragState(state) &&\n state.newActiveDescendant &&\n state.newActiveDescendant.data.value === nodeData.value\n ) {\n setActive(\n {\n data: parentData,\n el: parent,\n },\n {\n el: node,\n data: nodeData,\n },\n state\n );\n }\n\n if (\n !isDragState(state) &&\n state.activeState &&\n state.activeState.node.data.value === nodeData.value\n ) {\n setActive(\n {\n data: parentData,\n el: parent,\n },\n {\n el: node,\n data: nodeData,\n },\n state\n );\n }\n\n if (isDragState(state) && nodeData.value === state.draggedNode.data.value) {\n state.draggedNode.data = nodeData;\n\n state.draggedNode.el = node;\n const draggedNode = state.draggedNodes.find(\n (x) => x.data.value === nodeData.value\n );\n\n if (draggedNode) draggedNode.el = node;\n\n if (isSynthDragState(state))\n state.draggedNode.el.setPointerCapture(state.pointerId);\n }\n\n enabledNodeRecords.push({\n el: node,\n data: nodeData,\n });\n\n if (force || !prevNodeData)\n config.setupNode({\n parent: {\n el: parent,\n data: parentData,\n },\n node: {\n el: node,\n data: nodeData,\n },\n });\n\n setupNodeRemap({\n parent: {\n el: parent,\n data: parentData,\n },\n node: {\n el: node,\n data: nodeData,\n },\n });\n }\n\n parents.set(parent, { ...parentData, enabledNodes: enabledNodeRecords });\n\n config.remapFinished(parentData);\n\n parentData.config.plugins?.forEach((plugin: DNDPlugin) => {\n plugin(parent)?.remapFinished?.();\n });\n}\n\nexport function remapFinished() {\n state.remapJustFinished = true;\n\n if (\"draggedNode\" in state) state.affectedNodes = [];\n}\n\nexport function validateDragstart(data: NodeEventData): boolean {\n return !!data.targetData.parent.data.config.nativeDrag;\n}\n\nfunction draggedNodes(data: NodeEventData): Array> {\n if (!data.targetData.parent.data.config.multiDrag) {\n return [data.targetData.node];\n } else if (state.selectedState) {\n return [\n data.targetData.node,\n ...(state.selectedState?.nodes.filter(\n (x) => x.el !== data.targetData.node.el\n ) as Array>),\n ];\n }\n\n return [];\n}\n\n/**\n * Responsible for assigning dragstart classes to the dragged nodes.\n */\nexport function handleDragstart(\n data: NodeDragEventData,\n state: BaseDragState\n) {\n if (!validateDragstart(data) || !validateDragHandle(data)) {\n data.e.preventDefault();\n\n return;\n }\n\n const config = data.targetData.parent.data.config;\n\n const nodes = config.draggedNodes(data);\n\n config.dragstartClasses(data.targetData.node, nodes, config);\n\n const dragState = initDrag(data, nodes);\n\n if (config.onDragstart)\n config.onDragstart(\n {\n parent: data.targetData.parent,\n values: parentValues(\n data.targetData.parent.el,\n data.targetData.parent.data\n ),\n draggedNode: dragState.draggedNode,\n draggedNodes: dragState.draggedNodes,\n position: dragState.initialIndex,\n },\n state as DragState\n );\n}\n\nexport function handleNodePointerdown(\n data: NodePointerEventData,\n state: BaseDragState\n) {\n console.log(\"pointerdown\", synthNodePointerDown);\n\n if (!validateDragHandle(data)) return;\n\n data.e.stopPropagation();\n\n synthNodePointerDown = true;\n\n const parentData = data.targetData.parent.data;\n\n let selectedNodes = [data.targetData.node];\n\n const commandKey = data.e.ctrlKey || data.e.metaKey;\n const shiftKey = data.e.shiftKey;\n\n const targetNode = data.targetData.node;\n\n if (commandKey && parentData.config.multiDrag) {\n if (state.selectedState) {\n const idx = state.selectedState.nodes.findIndex(\n (x) => x.el === targetNode.el\n );\n\n if (idx === -1) {\n selectedNodes = [...state.selectedState.nodes, targetNode];\n } else {\n selectedNodes = state.selectedState.nodes.filter(\n (x) => x.el !== targetNode.el\n );\n }\n } else {\n selectedNodes = [targetNode];\n }\n\n setSelected(\n data.targetData.parent,\n selectedNodes,\n data.targetData.node,\n state,\n true\n );\n\n return;\n }\n\n if (shiftKey && parentData.config.multiDrag) {\n const nodes = data.targetData.parent.data.enabledNodes;\n if (state.selectedState && state.activeState) {\n if (state.selectedState.parent.el !== data.targetData.parent.el) {\n deselect(state.selectedState.nodes, state.selectedState.parent, state);\n state.selectedState = undefined;\n for (let x = 0; x <= targetNode.data.index; x++)\n selectedNodes.push(nodes[x]);\n } else {\n const [minIndex, maxIndex] =\n state.activeState.node.data.index < data.targetData.node.data.index\n ? [\n state.activeState.node.data.index,\n data.targetData.node.data.index,\n ]\n : [\n data.targetData.node.data.index,\n state.activeState.node.data.index,\n ];\n selectedNodes = nodes.slice(minIndex, maxIndex + 1);\n }\n } else {\n for (let x = 0; x <= targetNode.data.index; x++)\n selectedNodes.push(nodes[x]);\n }\n setSelected(\n data.targetData.parent,\n selectedNodes,\n data.targetData.node,\n state,\n true\n );\n\n return;\n }\n\n if (state.selectedState?.nodes?.length) {\n const idx = state.selectedState.nodes.findIndex(\n (x) => x.el === data.targetData.node.el\n );\n\n if (idx === -1) {\n if (state.selectedState.parent.el !== data.targetData.parent.el) {\n deselect(state.selectedState.nodes, data.targetData.parent, state);\n } else if (parentData.config.multiDrag && (touchDevice || !isNative)) {\n selectedNodes.push(...state.selectedState.nodes);\n } else {\n deselect(state.selectedState.nodes, data.targetData.parent, state);\n }\n setSelected(\n data.targetData.parent,\n selectedNodes,\n data.targetData.node,\n state,\n true\n );\n }\n } else {\n setSelected(\n data.targetData.parent,\n [data.targetData.node],\n data.targetData.node,\n state,\n true\n );\n }\n}\n\nexport function dragstartClasses(\n _node: NodeRecord,\n nodes: Array>,\n config: ParentConfig,\n isSynth = false\n) {\n addNodeClass(\n nodes.map((x) => x.el),\n isSynth ? config.synthDraggingClass : config.draggingClass\n );\n\n setTimeout(() => {\n removeClass(\n nodes.map((x) => x.el),\n isSynth ? config.synthDraggingClass : config.draggingClass\n );\n\n addNodeClass(\n nodes.map((x) => x.el),\n isSynth ? config.synthDragPlaceholderClass : config.dragPlaceholderClass\n );\n\n addNodeClass(\n nodes.map((x) => x.el),\n isSynth ? config.synthDropZoneClass : config.dropZoneClass\n );\n\n removeClass(\n nodes.map((x) => x.el),\n config.activeDescendantClass\n );\n\n removeClass(\n nodes.map((x) => x.el),\n config.selectedClass\n );\n });\n}\n\nexport function initDrag(\n data: NodeDragEventData,\n draggedNodes: Array>\n): DragState {\n const dragState = setDragState(dragStateProps(data, draggedNodes));\n\n data.e.stopPropagation();\n\n if (data.e.dataTransfer) {\n const config = data.targetData.parent.data.config;\n\n data.e.dataTransfer.dropEffect = config.dragDropEffect;\n\n data.e.dataTransfer.effectAllowed = config.dragEffectAllowed;\n\n let dragImage: HTMLElement | undefined;\n\n if (config.dragImage) {\n dragImage = config.dragImage(data, draggedNodes);\n } else {\n if (!config.multiDrag) {\n data.e.dataTransfer.setDragImage(\n data.targetData.node.el,\n data.e.offsetX,\n data.e.offsetY\n );\n\n return dragState;\n } else {\n const wrapper = document.createElement(\"div\");\n\n for (const node of draggedNodes) {\n const clonedNode = node.el.cloneNode(true) as HTMLElement;\n\n clonedNode.style.pointerEvents = \"none\";\n\n clonedNode.id = node.el.id + \"-clone\";\n\n copyNodeStyle(node.el, clonedNode, true);\n\n wrapper.append(clonedNode);\n }\n\n const { width } = draggedNodes[0].el.getBoundingClientRect();\n\n Object.assign(wrapper.style, {\n display: \"flex\",\n flexDirection: \"column\",\n width: `${width}px`,\n position: \"absolute\",\n pointerEvents: \"none\",\n zIndex: \"9999\",\n left: \"-9999px\",\n });\n\n dragImage = wrapper;\n }\n\n document.body.appendChild(dragImage);\n }\n\n data.e.dataTransfer.setDragImage(dragImage, data.e.offsetX, data.e.offsetY);\n\n setTimeout(() => {\n dragImage?.remove();\n });\n }\n\n return dragState;\n}\n\nexport function validateDragHandle(\n data: NodeDragEventData | NodePointerEventData\n): boolean {\n const config = data.targetData.parent.data.config;\n\n if (!config.dragHandle) return true;\n\n const dragHandles = data.targetData.node.el.querySelectorAll(\n config.dragHandle\n );\n\n if (!dragHandles) return false;\n\n const coordinates = data.e;\n\n const elFromPoint = config.root.elementFromPoint(\n coordinates.x,\n coordinates.y\n );\n\n if (!elFromPoint) return false;\n\n for (const handle of Array.from(dragHandles))\n if (elFromPoint === handle || handle.contains(elFromPoint)) return true;\n\n return false;\n}\n\nexport function handleClickNode(_data: NodeEventData) {}\n\nexport function handleClickParent(_data: ParentEventData) {}\n\nexport function handleNodeKeydown(_data: NodeEventData) {}\n\nexport function handleParentKeydown(\n data: ParentKeydownEventData,\n state: BaseDragState\n) {\n const activeDescendant = state.activeState?.node;\n\n if (!activeDescendant) return;\n\n const parentData = data.targetData.parent.data;\n\n const enabledNodes = parentData.enabledNodes;\n\n const index = enabledNodes.findIndex((x) => x.el === activeDescendant.el);\n\n if (index === -1) return;\n\n if (\n [\"ArrowDown\", \"ArrowUp\", \"ArrowRight\", \"ArrowLeft\"].includes(data.e.key)\n ) {\n data.e.preventDefault();\n\n const nextIndex =\n data.e.key === \"ArrowDown\" || data.e.key === \"ArrowRight\"\n ? index + 1\n : index - 1;\n\n if (nextIndex < 0 || nextIndex >= enabledNodes.length) return;\n\n const nextNode = enabledNodes[nextIndex];\n\n setActive(data.targetData.parent, nextNode, state);\n } else if (data.e.key === \" \") {\n data.e.preventDefault();\n\n state.selectedState && state.selectedState.nodes.includes(activeDescendant)\n ? setSelected(\n data.targetData.parent,\n state.selectedState.nodes.filter((x) => x.el !== activeDescendant.el),\n activeDescendant,\n state\n )\n : setSelected(\n data.targetData.parent,\n [activeDescendant],\n activeDescendant,\n state\n );\n\n //if (!state.selectedState)\n // updateLiveRegion(data.targetData.parent, \"\", true);\n } else if (data.e.key === \"Enter\" && state.selectedState) {\n if (\n state.selectedState.parent.el === data.targetData.parent.el &&\n state.activeState\n ) {\n if (state.selectedState.nodes[0].el === state.activeState.node.el) {\n updateLiveRegion(data.targetData.parent, \"Cannot drop item on itself\");\n\n return;\n }\n\n state.newActiveDescendant = state.selectedState.nodes[0];\n\n parentData.config.performSort({\n parent: data.targetData.parent,\n draggedNodes: state.selectedState.nodes,\n targetNode: state.activeState.node,\n });\n\n deselect([], data.targetData.parent, state);\n\n updateLiveRegion(data.targetData.parent, \"Drop successful\");\n } else if (\n state.activeState &&\n state.selectedState.parent.el !== data.targetData.parent.el &&\n validateTransfer({\n currentParent: data.targetData.parent,\n targetParent: state.selectedState.parent,\n initialParent: state.selectedState.parent,\n draggedNodes: state.selectedState.nodes,\n state,\n })\n ) {\n parentData.config.performTransfer({\n currentParent: state.selectedState.parent,\n targetParent: data.targetData.parent,\n initialParent: state.selectedState.parent,\n draggedNodes: state.selectedState.nodes,\n initialIndex: state.selectedState.nodes[0].data.index,\n state,\n targetNode: state.activeState.node,\n });\n\n state.newActiveDescendant = state.selectedState.nodes[0];\n\n setSelected(data.targetData.parent, [], undefined, state);\n\n updateLiveRegion(data.targetData.parent, \"Drop successful\");\n }\n }\n}\n\nexport function preventSortOnScroll() {\n let scrollTimeout: number;\n\n return () => {\n clearTimeout(scrollTimeout);\n\n if (state) state.preventEnter = true;\n\n scrollTimeout = setTimeout(() => {\n if (state) state.preventEnter = false;\n }, 100);\n };\n}\n\nexport function handleNodePointerover(e: PointeroverNodeEvent) {\n if (e.detail.targetData.parent.el === e.detail.state.currentParent.el)\n sort(e.detail, e.detail.state);\n else transfer(e.detail, e.detail.state);\n}\n\nexport function handleNodeDrop(\n data: NodeDragEventData,\n state: DragState | SynthDragState\n) {\n data.e.stopPropagation();\n\n dropped = true;\n\n const config = data.targetData.parent.data.config;\n\n config.handleEnd(state);\n}\n\nexport function handleDragend(\n data: NodeEventData,\n state: DragState | SynthDragState\n) {\n data.e.preventDefault();\n\n if (dropped) {\n dropped = false;\n\n return;\n }\n\n const config = parents.get(state.initialParent.el)?.config;\n config?.handleEnd(state);\n\n if (config?.onDragend) {\n config.onDragend({\n parent: state.currentParent,\n values: parentValues(state.currentParent.el, state.currentParent.data),\n draggedNode: state.draggedNode,\n draggedNodes: state.draggedNodes,\n position: state.initialIndex,\n });\n }\n}\n\nexport function handleEnd(state: DragState | SynthDragState) {\n cancelSynthScroll();\n\n for (const [_el, controller] of state.scrollEls) controller.abort();\n\n if (\"longPressTimeout\" in state && state.longPressTimeout)\n clearTimeout(state.longPressTimeout);\n\n const config = parents.get(state.initialParent.el)?.config;\n\n const isSynth = \"clonedDraggedNode\" in state && state.clonedDraggedNode;\n\n const dropZoneClass = isSynth\n ? config?.synthDropZoneClass\n : config?.dropZoneClass;\n\n if (state.originalZIndex !== undefined)\n state.draggedNode.el.style.zIndex = state.originalZIndex;\n\n removeClass(\n state.draggedNodes.map((x) => x.el),\n dropZoneClass\n );\n\n removeClass(\n state.draggedNodes.map((x) => x.el),\n state.initialParent.data?.config?.longPressClass\n );\n\n removeClass(\n state.draggedNodes.map((x) => x.el),\n isSynth\n ? state.initialParent.data.config.synthDragPlaceholderClass\n : state.initialParent.data?.config?.dragPlaceholderClass\n );\n\n if (isSynth) state.clonedDraggedNode.remove();\n\n deselect(state.draggedNodes, state.currentParent, state);\n\n setActive(state.currentParent, undefined, state);\n\n resetState();\n\n state.selectedState = undefined;\n\n synthNodePointerDown = false;\n\n state.emit(\"dragend\", state);\n}\n\nexport function handleNodeTouchstart(\n data: NodeEventData,\n _state: BaseDragState\n) {\n if (data.e.cancelable) data.e.preventDefault();\n}\n\nexport function handleNodePointerup(\n data: NodePointerEventData,\n state: DragState | SynthDragState | BaseDragState\n) {\n if (!state.pointerSelection && state.selectedState)\n deselect(state.selectedState.nodes, data.targetData.parent, state);\n\n const config = data.targetData.parent.data.config;\n\n state.pointerSelection = false;\n\n synthNodePointerDown = false;\n\n if (!isDragState(state)) return;\n\n config.handleEnd(state as DragState | SynthDragState);\n}\n\nexport function handleNodePointermove(\n data: NodePointerEventData,\n state: SynthDragState | BaseDragState\n) {\n // TODO: I think this is OK but not sure.\n //data.e.stopPropagation();\n\n if (isNative || !synthNodePointerDown || !validateDragHandle(data)) return;\n\n if (!isSynthDragState(state)) {\n const config = data.targetData.parent.data.config;\n\n const nodes = config.draggedNodes(data);\n\n config.dragstartClasses(data.targetData.node, nodes, config, true);\n\n const synthDragState = initSynthDrag(data, state, nodes);\n\n synthDragState.clonedDraggedNode.style.display =\n synthDragState.draggedNodeDisplay || \"\";\n\n synthMove(data, synthDragState);\n\n if (config.onDragstart)\n config.onDragstart(\n {\n parent: data.targetData.parent,\n values: parentValues(\n data.targetData.parent.el,\n data.targetData.parent.data\n ),\n draggedNode: synthDragState.draggedNode,\n draggedNodes: synthDragState.draggedNodes,\n position: synthDragState.initialIndex,\n },\n synthDragState\n );\n\n synthDragState.draggedNode.el.setPointerCapture(data.e.pointerId);\n\n synthDragState.pointerId = data.e.pointerId;\n\n return;\n }\n\n synthMove(data, state as SynthDragState);\n}\n\nfunction initSynthDrag(\n data: NodePointerEventData,\n _state: BaseDragState,\n draggedNodes: Array>\n): SynthDragState {\n const config = data.targetData.parent.data.config;\n\n let dragImage: HTMLElement | undefined;\n\n if (config.synthDragImage) {\n dragImage = config.synthDragImage(data, draggedNodes);\n } else {\n if (!config.multiDrag || draggedNodes.length === 1) {\n dragImage = data.targetData.node.el.cloneNode(true) as HTMLElement;\n\n dragImage.id = data.targetData.node.el.id + \"-clone\";\n\n copyNodeStyle(data.targetData.node.el, dragImage);\n\n Object.assign(dragImage.style, {\n width: data.targetData.node.el.getBoundingClientRect().width,\n zIndex: 9999,\n pointerEvents: \"none\",\n });\n\n document.body.appendChild(dragImage);\n } else {\n const wrapper = document.createElement(\"div\");\n\n for (const node of draggedNodes) {\n const clonedNode = node.el.cloneNode(true) as HTMLElement;\n\n copyNodeStyle(node.el, clonedNode);\n\n clonedNode.style.pointerEvents = \"none\";\n\n clonedNode.id = node.el.id + \"-clone\";\n\n wrapper.append(clonedNode);\n }\n\n const { width } = draggedNodes[0].el.getBoundingClientRect();\n\n Object.assign(wrapper.style, {\n display: \"flex\",\n flexDirection: \"column\",\n width: `${width}px`,\n position: \"fixed\",\n pointerEvents: \"none\",\n zIndex: \"9999\",\n left: \"-9999px\",\n });\n\n dragImage = wrapper;\n }\n }\n\n const display = dragImage.style.display;\n\n dragImage.style.display = \"none\";\n\n document.body.append(dragImage);\n\n dragImage.style.position = \"absolute\";\n\n const synthDragStateProps = {\n clonedDraggedEls: [],\n clonedDraggedNode: dragImage,\n draggedNodeDisplay: display,\n synthDragScrolling: false,\n };\n\n addEvents(document, {\n contextmenu: noDefault,\n });\n\n const synthDragState = setDragState({\n ...dragStateProps(data, draggedNodes, false),\n ...synthDragStateProps,\n }) as SynthDragState;\n\n return synthDragState;\n}\n\nexport function handleLongPress(\n data: NodePointerEventData,\n dragState: DragState\n) {\n const config = data.targetData.parent.data.config;\n\n if (!config.longPress) return;\n\n dragState.longPressTimeout = setTimeout(() => {\n if (!dragState) return;\n\n dragState.longPress = true;\n\n if (config.longPressClass && data.e.cancelable)\n addNodeClass(\n dragState.draggedNodes.map((x) => x.el),\n config.longPressClass\n );\n\n data.e.preventDefault();\n }, config.longPressTimeout || 200);\n}\n\nfunction pointermoveClasses(\n state: SynthDragState,\n config: ParentConfig\n) {\n if (config.longPressClass)\n removeClass(\n state.draggedNodes.map((x) => x.el),\n config?.longPressClass\n );\n}\n\nfunction getScrollData(\n e: DragEvent | PointerEvent,\n state: DragState | SynthDragState\n): ScrollData | undefined {\n if (!(e.currentTarget instanceof HTMLElement)) return;\n\n const {\n x: xThresh,\n y: yThresh,\n scrollOutside,\n } = state.initialParent.data.config.scrollBehavior;\n\n const coordinates = getRealCoords(e.currentTarget);\n\n return {\n xThresh,\n yThresh,\n scrollOutside,\n scrollParent: e.currentTarget,\n x: coordinates.left,\n y: coordinates.top,\n clientWidth: e.currentTarget.clientWidth,\n clientHeight: e.currentTarget.clientHeight,\n scrollWidth: e.currentTarget.scrollWidth,\n scrollHeight: e.currentTarget.scrollHeight,\n };\n}\n\nfunction cancelSynthScroll() {\n if (animationFrameId !== null) {\n cancelAnimationFrame(animationFrameId);\n\n animationFrameId = null;\n }\n}\n\nfunction setSynthScrollDirection(\n direction: \"up\" | \"down\" | \"left\" | \"right\" | undefined,\n el: HTMLElement,\n state: SynthDragState\n) {\n if (state.synthScrollDirection === direction) return;\n\n state.synthScrollDirection = direction;\n\n // Cancel any ongoing animation frame when direction changes\n cancelSynthScroll();\n\n if (direction === \"up\" && el.scrollTop === 0) return;\n\n if (direction === \"down\" && el.scrollTop + el.clientHeight >= el.scrollHeight)\n return;\n\n if (direction === \"left\" && el.scrollLeft === 0) return;\n\n if (direction === \"right\" && el.scrollLeft + el.clientWidth >= el.scrollWidth)\n return;\n\n let lastTimestamp: number | null = null;\n\n // Function to perform the scrolling based on the current direction\n const scroll = (timestamp: number) => {\n if (lastTimestamp === null) lastTimestamp = timestamp;\n\n const elapsed = timestamp - lastTimestamp;\n\n // Base scroll speed in pixels per second\n const baseSpeed = 500;\n\n const distance = (baseSpeed * elapsed) / 1000; // Pixels to scroll\n\n if (state.synthScrollDirection === undefined && animationFrameId) {\n cancelAnimationFrame(animationFrameId);\n\n animationFrameId = null;\n\n return;\n }\n\n switch (direction) {\n case \"up\":\n el.scrollBy(0, -distance);\n state.clonedDraggedNode.style.top = `${\n state.coordinates.y + el.scrollTop\n }px`;\n\n break;\n case \"down\":\n el.scrollBy(0, distance);\n state.clonedDraggedNode.style.top = `${\n state.coordinates.y + el.scrollTop - state.startTop\n }px`;\n\n break;\n case \"left\":\n el.scrollBy(-distance, 0);\n\n state.clonedDraggedNode.style.left = `${\n state.coordinates.x + el.scrollLeft\n }px`;\n\n break;\n case \"right\":\n state.clonedDraggedNode.style.left = `${\n state.coordinates.x + el.scrollLeft\n }px`;\n\n el.scrollBy(distance, 0);\n }\n\n lastTimestamp = timestamp;\n\n animationFrameId = requestAnimationFrame(scroll);\n };\n\n animationFrameId = requestAnimationFrame(scroll);\n}\n\nfunction shouldScroll(\n direction: string,\n e: DragEvent | PointerEvent,\n state: DragState | SynthDragState\n): boolean {\n const dataScrollData = getScrollData(e, state);\n\n if (!dataScrollData) return false;\n\n switch (direction) {\n case \"down\":\n return !!shouldScrollDown(state, dataScrollData);\n\n case \"up\":\n return !!shouldScrollUp(state, dataScrollData);\n\n case \"right\":\n return !!shouldScrollRight(state, dataScrollData);\n\n case \"left\":\n return !!shouldScrollLeft(state, dataScrollData);\n\n default:\n return false;\n }\n}\n\nfunction shouldScrollRight(\n state: DragState | SynthDragState,\n data: ScrollData\n): DragState | DragState | void {\n return;\n const diff = data.scrollParent.clientWidth + data.x - state.coordinates.x;\n\n if (!data.scrollOutside && diff < 0) return;\n\n if (\n diff < (1 - data.xThresh) * data.scrollParent.clientWidth &&\n !(\n data.scrollParent.scrollLeft + data.scrollParent.clientWidth >=\n data.scrollParent.scrollWidth\n )\n )\n return state;\n}\n\nfunction shouldScrollLeft(\n state: DragState,\n data: ScrollData\n): DragState | void {\n return;\n const diff = data.scrollParent.clientWidth + data.x - state.coordinates.x;\n\n if (!data.scrollOutside && diff > data.scrollParent.clientWidth) return;\n\n if (\n diff > data.xThresh * data.scrollParent.clientWidth &&\n data.scrollParent.scrollLeft !== 0\n )\n return state;\n}\n\nfunction shouldScrollUp(state: DragState, data: ScrollData): boolean {\n return (\n state.coordinates.y <= 0.1 * data.scrollParent.clientHeight &&\n data.scrollParent.scrollTop !== 0\n );\n}\n\nfunction shouldScrollDown(state: DragState, data: ScrollData): boolean {\n return (\n state.coordinates.y > data.clientHeight * data.yThresh &&\n data.scrollParent.scrollTop !== data.scrollParent.clientHeight\n );\n}\n\nfunction moveNode(data: NodePointerEventData, state: SynthDragState) {\n const { x, y } = eventCoordinates(data.e);\n\n state.coordinates.y = y;\n\n state.coordinates.x = x;\n\n const startLeft = state.startLeft ?? 0;\n\n const startTop = state.startTop ?? 0;\n\n state.clonedDraggedNode.style.top = `${y - startTop + window.scrollY}px`;\n\n state.clonedDraggedNode.style.left = `${x - startLeft + window.scrollX}px`;\n\n if (data.e.cancelable) data.e.preventDefault();\n\n pointermoveClasses(state, data.targetData.parent.data.config);\n}\n\nexport function synthMove(\n data: NodePointerEventData,\n state: SynthDragState\n) {\n const config = data.targetData.parent.data.config;\n\n if (config.longPress && !state.longPress) {\n clearTimeout(state.longPressTimeout);\n\n return;\n }\n\n moveNode(data, state);\n\n const elFromPoint = getElFromPoint(eventCoordinates(data.e));\n\n if (!elFromPoint) {\n document.dispatchEvent(\n new CustomEvent(\"handleRootPointerover\", {\n detail: {\n e: data.e,\n state,\n },\n })\n );\n\n return;\n }\n const pointerMoveEventData = {\n e: data.e,\n targetData: elFromPoint,\n state,\n };\n\n if (\"node\" in elFromPoint) {\n elFromPoint.node.el.dispatchEvent(\n new CustomEvent(\"handleNodePointerover\", {\n detail: pointerMoveEventData,\n })\n );\n } else {\n elFromPoint.parent.el.dispatchEvent(\n new CustomEvent(\"handleParentPointerover\", {\n detail: pointerMoveEventData,\n })\n );\n }\n}\n\nexport function handleScroll(e: DragEvent | PointerEvent) {\n e.stopPropagation();\n\n if (!isSynthDragState(state)) return;\n let directionSet = false;\n\n for (const direction of Object.keys(scrollConfig)) {\n if (shouldScroll(direction, e, state)) {\n setSynthScrollDirection(\n direction as \"up\" | \"down\" | \"left\" | \"right\" | undefined,\n e.currentTarget as HTMLElement,\n state\n );\n\n directionSet = true;\n\n break;\n }\n }\n\n if (!directionSet) state.synthScrollDirection = undefined;\n}\n\nexport function handleNodeDragover(\n data: NodeDragEventData,\n state: DragState\n) {\n const { x, y } = eventCoordinates(data.e);\n\n state.coordinates.y = y;\n\n state.coordinates.x = x;\n\n //data.e.preventDefault();\n\n //data.e.stopPropagation();\n\n data.targetData.parent.el === state.currentParent?.el\n ? sort(data, state)\n : transfer(data, state);\n}\n\nexport function handleParentDragover(\n data: ParentEventData,\n state: DragState\n) {\n if (!state) return;\n\n Object.assign(eventCoordinates(data.e as DragEvent));\n\n transfer(data, state);\n}\n\nexport function handleParentPointerover(e: PointeroverParentEvent) {\n if (e.detail.targetData.parent.el !== e.detail.state.currentParent.el)\n transfer(e.detail, e.detail.state);\n}\n\nexport function validateTransfer({\n currentParent,\n targetParent,\n initialParent,\n draggedNodes,\n state,\n}: {\n currentParent: ParentRecord;\n targetParent: ParentRecord;\n initialParent: ParentRecord;\n draggedNodes: Array>;\n state: BaseDragState;\n}) {\n if (targetParent.el === currentParent.el) return false;\n\n const targetConfig = targetParent.data.config;\n\n // Not checking for contains among all dragged nodes, should do this.\n if (targetConfig.treeGroup && draggedNodes[0].el.contains(targetParent.el))\n return false;\n\n if (targetConfig.dropZone === false) return false;\n\n const initialParentConfig = initialParent.data.config;\n\n if (targetConfig.accepts) {\n return targetConfig.accepts(\n targetParent,\n initialParent,\n currentParent,\n state\n );\n } else if (\n !targetConfig.group ||\n targetConfig.group !== initialParentConfig.group\n ) {\n return false;\n }\n\n return true;\n}\n\nfunction handleNodeDragenter(\n data: NodeDragEventData,\n _state: DragState\n) {\n data.e.preventDefault();\n}\n\nfunction handleNodeDragleave(\n data: NodeDragEventData,\n _state: DragState\n) {\n data.e.preventDefault();\n}\n\nexport function validateSort(\n data: NodeDragEventData | NodePointerEventData,\n state: DragState,\n x: number,\n y: number\n): boolean {\n if (\n state.affectedNodes\n .map((x) => x.data.value)\n .includes(data.targetData.node.data.value)\n ) {\n return false;\n }\n\n if (state.remapJustFinished) {\n state.remapJustFinished = false;\n\n if (\n data.targetData.node.data.value === state.currentTargetValue ||\n state.draggedNodes.map((x) => x.el).includes(data.targetData.node.el)\n ) {\n state.currentTargetValue = data.targetData.node.data.value;\n }\n\n return false;\n }\n\n if (state.preventEnter) return false;\n\n if (state.draggedNodes.map((x) => x.el).includes(data.targetData.node.el)) {\n state.currentTargetValue = undefined;\n\n return false;\n }\n\n if (data.targetData.node.data.value === state.currentTargetValue)\n return false;\n\n if (\n data.targetData.parent.el !== state.currentParent?.el ||\n data.targetData.parent.data.config.sortable === false\n )\n return false;\n\n const targetRect = data.targetData.node.el.getBoundingClientRect();\n\n const dragRect = state.draggedNode.el.getBoundingClientRect();\n\n const yDiff = targetRect.y - dragRect.y;\n\n const xDiff = targetRect.x - dragRect.x;\n\n let incomingDirection: \"above\" | \"below\" | \"left\" | \"right\";\n\n if (Math.abs(yDiff) > Math.abs(xDiff)) {\n incomingDirection = yDiff > 0 ? \"above\" : \"below\";\n } else {\n incomingDirection = xDiff > 0 ? \"left\" : \"right\";\n }\n\n const threshold = state.currentParent.data.config.threshold;\n\n switch (incomingDirection) {\n case \"left\":\n if (x > targetRect.x + targetRect.width * threshold.horizontal) {\n state.incomingDirection = \"left\";\n\n return true;\n }\n break;\n\n case \"right\":\n if (x < targetRect.x + targetRect.width * (1 - threshold.horizontal)) {\n state.incomingDirection = \"right\";\n\n return true;\n }\n break;\n\n case \"above\":\n if (y > targetRect.y + targetRect.height * threshold.vertical) {\n state.incomingDirection = \"above\";\n\n return true;\n }\n break;\n\n case \"below\":\n if (y < targetRect.y + targetRect.height * (1 - threshold.vertical)) {\n state.incomingDirection = \"below\";\n\n return true;\n }\n break;\n\n default:\n break;\n }\n\n return false;\n}\n\nexport function sort(\n data: NodeDragEventData | NodePointerEventData,\n state: DragState\n) {\n const { x, y } = eventCoordinates(data.e);\n\n if (!validateSort(data, state, x, y)) return;\n\n const range =\n state.draggedNode.data.index > data.targetData.node.data.index\n ? [data.targetData.node.data.index, state.draggedNode.data.index]\n : [state.draggedNode.data.index, data.targetData.node.data.index];\n\n state.targetIndex = data.targetData.node.data.index;\n\n state.affectedNodes = data.targetData.parent.data.enabledNodes.filter(\n (node) => {\n return (\n range[0] <= node.data.index &&\n node.data.index <= range[1] &&\n node.el !== state.draggedNode.el\n );\n }\n );\n\n data.targetData.parent.data.config.performSort({\n parent: data.targetData.parent,\n draggedNodes: state.draggedNodes,\n targetNode: data.targetData.node,\n });\n}\n\n/**\n * Event listener used for all nodes.\n *\n * @param e - The event.\n *\n */\nexport function nodeEventData(\n callback: any\n): (e: Event) => NodeEventData | undefined {\n function nodeTargetData(node: Node): NodeTargetData | undefined {\n const nodeData = nodes.get(node);\n\n if (!nodeData) return;\n\n const parentData = parents.get(node.parentNode);\n\n if (!parentData) return;\n\n return {\n node: {\n el: node,\n data: nodeData,\n },\n parent: {\n el: node.parentNode,\n data: parentData,\n },\n };\n }\n\n return (e: Event) => {\n const targetData = nodeTargetData(e.currentTarget as Node);\n\n if (!targetData) return;\n\n return callback(\n {\n e,\n targetData,\n },\n state\n );\n };\n}\n\n/**\n * Used when the dragged element enters into a parent other than its own.\n */\nexport function transfer(\n data: NodeEventData | ParentEventData,\n state: DragState\n): void {\n if (\n !validateTransfer({\n currentParent: state.currentParent,\n targetParent: data.targetData.parent,\n initialParent: state.initialParent,\n draggedNodes: state.draggedNodes,\n state,\n })\n )\n return;\n\n data.targetData.parent.data.config.performTransfer({\n currentParent: state.currentParent,\n targetParent: data.targetData.parent,\n initialParent: state.initialParent,\n draggedNodes: state.draggedNodes,\n initialIndex: state.initialIndex,\n state,\n targetNode: \"node\" in data.targetData ? data.targetData.node : undefined,\n });\n\n state.currentParent = data.targetData.parent;\n\n state.transferred = true;\n}\n\nexport function parentEventData(\n callback: any\n): (e: Event) => NodeEventData | undefined {\n function parentTargetData(\n parent: HTMLElement\n ): ParentTargetData | undefined {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n return {\n parent: {\n el: parent,\n data: parentData as ParentData,\n },\n };\n }\n\n return (e: Event) => {\n const targetData = parentTargetData(e.currentTarget as HTMLElement);\n\n if (!targetData) return;\n\n return callback(\n {\n e,\n targetData,\n },\n state\n );\n };\n}\n\nexport function noDefault(e: Event) {\n e.preventDefault();\n}\n\nexport function throttle(callback: any, limit: number) {\n var wait = false;\n return function (...args: any[]) {\n if (!wait) {\n callback.call(null, ...args);\n wait = true;\n setTimeout(function () {\n wait = false;\n }, limit);\n }\n };\n}\n\nfunction splitClass(className: string): Array {\n return className.split(\" \").filter((x) => x);\n}\n\nexport function addNodeClass(\n els: Array,\n className: string | undefined,\n omitAppendPrivateClass = false\n) {\n function nodeSetter(node: Node, nodeData: NodeData) {\n nodes.set(node, nodeData);\n }\n\n for (const el of els) {\n const nodeData = nodes.get(el as Node);\n\n const newData = addClass(el, className, nodeData, omitAppendPrivateClass);\n\n if (!newData) continue;\n\n nodeSetter(el as Node, newData as NodeData);\n }\n}\n\nexport function addParentClass(\n els: Array,\n className: string | undefined,\n omitAppendPrivateClass = false\n) {\n function parentSetter(parent: HTMLElement, parentData: ParentData) {\n parents.set(parent, parentData);\n }\n\n for (const el of els) {\n const parentData = parents.get(el);\n\n const newData = addClass(el, className, parentData, omitAppendPrivateClass);\n\n if (!newData) continue;\n\n parentSetter(el, newData as ParentData);\n }\n}\n\nexport function addClass(\n el: Node | HTMLElement | Element,\n className: string | undefined,\n data: NodeData | ParentData | undefined,\n omitAppendPrivateClass = false\n) {\n if (!className) return;\n\n const classNames = splitClass(className);\n\n if (!classNames.length) return;\n\n if (classNames.includes(\"longPress\")) return;\n\n if (!data) {\n el.classList.add(...classNames);\n\n return;\n }\n\n const privateClasses = [];\n\n for (const className of classNames) {\n if (!el.classList.contains(className)) {\n el.classList.add(className);\n } else if (\n el.classList.contains(className) &&\n omitAppendPrivateClass === false\n ) {\n privateClasses.push(className);\n }\n }\n\n data.privateClasses = privateClasses;\n\n return data;\n}\n\nexport function removeClass(\n els: Array,\n className: string | undefined\n) {\n if (!className) return;\n\n const classNames = splitClass(className);\n\n if (!classNames.length) return;\n\n for (const node of els) {\n if (!isNode(node)) {\n node.classList.remove(...classNames);\n continue;\n }\n\n const nodeData = nodes.get(node) || parents.get(node);\n\n if (!nodeData) continue;\n\n for (const className of classNames) {\n if (!nodeData.privateClasses.includes(className)) {\n node.classList.remove(className);\n }\n }\n }\n}\n\nfunction isScrollable(element: HTMLElement) {\n if (element === document.documentElement) {\n return (\n element.scrollHeight > element.clientHeight ||\n element.scrollWidth > element.clientWidth\n );\n }\n\n const style = window.getComputedStyle(element);\n\n return (\n ((style.overflowY === \"auto\" || style.overflowY === \"scroll\") &&\n element.scrollHeight > element.clientHeight) ||\n ((style.overflowX === \"auto\" || style.overflowX === \"scroll\") &&\n element.scrollWidth > element.clientWidth)\n );\n}\n\n/**\n * Used for getting the closest scrollable parent of a given element.\n *\n * @param node - The parent element to start the search from.\n *\n * @returns The closest scrollable parent or the document's root element.\n *\n * @internal\n */\nexport function getScrollables(): Array {\n return Array.from(document.querySelectorAll(\"*\")).filter(\n (el) => el instanceof HTMLElement && isScrollable(el)\n ) as Array;\n}\n\nexport function getElFromPoint(coordinates: {\n x: number;\n y: number;\n}): NodeFromPoint | ParentFromPoint | undefined {\n let target = document.elementFromPoint(coordinates.x, coordinates.y);\n\n if (!isNode(target)) return;\n\n let isParent;\n\n let invalidEl = true;\n\n while (target && invalidEl) {\n if (nodes.has(target as Node) || parents.has(target as HTMLElement)) {\n invalidEl = false;\n\n isParent = parents.has(target as HTMLElement);\n\n break;\n }\n\n target = target.parentNode as Node;\n }\n\n if (!isParent) {\n const targetNodeData = nodes.get(target as Node);\n\n if (!targetNodeData) return;\n\n const targetParentData = parents.get(target.parentNode as Node);\n\n if (!targetParentData) return;\n\n return {\n node: {\n el: target as Node,\n data: targetNodeData,\n },\n parent: {\n el: target.parentNode as Node,\n data: targetParentData as ParentData,\n },\n };\n } else {\n const parentData = parents.get(target as HTMLElement);\n\n if (!parentData) return;\n\n return {\n parent: {\n el: target as HTMLElement,\n data: parentData as ParentData,\n },\n };\n }\n}\n\n/**\n * Checks to see that a given element and its parent node are instances of\n * HTML Elements.\n *\n * @param {unknown} el - The element to check.\n *\n * @returns {boolean} - Whether or not provided element is of type Node.\n */\nexport function isNode(el: unknown): el is Node {\n return el instanceof HTMLElement && el.parentNode instanceof HTMLElement;\n}\n\n/**\n * Takes a given el and event handlers, assigns them, and returns the used abort\n * controller.\n *\n * @param el - The element to add the event listeners to.\n * @param events - The events to add to the element.\n * @returns - The abort controller used for the event listeners.\n */\nexport function addEvents(\n el: Document | ShadowRoot | Node | HTMLElement,\n events: EventHandlers | any\n): AbortController {\n const abortController = new AbortController();\n\n for (const eventName in events) {\n const handler = events[eventName];\n\n el.addEventListener(eventName, handler, {\n signal: abortController.signal,\n passive: false,\n });\n }\n\n return abortController;\n}\n\nexport function copyNodeStyle(\n sourceNode: HTMLElement,\n targetNode: HTMLElement,\n omitKeys = false\n) {\n const computedStyle = window.getComputedStyle(sourceNode);\n\n const omittedKeys = [\n \"position\",\n \"z-index\",\n \"top\",\n \"left\",\n \"x\",\n \"pointer-events\",\n \"y\",\n \"transform-origin\",\n \"filter\",\n \"-webkit-text-fill-color\",\n ];\n\n for (const key of Array.from(computedStyle)) {\n if (omitKeys === false && key && omittedKeys.includes(key)) continue;\n\n targetNode.style.setProperty(\n key,\n computedStyle.getPropertyValue(key),\n computedStyle.getPropertyPriority(key)\n );\n }\n\n for (const child of Array.from(sourceNode.children)) {\n if (!isNode(child)) continue;\n\n const targetChild = targetNode.children[\n Array.from(sourceNode.children).indexOf(child)\n ] as Node;\n\n copyNodeStyle(child, targetChild, omitKeys);\n }\n}\n\nexport function eventCoordinates(data: DragEvent | PointerEvent) {\n return { x: data.clientX, y: data.clientY };\n}\n\nexport function getRealCoords(el: HTMLElement): Coordinates {\n const { top, bottom, left, right, height, width } =\n el.getBoundingClientRect();\n\n const scrollLeft = window.scrollX || document.documentElement.scrollLeft;\n const scrollTop = window.scrollY || document.documentElement.scrollTop;\n\n const adjustedTop = top + scrollTop;\n const adjustedBottom = bottom + scrollTop;\n const adjustedLeft = left + scrollLeft;\n const adjustedRight = right + scrollLeft;\n\n return {\n top: adjustedTop,\n bottom: adjustedBottom,\n left: adjustedLeft,\n right: adjustedRight,\n height,\n width,\n };\n}\n"],"mappings":";AAIO,SAAS,WAAW,mBAA8C,CAAC,GAAG;AAC3E,QAAM,UAAU;AAAA,IACd;AAAA,MACE,WAAW,cAAc,iBAAiB,UAAU,EAAE;AAAA,IACxD;AAAA,IACA;AAAA,MACE,WAAW,cAAc,iBAAiB,UAAU,CAAC;AAAA,IACvD;AAAA,EACF;AAEA,QAAM,YAAY;AAAA,IAChB;AAAA,MACE,WAAW,eAAe,iBAAiB,UAAU,EAAE;AAAA,IACzD;AAAA,IACA;AAAA,MACE,WAAW,cAAc,iBAAiB,UAAU,CAAC;AAAA,IACvD;AAAA,EACF;AAEA,QAAM,YAAY;AAAA,IAChB;AAAA,MACE,WAAW,cAAc,iBAAiB,UAAU,EAAE;AAAA,IACxD;AAAA,IACA;AAAA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AA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,aAAW,OAAO,MAAM,KAAK,aAAa,GAAG;AAC3C,QAAI,aAAa,SAAS,OAAO,YAAY,SAAS,GAAG,EAAG;AAE5D,eAAW,MAAM;AAAA,MACf;AAAA,MACA,cAAc,iBAAiB,GAAG;AAAA,MAClC,cAAc,oBAAoB,GAAG;AAAA,IACvC;AAAA,EACF;AAEA,aAAW,SAAS,MAAM,KAAK,WAAW,QAAQ,GAAG;AACnD,QAAI,CAAC,OAAO,KAAK,EAAG;AAEpB,UAAM,cAAc,WAAW,SAC7B,MAAM,KAAK,WAAW,QAAQ,EAAE,QAAQ,KAAK,CAC/C;AAEA,kBAAc,OAAO,aAAa,QAAQ;AAAA,EAC5C;AACF;AAEO,SAAS,iBAAiB,MAAgC;AAC/D,SAAO,EAAE,GAAG,KAAK,SAAS,GAAG,KAAK,QAAQ;AAC5C;AAEO,SAAS,cAAc,IAA8B;AAC1D,QAAM,EAAE,KAAK,QAAQ,MAAM,OAAO,QAAQ,MAAM,IAC9C,GAAG,sBAAsB;AAE3B,QAAM,aAAa,OAAO,WAAW,SAAS,gBAAgB;AAC9D,QAAM,YAAY,OAAO,WAAW,SAAS,gBAAgB;AAE7D,QAAM,cAAc,MAAM;AAC1B,QAAM,iBAAiB,SAAS;AAChC,QAAM,eAAe,OAAO;AAC5B,QAAM,gBAAgB,QAAQ;AAE9B,SAAO;AAAA,IACL,KAAK;AAAA,IACL,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,OAAO;AAAA,IACP;AAAA,IACA;AAAA,EACF;AACF;","names":["handleEnd","state","handleEnd","state","draggedParentValues","handleDragoverNode","handleDragoverParent","handlePointeroverParent","state","handleEnd","handleDragoverParent","handleDragoverNode","handlePointeroverParent","emit","on","baseDragState","dragStateProps","handleNodePointerover","draggedNodes","state","nodes","parent","x","className"]} \ No newline at end of file +{"version":3,"sources":["../src/plugins/animations/index.ts","../src/plugins/insertion/index.ts","../src/plugins/place/index.ts","../src/plugins/swap/index.ts","../src/index.ts"],"sourcesContent":["import type { SetupNodeData, Node } from \"../../types\";\nimport type { AnimationsConfig } from \"./types\";\nimport { state, parents, isDragState } from \"../../index\";\n\nexport function animations(animationsConfig: Partial = {}) {\n const slideUp = [\n {\n transform: `translateY(${animationsConfig.yScale || 50}%)`,\n },\n {\n transform: `translateY(${animationsConfig.yScale || 0}%)`,\n },\n ];\n\n const slideDown = [\n {\n transform: `translateY(-${animationsConfig.yScale || 50}%)`,\n },\n {\n transform: `translateY(${animationsConfig.yScale || 0}%)`,\n },\n ];\n\n const slideLeft = [\n {\n transform: `translateX(${animationsConfig.xScale || 50}%)`,\n },\n {\n transform: `translateX(${animationsConfig.xScale || 0}%)`,\n },\n ];\n\n const slideRight = [\n {\n transform: `translateX(-${animationsConfig.xScale || 50}%)`,\n },\n {\n transform: `translateX(${animationsConfig.xScale || 0}%)`,\n },\n ];\n return (parent: HTMLElement) => {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n return {\n setup() {\n if (document.head.querySelector(\"[data-drag-and-drop]\")) return;\n },\n\n setupNodeRemap(data: SetupNodeData) {\n if (!isDragState(state)) return;\n\n const duration = animationsConfig.duration || 150;\n\n if (data.node.data.value === state.draggedNode.data.value) {\n switch (state.incomingDirection) {\n case \"below\":\n animate(data.node.el, slideUp, duration);\n\n break;\n case \"above\":\n animate(data.node.el, slideDown, duration);\n\n break;\n case \"left\":\n animate(data.node.el, slideRight, duration);\n\n break;\n case \"right\":\n animate(data.node.el, slideLeft, duration);\n\n break;\n }\n\n return;\n }\n\n if (\n !state.affectedNodes\n .map((x) => x.data.value)\n .includes(data.node.data.value)\n )\n return;\n\n const nodeRect = data.node.el.getBoundingClientRect();\n\n const nodeIndex = state.affectedNodes.findIndex(\n (x) => x.data.value === data.node.data.value\n );\n\n const draggedNodeIndex = state.draggedNode.data.index;\n\n const ascendingDirection = draggedNodeIndex >= state.targetIndex;\n\n let adjacentNode;\n\n if (ascendingDirection) {\n adjacentNode = state.affectedNodes[nodeIndex + 1]\n ? state.affectedNodes[nodeIndex + 1]\n : state.affectedNodes[nodeIndex - 1];\n } else {\n adjacentNode = state.affectedNodes[nodeIndex - 1]\n ? state.affectedNodes[nodeIndex - 1]\n : state.affectedNodes[nodeIndex + 1];\n }\n\n if (adjacentNode) {\n const xDiff = Math.abs(\n nodeRect.x - adjacentNode.el.getBoundingClientRect().x\n );\n\n const yDiff = Math.abs(\n nodeRect.y - adjacentNode.el.getBoundingClientRect().y\n );\n\n if (xDiff > yDiff && ascendingDirection) {\n animate(data.node.el, slideRight, duration);\n } else if (xDiff > yDiff && !ascendingDirection) {\n animate(data.node.el, slideLeft, duration);\n }\n } else {\n switch (state.incomingDirection) {\n case \"below\":\n animate(data.node.el, slideDown, duration);\n\n break;\n case \"above\":\n animate(data.node.el, slideUp, duration);\n\n break;\n case \"left\":\n animate(data.node.el, slideLeft, duration);\n\n break;\n case \"right\":\n animate(data.node.el, slideRight, duration);\n\n break;\n }\n }\n },\n };\n };\n}\n\nfunction animate(\n node: Node,\n animation: Keyframe[] | PropertyIndexedKeyframes,\n duration: number\n) {\n if (!state) return;\n\n state.preventEnter = true;\n\n node.animate(animation, {\n duration: duration,\n easing: \"ease-in-out\",\n });\n\n setTimeout(() => {\n if (!state) return;\n\n state.preventEnter = false;\n }, duration);\n}\n","import type { InsertionConfig, InsertionParentConfig } from \"./types\";\nimport type {\n DragState,\n NodeDragEventData,\n NodeRecord,\n ParentEventData,\n NodePointerEventData,\n PointeroverParentEvent,\n ParentRecord,\n Coordinates,\n} from \"../../types\";\n\nimport {\n handleEnd as originalHandleEnd,\n parents,\n parentValues,\n setParentValues,\n state,\n addParentClass,\n isDragState,\n eventCoordinates,\n removeClass,\n getRealCoords,\n} from \"../../index\";\n\nexport const insertionState = {\n draggedOverNodes: Array>(),\n draggedOverParent: null as ParentRecord | null,\n targetIndex: 0,\n ascending: false,\n};\n\n// WIP: This is a work in progress and not yet fully functional\nexport function insertion(\n insertionConfig: Partial> = {}\n) {\n return (parent: HTMLElement) => {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n const insertionParentConfig = {\n ...parentData.config,\n insertionConfig: insertionConfig,\n } as InsertionParentConfig;\n\n return {\n teardown() {\n if (parentData.abortControllers.root) {\n parentData.abortControllers.root.abort();\n }\n },\n setup() {\n insertionParentConfig.handleDragoverNode =\n insertionConfig.handleDragoverNode || handleDragoverNode;\n\n insertionParentConfig.handlePointeroverParent =\n insertionConfig.handlePointeroverParent || handlePointeroverParent;\n\n insertionParentConfig.handlePointeroverNode =\n insertionConfig.handlePointeroverNode || handlePointeroverParent;\n\n insertionParentConfig.handleDragoverParent =\n insertionConfig.handleDragoverParent || handleDragoverParent;\n\n insertionParentConfig.handleEnd =\n insertionConfig.handleEnd || handleEnd;\n\n document.body.addEventListener(\"dragover\", checkPosition);\n\n document.body.addEventListener(\"pointermove\", checkPosition);\n\n const observer = new ResizeObserver(() => {\n defineRanges(parent);\n });\n\n observer.observe(parent);\n\n parentData.config = insertionParentConfig;\n\n state.on(\"dragStarted\", () => {\n defineRanges(parent);\n });\n\n const insertionPointConfig = insertionConfig.insertionPoint || {};\n\n const div = document.createElement(insertionPointConfig.tag || \"div\");\n\n div.id = insertionPointConfig.id || \"insertion-point\";\n\n div.classList.add(\n ...(insertionPointConfig.classes || [\"insertion-point\"])\n );\n\n div.style.position = \"absolute\";\n\n div.style.display = \"none\";\n\n document.body.appendChild(div);\n\n window.addEventListener(\"scroll\", defineRanges.bind(null, parent));\n\n window.addEventListener(\"resize\", defineRanges.bind(null, parent));\n },\n\n remapFinished() {\n defineRanges(parent);\n },\n };\n };\n}\n\nfunction checkPosition(e: DragEvent | PointerEvent) {\n if (!isDragState(state)) return;\n\n const el = document.elementFromPoint(e.clientX, e.clientY);\n\n if (!(el instanceof HTMLElement)) return;\n\n if (!parents.has(el)) {\n const insertionPoint = document.getElementById(\"insertion-point\");\n\n if (insertionPoint && insertionPoint === el) return;\n\n if (insertionPoint) insertionPoint.style.display = \"none\";\n\n if (insertionState.draggedOverParent) {\n removeClass(\n [insertionState.draggedOverParent.el],\n insertionState.draggedOverParent.data.config.dropZoneClass\n );\n }\n\n insertionState.draggedOverNodes = [];\n\n insertionState.draggedOverParent = null;\n\n state.currentParent = state.initialParent;\n }\n}\n\nfunction ascendingVertical(\n nodeCoords: Coordinates,\n nextNodeCoords?: Coordinates\n) {\n const center = nodeCoords.top + nodeCoords.height / 2;\n\n if (!nextNodeCoords) {\n return {\n y: [center, center + nodeCoords.height / 2 + 10],\n x: [nodeCoords.left, nodeCoords.right],\n vertical: true,\n };\n }\n\n return {\n y: [\n center,\n nodeCoords.bottom + Math.abs(nodeCoords.bottom - nextNodeCoords.top) / 2,\n ],\n x: [nodeCoords.left, nodeCoords.right],\n vertical: true,\n };\n}\n\nfunction descendingVertical(\n nodeCoords: Coordinates,\n prevNodeCoords?: Coordinates\n) {\n const center = nodeCoords.top + nodeCoords.height / 2;\n\n if (!prevNodeCoords) {\n return {\n y: [center - nodeCoords.height / 2 - 10, center],\n x: [nodeCoords.left, nodeCoords.right],\n vertical: true,\n };\n }\n\n return {\n y: [\n prevNodeCoords.bottom +\n Math.abs(prevNodeCoords.bottom - nodeCoords.top) / 2,\n center,\n ],\n x: [nodeCoords.left, nodeCoords.right],\n vertical: true,\n };\n}\n\nfunction ascendingHorizontal(\n nodeCoords: Coordinates,\n nextNodeCoords?: Coordinates,\n lastInRow = false\n) {\n const center = nodeCoords.left + nodeCoords.width / 2;\n\n if (!nextNodeCoords) {\n return {\n x: [center, center + nodeCoords.width],\n y: [nodeCoords.top, nodeCoords.bottom],\n vertical: false,\n };\n }\n\n if (lastInRow) {\n return {\n x: [center, nodeCoords.right + 10],\n y: [nodeCoords.top, nodeCoords.bottom],\n vertical: false,\n };\n } else {\n const nextNodeCenter = nextNodeCoords.left + nextNodeCoords.width / 2;\n\n return {\n x: [center, center + Math.abs(center - nextNodeCenter) / 2],\n y: [nodeCoords.top, nodeCoords.bottom],\n vertical: false,\n };\n }\n}\n\nfunction descendingHorizontal(\n nodeCoords: Coordinates,\n prevNodeCoords?: Coordinates\n) {\n const center = nodeCoords.left + nodeCoords.width / 2;\n\n if (!prevNodeCoords) {\n return {\n x: [nodeCoords.left - 10, center],\n y: [nodeCoords.top, nodeCoords.bottom],\n vertical: false,\n };\n }\n\n return {\n x: [\n prevNodeCoords.right +\n Math.abs(prevNodeCoords.right - nodeCoords.left) / 2,\n center,\n ],\n y: [nodeCoords.top, nodeCoords.bottom],\n vertical: false,\n };\n}\n\nfunction defineRanges(parent: HTMLElement) {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n const enabledNodes = parentData.enabledNodes;\n\n enabledNodes.forEach((node, index) => {\n let aboveOrBelowPrevious = false;\n\n let aboveOrBelowAfter = false;\n\n let prevNodeCoords = undefined;\n\n let nextNodeCoords = undefined;\n\n if (enabledNodes[index - 1])\n prevNodeCoords = getRealCoords(enabledNodes[index - 1].el);\n\n if (enabledNodes[index + 1])\n nextNodeCoords = getRealCoords(enabledNodes[index + 1].el);\n\n const nodeCoords = getRealCoords(node.el);\n\n if (prevNodeCoords) {\n aboveOrBelowPrevious =\n nodeCoords.top > prevNodeCoords.bottom ||\n nodeCoords.bottom < prevNodeCoords.top;\n }\n\n if (nextNodeCoords) {\n aboveOrBelowAfter =\n nodeCoords.top > nextNodeCoords.bottom ||\n nodeCoords.bottom < nextNodeCoords.top;\n }\n\n const fullishWidth =\n parent.getBoundingClientRect().width * 0.8 < nodeCoords.width;\n\n if (!node.data.range) return;\n\n if (fullishWidth) {\n node.data.range.ascending = ascendingVertical(nodeCoords, nextNodeCoords);\n node.data.range.descending = descendingVertical(\n nodeCoords,\n prevNodeCoords\n );\n } else if (aboveOrBelowAfter && !aboveOrBelowPrevious) {\n node.data.range.ascending = ascendingHorizontal(\n nodeCoords,\n nextNodeCoords,\n true\n );\n node.data.range.descending = descendingHorizontal(\n nodeCoords,\n prevNodeCoords\n );\n } else if (!aboveOrBelowPrevious && !aboveOrBelowAfter) {\n node.data.range.ascending = ascendingHorizontal(\n nodeCoords,\n nextNodeCoords\n );\n node.data.range.descending = descendingHorizontal(\n nodeCoords,\n prevNodeCoords\n );\n } else if (aboveOrBelowPrevious && !nextNodeCoords) {\n node.data.range.ascending = ascendingHorizontal(nodeCoords);\n } else if (aboveOrBelowPrevious && !aboveOrBelowAfter) {\n node.data.range.ascending = ascendingHorizontal(\n nodeCoords,\n nextNodeCoords\n );\n\n node.data.range.descending = descendingHorizontal(nodeCoords);\n }\n });\n}\n\nexport function handleDragoverNode(data: NodeDragEventData) {\n data.e.preventDefault();\n}\n\nexport function handleDragoverParent(\n data: ParentEventData,\n state: DragState\n) {\n if (!insertionState) return;\n\n data.e.stopPropagation();\n\n data.e.preventDefault();\n\n const { x, y } = eventCoordinates(data.e as DragEvent | PointerEvent);\n\n // Get the client coordinates\n const clientX = x;\n const clientY = y;\n\n // Get the scroll positions\n const scrollLeft = window.scrollX || document.documentElement.scrollLeft;\n const scrollTop = window.scrollY || document.documentElement.scrollTop;\n\n // Calculate the coordinates relative to the entire document\n state.coordinates.x = clientX + scrollLeft;\n state.coordinates.y = clientY + scrollTop;\n\n const nestedParent = data.targetData.parent.data.nestedParent;\n\n let realTargetParent = data.targetData.parent;\n\n if (nestedParent) {\n const rect = nestedParent.el.getBoundingClientRect();\n\n if (state.coordinates.y > rect.top && state.coordinates.y < rect.bottom)\n realTargetParent = nestedParent;\n }\n\n realTargetParent.el === state.currentParent?.el\n ? moveBetween(realTargetParent)\n : moveOutside(realTargetParent, state);\n\n state.currentParent = realTargetParent;\n}\n\nexport function moveBetween(data: ParentRecord) {\n if (data.data.config.sortable === false) return;\n\n if (\n data.el === insertionState.draggedOverParent?.el &&\n insertionState.draggedOverParent.data.getValues(data.el).length === 0\n ) {\n return;\n } else if (insertionState.draggedOverParent?.el) {\n removeClass(\n [insertionState.draggedOverParent.el],\n insertionState.draggedOverParent.data.config.dropZoneClass\n );\n insertionState.draggedOverParent = null;\n }\n\n const foundRange = findClosest(data.data.enabledNodes);\n\n if (!foundRange) return;\n\n const position =\n foundRange[0].data.range![foundRange[1] as \"ascending\" | \"descending\"];\n\n if (!position) return;\n\n positionInsertionPoint(\n position,\n foundRange[1] === \"ascending\",\n foundRange[0]\n );\n}\n\nfunction moveOutside(data: ParentRecord, state: DragState) {\n if (data.el === state.currentParent.el) return false;\n\n const targetConfig = data.data.config;\n\n if (targetConfig.treeGroup && state.draggedNode.el.contains(data.el))\n return false;\n\n if (targetConfig.dropZone === false) return false;\n\n const initialParentConfig = state.initialParent.data.config;\n\n if (targetConfig.accepts) {\n return targetConfig.accepts(\n data,\n state.initialParent,\n state.currentParent,\n state\n );\n } else if (\n !targetConfig.group ||\n targetConfig.group !== initialParentConfig.group\n ) {\n return false;\n }\n\n const values = data.data.getValues(data.el);\n\n if (!values.length) {\n addParentClass([data.el], targetConfig.dropZoneClass);\n\n insertionState.draggedOverParent = data;\n\n const insertionPoint = document.getElementById(\"insertion-point\");\n\n if (insertionPoint) insertionPoint.style.display = \"none\";\n } else {\n removeClass([state.currentParent.el], targetConfig.dropZoneClass);\n\n const enabledNodes = data.data.enabledNodes;\n\n const foundRange = findClosest(enabledNodes);\n\n if (!foundRange) return;\n\n const position =\n foundRange[0].data.range![foundRange[1] as \"ascending\" | \"descending\"];\n\n if (!position) return;\n\n positionInsertionPoint(\n position,\n foundRange[1] === \"ascending\",\n foundRange[0]\n );\n }\n}\n\nfunction findClosest(enabledNodes: NodeRecord[]) {\n let foundRange: [NodeRecord, string] | null = null;\n\n for (let x = 0; x < enabledNodes.length; x++) {\n if (!isDragState(state) || !enabledNodes[x].data.range) continue;\n\n const ascending = enabledNodes[x].data.range!.ascending;\n\n const descending = enabledNodes[x].data.range!.descending;\n\n if (!ascending && !descending) continue;\n\n if (ascending) {\n if (\n state.coordinates.y > ascending.y[0] &&\n state.coordinates.y < ascending.y[1] &&\n state.coordinates.x > ascending.x[0] &&\n state.coordinates.x < ascending.x[1]\n ) {\n foundRange = [enabledNodes[x], \"ascending\"];\n\n return foundRange;\n }\n }\n\n if (descending) {\n if (\n state.coordinates.y > descending.y[0] &&\n state.coordinates.y < descending.y[1] &&\n state.coordinates.x > descending.x[0] &&\n state.coordinates.x < descending.x[1]\n ) {\n foundRange = [enabledNodes[x], \"descending\"];\n\n return foundRange;\n }\n }\n }\n}\n\nexport function handlePointeroverParent(\n data: PointeroverParentEvent,\n state: DragState\n) {\n if (!insertionState) return;\n\n data.detail.e.stopPropagation();\n\n const { x, y } = eventCoordinates(data.detail.e as PointerEvent);\n\n state.coordinates.y = y;\n\n state.coordinates.x = x;\n\n const nestedParent = data.detail.targetData.parent.data.nestedParent;\n\n let realTargetParent = data.detail.targetData.parent;\n\n if (nestedParent) {\n const rect = nestedParent.el.getBoundingClientRect();\n\n if (state.coordinates.y > rect.top && state.coordinates.y < rect.bottom)\n realTargetParent = nestedParent;\n }\n\n const enabledNodes = realTargetParent.data.enabledNodes;\n\n const foundRange = findClosest(enabledNodes);\n\n if (!foundRange) return;\n\n const position =\n foundRange[0].data.range![foundRange[1] as \"ascending\" | \"descending\"];\n\n positionInsertionPoint(\n position,\n foundRange[1] === \"ascending\",\n foundRange[0]\n );\n\n data.detail.targetData.parent.el === state.currentParent?.el\n ? moveBetween(realTargetParent)\n : moveOutside(realTargetParent, state);\n}\n\nfunction positionInsertionPoint(\n position: { x: number[]; y: number[]; vertical: boolean },\n ascending: boolean,\n node: NodeRecord\n) {\n if (!state) return;\n\n const div = document.getElementById(\"insertion-point\");\n\n if (!div) return;\n\n insertionState.draggedOverNodes = [node];\n\n if (position.vertical) {\n const topPosition =\n position.y[ascending ? 1 : 0] - div.getBoundingClientRect().height / 2;\n\n div.style.top = `${topPosition}px`;\n\n const leftCoordinate = position.x[0];\n\n const rightCoordinate = position.x[1];\n\n div.style.left = `${leftCoordinate}px`;\n\n div.style.right = `${rightCoordinate}px`;\n\n div.style.height = \"4px\";\n\n div.style.width = rightCoordinate - leftCoordinate + \"px\";\n } else {\n const leftPosition =\n position.x[ascending ? 1 : 0] - div.getBoundingClientRect().width / 2;\n div.style.left = `${leftPosition}px`;\n\n const topCoordinate = position.y[0];\n\n const bottomCoordinate = position.y[1];\n\n div.style.top = `${topCoordinate}px`;\n\n div.style.bottom = `${bottomCoordinate}px`;\n\n div.style.width = \"4px\";\n\n div.style.height = bottomCoordinate - topCoordinate + \"px\";\n }\n\n insertionState.targetIndex = node.data.index;\n\n insertionState.ascending = ascending;\n\n div.style.display = \"block\";\n}\n\nexport function handleParentDrop(_data: NodeDragEventData) {}\n\nexport function handleEnd(\n data: NodeDragEventData | NodePointerEventData,\n state: DragState\n) {\n data.e.stopPropagation();\n\n const insertionPoint = document.getElementById(\"insertion-point\");\n\n if (!insertionState.draggedOverParent) {\n const draggedParentValues = parentValues(\n state.initialParent.el,\n state.initialParent.data\n );\n\n const transferred = state.initialParent.el !== state.currentParent.el;\n\n const draggedValues = state.draggedNodes.map((node) => node.data.value);\n\n const enabledNodes = [...data.targetData.parent.data.enabledNodes];\n\n const originalIndex = state.draggedNodes[0].data.index;\n\n if (\n !transferred &&\n insertionState.draggedOverNodes[0] &&\n insertionState.draggedOverNodes[0].el !== state.draggedNodes[0].el\n ) {\n const newParentValues = [\n ...draggedParentValues.filter((x) => !draggedValues.includes(x)),\n ];\n\n let index = insertionState.draggedOverNodes[0].data.index;\n\n if (\n insertionState.targetIndex > state.draggedNodes[0].data.index &&\n !insertionState.ascending\n ) {\n index--;\n } else if (\n insertionState.targetIndex < state.draggedNodes[0].data.index &&\n insertionState.ascending\n ) {\n index++;\n }\n\n newParentValues.splice(index, 0, ...draggedValues);\n\n setParentValues(data.targetData.parent.el, data.targetData.parent.data, [\n ...newParentValues,\n ]);\n\n if (data.targetData.parent.data.config.onSort) {\n const sortEventData = {\n parent: {\n el: data.targetData.parent.el,\n data: data.targetData.parent.data,\n },\n previousValues: [...draggedParentValues],\n previousNodes: [...enabledNodes],\n nodes: [...data.targetData.parent.data.enabledNodes],\n values: [...newParentValues],\n draggedNode: state.draggedNode,\n previousPosition: originalIndex,\n position: index,\n };\n\n data.targetData.parent.data.config.onSort(sortEventData);\n }\n } else if (transferred && insertionState.draggedOverNodes.length) {\n const targetParentValues = parentValues(\n state.currentParent.el,\n state.currentParent.data\n );\n const draggedParentValues = parentValues(\n state.initialParent.el,\n state.initialParent.data\n );\n\n // For the time being, we will not be remoing the value of the original dragged parent.\n let index = insertionState.draggedOverNodes[0].data.index || 0;\n\n if (insertionState.ascending) index++;\n\n const insertValues = state.dynamicValues.length\n ? state.dynamicValues\n : draggedValues;\n targetParentValues.splice(index, 0, ...insertValues);\n setParentValues(state.currentParent.el, state.currentParent.data, [\n ...targetParentValues,\n ]);\n draggedParentValues.splice(state.initialIndex, draggedValues.length);\n setParentValues(state.initialParent.el, state.initialParent.data, [\n ...draggedParentValues,\n ]);\n\n const transferEventData = {\n sourceParent: state.currentParent,\n targetParent: data.targetData.parent,\n initialParent: state.initialParent,\n draggedNodes: state.draggedNodes,\n targetIndex: index,\n state,\n };\n if (data.targetData.parent.data.config.onTransfer)\n data.targetData.parent.data.config.onTransfer(transferEventData);\n if (state.currentParent.data.config.onTransfer)\n state.currentParent.data.config.onTransfer(transferEventData);\n }\n } else if (insertionState.draggedOverParent) {\n const draggedOverParentValues = parentValues(\n insertionState.draggedOverParent.el,\n insertionState.draggedOverParent.data\n );\n\n const draggedValues = state.draggedNodes.map((node) => node.data.value);\n\n const insertValues = state.dynamicValues.length\n ? state.dynamicValues\n : draggedValues;\n\n draggedOverParentValues.push(...insertValues);\n\n setParentValues(\n insertionState.draggedOverParent.el,\n insertionState.draggedOverParent.data,\n [...draggedOverParentValues]\n );\n\n const transferEventData = {\n sourceParent: state.currentParent,\n targetParent: insertionState.draggedOverParent,\n initialParent: state.initialParent,\n draggedNodes: state.draggedNodes,\n targetIndex: draggedOverParentValues.length - 1,\n state,\n };\n if (data.targetData.parent.data.config.onTransfer)\n data.targetData.parent.data.config.onTransfer(transferEventData);\n if (state.currentParent.data.config.onTransfer)\n state.currentParent.data.config.onTransfer(transferEventData);\n\n removeClass(\n [insertionState.draggedOverParent.el],\n insertionState.draggedOverParent.data.config.dropZoneClass\n );\n }\n\n if (insertionPoint) insertionPoint.style.display = \"none\";\n\n const dropZoneClass =\n \"clonedDraggedNode\" in state\n ? data.targetData.parent.data.config.synthDropZoneClass\n : data.targetData.parent.data.config.dropZoneClass;\n\n removeClass(\n insertionState.draggedOverNodes.map((node) => node.el),\n dropZoneClass\n );\n\n const dragPlaceholderClass =\n data.targetData.parent.data.config.dragPlaceholderClass;\n\n removeClass(\n state.draggedNodes.map((node) => node.el),\n dragPlaceholderClass\n );\n\n insertionState.draggedOverNodes = [];\n\n originalHandleEnd(data, state);\n}\n","import type {\n NodeDragEventData,\n ParentConfig,\n DragState,\n SynthDragState,\n NodeRecord,\n PointeroverNodeEvent,\n ParentDragEventData,\n PointeroverParentEvent,\n} from \"../../types\";\nimport {\n parents,\n parentValues,\n setParentValues,\n addNodeClass,\n isSynthDragState,\n removeClass,\n addClass,\n state,\n isDragState,\n} from \"../../index\";\n\nexport const placeState = {\n draggedOverNodes: Array>(),\n};\n\nlet dragoverEventListeneerSet = false;\n\ninterface PlaceConfig extends ParentConfig {}\n\nexport function place(placeConfig: Partial> = {}) {\n return (parent: HTMLElement) => {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n const placeParentConfig = {\n ...parentData.config,\n placeConfig: placeConfig,\n } as PlaceConfig;\n\n if (!dragoverEventListeneerSet) {\n document.addEventListener(\"dragover\", rootDragover);\n document.addEventListener(\n \"handleRootPointerover\" as keyof DocumentEventMap,\n (e) => rootPointerover(e as CustomEvent)\n );\n }\n\n return {\n setup() {\n placeParentConfig.handleNodeDragover =\n placeConfig.handleNodeDragover || handleDragoverNode;\n\n placeParentConfig.handleParentDragover =\n placeConfig.handleParentDragover || handleDragoverParent;\n\n placeParentConfig.handleNodePointerover =\n placeConfig.handleNodePointerover || handleNodePointerover;\n\n placeParentConfig.handleParentPointerover =\n placeConfig.handleParentPointerover || handlePointeroverParent;\n\n const originalHandleend = placeParentConfig.handleEnd;\n placeParentConfig.handleEnd = (state) => {\n handleEnd(state);\n\n originalHandleend(state);\n };\n\n parentData.config = placeParentConfig;\n },\n };\n };\n}\n\nfunction rootDragover(_e: DragEvent) {\n if (!isDragState(state)) return;\n\n removeClass(\n [state.currentParent.el],\n state.currentParent.data.config.dropZoneParentClass\n );\n}\n\nfunction rootPointerover(_e: CustomEvent) {\n if (!isSynthDragState(state)) return;\n\n removeClass(\n [state.currentParent.el],\n state.currentParent.data.config.synthDropZoneParentClass\n );\n}\n\nfunction updateDraggedOverNodes(\n data: PointeroverNodeEvent | NodeDragEventData,\n state: DragState | SynthDragState\n) {\n const targetData =\n \"detail\" in data ? data.detail.targetData : data.targetData;\n\n const config = targetData.parent.data.config;\n\n const dropZoneClass = isSynthDragState(state)\n ? config.synthDropZoneClass\n : config.dropZoneClass;\n\n removeClass(\n placeState.draggedOverNodes.map((node) => node.el),\n dropZoneClass\n );\n\n const enabledNodes = targetData.parent.data.enabledNodes;\n\n if (!enabledNodes) return;\n\n placeState.draggedOverNodes = enabledNodes.slice(\n targetData.node.data.index,\n targetData.node.data.index + state.draggedNodes.length\n );\n\n addNodeClass(\n placeState.draggedOverNodes.map((node) => node.el),\n dropZoneClass,\n true\n );\n\n state.currentTargetValue = targetData.node.data.value;\n\n state.currentParent = targetData.parent;\n\n addClass(\n state.currentParent.el,\n isSynthDragState(state)\n ? config.synthDropZoneParentClass\n : config.dropZoneParentClass,\n state.currentParent.data,\n true\n );\n}\n\nfunction handleDragoverNode(\n data: NodeDragEventData,\n state: DragState\n) {\n data.e.preventDefault();\n\n data.e.stopPropagation();\n\n updateDraggedOverNodes(data, state);\n}\n\nexport function handleDragoverParent(\n data: ParentDragEventData,\n state: DragState\n) {\n data.e.preventDefault();\n\n data.e.stopPropagation();\n\n const currentConfig = state.currentParent.data.config;\n\n removeClass(\n placeState.draggedOverNodes.map((node) => node.el),\n currentConfig.dropZoneClass\n );\n\n removeClass([state.currentParent.el], currentConfig.dropZoneParentClass);\n\n const config = data.targetData.parent.data.config;\n\n addClass(\n data.targetData.parent.el,\n config.dropZoneParentClass,\n data.targetData.parent.data,\n true\n );\n\n placeState.draggedOverNodes = [];\n\n state.currentParent = data.targetData.parent;\n}\n\nexport function handlePointeroverParent(data: PointeroverParentEvent) {\n const currentConfig = data.detail.state.currentParent.data.config;\n\n removeClass(\n placeState.draggedOverNodes.map((node) => node.el),\n currentConfig.synthDropZoneClass\n );\n\n removeClass(\n [data.detail.state.currentParent.el],\n currentConfig.synthDropZoneParentClass\n );\n\n const config = data.detail.targetData.parent.data.config;\n\n addClass(\n data.detail.targetData.parent.el,\n config.synthDropZoneParentClass,\n data.detail.targetData.parent.data,\n true\n );\n\n placeState.draggedOverNodes = [];\n}\n\nfunction handleNodePointerover(data: PointeroverNodeEvent) {\n if (!isSynthDragState(data.detail.state)) return;\n\n updateDraggedOverNodes(data, data.detail.state);\n}\n\nfunction handleEnd(state: DragState | SynthDragState) {\n const isSynth = isSynthDragState(state);\n\n removeClass(\n [state.currentParent.el],\n isSynth\n ? state.currentParent.data.config.synthDropZoneParentClass\n : state.currentParent.data.config.dropZoneParentClass\n );\n\n const values = parentValues(state.currentParent.el, state.currentParent.data);\n\n const draggedValues = state.draggedNodes.map((node) => node.data.value);\n\n const newValues = values.filter((x) => !draggedValues.includes(x));\n\n const index = placeState.draggedOverNodes[0]?.data.index;\n\n // If we do not have dragged over nodes, then we know that we are appending\n // items to the end of the list/\n index !== undefined\n ? newValues.splice(index, 0, ...draggedValues)\n : newValues.push(...draggedValues);\n\n if (state.initialParent.el !== state.currentParent.el) {\n const initialParentValues = parentValues(\n state.initialParent.el,\n state.initialParent.data\n );\n\n const newInitialValues = initialParentValues.filter(\n (x) => !draggedValues.includes(x)\n );\n setParentValues(\n state.initialParent.el,\n state.initialParent.data,\n newInitialValues\n );\n\n setParentValues(\n state.currentParent.el,\n state.currentParent.data,\n newValues\n );\n } else if (\n state.initialParent.el === state.currentParent.el &&\n placeState.draggedOverNodes.length\n ) {\n setParentValues(\n state.currentParent.el,\n state.currentParent.data,\n newValues\n );\n }\n\n removeClass(\n placeState.draggedOverNodes.map((node) => node.el),\n isSynth\n ? state.currentParent.data.config.synthDropZoneClass\n : state.currentParent.data.config.dropZoneClass\n );\n\n placeState.draggedOverNodes = [];\n}\n","import type {\n NodeDragEventData,\n ParentConfig,\n DragState,\n SynthDragState,\n NodeRecord,\n PointeroverNodeEvent,\n ParentDragEventData,\n PointeroverParentEvent,\n} from \"../../types\";\nimport {\n parents,\n parentValues,\n setParentValues,\n addNodeClass,\n isSynthDragState,\n removeClass,\n addClass,\n state,\n isDragState,\n} from \"../../index\";\n\nexport const placeState = {\n draggedOverNodes: Array>(),\n initialDraggedIndex: 0,\n transferred: false,\n};\n\nlet dragoverEventListeneerSet = false;\n\ninterface SwapConfig extends ParentConfig {}\n\nexport function swap(swapConfig: Partial> = {}) {\n return (parent: HTMLElement) => {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n const swapParentConfig = {\n ...parentData.config,\n swapConfig: swapConfig,\n } as SwapConfig;\n\n if (!dragoverEventListeneerSet) {\n document.addEventListener(\"dragover\", rootDragover);\n document.addEventListener(\n \"handleRootPointerover\" as keyof DocumentEventMap,\n (e) => rootPointerover(e as CustomEvent)\n );\n }\n\n return {\n setup() {\n swapParentConfig.handleNodeDragover =\n swapConfig.handleNodeDragover || handleDragoverNode;\n\n swapParentConfig.handleParentDragover =\n swapConfig.handleParentDragover || handleDragoverParent;\n\n swapParentConfig.handleNodePointerover =\n swapConfig.handleNodePointerover || handleNodePointerover;\n\n swapParentConfig.handleParentPointerover =\n swapConfig.handleParentPointerover || handeParentPointerover;\n\n const originalHandleend = swapParentConfig.handleEnd;\n swapParentConfig.handleEnd = (state) => {\n handleEnd(state);\n\n originalHandleend(state);\n };\n\n parentData.config = swapParentConfig;\n },\n };\n };\n}\n\nfunction rootDragover(_e: DragEvent) {\n if (!isDragState(state)) return;\n\n removeClass(\n [state.currentParent.el],\n state.currentParent.data.config.dropZoneParentClass\n );\n\n state.currentParent = state.initialParent;\n}\n\nfunction rootPointerover(_e: CustomEvent) {\n if (!isSynthDragState(state)) return;\n\n removeClass(\n [state.currentParent.el],\n state.currentParent.data.config.synthDropZoneParentClass\n );\n\n state.currentParent = state.initialParent;\n}\n\nfunction updateDraggedOverNodes(\n data: PointeroverNodeEvent | NodeDragEventData,\n state: DragState | SynthDragState\n) {\n const targetData =\n \"detail\" in data ? data.detail.targetData : data.targetData;\n\n const config = targetData.parent.data.config;\n\n const dropZoneClass = isSynthDragState(state)\n ? config.synthDropZoneClass\n : config.dropZoneClass;\n\n removeClass(\n placeState.draggedOverNodes.map((node) => node.el),\n dropZoneClass\n );\n\n const enabledNodes = targetData.parent.data.enabledNodes;\n\n if (!enabledNodes) return;\n\n placeState.draggedOverNodes = enabledNodes.slice(\n targetData.node.data.index,\n targetData.node.data.index + state.draggedNodes.length\n );\n\n addNodeClass(\n placeState.draggedOverNodes.map((node) => node.el),\n dropZoneClass,\n true\n );\n\n state.currentTargetValue = targetData.node.data.value;\n\n state.currentParent = targetData.parent;\n\n addClass(\n state.currentParent.el,\n isSynthDragState(state)\n ? config.synthDropZoneParentClass\n : config.dropZoneParentClass,\n state.currentParent.data,\n true\n );\n}\n\nfunction handleDragoverNode(\n data: NodeDragEventData,\n state: DragState\n) {\n data.e.preventDefault();\n\n data.e.stopPropagation();\n\n updateDraggedOverNodes(data, state);\n}\n\nexport function handleDragoverParent(\n data: ParentDragEventData,\n state: DragState\n) {\n data.e.preventDefault();\n\n data.e.stopPropagation();\n\n const currentConfig = state.currentParent.data.config;\n\n removeClass(\n placeState.draggedOverNodes.map((node) => node.el),\n currentConfig.dropZoneClass\n );\n\n removeClass([state.currentParent.el], currentConfig.dropZoneParentClass);\n\n const config = data.targetData.parent.data.config;\n\n addClass(\n data.targetData.parent.el,\n config.dropZoneParentClass,\n data.targetData.parent.data,\n true\n );\n\n placeState.draggedOverNodes = [];\n\n state.currentParent = data.targetData.parent;\n}\n\nexport function handeParentPointerover(data: PointeroverParentEvent) {\n const currentConfig = data.detail.state.currentParent.data.config;\n\n removeClass(\n placeState.draggedOverNodes.map((node) => node.el),\n currentConfig.synthDropZoneClass\n );\n\n removeClass(\n [data.detail.state.currentParent.el],\n currentConfig.synthDropZoneParentClass\n );\n\n const config = data.detail.targetData.parent.data.config;\n\n addClass(\n data.detail.targetData.parent.el,\n config.synthDropZoneParentClass,\n data.detail.targetData.parent.data,\n true\n );\n\n placeState.draggedOverNodes = [];\n\n data.detail.state.currentParent = data.detail.targetData.parent;\n}\n\nfunction handleNodePointerover(data: PointeroverNodeEvent) {\n if (!isSynthDragState(data.detail.state)) return;\n\n updateDraggedOverNodes(data, data.detail.state);\n}\n\nfunction handleEnd(state: DragState | SynthDragState) {\n const isSynth = isSynthDragState(state);\n removeClass(\n [state.currentParent.el],\n isSynth\n ? state.currentParent.data.config.synthDropZoneParentClass\n : state.currentParent.data.config.dropZoneParentClass\n );\n\n const values = parentValues(state.currentParent.el, state.currentParent.data);\n\n const draggedValues = state.draggedNodes.map((node) => node.data.value);\n\n const newValues = values.filter((x) => !draggedValues.includes(x));\n\n const targetIndex = placeState.draggedOverNodes[0]?.data.index;\n\n let newTargetParentValues: Array = [];\n\n if (state.initialParent.el == state.currentParent.el) {\n if (targetIndex !== undefined) {\n newValues.splice(targetIndex, 0, ...draggedValues);\n\n setParentValues(\n state.currentParent.el,\n state.currentParent.data,\n newValues\n );\n }\n } else if (state.initialParent.el !== state.currentParent.el) {\n const initialParentValues = parentValues(\n state.initialParent.el,\n state.initialParent.data\n );\n\n if (targetIndex === undefined) {\n newTargetParentValues = newValues.concat(draggedValues);\n\n setParentValues(\n state.currentParent.el,\n state.currentParent.data,\n newTargetParentValues\n );\n\n setParentValues(\n state.initialParent.el,\n state.initialParent.data,\n initialParentValues.filter((x) => !draggedValues.includes(x))\n );\n } else {\n const targetedNodeValues = state.currentParent.data.enabledNodes\n .slice(targetIndex, targetIndex + draggedValues.length)\n .map((node) => node.data.value);\n\n const newInitialParentValues = initialParentValues.filter(\n (x) => !draggedValues.includes(x)\n );\n\n newInitialParentValues.splice(\n state.initialIndex,\n 0,\n ...targetedNodeValues\n );\n\n setParentValues(\n state.initialParent.el,\n state.initialParent.data,\n newInitialParentValues\n );\n\n const newTargetParentValues = newValues.filter(\n (x) => !targetedNodeValues.includes(x)\n );\n\n newTargetParentValues.splice(targetIndex, 0, ...draggedValues);\n\n setParentValues(\n state.currentParent.el,\n state.currentParent.data,\n newTargetParentValues\n );\n }\n }\n\n removeClass(\n placeState.draggedOverNodes.map((node) => node.el),\n isSynth\n ? state.currentParent.data.config.synthDropZoneClass\n : state.currentParent.data.config.dropZoneClass\n );\n}\n","import type {\n DNDPlugin,\n DragAndDrop,\n DragState,\n DragStateProps,\n Node,\n NodeData,\n NodeDragEventData,\n NodeEventData,\n NodePointerEventData,\n NodeRecord,\n NodeTargetData,\n NodesData,\n ParentConfig,\n ParentData,\n ParentEventData,\n ParentTargetData,\n ParentsData,\n PointeroverNodeEvent,\n PointeroverParentEvent,\n ScrollData,\n SetupNodeData,\n TearDownNodeData,\n BaseDragState,\n SynthDragState,\n ParentKeydownEventData,\n SynthDragStateProps,\n ParentRecord,\n EventHandlers,\n NodeFromPoint,\n ParentFromPoint,\n Coordinates,\n} from \"./types\";\n\nexport * from \"./types\";\nexport { animations } from \"./plugins/animations\";\nexport { insertion } from \"./plugins/insertion\";\nexport { place } from \"./plugins/place\";\nexport { swap } from \"./plugins/swap\";\n\n/**\n * Check to see if code is running in a browser.\n *\n * @internal\n */\nexport const isBrowser = typeof window !== \"undefined\";\n\nexport const touchDevice = window && \"ontouchstart\" in window;\n\nlet dropped = false;\n\n/**\n * Abort controller for the document.\n */\nlet documentController: AbortController | undefined;\n\nlet isNative = false;\n\nlet animationFrameId: number | null = null;\n\nconst scrollConfig: {\n [key: string]: [number, number];\n} = {\n up: [0, -1],\n down: [0, 1],\n left: [-1, 0],\n right: [1, 0],\n};\n\nexport const nodes: NodesData = new WeakMap>();\n\nexport const parents: ParentsData = new WeakMap<\n HTMLElement,\n ParentData\n>();\n\nexport const treeAncestors: Record = {};\n\nlet synthNodePointerDown = false;\n\nexport function createEmitter() {\n const callbacks = new Map();\n\n const emit = function (eventName: string, data: any) {\n if (!callbacks.get(eventName)) return;\n callbacks.get(eventName)!.forEach((cb) => {\n cb(data);\n });\n };\n\n const on = function (eventName: string, callback: any) {\n const cbs = callbacks.get(eventName) ?? [];\n\n cbs.push(callback);\n\n callbacks.set(eventName, cbs);\n };\n\n return [emit, on];\n}\n\nexport const [emit, on] = createEmitter();\n\nconst baseDragState = {\n activeDescendant: undefined,\n affectedNodes: [],\n currentTargetValue: undefined,\n on,\n emit,\n newActiveDescendant: undefined,\n originalZIndex: undefined,\n pointerSelection: false,\n preventEnter: false,\n remapJustFinished: false,\n selectednodes: [],\n selectedParent: undefined,\n};\n\n/**\n * The state of the drag and drop.\n */\nexport let state: BaseDragState = baseDragState;\n\nexport function resetState() {\n const baseDragState = {\n activeDescendant: undefined,\n affectedNodes: [],\n on,\n emit,\n currentTargetValue: undefined,\n originalZIndex: undefined,\n pointerId: undefined,\n preventEnter: false,\n remapJustFinished: false,\n selectednodes: [],\n selectedParent: undefined,\n pointerSelection: false,\n synthScrollDirection: undefined,\n draggedNodeDisplay: undefined,\n synthDragScrolling: false,\n };\n\n state = { ...baseDragState } as BaseDragState;\n}\n\n/**\n * @param {DragStateProps} dragStateProps - Attributes to update state with.\n *\n * @mutation - Updates state with node values.\n *\n * @returns void\n */\nexport function setDragState(\n dragStateProps:\n | (SynthDragStateProps & DragStateProps)\n | DragStateProps\n | undefined\n): DragState | SynthDragState {\n Object.assign(state, dragStateProps);\n\n dropped = false;\n\n state.emit(\"dragStarted\", state);\n\n return state as DragState | SynthDragState;\n}\n\n/**\n *\n */\nfunction handlePointerdownRoot(_e: PointerEvent) {\n if (state.activeState) setActive(state.activeState.parent, undefined, state);\n\n if (state.selectedState)\n deselect(state.selectedState.nodes, state.selectedState.parent, state);\n\n state.selectedState = state.activeState = undefined;\n}\n\nfunction handlePointerupRoot(_e: PointerEvent) {\n if (!isSynthDragState(state)) return;\n\n const config = state.currentParent.data.config;\n\n if (isSynthDragState(state)) config.handleEnd(state);\n}\n\n/**\n * Handles the keydown event on the root element.\n *\n * @param {KeyboardEvent} e - The keyboard event.\n */\nfunction handleRootKeydown(e: KeyboardEvent) {\n if (e.key === \"Escape\") {\n if (state.selectedState)\n deselect(state.selectedState.nodes, state.selectedState.parent, state);\n\n if (state.activeState)\n setActive(state.activeState.parent, undefined, state);\n\n state.selectedState = state.activeState = undefined;\n }\n}\n\nfunction handleRootDrop(_e: DragEvent) {\n //e.preventDefault();\n}\n\n/**\n * If we are currently dragging, then let's prevent default on dragover to avoid\n * the default behavior of the browser on drop.\n */\nfunction handleRootDragover(e: DragEvent) {\n if (!isDragState(state)) return;\n\n e.preventDefault();\n}\n\n/**\n * Initializes the drag and drop functionality for a given parent.\n *\n * @param {DragAndDrop} dragAndDrop - The drag and drop configuration.\n *\n * @returns void\n */\nexport function dragAndDrop({\n parent,\n getValues,\n setValues,\n config = {},\n}: DragAndDrop): void {\n if (!isBrowser) return;\n\n if (!documentController)\n documentController = addEvents(document, {\n dragover: handleRootDragover,\n pointerdown: handlePointerdownRoot,\n pointerup: handlePointerupRoot,\n keydown: handleRootKeydown,\n drop: handleRootDrop,\n });\n\n tearDown(parent);\n\n const parentData: ParentData = {\n getValues,\n setValues,\n config: {\n dragDropEffect: config.dragDropEffect ?? \"move\",\n dragEffectAllowed: config.dragEffectAllowed ?? \"move\",\n draggedNodes,\n dragstartClasses,\n deepCopyStyles: config.deepCopyStyles ?? false,\n handleNodeKeydown,\n handleParentKeydown,\n handleDragstart,\n handleNodeDragover,\n handleParentDragover,\n handleNodeDrop,\n handleDragend,\n handleEnd,\n handleParentBlur,\n handleParentFocus,\n handleNodePointerup,\n handleNodeTouchstart,\n handleNodePointerover,\n handleParentPointerover,\n handleNodePointerdown,\n handleNodePointermove,\n handleNodeDragenter,\n handleNodeDragleave,\n handleParentDrop,\n multiDrag: config.multiDrag ?? false,\n nativeDrag: config.nativeDrag ?? true,\n performSort,\n performTransfer,\n root: config.root ?? document,\n setupNode,\n setupNodeRemap,\n reapplyDragClasses,\n tearDownNode,\n tearDownNodeRemap,\n remapFinished,\n scrollBehavior: {\n x: 0.95,\n y: 0.95,\n },\n threshold: {\n horizontal: 0,\n vertical: 0,\n },\n ...config,\n },\n enabledNodes: [],\n abortControllers: {},\n privateClasses: [],\n };\n\n const nodesObserver = new MutationObserver(nodesMutated);\n\n nodesObserver.observe(parent, { childList: true });\n\n parents.set(parent, parentData);\n\n if (config.treeAncestor && config.treeGroup)\n treeAncestors[config.treeGroup] = parent;\n\n config.plugins?.forEach((plugin) => {\n plugin(parent)?.tearDown?.();\n });\n\n config.plugins?.forEach((plugin) => {\n plugin(parent)?.tearDown?.();\n });\n\n config.plugins?.forEach((plugin: DNDPlugin) => {\n plugin(parent)?.setup?.();\n });\n\n setup(parent, parentData);\n\n remapNodes(parent, true);\n}\n\nexport function dragStateProps(\n data: NodeDragEventData | NodePointerEventData,\n draggedNodes: Array>,\n nativeDrag = true\n): DragStateProps {\n const { x, y } = eventCoordinates(data.e);\n\n const rect = data.targetData.node.el.getBoundingClientRect();\n\n const scrollEls: Array<[HTMLElement, AbortController]> = [];\n\n for (const scrollable of getScrollables()) {\n scrollEls.push([\n scrollable,\n nativeDrag\n ? addEvents(scrollable, {\n scroll: preventSortOnScroll(),\n })\n : addEvents(scrollable, {\n pointermove: handleScroll,\n }),\n ]);\n }\n\n return {\n affectedNodes: [],\n ascendingDirection: false,\n clonedDraggedEls: [],\n dynamicValues: [],\n coordinates: {\n x,\n y,\n },\n draggedNode: {\n el: data.targetData.node.el,\n data: data.targetData.node.data,\n },\n draggedNodes,\n incomingDirection: undefined,\n initialIndex: data.targetData.node.data.index,\n initialParent: {\n el: data.targetData.parent.el,\n data: data.targetData.parent.data,\n },\n currentParent: {\n el: data.targetData.parent.el,\n data: data.targetData.parent.data,\n },\n longPress: data.targetData.parent.data.config.longPress ?? false,\n longPressTimeout: 0,\n currentTargetValue: data.targetData.node.data.value,\n scrollEls,\n startLeft: x - rect.left,\n startTop: y - rect.top,\n targetIndex: data.targetData.node.data.index,\n transferred: false,\n };\n}\n\nexport function performSort({\n parent,\n draggedNodes,\n targetNode,\n}: {\n parent: ParentRecord;\n draggedNodes: Array>;\n targetNode: NodeRecord;\n}) {\n const draggedValues = draggedNodes.map((x) => x.data.value);\n\n const targetParentValues = parentValues(parent.el, parent.data);\n\n const originalIndex = draggedNodes[0].data.index;\n\n const enabledNodes = [...parent.data.enabledNodes];\n\n const newParentValues = [\n ...targetParentValues.filter((x) => !draggedValues.includes(x)),\n ];\n\n newParentValues.splice(targetNode.data.index, 0, ...draggedValues);\n\n if (\"draggedNode\" in state) state.currentTargetValue = targetNode.data.value;\n\n setParentValues(parent.el, parent.data, [...newParentValues]);\n\n if (parent.data.config.onSort)\n parent.data.config.onSort({\n parent: {\n el: parent.el,\n data: parent.data,\n },\n previousValues: [...targetParentValues],\n previousNodes: [...enabledNodes],\n nodes: [...parent.data.enabledNodes],\n values: [...newParentValues],\n draggedNode: draggedNodes[0],\n previousPosition: originalIndex,\n position: targetNode.data.index,\n });\n}\n\n/**\n * This function sets the active node as well as removing any classes or\n * attribute set.\n *\n * @param {ParentEventData} data - The parent event data.\n * @param {NodeRecord} newActiveNode - The new active node.\n * @param {BaseDragState} state - The current drag state.\n */\nfunction setActive(\n parent: ParentRecord,\n newActiveNode: NodeRecord | undefined,\n state: BaseDragState\n) {\n const activeDescendantClass = parent.data.config.activeDescendantClass;\n\n if (state.activeState) {\n {\n removeClass([state.activeState.node.el], activeDescendantClass);\n\n if (state.activeState.parent.el !== parent.el)\n state.activeState.parent.el.setAttribute(\"aria-activedescendant\", \"\");\n }\n }\n\n if (!newActiveNode) {\n state.activeState?.parent.el.setAttribute(\"aria-activedescendant\", \"\");\n\n state.activeState = undefined;\n\n return;\n }\n\n state.activeState = {\n node: newActiveNode,\n parent,\n };\n\n addNodeClass([newActiveNode.el], activeDescendantClass);\n\n state.activeState.parent.el.setAttribute(\n \"aria-activedescendant\",\n state.activeState.node.el.id\n );\n}\n\nfunction deselect(\n nodes: Array>,\n parent: ParentRecord,\n state: BaseDragState\n) {\n const selectedClass = parent.data.config.selectedClass;\n\n if (!state.selectedState) return;\n\n const iterativeNodes = Array.from(nodes);\n\n removeClass(\n nodes.map((x) => x.el),\n selectedClass\n );\n\n for (const node of iterativeNodes) {\n node.el.setAttribute(\"aria-selected\", \"false\");\n\n const index = state.selectedState.nodes.findIndex((x) => x.el === node.el);\n\n if (index === -1) continue;\n\n state.selectedState.nodes.splice(index, 1);\n }\n\n clearLiveRegion(parent);\n}\n\n/**\n * This function sets the selected nodes. This will clean the prior selected state\n * as well as removing any classes or attributes set.\n */\nfunction setSelected(\n parent: ParentRecord,\n selectedNodes: Array>,\n newActiveNode: NodeRecord | undefined,\n state: BaseDragState,\n pointerdown = false\n) {\n state.pointerSelection = pointerdown;\n\n for (const node of selectedNodes) {\n node.el.setAttribute(\"aria-selected\", \"true\");\n\n addNodeClass([node.el], parent.data.config.selectedClass, true);\n }\n\n state.selectedState = {\n nodes: selectedNodes,\n parent,\n };\n\n const selectedItems = selectedNodes.map((x) =>\n x.el.getAttribute(\"aria-label\")\n );\n\n if (selectedItems.length === 0) {\n state.selectedState = undefined;\n\n clearLiveRegion(parent);\n\n return;\n }\n\n setActive(parent, newActiveNode, state);\n\n updateLiveRegion(\n parent,\n `${selectedItems.join(\n \", \"\n )} ready for dragging. Use arrow keys to navigate. Press enter to drop ${selectedItems.join(\n \", \"\n )}.`\n );\n}\n\nfunction updateLiveRegion(parent: ParentRecord, message: string) {\n const parentId = parent.el.id;\n\n const liveRegion = document.getElementById(parentId + \"-live-region\");\n\n if (!liveRegion) return;\n\n liveRegion.textContent = message;\n}\n\nfunction clearLiveRegion(parent: ParentRecord) {\n const liveRegion = document.getElementById(parent.el.id + \"-live-region\");\n\n if (!liveRegion) return;\n\n liveRegion.textContent = \"\";\n}\n\nexport function handleParentBlur(\n _data: ParentEventData,\n _state: BaseDragState | DragState | SynthDragState\n) {}\n\nexport function handleParentFocus(\n data: ParentEventData,\n state: BaseDragState | DragState | SynthDragState\n) {\n const firstEnabledNode = data.targetData.parent.data.enabledNodes[0];\n\n if (!firstEnabledNode) return;\n\n if (\n state.selectedState &&\n state.selectedState.parent.el !== data.targetData.parent.el\n ) {\n setActive(data.targetData.parent, firstEnabledNode, state);\n } else if (!state.selectedState) {\n setActive(data.targetData.parent, firstEnabledNode, state);\n }\n}\n\nexport function performTransfer({\n currentParent,\n targetParent,\n initialParent,\n draggedNodes,\n initialIndex,\n targetNode,\n state,\n}: {\n currentParent: ParentRecord;\n targetParent: ParentRecord;\n initialParent: ParentRecord;\n draggedNodes: Array>;\n initialIndex: number;\n state: BaseDragState | DragState | SynthDragState;\n targetNode?: NodeRecord;\n}) {\n const draggedValues = draggedNodes.map((x) => x.data.value);\n\n const currentParentValues = parentValues(\n currentParent.el,\n currentParent.data\n ).filter((x: any) => !draggedValues.includes(x));\n\n const targetParentValues = parentValues(targetParent.el, targetParent.data);\n\n const reset =\n initialParent.el === targetParent.el &&\n targetParent.data.config.sortable === false;\n\n let targetIndex: number;\n\n if (targetNode) {\n if (reset) {\n targetIndex = initialIndex;\n } else if (targetParent.data.config.sortable === false) {\n targetIndex = targetParent.data.enabledNodes.length;\n } else {\n targetIndex = targetNode.data.index;\n }\n\n targetParentValues.splice(targetIndex, 0, ...draggedValues);\n } else {\n targetIndex = reset ? initialIndex : targetParent.data.enabledNodes.length;\n\n targetParentValues.splice(targetIndex, 0, ...draggedValues);\n }\n\n setParentValues(currentParent.el, currentParent.data, currentParentValues);\n\n setParentValues(targetParent.el, targetParent.data, targetParentValues);\n\n if (targetParent.data.config.onTransfer) {\n targetParent.data.config.onTransfer({\n sourceParent: currentParent,\n targetParent,\n initialParent,\n draggedNodes,\n targetIndex,\n state,\n });\n }\n\n if (currentParent.data.config.onTransfer) {\n currentParent.data.config.onTransfer({\n sourceParent: currentParent,\n targetParent,\n initialParent,\n draggedNodes,\n targetIndex,\n state,\n });\n }\n}\n\nexport function parentValues(\n parent: HTMLElement,\n parentData: ParentData\n): Array {\n return [...parentData.getValues(parent)];\n}\n\nfunction findArrayCoordinates(\n obj: any,\n targetArray: Array,\n path: Array = []\n) {\n let result: Array = [];\n\n if (obj === targetArray) result.push(path);\n\n if (Array.isArray(obj)) {\n const index = obj.findIndex((el) => el === targetArray);\n\n if (index !== -1) {\n result.push([...path, index]);\n } else {\n for (let i = 0; i < obj.length; i++) {\n result = result.concat(\n findArrayCoordinates(obj[i], targetArray, [...path, i])\n );\n }\n }\n } else if (typeof obj === \"object\" && obj !== null) {\n for (const key in obj) {\n result = result.concat(\n findArrayCoordinates(obj[key], targetArray, [...path, key])\n );\n }\n }\n\n return result;\n}\n\nfunction setValueAtCoordinatesUsingFindIndex(\n obj: Array,\n targetArray: Array,\n newArray: Array\n) {\n const coordinates = findArrayCoordinates(obj, targetArray);\n\n let newValues;\n\n coordinates.forEach((coords) => {\n let current = obj;\n for (let i = 0; i < coords.length - 1; i++) {\n const index = coords[i];\n current = current[index];\n }\n const lastIndex = coords[coords.length - 1];\n\n current[lastIndex] = newArray;\n\n // We want to access getter of object we are setting to set the new values\n // of the nested parent element (should be a part of the original structure of\n // ancestor values).\n newValues = current[lastIndex];\n });\n\n return newValues;\n}\n\nexport function setParentValues(\n parent: HTMLElement,\n parentData: ParentData,\n values: Array\n): void {\n const treeGroup = parentData.config.treeGroup;\n\n if (treeGroup) {\n const ancestorEl = treeAncestors[treeGroup];\n\n const ancestorData = parents.get(ancestorEl);\n\n if (!ancestorData) return;\n\n const ancestorValues = ancestorData.getValues(ancestorEl);\n\n const initialParentValues = parentData.getValues(parent);\n\n const updatedValues = setValueAtCoordinatesUsingFindIndex(\n ancestorValues,\n initialParentValues,\n values\n );\n\n if (!updatedValues) {\n console.warn(\"No updated value found\");\n\n return;\n }\n\n parentData.setValues(updatedValues, parent);\n\n return;\n }\n\n parentData.setValues(values, parent);\n}\n\nexport function dragValues(state: DragState): Array {\n return [...state.draggedNodes.map((x) => x.data.value)];\n}\n\n/**\n * Utility function to update parent config.\n */\nexport function updateConfig(\n parent: HTMLElement,\n config: Partial>\n) {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n parents.set(parent, {\n ...parentData,\n config: { ...parentData.config, ...config },\n });\n\n dragAndDrop({\n parent,\n getValues: parentData.getValues,\n setValues: parentData.setValues,\n config,\n });\n}\n\nexport function handleParentDrop(\n data: ParentEventData,\n state: DragState\n) {\n dropped = true;\n\n const config = data.targetData.parent.data.config;\n\n config.handleEnd(state);\n}\n\nexport function tearDown(parent: HTMLElement) {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n if (parentData.abortControllers.mainParent)\n parentData.abortControllers.mainParent.abort();\n}\n\nexport function isDragState(\n state: BaseDragState\n): state is DragState | SynthDragState {\n return \"draggedNode\" in state && !!state.draggedNode;\n}\n\nexport function isSynthDragState(\n state: BaseDragState\n): state is SynthDragState {\n return \"pointerId\" in state && !!state.pointerId;\n}\n\nfunction setup(parent: HTMLElement, parentData: ParentData): void {\n parentData.abortControllers.mainParent = addEvents(parent, {\n keydown: parentEventData(parentData.config.handleParentKeydown),\n dragover: parentEventData(parentData.config.handleParentDragover),\n handleParentPointerover: parentData.config.handleParentPointerover,\n drop: parentEventData(parentData.config.handleParentDrop),\n hasNestedParent: (e: CustomEvent) => {\n const parent = parents.get(e.target as HTMLElement);\n\n if (!parent) return;\n\n parent.nestedParent = e.detail.parent;\n },\n blur: parentEventData(parentData.config.handleParentBlur),\n focus: parentEventData(parentData.config.handleParentFocus),\n });\n\n setAttrs(parent, {\n role: \"listbox\",\n tabindex: \"0\",\n \"aria-multiselectable\": parentData.config.multiDrag ? \"true\" : \"false\",\n \"aria-activedescendant\": \"\",\n \"aria-describedby\": parent.id + \"-live-region\",\n });\n\n const liveRegion = document.createElement(\"div\");\n\n setAttrs(liveRegion, {\n \"aria-live\": \"polite\",\n \"aria-atomic\": \"true\",\n \"data-drag-and-drop-live-region\": \"true\",\n id: parent.id.toString() + \"-live-region\",\n });\n\n Object.assign(liveRegion.style, {\n position: \"absolute\",\n width: \"1px\",\n height: \"1px\",\n padding: \"0\",\n overflow: \"hidden\",\n clip: \"rect(0, 0, 0, 0)\",\n whiteSpace: \"nowrap\",\n border: \"0\",\n });\n\n document.body.appendChild(liveRegion);\n}\n\nexport function setAttrs(el: HTMLElement, attrs: Record) {\n for (const key in attrs) el.setAttribute(key, attrs[key]);\n}\n\nexport function setupNode(data: SetupNodeData) {\n const config = data.parent.data.config;\n\n data.node.el.draggable = true;\n\n data.node.data.abortControllers.mainNode = addEvents(data.node.el, {\n keydown: nodeEventData(config.handleNodeKeydown),\n dragstart: nodeEventData(config.handleDragstart),\n dragover: nodeEventData(config.handleNodeDragover),\n dragenter: nodeEventData(config.handleNodeDragenter),\n dragleave: nodeEventData(config.handleNodeDragleave),\n dragend: nodeEventData(config.handleDragend),\n drop: nodeEventData(config.handleNodeDrop),\n touchstart: nodeEventData(config.handleNodeTouchstart),\n pointercancel: nodeEventData(config.handleDragend),\n pointerdown: nodeEventData(config.handleNodePointerdown),\n pointerup: nodeEventData(config.handleNodePointerup),\n pointermove: nodeEventData(config.handleNodePointermove),\n handleNodePointerover: config.handleNodePointerover,\n mousedown: () => {\n if (!config.nativeDrag) isNative = false;\n else isNative = true;\n },\n });\n\n data.node.el.setAttribute(\"role\", \"option\");\n\n data.node.el.setAttribute(\"aria-selected\", \"false\");\n\n config.reapplyDragClasses(data.node.el, data.parent.data);\n\n data.parent.data.config.plugins?.forEach((plugin: DNDPlugin) => {\n plugin(data.parent.el)?.setupNode?.(data);\n });\n}\n\nexport function setupNodeRemap(data: SetupNodeData) {\n nodes.set(data.node.el, data.node.data);\n\n data.parent.data.config.plugins?.forEach((plugin: DNDPlugin) => {\n plugin(data.parent.el)?.setupNodeRemap?.(data);\n });\n}\n\nfunction reapplyDragClasses(node: Node, parentData: ParentData) {\n if (!isDragState(state)) return;\n\n const dropZoneClass = isSynthDragState(state)\n ? parentData.config.synthDropZoneClass\n : parentData.config.dropZoneClass;\n\n if (state.draggedNode.el !== node) return;\n\n addNodeClass([node], dropZoneClass, true);\n}\n\nexport function tearDownNodeRemap(data: TearDownNodeData) {\n data.parent.data.config.plugins?.forEach((plugin: DNDPlugin) => {\n plugin(data.parent.el)?.tearDownNodeRemap?.(data);\n });\n}\n\nexport function tearDownNode(data: TearDownNodeData) {\n data.parent.data.config.plugins?.forEach((plugin: DNDPlugin) => {\n plugin(data.parent.el)?.tearDownNode?.(data);\n });\n\n data.node.el.draggable = false;\n\n if (data.node.data?.abortControllers?.mainNode)\n data.node.data?.abortControllers?.mainNode.abort();\n}\n\n/**\n * Called when the nodes of a given parent element are mutated.\n *\n * @param mutationList - The list of mutations.\n *\n * @returns void\n *\n * @internal\n */\nfunction nodesMutated(mutationList: MutationRecord[]) {\n const parentEl = mutationList[0].target;\n\n if (!(parentEl instanceof HTMLElement)) return;\n\n const allSelectedAndActiveNodes = document.querySelectorAll(\n `[aria-selected=\"true\"]`\n );\n\n const parentData = parents.get(parentEl);\n\n if (!parentData) return;\n\n for (let x = 0; x < allSelectedAndActiveNodes.length; x++) {\n const node = allSelectedAndActiveNodes[x];\n\n node.setAttribute(\"aria-selected\", \"false\");\n\n removeClass([node], parentData.config.selectedClass);\n }\n\n remapNodes(parentEl);\n}\n\n/**\n * Remaps the data of the parent element's children.\n *\n * @param parent - The parent element.\n *\n * @returns void\n *\n * @internal\n */\nexport function remapNodes(parent: HTMLElement, force?: boolean) {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n parentData.privateClasses = Array.from(parent.classList);\n\n const enabledNodes: Array = [];\n\n const config = parentData.config;\n\n for (let x = 0; x < parent.children.length; x++) {\n const node = parent.children[x];\n\n if (!isNode(node)) continue;\n\n const nodeData = nodes.get(node);\n\n // Only tear down the node if we have explicitly called dragAndDrop\n if (force || !nodeData)\n config.tearDownNode({\n parent: {\n el: parent,\n data: parentData,\n },\n node: {\n el: node,\n data: nodeData,\n },\n });\n\n if (config.disabled) continue;\n\n if (!config.draggable || (config.draggable && config.draggable(node))) {\n enabledNodes.push(node);\n }\n }\n\n if (\n enabledNodes.length !== parentData.getValues(parent).length &&\n !config.disabled\n ) {\n console.warn(\n \"The number of draggable items defined in the parent element does not match the number of values. This may cause unexpected behavior.\"\n );\n\n return;\n }\n\n if (parentData.config.treeGroup && !parentData.config.treeAncestor) {\n let nextAncestorEl = parent.parentElement;\n\n let eventDispatched = false;\n\n while (nextAncestorEl) {\n if (!parents.has(nextAncestorEl as HTMLElement)) {\n nextAncestorEl = nextAncestorEl.parentElement;\n\n continue;\n }\n\n nextAncestorEl.dispatchEvent(\n new CustomEvent(\"hasNestedParent\", {\n detail: {\n parent: { data: parentData, el: parent },\n },\n })\n );\n\n eventDispatched = true;\n\n nextAncestorEl = null;\n }\n\n if (!eventDispatched) console.warn(\"No ancestor found for tree group\");\n }\n\n const values = parentData.getValues(parent);\n\n const enabledNodeRecords: Array> = [];\n\n for (let x = 0; x < enabledNodes.length; x++) {\n const node = enabledNodes[x];\n\n const prevNodeData = nodes.get(node);\n\n const nodeData = Object.assign(\n prevNodeData ?? {\n privateClasses: [],\n abortControllers: {},\n },\n {\n value: values[x],\n index: x,\n }\n );\n\n if (\n !isDragState(state) &&\n state.newActiveDescendant &&\n state.newActiveDescendant.data.value === nodeData.value\n ) {\n setActive(\n {\n data: parentData,\n el: parent,\n },\n {\n el: node,\n data: nodeData,\n },\n state\n );\n }\n\n if (\n !isDragState(state) &&\n state.activeState &&\n state.activeState.node.data.value === nodeData.value\n ) {\n setActive(\n {\n data: parentData,\n el: parent,\n },\n {\n el: node,\n data: nodeData,\n },\n state\n );\n }\n\n if (isDragState(state) && nodeData.value === state.draggedNode.data.value) {\n state.draggedNode.data = nodeData;\n\n state.draggedNode.el = node;\n const draggedNode = state.draggedNodes.find(\n (x) => x.data.value === nodeData.value\n );\n\n if (draggedNode) draggedNode.el = node;\n\n if (isSynthDragState(state))\n state.draggedNode.el.setPointerCapture(state.pointerId);\n }\n\n enabledNodeRecords.push({\n el: node,\n data: nodeData,\n });\n\n if (force || !prevNodeData)\n config.setupNode({\n parent: {\n el: parent,\n data: parentData,\n },\n node: {\n el: node,\n data: nodeData,\n },\n });\n\n setupNodeRemap({\n parent: {\n el: parent,\n data: parentData,\n },\n node: {\n el: node,\n data: nodeData,\n },\n });\n }\n\n parents.set(parent, { ...parentData, enabledNodes: enabledNodeRecords });\n\n config.remapFinished(parentData);\n\n parentData.config.plugins?.forEach((plugin: DNDPlugin) => {\n plugin(parent)?.remapFinished?.();\n });\n}\n\nexport function remapFinished() {\n state.remapJustFinished = true;\n\n if (\"draggedNode\" in state) state.affectedNodes = [];\n}\n\nexport function validateDragstart(data: NodeEventData): boolean {\n return !!data.targetData.parent.data.config.nativeDrag;\n}\n\nfunction draggedNodes(data: NodeEventData): Array> {\n if (!data.targetData.parent.data.config.multiDrag) {\n return [data.targetData.node];\n } else if (state.selectedState) {\n return [\n data.targetData.node,\n ...(state.selectedState?.nodes.filter(\n (x) => x.el !== data.targetData.node.el\n ) as Array>),\n ];\n }\n\n return [];\n}\n\n/**\n * Responsible for assigning dragstart classes to the dragged nodes.\n */\nexport function handleDragstart(\n data: NodeDragEventData,\n state: BaseDragState\n) {\n if (!validateDragstart(data) || !validateDragHandle(data)) {\n data.e.preventDefault();\n\n return;\n }\n\n const config = data.targetData.parent.data.config;\n\n const nodes = config.draggedNodes(data);\n\n config.dragstartClasses(data.targetData.node, nodes, config);\n\n const dragState = initDrag(data, nodes);\n\n if (config.onDragstart)\n config.onDragstart(\n {\n parent: data.targetData.parent,\n values: parentValues(\n data.targetData.parent.el,\n data.targetData.parent.data\n ),\n draggedNode: dragState.draggedNode,\n draggedNodes: dragState.draggedNodes,\n position: dragState.initialIndex,\n },\n state as DragState\n );\n}\n\nexport function handleNodePointerdown(\n data: NodePointerEventData,\n state: BaseDragState\n) {\n if (!validateDragHandle(data)) return;\n\n data.e.stopPropagation();\n\n synthNodePointerDown = true;\n\n const parentData = data.targetData.parent.data;\n\n let selectedNodes = [data.targetData.node];\n\n const commandKey = data.e.ctrlKey || data.e.metaKey;\n const shiftKey = data.e.shiftKey;\n\n const targetNode = data.targetData.node;\n\n if (commandKey && parentData.config.multiDrag) {\n if (state.selectedState) {\n const idx = state.selectedState.nodes.findIndex(\n (x) => x.el === targetNode.el\n );\n\n if (idx === -1) {\n selectedNodes = [...state.selectedState.nodes, targetNode];\n } else {\n selectedNodes = state.selectedState.nodes.filter(\n (x) => x.el !== targetNode.el\n );\n }\n } else {\n selectedNodes = [targetNode];\n }\n\n setSelected(\n data.targetData.parent,\n selectedNodes,\n data.targetData.node,\n state,\n true\n );\n\n return;\n }\n\n if (shiftKey && parentData.config.multiDrag) {\n const nodes = data.targetData.parent.data.enabledNodes;\n if (state.selectedState && state.activeState) {\n if (state.selectedState.parent.el !== data.targetData.parent.el) {\n deselect(state.selectedState.nodes, state.selectedState.parent, state);\n state.selectedState = undefined;\n for (let x = 0; x <= targetNode.data.index; x++)\n selectedNodes.push(nodes[x]);\n } else {\n const [minIndex, maxIndex] =\n state.activeState.node.data.index < data.targetData.node.data.index\n ? [\n state.activeState.node.data.index,\n data.targetData.node.data.index,\n ]\n : [\n data.targetData.node.data.index,\n state.activeState.node.data.index,\n ];\n selectedNodes = nodes.slice(minIndex, maxIndex + 1);\n }\n } else {\n for (let x = 0; x <= targetNode.data.index; x++)\n selectedNodes.push(nodes[x]);\n }\n setSelected(\n data.targetData.parent,\n selectedNodes,\n data.targetData.node,\n state,\n true\n );\n\n return;\n }\n\n if (state.selectedState?.nodes?.length) {\n const idx = state.selectedState.nodes.findIndex(\n (x) => x.el === data.targetData.node.el\n );\n\n if (idx === -1) {\n if (state.selectedState.parent.el !== data.targetData.parent.el) {\n deselect(state.selectedState.nodes, data.targetData.parent, state);\n } else if (parentData.config.multiDrag && (touchDevice || !isNative)) {\n selectedNodes.push(...state.selectedState.nodes);\n } else {\n deselect(state.selectedState.nodes, data.targetData.parent, state);\n }\n setSelected(\n data.targetData.parent,\n selectedNodes,\n data.targetData.node,\n state,\n true\n );\n }\n } else {\n setSelected(\n data.targetData.parent,\n [data.targetData.node],\n data.targetData.node,\n state,\n true\n );\n }\n}\n\nexport function dragstartClasses(\n _node: NodeRecord,\n nodes: Array>,\n config: ParentConfig,\n isSynth = false\n) {\n addNodeClass(\n nodes.map((x) => x.el),\n isSynth ? config.synthDraggingClass : config.draggingClass\n );\n\n setTimeout(() => {\n removeClass(\n nodes.map((x) => x.el),\n isSynth ? config.synthDraggingClass : config.draggingClass\n );\n\n addNodeClass(\n nodes.map((x) => x.el),\n isSynth ? config.synthDragPlaceholderClass : config.dragPlaceholderClass\n );\n\n addNodeClass(\n nodes.map((x) => x.el),\n isSynth ? config.synthDropZoneClass : config.dropZoneClass\n );\n\n removeClass(\n nodes.map((x) => x.el),\n config.activeDescendantClass\n );\n\n removeClass(\n nodes.map((x) => x.el),\n config.selectedClass\n );\n });\n}\n\nexport function initDrag(\n data: NodeDragEventData,\n draggedNodes: Array>\n): DragState {\n const dragState = setDragState(dragStateProps(data, draggedNodes));\n\n data.e.stopPropagation();\n\n if (data.e.dataTransfer) {\n const config = data.targetData.parent.data.config;\n\n data.e.dataTransfer.dropEffect = config.dragDropEffect;\n\n data.e.dataTransfer.effectAllowed = config.dragEffectAllowed;\n\n let dragImage: HTMLElement | undefined;\n\n if (config.dragImage) {\n dragImage = config.dragImage(data, draggedNodes);\n } else {\n if (!config.multiDrag) {\n data.e.dataTransfer.setDragImage(\n data.targetData.node.el,\n data.e.offsetX,\n data.e.offsetY\n );\n\n return dragState;\n } else {\n const wrapper = document.createElement(\"div\");\n\n for (const node of draggedNodes) {\n const clonedNode = node.el.cloneNode(true) as HTMLElement;\n\n clonedNode.style.pointerEvents = \"none\";\n\n clonedNode.id = node.el.id + \"-clone\";\n\n copyNodeStyle(node.el, clonedNode, true);\n\n wrapper.append(clonedNode);\n }\n\n const { width } = draggedNodes[0].el.getBoundingClientRect();\n\n Object.assign(wrapper.style, {\n display: \"flex\",\n flexDirection: \"column\",\n width: `${width}px`,\n position: \"absolute\",\n pointerEvents: \"none\",\n zIndex: \"9999\",\n left: \"-9999px\",\n });\n\n dragImage = wrapper;\n }\n\n document.body.appendChild(dragImage);\n }\n\n data.e.dataTransfer.setDragImage(dragImage, data.e.offsetX, data.e.offsetY);\n\n setTimeout(() => {\n dragImage?.remove();\n });\n }\n\n return dragState;\n}\n\nexport function validateDragHandle(\n data: NodeDragEventData | NodePointerEventData\n): boolean {\n const config = data.targetData.parent.data.config;\n\n if (!config.dragHandle) return true;\n\n const dragHandles = data.targetData.node.el.querySelectorAll(\n config.dragHandle\n );\n\n if (!dragHandles) return false;\n\n const coordinates = data.e;\n\n const elFromPoint = config.root.elementFromPoint(\n coordinates.x,\n coordinates.y\n );\n\n if (!elFromPoint) return false;\n\n for (const handle of Array.from(dragHandles))\n if (elFromPoint === handle || handle.contains(elFromPoint)) return true;\n\n return false;\n}\n\nexport function handleClickNode(_data: NodeEventData) {}\n\nexport function handleClickParent(_data: ParentEventData) {}\n\nexport function handleNodeKeydown(_data: NodeEventData) {}\n\nexport function handleParentKeydown(\n data: ParentKeydownEventData,\n state: BaseDragState\n) {\n const activeDescendant = state.activeState?.node;\n\n if (!activeDescendant) return;\n\n const parentData = data.targetData.parent.data;\n\n const enabledNodes = parentData.enabledNodes;\n\n const index = enabledNodes.findIndex((x) => x.el === activeDescendant.el);\n\n if (index === -1) return;\n\n if (\n [\"ArrowDown\", \"ArrowUp\", \"ArrowRight\", \"ArrowLeft\"].includes(data.e.key)\n ) {\n data.e.preventDefault();\n\n const nextIndex =\n data.e.key === \"ArrowDown\" || data.e.key === \"ArrowRight\"\n ? index + 1\n : index - 1;\n\n if (nextIndex < 0 || nextIndex >= enabledNodes.length) return;\n\n const nextNode = enabledNodes[nextIndex];\n\n setActive(data.targetData.parent, nextNode, state);\n } else if (data.e.key === \" \") {\n data.e.preventDefault();\n\n state.selectedState && state.selectedState.nodes.includes(activeDescendant)\n ? setSelected(\n data.targetData.parent,\n state.selectedState.nodes.filter((x) => x.el !== activeDescendant.el),\n activeDescendant,\n state\n )\n : setSelected(\n data.targetData.parent,\n [activeDescendant],\n activeDescendant,\n state\n );\n\n //if (!state.selectedState)\n // updateLiveRegion(data.targetData.parent, \"\", true);\n } else if (data.e.key === \"Enter\" && state.selectedState) {\n if (\n state.selectedState.parent.el === data.targetData.parent.el &&\n state.activeState\n ) {\n if (state.selectedState.nodes[0].el === state.activeState.node.el) {\n updateLiveRegion(data.targetData.parent, \"Cannot drop item on itself\");\n\n return;\n }\n\n state.newActiveDescendant = state.selectedState.nodes[0];\n\n parentData.config.performSort({\n parent: data.targetData.parent,\n draggedNodes: state.selectedState.nodes,\n targetNode: state.activeState.node,\n });\n\n deselect([], data.targetData.parent, state);\n\n updateLiveRegion(data.targetData.parent, \"Drop successful\");\n } else if (\n state.activeState &&\n state.selectedState.parent.el !== data.targetData.parent.el &&\n validateTransfer({\n currentParent: data.targetData.parent,\n targetParent: state.selectedState.parent,\n initialParent: state.selectedState.parent,\n draggedNodes: state.selectedState.nodes,\n state,\n })\n ) {\n parentData.config.performTransfer({\n currentParent: state.selectedState.parent,\n targetParent: data.targetData.parent,\n initialParent: state.selectedState.parent,\n draggedNodes: state.selectedState.nodes,\n initialIndex: state.selectedState.nodes[0].data.index,\n state,\n targetNode: state.activeState.node,\n });\n\n state.newActiveDescendant = state.selectedState.nodes[0];\n\n setSelected(data.targetData.parent, [], undefined, state);\n\n updateLiveRegion(data.targetData.parent, \"Drop successful\");\n }\n }\n}\n\nexport function preventSortOnScroll() {\n let scrollTimeout: number;\n\n return () => {\n clearTimeout(scrollTimeout);\n\n if (state) state.preventEnter = true;\n\n scrollTimeout = setTimeout(() => {\n if (state) state.preventEnter = false;\n }, 100);\n };\n}\n\nexport function handleNodePointerover(e: PointeroverNodeEvent) {\n if (e.detail.targetData.parent.el === e.detail.state.currentParent.el)\n sort(e.detail, e.detail.state);\n else transfer(e.detail, e.detail.state);\n}\n\nexport function handleNodeDrop(\n data: NodeDragEventData,\n state: DragState | SynthDragState\n) {\n data.e.stopPropagation();\n\n dropped = true;\n\n const config = data.targetData.parent.data.config;\n\n config.handleEnd(state);\n}\n\nexport function handleDragend(\n data: NodeEventData,\n state: DragState | SynthDragState\n) {\n data.e.preventDefault();\n\n if (dropped) {\n dropped = false;\n\n return;\n }\n\n const config = parents.get(state.initialParent.el)?.config;\n config?.handleEnd(state);\n\n if (config?.onDragend) {\n config.onDragend({\n parent: state.currentParent,\n values: parentValues(state.currentParent.el, state.currentParent.data),\n draggedNode: state.draggedNode,\n draggedNodes: state.draggedNodes,\n position: state.initialIndex,\n });\n }\n}\n\nexport function handleEnd(state: DragState | SynthDragState) {\n cancelSynthScroll();\n\n for (const [_el, controller] of state.scrollEls) controller.abort();\n\n if (\"longPressTimeout\" in state && state.longPressTimeout)\n clearTimeout(state.longPressTimeout);\n\n const config = parents.get(state.initialParent.el)?.config;\n\n const isSynth = \"clonedDraggedNode\" in state && state.clonedDraggedNode;\n\n const dropZoneClass = isSynth\n ? config?.synthDropZoneClass\n : config?.dropZoneClass;\n\n if (state.originalZIndex !== undefined)\n state.draggedNode.el.style.zIndex = state.originalZIndex;\n\n removeClass(\n state.draggedNodes.map((x) => x.el),\n dropZoneClass\n );\n\n removeClass(\n state.draggedNodes.map((x) => x.el),\n state.initialParent.data?.config?.longPressClass\n );\n\n removeClass(\n state.draggedNodes.map((x) => x.el),\n isSynth\n ? state.initialParent.data.config.synthDragPlaceholderClass\n : state.initialParent.data?.config?.dragPlaceholderClass\n );\n\n if (isSynth) state.clonedDraggedNode.remove();\n\n deselect(state.draggedNodes, state.currentParent, state);\n\n setActive(state.currentParent, undefined, state);\n\n resetState();\n\n state.selectedState = undefined;\n\n synthNodePointerDown = false;\n\n state.emit(\"dragend\", state);\n}\n\nexport function handleNodeTouchstart(\n data: NodeEventData,\n _state: BaseDragState\n) {\n if (data.e.cancelable) data.e.preventDefault();\n}\n\nexport function handleNodePointerup(\n data: NodePointerEventData,\n state: DragState | SynthDragState | BaseDragState\n) {\n if (!state.pointerSelection && state.selectedState)\n deselect(state.selectedState.nodes, data.targetData.parent, state);\n\n const config = data.targetData.parent.data.config;\n\n state.pointerSelection = false;\n\n synthNodePointerDown = false;\n\n if (!isDragState(state)) return;\n\n config.handleEnd(state as DragState | SynthDragState);\n}\n\nexport function handleNodePointermove(\n data: NodePointerEventData,\n state: SynthDragState | BaseDragState\n) {\n // TODO: I think this is OK but not sure.\n //data.e.stopPropagation();\n\n if (isNative || !synthNodePointerDown || !validateDragHandle(data)) return;\n\n if (!isSynthDragState(state)) {\n const config = data.targetData.parent.data.config;\n\n const nodes = config.draggedNodes(data);\n\n config.dragstartClasses(data.targetData.node, nodes, config, true);\n\n const synthDragState = initSynthDrag(data, state, nodes);\n\n synthDragState.clonedDraggedNode.style.display =\n synthDragState.draggedNodeDisplay || \"\";\n\n synthMove(data, synthDragState);\n\n if (config.onDragstart)\n config.onDragstart(\n {\n parent: data.targetData.parent,\n values: parentValues(\n data.targetData.parent.el,\n data.targetData.parent.data\n ),\n draggedNode: synthDragState.draggedNode,\n draggedNodes: synthDragState.draggedNodes,\n position: synthDragState.initialIndex,\n },\n synthDragState\n );\n\n synthDragState.draggedNode.el.setPointerCapture(data.e.pointerId);\n\n synthDragState.pointerId = data.e.pointerId;\n\n return;\n }\n\n synthMove(data, state as SynthDragState);\n}\n\nfunction initSynthDrag(\n data: NodePointerEventData,\n _state: BaseDragState,\n draggedNodes: Array>\n): SynthDragState {\n const config = data.targetData.parent.data.config;\n\n let dragImage: HTMLElement | undefined;\n\n if (config.synthDragImage) {\n dragImage = config.synthDragImage(data, draggedNodes);\n } else {\n if (!config.multiDrag || draggedNodes.length === 1) {\n dragImage = data.targetData.node.el.cloneNode(true) as HTMLElement;\n\n dragImage.id = data.targetData.node.el.id + \"-clone\";\n\n copyNodeStyle(data.targetData.node.el, dragImage);\n\n Object.assign(dragImage.style, {\n width: data.targetData.node.el.getBoundingClientRect().width,\n zIndex: 9999,\n pointerEvents: \"none\",\n });\n\n document.body.appendChild(dragImage);\n } else {\n const wrapper = document.createElement(\"div\");\n\n for (const node of draggedNodes) {\n const clonedNode = node.el.cloneNode(true) as HTMLElement;\n\n copyNodeStyle(node.el, clonedNode);\n\n clonedNode.style.pointerEvents = \"none\";\n\n clonedNode.id = node.el.id + \"-clone\";\n\n wrapper.append(clonedNode);\n }\n\n const { width } = draggedNodes[0].el.getBoundingClientRect();\n\n Object.assign(wrapper.style, {\n display: \"flex\",\n flexDirection: \"column\",\n width: `${width}px`,\n position: \"fixed\",\n pointerEvents: \"none\",\n zIndex: \"9999\",\n left: \"-9999px\",\n });\n\n dragImage = wrapper;\n }\n }\n\n const display = dragImage.style.display;\n\n dragImage.style.display = \"none\";\n\n document.body.append(dragImage);\n\n dragImage.style.position = \"absolute\";\n\n const synthDragStateProps = {\n clonedDraggedEls: [],\n clonedDraggedNode: dragImage,\n draggedNodeDisplay: display,\n synthDragScrolling: false,\n };\n\n addEvents(document, {\n contextmenu: noDefault,\n });\n\n const synthDragState = setDragState({\n ...dragStateProps(data, draggedNodes, false),\n ...synthDragStateProps,\n }) as SynthDragState;\n\n return synthDragState;\n}\n\nexport function handleLongPress(\n data: NodePointerEventData,\n dragState: DragState\n) {\n const config = data.targetData.parent.data.config;\n\n if (!config.longPress) return;\n\n dragState.longPressTimeout = setTimeout(() => {\n if (!dragState) return;\n\n dragState.longPress = true;\n\n if (config.longPressClass && data.e.cancelable)\n addNodeClass(\n dragState.draggedNodes.map((x) => x.el),\n config.longPressClass\n );\n\n data.e.preventDefault();\n }, config.longPressTimeout || 200);\n}\n\nfunction pointermoveClasses(\n state: SynthDragState,\n config: ParentConfig\n) {\n if (config.longPressClass)\n removeClass(\n state.draggedNodes.map((x) => x.el),\n config?.longPressClass\n );\n}\n\nfunction getScrollData(\n e: DragEvent | PointerEvent,\n state: DragState | SynthDragState\n): ScrollData | undefined {\n if (!(e.currentTarget instanceof HTMLElement)) return;\n\n const {\n x: xThresh,\n y: yThresh,\n scrollOutside,\n } = state.initialParent.data.config.scrollBehavior;\n\n const coordinates = getRealCoords(e.currentTarget);\n\n return {\n xThresh,\n yThresh,\n scrollOutside,\n scrollParent: e.currentTarget,\n x: coordinates.left,\n y: coordinates.top,\n clientWidth: e.currentTarget.clientWidth,\n clientHeight: e.currentTarget.clientHeight,\n scrollWidth: e.currentTarget.scrollWidth,\n scrollHeight: e.currentTarget.scrollHeight,\n };\n}\n\nfunction cancelSynthScroll() {\n if (animationFrameId !== null) {\n cancelAnimationFrame(animationFrameId);\n\n animationFrameId = null;\n }\n}\n\nfunction setSynthScrollDirection(\n direction: \"up\" | \"down\" | \"left\" | \"right\" | undefined,\n el: HTMLElement,\n state: SynthDragState\n) {\n if (state.synthScrollDirection === direction) return;\n\n state.synthScrollDirection = direction;\n\n // Cancel any ongoing animation frame when direction changes\n cancelSynthScroll();\n\n if (direction === \"up\" && el.scrollTop === 0) return;\n\n if (direction === \"down\" && el.scrollTop + el.clientHeight >= el.scrollHeight)\n return;\n\n if (direction === \"left\" && el.scrollLeft === 0) return;\n\n if (direction === \"right\" && el.scrollLeft + el.clientWidth >= el.scrollWidth)\n return;\n\n let lastTimestamp: number | null = null;\n\n // Function to perform the scrolling based on the current direction\n const scroll = (timestamp: number) => {\n if (lastTimestamp === null) lastTimestamp = timestamp;\n\n const elapsed = timestamp - lastTimestamp;\n\n // Base scroll speed in pixels per second\n const baseSpeed = 500;\n\n const distance = (baseSpeed * elapsed) / 1000; // Pixels to scroll\n\n if (state.synthScrollDirection === undefined && animationFrameId) {\n cancelAnimationFrame(animationFrameId);\n\n animationFrameId = null;\n\n return;\n }\n\n switch (direction) {\n case \"up\":\n el.scrollBy(0, -distance);\n state.clonedDraggedNode.style.top = `${\n state.coordinates.y + el.scrollTop\n }px`;\n\n break;\n case \"down\":\n el.scrollBy(0, distance);\n state.clonedDraggedNode.style.top = `${\n state.coordinates.y + el.scrollTop - state.startTop\n }px`;\n\n break;\n case \"left\":\n el.scrollBy(-distance, 0);\n\n state.clonedDraggedNode.style.left = `${\n state.coordinates.x + el.scrollLeft\n }px`;\n\n break;\n case \"right\":\n state.clonedDraggedNode.style.left = `${\n state.coordinates.x + el.scrollLeft\n }px`;\n\n el.scrollBy(distance, 0);\n }\n\n lastTimestamp = timestamp;\n\n animationFrameId = requestAnimationFrame(scroll);\n };\n\n animationFrameId = requestAnimationFrame(scroll);\n}\n\nfunction shouldScroll(\n direction: string,\n e: DragEvent | PointerEvent,\n state: DragState | SynthDragState\n): boolean {\n const dataScrollData = getScrollData(e, state);\n\n if (!dataScrollData) return false;\n\n switch (direction) {\n case \"down\":\n return !!shouldScrollDown(state, dataScrollData);\n\n case \"up\":\n return !!shouldScrollUp(state, dataScrollData);\n\n case \"right\":\n return !!shouldScrollRight(state, dataScrollData);\n\n case \"left\":\n return !!shouldScrollLeft(state, dataScrollData);\n\n default:\n return false;\n }\n}\n\nfunction shouldScrollRight(\n state: DragState | SynthDragState,\n data: ScrollData\n): DragState | DragState | void {\n return;\n const diff = data.scrollParent.clientWidth + data.x - state.coordinates.x;\n\n if (!data.scrollOutside && diff < 0) return;\n\n if (\n diff < (1 - data.xThresh) * data.scrollParent.clientWidth &&\n !(\n data.scrollParent.scrollLeft + data.scrollParent.clientWidth >=\n data.scrollParent.scrollWidth\n )\n )\n return state;\n}\n\nfunction shouldScrollLeft(\n state: DragState,\n data: ScrollData\n): DragState | void {\n return;\n const diff = data.scrollParent.clientWidth + data.x - state.coordinates.x;\n\n if (!data.scrollOutside && diff > data.scrollParent.clientWidth) return;\n\n if (\n diff > data.xThresh * data.scrollParent.clientWidth &&\n data.scrollParent.scrollLeft !== 0\n )\n return state;\n}\n\nfunction shouldScrollUp(state: DragState, data: ScrollData): boolean {\n return (\n state.coordinates.y <= 0.1 * data.scrollParent.clientHeight &&\n data.scrollParent.scrollTop !== 0\n );\n}\n\nfunction shouldScrollDown(state: DragState, data: ScrollData): boolean {\n return (\n state.coordinates.y > data.clientHeight * data.yThresh &&\n data.scrollParent.scrollTop !== data.scrollParent.clientHeight\n );\n}\n\nfunction moveNode(data: NodePointerEventData, state: SynthDragState) {\n const { x, y } = eventCoordinates(data.e);\n\n state.coordinates.y = y;\n\n state.coordinates.x = x;\n\n const startLeft = state.startLeft ?? 0;\n\n const startTop = state.startTop ?? 0;\n\n state.clonedDraggedNode.style.top = `${y - startTop + window.scrollY}px`;\n\n state.clonedDraggedNode.style.left = `${x - startLeft + window.scrollX}px`;\n\n if (data.e.cancelable) data.e.preventDefault();\n\n pointermoveClasses(state, data.targetData.parent.data.config);\n}\n\nexport function synthMove(\n data: NodePointerEventData,\n state: SynthDragState\n) {\n const config = data.targetData.parent.data.config;\n\n if (config.longPress && !state.longPress) {\n clearTimeout(state.longPressTimeout);\n\n return;\n }\n\n moveNode(data, state);\n\n const elFromPoint = getElFromPoint(eventCoordinates(data.e));\n\n if (!elFromPoint) {\n document.dispatchEvent(\n new CustomEvent(\"handleRootPointerover\", {\n detail: {\n e: data.e,\n state,\n },\n })\n );\n\n return;\n }\n const pointerMoveEventData = {\n e: data.e,\n targetData: elFromPoint,\n state,\n };\n\n if (\"node\" in elFromPoint) {\n elFromPoint.node.el.dispatchEvent(\n new CustomEvent(\"handleNodePointerover\", {\n detail: pointerMoveEventData,\n })\n );\n } else {\n elFromPoint.parent.el.dispatchEvent(\n new CustomEvent(\"handleParentPointerover\", {\n detail: pointerMoveEventData,\n })\n );\n }\n}\n\nexport function handleScroll(e: DragEvent | PointerEvent) {\n e.stopPropagation();\n\n if (!isSynthDragState(state)) return;\n let directionSet = false;\n\n for (const direction of Object.keys(scrollConfig)) {\n if (shouldScroll(direction, e, state)) {\n setSynthScrollDirection(\n direction as \"up\" | \"down\" | \"left\" | \"right\" | undefined,\n e.currentTarget as HTMLElement,\n state\n );\n\n directionSet = true;\n\n break;\n }\n }\n\n if (!directionSet) state.synthScrollDirection = undefined;\n}\n\nexport function handleNodeDragover(\n data: NodeDragEventData,\n state: DragState\n) {\n const { x, y } = eventCoordinates(data.e);\n\n state.coordinates.y = y;\n\n state.coordinates.x = x;\n\n //data.e.preventDefault();\n\n //data.e.stopPropagation();\n\n data.targetData.parent.el === state.currentParent?.el\n ? sort(data, state)\n : transfer(data, state);\n}\n\nexport function handleParentDragover(\n data: ParentEventData,\n state: DragState\n) {\n if (!state) return;\n\n Object.assign(eventCoordinates(data.e as DragEvent));\n\n transfer(data, state);\n}\n\nexport function handleParentPointerover(e: PointeroverParentEvent) {\n if (e.detail.targetData.parent.el !== e.detail.state.currentParent.el)\n transfer(e.detail, e.detail.state);\n}\n\nexport function validateTransfer({\n currentParent,\n targetParent,\n initialParent,\n draggedNodes,\n state,\n}: {\n currentParent: ParentRecord;\n targetParent: ParentRecord;\n initialParent: ParentRecord;\n draggedNodes: Array>;\n state: BaseDragState;\n}) {\n if (targetParent.el === currentParent.el) return false;\n\n const targetConfig = targetParent.data.config;\n\n // Not checking for contains among all dragged nodes, should do this.\n if (targetConfig.treeGroup && draggedNodes[0].el.contains(targetParent.el))\n return false;\n\n if (targetConfig.dropZone === false) return false;\n\n const initialParentConfig = initialParent.data.config;\n\n if (targetConfig.accepts) {\n return targetConfig.accepts(\n targetParent,\n initialParent,\n currentParent,\n state\n );\n } else if (\n !targetConfig.group ||\n targetConfig.group !== initialParentConfig.group\n ) {\n return false;\n }\n\n return true;\n}\n\nfunction handleNodeDragenter(\n data: NodeDragEventData,\n _state: DragState\n) {\n data.e.preventDefault();\n}\n\nfunction handleNodeDragleave(\n data: NodeDragEventData,\n _state: DragState\n) {\n data.e.preventDefault();\n}\n\nexport function validateSort(\n data: NodeDragEventData | NodePointerEventData,\n state: DragState,\n x: number,\n y: number\n): boolean {\n if (\n state.affectedNodes\n .map((x) => x.data.value)\n .includes(data.targetData.node.data.value)\n ) {\n return false;\n }\n\n if (state.remapJustFinished) {\n state.remapJustFinished = false;\n\n if (\n data.targetData.node.data.value === state.currentTargetValue ||\n state.draggedNodes.map((x) => x.el).includes(data.targetData.node.el)\n ) {\n state.currentTargetValue = data.targetData.node.data.value;\n }\n\n return false;\n }\n\n if (state.preventEnter) return false;\n\n if (state.draggedNodes.map((x) => x.el).includes(data.targetData.node.el)) {\n state.currentTargetValue = undefined;\n\n return false;\n }\n\n if (data.targetData.node.data.value === state.currentTargetValue)\n return false;\n\n if (\n data.targetData.parent.el !== state.currentParent?.el ||\n data.targetData.parent.data.config.sortable === false\n )\n return false;\n\n const targetRect = data.targetData.node.el.getBoundingClientRect();\n\n const dragRect = state.draggedNode.el.getBoundingClientRect();\n\n const yDiff = targetRect.y - dragRect.y;\n\n const xDiff = targetRect.x - dragRect.x;\n\n let incomingDirection: \"above\" | \"below\" | \"left\" | \"right\";\n\n if (Math.abs(yDiff) > Math.abs(xDiff)) {\n incomingDirection = yDiff > 0 ? \"above\" : \"below\";\n } else {\n incomingDirection = xDiff > 0 ? \"left\" : \"right\";\n }\n\n const threshold = state.currentParent.data.config.threshold;\n\n switch (incomingDirection) {\n case \"left\":\n if (x > targetRect.x + targetRect.width * threshold.horizontal) {\n state.incomingDirection = \"left\";\n\n return true;\n }\n break;\n\n case \"right\":\n if (x < targetRect.x + targetRect.width * (1 - threshold.horizontal)) {\n state.incomingDirection = \"right\";\n\n return true;\n }\n break;\n\n case \"above\":\n if (y > targetRect.y + targetRect.height * threshold.vertical) {\n state.incomingDirection = \"above\";\n\n return true;\n }\n break;\n\n case \"below\":\n if (y < targetRect.y + targetRect.height * (1 - threshold.vertical)) {\n state.incomingDirection = \"below\";\n\n return true;\n }\n break;\n\n default:\n break;\n }\n\n return false;\n}\n\nexport function sort(\n data: NodeDragEventData | NodePointerEventData,\n state: DragState\n) {\n const { x, y } = eventCoordinates(data.e);\n\n if (!validateSort(data, state, x, y)) return;\n\n const range =\n state.draggedNode.data.index > data.targetData.node.data.index\n ? [data.targetData.node.data.index, state.draggedNode.data.index]\n : [state.draggedNode.data.index, data.targetData.node.data.index];\n\n state.targetIndex = data.targetData.node.data.index;\n\n state.affectedNodes = data.targetData.parent.data.enabledNodes.filter(\n (node) => {\n return (\n range[0] <= node.data.index &&\n node.data.index <= range[1] &&\n node.el !== state.draggedNode.el\n );\n }\n );\n\n data.targetData.parent.data.config.performSort({\n parent: data.targetData.parent,\n draggedNodes: state.draggedNodes,\n targetNode: data.targetData.node,\n });\n}\n\n/**\n * Event listener used for all nodes.\n *\n * @param e - The event.\n *\n */\nexport function nodeEventData(\n callback: any\n): (e: Event) => NodeEventData | undefined {\n function nodeTargetData(node: Node): NodeTargetData | undefined {\n const nodeData = nodes.get(node);\n\n if (!nodeData) return;\n\n const parentData = parents.get(node.parentNode);\n\n if (!parentData) return;\n\n return {\n node: {\n el: node,\n data: nodeData,\n },\n parent: {\n el: node.parentNode,\n data: parentData,\n },\n };\n }\n\n return (e: Event) => {\n const targetData = nodeTargetData(e.currentTarget as Node);\n\n if (!targetData) return;\n\n return callback(\n {\n e,\n targetData,\n },\n state\n );\n };\n}\n\n/**\n * Used when the dragged element enters into a parent other than its own.\n */\nexport function transfer(\n data: NodeEventData | ParentEventData,\n state: DragState\n): void {\n if (\n !validateTransfer({\n currentParent: state.currentParent,\n targetParent: data.targetData.parent,\n initialParent: state.initialParent,\n draggedNodes: state.draggedNodes,\n state,\n })\n )\n return;\n\n data.targetData.parent.data.config.performTransfer({\n currentParent: state.currentParent,\n targetParent: data.targetData.parent,\n initialParent: state.initialParent,\n draggedNodes: state.draggedNodes,\n initialIndex: state.initialIndex,\n state,\n targetNode: \"node\" in data.targetData ? data.targetData.node : undefined,\n });\n\n state.currentParent = data.targetData.parent;\n\n state.transferred = true;\n}\n\nexport function parentEventData(\n callback: any\n): (e: Event) => NodeEventData | undefined {\n function parentTargetData(\n parent: HTMLElement\n ): ParentTargetData | undefined {\n const parentData = parents.get(parent);\n\n if (!parentData) return;\n\n return {\n parent: {\n el: parent,\n data: parentData as ParentData,\n },\n };\n }\n\n return (e: Event) => {\n const targetData = parentTargetData(e.currentTarget as HTMLElement);\n\n if (!targetData) return;\n\n return callback(\n {\n e,\n targetData,\n },\n state\n );\n };\n}\n\nexport function noDefault(e: Event) {\n e.preventDefault();\n}\n\nexport function throttle(callback: any, limit: number) {\n var wait = false;\n return function (...args: any[]) {\n if (!wait) {\n callback.call(null, ...args);\n wait = true;\n setTimeout(function () {\n wait = false;\n }, limit);\n }\n };\n}\n\nfunction splitClass(className: string): Array {\n return className.split(\" \").filter((x) => x);\n}\n\nexport function addNodeClass(\n els: Array,\n className: string | undefined,\n omitAppendPrivateClass = false\n) {\n function nodeSetter(node: Node, nodeData: NodeData) {\n nodes.set(node, nodeData);\n }\n\n for (const el of els) {\n const nodeData = nodes.get(el as Node);\n\n const newData = addClass(el, className, nodeData, omitAppendPrivateClass);\n\n if (!newData) continue;\n\n nodeSetter(el as Node, newData as NodeData);\n }\n}\n\nexport function addParentClass(\n els: Array,\n className: string | undefined,\n omitAppendPrivateClass = false\n) {\n function parentSetter(parent: HTMLElement, parentData: ParentData) {\n parents.set(parent, parentData);\n }\n\n for (const el of els) {\n const parentData = parents.get(el);\n\n const newData = addClass(el, className, parentData, omitAppendPrivateClass);\n\n if (!newData) continue;\n\n parentSetter(el, newData as ParentData);\n }\n}\n\nexport function addClass(\n el: Node | HTMLElement | Element,\n className: string | undefined,\n data: NodeData | ParentData | undefined,\n omitAppendPrivateClass = false\n) {\n if (!className) return;\n\n const classNames = splitClass(className);\n\n if (!classNames.length) return;\n\n if (classNames.includes(\"longPress\")) return;\n\n if (!data) {\n el.classList.add(...classNames);\n\n return;\n }\n\n const privateClasses = [];\n\n for (const className of classNames) {\n if (!el.classList.contains(className)) {\n el.classList.add(className);\n } else if (\n el.classList.contains(className) &&\n omitAppendPrivateClass === false\n ) {\n privateClasses.push(className);\n }\n }\n\n data.privateClasses = privateClasses;\n\n return data;\n}\n\nexport function removeClass(\n els: Array,\n className: string | undefined\n) {\n if (!className) return;\n\n const classNames = splitClass(className);\n\n if (!classNames.length) return;\n\n for (const node of els) {\n if (!isNode(node)) {\n node.classList.remove(...classNames);\n continue;\n }\n\n const nodeData = nodes.get(node) || parents.get(node);\n\n if (!nodeData) continue;\n\n for (const className of classNames) {\n if (!nodeData.privateClasses.includes(className)) {\n node.classList.remove(className);\n }\n }\n }\n}\n\nfunction isScrollable(element: HTMLElement) {\n if (element === document.documentElement) {\n return (\n element.scrollHeight > element.clientHeight ||\n element.scrollWidth > element.clientWidth\n );\n }\n\n const style = window.getComputedStyle(element);\n\n return (\n ((style.overflowY === \"auto\" || style.overflowY === \"scroll\") &&\n element.scrollHeight > element.clientHeight) ||\n ((style.overflowX === \"auto\" || style.overflowX === \"scroll\") &&\n element.scrollWidth > element.clientWidth)\n );\n}\n\n/**\n * Used for getting the closest scrollable parent of a given element.\n *\n * @param node - The parent element to start the search from.\n *\n * @returns The closest scrollable parent or the document's root element.\n *\n * @internal\n */\nexport function getScrollables(): Array {\n return Array.from(document.querySelectorAll(\"*\")).filter(\n (el) => el instanceof HTMLElement && isScrollable(el)\n ) as Array;\n}\n\nexport function getElFromPoint(coordinates: {\n x: number;\n y: number;\n}): NodeFromPoint | ParentFromPoint | undefined {\n let target = document.elementFromPoint(coordinates.x, coordinates.y);\n\n if (!isNode(target)) return;\n\n let isParent;\n\n let invalidEl = true;\n\n while (target && invalidEl) {\n if (nodes.has(target as Node) || parents.has(target as HTMLElement)) {\n invalidEl = false;\n\n isParent = parents.has(target as HTMLElement);\n\n break;\n }\n\n target = target.parentNode as Node;\n }\n\n if (!isParent) {\n const targetNodeData = nodes.get(target as Node);\n\n if (!targetNodeData) return;\n\n const targetParentData = parents.get(target.parentNode as Node);\n\n if (!targetParentData) return;\n\n return {\n node: {\n el: target as Node,\n data: targetNodeData,\n },\n parent: {\n el: target.parentNode as Node,\n data: targetParentData as ParentData,\n },\n };\n } else {\n const parentData = parents.get(target as HTMLElement);\n\n if (!parentData) return;\n\n return {\n parent: {\n el: target as HTMLElement,\n data: parentData as ParentData,\n },\n };\n }\n}\n\n/**\n * Checks to see that a given element and its parent node are instances of\n * HTML Elements.\n *\n * @param {unknown} el - The element to check.\n *\n * @returns {boolean} - Whether or not provided element is of type Node.\n */\nexport function isNode(el: unknown): el is Node {\n return el instanceof HTMLElement && el.parentNode instanceof HTMLElement;\n}\n\n/**\n * Takes a given el and event handlers, assigns them, and returns the used abort\n * controller.\n *\n * @param el - The element to add the event listeners to.\n * @param events - The events to add to the element.\n * @returns - The abort controller used for the event listeners.\n */\nexport function addEvents(\n el: Document | ShadowRoot | Node | HTMLElement,\n events: EventHandlers | any\n): AbortController {\n const abortController = new AbortController();\n\n for (const eventName in events) {\n const handler = events[eventName];\n\n el.addEventListener(eventName, handler, {\n signal: abortController.signal,\n passive: false,\n });\n }\n\n return abortController;\n}\n\nexport function copyNodeStyle(\n sourceNode: HTMLElement,\n targetNode: HTMLElement,\n omitKeys = false\n) {\n const computedStyle = window.getComputedStyle(sourceNode);\n\n const omittedKeys = [\n \"position\",\n \"z-index\",\n \"top\",\n \"left\",\n \"x\",\n \"pointer-events\",\n \"y\",\n \"transform-origin\",\n \"filter\",\n \"-webkit-text-fill-color\",\n ];\n\n for (const key of Array.from(computedStyle)) {\n if (omitKeys === false && key && omittedKeys.includes(key)) continue;\n\n targetNode.style.setProperty(\n key,\n computedStyle.getPropertyValue(key),\n computedStyle.getPropertyPriority(key)\n );\n }\n\n for (const child of Array.from(sourceNode.children)) {\n if (!isNode(child)) continue;\n\n const targetChild = targetNode.children[\n Array.from(sourceNode.children).indexOf(child)\n ] as Node;\n\n copyNodeStyle(child, targetChild, omitKeys);\n }\n}\n\nexport function eventCoordinates(data: DragEvent | PointerEvent) {\n return { x: data.clientX, y: data.clientY };\n}\n\nexport function getRealCoords(el: HTMLElement): Coordinates {\n const { top, bottom, left, right, height, width } =\n el.getBoundingClientRect();\n\n const scrollLeft = window.scrollX || document.documentElement.scrollLeft;\n const scrollTop = window.scrollY || document.documentElement.scrollTop;\n\n const adjustedTop = top + scrollTop;\n const adjustedBottom = bottom + scrollTop;\n const adjustedLeft = left + scrollLeft;\n const adjustedRight = right + scrollLeft;\n\n return {\n top: adjustedTop,\n bottom: adjustedBottom,\n left: adjustedLeft,\n right: adjustedRight,\n height,\n width,\n };\n}\n"],"mappings":";AAIO,SAAS,WAAW,mBAA8C,CAAC,GAAG;AAC3E,QAAM,UAAU;AAAA,IACd;AAAA,MACE,WAAW,cAAc,iBAAiB,UAAU,EAAE;AAAA,IACxD;AAAA,IACA;AAAA,MACE,WAAW,cAAc,iBAAiB,UAAU,CAAC;AAAA,IACvD;AAAA,EACF;AAEA,QAAM,YAAY;AAAA,IAChB;AAAA,MACE,WAAW,eAAe,iBAAiB,UAAU,EAAE;AAAA,IACzD;AAAA,IACA;AAAA,MACE,WAAW,cAAc,iBAAiB,UAAU,CAAC;AAAA,IACvD;AAAA,EACF;AAEA,QAAM,YAAY;AAAA,IAChB;AAAA,MACE,WAAW,cAAc,iBAAiB,UAAU,EAAE;AAAA,IACxD;AAAA,IACA;AAAA,MACE,WAAW,cAAc,iBAAiB,UAAU,CAAC;AAAA,IACvD;AAAA,EACF;AAEA,QAAM,aAAa;AAAA,IACjB;AAAA,MACE,WAAW,eAAe,iBAAiB,UAAU,EAAE;AAAA,IACzD;AAAA,IACA;AAAA,MACE,WAAW,cAAc,iBAAiB,UAAU,CAAC;AAAA,IACvD;AAAA,EACF;AACA,SAAO,CAAC,WAAwB;AAC9B,UAAM,aAAa,QAAQ,IAAI,MAAM;AAErC,QAAI,CAAC,WAAY;AAEjB,WAAO;AAAA,MACL,QAAQ;AACN,YAAI,SAAS,KAAK,cAAc,sBAAsB,EAAG;AAAA,MAC3D;AAAA,MAEA,eAAkB,MAAwB;AACxC,YAAI,CAAC,YAAY,KAAK,EAAG;AAEzB,c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iBAAiB,GAAG;AAAA,MAClC,cAAc,oBAAoB,GAAG;AAAA,IACvC;AAAA,EACF;AAEA,aAAW,SAAS,MAAM,KAAK,WAAW,QAAQ,GAAG;AACnD,QAAI,CAAC,OAAO,KAAK,EAAG;AAEpB,UAAM,cAAc,WAAW,SAC7B,MAAM,KAAK,WAAW,QAAQ,EAAE,QAAQ,KAAK,CAC/C;AAEA,kBAAc,OAAO,aAAa,QAAQ;AAAA,EAC5C;AACF;AAEO,SAAS,iBAAiB,MAAgC;AAC/D,SAAO,EAAE,GAAG,KAAK,SAAS,GAAG,KAAK,QAAQ;AAC5C;AAEO,SAAS,cAAc,IAA8B;AAC1D,QAAM,EAAE,KAAK,QAAQ,MAAM,OAAO,QAAQ,MAAM,IAC9C,GAAG,sBAAsB;AAE3B,QAAM,aAAa,OAAO,WAAW,SAAS,gBAAgB;AAC9D,QAAM,YAAY,OAAO,WAAW,SAAS,gBAAgB;AAE7D,QAAM,cAAc,MAAM;AAC1B,QAAM,iBAAiB,SAAS;AAChC,QAAM,eAAe,OAAO;AAC5B,QAAM,gBAAgB,QAAQ;AAE9B,SAAO;AAAA,IACL,KAAK;AAAA,IACL,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,OAAO;AAAA,IACP;AAAA,IACA;AAAA,EACF;AACF;","names":["handleEnd","state","handleEnd","state","draggedParentValues","handleDragoverNode","handleDragoverParent","handlePointeroverParent","state","handleEnd","placeState","dragoverEventListeneerSet","rootDragover","rootPointerover","handleDragoverNode","handleDragoverParent","handleNodePointerover","state","handleEnd","updateDraggedOverNodes","newTargetParentValues","emit","on","baseDragState","dragStateProps","handleNodePointerover","draggedNodes","state","nodes","parent","x","className"]} \ No newline at end of file diff --git a/playwright.config.ts b/playwright.config.ts index 563f76f..3b49425 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -20,35 +20,35 @@ export default defineConfig({ ...devices["Desktop Chrome"], }, }, - { - name: "Desktop Firefox", - testMatch: "tests/drag/**/*.spec.ts", - use: { - ...devices["Desktop Firefox"], - }, - }, - { - name: "Desktop Webkit", - testMatch: "tests/drag/**/*.spec.ts", - use: { - ...devices["Desktop Webkit"], - }, - }, - { - name: "iPhone 13 Chromium", - testMatch: "tests/synthetic-drag/**/*.spec.ts", - use: { - ...devices["iPhone 13"], - browserName: "chromium", - }, - }, - { - name: "iPhone 13 webkit", - testMatch: "tests/synthetic-drag/**/*.spec.ts", - use: { - ...devices["iPhone 13"], - browserName: "webkit", - }, - }, + //{ + // name: "Desktop Firefox", + // testMatch: "tests/drag/**/*.spec.ts", + // use: { + // ...devices["Desktop Firefox"], + // }, + //}, + //{ + // name: "Desktop Webkit", + // testMatch: "tests/drag/**/*.spec.ts", + // use: { + // ...devices["Desktop Webkit"], + // }, + //}, + //{ + // name: "iPhone 13 Chromium", + // testMatch: "tests/synthetic-drag/**/*.spec.ts", + // use: { + // ...devices["iPhone 13"], + // browserName: "chromium", + // }, + //}, + //{ + // name: "iPhone 13 webkit", + // testMatch: "tests/synthetic-drag/**/*.spec.ts", + // use: { + // ...devices["iPhone 13"], + // browserName: "webkit", + // }, + //}, ], }); diff --git a/playwright/tests/drag/swap.spec.ts b/playwright/tests/drag/swap.spec.ts index 3fd6985..21b63e2 100644 --- a/playwright/tests/drag/swap.spec.ts +++ b/playwright/tests/drag/swap.spec.ts @@ -7,8 +7,8 @@ test.beforeEach(async ({ browser }) => { page = await browser.newPage(); }); -test.describe("Drag swap", async () => { - test("Test #1: Swapping within list.", async () => { +test.describe.only("Drag swap", async () => { + test.only("Test #1: Swapping within list.", async () => { await page.goto("http://localhost:3001/swap"); await new Promise((r) => setTimeout(r, 1000)); @@ -70,6 +70,16 @@ test.describe("Drag swap", async () => { await expect(page.locator("#list_1")).toHaveClass("list"); await expect(page.locator("#Banana")).toHaveClass("item"); await expect(page.locator("#values_1")).toHaveText("Banana Apple Orange"); + + // Taking the last item and dropping it on the first item should swap the + // items. + await drag(page, { + originEl: { id: "Banana", position: "center" }, + destinationEl: { id: "Orange", position: "center" }, + dragStart: true, + drop: true, + }); + await expect(page.locator("#values_1")).toHaveText("Orange Apple Banana"); }); test("Test #2: Swapping between lists.", async () => { diff --git a/src/index.ts b/src/index.ts index 822ee04..a8878a6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -37,6 +37,7 @@ export { animations } from "./plugins/animations"; export { insertion } from "./plugins/insertion"; export { place } from "./plugins/place"; export { swap } from "./plugins/swap"; +export { dropOrSwap } from "./plugins/drop-or-swap"; /** * Check to see if code is running in a browser. @@ -257,8 +258,9 @@ export function dragAndDrop({ handleNodeDragover, handleParentDragover, handleNodeDrop, - handleDragend, + handlePointercancel, handleEnd, + handleDragend, handleParentBlur, handleParentFocus, handleNodePointerup, @@ -893,7 +895,7 @@ export function setupNode(data: SetupNodeData) { dragend: nodeEventData(config.handleDragend), drop: nodeEventData(config.handleNodeDrop), touchstart: nodeEventData(config.handleNodeTouchstart), - pointercancel: nodeEventData(config.handleDragend), + pointercancel: nodeEventData(config.handlePointercancel), pointerdown: nodeEventData(config.handleNodePointerdown), pointerup: nodeEventData(config.handleNodePointerup), pointermove: nodeEventData(config.handleNodePointermove), @@ -1225,6 +1227,8 @@ export function handleDragstart( const dragState = initDrag(data, nodes); + console.log(dragState); + if (config.onDragstart) config.onDragstart( { @@ -1636,9 +1640,38 @@ export function handleNodeDrop( } export function handleDragend( + data: NodeDragEventData, + state: DragState +) { + data.e.preventDefault(); + + if (dropped) { + dropped = false; + + return; + } + + const config = data.targetData.parent.data.config; + + if (config?.onDragend) { + config.onDragend({ + parent: state.currentParent, + values: parentValues(state.currentParent.el, state.currentParent.data), + draggedNode: state.draggedNode, + draggedNodes: state.draggedNodes, + position: state.initialIndex, + }); + } + + config.handleEnd(state); +} + +export function handlePointercancel( data: NodeEventData, - state: DragState | SynthDragState + state: DragState | SynthDragState | BaseDragState ) { + if (!isSynthDragState(state)) return; + data.e.preventDefault(); if (dropped) { @@ -1648,7 +1681,6 @@ export function handleDragend( } const config = parents.get(state.initialParent.el)?.config; - config?.handleEnd(state); if (config?.onDragend) { config.onDragend({ @@ -1659,6 +1691,8 @@ export function handleDragend( position: state.initialIndex, }); } + + config?.handleEnd(state); } export function handleEnd(state: DragState | SynthDragState) { diff --git a/src/plugins/drop-or-swap/index.ts b/src/plugins/drop-or-swap/index.ts new file mode 100644 index 0000000..f17575f --- /dev/null +++ b/src/plugins/drop-or-swap/index.ts @@ -0,0 +1,420 @@ +import type { + NodeDragEventData, + DragState, + SynthDragState, + NodeRecord, + PointeroverNodeEvent, + ParentDragEventData, + PointeroverParentEvent, +} from "../../types"; +import type { DropSwapConfig } from "./types"; +import { + parents, + parentValues, + setParentValues, + addNodeClass, + isSynthDragState, + removeClass, + addClass, + state, + isDragState, +} from "../../index"; + +export const dropSwapState = { + draggedOverNodes: Array>(), + initialDraggedIndex: undefined, + transferred: false, +}; + +let dragoverEventListeneerSet = false; + +export function dropOrSwap(dropSwapConfig: Partial> = {}) { + return (parent: HTMLElement) => { + const parentData = parents.get(parent); + + if (!parentData) return; + + const dropSwapParentConfig = { + ...parentData.config, + dropSwapConfig, + }; + + if (!dragoverEventListeneerSet) { + document.addEventListener("dragover", rootDragover); + + document.addEventListener( + "handleRootPointerover" as keyof DocumentEventMap, + (e) => rootPointerover(e as CustomEvent) + ); + + dragoverEventListeneerSet = true; + } + + return { + setup() { + dropSwapParentConfig.handleNodeDragover = + dropSwapConfig.handleNodeDragover || handleNodeDragover; + + dropSwapParentConfig.handleParentDragover = + dropSwapConfig.handleParentDragover || handleParentDragover; + + dropSwapParentConfig.handleNodePointerover = + dropSwapConfig.handleNodePointerover || handleNodePointerover; + + dropSwapParentConfig.handleParentPointerover = + dropSwapConfig.handleParentPointerover || handeParentPointerover; + + const originalHandleend = dropSwapParentConfig.handleEnd; + + dropSwapParentConfig.handleEnd = ( + state: DragState | SynthDragState + ) => { + handleEnd(state); + + originalHandleend(state); + }; + + parentData.config = dropSwapParentConfig; + }, + }; + }; +} + +function rootDragover(_e: DragEvent) { + if (!isDragState(state)) return; + + removeClass( + [state.currentParent.el], + state.currentParent.data.config.dropZoneParentClass + ); + + state.currentParent = state.initialParent; +} + +function rootPointerover(_e: CustomEvent) { + if (!isSynthDragState(state)) return; + + removeClass( + [state.currentParent.el], + state.currentParent.data.config.synthDropZoneParentClass + ); + + state.currentParent = state.initialParent; +} + +function updateDraggedOverNodes( + data: PointeroverNodeEvent | NodeDragEventData, + state: DragState | SynthDragState +) { + const targetData = + "detail" in data ? data.detail.targetData : data.targetData; + + const config = targetData.parent.data.config; + + const dropZoneClass = isSynthDragState(state) + ? config.synthDropZoneClass + : config.dropZoneClass; + + removeClass( + dropSwapState.draggedOverNodes.map((node) => node.el), + dropZoneClass + ); + + const enabledNodes = targetData.parent.data.enabledNodes; + + if (!enabledNodes) return; + + dropSwapState.draggedOverNodes = enabledNodes.slice( + targetData.node.data.index, + targetData.node.data.index + state.draggedNodes.length + ); + + addNodeClass( + dropSwapState.draggedOverNodes.map((node) => node.el), + dropZoneClass, + true + ); + + state.currentTargetValue = targetData.node.data.value; + + state.currentParent = targetData.parent; + + addClass( + state.currentParent.el, + isSynthDragState(state) + ? config.synthDropZoneParentClass + : config.dropZoneParentClass, + state.currentParent.data, + true + ); +} + +function handleNodeDragover( + data: NodeDragEventData, + state: DragState +) { + data.e.preventDefault(); + + data.e.stopPropagation(); + + updateDraggedOverNodes(data, state); +} + +export function handleParentDragover( + data: ParentDragEventData, + state: DragState +) { + data.e.preventDefault(); + + data.e.stopPropagation(); + + const currentConfig = state.currentParent.data.config; + + removeClass( + dropSwapState.draggedOverNodes.map((node) => node.el), + currentConfig.dropZoneClass + ); + + removeClass([state.currentParent.el], currentConfig.dropZoneParentClass); + + const config = data.targetData.parent.data.config; + + addClass( + data.targetData.parent.el, + config.dropZoneParentClass, + data.targetData.parent.data, + true + ); + + dropSwapState.draggedOverNodes = []; + + state.currentParent = data.targetData.parent; +} + +export function handeParentPointerover(data: PointeroverParentEvent) { + const currentConfig = data.detail.state.currentParent.data.config; + + removeClass( + dropSwapState.draggedOverNodes.map((node) => node.el), + currentConfig.synthDropZoneClass + ); + + removeClass( + [data.detail.state.currentParent.el], + currentConfig.synthDropZoneParentClass + ); + + const config = data.detail.targetData.parent.data.config; + + addClass( + data.detail.targetData.parent.el, + config.synthDropZoneParentClass, + data.detail.targetData.parent.data, + true + ); + + dropSwapState.draggedOverNodes = []; + + data.detail.state.currentParent = data.detail.targetData.parent; +} + +function handleNodePointerover(data: PointeroverNodeEvent) { + if (!isSynthDragState(data.detail.state)) return; + + updateDraggedOverNodes(data, data.detail.state); +} + +function placeHandleEnd(state: DragState | SynthDragState) { + const isSynth = isSynthDragState(state); + + removeClass( + [state.currentParent.el], + isSynth + ? state.currentParent.data.config.synthDropZoneParentClass + : state.currentParent.data.config.dropZoneParentClass + ); + + const values = parentValues(state.currentParent.el, state.currentParent.data); + + const draggedValues = state.draggedNodes.map((node) => node.data.value); + + const newValues = values.filter((x) => !draggedValues.includes(x)); + + const index = dropSwapState.draggedOverNodes[0]?.data.index; + + // If we do not have dragged over nodes, then we know that we are appending + // items to the end of the list/ + index !== undefined + ? newValues.splice(index, 0, ...draggedValues) + : newValues.push(...draggedValues); + + if (state.initialParent.el !== state.currentParent.el) { + const initialParentValues = parentValues( + state.initialParent.el, + state.initialParent.data + ); + + const newInitialValues = initialParentValues.filter( + (x) => !draggedValues.includes(x) + ); + setParentValues( + state.initialParent.el, + state.initialParent.data, + newInitialValues + ); + + setParentValues( + state.currentParent.el, + state.currentParent.data, + newValues + ); + } else if ( + state.initialParent.el === state.currentParent.el && + dropSwapState.draggedOverNodes.length + ) { + setParentValues( + state.currentParent.el, + state.currentParent.data, + newValues + ); + } + + removeClass( + dropSwapState.draggedOverNodes.map((node) => node.el), + isSynth + ? state.currentParent.data.config.synthDropZoneClass + : state.currentParent.data.config.dropZoneClass + ); + + dropSwapState.draggedOverNodes = []; +} + +function swapElements( + arr1: T[], // First array + arr2: T[] | null, // Second array (null if it's a single array operation) + index1: number | number[], // Index (or indices) in arr1 to swap + index2: number // Index in arr2 (or in arr1 if arr2 is null) to swap +): T[] | [T[], T[]] { + // Ensure index1 is an array (if a single index is passed) + const indices1 = Array.isArray(index1) ? index1 : [index1]; + + if (arr2 === null) { + // Case for a single array, swapping within arr1 + // Extract elements from arr1 + const elementsFromArr1 = indices1.map((i) => arr1[i]); + const elementFromArr2 = arr1[index2]; + + // Swap the elements within arr1 + arr1.splice(index2, 1, ...elementsFromArr1); + indices1.forEach((i, idx) => { + arr1[i] = idx === 0 ? elementFromArr2 : (undefined as unknown as T); + }); + + // Filter out undefined values + return arr1.filter((el) => el !== undefined); + } else { + // Case for swapping between two arrays + // Extract elements from both arrays + const elementsFromArr1 = indices1.map((i) => arr1[i]); + const elementFromArr2 = arr2[index2]; + + // Swap the elements + arr2.splice(index2, 1, ...elementsFromArr1); + indices1.forEach((i, idx) => { + arr1[i] = idx === 0 ? elementFromArr2 : (undefined as unknown as T); + }); + + // Filter out undefined values from arr1 if multiple elements were swapped + return [arr1.filter((el) => el !== undefined), arr2]; + } +} + +// Example usage: + +function handleEnd(state: DragState | SynthDragState) { + const isSynth = isSynthDragState(state); + + removeClass( + [state.currentParent.el], + isSynth + ? state.currentParent.data.config.synthDropZoneParentClass + : state.currentParent.data.config.dropZoneParentClass + ); + + removeClass( + dropSwapState.draggedOverNodes.map((node) => node.el), + isSynth + ? state.currentParent.data.config.synthDropZoneClass + : state.currentParent.data.config.dropZoneClass + ); + + const values = parentValues(state.currentParent.el, state.currentParent.data); + + const draggedValues = state.draggedNodes.map((node) => node.data.value); + + const newValues = values.filter((x) => !draggedValues.includes(x)); + + const targetIndex = dropSwapState.draggedOverNodes[0]?.data.index; + + const draggedIndex = state.draggedNodes[0].data.index; + + if (targetIndex === undefined) { + console.log("targetIndex is undefined"); + if (state.initialParent.el === state.currentParent.el) return; + + setParentValues( + state.currentParent.el, + state.currentParent.data, + values.concat(draggedValues) + ); + + return; + } + + let swap = false; + + const shouldSwap = state.initialParent.data.config.dropSwapConfig?.shouldSwap; + + if (shouldSwap) + swap = shouldSwap({ + sourceParent: state.initialParent, + targetParent: state.currentParent, + draggedNodes: state.draggedNodes, + targetNodes: dropSwapState.draggedOverNodes as NodeRecord[], + state, + }); + + if (state.initialParent.el === state.currentParent.el) { + setParentValues( + state.currentParent.el, + state.currentParent.data, + swap + ? swapElements(values, null, draggedIndex, targetIndex) + : newValues.concat(draggedValues) + ); + } else { + const initialParentValues = parentValues( + state.initialParent.el, + state.initialParent.data + ); + + const res = swapElements( + initialParentValues, + newValues, + state.initialIndex, + targetIndex + ); + + setParentValues( + state.initialParent.el, + state.initialParent.data, + res[0] as T[] + ); + + setParentValues( + state.currentParent.el, + state.currentParent.data, + res[1] as T[] + ); + } +} diff --git a/src/types.ts b/src/types.ts index 6edd7c6..9d1119d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -87,6 +87,10 @@ export interface ParentConfig { // representations being dragged) on dragstart. This will remain on the nodes // until the drag ends. dragPlaceholderClass?: string; + /** + * The configuration object for the drop and swap plugin. + */ + dropSwapConfig?: DropSwapConfig; /** * The class to add to a node when the node is dragged over it. */ @@ -117,10 +121,7 @@ export interface ParentConfig { /** * Function that is called when dragend or touchend event occurs. */ - handleDragend: ( - data: NodeDragEventData | NodePointerEventData, - state: DragState - ) => void; + handleDragend: (data: NodeDragEventData, state: DragState) => void; /** * Function that is called when dragstart event occurs. */ @@ -167,6 +168,10 @@ export interface ParentConfig { * Function that is called when a dragover event is triggered on a node. */ handleNodeDragover: (data: NodeDragEventData, state: DragState) => void; + handlePointercancel: ( + data: NodeDragEventData | NodePointerEventData, + state: DragState | SynthDragState | BaseDragState + ) => void; /* * Function that is called when a pointerdown is triggered on node. */ @@ -950,3 +955,21 @@ export type StateEvents = | "end" | "dragend" | "synthdragend"; + +export interface ShouldSwapData { + sourceParent: ParentRecord; + targetParent: ParentRecord; + draggedNodes: Array>; + targetNodes: Array>; + state: BaseDragState | DragState | SynthDragState; +} +// Drop or Swap Types +export interface DropSwapConfig { + shouldSwap: (data: ShouldSwapData) => boolean; +} + +export interface DropSwapState { + draggedOverNodes: Array>; + initialDraggedIndex: number | undefined; + transferred: boolean; +} diff --git a/tests/pages/place/index.vue b/tests/pages/place/index.vue index f64ba87..e1a106a 100644 --- a/tests/pages/place/index.vue +++ b/tests/pages/place/index.vue @@ -5,6 +5,7 @@ import { place } from "../../../src/index"; const [parent1, values1] = useDragAndDrop(["Apple", "Banana", "Orange"], { plugins: [place()], dropZoneClass: "dropZone", + group: "transfer", dragPlaceholderClass: "dragPlaceholder", dropZoneParentClass: "dropZoneParent", @@ -46,6 +47,7 @@ const [parent2, values2] = useDragAndDrop(["Tomato", "Potato", "Onion"], { {{ values1.map((x) => x).join(" ") }} + 1
diff --git a/tests/pages/swap/index.vue b/tests/pages/swap/index.vue index 21c52e0..7f2298f 100644 --- a/tests/pages/swap/index.vue +++ b/tests/pages/swap/index.vue @@ -1,9 +1,16 @@