@os-design/drag-sort 1.0.6 → 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 (73) hide show
  1. package/dist/cjs/DragAndDrop.js +2 -1
  2. package/dist/cjs/DragAndDrop.js.map +1 -1
  3. package/dist/cjs/Draggable.js +4 -2
  4. package/dist/cjs/Draggable.js.map +1 -1
  5. package/dist/cjs/Droppable.js +1 -1
  6. package/dist/cjs/Droppable.js.map +1 -1
  7. package/dist/cjs/index.js.map +1 -1
  8. package/dist/cjs/utils/ListStore.js.map +1 -1
  9. package/dist/cjs/utils/NodeList.js +4 -4
  10. package/dist/cjs/utils/NodeList.js.map +1 -1
  11. package/dist/cjs/utils/getElementOffset.js.map +1 -1
  12. package/dist/cjs/utils/getElementScroll.js.map +1 -1
  13. package/dist/cjs/utils/getNodeRect.js.map +1 -1
  14. package/dist/cjs/utils/useAppendClassName.js.map +1 -1
  15. package/dist/cjs/utils/useBlankNode.js +2 -1
  16. package/dist/cjs/utils/useBlankNode.js.map +1 -1
  17. package/dist/cjs/utils/useDragAndDrop.js.map +1 -1
  18. package/dist/cjs/utils/useDragEffect.js +13 -9
  19. package/dist/cjs/utils/useDragEffect.js.map +1 -1
  20. package/dist/cjs/utils/useDroppable.js +1 -1
  21. package/dist/cjs/utils/useDroppable.js.map +1 -1
  22. package/dist/cjs/utils/useGeneratedId.js +3 -7
  23. package/dist/cjs/utils/useGeneratedId.js.map +1 -1
  24. package/dist/cjs/utils/useGetNodeStyle.js.map +1 -1
  25. package/dist/cjs/utils/useInitRect.js.map +1 -1
  26. package/dist/cjs/utils/useInitScrollOffset.js.map +1 -1
  27. package/dist/cjs/utils/useMoveNode.js.map +1 -1
  28. package/dist/cjs/utils/useScrollEventByPoint.js.map +1 -1
  29. package/dist/cjs/utils/useTargetList.js.map +1 -1
  30. package/dist/cjs/utils/useTransitionStyle.js.map +1 -1
  31. package/dist/esm/DragAndDrop.js +2 -1
  32. package/dist/esm/DragAndDrop.js.map +1 -1
  33. package/dist/esm/Draggable.js +4 -2
  34. package/dist/esm/Draggable.js.map +1 -1
  35. package/dist/esm/Droppable.js +1 -1
  36. package/dist/esm/Droppable.js.map +1 -1
  37. package/dist/esm/index.js.map +1 -1
  38. package/dist/esm/utils/ListStore.js.map +1 -1
  39. package/dist/esm/utils/NodeList.js +4 -4
  40. package/dist/esm/utils/NodeList.js.map +1 -1
  41. package/dist/esm/utils/getElementOffset.js.map +1 -1
  42. package/dist/esm/utils/getElementScroll.js.map +1 -1
  43. package/dist/esm/utils/getNodeRect.js.map +1 -1
  44. package/dist/esm/utils/useAppendClassName.js.map +1 -1
  45. package/dist/esm/utils/useBlankNode.js +2 -1
  46. package/dist/esm/utils/useBlankNode.js.map +1 -1
  47. package/dist/esm/utils/useDragAndDrop.js.map +1 -1
  48. package/dist/esm/utils/useDragEffect.js +9 -7
  49. package/dist/esm/utils/useDragEffect.js.map +1 -1
  50. package/dist/esm/utils/useDroppable.js +1 -1
  51. package/dist/esm/utils/useDroppable.js.map +1 -1
  52. package/dist/esm/utils/useGeneratedId.js +1 -2
  53. package/dist/esm/utils/useGeneratedId.js.map +1 -1
  54. package/dist/esm/utils/useGetNodeStyle.js.map +1 -1
  55. package/dist/esm/utils/useInitRect.js.map +1 -1
  56. package/dist/esm/utils/useInitScrollOffset.js.map +1 -1
  57. package/dist/esm/utils/useMoveNode.js.map +1 -1
  58. package/dist/esm/utils/useScrollEventByPoint.js.map +1 -1
  59. package/dist/esm/utils/useTargetList.js.map +1 -1
  60. package/dist/esm/utils/useTransitionStyle.js.map +1 -1
  61. package/dist/types/DragAndDrop.d.ts.map +1 -1
  62. package/dist/types/Draggable.d.ts +1 -0
  63. package/dist/types/Draggable.d.ts.map +1 -1
  64. package/dist/types/utils/NodeList.d.ts +3 -1
  65. package/dist/types/utils/NodeList.d.ts.map +1 -1
  66. package/dist/types/utils/useBlankNode.d.ts.map +1 -1
  67. package/dist/types/utils/useDragEffect.d.ts +2 -1
  68. package/dist/types/utils/useDragEffect.d.ts.map +1 -1
  69. package/dist/types/utils/useGeneratedId.d.ts +1 -1
  70. package/dist/types/utils/useGeneratedId.d.ts.map +1 -1
  71. package/dist/types/utils/useMoveNode.d.ts +1 -1
  72. package/dist/types/utils/useMoveNode.d.ts.map +1 -1
  73. package/package.json +3 -3
