@os-design/drag-sort 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/cjs/DragAndDrop.js.map +1 -1
  2. package/dist/cjs/Draggable.js.map +1 -1
  3. package/dist/cjs/Droppable.js.map +1 -1
  4. package/dist/cjs/index.js.map +1 -1
  5. package/dist/cjs/utils/ListStore.js.map +1 -1
  6. package/dist/cjs/utils/NodeList.js.map +1 -1
  7. package/dist/cjs/utils/getElementOffset.js.map +1 -1
  8. package/dist/cjs/utils/getElementScroll.js.map +1 -1
  9. package/dist/cjs/utils/getNodeRect.js.map +1 -1
  10. package/dist/cjs/utils/useAppendClassName.js.map +1 -1
  11. package/dist/cjs/utils/useBlankNode.js.map +1 -1
  12. package/dist/cjs/utils/useDragAndDrop.js.map +1 -1
  13. package/dist/cjs/utils/useDragEffect.js.map +1 -1
  14. package/dist/cjs/utils/useDroppable.js.map +1 -1
  15. package/dist/cjs/utils/useGeneratedId.js.map +1 -1
  16. package/dist/cjs/utils/useGetNodeStyle.js.map +1 -1
  17. package/dist/cjs/utils/useInitRect.js.map +1 -1
  18. package/dist/cjs/utils/useInitScrollOffset.js.map +1 -1
  19. package/dist/cjs/utils/useMoveNode.js.map +1 -1
  20. package/dist/cjs/utils/useScrollEventByPoint.js.map +1 -1
  21. package/dist/cjs/utils/useTargetList.js.map +1 -1
  22. package/dist/cjs/utils/useTransitionStyle.js.map +1 -1
  23. package/dist/esm/DragAndDrop.js.map +1 -1
  24. package/dist/esm/Draggable.js.map +1 -1
  25. package/dist/esm/Droppable.js.map +1 -1
  26. package/dist/esm/index.js.map +1 -1
  27. package/dist/esm/utils/ListStore.js.map +1 -1
  28. package/dist/esm/utils/NodeList.js.map +1 -1
  29. package/dist/esm/utils/getElementOffset.js.map +1 -1
  30. package/dist/esm/utils/getElementScroll.js.map +1 -1
  31. package/dist/esm/utils/getNodeRect.js.map +1 -1
  32. package/dist/esm/utils/useAppendClassName.js.map +1 -1
  33. package/dist/esm/utils/useBlankNode.js.map +1 -1
  34. package/dist/esm/utils/useDragAndDrop.js.map +1 -1
  35. package/dist/esm/utils/useDragEffect.js.map +1 -1
  36. package/dist/esm/utils/useDroppable.js.map +1 -1
  37. package/dist/esm/utils/useGeneratedId.js.map +1 -1
  38. package/dist/esm/utils/useGetNodeStyle.js.map +1 -1
  39. package/dist/esm/utils/useInitRect.js.map +1 -1
  40. package/dist/esm/utils/useInitScrollOffset.js.map +1 -1
  41. package/dist/esm/utils/useMoveNode.js.map +1 -1
  42. package/dist/esm/utils/useScrollEventByPoint.js.map +1 -1
  43. package/dist/esm/utils/useTargetList.js.map +1 -1
  44. package/dist/esm/utils/useTransitionStyle.js.map +1 -1
  45. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/useTargetList.ts"],"names":["useTargetList","position","listStoreRef","number","setNumber","targetList","current","x","y","list","findByPosition","forceUpdate","n","throttledForceUpdate"],"mappings":";;;;;;;AAAA;;AACA;;AAGA;;;;;;;;;;;;;;;;AAEA,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,CACpBC,QADoB,EAEpBC,YAFoB,EAGjB;AACH,kBAA4B,qBAAS,CAAT,CAA5B;AAAA;AAAA,MAAOC,MAAP;AAAA,MAAeC,SAAf;;AAEA,MAAMC,UAAU,GAAG,oBAAQ,YAAM;AAC/B,QAAI,CAACJ,QAAD,IAAa,CAACC,YAAY,CAACI,OAA/B,EAAwC,OAAO,IAAP;AACxC,QAAQC,CAAR,GAAiBN,QAAjB,CAAQM,CAAR;AAAA,QAAWC,CAAX,GAAiBP,QAAjB,CAAWO,CAAX;AACA,QAAMC,IAAI,GAAGP,YAAY,CAACI,OAAb,CAAqBI,cAArB,CAAoCH,CAApC,EAAuCC,CAAvC,CAAb;AACA,WAAOC,IAAI,IAAI,IAAf;AACD,GALkB,EAKhB,CAACP,YAAD,EAAeD,QAAf,EAAyBE,MAAzB,CALgB,CAAnB,CAHG,CAQmC;;AAEtC,MAAMQ,WAAW,GAAG,wBAAY,YAAM;AACpCP,IAAAA,SAAS,CAAC,UAACQ,CAAD;AAAA,aAAOA,CAAC,GAAG,CAAX;AAAA,KAAD,CAAT;AACD,GAFmB,EAEjB,EAFiB,CAApB,CAVG,CAcH;;AACA,qBAA+B,8BAAYD,WAAZ,EAAyB,GAAzB,CAA/B;AAAA;AAAA,MAAOE,oBAAP;;AACA,yCAAsBZ,QAAtB,EAAgCY,oBAAhC;AAEA,SAAOR,UAAP;AACD,CAtBD;;eAwBeL,a","sourcesContent":["import { RefObject, useCallback, useMemo, useState } from 'react';\nimport useThrottle from '@os-design/use-throttle';\nimport { Position } from '@os-design/use-drag';\nimport ListStore from './ListStore';\nimport useScrollEventByPoint from './useScrollEventByPoint';\n\nconst useTargetList = (\n position: Position | null,\n listStoreRef: RefObject<ListStore>\n) => {\n const [number, setNumber] = useState(0);\n\n const targetList = useMemo(() => {\n if (!position || !listStoreRef.current) return null;\n const { x, y } = position;\n const list = listStoreRef.current.findByPosition(x, y);\n return list || null;\n }, [listStoreRef, position, number]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const forceUpdate = useCallback(() => {\n setNumber((n) => n + 1);\n }, []);\n\n // Update the target list if one of the elements located under the specified point has been scrolled\n const [throttledForceUpdate] = useThrottle(forceUpdate, 100);\n useScrollEventByPoint(position, throttledForceUpdate);\n\n return targetList;\n};\n\nexport default useTargetList;\n"],"file":"useTargetList.js"}
1
+ {"version":3,"file":"useTargetList.js","names":["useTargetList","position","listStoreRef","useState","number","setNumber","targetList","useMemo","current","x","y","list","findByPosition","forceUpdate","useCallback","n","useThrottle","throttledForceUpdate","useScrollEventByPoint"],"sources":["../../../src/utils/useTargetList.ts"],"sourcesContent":["import { RefObject, useCallback, useMemo, useState } from 'react';\nimport useThrottle from '@os-design/use-throttle';\nimport { Position } from '@os-design/use-drag';\nimport ListStore from './ListStore';\nimport useScrollEventByPoint from './useScrollEventByPoint';\n\nconst useTargetList = (\n position: Position | null,\n listStoreRef: RefObject<ListStore>\n) => {\n const [number, setNumber] = useState(0);\n\n const targetList = useMemo(() => {\n if (!position || !listStoreRef.current) return null;\n const { x, y } = position;\n const list = listStoreRef.current.findByPosition(x, y);\n return list || null;\n }, [listStoreRef, position, number]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const forceUpdate = useCallback(() => {\n setNumber((n) => n + 1);\n }, []);\n\n // Update the target list if one of the elements located under the specified point has been scrolled\n const [throttledForceUpdate] = useThrottle(forceUpdate, 100);\n useScrollEventByPoint(position, throttledForceUpdate);\n\n return targetList;\n};\n\nexport default useTargetList;\n"],"mappings":";;;;;;;AAAA;;AACA;;AAGA;;;;;;;;;;;;;;;;AAEA,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,CACpBC,QADoB,EAEpBC,YAFoB,EAGjB;EACH,gBAA4B,IAAAC,eAAA,EAAS,CAAT,CAA5B;EAAA;EAAA,IAAOC,MAAP;EAAA,IAAeC,SAAf;;EAEA,IAAMC,UAAU,GAAG,IAAAC,cAAA,EAAQ,YAAM;IAC/B,IAAI,CAACN,QAAD,IAAa,CAACC,YAAY,CAACM,OAA/B,EAAwC,OAAO,IAAP;IACxC,IAAQC,CAAR,GAAiBR,QAAjB,CAAQQ,CAAR;IAAA,IAAWC,CAAX,GAAiBT,QAAjB,CAAWS,CAAX;IACA,IAAMC,IAAI,GAAGT,YAAY,CAACM,OAAb,CAAqBI,cAArB,CAAoCH,CAApC,EAAuCC,CAAvC,CAAb;IACA,OAAOC,IAAI,IAAI,IAAf;EACD,CALkB,EAKhB,CAACT,YAAD,EAAeD,QAAf,EAAyBG,MAAzB,CALgB,CAAnB,CAHG,CAQmC;;EAEtC,IAAMS,WAAW,GAAG,IAAAC,kBAAA,EAAY,YAAM;IACpCT,SAAS,CAAC,UAACU,CAAD;MAAA,OAAOA,CAAC,GAAG,CAAX;IAAA,CAAD,CAAT;EACD,CAFmB,EAEjB,EAFiB,CAApB,CAVG,CAcH;;EACA,mBAA+B,IAAAC,wBAAA,EAAYH,WAAZ,EAAyB,GAAzB,CAA/B;EAAA;EAAA,IAAOI,oBAAP;;EACA,IAAAC,iCAAA,EAAsBjB,QAAtB,EAAgCgB,oBAAhC;EAEA,OAAOX,UAAP;AACD,CAtBD;;eAwBeN,a"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/useTransitionStyle.ts"],"names":["useTransitionStyle","props","className","ms","enabled","style","document","createElement","innerHTML","child","head","appendChild","removeChild"],"mappings":";;;;;;;AAAA;;AAQA;AACA;AACA;AACA,IAAMA,kBAAkB,GAAG,SAArBA,kBAAqB,CAACC,KAAD,EAAoC;AAC7D,MAAQC,SAAR,GAAmCD,KAAnC,CAAQC,SAAR;AAAA,MAAmBC,EAAnB,GAAmCF,KAAnC,CAAmBE,EAAnB;AAAA,MAAuBC,OAAvB,GAAmCH,KAAnC,CAAuBG,OAAvB;AAEA,wBAAU,YAAM;AACd,QAAI,CAACA,OAAL,EAAc,OAAO,YAAM,CAAE,CAAf;AACd,QAAMC,KAAK,GAAGC,QAAQ,CAACC,aAAT,CAAuB,OAAvB,CAAd;AACAF,IAAAA,KAAK,CAACG,SAAN,cAAsBN,SAAtB,mCAAwDC,EAAxD;AACA,QAAMM,KAAK,GAAGH,QAAQ,CAACI,IAAT,CAAcC,WAAd,CAA0BN,KAA1B,CAAd;AACA,WAAO,YAAM;AACXC,MAAAA,QAAQ,CAACI,IAAT,CAAcE,WAAd,CAA0BH,KAA1B;AACD,KAFD;AAGD,GARD,EAQG,CAACP,SAAD,EAAYE,OAAZ,EAAqBD,EAArB,CARH;AASD,CAZD;;eAceH,kB","sourcesContent":["import { useEffect } from 'react';\n\ninterface UseTransitionStyleProps {\n className: string;\n ms: number;\n enabled: boolean;\n}\n\n/**\n * Creates the global style for setting the transition delay.\n */\nconst useTransitionStyle = (props: UseTransitionStyleProps) => {\n const { className, ms, enabled } = props;\n\n useEffect(() => {\n if (!enabled) return () => {};\n const style = document.createElement('style');\n style.innerHTML = `.${className}{transition:transform ${ms}ms;}`;\n const child = document.head.appendChild(style);\n return () => {\n document.head.removeChild(child);\n };\n }, [className, enabled, ms]);\n};\n\nexport default useTransitionStyle;\n"],"file":"useTransitionStyle.js"}
1
+ {"version":3,"file":"useTransitionStyle.js","names":["useTransitionStyle","props","className","ms","enabled","useEffect","style","document","createElement","innerHTML","child","head","appendChild","removeChild"],"sources":["../../../src/utils/useTransitionStyle.ts"],"sourcesContent":["import { useEffect } from 'react';\n\ninterface UseTransitionStyleProps {\n className: string;\n ms: number;\n enabled: boolean;\n}\n\n/**\n * Creates the global style for setting the transition delay.\n */\nconst useTransitionStyle = (props: UseTransitionStyleProps) => {\n const { className, ms, enabled } = props;\n\n useEffect(() => {\n if (!enabled) return () => {};\n const style = document.createElement('style');\n style.innerHTML = `.${className}{transition:transform ${ms}ms;}`;\n const child = document.head.appendChild(style);\n return () => {\n document.head.removeChild(child);\n };\n }, [className, enabled, ms]);\n};\n\nexport default useTransitionStyle;\n"],"mappings":";;;;;;;AAAA;;AAQA;AACA;AACA;AACA,IAAMA,kBAAkB,GAAG,SAArBA,kBAAqB,CAACC,KAAD,EAAoC;EAC7D,IAAQC,SAAR,GAAmCD,KAAnC,CAAQC,SAAR;EAAA,IAAmBC,EAAnB,GAAmCF,KAAnC,CAAmBE,EAAnB;EAAA,IAAuBC,OAAvB,GAAmCH,KAAnC,CAAuBG,OAAvB;EAEA,IAAAC,gBAAA,EAAU,YAAM;IACd,IAAI,CAACD,OAAL,EAAc,OAAO,YAAM,CAAE,CAAf;IACd,IAAME,KAAK,GAAGC,QAAQ,CAACC,aAAT,CAAuB,OAAvB,CAAd;IACAF,KAAK,CAACG,SAAN,cAAsBP,SAAtB,mCAAwDC,EAAxD;IACA,IAAMO,KAAK,GAAGH,QAAQ,CAACI,IAAT,CAAcC,WAAd,CAA0BN,KAA1B,CAAd;IACA,OAAO,YAAM;MACXC,QAAQ,CAACI,IAAT,CAAcE,WAAd,CAA0BH,KAA1B;IACD,CAFD;EAGD,CARD,EAQG,CAACR,SAAD,EAAYE,OAAZ,EAAqBD,EAArB,CARH;AASD,CAZD;;eAceH,kB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/DragAndDrop.tsx"],"names":["React","useCallback","useMemo","useRef","useState","usePreventDefaultEvent","useMemoObject","useDrag","Portal","useAutoScroll","DragAndDropContext","ListStore","useDragEffect","useGeneratedId","useTransitionStyle","useInitRect","DragAndDrop","draggedNodeContainer","minMouseDistPx","longPressMs","autoScrollDistPercent","autoScrollMaxSpeedPx","transitionDelayMs","onDragEnd","children","listStoreRef","generatedId","nodeClassName","draggedNode","setDraggedNode","startNodeRef","cursorPosition","setCursorPosition","x","y","registerList","list","current","add","deregisterList","id","remove","className","ms","enabled","onDragStart","pos","startPos","startNode","nodeRef","node","rect","getBoundingClientRect","position","onDragMove","dragEndHandler","onMouseDown","onTouchStart","mouseDownHandler","e","touchStartHandler","document","body","distPercent","maxSpeedPx","initRect","undefined","dragAndDropContext","renderDraggedNode","index","style","left","top","width","initWidth","height","initHeight","zIndex"],"mappings":"AAAA,OAAOA,KAAP,IACEC,WADF,EAEEC,OAFF,EAGEC,MAHF,EAIEC,QAJF,QAOO,OAPP;AAQA,OAAOC,sBAAP,MAAmC,sCAAnC;AACA,OAAOC,aAAP,MAA0B,4BAA1B;AACA,OAAOC,OAAP,MAKO,qBALP;AAMA,OAAOC,MAAP,MAAoC,mBAApC;AACA,OAAOC,aAAP,MAA0B,4BAA1B;AACA,SAASC,kBAAT,QAAmC,wBAAnC;AACA,OAAOC,SAAP,MAAsB,mBAAtB;AAEA,OAAOC,aAAP,MAGO,uBAHP;AAIA,OAAOC,cAAP,MAA2B,wBAA3B;AACA,OAAOC,kBAAP,MAA+B,4BAA/B;AACA,OAAOC,WAAP,MAAwB,qBAAxB;;AAkDA;AACA;AACA;AACA,MAAMC,WAAuC,GAAG,CAAC;AAC/CC,EAAAA,oBAD+C;AAE/CC,EAAAA,cAAc,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iB,IAAAA,WAAW,EAAEE,gBAH0B;AAIvCD,IAAAA,YAAY,EAAEG,iBAJyB;AAKvCjC,IAAAA;AALuC,GAAD,CAAxC;AAQA,sBACE,oBAAC,kBAAD,CAAoB,QAApB;AAA6B,IAAA,KAAK,EAAEwC;AAApC,KACG3C,QADH,EAGGI,WAAW,iBACV,oBAAC,MAAD;AAAQ,IAAA,SAAS,EAAEX;AAAnB,KACGW,WAAW,CAACQ,IAAZ,CAAiBgC,iBAAjB,CAAmC;AAClCC,IAAAA,KAAK,EAAEzC,WAAW,CAACsB,IAAZ,CAAiB,CAAjB,CAD2B;AAElCV,IAAAA,EAAE,EAAEZ,WAAW,CAACsB,IAAZ,CAAiB,CAAjB,CAF8B;AAGlCoB,IAAAA,KAAK,EAAE;AACLjB,MAAAA,QAAQ,EAAE,OADL;AAELkB,MAAAA,IAAI,EAAExC,cAAc,CAACE,CAAf,GAAmBL,WAAW,CAACyB,QAAZ,CAAqBpB,CAFzC;AAGLuC,MAAAA,GAAG,EAAEzC,cAAc,CAACG,CAAf,GAAmBN,WAAW,CAACyB,QAAZ,CAAqBnB,CAHxC;AAILuC,MAAAA,KAAK,EAAER,QAAQ,GAAGA,QAAQ,CAACS,SAAZ,GAAwBR,SAJlC;AAKLS,MAAAA,MAAM,EAAEV,QAAQ,GAAGA,QAAQ,CAACW,UAAZ,GAAyBV,SALpC;AAMLW,MAAAA,MAAM,EAAE;AANH;AAH2B,GAAnC,CADH,CAJJ,CADF;AAsBD,CAnJD;;AAuJA,eAAe7D,WAAf","sourcesContent":["import React, {\n useCallback,\n useMemo,\n useRef,\n useState,\n MouseEvent,\n TouchEvent,\n} from 'react';\nimport usePreventDefaultEvent from '@os-design/use-prevent-default-event';\nimport useMemoObject from '@os-design/use-memo-object';\nimport useDrag, {\n Position,\n OnDragEnd,\n OnDragMove,\n OnDragStart,\n} from '@os-design/use-drag';\nimport Portal, { PortalProps } from '@os-design/portal';\nimport useAutoScroll from '@os-design/use-auto-scroll';\nimport { DragAndDropContext } from './utils/useDragAndDrop';\nimport ListStore from './utils/ListStore';\nimport NodeList, { ExistingNode } from './utils/NodeList';\nimport useDragEffect, {\n DragEndHandler,\n DraggedNode,\n} from './utils/useDragEffect';\nimport useGeneratedId from './utils/useGeneratedId';\nimport useTransitionStyle from './utils/useTransitionStyle';\nimport useInitRect from './utils/useInitRect';\n\nexport interface DragAndDropProps {\n /**\n * The container in which the dragged node will be rendered.\n * @default document.body\n */\n draggedNodeContainer?: PortalProps['container'];\n /**\n * The min distance required to start dragging a node (in px).\n * @default 10\n */\n minMouseDistPx?: number;\n /**\n * The delay of the long press event required to start dragging a node on the touch device (in ms).\n * @default 500\n */\n longPressMs?: number;\n /**\n * The distance to the bound at which the list starts to scroll automatically (in percent).\n * @default 20\n */\n autoScrollDistPercent?: number;\n /**\n * The max auto scroll speed (in px).\n * @default 100\n */\n autoScrollMaxSpeedPx?: number;\n /**\n * The animation duration (in ms).\n * @default 250\n */\n transitionDelayMs?: number;\n /**\n * The callback that is called when the drag is completed.\n * @default undefined\n */\n onDragEnd?: DragEndHandler;\n /**\n * The children.\n * @default undefined\n */\n children?: React.ReactNode;\n}\n\ninterface StartNode {\n list: NodeList;\n node: ExistingNode;\n}\n\n/**\n * The container containing one or more lists with draggable nodes.\n */\nconst DragAndDrop: React.FC<DragAndDropProps> = ({\n draggedNodeContainer,\n minMouseDistPx = 10,\n longPressMs = 500,\n autoScrollDistPercent = 20,\n autoScrollMaxSpeedPx = 100,\n transitionDelayMs = 250,\n onDragEnd = () => {},\n children,\n}) => {\n // The user can drag a node between the lists (the Droppable components).\n // To determine which list a node should be dropped in, we need to store refs to all the lists.\n const listStoreRef = useRef<ListStore>(new ListStore());\n\n // The class name for a node used to set the transition style\n const generatedId = useGeneratedId();\n const nodeClassName = useMemo(() => `n${generatedId}`, [generatedId]);\n\n // The node that is currently being dragged\n const [draggedNode, setDraggedNode] = useState<DraggedNode | null>(null);\n const startNodeRef = useRef<StartNode | null>(null);\n const [cursorPosition, setCursorPosition] = useState<Position>({\n x: 0,\n y: 0,\n });\n\n // Add a new list to the store\n const registerList = useCallback((list: NodeList) => {\n listStoreRef.current.add(list);\n }, []);\n\n // Remove the existing list from the store\n const deregisterList = useCallback((id: string) => {\n listStoreRef.current.remove(id);\n }, []);\n\n // Set the style to delay transitions when the node is dragging\n useTransitionStyle({\n className: nodeClassName,\n ms: transitionDelayMs,\n enabled: !!draggedNode,\n });\n\n const onDragStart = useCallback<OnDragStart>(\n (pos: Position, startPos: Position) => {\n const startNode = startNodeRef.current;\n if (!startNode) return;\n const [, , nodeRef] = startNode.node;\n if (!nodeRef.current) return;\n const rect = nodeRef.current.getBoundingClientRect();\n setCursorPosition(pos);\n setDraggedNode({\n list: startNode.list,\n node: startNode.node,\n position: {\n x: startPos.x - rect.x,\n y: startPos.y - rect.y,\n },\n });\n startNodeRef.current = null;\n },\n []\n );\n\n const onDragMove = useCallback<OnDragMove>((pos: Position) => {\n setCursorPosition(pos);\n }, []);\n\n const dragEndHandler = useCallback<OnDragEnd>(() => {\n setDraggedNode(null);\n }, []);\n\n const { onMouseDown, onTouchStart } = useDrag({\n onDragStart,\n onDragMove,\n onDragEnd: dragEndHandler,\n minMouseDistPx,\n longPressMs,\n });\n\n // Handlers that determine whether a user clicks on the node\n const mouseDownHandler = useCallback(\n (e: MouseEvent, list: NodeList, node: ExistingNode) => {\n startNodeRef.current = { list, node };\n onMouseDown(e);\n },\n [onMouseDown]\n );\n const touchStartHandler = useCallback(\n (e: TouchEvent, list: NodeList, node: ExistingNode) => {\n startNodeRef.current = { list, node };\n onTouchStart(e);\n },\n [onTouchStart]\n );\n\n // Prevent body scrolling when the node is dragging.\n // It's important to attach the event to the body (not to the document). Otherwise, it won't work in mobile chrome.\n usePreventDefaultEvent(document.body, 'touchmove', !!draggedNode);\n\n // Implement the drag animation\n useDragEffect({\n draggedNode,\n cursorPosition,\n listStoreRef,\n onDragEnd,\n });\n\n // Auto scroll if the cursor position is located near the border\n useAutoScroll({\n enabled: !!draggedNode,\n distPercent: autoScrollDistPercent,\n maxSpeedPx: autoScrollMaxSpeedPx,\n });\n\n const initRect = useInitRect(draggedNode ? draggedNode.node[2] : undefined);\n\n const dragAndDropContext = useMemoObject({\n registerList,\n deregisterList,\n onMouseDown: mouseDownHandler,\n onTouchStart: touchStartHandler,\n nodeClassName,\n });\n\n return (\n <DragAndDropContext.Provider value={dragAndDropContext}>\n {children}\n\n {draggedNode && (\n <Portal container={draggedNodeContainer}>\n {draggedNode.list.renderDraggedNode({\n index: draggedNode.node[4],\n id: draggedNode.node[5],\n style: {\n position: 'fixed',\n left: cursorPosition.x - draggedNode.position.x,\n top: cursorPosition.y - draggedNode.position.y,\n width: initRect ? initRect.initWidth : undefined,\n height: initRect ? initRect.initHeight : undefined,\n zIndex: 1001,\n },\n })}\n </Portal>\n )}\n </DragAndDropContext.Provider>\n );\n};\n\nexport type { DragEndHandler } from './utils/useDragEffect';\n\nexport default DragAndDrop;\n"],"file":"DragAndDrop.js"}
1
+ {"version":3,"file":"DragAndDrop.js","names":["React","useCallback","useMemo","useRef","useState","usePreventDefaultEvent","useMemoObject","useDrag","Portal","useAutoScroll","DragAndDropContext","ListStore","useDragEffect","useGeneratedId","useTransitionStyle","useInitRect","DragAndDrop","draggedNodeContainer","minMouseDistPx","longPressMs","autoScrollDistPercent","autoScrollMaxSpeedPx","transitionDelayMs","onDragEnd","children","listStoreRef","generatedId","nodeClassName","draggedNode","setDraggedNode","startNodeRef","cursorPosition","setCursorPosition","x","y","registerList","list","current","add","deregisterList","id","remove","className","ms","enabled","onDragStart","pos","startPos","startNode","nodeRef","node","rect","getBoundingClientRect","position","onDragMove","dragEndHandler","onMouseDown","onTouchStart","mouseDownHandler","e","touchStartHandler","document","body","distPercent","maxSpeedPx","initRect","undefined","dragAndDropContext","renderDraggedNode","index","style","left","top","width","initWidth","height","initHeight","zIndex"],"sources":["../../src/DragAndDrop.tsx"],"sourcesContent":["import React, {\n useCallback,\n useMemo,\n useRef,\n useState,\n MouseEvent,\n TouchEvent,\n} from 'react';\nimport usePreventDefaultEvent from '@os-design/use-prevent-default-event';\nimport useMemoObject from '@os-design/use-memo-object';\nimport useDrag, {\n Position,\n OnDragEnd,\n OnDragMove,\n OnDragStart,\n} from '@os-design/use-drag';\nimport Portal, { PortalProps } from '@os-design/portal';\nimport useAutoScroll from '@os-design/use-auto-scroll';\nimport { DragAndDropContext } from './utils/useDragAndDrop';\nimport ListStore from './utils/ListStore';\nimport NodeList, { ExistingNode } from './utils/NodeList';\nimport useDragEffect, {\n DragEndHandler,\n DraggedNode,\n} from './utils/useDragEffect';\nimport useGeneratedId from './utils/useGeneratedId';\nimport useTransitionStyle from './utils/useTransitionStyle';\nimport useInitRect from './utils/useInitRect';\n\nexport interface DragAndDropProps {\n /**\n * The container in which the dragged node will be rendered.\n * @default document.body\n */\n draggedNodeContainer?: PortalProps['container'];\n /**\n * The min distance required to start dragging a node (in px).\n * @default 10\n */\n minMouseDistPx?: number;\n /**\n * The delay of the long press event required to start dragging a node on the touch device (in ms).\n * @default 500\n */\n longPressMs?: number;\n /**\n * The distance to the bound at which the list starts to scroll automatically (in percent).\n * @default 20\n */\n autoScrollDistPercent?: number;\n /**\n * The max auto scroll speed (in px).\n * @default 100\n */\n autoScrollMaxSpeedPx?: number;\n /**\n * The animation duration (in ms).\n * @default 250\n */\n transitionDelayMs?: number;\n /**\n * The callback that is called when the drag is completed.\n * @default undefined\n */\n onDragEnd?: DragEndHandler;\n /**\n * The children.\n * @default undefined\n */\n children?: React.ReactNode;\n}\n\ninterface StartNode {\n list: NodeList;\n node: ExistingNode;\n}\n\n/**\n * The container containing one or more lists with draggable nodes.\n */\nconst DragAndDrop: React.FC<DragAndDropProps> = ({\n draggedNodeContainer,\n minMouseDistPx = 10,\n longPressMs = 500,\n autoScrollDistPercent = 20,\n autoScrollMaxSpeedPx = 100,\n transitionDelayMs = 250,\n onDragEnd = () => {},\n children,\n}) => {\n // The user can drag a node between the lists (the Droppable components).\n // To determine which list a node should be dropped in, we need to store refs to all the lists.\n const listStoreRef = useRef<ListStore>(new ListStore());\n\n // The class name for a node used to set the transition style\n const generatedId = useGeneratedId();\n const nodeClassName = useMemo(() => `n${generatedId}`, [generatedId]);\n\n // The node that is currently being dragged\n const [draggedNode, setDraggedNode] = useState<DraggedNode | null>(null);\n const startNodeRef = useRef<StartNode | null>(null);\n const [cursorPosition, setCursorPosition] = useState<Position>({\n x: 0,\n y: 0,\n });\n\n // Add a new list to the store\n const registerList = useCallback((list: NodeList) => {\n listStoreRef.current.add(list);\n }, []);\n\n // Remove the existing list from the store\n const deregisterList = useCallback((id: string) => {\n listStoreRef.current.remove(id);\n }, []);\n\n // Set the style to delay transitions when the node is dragging\n useTransitionStyle({\n className: nodeClassName,\n ms: transitionDelayMs,\n enabled: !!draggedNode,\n });\n\n const onDragStart = useCallback<OnDragStart>(\n (pos: Position, startPos: Position) => {\n const startNode = startNodeRef.current;\n if (!startNode) return;\n const [, , nodeRef] = startNode.node;\n if (!nodeRef.current) return;\n const rect = nodeRef.current.getBoundingClientRect();\n setCursorPosition(pos);\n setDraggedNode({\n list: startNode.list,\n node: startNode.node,\n position: {\n x: startPos.x - rect.x,\n y: startPos.y - rect.y,\n },\n });\n startNodeRef.current = null;\n },\n []\n );\n\n const onDragMove = useCallback<OnDragMove>((pos: Position) => {\n setCursorPosition(pos);\n }, []);\n\n const dragEndHandler = useCallback<OnDragEnd>(() => {\n setDraggedNode(null);\n }, []);\n\n const { onMouseDown, onTouchStart } = useDrag({\n onDragStart,\n onDragMove,\n onDragEnd: dragEndHandler,\n minMouseDistPx,\n longPressMs,\n });\n\n // Handlers that determine whether a user clicks on the node\n const mouseDownHandler = useCallback(\n (e: MouseEvent, list: NodeList, node: ExistingNode) => {\n startNodeRef.current = { list, node };\n onMouseDown(e);\n },\n [onMouseDown]\n );\n const touchStartHandler = useCallback(\n (e: TouchEvent, list: NodeList, node: ExistingNode) => {\n startNodeRef.current = { list, node };\n onTouchStart(e);\n },\n [onTouchStart]\n );\n\n // Prevent body scrolling when the node is dragging.\n // It's important to attach the event to the body (not to the document). Otherwise, it won't work in mobile chrome.\n usePreventDefaultEvent(document.body, 'touchmove', !!draggedNode);\n\n // Implement the drag animation\n useDragEffect({\n draggedNode,\n cursorPosition,\n listStoreRef,\n onDragEnd,\n });\n\n // Auto scroll if the cursor position is located near the border\n useAutoScroll({\n enabled: !!draggedNode,\n distPercent: autoScrollDistPercent,\n maxSpeedPx: autoScrollMaxSpeedPx,\n });\n\n const initRect = useInitRect(draggedNode ? draggedNode.node[2] : undefined);\n\n const dragAndDropContext = useMemoObject({\n registerList,\n deregisterList,\n onMouseDown: mouseDownHandler,\n onTouchStart: touchStartHandler,\n nodeClassName,\n });\n\n return (\n <DragAndDropContext.Provider value={dragAndDropContext}>\n {children}\n\n {draggedNode && (\n <Portal container={draggedNodeContainer}>\n {draggedNode.list.renderDraggedNode({\n index: draggedNode.node[4],\n id: draggedNode.node[5],\n style: {\n position: 'fixed',\n left: cursorPosition.x - draggedNode.position.x,\n top: cursorPosition.y - draggedNode.position.y,\n width: initRect ? initRect.initWidth : undefined,\n height: initRect ? initRect.initHeight : undefined,\n zIndex: 1001,\n },\n })}\n </Portal>\n )}\n </DragAndDropContext.Provider>\n );\n};\n\nexport type { DragEndHandler } from './utils/useDragEffect';\n\nexport default DragAndDrop;\n"],"mappings":"AAAA,OAAOA,KAAP,IACEC,WADF,EAEEC,OAFF,EAGEC,MAHF,EAIEC,QAJF,QAOO,OAPP;AAQA,OAAOC,sBAAP,MAAmC,sCAAnC;AACA,OAAOC,aAAP,MAA0B,4BAA1B;AACA,OAAOC,OAAP,MAKO,qBALP;AAMA,OAAOC,MAAP,MAAoC,mBAApC;AACA,OAAOC,aAAP,MAA0B,4BAA1B;AACA,SAASC,kBAAT,QAAmC,wBAAnC;AACA,OAAOC,SAAP,MAAsB,mBAAtB;AAEA,OAAOC,aAAP,MAGO,uBAHP;AAIA,OAAOC,cAAP,MAA2B,wBAA3B;AACA,OA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GW,WAAW,CAACQ,IAAZ,CAAiBgC,iBAAjB,CAAmC;IAClCC,KAAK,EAAEzC,WAAW,CAACsB,IAAZ,CAAiB,CAAjB,CAD2B;IAElCV,EAAE,EAAEZ,WAAW,CAACsB,IAAZ,CAAiB,CAAjB,CAF8B;IAGlCoB,KAAK,EAAE;MACLjB,QAAQ,EAAE,OADL;MAELkB,IAAI,EAAExC,cAAc,CAACE,CAAf,GAAmBL,WAAW,CAACyB,QAAZ,CAAqBpB,CAFzC;MAGLuC,GAAG,EAAEzC,cAAc,CAACG,CAAf,GAAmBN,WAAW,CAACyB,QAAZ,CAAqBnB,CAHxC;MAILuC,KAAK,EAAER,QAAQ,GAAGA,QAAQ,CAACS,SAAZ,GAAwBR,SAJlC;MAKLS,MAAM,EAAEV,QAAQ,GAAGA,QAAQ,CAACW,UAAZ,GAAyBV,SALpC;MAMLW,MAAM,EAAE;IANH;EAH2B,CAAnC,CADH,CAJJ,CADF;AAsBD,CAnJD;;AAuJA,eAAe7D,WAAf"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Draggable.tsx"],"names":["React","useCallback","useEffect","useRef","useState","useMemoObject","useDroppable","useDragAndDrop","useAppendClassName","Draggable","index","id","children","ref","nodeRef","style","setStyle","nodeClassName","registerNode","deregisterNode","onMouseDown","onTouchStart","current","mouseDownHandler","e","touchStartHandler","handlers"],"mappings":"AAAA,OAAOA,KAAP,IAGEC,WAHF,EAIEC,SAJF,EAKEC,MALF,EAMEC,QANF,QASO,OATP;AAUA,OAAOC,aAAP,MAA0B,4BAA1B;AAEA,OAAOC,YAAP,MAAyB,sBAAzB;AACA,OAAOC,cAAP,MAA2B,wBAA3B;AACA,OAAOC,kBAAP,MAA+B,4BAA/B;;AA2CA,MAAMC,SAAmC,GAAG,CAAC;AAAEC,EAAAA,KAAF;AAASC,EAAAA,EAAT;AAAaC,EAAAA;AAAb,CAAD,KAA6B;AACvE;AACA,QAAMC,GAAG,GAAGV,MAAM,CAAwB,IAAxB,CA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,OAAO,CAACQ,OAAZ,CAAZ;AACD,GAJkC,EAKnC,CAACD,YAAD,CALmC,CAArC;AAQA,QAAMK,QAAQ,GAAGrB,aAAa,CAAC;AAC7Be,IAAAA,WAAW,EAAEG,gBADgB;AAE7BF,IAAAA,YAAY,EAAEI;AAFe,GAAD,CAA9B;AAKA,sBAAO,0CAAGb,QAAQ,CAAC;AAAEC,IAAAA,GAAF;AAAOE,IAAAA,KAAP;AAAcW,IAAAA;AAAd,GAAD,CAAX,CAAP;AACD,CA/CD;;AAiDA,eAAejB,SAAf","sourcesContent":["import React, {\n CSSProperties,\n RefObject,\n useCallback,\n useEffect,\n useRef,\n useState,\n MouseEvent,\n TouchEvent,\n} from 'react';\nimport useMemoObject from '@os-design/use-memo-object';\nimport { Node } from './utils/NodeList';\nimport useDroppable from './utils/useDroppable';\nimport useDragAndDrop from './utils/useDragAndDrop';\nimport useAppendClassName from './utils/useAppendClassName';\n\nexport interface DraggableHandlers {\n /**\n * The handler that should be called when the mouse down event occurs.\n */\n onMouseDown: (e: MouseEvent) => void;\n /**\n * The handler that should be called when the touch start event occurs.\n */\n onTouchStart: (e: TouchEvent) => void;\n}\n\nexport interface DraggableChildrenProps {\n /**\n * The reference to the draggable list item.\n */\n ref: RefObject<any>; // eslint-disable-line @typescript-eslint/no-explicit-any\n /**\n * Additional styles for moving the list item.\n */\n style: CSSProperties;\n /**\n * The handlers to catch events when the user starts dragging the list item.\n */\n handlers: DraggableHandlers;\n}\n\nexport interface DraggableProps {\n /**\n * The index of the draggable node.\n */\n index: number;\n /**\n * The ID of the draggable node.\n */\n id: string;\n /**\n * The function that renders the draggable node.\n */\n children: (props: DraggableChildrenProps) => React.ReactNode;\n}\n\nconst Draggable: React.FC<DraggableProps> = ({ index, id, children }) => {\n // The reference to the list item\n const ref = useRef<HTMLDivElement | null>(null);\n // The reference to the node containing the refs to the prev and next nodes\n const nodeRef = useRef<Node>(null);\n // Additional styles for moving the list item\n const [style, setStyle] = useState<CSSProperties>({});\n\n const { nodeClassName } = useDragAndDrop();\n const { registerNode, deregisterNode, onMouseDown, onTouchStart } =\n useDroppable();\n\n // Register the node in the list\n useEffect(() => {\n nodeRef.current = registerNode({ ref, setStyle, index, id });\n return () => {\n if (!nodeRef.current) return;\n deregisterNode(nodeRef.current);\n nodeRef.current = null;\n };\n }, [deregisterNode, id, index, registerNode]);\n\n // Set the class name for the node to apply the transition style (see the DragAndDrop container)\n useAppendClassName(ref, nodeClassName);\n\n // Handlers that determine whether a user clicks on the node\n const mouseDownHandler = useCallback(\n (e: MouseEvent) => {\n if (!nodeRef.current) return;\n onMouseDown(e, nodeRef.current);\n },\n [onMouseDown]\n );\n const touchStartHandler = useCallback(\n (e: TouchEvent) => {\n if (!nodeRef.current) return;\n onTouchStart(e, nodeRef.current);\n },\n [onTouchStart]\n );\n\n const handlers = useMemoObject({\n onMouseDown: mouseDownHandler,\n onTouchStart: touchStartHandler,\n });\n\n return <>{children({ ref, style, handlers })}</>;\n};\n\nexport default Draggable;\n"],"file":"Draggable.js"}
1
+ {"version":3,"file":"Draggable.js","names":["React","useCallback","useEffect","useRef","useState","useMemoObject","useDroppable","useDragAndDrop","useAppendClassName","Draggable","index","id","children","ref","nodeRef","style","setStyle","nodeClassName","registerNode","deregisterNode","onMouseDown","onTouchStart","current","mouseDownHandler","e","touchStartHandler","handlers"],"sources":["../../src/Draggable.tsx"],"sourcesContent":["import React, {\n CSSProperties,\n RefObject,\n useCallback,\n useEffect,\n useRef,\n useState,\n MouseEvent,\n TouchEvent,\n} from 'react';\nimport useMemoObject from '@os-design/use-memo-object';\nimport { Node } from './utils/NodeList';\nimport useDroppable from './utils/useDroppable';\nimport useDragAndDrop from './utils/useDragAndDrop';\nimport useAppendClassName from './utils/useAppendClassName';\n\nexport interface DraggableHandlers {\n /**\n * The handler that should be called when the mouse down event occurs.\n */\n onMouseDown: (e: MouseEvent) => void;\n /**\n * The handler that should be called when the touch start event occurs.\n */\n onTouchStart: (e: TouchEvent) => void;\n}\n\nexport interface DraggableChildrenProps {\n /**\n * The reference to the draggable list item.\n */\n ref: RefObject<any>; // eslint-disable-line @typescript-eslint/no-explicit-any\n /**\n * Additional styles for moving the list item.\n */\n style: CSSProperties;\n /**\n * The handlers to catch events when the user starts dragging the list item.\n */\n handlers: DraggableHandlers;\n}\n\nexport interface DraggableProps {\n /**\n * The index of the draggable node.\n */\n index: number;\n /**\n * The ID of the draggable node.\n */\n id: string;\n /**\n * The function that renders the draggable node.\n */\n children: (props: DraggableChildrenProps) => React.ReactNode;\n}\n\nconst Draggable: React.FC<DraggableProps> = ({ index, id, children }) => {\n // The reference to the list item\n const ref = useRef<HTMLDivElement | null>(null);\n // The reference to the node containing the refs to the prev and next nodes\n const nodeRef = useRef<Node>(null);\n // Additional styles for moving the list item\n const [style, setStyle] = useState<CSSProperties>({});\n\n const { nodeClassName } = useDragAndDrop();\n const { registerNode, deregisterNode, onMouseDown, onTouchStart } =\n useDroppable();\n\n // Register the node in the list\n useEffect(() => {\n nodeRef.current = registerNode({ ref, setStyle, index, id });\n return () => {\n if (!nodeRef.current) return;\n deregisterNode(nodeRef.current);\n nodeRef.current = null;\n };\n }, [deregisterNode, id, index, registerNode]);\n\n // Set the class name for the node to apply the transition style (see the DragAndDrop container)\n useAppendClassName(ref, nodeClassName);\n\n // Handlers that determine whether a user clicks on the node\n const mouseDownHandler = useCallback(\n (e: MouseEvent) => {\n if (!nodeRef.current) return;\n onMouseDown(e, nodeRef.current);\n },\n [onMouseDown]\n );\n const touchStartHandler = useCallback(\n (e: TouchEvent) => {\n if (!nodeRef.current) return;\n onTouchStart(e, nodeRef.current);\n },\n [onTouchStart]\n );\n\n const handlers = useMemoObject({\n onMouseDown: mouseDownHandler,\n onTouchStart: touchStartHandler,\n });\n\n return <>{children({ ref, style, handlers })}</>;\n};\n\nexport default Draggable;\n"],"mappings":"AAAA,OAAOA,KAAP,IAGEC,WAHF,EAIEC,SAJF,EAKEC,MALF,EAMEC,QANF,QASO,OATP;AAUA,OAAOC,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AAD,CALkC,CAApC;EAOA,MAAMK,iBAAiB,GAAGxB,WAAW,CAClCuB,CAAD,IAAmB;IACjB,IAAI,CAACV,OAAO,CAACQ,OAAb,EAAsB;IACtBD,YAAY,CAACG,CAAD,EAAIV,OAAO,CAACQ,OAAZ,CAAZ;EACD,CAJkC,EAKnC,CAACD,YAAD,CALmC,CAArC;EAQA,MAAMK,QAAQ,GAAGrB,aAAa,CAAC;IAC7Be,WAAW,EAAEG,gBADgB;IAE7BF,YAAY,EAAEI;EAFe,CAAD,CAA9B;EAKA,oBAAO,0CAAGb,QAAQ,CAAC;IAAEC,GAAF;IAAOE,KAAP;IAAcW;EAAd,CAAD,CAAX,CAAP;AACD,CA/CD;;AAiDA,eAAejB,SAAf"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Droppable.tsx"],"names":["React","useCallback","useEffect","useMemo","useRef","useMemoObject","NodeList","useDragAndDrop","DroppableContext","useGeneratedId","Droppable","renderDraggedNode","id","horizontal","children","ref","innerRef","generatedId","droppableId","listRef","current","registerList","deregisterList","onMouseDown","onTouchStart","listId","registerNode","props","add","deregisterNode","node","remove","mouseDownHandler","e","touchStartHandler","droppableContext"],"mappings":"AAAA,OAAOA,KAAP,IAEEC,WAFF,EAGEC,SAHF,EAIEC,OAJF,EAKEC,MALF,QAQO,OARP;AASA,OAAOC,aAAP,MAA0B,4BAA1B;AACA,OAAOC,QAAP,MAIO,kBAJP;AAKA,OAAOC,cAAP,MAA2B,wBAA3B;AACA,SAASC,gBAAT,QAAiC,sBAAjC;AACA,OAAOC,cAAP,MAA2B,wBAA3B;;AAqCA,MAAMC,SAAmC,GAAG,CAAC;AAC3CC,EAAAA,iBAD2C;AAE3CC,EAAAA,EAF2C;AAG3CC,EAAAA,UAAU,GAAG,KAH8B;AAI3CC,EAAAA;AAJ2C,CAAD,KAKtC;AACJ;AACA,QAAMC,GAAG,GAAGX,MAAM,CAAiB,IAAjB,CAAlB,CAFI,CAGJ;;AACA,QAAMY,QAAQ,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AjB,CAJM,CAAT;AAMA,QAAMK,YAAY,GAAGzB,WAAW,CAC7B0B,KAAD,IAAsBR,OAAO,CAACC,OAAR,CAAgBQ,GAAhB,CAAoBD,KAApB,CADQ,EAE9B,EAF8B,CAAhC;AAIA,QAAME,cAAc,GAAG5B,WAAW,CAAE6B,IAAD,IAAwB;AACzDX,IAAAA,OAAO,CAACC,OAAR,CAAgBW,MAAhB,CAAuBD,IAAvB;AACD,GAFiC,EAE/B,EAF+B,CAAlC,CAjDI,CAqDJ;;AACA,QAAME,gBAAgB,GAAG/B,WAAW,CAClC,CAACgC,CAAD,EAAgBH,IAAhB,KAAuC;AACrCP,IAAAA,WAAW,CAACU,CAAD,EAAId,OAAO,CAACC,OAAZ,EAAqBU,IAArB,CAAX;AACD,GAHiC,EAIlC,CAACP,WAAD,CAJkC,CAApC;AAMA,QAAMW,iBAAiB,GAAGjC,WAAW,CACnC,CAACgC,CAAD,EAAgBH,IAAhB,KAAuC;AACrCN,IAAAA,YAAY,CAACS,CAAD,EAAId,OAAO,CAACC,OAAZ,EAAqBU,IAArB,CAAZ;AACD,GAHkC,EAInC,CAACN,YAAD,CAJmC,CAArC;AAOA,QAAMW,gBAAgB,GAAG9B,aAAa,CAAC;AACrCqB,IAAAA,YADqC;AAErCG,IAAAA,cAFqC;AAGrCN,IAAAA,WAAW,EAAES,gBAHwB;AAIrCR,IAAAA,YAAY,EAAEU;AAJuB,GAAD,CAAtC;AAOA,sBACE,oBAAC,gBAAD,CAAkB,QAAlB;AAA2B,IAAA,KAAK,EAAEC;AAAlC,KACIrB,QAAD,CAAuB;AAAEC,IAAAA,GAAF;AAAOC,IAAAA;AAAP,GAAvB,CADH,CADF;AAKD,CApFD;;AAsFA,eAAeN,SAAf","sourcesContent":["import React, {\n RefObject,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n MouseEvent,\n TouchEvent,\n} from 'react';\nimport useMemoObject from '@os-design/use-memo-object';\nimport NodeList, {\n ExistingNode,\n NodeProps,\n RenderDraggedNode,\n} from './utils/NodeList';\nimport useDragAndDrop from './utils/useDragAndDrop';\nimport { DroppableContext } from './utils/useDroppable';\nimport useGeneratedId from './utils/useGeneratedId';\n\nexport interface DroppableChildrenProps {\n /**\n * The reference to the list.\n * If a virtual list is used, pass it to the outerRef prop.\n */\n ref: RefObject<HTMLDivElement>;\n /**\n * The reference to the container inside the virtual list.\n * Pass it to the innerRef prop.\n */\n innerRef: RefObject<HTMLDivElement>;\n}\n\nexport interface DroppableProps {\n /**\n * The function that renders the dragged node.\n */\n renderDraggedNode: RenderDraggedNode;\n /**\n * The ID of the list with draggable nodes.\n * Used to determine in which list the dragged node was dropped.\n * @default undefined\n */\n id?: string;\n /**\n * Whether the list is horizontal.\n * @default false\n */\n horizontal?: boolean;\n /**\n * The function that renders the list with draggable nodes.\n */\n children: (props: DroppableChildrenProps) => React.ReactNode;\n}\n\nconst Droppable: React.FC<DroppableProps> = ({\n renderDraggedNode,\n id,\n horizontal = false,\n children,\n}) => {\n // The reference to the list\n const ref = useRef<HTMLDivElement>(null);\n // The reference to the container inside the virtual list\n const innerRef = useRef<HTMLDivElement>(null);\n // The unique ID of the list. If no ID was specified, the generated one is used.\n const generatedId = useGeneratedId();\n const droppableId = useMemo(() => id || generatedId, [generatedId, id]);\n // The reference to the list of nodes\n const listRef = useRef(\n new NodeList({\n id: droppableId,\n ref,\n innerRef,\n horizontal,\n renderDraggedNode,\n })\n );\n\n // Update the ID of the list if it changes\n useEffect(() => {\n listRef.current.id = droppableId;\n }, [droppableId]);\n\n // Update the list orientation if it changes.\n // There is no need to check the order of the nodes in the list because it will be the same.\n useEffect(() => {\n listRef.current.horizontal = horizontal;\n }, [horizontal]);\n\n // Update the callback that renders the dragged node if it changes\n useEffect(() => {\n listRef.current.renderDraggedNode = renderDraggedNode;\n }, [renderDraggedNode]);\n\n const { registerList, deregisterList, onMouseDown, onTouchStart } =\n useDragAndDrop();\n\n // Register the list in the store\n useEffect(() => {\n registerList(listRef.current);\n const listId = listRef.current.id;\n return () => deregisterList(listId);\n }, [deregisterList, registerList]);\n\n const registerNode = useCallback(\n (props: NodeProps) => listRef.current.add(props),\n []\n );\n const deregisterNode = useCallback((node: ExistingNode) => {\n listRef.current.remove(node);\n }, []);\n\n // Handlers that determine whether a user clicks on the node\n const mouseDownHandler = useCallback(\n (e: MouseEvent, node: ExistingNode) => {\n onMouseDown(e, listRef.current, node);\n },\n [onMouseDown]\n );\n const touchStartHandler = useCallback(\n (e: TouchEvent, node: ExistingNode) => {\n onTouchStart(e, listRef.current, node);\n },\n [onTouchStart]\n );\n\n const droppableContext = useMemoObject({\n registerNode,\n deregisterNode,\n onMouseDown: mouseDownHandler,\n onTouchStart: touchStartHandler,\n });\n\n return (\n <DroppableContext.Provider value={droppableContext}>\n {(children as Function)({ ref, innerRef })}\n </DroppableContext.Provider>\n );\n};\n\nexport default Droppable;\n"],"file":"Droppable.js"}
1
+ {"version":3,"file":"Droppable.js","names":["React","useCallback","useEffect","useMemo","useRef","useMemoObject","NodeList","useDragAndDrop","DroppableContext","useGeneratedId","Droppable","renderDraggedNode","id","horizontal","children","ref","innerRef","generatedId","droppableId","listRef","current","registerList","deregisterList","onMouseDown","onTouchStart","listId","registerNode","props","add","deregisterNode","node","remove","mouseDownHandler","e","touchStartHandler","droppableContext"],"sources":["../../src/Droppable.tsx"],"sourcesContent":["import React, {\n RefObject,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n MouseEvent,\n TouchEvent,\n} from 'react';\nimport useMemoObject from '@os-design/use-memo-object';\nimport NodeList, {\n ExistingNode,\n NodeProps,\n RenderDraggedNode,\n} from './utils/NodeList';\nimport useDragAndDrop from './utils/useDragAndDrop';\nimport { DroppableContext } from './utils/useDroppable';\nimport useGeneratedId from './utils/useGeneratedId';\n\nexport interface DroppableChildrenProps {\n /**\n * The reference to the list.\n * If a virtual list is used, pass it to the outerRef prop.\n */\n ref: RefObject<HTMLDivElement>;\n /**\n * The reference to the container inside the virtual list.\n * Pass it to the innerRef prop.\n */\n innerRef: RefObject<HTMLDivElement>;\n}\n\nexport interface DroppableProps {\n /**\n * The function that renders the dragged node.\n */\n renderDraggedNode: RenderDraggedNode;\n /**\n * The ID of the list with draggable nodes.\n * Used to determine in which list the dragged node was dropped.\n * @default undefined\n */\n id?: string;\n /**\n * Whether the list is horizontal.\n * @default false\n */\n horizontal?: boolean;\n /**\n * The function that renders the list with draggable nodes.\n */\n children: (props: DroppableChildrenProps) => React.ReactNode;\n}\n\nconst Droppable: React.FC<DroppableProps> = ({\n renderDraggedNode,\n id,\n horizontal = false,\n children,\n}) => {\n // The reference to the list\n const ref = useRef<HTMLDivElement>(null);\n // The reference to the container inside the virtual list\n const innerRef = useRef<HTMLDivElement>(null);\n // The unique ID of the list. If no ID was specified, the generated one is used.\n const generatedId = useGeneratedId();\n const droppableId = useMemo(() => id || generatedId, [generatedId, id]);\n // The reference to the list of nodes\n const listRef = useRef(\n new NodeList({\n id: droppableId,\n ref,\n innerRef,\n horizontal,\n renderDraggedNode,\n })\n );\n\n // Update the ID of the list if it changes\n useEffect(() => {\n listRef.current.id = droppableId;\n }, [droppableId]);\n\n // Update the list orientation if it changes.\n // There is no need to check the order of the nodes in the list because it will be the same.\n useEffect(() => {\n listRef.current.horizontal = horizontal;\n }, [horizontal]);\n\n // Update the callback that renders the dragged node if it changes\n useEffect(() => {\n listRef.current.renderDraggedNode = renderDraggedNode;\n }, [renderDraggedNode]);\n\n const { registerList, deregisterList, onMouseDown, onTouchStart } =\n useDragAndDrop();\n\n // Register the list in the store\n useEffect(() => {\n registerList(listRef.current);\n const listId = listRef.current.id;\n return () => deregisterList(listId);\n }, [deregisterList, registerList]);\n\n const registerNode = useCallback(\n (props: NodeProps) => listRef.current.add(props),\n []\n );\n const deregisterNode = useCallback((node: ExistingNode) => {\n listRef.current.remove(node);\n }, []);\n\n // Handlers that determine whether a user clicks on the node\n const mouseDownHandler = useCallback(\n (e: MouseEvent, node: ExistingNode) => {\n onMouseDown(e, listRef.current, node);\n },\n [onMouseDown]\n );\n const touchStartHandler = useCallback(\n (e: TouchEvent, node: ExistingNode) => {\n onTouchStart(e, listRef.current, node);\n },\n [onTouchStart]\n );\n\n const droppableContext = useMemoObject({\n registerNode,\n deregisterNode,\n onMouseDown: mouseDownHandler,\n onTouchStart: touchStartHandler,\n });\n\n return (\n <DroppableContext.Provider value={droppableContext}>\n {(children as Function)({ ref, innerRef })}\n </DroppableContext.Provider>\n );\n};\n\nexport default Droppable;\n"],"mappings":"AAAA,OAAOA,KAAP,IAEEC,WAFF,EAGEC,SAHF,EAIEC,OAJF,EAKEC,MALF,QAQO,OARP;AASA,OAAOC,aAAP,MAA0B,4BAA1B;AACA,OAAOC,QAAP,MAIO,kBAJP;AAKA,OAAOC,cAAP,MAA2B,wBAA3B;AACA,SAASC,gBAAT,QAAiC,sBAAjC;AACA,OAAOC,cAAP,MAA2B,wBAA3B;;AAqCA,MAAMC,SAAmC,GAAG,CAAC;EAC3CC,iBAD2C;EAE3CC,EAF2C;EAG3CC,UAAU,GAAG,KAH8B;EAI3CC;AAJ2C,CAAD,KAKtC;EACJ;EACA,MAAMC,GAAG,GAAGX,MAAM,CAAiB,IAAjB,CAAlB,CAFI,CAGJ;;EACA,MAAMY,QAAQ,GAAGZ,MAAM,CAAiB,IAAjB,CAAvB,CAJI,CAKJ;;EACA,MAAMa,WAAW,GAAGR,cAAc,EAAlC;EACA,MAAMS,WAAW,GAAGf,OAAO,CAAC,MAAMS,EAAE,IAAIK,WAAb,EAA0B,CAACA,WAAD,EAAcL,EAAd,CAA1B,CAA3B,CAPI,CAQJ;;EACA,MAAMO,OAAO,GAAGf,MAAM,CACpB,IAAIE,QAAJ,CAAa;IACXM,EAAE,EAAEM,WADO;IAEXH,GAFW;IAGXC,QAHW;IAIXH,UAJW;IAKXF;EALW,CAAb,CADoB,CAAtB,CATI,CAmBJ;;EACAT,SAAS,CAAC,MAAM;IACdiB,OAAO,CAACC,OAAR,CAAgBR,EAAhB,GAAqBM,WAArB;EACD,CAFQ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,CAACS,CAAD,EAAId,OAAO,CAACC,OAAZ,EAAqBU,IAArB,CAAZ;EACD,CAHkC,EAInC,CAACN,YAAD,CAJmC,CAArC;EAOA,MAAMW,gBAAgB,GAAG9B,aAAa,CAAC;IACrCqB,YADqC;IAErCG,cAFqC;IAGrCN,WAAW,EAAES,gBAHwB;IAIrCR,YAAY,EAAEU;EAJuB,CAAD,CAAtC;EAOA,oBACE,oBAAC,gBAAD,CAAkB,QAAlB;IAA2B,KAAK,EAAEC;EAAlC,GACIrB,QAAD,CAAuB;IAAEC,GAAF;IAAOC;EAAP,CAAvB,CADH,CADF;AAKD,CApFD;;AAsFA,eAAeN,SAAf"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"names":["default","DragAndDrop","Droppable","Draggable"],"mappings":"AAAA,SAASA,OAAO,IAAIC,WAApB,QAAuC,eAAvC;AACA,SAASD,OAAO,IAAIE,SAApB,QAAqC,aAArC;AACA,SAASF,OAAO,IAAIG,SAApB,QAAqC,aAArC;AAEA,cAAc,eAAd;AACA,cAAc,aAAd;AACA,cAAc,aAAd","sourcesContent":["export { default as DragAndDrop } from './DragAndDrop';\nexport { default as Droppable } from './Droppable';\nexport { default as Draggable } from './Draggable';\n\nexport * from './DragAndDrop';\nexport * from './Droppable';\nexport * from './Draggable';\n"],"file":"index.js"}
1
+ {"version":3,"file":"index.js","names":["default","DragAndDrop","Droppable","Draggable"],"sources":["../../src/index.ts"],"sourcesContent":["export { default as DragAndDrop } from './DragAndDrop';\nexport { default as Droppable } from './Droppable';\nexport { default as Draggable } from './Draggable';\n\nexport * from './DragAndDrop';\nexport * from './Droppable';\nexport * from './Draggable';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,WAApB,QAAuC,eAAvC;AACA,SAASD,OAAO,IAAIE,SAApB,QAAqC,aAArC;AACA,SAASF,OAAO,IAAIG,SAApB,QAAqC,aAArC;AAEA,cAAc,eAAd;AACA,cAAc,aAAd;AACA,cAAc,aAAd"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/ListStore.ts"],"names":["ListStore","constructor","lists","add","list","push","remove","id","index","findIndex","item","splice","findByPosition","x","y","find","current","ref","rect","getBoundingClientRect","width","height"],"mappings":"AAEA;AACA;AACA;AACA,MAAMA,SAAN,CAAgB;AAGPC,EAAAA,WAAW,GAAG;AAAA,SAFbC,KAEa;AACnB,SAAKA,KAAL,GAAa,EAAb;AACD;AAED;AACF;AACA;;;AACSC,EAAAA,GAAG,CAACC,IAAD,EAAiB;AACzB,SAAKF,KAAL,CAAWG,IAAX,CAAgBD,IAAhB;AACD;AAED;AACF;AACA;;;AACSE,EAAAA,MAAM,CAACC,EAAD,EAAa;AACxB,UAAMC,KAAK,GAAG,KAAKN,KAAL,CAAWO,SAAX,CAAsBC,IAAD,IAAUA,IAAI,CAACH,EAAL,KAAYA,EAA3C,CAAd;AACA,QAAIC,KAAK,KAAK,CAAC,CAAf,EAAkB;AAClB,SAAKN,KAAL,CAAWS,MAAX,CAAkBH,KAAlB,EAAyB,CAAzB;AACD;AAED;AACF;AACA;;;AACSI,EAAAA,cAAc,CAACC,CAAD,EAAYC,CAAZ,EAAuB;AAC1C,WAAO,KAAKZ,KAAL,CAAWa,IAAX,CAAiBX,IAAD,IAAU;AAC/B,YAAM;AAAEY,QAAAA;AAAF,UAAcZ,IAAI,CAACa,GAAzB;AACA,UAAI,CAACD,OAAL,EAAc,OAAO,KAAP;AACd,YAAME,IAAI,GAAGF,OAAO,CAACG,qBAAR,EAAb;AACA,aACEN,CAAC,IAAIK,IAAI,CAACL,CAAV,IACAA,CAAC,IAAIK,IAAI,CAACL,CAAL,GAASK,IAAI,CAACE,KADnB,IAEAN,CAAC,IAAII,IAAI,CAACJ,CAFV,IAGAA,CAAC,IAAII,IAAI,CAACJ,CAAL,GAASI,IAAI,CAACG,MAJrB;AAMD,KAVM,CAAP;AAWD;;AAtCa;;AAyChB,eAAerB,SAAf","sourcesContent":["import NodeList from './NodeList';\n\n/**\n * Stores all the lists where the draggable items is located.\n */\nclass ListStore {\n private lists: NodeList[];\n\n public constructor() {\n this.lists = [];\n }\n\n /**\n * Adds a new list to the store.\n */\n public add(list: NodeList) {\n this.lists.push(list);\n }\n\n /**\n * Removes the list from the store.\n */\n public remove(id: string) {\n const index = this.lists.findIndex((item) => item.id === id);\n if (index === -1) return;\n this.lists.splice(index, 1);\n }\n\n /**\n * Returns the list in which the position is located.\n */\n public findByPosition(x: number, y: number) {\n return this.lists.find((list) => {\n const { current } = list.ref;\n if (!current) return false;\n const rect = current.getBoundingClientRect();\n return (\n x >= rect.x &&\n x <= rect.x + rect.width &&\n y >= rect.y &&\n y <= rect.y + rect.height\n );\n });\n }\n}\n\nexport default ListStore;\n"],"file":"ListStore.js"}
1
+ {"version":3,"file":"ListStore.js","names":["ListStore","constructor","lists","add","list","push","remove","id","index","findIndex","item","splice","findByPosition","x","y","find","current","ref","rect","getBoundingClientRect","width","height"],"sources":["../../../src/utils/ListStore.ts"],"sourcesContent":["import NodeList from './NodeList';\n\n/**\n * Stores all the lists where the draggable items is located.\n */\nclass ListStore {\n private lists: NodeList[];\n\n public constructor() {\n this.lists = [];\n }\n\n /**\n * Adds a new list to the store.\n */\n public add(list: NodeList) {\n this.lists.push(list);\n }\n\n /**\n * Removes the list from the store.\n */\n public remove(id: string) {\n const index = this.lists.findIndex((item) => item.id === id);\n if (index === -1) return;\n this.lists.splice(index, 1);\n }\n\n /**\n * Returns the list in which the position is located.\n */\n public findByPosition(x: number, y: number) {\n return this.lists.find((list) => {\n const { current } = list.ref;\n if (!current) return false;\n const rect = current.getBoundingClientRect();\n return (\n x >= rect.x &&\n x <= rect.x + rect.width &&\n y >= rect.y &&\n y <= rect.y + rect.height\n );\n });\n }\n}\n\nexport default ListStore;\n"],"mappings":"AAEA;AACA;AACA;AACA,MAAMA,SAAN,CAAgB;EAGPC,WAAW,GAAG;IAAA,KAFbC,KAEa;IACnB,KAAKA,KAAL,GAAa,EAAb;EACD;EAED;AACF;AACA;;;EACSC,GAAG,CAACC,IAAD,EAAiB;IACzB,KAAKF,KAAL,CAAWG,IAAX,CAAgBD,IAAhB;EACD;EAED;AACF;AACA;;;EACSE,MAAM,CAACC,EAAD,EAAa;IACxB,MAAMC,KAAK,GAAG,KAAKN,KAAL,CAAWO,SAAX,CAAsBC,IAAD,IAAUA,IAAI,CAACH,EAAL,KAAYA,EAA3C,CAAd;IACA,IAAIC,KAAK,KAAK,CAAC,CAAf,EAAkB;IAClB,KAAKN,KAAL,CAAWS,MAAX,CAAkBH,KAAlB,EAAyB,CAAzB;EACD;EAED;AACF;AACA;;;EACSI,cAAc,CAACC,CAAD,EAAYC,CAAZ,EAAuB;IAC1C,OAAO,KAAKZ,KAAL,CAAWa,IAAX,CAAiBX,IAAD,IAAU;MAC/B,MAAM;QAAEY;MAAF,IAAcZ,IAAI,CAACa,GAAzB;MACA,IAAI,CAACD,OAAL,EAAc,OAAO,KAAP;MACd,MAAME,IAAI,GAAGF,OAAO,CAACG,qBAAR,EAAb;MACA,OACEN,CAAC,IAAIK,IAAI,CAACL,CAAV,IACAA,CAAC,IAAIK,IAAI,CAACL,CAAL,GAASK,IAAI,CAACE,KADnB,IAEAN,CAAC,IAAII,IAAI,CAACJ,CAFV,IAGAA,CAAC,IAAII,IAAI,CAACJ,CAAL,GAASI,IAAI,CAACG,MAJrB;IAMD,CAVM,CAAP;EAWD;;AAtCa;;AAyChB,eAAerB,SAAf"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/NodeList.ts"],"names":["NodeList","constructor","props","id","ref","innerRef","horizontal","renderDraggedNode","head","tail","listeners","getHead","getTail","addToTheBeginning","setStyle","index","next","addToTheEnd","prev","addAfter","node","add","forEach","listener","headIndex","tailIndex","nextIndex","remove","addListener","callback","push","removeListener","findIndex","splice"],"mappings":"AAEA;AAEA;;AAyCA;AACA;AACA;AACA;AACA,MAAMA,QAAN,CAAe;AACb;AACF;AACA;;AAGE;AACF;AACA;;AAGE;AACF;AACA;AACA;;AAG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I,CAAC,CAAD,CAAJ,GAAU,IAAV;AACA,WAAKR,IAAL,GAAYQ,IAAZ;AACA;AACD;;AACD,QAAIE,IAAI,IAAI,CAACF,IAAb,EAAmB;AACjBE,MAAAA,IAAI,CAAC,CAAD,CAAJ,GAAU,IAAV;AACA,WAAKT,IAAL,GAAYS,IAAZ;AACA;AACD;;AACD,QAAIA,IAAI,IAAIF,IAAZ,EAAkB;AAChBE,MAAAA,IAAI,CAAC,CAAD,CAAJ,GAAUF,IAAV;AACAA,MAAAA,IAAI,CAAC,CAAD,CAAJ,GAAUE,IAAV;AACD;AACF;;AAEMU,EAAAA,WAAW,CAACC,QAAD,EAAuC;AACvD,SAAKnB,SAAL,CAAeoB,IAAf,CAAoBD,QAApB;AACD;;AAEME,EAAAA,cAAc,CAACF,QAAD,EAAuC;AAC1D,UAAMd,KAAK,GAAG,KAAKL,SAAL,CAAesB,SAAf,CAA0BT,QAAD,IAAcA,QAAQ,KAAKM,QAApD,CAAd;AACA,SAAKnB,SAAL,CAAeuB,MAAf,CAAsBlB,KAAtB,EAA6B,CAA7B;AACD;;AAhMY;;AAmMf,eAAef,QAAf","sourcesContent":["import React, { CSSProperties, RefObject } from 'react';\n\n/* eslint-disable @typescript-eslint/no-explicit-any,no-param-reassign,prefer-destructuring,no-constant-condition */\n\n// [prev, next, ref, setStyle, index, id]\nexport type Node =\n | [Node, Node, RefObject<any>, (style: CSSProperties) => void, number, string]\n | null;\n\nexport type ExistingNode = Exclude<Node, null>;\n\nexport interface NodeProps {\n ref: React.MutableRefObject<any>;\n setStyle: (style: CSSProperties) => void;\n index: number;\n id: string;\n}\n\ninterface RenderDraggedNodeProps {\n /**\n * The index of the dragged node.\n */\n index: number;\n /**\n * The ID of the dragged node.\n */\n id: string;\n /**\n * The style of the dragged node with position.\n */\n style: CSSProperties;\n}\n\nexport type RenderDraggedNode = (\n props: RenderDraggedNodeProps\n) => React.ReactNode;\n\ninterface InitProps {\n id: string;\n ref: RefObject<HTMLDivElement>;\n innerRef: RefObject<HTMLDivElement>;\n horizontal: boolean;\n renderDraggedNode: RenderDraggedNode;\n}\n\n/**\n * Stores all the draggable items in the list.\n * The structure of the doubly linked list is used.\n */\nclass NodeList {\n /**\n * The ID of the list.\n */\n public id: string;\n\n /**\n * The ref to the list.\n */\n public ref: RefObject<HTMLDivElement>;\n\n /**\n * The inner ref to the list.\n * Used by the virtual list.\n */\n public innerRef: RefObject<HTMLDivElement>;\n\n /**\n * Whether the list is horizontal.\n */\n public horizontal: boolean;\n\n /**\n * The callback that renders the dragged node.\n */\n public renderDraggedNode: RenderDraggedNode;\n\n /**\n * The head of draggable nodes.\n */\n private head: Node;\n\n /**\n * The tail of draggable nodes.\n */\n private tail: Node;\n\n /**\n * Listeners of node addition events.\n */\n private listeners: Array<(props: NodeProps) => void>;\n\n public constructor(props: InitProps) {\n this.id = props.id;\n this.ref = props.ref;\n this.innerRef = props.innerRef;\n this.horizontal = props.horizontal;\n this.renderDraggedNode = props.renderDraggedNode;\n this.head = null;\n this.tail = null;\n this.listeners = [];\n }\n\n public getHead() {\n return this.head;\n }\n\n public getTail() {\n return this.tail;\n }\n\n /**\n * Adds the node to the beginning.\n * TL: O(1).\n */\n private addToTheBeginning(props: NodeProps): ExistingNode {\n this.head = [\n null,\n this.head,\n props.ref,\n props.setStyle,\n props.index,\n props.id,\n ];\n const [, next] = this.head;\n if (next) next[0] = this.head; // Set the prev cursor of the next element\n if (!this.tail) this.tail = this.head;\n return this.head;\n }\n\n /**\n * Adds the node to the end.\n * TL: O(1).\n */\n private addToTheEnd(props: NodeProps): ExistingNode {\n this.tail = [\n this.tail,\n null,\n props.ref,\n props.setStyle,\n props.index,\n props.id,\n ];\n const [prev] = this.tail;\n if (prev) prev[1] = this.tail; // Set the next cursor of the prev element\n if (!this.head) this.head = this.tail;\n return this.tail;\n }\n\n /**\n * Adds the node after the specified one.\n * TL: O(1).\n */\n private static addAfter(node: ExistingNode, props: NodeProps): ExistingNode {\n node[1] = [node, node[1], props.ref, props.setStyle, props.index, props.id];\n if (node[1][1]) node[1][1][0] = node[1];\n return node[1];\n }\n\n /**\n * Adds a new node depends on its position.\n * Called when a new node is mounted.\n * TL: O(1) – add to the beginning or to the end, O(n) – add to the middle.\n */\n public add(props: NodeProps): ExistingNode {\n const { index } = props;\n\n // Run listeners\n this.listeners.forEach((listener) => listener(props));\n\n // Add the first node to the beginning\n if (!this.head || !this.tail) {\n return this.addToTheBeginning(props);\n }\n\n // Add the node to the beginning if it is located above the first one\n const [, , , , headIndex] = this.head;\n if (index < headIndex) {\n return this.addToTheBeginning(props);\n }\n\n // Add the node to the end if it is located below the last one\n const [, , , , tailIndex] = this.tail;\n if (index === tailIndex) {\n // The tail is the blank node\n const [prev] = this.tail;\n if (prev) {\n this.tail[4] += 1;\n return NodeList.addAfter(prev, props);\n }\n }\n if (index > tailIndex) {\n return this.addToTheEnd(props);\n }\n\n // Add the node after the one that is located above the current one\n let node = this.head;\n while (true) {\n const [, next] = node;\n if (!next) break;\n const [, , , , nextIndex] = next;\n if (index < nextIndex) break;\n node = next;\n }\n return NodeList.addAfter(node, props);\n }\n\n /**\n * Removes the existing node.\n * Called when the node is unmounted.\n * TL: O(1).\n */\n public remove(node: ExistingNode) {\n const [prev, next] = node;\n if (!prev && !next) {\n this.head = null;\n this.tail = null;\n return;\n }\n if (!prev && next) {\n next[0] = null;\n this.head = next;\n return;\n }\n if (prev && !next) {\n prev[1] = null;\n this.tail = prev;\n return;\n }\n if (prev && next) {\n prev[1] = next;\n next[0] = prev;\n }\n }\n\n public addListener(callback: (props: NodeProps) => void) {\n this.listeners.push(callback);\n }\n\n public removeListener(callback: (props: NodeProps) => void) {\n const index = this.listeners.findIndex((listener) => listener === callback);\n this.listeners.splice(index, 1);\n }\n}\n\nexport default NodeList;\n"],"file":"NodeList.js"}
1
+ {"version":3,"file":"NodeList.js","names":["NodeList","constructor","props","id","ref","innerRef","horizontal","renderDraggedNode","head","tail","listeners","getHead","getTail","addToTheBeginning","setStyle","index","next","addToTheEnd","prev","addAfter","node","add","forEach","listener","headIndex","tailIndex","nextIndex","remove","addListener","callback","push","removeListener","findIndex","splice"],"sources":["../../../src/utils/NodeList.ts"],"sourcesContent":["import React, { CSSProperties, RefObject } from 'react';\n\n/* eslint-disable @typescript-eslint/no-explicit-any,no-param-reassign,prefer-destructuring,no-constant-condition */\n\n// [prev, next, ref, setStyle, index, id]\nexport type Node =\n | [Node, Node, RefObject<any>, (style: CSSProperties) => void, number, string]\n | null;\n\nexport type ExistingNode = Exclude<Node, null>;\n\nexport interface NodeProps {\n ref: React.MutableRefObject<any>;\n setStyle: (style: CSSProperties) => void;\n index: number;\n id: string;\n}\n\ninterface RenderDraggedNodeProps {\n /**\n * The index of the dragged node.\n */\n index: number;\n /**\n * The ID of the dragged node.\n */\n id: string;\n /**\n * The style of the dragged node with position.\n */\n style: CSSProperties;\n}\n\nexport type RenderDraggedNode = (\n props: RenderDraggedNodeProps\n) => React.ReactNode;\n\ninterface InitProps {\n id: string;\n ref: RefObject<HTMLDivElement>;\n innerRef: RefObject<HTMLDivElement>;\n horizontal: boolean;\n renderDraggedNode: RenderDraggedNode;\n}\n\n/**\n * Stores all the draggable items in the list.\n * The structure of the doubly linked list is used.\n */\nclass NodeList {\n /**\n * The ID of the list.\n */\n public id: string;\n\n /**\n * The ref to the list.\n */\n public ref: RefObject<HTMLDivElement>;\n\n /**\n * The inner ref to the list.\n * Used by the virtual list.\n */\n public innerRef: RefObject<HTMLDivElement>;\n\n /**\n * Whether the list is horizontal.\n */\n public horizontal: boolean;\n\n /**\n * The callback that renders the dragged node.\n */\n public renderDraggedNode: RenderDraggedNode;\n\n /**\n * The head of draggable nodes.\n */\n private head: Node;\n\n /**\n * The tail of draggable nodes.\n */\n private tail: Node;\n\n /**\n * Listeners of node addition events.\n */\n private listeners: Array<(props: NodeProps) => void>;\n\n public constructor(props: InitProps) {\n this.id = props.id;\n this.ref = props.ref;\n this.innerRef = props.innerRef;\n this.horizontal = props.horizontal;\n this.renderDraggedNode = props.renderDraggedNode;\n this.head = null;\n this.tail = null;\n this.listeners = [];\n }\n\n public getHead() {\n return this.head;\n }\n\n public getTail() {\n return this.tail;\n }\n\n /**\n * Adds the node to the beginning.\n * TL: O(1).\n */\n private addToTheBeginning(props: NodeProps): ExistingNode {\n this.head = [\n null,\n this.head,\n props.ref,\n props.setStyle,\n props.index,\n props.id,\n ];\n const [, next] = this.head;\n if (next) next[0] = this.head; // Set the prev cursor of the next element\n if (!this.tail) this.tail = this.head;\n return this.head;\n }\n\n /**\n * Adds the node to the end.\n * TL: O(1).\n */\n private addToTheEnd(props: NodeProps): ExistingNode {\n this.tail = [\n this.tail,\n null,\n props.ref,\n props.setStyle,\n props.index,\n props.id,\n ];\n const [prev] = this.tail;\n if (prev) prev[1] = this.tail; // Set the next cursor of the prev element\n if (!this.head) this.head = this.tail;\n return this.tail;\n }\n\n /**\n * Adds the node after the specified one.\n * TL: O(1).\n */\n private static addAfter(node: ExistingNode, props: NodeProps): ExistingNode {\n node[1] = [node, node[1], props.ref, props.setStyle, props.index, props.id];\n if (node[1][1]) node[1][1][0] = node[1];\n return node[1];\n }\n\n /**\n * Adds a new node depends on its position.\n * Called when a new node is mounted.\n * TL: O(1) – add to the beginning or to the end, O(n) – add to the middle.\n */\n public add(props: NodeProps): ExistingNode {\n const { index } = props;\n\n // Run listeners\n this.listeners.forEach((listener) => listener(props));\n\n // Add the first node to the beginning\n if (!this.head || !this.tail) {\n return this.addToTheBeginning(props);\n }\n\n // Add the node to the beginning if it is located above the first one\n const [, , , , headIndex] = this.head;\n if (index < headIndex) {\n return this.addToTheBeginning(props);\n }\n\n // Add the node to the end if it is located below the last one\n const [, , , , tailIndex] = this.tail;\n if (index === tailIndex) {\n // The tail is the blank node\n const [prev] = this.tail;\n if (prev) {\n this.tail[4] += 1;\n return NodeList.addAfter(prev, props);\n }\n }\n if (index > tailIndex) {\n return this.addToTheEnd(props);\n }\n\n // Add the node after the one that is located above the current one\n let node = this.head;\n while (true) {\n const [, next] = node;\n if (!next) break;\n const [, , , , nextIndex] = next;\n if (index < nextIndex) break;\n node = next;\n }\n return NodeList.addAfter(node, props);\n }\n\n /**\n * Removes the existing node.\n * Called when the node is unmounted.\n * TL: O(1).\n */\n public remove(node: ExistingNode) {\n const [prev, next] = node;\n if (!prev && !next) {\n this.head = null;\n this.tail = null;\n return;\n }\n if (!prev && next) {\n next[0] = null;\n this.head = next;\n return;\n }\n if (prev && !next) {\n prev[1] = null;\n this.tail = prev;\n return;\n }\n if (prev && next) {\n prev[1] = next;\n next[0] = prev;\n }\n }\n\n public addListener(callback: (props: NodeProps) => void) {\n this.listeners.push(callback);\n }\n\n public removeListener(callback: (props: NodeProps) => void) {\n const index = this.listeners.findIndex((listener) => listener === callback);\n this.listeners.splice(index, 1);\n }\n}\n\nexport default NodeList;\n"],"mappings":"AAEA;AAEA;;AAyCA;AACA;AACA;AACA;AACA,MAAMA,QAAN,CAAe;EACb;AACF;AACA;;EAGE;AACF;AACA;;EAGE;AACF;AACA;AACA;;EAGE;AACF;AACA;;EAGE;AACF;AACA;;EAGE;AACF;AACA;;EAGE;AACF;AACA;;EAGE;AACF;AACA;EAGSC,WAAW,CAACC,KAAD,EAAmB;IAAA,KAtC9BC,EAsC8B;IAAA,KAjC9BC,GAiC8B;IAAA,KA3B9BC,QA2B8B;IAAA,KAtB9BC,UAsB8B;IAAA,KAjB9BC,iBAiB8B;IAAA,KAZ7BC,IAY6B;IAAA,KAP7BC,IAO6B;IAAA,KAF7BC,SAE6B;IACnC,KAAKP,EAAL,GAAUD,KAAK,CAACC,EAAhB;IACA,KAAKC,GAAL,GAAWF,KAAK,CAACE,GAAjB;IACA,KAAKC,QAAL,GAAgBH,KAAK,CAACG,QAAtB;IACA,KAAKC,UAAL,GAAkBJ,KAAK,CAACI,UAAxB;IACA,KAAKC,iBAAL,GAAyBL,KAAK,CAACK,iBAA/B;IACA,KAAKC,IAAL,GAAY,IAAZ;IACA,KAAKC,IAAL,GAAY,IAAZ;IACA,KA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1 @@
1
- {"version":3,"sources":["../../../src/utils/getElementOffset.ts"],"names":["getElementOffset","element","offsetLeft","offsetTop","el","offsetParent"],"mappings":"AAAA,MAAMA,gBAAgB,GAAIC,OAAD,IAA0B;AACjD,MAAIC,UAAU,GAAG,CAAjB;AACA,MAAIC,SAAS,GAAG,CAAhB;AACA,MAAIC,EAAsB,GAAGH,OAA7B;;AACA,SAAOG,EAAP,EAAW;AACTF,IAAAA,UAAU,IAAIE,EAAE,CAACF,UAAjB;AACAC,IAAAA,SAAS,IAAIC,EAAE,CAACD,SAAhB;AACAC,IAAAA,EAAE,GAAGA,EAAE,CAACC,YAAR;AACD;;AACD,SAAO;AAAEH,IAAAA,UAAF;AAAcC,IAAAA;AAAd,GAAP;AACD,CAVD;;AAYA,eAAeH,gBAAf","sourcesContent":["const getElementOffset = (element: HTMLElement) => {\n let offsetLeft = 0;\n let offsetTop = 0;\n let el: HTMLElement | null = element;\n while (el) {\n offsetLeft += el.offsetLeft;\n offsetTop += el.offsetTop;\n el = el.offsetParent as HTMLElement;\n }\n return { offsetLeft, offsetTop };\n};\n\nexport default getElementOffset;\n"],"file":"getElementOffset.js"}
1
+ {"version":3,"file":"getElementOffset.js","names":["getElementOffset","element","offsetLeft","offsetTop","el","offsetParent"],"sources":["../../../src/utils/getElementOffset.ts"],"sourcesContent":["const getElementOffset = (element: HTMLElement) => {\n let offsetLeft = 0;\n let offsetTop = 0;\n let el: HTMLElement | null = element;\n while (el) {\n offsetLeft += el.offsetLeft;\n offsetTop += el.offsetTop;\n el = el.offsetParent as HTMLElement;\n }\n return { offsetLeft, offsetTop };\n};\n\nexport default getElementOffset;\n"],"mappings":"AAAA,MAAMA,gBAAgB,GAAIC,OAAD,IAA0B;EACjD,IAAIC,UAAU,GAAG,CAAjB;EACA,IAAIC,SAAS,GAAG,CAAhB;EACA,IAAIC,EAAsB,GAAGH,OAA7B;;EACA,OAAOG,EAAP,EAAW;IACTF,UAAU,IAAIE,EAAE,CAACF,UAAjB;IACAC,SAAS,IAAIC,EAAE,CAACD,SAAhB;IACAC,EAAE,GAAGA,EAAE,CAACC,YAAR;EACD;;EACD,OAAO;IAAEH,UAAF;IAAcC;EAAd,CAAP;AACD,CAVD;;AAYA,eAAeH,gBAAf"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/getElementScroll.ts"],"names":["getElementScroll","element","scrollLeft","scrollTop","el","parentElement"],"mappings":"AAAA,MAAMA,gBAAgB,GAAIC,OAAD,IAA0B;AACjD,MAAIC,UAAU,GAAG,CAAjB;AACA,MAAIC,SAAS,GAAG,CAAhB;AACA,MAAIC,EAAsB,GAAGH,OAA7B;;AACA,SAAOG,EAAP,EAAW;AACTF,IAAAA,UAAU,IAAIE,EAAE,CAACF,UAAjB;AACAC,IAAAA,SAAS,IAAIC,EAAE,CAACD,SAAhB;AACAC,IAAAA,EAAE,GAAGA,EAAE,CAACC,aAAR;AACD;;AACD,SAAO;AAAEH,IAAAA,UAAF;AAAcC,IAAAA;AAAd,GAAP;AACD,CAVD;;AAYA,eAAeH,gBAAf","sourcesContent":["const getElementScroll = (element: HTMLElement) => {\n let scrollLeft = 0;\n let scrollTop = 0;\n let el: HTMLElement | null = element;\n while (el) {\n scrollLeft += el.scrollLeft;\n scrollTop += el.scrollTop;\n el = el.parentElement;\n }\n return { scrollLeft, scrollTop };\n};\n\nexport default getElementScroll;\n"],"file":"getElementScroll.js"}
1
+ {"version":3,"file":"getElementScroll.js","names":["getElementScroll","element","scrollLeft","scrollTop","el","parentElement"],"sources":["../../../src/utils/getElementScroll.ts"],"sourcesContent":["const getElementScroll = (element: HTMLElement) => {\n let scrollLeft = 0;\n let scrollTop = 0;\n let el: HTMLElement | null = element;\n while (el) {\n scrollLeft += el.scrollLeft;\n scrollTop += el.scrollTop;\n el = el.parentElement;\n }\n return { scrollLeft, scrollTop };\n};\n\nexport default getElementScroll;\n"],"mappings":"AAAA,MAAMA,gBAAgB,GAAIC,OAAD,IAA0B;EACjD,IAAIC,UAAU,GAAG,CAAjB;EACA,IAAIC,SAAS,GAAG,CAAhB;EACA,IAAIC,EAAsB,GAAGH,OAA7B;;EACA,OAAOG,EAAP,EAAW;IACTF,UAAU,IAAIE,EAAE,CAACF,UAAjB;IACAC,SAAS,IAAIC,EAAE,CAACD,SAAhB;IACAC,EAAE,GAAGA,EAAE,CAACC,aAAR;EACD;;EACD,OAAO;IAAEH,UAAF;IAAcC;EAAd,CAAP;AACD,CAVD;;AAYA,eAAeH,gBAAf"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/getNodeRect.ts"],"names":["getElementScroll","getElementOffset","getNodeRect","ref","current","parent","parentElement","width","height","getBoundingClientRect","offsetLeft","offsetTop","scrollLeft","scrollTop","left","top","right","bottom"],"mappings":"AACA,OAAOA,gBAAP,MAA6B,oBAA7B;AACA,OAAOC,gBAAP,MAA6B,oBAA7B;AAEA;AACA;AACA;;AACA,MAAMC,WAAW,GAAIC,GAAD,IAAiC;AACnD,MAAI,CAACA,GAAG,CAACC,OAAT,EAAkB,OAAO,IAAP;AAElB,QAAMC,MAAM,GAAGF,GAAG,CAACC,OAAJ,CAAYE,aAA3B;AACA,QAAM;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,MAAoBL,GAAG,CAACC,OAAJ,CAAYK,qBAAZ,EAA1B;AACA,QAAM;AAAEC,IAAAA,UAAF;AAAcC,IAAAA;AAAd,MAA4BV,gBAAgB,CAACE,GAAG,CAACC,OAAL,CAAlD;AACA,QAAM;AAAEQ,IAAAA,UAAF;AAAcC,IAAAA;AAAd,MAA4BR,MAAM,GACpCL,gBAAgB,CAACK,MAAD,CADoB,GAEpC;AAAEO,IAAAA,UAAU,EAAE,CAAd;AAAiBC,IAAAA,SAAS,EAAE;AAA5B,GAFJ;AAIA,QAAMC,IAAI,GAAGJ,UAAU,GAAGE,UAA1B;AACA,QAAMG,GAAG,GAAGJ,SAAS,GAAGE,SAAxB;AAEA,SAAO;AACLC,IAAAA,IADK;AAELC,IAAAA,GAFK;AAGLC,IAAAA,KAAK,EAAEF,IAAI,GAAGP,KAHT;AAILU,IAAAA,MAAM,EAAEF,GAAG,GAAGP;AAJT,GAAP;AAMD,CAnBD;;AAqBA,eAAeN,WAAf","sourcesContent":["import { RefObject } from 'react';\nimport getElementScroll from './getElementScroll';\nimport getElementOffset from './getElementOffset';\n\n/**\n * Computes the bounds of the existing node without considering transforms.\n */\nconst getNodeRect = (ref: RefObject<HTMLElement>) => {\n if (!ref.current) return null;\n\n const parent = ref.current.parentElement;\n const { width, height } = ref.current.getBoundingClientRect();\n const { offsetLeft, offsetTop } = getElementOffset(ref.current);\n const { scrollLeft, scrollTop } = parent\n ? getElementScroll(parent)\n : { scrollLeft: 0, scrollTop: 0 };\n\n const left = offsetLeft - scrollLeft;\n const top = offsetTop - scrollTop;\n\n return {\n left,\n top,\n right: left + width,\n bottom: top + height,\n };\n};\n\nexport default getNodeRect;\n"],"file":"getNodeRect.js"}
1
+ {"version":3,"file":"getNodeRect.js","names":["getElementScroll","getElementOffset","getNodeRect","ref","current","parent","parentElement","width","height","getBoundingClientRect","offsetLeft","offsetTop","scrollLeft","scrollTop","left","top","right","bottom"],"sources":["../../../src/utils/getNodeRect.ts"],"sourcesContent":["import { RefObject } from 'react';\nimport getElementScroll from './getElementScroll';\nimport getElementOffset from './getElementOffset';\n\n/**\n * Computes the bounds of the existing node without considering transforms.\n */\nconst getNodeRect = (ref: RefObject<HTMLElement>) => {\n if (!ref.current) return null;\n\n const parent = ref.current.parentElement;\n const { width, height } = ref.current.getBoundingClientRect();\n const { offsetLeft, offsetTop } = getElementOffset(ref.current);\n const { scrollLeft, scrollTop } = parent\n ? getElementScroll(parent)\n : { scrollLeft: 0, scrollTop: 0 };\n\n const left = offsetLeft - scrollLeft;\n const top = offsetTop - scrollTop;\n\n return {\n left,\n top,\n right: left + width,\n bottom: top + height,\n };\n};\n\nexport default getNodeRect;\n"],"mappings":"AACA,OAAOA,gBAAP,MAA6B,oBAA7B;AACA,OAAOC,gBAAP,MAA6B,oBAA7B;AAEA;AACA;AACA;;AACA,MAAMC,WAAW,GAAIC,GAAD,IAAiC;EACnD,IAAI,CAACA,GAAG,CAACC,OAAT,EAAkB,OAAO,IAAP;EAElB,MAAMC,MAAM,GAAGF,GAAG,CAACC,OAAJ,CAAYE,aAA3B;EACA,MAAM;IAAEC,KAAF;IAASC;EAAT,IAAoBL,GAAG,CAACC,OAAJ,CAAYK,qBAAZ,EAA1B;EACA,MAAM;IAAEC,UAAF;IAAcC;EAAd,IAA4BV,gBAAgB,CAACE,GAAG,CAACC,OAAL,CAAlD;EACA,MAAM;IAAEQ,UAAF;IAAcC;EAAd,IAA4BR,MAAM,GACpCL,gBAAgB,CAACK,MAAD,CADoB,GAEpC;IAAEO,UAAU,EAAE,CAAd;IAAiBC,SAAS,EAAE;EAA5B,CAFJ;EAIA,MAAMC,IAAI,GAAGJ,UAAU,GAAGE,UAA1B;EACA,MAAMG,GAAG,GAAGJ,SAAS,GAAGE,SAAxB;EAEA,OAAO;IACLC,IADK;IAELC,GAFK;IAGLC,KAAK,EAAEF,IAAI,GAAGP,KAHT;IAILU,MAAM,EAAEF,GAAG,GAAGP;EAJT,CAAP;AAMD,CAnBD;;AAqBA,eAAeN,WAAf"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/useAppendClassName.ts"],"names":["useEffect","useAppendClassName","ref","className","element","current","initClassName","trim"],"mappings":"AAAA,SAAoBA,SAApB,QAAqC,OAArC;AAEA;AACA;AACA;;AACA,MAAMC,kBAAkB,GAAG,CAACC,GAAD,EAA8BC,SAA9B,KAAoD;AAC7EH,EAAAA,SAAS,CAAC,MAAM;AACd,UAAMI,OAAO,GAAGF,GAAG,CAACG,OAApB;AACA,QAAI,CAACD,OAAL,EAAc,OAAO,MAAM,CAAE,CAAf;AAEd,UAAME,aAAa,GAAGF,OAAO,CAACD,SAA9B;AACAC,IAAAA,OAAO,CAACD,SAAR,GAAqB,GAAEG,aAAc,IAAGH,SAAU,EAA9B,CAAgCI,IAAhC,EAApB;AAEA,WAAO,MAAM;AACXH,MAAAA,OAAO,CAACD,SAAR,GAAoBG,aAApB;AACD,KAFD;AAGD,GAVQ,EAUN,CAACH,SAAD,EAAYD,GAAZ,CAVM,CAAT;AAWD,CAZD;;AAcA,eAAeD,kBAAf","sourcesContent":["import { RefObject, useEffect } from 'react';\n\n/**\n * Adds a new class name to the element.\n */\nconst useAppendClassName = (ref: RefObject<HTMLElement>, className: string) => {\n useEffect(() => {\n const element = ref.current;\n if (!element) return () => {};\n\n const initClassName = element.className;\n element.className = `${initClassName} ${className}`.trim();\n\n return () => {\n element.className = initClassName;\n };\n }, [className, ref]);\n};\n\nexport default useAppendClassName;\n"],"file":"useAppendClassName.js"}
1
+ {"version":3,"file":"useAppendClassName.js","names":["useEffect","useAppendClassName","ref","className","element","current","initClassName","trim"],"sources":["../../../src/utils/useAppendClassName.ts"],"sourcesContent":["import { RefObject, useEffect } from 'react';\n\n/**\n * Adds a new class name to the element.\n */\nconst useAppendClassName = (ref: RefObject<HTMLElement>, className: string) => {\n useEffect(() => {\n const element = ref.current;\n if (!element) return () => {};\n\n const initClassName = element.className;\n element.className = `${initClassName} ${className}`.trim();\n\n return () => {\n element.className = initClassName;\n };\n }, [className, ref]);\n};\n\nexport default useAppendClassName;\n"],"mappings":"AAAA,SAAoBA,SAApB,QAAqC,OAArC;AAEA;AACA;AACA;;AACA,MAAMC,kBAAkB,GAAG,CAACC,GAAD,EAA8BC,SAA9B,KAAoD;EAC7EH,SAAS,CAAC,MAAM;IACd,MAAMI,OAAO,GAAGF,GAAG,CAACG,OAApB;IACA,IAAI,CAACD,OAAL,EAAc,OAAO,MAAM,CAAE,CAAf;IAEd,MAAME,aAAa,GAAGF,OAAO,CAACD,SAA9B;IACAC,OAAO,CAACD,SAAR,GAAqB,GAAEG,aAAc,IAAGH,SAAU,EAA9B,CAAgCI,IAAhC,EAApB;IAEA,OAAO,MAAM;MACXH,OAAO,CAACD,SAAR,GAAoBG,aAApB;IACD,CAFD;EAGD,CAVQ,EAUN,CAACH,SAAD,EAAYD,GAAZ,CAVM,CAAT;AAWD,CAZD;;AAcA,eAAeD,kBAAf"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/useBlankNode.ts"],"names":["useCallback","useEffect","useRef","useBlankNode","props","draggedNode","targetList","initDraggedNodeRect","initDraggedNodeRectRef","blankNode","current","ref","list","initWidth","initHeight","div","document","createElement","style","width","height","minWidth","minHeight","parent","innerList","innerRef","getBoundingClientRect","position","left","horizontal","top","appendChild","tail","getTail","node","add","setStyle","index","id","removeBlankNode","blank","remove","blankNodeRef","parentElement","removeChild"],"mappings":"AAAA,SAASA,WAAT,EAAsBC,SAAtB,EAAiCC,MAAjC,QAA+C,OAA/C;;AAuBA;AACA;AACA;AACA;AACA,MAAMC,YAAY,GAAIC,KAAD,IAA8B;AACjD,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,UAAf;AAA2BC,IAAAA;AAA3B,MAAmDH,KAAzD;AACA,QAAMI,sBAAsB,GAAGN,MAAM,CAACK,mBAAD,CAArC;AACA,QAAME,SAAS,GAAGP,MAAM,CAAmB,IAAnB,CAAxB;AAEAD,EAAAA,SAAS,CAAC,MAAM;AACdO,IAAAA,sBAAsB,CAACE,OAAvB,GAAiCH,mBAAjC;AACD,GAFQ,EAEN,CAACA,mBAAD,CAFM,CAAT;AAIAN,EAAAA,SAAS,CAAC,MAAM;AACd,QACE,CAACI,WAAD,IACA,CAACC,UADD,IAEA,CAACA,UAAU,CAACK,GAAX,CAAeD,OAFhB,IAGAL,WAAW,CAACO,IAAZ,KAAqBN,UAHrB,IAIA,CAACE,sBAAsB,CAACE,OAL1B,EAME;AACA;AACD,KATa,CAWd;;;AACA,UAAM;AAAEG,MAAAA,SAAF;AAAaC,MAAAA;AAAb,QAA4BN,sBAAsB,CAACE,OAAzD;AACA,UAAMK,GAAG,GAAGC,QAAQ,CAACC,aAAT,CAAuB,KAAvB,CAAZ;AACAF,IAAA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AFC;AAGnBC,QAAAA,KAAK,EAAEL,IAAI,GAAGA,IAAI,CAAC,CAAD,CAAJ,GAAU,CAAb,GAAiB,CAHT;AAInBM,QAAAA,EAAE,EAAE;AAJe,OAAf;AAFY,KAApB;AASD,GA7CQ,EA6CN,CAACjC,WAAD,EAAcC,UAAd,CA7CM,CAAT;AA+CA,QAAMiC,eAAe,GAAGvC,WAAW,CAAC,MAAM;AACxC,UAAMwC,KAAK,GAAG/B,SAAS,CAACC,OAAxB;AACA,QAAI,CAAC8B,KAAL,EAAY;AACZ/B,IAAAA,SAAS,CAACC,OAAV,GAAoB,IAApB;AACA8B,IAAAA,KAAK,CAAC5B,IAAN,CAAW6B,MAAX,CAAkBD,KAAK,CAACN,IAAxB;AACA,UAAM,IAAKQ,YAAL,IAAqBF,KAAK,CAACN,IAAjC;AACA,QAAI,CAACM,KAAK,CAAC5B,IAAN,CAAWD,GAAX,CAAeD,OAAhB,IAA2B,CAACgC,YAAY,CAAChC,OAA7C,EAAsD;AACtD,UAAMa,MAAM,GAAGmB,YAAY,CAAChC,OAAb,CAAqBiC,aAApC;AACA,QAAIpB,MAAJ,EAAYA,MAAM,CAACqB,WAAP,CAAmBF,YAAY,CAAChC,OAAhC;AACb,GATkC,EAShC,EATgC,CAAnC,CAxDiD,CAmEjD;;AACAT,EAAAA,SAAS,CAAC,MAAM;AACd,QAAI,CAACI,WAAL,EAAkB,OAAO,MAAM,CAAE,CAAf;AAClB,WAAO,MAAMkC,eAAe,EAA5B;AACD,GAHQ,EAGN,CAAClC,WAAD,EAAckC,eAAd,CAHM,CAAT;AAKA,SAAOA,eAAP;AACD,CA1ED;;AA4EA,eAAepC,YAAf","sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\nimport NodeList, { ExistingNode } from './NodeList';\n\ninterface InitSize {\n initWidth: number;\n initHeight: number;\n}\n\ninterface DraggedNode {\n list: NodeList;\n}\n\ninterface UseBlankNodeProps {\n draggedNode: DraggedNode | null;\n targetList: NodeList | null;\n initDraggedNodeRect: InitSize | null;\n}\n\ninterface BlankNode {\n list: NodeList;\n node: ExistingNode;\n}\n\n/**\n * Appends the blank node to the list to increase the height of it.\n * Used when the dragged node is located inside another list.\n */\nconst useBlankNode = (props: UseBlankNodeProps) => {\n const { draggedNode, targetList, initDraggedNodeRect } = props;\n const initDraggedNodeRectRef = useRef(initDraggedNodeRect);\n const blankNode = useRef<BlankNode | null>(null);\n\n useEffect(() => {\n initDraggedNodeRectRef.current = initDraggedNodeRect;\n }, [initDraggedNodeRect]);\n\n useEffect(() => {\n if (\n !draggedNode ||\n !targetList ||\n !targetList.ref.current ||\n draggedNode.list === targetList ||\n !initDraggedNodeRectRef.current\n ) {\n return;\n }\n\n // Create a new blank div\n const { initWidth, initHeight } = initDraggedNodeRectRef.current;\n const div = document.createElement('div');\n div.style.width = `${initWidth}px`;\n div.style.height = `${initHeight}px`;\n div.style.minWidth = `${initWidth}px`;\n div.style.minHeight = `${initHeight}px`;\n\n let parent = targetList.ref.current;\n const innerList = targetList.innerRef.current;\n\n // The inner ref used only in the virtual list\n if (innerList) {\n const { width, height } = innerList.getBoundingClientRect();\n div.style.position = 'absolute';\n div.style.left = targetList.horizontal ? `${width}px` : '0px';\n div.style.top = targetList.horizontal ? '0px' : `${height}px`;\n parent = innerList;\n }\n\n // Append the blank div to increase the height of the list\n parent.appendChild(div);\n\n // Add the blank node to the node list\n const tail = targetList.getTail();\n blankNode.current = {\n list: targetList,\n node: targetList.add({\n ref: { current: div },\n setStyle: () => {},\n index: tail ? tail[4] + 1 : 0,\n id: 'blank',\n }),\n };\n }, [draggedNode, targetList]);\n\n const removeBlankNode = useCallback(() => {\n const blank = blankNode.current;\n if (!blank) return;\n blankNode.current = null;\n blank.list.remove(blank.node);\n const [, , blankNodeRef] = blank.node;\n if (!blank.list.ref.current || !blankNodeRef.current) return;\n const parent = blankNodeRef.current.parentElement;\n if (parent) parent.removeChild(blankNodeRef.current);\n }, []);\n\n // Remove the blank node if the dragged node has been dropped\n useEffect(() => {\n if (!draggedNode) return () => {};\n return () => removeBlankNode();\n }, [draggedNode, removeBlankNode]);\n\n return removeBlankNode;\n};\n\nexport default useBlankNode;\n"],"file":"useBlankNode.js"}
1
+ {"version":3,"file":"useBlankNode.js","names":["useCallback","useEffect","useRef","useBlankNode","props","draggedNode","targetList","initDraggedNodeRect","initDraggedNodeRectRef","blankNode","current","ref","list","initWidth","initHeight","div","document","createElement","style","width","height","minWidth","minHeight","parent","innerList","innerRef","getBoundingClientRect","position","left","horizontal","top","appendChild","tail","getTail","node","add","setStyle","index","id","removeBlankNode","blank","remove","blankNodeRef","parentElement","removeChild"],"sources":["../../../src/utils/useBlankNode.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\nimport NodeList, { ExistingNode } from './NodeList';\n\ninterface InitSize {\n initWidth: number;\n initHeight: number;\n}\n\ninterface DraggedNode {\n list: NodeList;\n}\n\ninterface UseBlankNodeProps {\n draggedNode: DraggedNode | null;\n targetList: NodeList | null;\n initDraggedNodeRect: InitSize | null;\n}\n\ninterface BlankNode {\n list: NodeList;\n node: ExistingNode;\n}\n\n/**\n * Appends the blank node to the list to increase the height of it.\n * Used when the dragged node is located inside another list.\n */\nconst useBlankNode = (props: UseBlankNodeProps) => {\n const { draggedNode, targetList, initDraggedNodeRect } = props;\n const initDraggedNodeRectRef = useRef(initDraggedNodeRect);\n const blankNode = useRef<BlankNode | null>(null);\n\n useEffect(() => {\n initDraggedNodeRectRef.current = initDraggedNodeRect;\n }, [initDraggedNodeRect]);\n\n useEffect(() => {\n if (\n !draggedNode ||\n !targetList ||\n !targetList.ref.current ||\n draggedNode.list === targetList ||\n !initDraggedNodeRectRef.current\n ) {\n return;\n }\n\n // Create a new blank div\n const { initWidth, initHeight } = initDraggedNodeRectRef.current;\n const div = document.createElement('div');\n div.style.width = `${initWidth}px`;\n div.style.height = `${initHeight}px`;\n div.style.minWidth = `${initWidth}px`;\n div.style.minHeight = `${initHeight}px`;\n\n let parent = targetList.ref.current;\n const innerList = targetList.innerRef.current;\n\n // The inner ref used only in the virtual list\n if (innerList) {\n const { width, height } = innerList.getBoundingClientRect();\n div.style.position = 'absolute';\n div.style.left = targetList.horizontal ? `${width}px` : '0px';\n div.style.top = targetList.horizontal ? '0px' : `${height}px`;\n parent = innerList;\n }\n\n // Append the blank div to increase the height of the list\n parent.appendChild(div);\n\n // Add the blank node to the node list\n const tail = targetList.getTail();\n blankNode.current = {\n list: targetList,\n node: targetList.add({\n ref: { current: div },\n setStyle: () => {},\n index: tail ? tail[4] + 1 : 0,\n id: 'blank',\n }),\n };\n }, [draggedNode, targetList]);\n\n const removeBlankNode = useCallback(() => {\n const blank = blankNode.current;\n if (!blank) return;\n blankNode.current = null;\n blank.list.remove(blank.node);\n const [, , blankNodeRef] = blank.node;\n if (!blank.list.ref.current || !blankNodeRef.current) return;\n const parent = blankNodeRef.current.parentElement;\n if (parent) parent.removeChild(blankNodeRef.current);\n }, []);\n\n // Remove the blank node if the dragged node has been dropped\n useEffect(() => {\n if (!draggedNode) return () => {};\n return () => removeBlankNode();\n }, [draggedNode, removeBlankNode]);\n\n return removeBlankNode;\n};\n\nexport default useBlankNode;\n"],"mappings":"AAAA,SAASA,WAAT,EAAsBC,SAAtB,EAAiCC,MAAjC,QAA+C,OAA/C;;AAuBA;AACA;AACA;AACA;AACA,MAAMC,YAAY,GAAIC,KAAD,IAA8B;EACjD,MAAM;IAAEC,WAAF;IAAeC,UAAf;IAA2BC;EAA3B,IAAmDH,KAAzD;EACA,MAAMI,sBAAsB,GAAGN,MAAM,CAACK,mBAAD,CAArC;EACA,MAAME,SAAS,GAAGP,MAAM,CAAmB,IAAnB,CAAxB;EAEAD,SAAS,CAAC,MAAM;IACdO,sBAAsB,CAACE,OAAvB,GAAiCH,mBAAjC;EACD,CAFQ,EAEN,CAACA,mBAAD,CAFM,CAAT;EAIAN,SAAS,CAAC,MAAM;IACd,IACE,CAACI,WAAD,IACA,CAACC,UADD,IAEA,CAACA,UAAU,CAACK,GAAX,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ADY;MAElB4B,IAAI,EAAE5B,UAAU,CAAC6B,GAAX,CAAe;QACnBxB,GAAG,EAAE;UAAED,OAAO,EAAEK;QAAX,CADc;QAEnBqB,QAAQ,EAAE,MAAM,CAAE,CAFC;QAGnBC,KAAK,EAAEL,IAAI,GAAGA,IAAI,CAAC,CAAD,CAAJ,GAAU,CAAb,GAAiB,CAHT;QAInBM,EAAE,EAAE;MAJe,CAAf;IAFY,CAApB;EASD,CA7CQ,EA6CN,CAACjC,WAAD,EAAcC,UAAd,CA7CM,CAAT;EA+CA,MAAMiC,eAAe,GAAGvC,WAAW,CAAC,MAAM;IACxC,MAAMwC,KAAK,GAAG/B,SAAS,CAACC,OAAxB;IACA,IAAI,CAAC8B,KAAL,EAAY;IACZ/B,SAAS,CAACC,OAAV,GAAoB,IAApB;IACA8B,KAAK,CAAC5B,IAAN,CAAW6B,MAAX,CAAkBD,KAAK,CAACN,IAAxB;IACA,MAAM,IAAKQ,YAAL,IAAqBF,KAAK,CAACN,IAAjC;IACA,IAAI,CAACM,KAAK,CAAC5B,IAAN,CAAWD,GAAX,CAAeD,OAAhB,IAA2B,CAACgC,YAAY,CAAChC,OAA7C,EAAsD;IACtD,MAAMa,MAAM,GAAGmB,YAAY,CAAChC,OAAb,CAAqBiC,aAApC;IACA,IAAIpB,MAAJ,EAAYA,MAAM,CAACqB,WAAP,CAAmBF,YAAY,CAAChC,OAAhC;EACb,CATkC,EAShC,EATgC,CAAnC,CAxDiD,CAmEjD;;EACAT,SAAS,CAAC,MAAM;IACd,IAAI,CAACI,WAAL,EAAkB,OAAO,MAAM,CAAE,CAAf;IAClB,OAAO,MAAMkC,eAAe,EAA5B;EACD,CAHQ,EAGN,CAAClC,WAAD,EAAckC,eAAd,CAHM,CAAT;EAKA,OAAOA,eAAP;AACD,CA1ED;;AA4EA,eAAepC,YAAf"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/useDragAndDrop.ts"],"names":["React","useContext","DragAndDropContext","createContext","registerList","deregisterList","onMouseDown","onTouchStart","nodeClassName","useDragAndDrop"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,UAAhB,QAA0D,OAA1D;AAoBA,OAAO,MAAMC,kBAAkB,gBAAGF,KAAK,CAACG,aAAN,CAA6C;AAC7EC,EAAAA,YAAY,EAAE,MAAM,CAAE,CADuD;AAE7EC,EAAAA,cAAc,EAAE,MAAM,CAAE,CAFqD;AAG7EC,EAAAA,WAAW,EAAE,MAAM,CAAE,CAHwD;AAI7EC,EAAAA,YAAY,EAAE,MAAM,CAAE,CAJuD;AAK7EC,EAAAA,aAAa,EAAE;AAL8D,CAA7C,CAA3B;;AAQP,MAAMC,cAAc,GAAG,MACrBR,UAAU,CAACC,kBAAD,CADZ;;AAGA,eAAeO,cAAf","sourcesContent":["import React, { useContext, MouseEvent, TouchEvent } from 'react';\nimport { Position } from '@os-design/use-drag';\nimport NodeList, { ExistingNode } from './NodeList';\n\nexport interface SetDraggedNodeProps {\n list: NodeList;\n node: ExistingNode;\n position: Position;\n}\n\ntype NodeEventHandler<T> = (e: T, list: NodeList, node: ExistingNode) => void;\n\ninterface DragAndDropContextProps {\n registerList: (list: NodeList) => void;\n deregisterList: (id: string) => void;\n onMouseDown: NodeEventHandler<MouseEvent>;\n onTouchStart: NodeEventHandler<TouchEvent>;\n nodeClassName: string;\n}\n\nexport const DragAndDropContext = React.createContext<DragAndDropContextProps>({\n registerList: () => {},\n deregisterList: () => {},\n onMouseDown: () => {},\n onTouchStart: () => {},\n nodeClassName: '',\n});\n\nconst useDragAndDrop = (): DragAndDropContextProps =>\n useContext(DragAndDropContext);\n\nexport default useDragAndDrop;\n"],"file":"useDragAndDrop.js"}
1
+ {"version":3,"file":"useDragAndDrop.js","names":["React","useContext","DragAndDropContext","createContext","registerList","deregisterList","onMouseDown","onTouchStart","nodeClassName","useDragAndDrop"],"sources":["../../../src/utils/useDragAndDrop.ts"],"sourcesContent":["import React, { useContext, MouseEvent, TouchEvent } from 'react';\nimport { Position } from '@os-design/use-drag';\nimport NodeList, { ExistingNode } from './NodeList';\n\nexport interface SetDraggedNodeProps {\n list: NodeList;\n node: ExistingNode;\n position: Position;\n}\n\ntype NodeEventHandler<T> = (e: T, list: NodeList, node: ExistingNode) => void;\n\ninterface DragAndDropContextProps {\n registerList: (list: NodeList) => void;\n deregisterList: (id: string) => void;\n onMouseDown: NodeEventHandler<MouseEvent>;\n onTouchStart: NodeEventHandler<TouchEvent>;\n nodeClassName: string;\n}\n\nexport const DragAndDropContext = React.createContext<DragAndDropContextProps>({\n registerList: () => {},\n deregisterList: () => {},\n onMouseDown: () => {},\n onTouchStart: () => {},\n nodeClassName: '',\n});\n\nconst useDragAndDrop = (): DragAndDropContextProps =>\n useContext(DragAndDropContext);\n\nexport default useDragAndDrop;\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,UAAhB,QAA0D,OAA1D;AAoBA,OAAO,MAAMC,kBAAkB,gBAAGF,KAAK,CAACG,aAAN,CAA6C;EAC7EC,YAAY,EAAE,MAAM,CAAE,CADuD;EAE7EC,cAAc,EAAE,MAAM,CAAE,CAFqD;EAG7EC,WAAW,EAAE,MAAM,CAAE,CAHwD;EAI7EC,YAAY,EAAE,MAAM,CAAE,CAJuD;EAK7EC,aAAa,EAAE;AAL8D,CAA7C,CAA3B;;AAQP,MAAMC,cAAc,GAAG,MACrBR,UAAU,CAACC,kBAAD,CADZ;;AAGA,eAAeO,cAAf"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/useDragEffect.ts"],"names":["useCallback","useEffect","useMemo","useRef","useThrottle","useEvent","getElementScroll","useTargetList","useInitRect","useInitScrollOffset","useGetNodeStyle","useMoveNode","getNodeRect","useBlankNode","HIDDEN_NODE_STYLE","opacity","pointerEvents","createEmptyNode","prev","next","current","useDragEffect","props","draggedNode","cursorPosition","listStoreRef","onDragEnd","targetRef","targetNodeRef","onDragEndRef","initDraggedNodeRect","node","undefined","initDraggedNodeListScrollOffset","list","ref","position","x","y","initWidth","initHeight","targetList","getNodeStyle","moveNode","setTargetNode","nodeIndex","nodeId","listId","id","index","clearTargetNode","getDraggedNodePos","initX","initY","initScrollLeft","initScrollTop","scrollLeft","scrollTop","getDraggedNodePosRef","draggedNodeSetStyle","removeBlankNode","updateTargetNode","prevTargetNode","startNode","direction","destination","isAnotherList","tail","getTail","axis","horizontal","prevTargetNodeRef","draggedNodePos","isDraggingUp","head","getHead","prevTargetNodeRect","startRectProp","isMoveUp","throttledUpdateTargetNode","window","draggedNodeIndex","targetNode","nodeSetStyle","targetNodeIndex","targetNodeSetStyle","update","nodeProps","setStyle","addListener","removeListener","target","draggedNodeId","dragged"],"mappings":"AACA,SAGEA,WAHF,EAIEC,SAJF,EAKEC,OALF,EAMEC,MANF,QAOO,OAPP;AAQA,OAAOC,WAAP,MAAwB,yBAAxB;AACA,OAAOC,QAAP,MAAqB,sBAArB;AAGA,OAAOC,gBAAP,MAA6B,oBAA7B;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,OAAOC,WAAP,MAAwB,eAAxB;AACA,OAAOC,mBAAP,MAAgC,uBAAhC;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AACA,OAAOC,WAAP,MAAwB,eAAxB;AACA,OAAOC,WAAP,MAAwB,eAAxB;AACA,OAAOC,YAAP,MAAyB,gBAAzB;AA+BA,MAAMC,iBAAgC,GAAG;AACvCC,EAAAA,OAAO,EAAE,CAD8B;AAEvCC,EAAAA,aAAa,EAAE;AAFwB,CAAzC;;AAKA,MAAMC,eAAe,GAAG,CAAC;AACvBC,EAAAA,IAAI,GAAG,IADgB;AAEvBC,EAAAA,IAAI,GAAG;AAFgB,CAAD,KAMJ,CAACD,IAAD,EAAOC,IAAP,EAAa;AAAEC,EAAAA,OAAO,EAAE;AAAX,CAAb,EAAgC,MAAM,CAAE,CAAxC,EAA0C,CAAC,CAA3C,EAA8C,IAA9C,CANpB;AAQA;;;AAEA,MAAMC,aAAa,GAAIC,KAAD,IAA+B;AACnD,QAAM;AAAEC,IA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C,UAAU,CAACiD,cAAX,CAA0BJ,MAA1B,CAAb;AACD,GAlBQ,EAkBN,CAAC/D,WAAD,EAAcmB,YAAd,EAA4BD,UAA5B,CAlBM,CAAT,CAhYmD,CAoZnD;;AACAxC,EAAAA,SAAS,CAAC,MAAM;AACd,QAAI,CAACsB,WAAL,EAAkB,OAAO,MAAM,CAAE,CAAf;AAClB,WAAO,MAAM;AACX;AACA,YAAMoE,MAAM,GAAGhE,SAAS,CAACP,OAAzB;AACA,UAAI,CAACuE,MAAL,EAAa;AACb,YAAM,MAASV,gBAAT,EAA2BW,aAA3B,IAA4CrE,WAAW,CAACQ,IAA9D;AACA,YAAM8D,OAAO,GAAG;AACd9C,QAAAA,MAAM,EAAExB,WAAW,CAACW,IAAZ,CAAiBc,EADX;AAEdC,QAAAA,KAAK,EAAEgC,gBAFO;AAGdjC,QAAAA,EAAE,EAAE4C;AAHU,OAAhB;AAKA,UAAIC,OAAO,CAAC7C,EAAR,KAAe2C,MAAM,CAAC3C,EAAtB,IAA4B6C,OAAO,CAAC5C,KAAR,KAAkB0C,MAAM,CAAC1C,KAAzD,EAAgE;AAChEpB,MAAAA,YAAY,CAACT,OAAb,CAAqByE,OAArB,EAA8BF,MAA9B;AACD,KAZD;AAaD,GAfQ,EAeN,CAACpE,WAAD,CAfM,CAAT;AAgBD,CAraD;;AAuaA,eAAeF,aAAf","sourcesContent":["import { Position } from '@os-design/use-drag';\nimport {\n CSSProperties,\n RefObject,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from 'react';\nimport useThrottle from '@os-design/use-throttle';\nimport useEvent from '@os-design/use-event';\nimport NodeList, { ExistingNode, Node, NodeProps } from './NodeList';\nimport ListStore from './ListStore';\nimport getElementScroll from './getElementScroll';\nimport useTargetList from './useTargetList';\nimport useInitRect from './useInitRect';\nimport useInitScrollOffset from './useInitScrollOffset';\nimport useGetNodeStyle from './useGetNodeStyle';\nimport useMoveNode from './useMoveNode';\nimport getNodeRect from './getNodeRect';\nimport useBlankNode from './useBlankNode';\n\nexport interface DraggedNode {\n list: NodeList;\n node: ExistingNode;\n position: Position;\n}\n\ninterface TargetNode {\n list: NodeList;\n node: ExistingNode;\n}\n\nexport interface ItemLocation {\n listId: string;\n index: number;\n id: string;\n}\n\nexport type DragEndHandler = (\n dragged: ItemLocation,\n target: ItemLocation\n) => void;\n\ninterface UseDragEffectProps {\n draggedNode: DraggedNode | null;\n cursorPosition: Position;\n listStoreRef: RefObject<ListStore>;\n onDragEnd: DragEndHandler;\n}\n\nconst HIDDEN_NODE_STYLE: CSSProperties = {\n opacity: 0,\n pointerEvents: 'none',\n};\n\nconst createEmptyNode = ({\n prev = null,\n next = null,\n}: {\n prev?: Node;\n next?: Node;\n}): ExistingNode => [prev, next, { current: null }, () => {}, -1, 'id'];\n\n/* eslint-disable no-constant-condition */\n\nconst useDragEffect = (props: UseDragEffectProps) => {\n const { draggedNode, cursorPosition, listStoreRef, onDragEnd } = props;\n\n const targetRef = useRef<ItemLocation | null>(null);\n const targetNodeRef = useRef<TargetNode | null>(draggedNode);\n\n useEffect(() => {\n targetNodeRef.current = draggedNode;\n }, [draggedNode]);\n\n const onDragEndRef = useRef(onDragEnd);\n useEffect(() => {\n onDragEndRef.current = onDragEnd;\n }, [onDragEnd]);\n\n // The initial bounds of the dragged node.\n // We can't read the bounds of the dragged node on the fly because the node can be unmounted in the virtual list.\n const initDraggedNodeRect = useInitRect(\n draggedNode ? draggedNode.node[2] : undefined\n );\n\n // The initial scroll position of the list where the dragged node is located.\n // Used to detect the actual position of the dragged node. The purpose is the same as with initDraggedNodeRect.\n const initDraggedNodeListScrollOffset = useInitScrollOffset(\n draggedNode ? draggedNode.list.ref : undefined\n );\n\n // The central position of the dragged node\n const position = useMemo(() => {\n if (!draggedNode || !initDraggedNodeRect) return null;\n const { x, y } = cursorPosition;\n const { initWidth, initHeight } = initDraggedNodeRect;\n return {\n x: x - draggedNode.position.x + initWidth / 2,\n y: y - draggedNode.position.y + initHeight / 2,\n };\n }, [cursorPosition, draggedNode, initDraggedNodeRect]);\n\n // The list in which the cursor is located\n const targetList = useTargetList(position, listStoreRef);\n\n // Returns the style for moving the node in the specified direction\n const getNodeStyle = useGetNodeStyle(initDraggedNodeRect);\n\n // Moves the node up or down\n const moveNode = useMoveNode({ position, draggedNode, getNodeStyle });\n\n const setTargetNode = useCallback((list: NodeList, node: ExistingNode) => {\n const [, , , , nodeIndex, nodeId] = node;\n targetNodeRef.current = { list, node };\n targetRef.current = {\n listId: list.id,\n index: nodeIndex,\n id: nodeId,\n };\n }, []);\n\n const clearTargetNode = useCallback(() => {\n targetNodeRef.current = null;\n targetRef.current = null;\n }, []);\n\n // Returns the central position of the dragged node in the list\n const getDraggedNodePos = useCallback(() => {\n if (\n !targetList ||\n !targetList.ref.current ||\n !initDraggedNodeRect ||\n !initDraggedNodeListScrollOffset\n ) {\n return null;\n }\n const { initX, initY, initWidth, initHeight } = initDraggedNodeRect;\n const { initScrollLeft, initScrollTop } = initDraggedNodeListScrollOffset;\n const { scrollLeft, scrollTop } = getElementScroll(targetList.ref.current);\n return {\n x: initX + initWidth / 2 + initScrollLeft - scrollLeft,\n y: initY + initHeight / 2 + initScrollTop - scrollTop,\n };\n }, [initDraggedNodeListScrollOffset, initDraggedNodeRect, targetList]);\n\n const getDraggedNodePosRef = useRef(getDraggedNodePos);\n useEffect(() => {\n getDraggedNodePosRef.current = getDraggedNodePos;\n }, [getDraggedNodePos]);\n\n // Hide the dragged node\n useEffect(() => {\n if (!draggedNode) return () => {};\n const [, , , draggedNodeSetStyle] = draggedNode.node;\n draggedNodeSetStyle(HIDDEN_NODE_STYLE);\n return () => draggedNodeSetStyle({});\n }, [draggedNode]);\n\n // Append the blank node to the list to increase the height of it.\n // Used when the dragged node is located inside another list.\n const removeBlankNode = useBlankNode({\n draggedNode,\n targetList,\n initDraggedNodeRect,\n });\n\n const updateTargetNode = useCallback(() => {\n if (!draggedNode) return;\n const prevTargetNode = targetNodeRef.current; // The last updated node\n\n // Dragging outside the origin list\n if (\n prevTargetNode &&\n prevTargetNode.list === draggedNode.list &&\n targetList !== draggedNode.list\n ) {\n moveNode({\n list: prevTargetNode.list,\n startNode: prevTargetNode.node,\n direction: 'down',\n destination: 'end',\n });\n clearTargetNode();\n }\n\n // Dragging outside another list\n if (\n prevTargetNode &&\n prevTargetNode.list !== draggedNode.list &&\n targetList !== prevTargetNode.list\n ) {\n moveNode({\n list: prevTargetNode.list,\n startNode: prevTargetNode.node,\n direction: 'down',\n destination: 'end',\n isAnotherList: true,\n });\n removeBlankNode();\n clearTargetNode();\n }\n\n // Dragging inside the origin list\n if (!prevTargetNode && targetList === draggedNode.list) {\n const tail = targetList.getTail();\n if (!tail) return;\n const node = moveNode({\n list: targetList,\n startNode: tail,\n direction: 'up',\n destination: 'cursor',\n });\n setTargetNode(targetList, node);\n return;\n }\n\n // Dragging inside another list\n if (\n targetList &&\n targetList !== draggedNode.list &&\n (!prevTargetNode || prevTargetNode.list !== targetList)\n ) {\n const tail = targetList.getTail();\n if (!tail) return;\n const node = moveNode({\n list: targetList,\n startNode: tail,\n direction: 'up',\n destination: 'cursor',\n isAnotherList: true,\n });\n setTargetNode(targetList, node);\n return;\n }\n\n // Dragging in the origin list\n if (\n prevTargetNode &&\n prevTargetNode.list === draggedNode.list &&\n targetList === draggedNode.list\n ) {\n const axis = targetList.horizontal ? 'x' : 'y';\n const [, , prevTargetNodeRef, ,] = prevTargetNode.node;\n if (!prevTargetNodeRef.current) {\n // The target node was unmounted. It happens when the virtual list is used.\n // If the cursor is above the dragged node, we need to move the nodes down from the tail to the node where\n // the cursor is located. Otherwise, we need to move the nodes up from the head to the node where the cursor\n // is located.\n const draggedNodePos = getDraggedNodePosRef.current();\n if (!position || !draggedNodePos) return;\n const isDraggingUp = position[axis] < draggedNodePos[axis];\n if (isDraggingUp) {\n const tail = targetList.getTail();\n if (!tail || !tail[2].current) return;\n const node = moveNode({\n list: targetList,\n startNode: createEmptyNode({ prev: tail }),\n direction: 'up',\n destination: 'cursor',\n });\n setTargetNode(targetList, node);\n } else {\n const head = targetList.getHead();\n if (!head || !head[2].current) return;\n const node = moveNode({\n list: targetList,\n startNode: createEmptyNode({ next: head }),\n direction: 'down',\n destination: 'cursor',\n });\n setTargetNode(targetList, node);\n }\n return;\n }\n const prevTargetNodeRect = getNodeRect(prevTargetNode.node[2]);\n const startRectProp = targetList.horizontal ? 'left' : 'top';\n if (!position || !prevTargetNodeRect) return;\n const isMoveUp = position[axis] < prevTargetNodeRect[startRectProp];\n const node = isMoveUp\n ? moveNode({\n list: targetList,\n startNode: prevTargetNode.node,\n direction: 'up',\n destination: 'cursor',\n })\n : moveNode({\n list: targetList,\n startNode: prevTargetNode.node,\n direction: 'down',\n destination: 'cursor',\n });\n setTargetNode(targetList, node);\n return;\n }\n\n // Dragging in another list\n if (\n targetList &&\n targetList !== draggedNode.list &&\n prevTargetNode &&\n prevTargetNode.list === targetList\n ) {\n const axis = targetList.horizontal ? 'x' : 'y';\n const prevTargetNodeRect = getNodeRect(prevTargetNode.node[2]);\n const startRectProp = targetList.horizontal ? 'left' : 'top';\n if (!position || !prevTargetNodeRect) return;\n const isMoveUp = position[axis] < prevTargetNodeRect[startRectProp];\n const node = isMoveUp\n ? moveNode({\n list: targetList,\n startNode: prevTargetNode.node,\n direction: 'up',\n destination: 'cursor',\n isAnotherList: true,\n })\n : moveNode({\n list: targetList,\n startNode: prevTargetNode.node,\n direction: 'down',\n destination: 'cursor',\n isAnotherList: true,\n });\n setTargetNode(targetList, node);\n }\n }, [\n draggedNode,\n targetList,\n moveNode,\n clearTargetNode,\n removeBlankNode,\n setTargetNode,\n position,\n ]);\n\n // Update the target node if either the position or the target list has been changed\n useEffect(() => {\n updateTargetNode();\n }, [updateTargetNode]);\n\n // Update the target node if the target list has been scrolled\n const [throttledUpdateTargetNode] = useThrottle(updateTargetNode, 100);\n useEvent(\n (targetList ? targetList.ref : undefined) as unknown as EventTarget,\n 'scroll',\n throttledUpdateTargetNode\n );\n useEvent(window, 'scroll', throttledUpdateTargetNode);\n\n // Reset styles of the affected nodes when the dragged node was dropped\n useEffect(() => {\n if (!draggedNode) return () => {};\n const [, , , , draggedNodeIndex] = draggedNode.node;\n return () => {\n const targetNode = targetNodeRef.current;\n\n // If the dragged node was outside the origin list, reset the styles for the nodes,\n // starting at the tail and ending with the dragged node in the origin list.\n if (!targetNode || targetNode.list !== draggedNode.list) {\n const tail = draggedNode.list.getTail();\n if (tail) {\n let node = tail;\n while (true) {\n const [prev, , , nodeSetStyle, nodeIndex] = node;\n nodeSetStyle({});\n if (!prev || nodeIndex <= draggedNodeIndex) break;\n node = prev;\n }\n }\n }\n\n // If the dragged node was inside another list, reset the styles for the nodes,\n // starting at the tail and ending with the dragged node in the target list.\n if (targetNode && targetNode.list !== draggedNode.list) {\n const tail = targetNode.list.getTail();\n const [, , , , targetNodeIndex] = targetNode.node;\n if (tail) {\n let node = tail;\n while (true) {\n const [prev, , , nodeSetStyle, nodeIndex] = node;\n nodeSetStyle({});\n if (!prev || nodeIndex <= targetNodeIndex) break;\n node = prev;\n }\n }\n }\n\n // If the dragged node was moved inside the origin list, reset the styles for the nodes,\n // starting with target node and ending with the dragged node.\n if (targetNode && targetNode.list === draggedNode.list) {\n const [, , , targetNodeSetStyle, targetNodeIndex] = targetNode.node;\n if (targetNodeIndex > draggedNodeIndex) {\n let { node } = targetNode;\n while (true) {\n const [prev, , , nodeSetStyle, nodeIndex] = node;\n nodeSetStyle({});\n if (!prev || nodeIndex <= draggedNodeIndex) break;\n node = prev;\n }\n } else if (targetNodeIndex < draggedNodeIndex) {\n let { node } = targetNode;\n while (true) {\n const [, next, , nodeSetStyle, nodeIndex] = node;\n nodeSetStyle({});\n if (!next || nodeIndex >= draggedNodeIndex) break;\n node = next;\n }\n } else if (targetNodeIndex === draggedNodeIndex) {\n targetNodeSetStyle({});\n }\n }\n };\n }, [draggedNode]);\n\n // Update the position of the newly mounted nodes in the origin list (used in the virtual list)\n useEffect(() => {\n if (!draggedNode) return () => {};\n const [, , , , draggedNodeIndex] = draggedNode.node;\n\n const update = (nodeProps: NodeProps) => {\n const { setStyle, index } = nodeProps;\n const targetNode = targetNodeRef.current;\n\n // Set the hidden style, if the mounted node is the dragged node\n if (index === draggedNodeIndex) {\n setStyle(HIDDEN_NODE_STYLE);\n return;\n }\n\n // If the dragged node is inside the origin list\n if (targetNode && targetNode.list === draggedNode.list) {\n // Move the mounted node up/down, if it is located between the dragged and target node\n const [, , , , targetNodeIndex] = targetNode.node;\n if (index > draggedNodeIndex && index < targetNodeIndex) {\n setStyle(getNodeStyle('up', targetNode.list.horizontal));\n } else if (index < draggedNodeIndex && index > targetNodeIndex) {\n setStyle(getNodeStyle('down', targetNode.list.horizontal));\n }\n } else if (index > draggedNodeIndex) {\n // Otherwise, move the mounted node up, if it is located below the dragged node\n setStyle(getNodeStyle('up', draggedNode.list.horizontal));\n }\n };\n\n draggedNode.list.addListener(update);\n return () => draggedNode.list.removeListener(update);\n }, [draggedNode, getNodeStyle]);\n\n // Update the position of the newly mounted nodes in the target list (used in the virtual list)\n useEffect(() => {\n if (!draggedNode || !targetList || targetList === draggedNode.list) {\n return () => {};\n }\n\n const update = (nodeProps: NodeProps) => {\n const { setStyle, index } = nodeProps;\n const targetNode = targetNodeRef.current;\n if (!targetNode) return;\n const [, , , , targetNodeIndex] = targetNode.node;\n if (index >= targetNodeIndex) {\n // Move the mounted node down, if it is located below the target node or if it is the target node\n setStyle(getNodeStyle('down', targetList.horizontal));\n }\n };\n\n targetList.addListener(update);\n return () => targetList.removeListener(update);\n }, [draggedNode, getNodeStyle, targetList]);\n\n // Call the onDragEnd callback if the draggedNode was changed to null\n useEffect(() => {\n if (!draggedNode) return () => {};\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const target = targetRef.current;\n if (!target) return;\n const [, , , , draggedNodeIndex, draggedNodeId] = draggedNode.node;\n const dragged = {\n listId: draggedNode.list.id,\n index: draggedNodeIndex,\n id: draggedNodeId,\n };\n if (dragged.id === target.id && dragged.index === target.index) return;\n onDragEndRef.current(dragged, target);\n };\n }, [draggedNode]);\n};\n\nexport default useDragEffect;\n"],"file":"useDragEffect.js"}
1
+ {"version":3,"file":"useDragEffect.js","names":["useCallback","useEffect","useMemo","useRef","useThrottle","useEvent","getElementScroll","useTargetList","useInitRect","useInitScrollOffset","useGetNodeStyle","useMoveNode","getNodeRect","useBlankNode","HIDDEN_NODE_STYLE","opacity","pointerEvents","createEmptyNode","prev","next","current","useDragEffect","props","draggedNode","cursorPosition","listStoreRef","onDragEnd","targetRef","targetNodeRef","onDragEndRef","initDraggedNodeRect","node","undefined","initDraggedNodeListScrollOffset","list","ref","position","x","y","initWidth","initHeight","targetList","getNodeStyle","moveNode","setTargetNode","nodeIndex","nodeId","listId","id","index","clearTargetNode","getDraggedNodePos","initX","initY","initScrollLeft","initScrollTop","scrollLeft","scrollTop","getDraggedNodePosRef","draggedNodeSetStyle","removeBlankNode","updateTargetNode","prevTargetNode","startNode","direction","destination","isAnotherList","tail","getTail","axis","horizontal","prevTargetNodeRef","draggedNodePos","isDraggingUp","head","getHead","prevTargetNodeRect","startRectProp","isMoveUp","throttledUpdateTargetNode","window","draggedNodeIndex","targetNode","nodeSetStyle","targetNodeIndex","targetNodeSetStyle","update","nodeProps","setStyle","addListener","removeListener","target","draggedNodeId","dragged"],"sources":["../../../src/utils/useDragEffect.ts"],"sourcesContent":["import { Position } from '@os-design/use-drag';\nimport {\n CSSProperties,\n RefObject,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from 'react';\nimport useThrottle from '@os-design/use-throttle';\nimport useEvent from '@os-design/use-event';\nimport NodeList, { ExistingNode, Node, NodeProps } from './NodeList';\nimport ListStore from './ListStore';\nimport getElementScroll from './getElementScroll';\nimport useTargetList from './useTargetList';\nimport useInitRect from './useInitRect';\nimport useInitScrollOffset from './useInitScrollOffset';\nimport useGetNodeStyle from './useGetNodeStyle';\nimport useMoveNode from './useMoveNode';\nimport getNodeRect from './getNodeRect';\nimport useBlankNode from './useBlankNode';\n\nexport interface DraggedNode {\n list: NodeList;\n node: ExistingNode;\n position: Position;\n}\n\ninterface TargetNode {\n list: NodeList;\n node: ExistingNode;\n}\n\nexport interface ItemLocation {\n listId: string;\n index: number;\n id: string;\n}\n\nexport type DragEndHandler = (\n dragged: ItemLocation,\n target: ItemLocation\n) => void;\n\ninterface UseDragEffectProps {\n draggedNode: DraggedNode | null;\n cursorPosition: Position;\n listStoreRef: RefObject<ListStore>;\n onDragEnd: DragEndHandler;\n}\n\nconst HIDDEN_NODE_STYLE: CSSProperties = {\n opacity: 0,\n pointerEvents: 'none',\n};\n\nconst createEmptyNode = ({\n prev = null,\n next = null,\n}: {\n prev?: Node;\n next?: Node;\n}): ExistingNode => [prev, next, { current: null }, () => {}, -1, 'id'];\n\n/* eslint-disable no-constant-condition */\n\nconst useDragEffect = (props: UseDragEffectProps) => {\n const { draggedNode, cursorPosition, listStoreRef, onDragEnd } = props;\n\n const targetRef = useRef<ItemLocation | null>(null);\n const targetNodeRef = useRef<TargetNode | null>(draggedNode);\n\n useEffect(() => {\n targetNodeRef.current = draggedNode;\n }, [draggedNode]);\n\n const onDragEndRef = useRef(onDragEnd);\n useEffect(() => {\n onDragEndRef.current = onDragEnd;\n }, [onDragEnd]);\n\n // The initial bounds of the dragged node.\n // We can't read the bounds of the dragged node on the fly because the node can be unmounted in the virtual list.\n const initDraggedNodeRect = useInitRect(\n draggedNode ? draggedNode.node[2] : undefined\n );\n\n // The initial scroll position of the list where the dragged node is located.\n // Used to detect the actual position of the dragged node. The purpose is the same as with initDraggedNodeRect.\n const initDraggedNodeListScrollOffset = useInitScrollOffset(\n draggedNode ? draggedNode.list.ref : undefined\n );\n\n // The central position of the dragged node\n const position = useMemo(() => {\n if (!draggedNode || !initDraggedNodeRect) return null;\n const { x, y } = cursorPosition;\n const { initWidth, initHeight } = initDraggedNodeRect;\n return {\n x: x - draggedNode.position.x + initWidth / 2,\n y: y - draggedNode.position.y + initHeight / 2,\n };\n }, [cursorPosition, draggedNode, initDraggedNodeRect]);\n\n // The list in which the cursor is located\n const targetList = useTargetList(position, listStoreRef);\n\n // Returns the style for moving the node in the specified direction\n const getNodeStyle = useGetNodeStyle(initDraggedNodeRect);\n\n // Moves the node up or down\n const moveNode = useMoveNode({ position, draggedNode, getNodeStyle });\n\n const setTargetNode = useCallback((list: NodeList, node: ExistingNode) => {\n const [, , , , nodeIndex, nodeId] = node;\n targetNodeRef.current = { list, node };\n targetRef.current = {\n listId: list.id,\n index: nodeIndex,\n id: nodeId,\n };\n }, []);\n\n const clearTargetNode = useCallback(() => {\n targetNodeRef.current = null;\n targetRef.current = null;\n }, []);\n\n // Returns the central position of the dragged node in the list\n const getDraggedNodePos = useCallback(() => {\n if (\n !targetList ||\n !targetList.ref.current ||\n !initDraggedNodeRect ||\n !initDraggedNodeListScrollOffset\n ) {\n return null;\n }\n const { initX, initY, initWidth, initHeight } = initDraggedNodeRect;\n const { initScrollLeft, initScrollTop } = initDraggedNodeListScrollOffset;\n const { scrollLeft, scrollTop } = getElementScroll(targetList.ref.current);\n return {\n x: initX + initWidth / 2 + initScrollLeft - scrollLeft,\n y: initY + initHeight / 2 + initScrollTop - scrollTop,\n };\n }, [initDraggedNodeListScrollOffset, initDraggedNodeRect, targetList]);\n\n const getDraggedNodePosRef = useRef(getDraggedNodePos);\n useEffect(() => {\n getDraggedNodePosRef.current = getDraggedNodePos;\n }, [getDraggedNodePos]);\n\n // Hide the dragged node\n useEffect(() => {\n if (!draggedNode) return () => {};\n const [, , , draggedNodeSetStyle] = draggedNode.node;\n draggedNodeSetStyle(HIDDEN_NODE_STYLE);\n return () => draggedNodeSetStyle({});\n }, [draggedNode]);\n\n // Append the blank node to the list to increase the height of it.\n // Used when the dragged node is located inside another list.\n const removeBlankNode = useBlankNode({\n draggedNode,\n targetList,\n initDraggedNodeRect,\n });\n\n const updateTargetNode = useCallback(() => {\n if (!draggedNode) return;\n const prevTargetNode = targetNodeRef.current; // The last updated node\n\n // Dragging outside the origin list\n if (\n prevTargetNode &&\n prevTargetNode.list === draggedNode.list &&\n targetList !== draggedNode.list\n ) {\n moveNode({\n list: prevTargetNode.list,\n startNode: prevTargetNode.node,\n direction: 'down',\n destination: 'end',\n });\n clearTargetNode();\n }\n\n // Dragging outside another list\n if (\n prevTargetNode &&\n prevTargetNode.list !== draggedNode.list &&\n targetList !== prevTargetNode.list\n ) {\n moveNode({\n list: prevTargetNode.list,\n startNode: prevTargetNode.node,\n direction: 'down',\n destination: 'end',\n isAnotherList: true,\n });\n removeBlankNode();\n clearTargetNode();\n }\n\n // Dragging inside the origin list\n if (!prevTargetNode && targetList === draggedNode.list) {\n const tail = targetList.getTail();\n if (!tail) return;\n const node = moveNode({\n list: targetList,\n startNode: tail,\n direction: 'up',\n destination: 'cursor',\n });\n setTargetNode(targetList, node);\n return;\n }\n\n // Dragging inside another list\n if (\n targetList &&\n targetList !== draggedNode.list &&\n (!prevTargetNode || prevTargetNode.list !== targetList)\n ) {\n const tail = targetList.getTail();\n if (!tail) return;\n const node = moveNode({\n list: targetList,\n startNode: tail,\n direction: 'up',\n destination: 'cursor',\n isAnotherList: true,\n });\n setTargetNode(targetList, node);\n return;\n }\n\n // Dragging in the origin list\n if (\n prevTargetNode &&\n prevTargetNode.list === draggedNode.list &&\n targetList === draggedNode.list\n ) {\n const axis = targetList.horizontal ? 'x' : 'y';\n const [, , prevTargetNodeRef, ,] = prevTargetNode.node;\n if (!prevTargetNodeRef.current) {\n // The target node was unmounted. It happens when the virtual list is used.\n // If the cursor is above the dragged node, we need to move the nodes down from the tail to the node where\n // the cursor is located. Otherwise, we need to move the nodes up from the head to the node where the cursor\n // is located.\n const draggedNodePos = getDraggedNodePosRef.current();\n if (!position || !draggedNodePos) return;\n const isDraggingUp = position[axis] < draggedNodePos[axis];\n if (isDraggingUp) {\n const tail = targetList.getTail();\n if (!tail || !tail[2].current) return;\n const node = moveNode({\n list: targetList,\n startNode: createEmptyNode({ prev: tail }),\n direction: 'up',\n destination: 'cursor',\n });\n setTargetNode(targetList, node);\n } else {\n const head = targetList.getHead();\n if (!head || !head[2].current) return;\n const node = moveNode({\n list: targetList,\n startNode: createEmptyNode({ next: head }),\n direction: 'down',\n destination: 'cursor',\n });\n setTargetNode(targetList, node);\n }\n return;\n }\n const prevTargetNodeRect = getNodeRect(prevTargetNode.node[2]);\n const startRectProp = targetList.horizontal ? 'left' : 'top';\n if (!position || !prevTargetNodeRect) return;\n const isMoveUp = position[axis] < prevTargetNodeRect[startRectProp];\n const node = isMoveUp\n ? moveNode({\n list: targetList,\n startNode: prevTargetNode.node,\n direction: 'up',\n destination: 'cursor',\n })\n : moveNode({\n list: targetList,\n startNode: prevTargetNode.node,\n direction: 'down',\n destination: 'cursor',\n });\n setTargetNode(targetList, node);\n return;\n }\n\n // Dragging in another list\n if (\n targetList &&\n targetList !== draggedNode.list &&\n prevTargetNode &&\n prevTargetNode.list === targetList\n ) {\n const axis = targetList.horizontal ? 'x' : 'y';\n const prevTargetNodeRect = getNodeRect(prevTargetNode.node[2]);\n const startRectProp = targetList.horizontal ? 'left' : 'top';\n if (!position || !prevTargetNodeRect) return;\n const isMoveUp = position[axis] < prevTargetNodeRect[startRectProp];\n const node = isMoveUp\n ? moveNode({\n list: targetList,\n startNode: prevTargetNode.node,\n direction: 'up',\n destination: 'cursor',\n isAnotherList: true,\n })\n : moveNode({\n list: targetList,\n startNode: prevTargetNode.node,\n direction: 'down',\n destination: 'cursor',\n isAnotherList: true,\n });\n setTargetNode(targetList, node);\n }\n }, [\n draggedNode,\n targetList,\n moveNode,\n clearTargetNode,\n removeBlankNode,\n setTargetNode,\n position,\n ]);\n\n // Update the target node if either the position or the target list has been changed\n useEffect(() => {\n updateTargetNode();\n }, [updateTargetNode]);\n\n // Update the target node if the target list has been scrolled\n const [throttledUpdateTargetNode] = useThrottle(updateTargetNode, 100);\n useEvent(\n (targetList ? targetList.ref : undefined) as unknown as EventTarget,\n 'scroll',\n throttledUpdateTargetNode\n );\n useEvent(window, 'scroll', throttledUpdateTargetNode);\n\n // Reset styles of the affected nodes when the dragged node was dropped\n useEffect(() => {\n if (!draggedNode) return () => {};\n const [, , , , draggedNodeIndex] = draggedNode.node;\n return () => {\n const targetNode = targetNodeRef.current;\n\n // If the dragged node was outside the origin list, reset the styles for the nodes,\n // starting at the tail and ending with the dragged node in the origin list.\n if (!targetNode || targetNode.list !== draggedNode.list) {\n const tail = draggedNode.list.getTail();\n if (tail) {\n let node = tail;\n while (true) {\n const [prev, , , nodeSetStyle, nodeIndex] = node;\n nodeSetStyle({});\n if (!prev || nodeIndex <= draggedNodeIndex) break;\n node = prev;\n }\n }\n }\n\n // If the dragged node was inside another list, reset the styles for the nodes,\n // starting at the tail and ending with the dragged node in the target list.\n if (targetNode && targetNode.list !== draggedNode.list) {\n const tail = targetNode.list.getTail();\n const [, , , , targetNodeIndex] = targetNode.node;\n if (tail) {\n let node = tail;\n while (true) {\n const [prev, , , nodeSetStyle, nodeIndex] = node;\n nodeSetStyle({});\n if (!prev || nodeIndex <= targetNodeIndex) break;\n node = prev;\n }\n }\n }\n\n // If the dragged node was moved inside the origin list, reset the styles for the nodes,\n // starting with target node and ending with the dragged node.\n if (targetNode && targetNode.list === draggedNode.list) {\n const [, , , targetNodeSetStyle, targetNodeIndex] = targetNode.node;\n if (targetNodeIndex > draggedNodeIndex) {\n let { node } = targetNode;\n while (true) {\n const [prev, , , nodeSetStyle, nodeIndex] = node;\n nodeSetStyle({});\n if (!prev || nodeIndex <= draggedNodeIndex) break;\n node = prev;\n }\n } else if (targetNodeIndex < draggedNodeIndex) {\n let { node } = targetNode;\n while (true) {\n const [, next, , nodeSetStyle, nodeIndex] = node;\n nodeSetStyle({});\n if (!next || nodeIndex >= draggedNodeIndex) break;\n node = next;\n }\n } else if (targetNodeIndex === draggedNodeIndex) {\n targetNodeSetStyle({});\n }\n }\n };\n }, [draggedNode]);\n\n // Update the position of the newly mounted nodes in the origin list (used in the virtual list)\n useEffect(() => {\n if (!draggedNode) return () => {};\n const [, , , , draggedNodeIndex] = draggedNode.node;\n\n const update = (nodeProps: NodeProps) => {\n const { setStyle, index } = nodeProps;\n const targetNode = targetNodeRef.current;\n\n // Set the hidden style, if the mounted node is the dragged node\n if (index === draggedNodeIndex) {\n setStyle(HIDDEN_NODE_STYLE);\n return;\n }\n\n // If the dragged node is inside the origin list\n if (targetNode && targetNode.list === draggedNode.list) {\n // Move the mounted node up/down, if it is located between the dragged and target node\n const [, , , , targetNodeIndex] = targetNode.node;\n if (index > draggedNodeIndex && index < targetNodeIndex) {\n setStyle(getNodeStyle('up', targetNode.list.horizontal));\n } else if (index < draggedNodeIndex && index > targetNodeIndex) {\n setStyle(getNodeStyle('down', targetNode.list.horizontal));\n }\n } else if (index > draggedNodeIndex) {\n // Otherwise, move the mounted node up, if it is located below the dragged node\n setStyle(getNodeStyle('up', draggedNode.list.horizontal));\n }\n };\n\n draggedNode.list.addListener(update);\n return () => draggedNode.list.removeListener(update);\n }, [draggedNode, getNodeStyle]);\n\n // Update the position of the newly mounted nodes in the target list (used in the virtual list)\n useEffect(() => {\n if (!draggedNode || !targetList || targetList === draggedNode.list) {\n return () => {};\n }\n\n const update = (nodeProps: NodeProps) => {\n const { setStyle, index } = nodeProps;\n const targetNode = targetNodeRef.current;\n if (!targetNode) return;\n const [, , , , targetNodeIndex] = targetNode.node;\n if (index >= targetNodeIndex) {\n // Move the mounted node down, if it is located below the target node or if it is the target node\n setStyle(getNodeStyle('down', targetList.horizontal));\n }\n };\n\n targetList.addListener(update);\n return () => targetList.removeListener(update);\n }, [draggedNode, getNodeStyle, targetList]);\n\n // Call the onDragEnd callback if the draggedNode was changed to null\n useEffect(() => {\n if (!draggedNode) return () => {};\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const target = targetRef.current;\n if (!target) return;\n const [, , , , draggedNodeIndex, draggedNodeId] = draggedNode.node;\n const dragged = {\n listId: draggedNode.list.id,\n index: draggedNodeIndex,\n id: draggedNodeId,\n };\n if (dragged.id === target.id && dragged.index === target.index) return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mB,YAAd,EAA4BD,UAA5B,CAlBM,CAAT,CAhYmD,CAoZnD;;EACAxC,SAAS,CAAC,MAAM;IACd,IAAI,CAACsB,WAAL,EAAkB,OAAO,MAAM,CAAE,CAAf;IAClB,OAAO,MAAM;MACX;MACA,MAAMoE,MAAM,GAAGhE,SAAS,CAACP,OAAzB;MACA,IAAI,CAACuE,MAAL,EAAa;MACb,MAAM,MAASV,gBAAT,EAA2BW,aAA3B,IAA4CrE,WAAW,CAACQ,IAA9D;MACA,MAAM8D,OAAO,GAAG;QACd9C,MAAM,EAAExB,WAAW,CAACW,IAAZ,CAAiBc,EADX;QAEdC,KAAK,EAAEgC,gBAFO;QAGdjC,EAAE,EAAE4C;MAHU,CAAhB;MAKA,IAAIC,OAAO,CAAC7C,EAAR,KAAe2C,MAAM,CAAC3C,EAAtB,IAA4B6C,OAAO,CAAC5C,KAAR,KAAkB0C,MAAM,CAAC1C,KAAzD,EAAgE;MAChEpB,YAAY,CAACT,OAAb,CAAqByE,OAArB,EAA8BF,MAA9B;IACD,CAZD;EAaD,CAfQ,EAeN,CAACpE,WAAD,CAfM,CAAT;AAgBD,CAraD;;AAuaA,eAAeF,aAAf"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/useDroppable.ts"],"names":["React","useContext","DroppableContext","createContext","registerNode","current","deregisterNode","onMouseDown","onTouchStart","useDroppable"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,UAAhB,QAA0D,OAA1D;AAUA,OAAO,MAAMC,gBAAgB,gBAAGF,KAAK,CAACG,aAAN,CAA2C;AACzEC,EAAAA,YAAY,EAAE,MACZ,CAAC,IAAD,EAAO,IAAP,EAAa;AAAEC,IAAAA,OAAO,EAAE;AAAX,GAAb,EAAgC,MAAM,CAAE,CAAxC,EAA0C,CAAC,CAA3C,EAA8C,IAA9C,CAFuE;AAGzEC,EAAAA,cAAc,EAAE,MAAM,CAAE,CAHiD;AAIzEC,EAAAA,WAAW,EAAE,MAAM,CAAE,CAJoD;AAKzEC,EAAAA,YAAY,EAAE,MAAM,CAAE;AALmD,CAA3C,CAAzB;;AAQP,MAAMC,YAAY,GAAG,MAA6BR,UAAU,CAACC,gBAAD,CAA5D;;AAEA,eAAeO,YAAf","sourcesContent":["import React, { useContext, MouseEvent, TouchEvent } from 'react';\nimport { ExistingNode, NodeProps } from './NodeList';\n\ninterface DroppableContextProps {\n registerNode: (props: NodeProps) => ExistingNode;\n deregisterNode: (node: ExistingNode) => void;\n onMouseDown: (e: MouseEvent, node: ExistingNode) => void;\n onTouchStart: (e: TouchEvent, node: ExistingNode) => void;\n}\n\nexport const DroppableContext = React.createContext<DroppableContextProps>({\n registerNode: () =>\n [null, null, { current: null }, () => {}, -1, 'id'] as ExistingNode,\n deregisterNode: () => {},\n onMouseDown: () => {},\n onTouchStart: () => {},\n});\n\nconst useDroppable = (): DroppableContextProps => useContext(DroppableContext);\n\nexport default useDroppable;\n"],"file":"useDroppable.js"}
1
+ {"version":3,"file":"useDroppable.js","names":["React","useContext","DroppableContext","createContext","registerNode","current","deregisterNode","onMouseDown","onTouchStart","useDroppable"],"sources":["../../../src/utils/useDroppable.ts"],"sourcesContent":["import React, { useContext, MouseEvent, TouchEvent } from 'react';\nimport { ExistingNode, NodeProps } from './NodeList';\n\ninterface DroppableContextProps {\n registerNode: (props: NodeProps) => ExistingNode;\n deregisterNode: (node: ExistingNode) => void;\n onMouseDown: (e: MouseEvent, node: ExistingNode) => void;\n onTouchStart: (e: TouchEvent, node: ExistingNode) => void;\n}\n\nexport const DroppableContext = React.createContext<DroppableContextProps>({\n registerNode: () =>\n [null, null, { current: null }, () => {}, -1, 'id'] as ExistingNode,\n deregisterNode: () => {},\n onMouseDown: () => {},\n onTouchStart: () => {},\n});\n\nconst useDroppable = (): DroppableContextProps => useContext(DroppableContext);\n\nexport default useDroppable;\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,UAAhB,QAA0D,OAA1D;AAUA,OAAO,MAAMC,gBAAgB,gBAAGF,KAAK,CAACG,aAAN,CAA2C;EACzEC,YAAY,EAAE,MACZ,CAAC,IAAD,EAAO,IAAP,EAAa;IAAEC,OAAO,EAAE;EAAX,CAAb,EAAgC,MAAM,CAAE,CAAxC,EAA0C,CAAC,CAA3C,EAA8C,IAA9C,CAFuE;EAGzEC,cAAc,EAAE,MAAM,CAAE,CAHiD;EAIzEC,WAAW,EAAE,MAAM,CAAE,CAJoD;EAKzEC,YAAY,EAAE,MAAM,CAAE;AALmD,CAA3C,CAAzB;;AAQP,MAAMC,YAAY,GAAG,MAA6BR,UAAU,CAACC,gBAAD,CAA5D;;AAEA,eAAeO,YAAf"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/useGeneratedId.ts"],"names":["useMemo","useGeneratedId","Math","random","toString","slice"],"mappings":"AAAA,SAASA,OAAT,QAAwB,OAAxB;;AAEA,MAAMC,cAAc,GAAG,MACrBD,OAAO,CAAC,MAAME,IAAI,CAACC,MAAL,GAAcC,QAAd,CAAuB,EAAvB,EAA2BC,KAA3B,CAAiC,CAAjC,CAAP,EAA4C,EAA5C,CADT;;AAGA,eAAeJ,cAAf","sourcesContent":["import { useMemo } from 'react';\n\nconst useGeneratedId = () =>\n useMemo(() => Math.random().toString(16).slice(2), []);\n\nexport default useGeneratedId;\n"],"file":"useGeneratedId.js"}
1
+ {"version":3,"file":"useGeneratedId.js","names":["useMemo","useGeneratedId","Math","random","toString","slice"],"sources":["../../../src/utils/useGeneratedId.ts"],"sourcesContent":["import { useMemo } from 'react';\n\nconst useGeneratedId = () =>\n useMemo(() => Math.random().toString(16).slice(2), []);\n\nexport default useGeneratedId;\n"],"mappings":"AAAA,SAASA,OAAT,QAAwB,OAAxB;;AAEA,MAAMC,cAAc,GAAG,MACrBD,OAAO,CAAC,MAAME,IAAI,CAACC,MAAL,GAAcC,QAAd,CAAuB,EAAvB,EAA2BC,KAA3B,CAAiC,CAAjC,CAAP,EAA4C,EAA5C,CADT;;AAGA,eAAeJ,cAAf"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/useGetNodeStyle.ts"],"names":["useCallback","useEffect","useRef","useGetNodeStyle","size","sizeRef","current","type","horizontal","translateFn","sizeProp","sign","style","transform"],"mappings":"AAAA,SAAwBA,WAAxB,EAAqCC,SAArC,EAAgDC,MAAhD,QAA8D,OAA9D;;AAYA,MAAMC,eAAe,GAAIC,IAAD,IAA4C;AAClE,QAAMC,OAAO,GAAGH,MAAM,CAACE,IAAD,CAAtB;AAEAH,EAAAA,SAAS,CAAC,MAAM;AACdI,IAAAA,OAAO,CAACC,OAAR,GAAkBF,IAAlB;AACD,GAFQ,EAEN,CAACA,IAAD,CAFM,CAAT;AAIA,SAAOJ,WAAW,CAAkB,CAACO,IAAD,EAAOC,UAAP,KAAsB;AACxD,QAAID,IAAI,KAAK,MAAT,IAAmB,CAACF,OAAO,CAACC,OAAhC,EAAyC,OAAO,EAAP;AAEzC,UAAMG,WAAW,GAAGD,UAAU,GAAG,YAAH,GAAkB,YAAhD;AACA,UAAME,QAAQ,GAAGF,UAAU,GAAG,WAAH,GAAiB,YAA5C;AACA,UAAMG,IAAI,GAAGJ,IAAI,KAAK,MAAT,GAAkB,CAAlB,GAAsB,CAAC,CAApC;AAEA,UAAMK,KAAoB,GAAG,EAA7B;AACAA,IAAAA,KAAK,CAACC,SAAN,GAAmB,GAAEJ,WAAY,IAAGE,IAAI,GAAGN,OAAO,CAACC,OAAR,CAAgBI,QAAhB,CAA0B,KAArE;AAEA,WAAOE,KAAP;AACD,GAXiB,EAWf,EAXe,CAAlB;AAYD,CAnBD;;AAqBA,eAAeT,eAAf","sourcesContent":["import { CSSProperties, useCallback, useEffect, useRef } from 'react';\n\ninterface InitSize {\n initWidth: number;\n initHeight: number;\n}\n\nexport type NodeStyleGetter = (\n type: 'up' | 'down' | 'init',\n horizontal: boolean\n) => CSSProperties;\n\nconst useGetNodeStyle = (size: InitSize | null): NodeStyleGetter => {\n const sizeRef = useRef(size);\n\n useEffect(() => {\n sizeRef.current = size;\n }, [size]);\n\n return useCallback<NodeStyleGetter>((type, horizontal) => {\n if (type === 'init' || !sizeRef.current) return {};\n\n const translateFn = horizontal ? 'translateX' : 'translateY';\n const sizeProp = horizontal ? 'initWidth' : 'initHeight';\n const sign = type === 'down' ? 1 : -1;\n\n const style: CSSProperties = {};\n style.transform = `${translateFn}(${sign * sizeRef.current[sizeProp]}px)`;\n\n return style;\n }, []);\n};\n\nexport default useGetNodeStyle;\n"],"file":"useGetNodeStyle.js"}
1
+ {"version":3,"file":"useGetNodeStyle.js","names":["useCallback","useEffect","useRef","useGetNodeStyle","size","sizeRef","current","type","horizontal","translateFn","sizeProp","sign","style","transform"],"sources":["../../../src/utils/useGetNodeStyle.ts"],"sourcesContent":["import { CSSProperties, useCallback, useEffect, useRef } from 'react';\n\ninterface InitSize {\n initWidth: number;\n initHeight: number;\n}\n\nexport type NodeStyleGetter = (\n type: 'up' | 'down' | 'init',\n horizontal: boolean\n) => CSSProperties;\n\nconst useGetNodeStyle = (size: InitSize | null): NodeStyleGetter => {\n const sizeRef = useRef(size);\n\n useEffect(() => {\n sizeRef.current = size;\n }, [size]);\n\n return useCallback<NodeStyleGetter>((type, horizontal) => {\n if (type === 'init' || !sizeRef.current) return {};\n\n const translateFn = horizontal ? 'translateX' : 'translateY';\n const sizeProp = horizontal ? 'initWidth' : 'initHeight';\n const sign = type === 'down' ? 1 : -1;\n\n const style: CSSProperties = {};\n style.transform = `${translateFn}(${sign * sizeRef.current[sizeProp]}px)`;\n\n return style;\n }, []);\n};\n\nexport default useGetNodeStyle;\n"],"mappings":"AAAA,SAAwBA,WAAxB,EAAqCC,SAArC,EAAgDC,MAAhD,QAA8D,OAA9D;;AAYA,MAAMC,eAAe,GAAIC,IAAD,IAA4C;EAClE,MAAMC,OAAO,GAAGH,MAAM,CAACE,IAAD,CAAtB;EAEAH,SAAS,CAAC,MAAM;IACdI,OAAO,CAACC,OAAR,GAAkBF,IAAlB;EACD,CAFQ,EAEN,CAACA,IAAD,CAFM,CAAT;EAIA,OAAOJ,WAAW,CAAkB,CAACO,IAAD,EAAOC,UAAP,KAAsB;IACxD,IAAID,IAAI,KAAK,MAAT,IAAmB,CAACF,OAAO,CAACC,OAAhC,EAAyC,OAAO,EAAP;IAEzC,MAAMG,WAAW,GAAGD,UAAU,GAAG,YAAH,GAAkB,YAAhD;IACA,MAAME,QAAQ,GAAGF,UAAU,GAAG,WAAH,GAAiB,YAA5C;IACA,MAAMG,IAAI,GAAGJ,IAAI,KAAK,MAAT,GAAkB,CAAlB,GAAsB,CAAC,CAApC;IAEA,MAAMK,KAAoB,GAAG,EAA7B;IACAA,KAAK,CAACC,SAAN,GAAmB,GAAEJ,WAAY,IAAGE,IAAI,GAAGN,OAAO,CAACC,OAAR,CAAgBI,QAAhB,CAA0B,KAArE;IAEA,OAAOE,KAAP;EACD,CAXiB,EAWf,EAXe,CAAlB;AAYD,CAnBD;;AAqBA,eAAeT,eAAf"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/useInitRect.ts"],"names":["useMemo","useInitRect","ref","current","rect","getBoundingClientRect","initX","x","initY","y","initWidth","width","initHeight","height"],"mappings":"AAAA,SAAoBA,OAApB,QAAmC,OAAnC;;AAEA,MAAMC,WAAW,GAAIC,GAAD,IAClBF,OAAO,CAAC,MAAM;AACZ,MAAI,CAACE,GAAD,IAAQ,CAACA,GAAG,CAACC,OAAjB,EAA0B,OAAO,IAAP;AAE1B,QAAMC,IAAI,GAAGF,GAAG,CAACC,OAAJ,CAAYE,qBAAZ,EAAb;AAEA,SAAO;AACLC,IAAAA,KAAK,EAAEF,IAAI,CAACG,CADP;AAELC,IAAAA,KAAK,EAAEJ,IAAI,CAACK,CAFP;AAGLC,IAAAA,SAAS,EAAEN,IAAI,CAACO,KAHX;AAILC,IAAAA,UAAU,EAAER,IAAI,CAACS;AAJZ,GAAP;AAMD,CAXM,EAWJ,CAACX,GAAD,CAXI,CADT;;AAcA,eAAeD,WAAf","sourcesContent":["import { RefObject, useMemo } from 'react';\n\nconst useInitRect = (ref?: RefObject<HTMLElement>) =>\n useMemo(() => {\n if (!ref || !ref.current) return null;\n\n const rect = ref.current.getBoundingClientRect();\n\n return {\n initX: rect.x,\n initY: rect.y,\n initWidth: rect.width,\n initHeight: rect.height,\n };\n }, [ref]);\n\nexport default useInitRect;\n"],"file":"useInitRect.js"}
1
+ {"version":3,"file":"useInitRect.js","names":["useMemo","useInitRect","ref","current","rect","getBoundingClientRect","initX","x","initY","y","initWidth","width","initHeight","height"],"sources":["../../../src/utils/useInitRect.ts"],"sourcesContent":["import { RefObject, useMemo } from 'react';\n\nconst useInitRect = (ref?: RefObject<HTMLElement>) =>\n useMemo(() => {\n if (!ref || !ref.current) return null;\n\n const rect = ref.current.getBoundingClientRect();\n\n return {\n initX: rect.x,\n initY: rect.y,\n initWidth: rect.width,\n initHeight: rect.height,\n };\n }, [ref]);\n\nexport default useInitRect;\n"],"mappings":"AAAA,SAAoBA,OAApB,QAAmC,OAAnC;;AAEA,MAAMC,WAAW,GAAIC,GAAD,IAClBF,OAAO,CAAC,MAAM;EACZ,IAAI,CAACE,GAAD,IAAQ,CAACA,GAAG,CAACC,OAAjB,EAA0B,OAAO,IAAP;EAE1B,MAAMC,IAAI,GAAGF,GAAG,CAACC,OAAJ,CAAYE,qBAAZ,EAAb;EAEA,OAAO;IACLC,KAAK,EAAEF,IAAI,CAACG,CADP;IAELC,KAAK,EAAEJ,IAAI,CAACK,CAFP;IAGLC,SAAS,EAAEN,IAAI,CAACO,KAHX;IAILC,UAAU,EAAER,IAAI,CAACS;EAJZ,CAAP;AAMD,CAXM,EAWJ,CAACX,GAAD,CAXI,CADT;;AAcA,eAAeD,WAAf"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/useInitScrollOffset.ts"],"names":["useMemo","getElementScroll","useInitScrollOffset","ref","current","scrollOffset","initScrollLeft","scrollLeft","initScrollTop","scrollTop"],"mappings":"AAAA,SAAoBA,OAApB,QAAmC,OAAnC;AACA,OAAOC,gBAAP,MAA6B,oBAA7B;;AAEA,MAAMC,mBAAmB,GAAIC,GAAD,IAC1BH,OAAO,CAAC,MAAM;AACZ,MAAI,CAACG,GAAD,IAAQ,CAACA,GAAG,CAACC,OAAjB,EAA0B,OAAO,IAAP;AAE1B,QAAMC,YAAY,GAAGJ,gBAAgB,CAACE,GAAG,CAACC,OAAL,CAArC;AAEA,SAAO;AACLE,IAAAA,cAAc,EAAED,YAAY,CAACE,UADxB;AAELC,IAAAA,aAAa,EAAEH,YAAY,CAACI;AAFvB,GAAP;AAID,CATM,EASJ,CAACN,GAAD,CATI,CADT;;AAYA,eAAeD,mBAAf","sourcesContent":["import { RefObject, useMemo } from 'react';\nimport getElementScroll from './getElementScroll';\n\nconst useInitScrollOffset = (ref?: RefObject<HTMLElement>) =>\n useMemo(() => {\n if (!ref || !ref.current) return null;\n\n const scrollOffset = getElementScroll(ref.current);\n\n return {\n initScrollLeft: scrollOffset.scrollLeft,\n initScrollTop: scrollOffset.scrollTop,\n };\n }, [ref]);\n\nexport default useInitScrollOffset;\n"],"file":"useInitScrollOffset.js"}
1
+ {"version":3,"file":"useInitScrollOffset.js","names":["useMemo","getElementScroll","useInitScrollOffset","ref","current","scrollOffset","initScrollLeft","scrollLeft","initScrollTop","scrollTop"],"sources":["../../../src/utils/useInitScrollOffset.ts"],"sourcesContent":["import { RefObject, useMemo } from 'react';\nimport getElementScroll from './getElementScroll';\n\nconst useInitScrollOffset = (ref?: RefObject<HTMLElement>) =>\n useMemo(() => {\n if (!ref || !ref.current) return null;\n\n const scrollOffset = getElementScroll(ref.current);\n\n return {\n initScrollLeft: scrollOffset.scrollLeft,\n initScrollTop: scrollOffset.scrollTop,\n };\n }, [ref]);\n\nexport default useInitScrollOffset;\n"],"mappings":"AAAA,SAAoBA,OAApB,QAAmC,OAAnC;AACA,OAAOC,gBAAP,MAA6B,oBAA7B;;AAEA,MAAMC,mBAAmB,GAAIC,GAAD,IAC1BH,OAAO,CAAC,MAAM;EACZ,IAAI,CAACG,GAAD,IAAQ,CAACA,GAAG,CAACC,OAAjB,EAA0B,OAAO,IAAP;EAE1B,MAAMC,YAAY,GAAGJ,gBAAgB,CAACE,GAAG,CAACC,OAAL,CAArC;EAEA,OAAO;IACLE,cAAc,EAAED,YAAY,CAACE,UADxB;IAELC,aAAa,EAAEH,YAAY,CAACI;EAFvB,CAAP;AAID,CATM,EASJ,CAACN,GAAD,CATI,CADT;;AAYA,eAAeD,mBAAf"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/useMoveNode.ts"],"names":["useCallback","getNodeRect","useMoveNode","props","position","draggedNode","getNodeStyle","options","list","startNode","direction","destination","isAnotherList","draggedNodeIndex","node","axis","horizontal","startRectProp","endRectProp","prev","nodeSetStyle","nodeIndex","prevNodeRef","prevNodeSetStyle","prevNodeIndex","prevNodeRect","next","nextNodeRef","nextNodeSetStyle","nextNodeIndex","nextNodeRect"],"mappings":"AAAA,SAASA,WAAT,QAA4B,OAA5B;AAGA,OAAOC,WAAP,MAAwB,eAAxB;;AAqBA;AAEA,MAAMC,WAAW,GAAIC,KAAD,IAA6B;AAC/C,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,WAAZ;AAAyBC,IAAAA;AAAzB,MAA0CH,KAAhD;AAEA,SAAOH,WAAW,CACfO,OAAD,IAAwB;AACtB,UAAM;AACJC,MAAAA,IADI;AAEJC,MAAAA,SAFI;AAGJC,MAAAA,SAHI;AAIJC,MAAAA,WAJI;AAKJC,MAAAA,aAAa,GAAG;AALZ,QAMFL,OANJ;AAQA,QAAI,CAACF,WAAD,IAAgB,CAACD,QAArB,EAA+B,OAAOK,SAAP;AAC/B,UAAM,MAASI,gBAAT,IAA6BR,WAAW,CAACS,IAA/C;AACA,UAAMC,IAAI,GAAGP,IAAI,CAACQ,UAAL,GAAkB,GAAlB,GAAwB,GAArC;AACA,UAAMC,aAAa,GAAGT,IAAI,CAACQ,UAAL,GAAkB,MAAlB,GAA2B,KAAjD;AACA,UA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IAAI1B,QAAQ,CAACW,IAAD,CAAR,GAAiBe,YAAY,CAACb,aAAD,CAAjD,EAAkE;AAChE,mBAAOH,IAAP;AACD;AACF;;AAED,YAAIF,aAAa,IAAIS,SAAS,GAAGR,gBAAjC,EAAmD;AACjDO,UAAAA,YAAY,CAACd,YAAY,CAAC,MAAD,EAASE,IAAI,CAACQ,UAAd,CAAb,CAAZ;AACD,SAFD,MAEO,IAAIa,aAAa,GAAGhB,gBAApB,EAAsC;AAC3Ce,UAAAA,gBAAgB,CAACtB,YAAY,CAAC,IAAD,EAAOE,IAAI,CAACQ,UAAZ,CAAb,CAAhB;AACD;;AAEDF,QAAAA,IAAI,GAAGY,IAAP;AACD;AACF;AACF,GA9De,EA+DhB,CAACrB,WAAD,EAAcC,YAAd,EAA4BF,QAA5B,CA/DgB,CAAlB;AAiED,CApED;;AAsEA,eAAeF,WAAf","sourcesContent":["import { useCallback } from 'react';\nimport { Position } from '@os-design/use-drag';\nimport NodeList, { ExistingNode } from './NodeList';\nimport getNodeRect from './getNodeRect';\nimport { NodeStyleGetter } from './useGetNodeStyle';\n\ninterface DraggedNode {\n node: ExistingNode;\n}\n\ninterface UseMoveNodeProps {\n position: Position | null;\n draggedNode: DraggedNode | null;\n getNodeStyle: NodeStyleGetter;\n}\n\ninterface MoveProps {\n list: NodeList;\n startNode: ExistingNode;\n direction: 'up' | 'down';\n destination: 'cursor' | 'end';\n isAnotherList?: boolean;\n}\n\n/* eslint-disable no-constant-condition */\n\nconst useMoveNode = (props: UseMoveNodeProps) => {\n const { position, draggedNode, getNodeStyle } = props;\n\n return useCallback(\n (options: MoveProps) => {\n const {\n list,\n startNode,\n direction,\n destination,\n isAnotherList = false,\n } = options;\n\n if (!draggedNode || !position) return startNode;\n const [, , , , draggedNodeIndex] = draggedNode.node;\n const axis = list.horizontal ? 'x' : 'y';\n const startRectProp = list.horizontal ? 'left' : 'top';\n const endRectProp = list.horizontal ? 'right' : 'bottom';\n let node = startNode;\n\n if (direction === 'up') {\n while (true) {\n const [prev, , , nodeSetStyle, nodeIndex] = node;\n if (!prev) return node;\n\n const [, , prevNodeRef, prevNodeSetStyle, prevNodeIndex] = prev;\n\n if (destination === 'cursor') {\n const prevNodeRect = getNodeRect(prevNodeRef);\n if (prevNodeRect && position[axis] > prevNodeRect[endRectProp]) {\n return node;\n }\n }\n\n if (isAnotherList || prevNodeIndex < draggedNodeIndex) {\n prevNodeSetStyle(getNodeStyle('down', list.horizontal));\n } else if (nodeIndex > draggedNodeIndex) {\n nodeSetStyle(getNodeStyle('init', list.horizontal));\n }\n\n node = prev;\n }\n } else {\n while (true) {\n const [, next, , nodeSetStyle, nodeIndex] = node;\n if (!next) return node;\n\n const [, , nextNodeRef, nextNodeSetStyle, nextNodeIndex] = next;\n\n if (destination === 'cursor') {\n const nextNodeRect = getNodeRect(nextNodeRef);\n if (nextNodeRect && position[axis] < nextNodeRect[startRectProp]) {\n return node;\n }\n }\n\n if (isAnotherList || nodeIndex < draggedNodeIndex) {\n nodeSetStyle(getNodeStyle('init', list.horizontal));\n } else if (nextNodeIndex > draggedNodeIndex) {\n nextNodeSetStyle(getNodeStyle('up', list.horizontal));\n }\n\n node = next;\n }\n }\n },\n [draggedNode, getNodeStyle, position]\n );\n};\n\nexport default useMoveNode;\n"],"file":"useMoveNode.js"}
1
+ {"version":3,"file":"useMoveNode.js","names":["useCallback","getNodeRect","useMoveNode","props","position","draggedNode","getNodeStyle","options","list","startNode","direction","destination","isAnotherList","draggedNodeIndex","node","axis","horizontal","startRectProp","endRectProp","prev","nodeSetStyle","nodeIndex","prevNodeRef","prevNodeSetStyle","prevNodeIndex","prevNodeRect","next","nextNodeRef","nextNodeSetStyle","nextNodeIndex","nextNodeRect"],"sources":["../../../src/utils/useMoveNode.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { Position } from '@os-design/use-drag';\nimport NodeList, { ExistingNode } from './NodeList';\nimport getNodeRect from './getNodeRect';\nimport { NodeStyleGetter } from './useGetNodeStyle';\n\ninterface DraggedNode {\n node: ExistingNode;\n}\n\ninterface UseMoveNodeProps {\n position: Position | null;\n draggedNode: DraggedNode | null;\n getNodeStyle: NodeStyleGetter;\n}\n\ninterface MoveProps {\n list: NodeList;\n startNode: ExistingNode;\n direction: 'up' | 'down';\n destination: 'cursor' | 'end';\n isAnotherList?: boolean;\n}\n\n/* eslint-disable no-constant-condition */\n\nconst useMoveNode = (props: UseMoveNodeProps) => {\n const { position, draggedNode, getNodeStyle } = props;\n\n return useCallback(\n (options: MoveProps) => {\n const {\n list,\n startNode,\n direction,\n destination,\n isAnotherList = false,\n } = options;\n\n if (!draggedNode || !position) return startNode;\n const [, , , , draggedNodeIndex] = draggedNode.node;\n const axis = list.horizontal ? 'x' : 'y';\n const startRectProp = list.horizontal ? 'left' : 'top';\n const endRectProp = list.horizontal ? 'right' : 'bottom';\n let node = startNode;\n\n if (direction === 'up') {\n while (true) {\n const [prev, , , nodeSetStyle, nodeIndex] = node;\n if (!prev) return node;\n\n const [, , prevNodeRef, prevNodeSetStyle, prevNodeIndex] = prev;\n\n if (destination === 'cursor') {\n const prevNodeRect = getNodeRect(prevNodeRef);\n if (prevNodeRect && position[axis] > prevNodeRect[endRectProp]) {\n return node;\n }\n }\n\n if (isAnotherList || prevNodeIndex < draggedNodeIndex) {\n prevNodeSetStyle(getNodeStyle('down', list.horizontal));\n } else if (nodeIndex > draggedNodeIndex) {\n nodeSetStyle(getNodeStyle('init', list.horizontal));\n }\n\n node = prev;\n }\n } else {\n while (true) {\n const [, next, , nodeSetStyle, nodeIndex] = node;\n if (!next) return node;\n\n const [, , nextNodeRef, nextNodeSetStyle, nextNodeIndex] = next;\n\n if (destination === 'cursor') {\n const nextNodeRect = getNodeRect(nextNodeRef);\n if (nextNodeRect && position[axis] < nextNodeRect[startRectProp]) {\n return node;\n }\n }\n\n if (isAnotherList || nodeIndex < draggedNodeIndex) {\n nodeSetStyle(getNodeStyle('init', list.horizontal));\n } else if (nextNodeIndex > draggedNodeIndex) {\n nextNodeSetStyle(getNodeStyle('up', list.horizontal));\n }\n\n node = next;\n }\n }\n },\n [draggedNode, getNodeStyle, position]\n );\n};\n\nexport default useMoveNode;\n"],"mappings":"AAAA,SAASA,WAAT,QAA4B,OAA5B;AAGA,OAAOC,WAAP,MAAwB,eAAxB;;AAqBA;AAEA,MAAMC,WAAW,GAAIC,KAAD,IAA6B;EAC/C,MAAM;IAAEC,QAAF;IAAYC,WAAZ;IAAyBC;EAAzB,IAA0CH,KAAhD;EAEA,OAAOH,WAAW,CACfO,OAAD,IAAwB;IACtB,MAAM;MACJC,IADI;MAEJC,SAFI;MAGJC,SAHI;MAIJC,WAJI;MAKJC,aAAa,GAAG;IALZ,IAMFL,OANJ;IAQA,IAAI,CAACF,WAAD,IAAgB,CAACD,QAArB,EAA+B,OAAOK,SAAP;IAC/B,MAAM,MAASI,gBAAT,IAA6BR,WAAW,CAACS,IAA/C;IACA,MAAMC,IAAI,GAAGP,IAAI,CAACQ,UAAL,GAAkB,GAAlB,GAAwB,GAArC;IACA,MAAMC,aAAa,GAAGT,IAAI,CAACQ,UAAL,GAAkB,MAAlB,GAA2B,KAAjD;IACA,MAAME,WAAW,GAAGV,IAAI,CAACQ,UAAL,GAAkB,OAAlB,GAA4B,QAAhD;IACA,IAAIF,IAAI,GAAGL,SAAX;;IAEA,IAAIC,SAAS,KAAK,IAAlB,EAAwB;MACtB,OAAO,IAAP,EAAa;QACX,MAAM,CAACS,IAAD,IAAWC,YAAX,EAAyBC,SAAzB,IAAsCP,IAA5C;QACA,IAAI,CAACK,IAAL,EAAW,OAAOL,IAAP;QAEX,MAAM,IAAKQ,WAAL,EAAkBC,gBAAlB,EAAoCC,aAApC,IAAqDL,IAA3D;;QAEA,IAAIR,WAAW,KAAK,QAApB,EAA8B;UAC5B,MAAMc,YAAY,GAAGxB,WAAW,CAACqB,WAAD,CAAhC;;UACA,IAAIG,YAAY,IAAIrB,QAAQ,CAACW,IAAD,CAAR,GAAiBU,YAAY,CAACP,WAAD,CAAjD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