@@ -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;;AAoCA;AACA;AACA;AACA;AACA,MAAMA,QAAN,CAAe;AACb;AACF;AACA;;AAGE;AACF;AACA;;AAGE;AACF;AACA;AACA;;AAGE;AACF;AACA;;AAGE;AACF;AACA;;AAGE;AACF;AACA;;AAGE;AACF;AACA;;AAGE;AACF;AACA;AAGSC,EAAAA,WAAW,CAACC,KAAD,EAAmB;AAAA,SAtC9BC,EAsC8B;AAAA,SAjC9BC,GAiC8B;AAAA,SA3B9BC,QA2B8B;AAAA,SAtB9BC,UAsB8B;AAAA,SAjB9BC,iBAiB8B;AAAA,SAZ7BC,IAY6B;AAAA,SAP7BC,IAO6B;AAAA,SAF7BC,SAE6B;AACnC,SAAKP,EAAL,GAAUD,KAAK,CAACC,EAAhB;AACA,SAAKC,GAAL,GAAWF,KAAK,CAACE,GAAjB;AACA,SAAKC,QAAL,GAAgBH,KAAK,CAACG,QAAtB;AACA,SAAKC,UAAL,GAAkBJ,KAAK,CAACI,UAAxB;AACA,SAAKC,iBAAL,GAAyBL,KAAK,CAACK,iBAA/B;AACA,SAAKC,IAAL,GAAY,IAAZ;AACA,SAAKC,IAAL,GAAY,IAAZ;AACA,SAAKC,SAAL,GAAiB,EAAjB;AACD;;AAEMC,EAAAA,OAAO,GAAG;AAC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Properties, 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]\nexport type Node =\n | [Node, Node, RefObject<any>, (style: CSSProperties) => void, number]\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}\n\ninterface RenderDraggedNodeProps {\n /**\n * The index of the dragged node.\n */\n index: number;\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 = [null, this.head, props.ref, props.setStyle, props.index];\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 = [this.tail, null, props.ref, props.setStyle, props.index];\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];\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;IAA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,CAAD,CAAJ,GAAUF,IAAV;MACAA,IAAI,CAAC,CAAD,CAAJ,GAAUE,IAAV;IACD;EACF;;EAEMU,WAAW,CAACC,QAAD,EAAuC;IACvD,KAAKnB,SAAL,CAAeoB,IAAf,CAAoBD,QAApB;EACD;;EAEME,cAAc,CAACF,QAAD,EAAuC;IAC1D,MAAMd,KAAK,GAAG,KAAKL,SAAL,CAAesB,SAAf,CAA0BT,QAAD,IAAcA,QAAQ,KAAKM,QAApD,CAAd;IACA,KAAKnB,SAAL,CAAeuB,MAAf,CAAsBlB,KAAtB,EAA6B,CAA7B;EACD;;AAhMY;;AAmMf,eAAef,QAAf"}
@@ -1 +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"}
@@ -55,7 +55,8 @@ const useBlankNode = props => {
55
55
  current: div
56
56
  },
57
57
  setStyle: () => {},
58
- index: tail ? tail[4] + 1 : 0
58
+ index: tail ? tail[4] + 1 : 0,
59
+ id: 'blank'
59
60
  })
60
61
  };
61
62
  }, [draggedNode, targetList]);
@@ -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","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,sBAA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AAqBgC,aAApC;AACA,QAAInB,MAAJ,EAAYA,MAAM,CAACoB,WAAP,CAAmBF,YAAY,CAAC/B,OAAhC;AACb,GATkC,EAShC,EATgC,CAAnC,CAvDiD,CAkEjD;;AACAT,EAAAA,SAAS,CAAC,MAAM;AACd,QAAI,CAACI,WAAL,EAAkB,OAAO,MAAM,CAAE,CAAf;AAClB,WAAO,MAAMiC,eAAe,EAA5B;AACD,GAHQ,EAGN,CAACjC,WAAD,EAAciC,eAAd,CAHM,CAAT;AAKA,SAAOA,eAAP;AACD,CAzED;;AA2EA,eAAenC,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 }),\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]);\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,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"}
@@ -19,7 +19,7 @@ const createEmptyNode = ({
19
19
  next = null
20
20
  }) => [prev, next, {
21
21
  current: null
22
- }, () => {}, -1];
22
+ }, () => {}, -1, 'id'];
23
23
  /* eslint-disable no-constant-condition */
24
24
 
25
25
 
@@ -72,14 +72,15 @@ const useDragEffect = props => {
72
72
  getNodeStyle
73
73
  });
74
74
  const setTargetNode = useCallback((list, node) => {
75
- const [,,,, nodeIndex] = node;
75
+ const [,,,, nodeIndex, nodeId] = node;
76
76
  targetNodeRef.current = {
77
77
  list,
78
78
  node
79
79
  };
80
80
  targetRef.current = {
81
- id: list.id,
82
- index: nodeIndex
81
+ listId: list.id,
82
+ index: nodeIndex,
83
+ id: nodeId
83
84
  };
84
85
  }, []);
85
86
  const clearTargetNode = useCallback(() => {
@@ -420,10 +421,11 @@ const useDragEffect = props => {
420
421
  // eslint-disable-next-line react-hooks/exhaustive-deps
421
422
  const target = targetRef.current;
422
423
  if (!target) return;
423
- const [,,,, draggedNodeIndex] = draggedNode.node;
424
+ const [,,,, draggedNodeIndex, draggedNodeId] = draggedNode.node;
424
425
  const dragged = {
425
- id: draggedNode.list.id,
426
- index: draggedNodeIndex
426
+ listId: draggedNode.list.id,
427
+ index: draggedNodeIndex,
428
+ id: draggedNodeId
427
429
  };
428
430
  if (dragged.id === target.id && dragged.index === target.index) return;
429
431
  onDragEndRef.current(dragged, target);
@@ -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","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","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;AA8BA,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,EAA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B,UAApB,CAAb,CAAR;AACD;AACF,KATD;;AAWA3B,IAAAA,UAAU,CAAC8C,WAAX,CAAuBH,MAAvB;AACA,WAAO,MAAM3C,UAAU,CAAC+C,cAAX,CAA0BJ,MAA1B,CAAb;AACD,GAlBQ,EAkBN,CAAC7D,WAAD,EAAcmB,YAAd,EAA4BD,UAA5B,CAlBM,CAAT,CA5XmD,CAgZnD;;AACAxC,EAAAA,SAAS,CAAC,MAAM;AACd,QAAI,CAACsB,WAAL,EAAkB,OAAO,MAAM,CAAE,CAAf;AAClB,WAAO,MAAM;AACX;AACA,YAAMkE,MAAM,GAAG9D,SAAS,CAACP,OAAzB;AACA,UAAI,CAACqE,MAAL,EAAa;AACb,YAAM,MAASV,gBAAT,IAA6BxD,WAAW,CAACQ,IAA/C;AACA,YAAM2D,OAAO,GAAG;AAAE5C,QAAAA,EAAE,EAAEvB,WAAW,CAACW,IAAZ,CAAiBY,EAAvB;AAA2BC,QAAAA,KAAK,EAAEgC;AAAlC,OAAhB;AACA,UAAIW,OAAO,CAAC5C,EAAR,KAAe2C,MAAM,CAAC3C,EAAtB,IAA4B4C,OAAO,CAAC3C,KAAR,KAAkB0C,MAAM,CAAC1C,KAAzD,EAAgE;AAChElB,MAAAA,YAAY,CAACT,OAAb,CAAqBsE,OAArB,EAA8BD,MAA9B;AACD,KARD;AASD,GAXQ,EAWN,CAAClE,WAAD,CAXM,CAAT;AAYD,CA7ZD;;AA+ZA,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 id: string;\n index: number;\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];\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] = node;\n targetNodeRef.current = { list, node };\n targetRef.current = { id: list.id, index: nodeIndex };\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] = draggedNode.node;\n const dragged = { id: draggedNode.list.id, index: draggedNodeIndex };\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;\n onDragEndRef.current(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D,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"}
@@ -2,7 +2,7 @@ import React, { useContext } from 'react';
2
2
  export const DroppableContext = /*#__PURE__*/React.createContext({
3
3
  registerNode: () => [null, null, {
4
4
  current: null
5
- }, () => {}, -1],
5
+ }, () => {}, -1, 'id'],
6
6
  deregisterNode: () => {},
7
7
  onMouseDown: () => {},
8
8
  onTouchStart: () => {}
@@ -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,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] 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,7 +1,6 @@
1
1
  import { useMemo } from 'react';
2
- import crypto from 'crypto';
3
2
 
4
- const useGeneratedId = size => useMemo(() => crypto.randomBytes(size).toString('hex'), [size]);
3
+ const useGeneratedId = () => useMemo(() => Math.random().toString(16).slice(2), []);
5
4
 
6
5
  export default useGeneratedId;
7
6
  //# sourceMappingURL=useGeneratedId.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/useGeneratedId.ts"],"names":["useMemo","crypto","useGeneratedId","size","randomBytes","toString"],"mappings":"AAAA,SAASA,OAAT,QAAwB,OAAxB;AACA,OAAOC,MAAP,MAAmB,QAAnB;;AAEA,MAAMC,cAAc,GAAIC,IAAD,IACrBH,OAAO,CAAC,MAAMC,MAAM,CAACG,WAAP,CAAmBD,IAAnB,EAAyBE,QAAzB,CAAkC,KAAlC,CAAP,EAAiD,CAACF,IAAD,CAAjD,CADT;;AAGA,eAAeD,cAAf","sourcesContent":["import { useMemo } from 'react';\nimport crypto from 'crypto';\n\nconst useGeneratedId = (size: number) =>\n useMemo(() => crypto.randomBytes(size).toString('hex'), [size]);\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,I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kC;AACvCO,UAAAA,YAAY,CAACd,YAAY,CAAC,MAAD,EAASE,IAAI,CAACQ,UAAd,CAAb,CAAZ;AACD;;AAEDF,QAAAA,IAAI,GAAGK,IAAP;AACD;AACF,KAtBD,MAsBO;AACL,aAAO,IAAP,EAAa;AACX,cAAM,GAAGO,IAAH,GAAWN,YAAX,EAAyBC,SAAzB,IAAsCP,IAA5C;AACA,YAAI,CAACY,IAAL,EAAW,OAAOZ,IAAP;AAEX,cAAM,IAAKa,WAAL,EAAkBC,gBAAlB,EAAoCC,aAApC,IAAqDH,IAA3D;;AAEA,YAAIf,WAAW,KAAK,QAApB,EAA8B;AAC5B,gBAAMmB,YAAY,GAAG7B,WAAW,CAAC0B,WAAD,CAAhC;;AACA,cAAIG,YAAY,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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YAChE,OAAOH,IAAP;UACD;QACF;;QAED,IAAIF,aAAa,IAAIS,SAAS,GAAGR,gBAAjC,EAAmD;UACjDO,YAAY,CAACd,YAAY,CAAC,MAAD,EAASE,IAAI,CAACQ,UAAd,CAAb,CAAZ;QACD,CAFD,MAEO,IAAIa,aAAa,GAAGhB,gBAApB,EAAsC;UAC3Ce,gBAAgB,CAACtB,YAAY,CAAC,IAAD,EAAOE,IAAI,CAACQ,UAAZ,CAAb,CAAhB;QACD;;QAEDF,IAAI,GAAGY,IAAP;MACD;IACF;EACF,CA9De,EA+DhB,CAACrB,WAAD,EAAcC,YAAd,EAA4BF,QAA5B,CA/DgB,CAAlB;AAiED,CApED;;AAsEA,eAAeF,WAAf"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/useScrollEventByPoint.ts"],"names":["useCallback","useEffect","useRef","getScrollableElements","compare","prevArr","nextArr","remove","add","forEach","item","includes","push","useScrollEventByPoint","point","listener","listenerRef","current","eventListener","e","elementsRef","scrollableElements","x","y","getTarget","document","body","window","index","indexOf","splice","removeEventListener","addEventListener"],"mappings":"AAAA,SAASA,WAAT,EAAsBC,SAAtB,EAAiCC,MAAjC,QAA+C,OAA/C;AACA,SAASC,qBAAT,QAAsC,4BAAtC;;AAEA,MAAMC,OAAO,GAAG,CAAIC,OAAJ,EAAkBC,OAAlB,KAAmC;AACjD,QAAMC,MAAW,GAAG,EAApB;AACA,QAAMC,GAAQ,GAAG,EAAjB;AACAH,EAAAA,OAAO,CAACI,OAAR,CAAiBC,IAAD,IAAU;AACxB,QAAI,CAACJ,OAAO,CAACK,QAAR,CAAiBD,IAAjB,CAAL,EAA6BH,MAAM,CAACK,IAAP,CAAYF,IAAZ;AAC9B,GAFD;AAGAJ,EAAAA,OAAO,CAACG,OAAR,CAAiBC,IAAD,IAAU;AACxB,QAAI,CAACL,OAAO,CAACM,QAAR,CAAiBD,IAAjB,CAAL,EAA6BF,GAAG,CAACI,IAAJ,CAASF,IAAT;AAC9B,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IAAAA,GAAG,CAACC,OAAJ,CAAaC,IAAD,IAAU;AACpBU,MAAAA,WAAW,CAACH,OAAZ,CAAoBL,IAApB,CAAyBF,IAAzB;AACAc,MAAAA,SAAS,CAACd,IAAD,CAAT,CAAgBsB,gBAAhB,CAAiC,QAAjC,EAA2Cd,aAA3C;AACD,KAHD;AAID,GAhBQ,EAgBN,CAACA,aAAD,EAAgBJ,KAAhB,CAhBM,CAAT;AAiBD,CA7BD;;AA+BA,eAAeD,qBAAf","sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\nimport { getScrollableElements } from '@os-design/use-auto-scroll';\n\nconst compare = <T>(prevArr: T[], nextArr: T[]) => {\n const remove: T[] = [];\n const add: T[] = [];\n prevArr.forEach((item) => {\n if (!nextArr.includes(item)) remove.push(item);\n });\n nextArr.forEach((item) => {\n if (!prevArr.includes(item)) add.push(item);\n });\n return { remove, add };\n};\n\nexport interface Point {\n x: number;\n y: number;\n}\n\n/**\n * Sets the listener that will be called whenever the scroll event occurs\n * in one of the elements located under the specified point.\n */\nconst useScrollEventByPoint = (\n point: Point | null,\n listener: (e: Event) => void\n) => {\n const listenerRef = useRef(listener);\n useEffect(() => {\n listenerRef.current = listener;\n }, [listener]);\n\n const eventListener = useCallback((e: Event) => listenerRef.current(e), []);\n const elementsRef = useRef<Element[]>([]);\n\n useEffect(() => {\n if (!point) return;\n const scrollableElements = getScrollableElements(point.x, point.y);\n const { remove, add } = compare(elementsRef.current, scrollableElements);\n const getTarget = (item: Element) =>\n item === document.body ? window : item;\n\n remove.forEach((item) => {\n const index = elementsRef.current.indexOf(item);\n if (index >= 0) elementsRef.current.splice(index, 1);\n getTarget(item).removeEventListener('scroll', eventListener);\n });\n add.forEach((item) => {\n elementsRef.current.push(item);\n getTarget(item).addEventListener('scroll', eventListener);\n });\n }, [eventListener, point]);\n};\n\nexport default useScrollEventByPoint;\n"],"file":"useScrollEventByPoint.js"}
1
+ {"version":3,"file":"useScrollEventByPoint.js","names":["useCallback","useEffect","useRef","getScrollableElements","compare","prevArr","nextArr","remove","add","forEach","item","includes","push","useScrollEventByPoint","point","listener","listenerRef","current","eventListener","e","elementsRef","scrollableElements","x","y","getTarget","document","body","window","index","indexOf","splice","removeEventListener","addEventListener"],"sources":["../../../src/utils/useScrollEventByPoint.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\nimport { getScrollableElements } from '@os-design/use-auto-scroll';\n\nconst compare = <T>(prevArr: T[], nextArr: T[]) => {\n const remove: T[] = [];\n const add: T[] = [];\n prevArr.forEach((item) => {\n if (!nextArr.includes(item)) remove.push(item);\n });\n nextArr.forEach((item) => {\n if (!prevArr.includes(item)) add.push(item);\n });\n return { remove, add };\n};\n\nexport interface Point {\n x: number;\n y: number;\n}\n\n/**\n * Sets the listener that will be called whenever the scroll event occurs\n * in one of the elements located under the specified point.\n */\nconst useScrollEventByPoint = (\n point: Point | null,\n listener: (e: Event) => void\n) => {\n const listenerRef = useRef(listener);\n useEffect(() => {\n listenerRef.current = listener;\n }, [listener]);\n\n const eventListener = useCallback((e: Event) => listenerRef.current(e), []);\n const elementsRef = useRef<Element[]>([]);\n\n useEffect(() => {\n if (!point) return;\n const scrollableElements = getScrollableElements(point.x, point.y);\n const { remove, add } = compare(elementsRef.current, scrollableElements);\n const getTarget = (item: Element) =>\n item === document.body ? window : item;\n\n remove.forEach((item) => {\n const index = elementsRef.current.indexOf(item);\n if (index >= 0) elementsRef.current.splice(index, 1);\n getTarget(item).removeEventListener('scroll', eventListener);\n });\n add.forEach((item) => {\n elementsRef.current.push(item);\n getTarget(item).addEventListener('scroll', eventListener);\n });\n }, [eventListener, point]);\n};\n\nexport default useScrollEventByPoint;\n"],"mappings":"AAAA,SAASA,WAAT,EAAsBC,SAAtB,EAAiCC,MAAjC,QAA+C,OAA/C;AACA,SAASC,qBAAT,QAAsC,4BAAtC;;AAEA,MAAMC,OAAO,GAAG,CAAIC,OAAJ,EAAkBC,OAAlB,KAAmC;EACjD,MAAMC,MAAW,GAAG,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B,MAAMkB,KAAK,GAAGR,WAAW,CAACH,OAAZ,CAAoBY,OAApB,CAA4BnB,IAA5B,CAAd;MACA,IAAIkB,KAAK,IAAI,CAAb,EAAgBR,WAAW,CAACH,OAAZ,CAAoBa,MAApB,CAA2BF,KAA3B,EAAkC,CAAlC;MAChBJ,SAAS,CAACd,IAAD,CAAT,CAAgBqB,mBAAhB,CAAoC,QAApC,EAA8Cb,aAA9C;IACD,CAJD;IAKAV,GAAG,CAACC,OAAJ,CAAaC,IAAD,IAAU;MACpBU,WAAW,CAACH,OAAZ,CAAoBL,IAApB,CAAyBF,IAAzB;MACAc,SAAS,CAACd,IAAD,CAAT,CAAgBsB,gBAAhB,CAAiC,QAAjC,EAA2Cd,aAA3C;IACD,CAHD;EAID,CAhBQ,EAgBN,CAACA,aAAD,EAAgBJ,KAAhB,CAhBM,CAAT;AAiBD,CA7BD;;AA+BA,eAAeD,qBAAf"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/useTargetList.ts"],"names":["useCallback","useMemo","useState","useThrottle","useScrollEventByPoint","useTargetList","position","listStoreRef","number","setNumber","targetList","current","x","y","list","findByPosition","forceUpdate","n","throttledForceUpdate"],"mappings":"AAAA,SAAoBA,WAApB,EAAiCC,OAAjC,EAA0CC,QAA1C,QAA0D,OAA1D;AACA,OAAOC,WAAP,MAAwB,yBAAxB;AAGA,OAAOC,qBAAP,MAAkC,yBAAlC;;AAEA,MAAMC,aAAa,GAAG,CACpBC,QADoB,EAEpBC,YAFoB,KAGjB;AACH,QAAM,CAACC,MAAD,EAASC,SAAT,IAAsBP,QAAQ,CAAC,CAAD,CAApC;AAEA,QAAMQ,UAAU,GAAGT,OAAO,CAAC,MAAM;AAC/B,QAAI,CAACK,QAAD,IAAa,CAACC,YAAY,CAACI,OAA/B,EAAwC,OAAO,IAAP;AACxC,UAAM;AAAEC,MAAAA,CAAF;AAAKC,MAAAA;AAAL,QAAWP,QAAjB;AACA,UAAMQ,IAAI,GAAGP,YAAY,CAACI,OAAb,CAAqBI,cAArB,CAAoCH,CAApC,EAAuCC,CAAvC,CAAb;AACA,WAAOC,IAAI,IAAI,IAAf;AACD,GALyB,EAKvB,CAACP,YAAD,EAAeD,QAAf,EAAyBE,MAAzB,CALuB,CAA1B,CAHG,CAQmC;;AAEtC,QAAMQ,WAAW,GAAGhB,WAAW,CAAC,MAAM;AACpCS,IAAAA,SAAS,CAAEQ,CAAD,IAAOA,CAAC,GAAG,CAAZ,CAAT;AACD,GAF8B,EAE5B,EAF4B,CAA/B,CAVG,CAcH;;AACA,QAAM,CAACC,oBAAD,IAAyBf,WAAW,CAACa,WAAD,EAAc,GAAd,CAA1C;AACAZ,EAAAA,qBAAqB,CAACE,QAAD,EAAWY,oBAAX,CAArB;AAEA,SAAOR,UAAP;AACD,CAtBD;;AAwBA,eAAeL,aAAf","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":["useCallback","useMemo","useState","useThrottle","useScrollEventByPoint","useTargetList","position","listStoreRef","number","setNumber","targetList","current","x","y","list","findByPosition","forceUpdate","n","throttledForceUpdate"],"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,SAAoBA,WAApB,EAAiCC,OAAjC,EAA0CC,QAA1C,QAA0D,OAA1D;AACA,OAAOC,WAAP,MAAwB,yBAAxB;AAGA,OAAOC,qBAAP,MAAkC,yBAAlC;;AAEA,MAAMC,aAAa,GAAG,CACpBC,QADoB,EAEpBC,YAFoB,KAGjB;EACH,MAAM,CAACC,MAAD,EAASC,SAAT,IAAsBP,QAAQ,CAAC,CAAD,CAApC;EAEA,MAAMQ,UAAU,GAAGT,OAAO,CAAC,MAAM;IAC/B,IAAI,CAACK,QAAD,IAAa,CAACC,YAAY,CAACI,OAA/B,EAAwC,OAAO,IAAP;IACxC,MAAM;MAAEC,CAAF;MAAKC;IAAL,IAAWP,QAAjB;IACA,MAAMQ,IAAI,GAAGP,YAAY,CAACI,OAAb,CAAqBI,cAArB,CAAoCH,CAApC,EAAuCC,CAAvC,CAAb;IACA,OAAOC,IAAI,IAAI,IAAf;EACD,CALyB,EAKvB,CAACP,YAAD,EAAeD,QAAf,EAAyBE,MAAzB,CALuB,CAA1B,CAHG,CAQmC;;EAEtC,MAAMQ,WAAW,GAAGhB,WAAW,CAAC,MAAM;IACpCS,SAAS,CAAEQ,CAAD,IAAOA,CAAC,GAAG,CAAZ,CAAT;EACD,CAF8B,EAE5B,EAF4B,CAA/B,CAVG,CAcH;;EACA,MAAM,CAACC,oBAAD,IAAyBf,WAAW,CAACa,WAAD,EAAc,GAAd,CAA1C;EACAZ,qBAAqB,CAACE,QAAD,EAAWY,oBAAX,CAArB;EAEA,OAAOR,UAAP;AACD,CAtBD;;AAwBA,eAAeL,aAAf"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/useTransitionStyle.ts"],"names":["useEffect","useTransitionStyle","props","className","ms","enabled","style","document","createElement","innerHTML","child","head","appendChild","removeChild"],"mappings":"AAAA,SAASA,SAAT,QAA0B,OAA1B;;AAQA;AACA;AACA;AACA,MAAMC,kBAAkB,GAAIC,KAAD,IAAoC;AAC7D,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,EAAb;AAAiBC,IAAAA;AAAjB,MAA6BH,KAAnC;AAEAF,EAAAA,SAAS,CAAC,MAAM;AACd,QAAI,CAACK,OAAL,EAAc,OAAO,MAAM,CAAE,CAAf;AACd,UAAMC,KAAK,GAAGC,QAAQ,CAACC,aAAT,CAAuB,OAAvB,CAAd;AACAF,IAAAA,KAAK,CAACG,SAAN,GAAmB,IAAGN,SAAU,yBAAwBC,EAAG,MAA3D;AACA,UAAMM,KAAK,GAAGH,QAAQ,CAACI,IAAT,CAAcC,WAAd,CAA0BN,KAA1B,CAAd;AACA,WAAO,MAAM;AACXC,MAAAA,QAAQ,CAACI,IAAT,CAAcE,WAAd,CAA0BH,KAA1B;AACD,KAFD;AAGD,GARQ,EAQN,CAACP,SAAD,EAAYE,OAAZ,EAAqBD,EAArB,CARM,CAAT;AASD,CAZD;;AAcA,eAAeH,kBAAf","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":["useEffect","useTransitionStyle","props","className","ms","enabled","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,SAASA,SAAT,QAA0B,OAA1B;;AAQA;AACA;AACA;AACA,MAAMC,kBAAkB,GAAIC,KAAD,IAAoC;EAC7D,MAAM;IAAEC,SAAF;IAAaC,EAAb;IAAiBC;EAAjB,IAA6BH,KAAnC;EAEAF,SAAS,CAAC,MAAM;IACd,IAAI,CAACK,OAAL,EAAc,OAAO,MAAM,CAAE,CAAf;IACd,MAAMC,KAAK,GAAGC,QAAQ,CAACC,aAAT,CAAuB,OAAvB,CAAd;IACAF,KAAK,CAACG,SAAN,GAAmB,IAAGN,SAAU,yBAAwBC,EAAG,MAA3D;IACA,MAAMM,KAAK,GAAGH,QAAQ,CAACI,IAAT,CAAcC,WAAd,CAA0BN,KAA1B,CAAd;IACA,OAAO,MAAM;MACXC,QAAQ,CAACI,IAAT,CAAcE,WAAd,CAA0BH,KAA1B;IACD,CAFD;EAGD,CARQ,EAQN,CAACP,SAAD,EAAYE,OAAZ,EAAqBD,EAArB,CARM,CAAT;AASD,CAZD;;AAcA,eAAeH,kBAAf"}
@@ -1 +1 @@
1
- {"version":3,"file":"DragAndDrop.d.ts","sourceRoot":"","sources":["../../src/DragAndDrop.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AASf,OAAe,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKxD,OAAsB,EACpB,cAAc,EAEf,MAAM,uBAAuB,CAAC;AAK/B,MAAM,WAAW,gBAAgB;IAK/B,oBAAoB,CAAC,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;IAKhD,cAAc,CAAC,EAAE,MAAM,CAAC;IAKxB,WAAW,CAAC,EAAE,MAAM,CAAC;IAKrB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAK/B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAK9B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAK3B,SAAS,CAAC,EAAE,cAAc,CAAC;IAK3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAUD,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAkJ3C,CAAC;AAEF,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"DragAndDrop.d.ts","sourceRoot":"","sources":["../../src/DragAndDrop.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AASf,OAAe,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKxD,OAAsB,EACpB,cAAc,EAEf,MAAM,uBAAuB,CAAC;AAK/B,MAAM,WAAW,gBAAgB;IAK/B,oBAAoB,CAAC,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;IAKhD,cAAc,CAAC,EAAE,MAAM,CAAC;IAKxB,WAAW,CAAC,EAAE,MAAM,CAAC;IAKrB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAK/B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAK9B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAK3B,SAAS,CAAC,EAAE,cAAc,CAAC;IAK3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAUD,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAmJ3C,CAAC;AAEF,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,eAAe,WAAW,CAAC"}
@@ -10,6 +10,7 @@ export interface DraggableChildrenProps {
10
10
  }
11
11
  export interface DraggableProps {
12
12
  index: number;
13
+ id: string;
13
14
  children: (props: DraggableChildrenProps) => React.ReactNode;
14
15
  }
15
16
  declare const Draggable: React.FC<DraggableProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"Draggable.d.ts","sourceRoot":"","sources":["../../src/Draggable.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,aAAa,EACb,SAAS,EAKT,UAAU,EACV,UAAU,EACX,MAAM,OAAO,CAAC;AAOf,MAAM,WAAW,iBAAiB;IAIhC,WAAW,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IAIrC,YAAY,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;CACvC;AAED,MAAM,WAAW,sBAAsB;IAIrC,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC;IAIpB,KAAK,EAAE,aAAa,CAAC;IAIrB,QAAQ,EAAE,iBAAiB,CAAC;CAC7B;AAED,MAAM,WAAW,cAAc;IAI7B,KAAK,EAAE,MAAM,CAAC;IAId,QAAQ,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,KAAK,CAAC,SAAS,CAAC;CAC9D;AAED,QAAA,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CA+CvC,CAAC;AAEF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"Draggable.d.ts","sourceRoot":"","sources":["../../src/Draggable.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,aAAa,EACb,SAAS,EAKT,UAAU,EACV,UAAU,EACX,MAAM,OAAO,CAAC;AAOf,MAAM,WAAW,iBAAiB;IAIhC,WAAW,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IAIrC,YAAY,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;CACvC;AAED,MAAM,WAAW,sBAAsB;IAIrC,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC;IAIpB,KAAK,EAAE,aAAa,CAAC;IAIrB,QAAQ,EAAE,iBAAiB,CAAC;CAC7B;AAED,MAAM,WAAW,cAAc;IAI7B,KAAK,EAAE,MAAM,CAAC;IAId,EAAE,EAAE,MAAM,CAAC;IAIX,QAAQ,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,KAAK,CAAC,SAAS,CAAC;CAC9D;AAED,QAAA,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CA+CvC,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -1,13 +1,15 @@
1
1
  import React, { CSSProperties, RefObject } from 'react';
2
- export declare type Node = [Node, Node, RefObject<any>, (style: CSSProperties) => void, number] | null;
2
+ export declare type Node = [Node, Node, RefObject<any>, (style: CSSProperties) => void, number, string] | null;
3
3
  export declare type ExistingNode = Exclude<Node, null>;
4
4
  export interface NodeProps {
5
5
  ref: React.MutableRefObject<any>;
6
6
  setStyle: (style: CSSProperties) => void;
7
7
  index: number;
8
+ id: string;
8
9
  }
9
10
  interface RenderDraggedNodeProps {
10
11
  index: number;
12
+ id: string;
11
13
  style: CSSProperties;
12
14
  }
13
15
  export declare type RenderDraggedNode = (props: RenderDraggedNode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ED,UAAU,iBAAiB;IACzB,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IAChC,UAAU,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC5B,mBAAmB,EAAE,QAAQ,GAAG,IAAI,CAAC;CACtC;AAWD,QAAA,MAAM,YAAY,UAAW,iBAAiB,eAyE7C,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"useBlankNode.d.ts","sourceRoot":"","sources":["../../../src/utils/useBlankNode.ts"],"names":[],"mappings":"AACA,OAAO,QAA0B,MAAM,YAAY,CAAC;AAEpD,UAAU,QAAQ;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,WAAW;IACnB,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED,UAAU,iBAAiB;IACzB,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IAChC,UAAU,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC5B,mBAAmB,EAAE,QAAQ,GAAG,IAAI,CAAC;CACtC;AAWD,QAAA,MAAM,YAAY,UAAW,iBAAiB,eA0E7C,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -8,8 +8,9 @@ export interface DraggedNode {
8
8
  position: Position;
9
9
  }
10
10
  export interface ItemLocation {
11
- id: string;
11
+ listId: string;
12
12
  index: number;
13
+ id: string;
13
14
  }
14
15
  export declare type DragEndHandler = (dragged: ItemLocation, target: ItemLocation) => void;
15
16
  interface UseDragEffectProps {