@os-design/drag-sort 1.0.25 → 1.0.27

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 (50) hide show
  1. package/dist/cjs/DragAndDrop.js +5 -6
  2. package/dist/cjs/DragAndDrop.js.map +1 -1
  3. package/dist/cjs/Draggable.js +5 -6
  4. package/dist/cjs/Draggable.js.map +1 -1
  5. package/dist/cjs/Droppable.js +4 -5
  6. package/dist/cjs/Droppable.js.map +1 -1
  7. package/dist/cjs/index.js +3 -3
  8. package/dist/cjs/index.js.map +1 -1
  9. package/dist/cjs/utils/ListStore.js +4 -5
  10. package/dist/cjs/utils/ListStore.js.map +1 -1
  11. package/dist/cjs/utils/NodeList.js +5 -6
  12. package/dist/cjs/utils/NodeList.js.map +1 -1
  13. package/dist/cjs/utils/getElementOffset.js +1 -2
  14. package/dist/cjs/utils/getElementOffset.js.map +1 -1
  15. package/dist/cjs/utils/getElementScroll.js +1 -2
  16. package/dist/cjs/utils/getElementScroll.js.map +1 -1
  17. package/dist/cjs/utils/getNodeRect.js +1 -2
  18. package/dist/cjs/utils/getNodeRect.js.map +1 -1
  19. package/dist/cjs/utils/useAppendClassName.js +1 -2
  20. package/dist/cjs/utils/useAppendClassName.js.map +1 -1
  21. package/dist/cjs/utils/useBlankNode.js +2 -3
  22. package/dist/cjs/utils/useBlankNode.js.map +1 -1
  23. package/dist/cjs/utils/useDragAndDrop.js +5 -7
  24. package/dist/cjs/utils/useDragAndDrop.js.map +1 -1
  25. package/dist/cjs/utils/useDragEffect.js +2 -3
  26. package/dist/cjs/utils/useDragEffect.js.map +1 -1
  27. package/dist/cjs/utils/useDroppable.js +5 -7
  28. package/dist/cjs/utils/useDroppable.js.map +1 -1
  29. package/dist/cjs/utils/useGeneratedId.js +1 -2
  30. package/dist/cjs/utils/useGeneratedId.js.map +1 -1
  31. package/dist/cjs/utils/useGetNodeStyle.js +1 -2
  32. package/dist/cjs/utils/useGetNodeStyle.js.map +1 -1
  33. package/dist/cjs/utils/useInitRect.js +1 -2
  34. package/dist/cjs/utils/useInitRect.js.map +1 -1
  35. package/dist/cjs/utils/useInitScrollOffset.js +1 -2
  36. package/dist/cjs/utils/useInitScrollOffset.js.map +1 -1
  37. package/dist/cjs/utils/useMoveNode.js +2 -3
  38. package/dist/cjs/utils/useMoveNode.js.map +1 -1
  39. package/dist/cjs/utils/useScrollEventByPoint.js +1 -2
  40. package/dist/cjs/utils/useScrollEventByPoint.js.map +1 -1
  41. package/dist/cjs/utils/useTargetList.js +2 -3
  42. package/dist/cjs/utils/useTargetList.js.map +1 -1
  43. package/dist/cjs/utils/useTransitionStyle.js +1 -2
  44. package/dist/cjs/utils/useTransitionStyle.js.map +1 -1
  45. package/dist/esm/Droppable.js.map +1 -1
  46. package/dist/esm/utils/NodeList.js +4 -1
  47. package/dist/esm/utils/NodeList.js.map +1 -1
  48. package/dist/types/Droppable.d.ts.map +1 -1
  49. package/package.json +13 -13
  50. package/src/Droppable.tsx +4 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useMoveNode.js","names":["_react","require","_getNodeRect","_interopRequireDefault","obj","__esModule","_slicedToArray","arr","i","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","o","minLen","_arrayLikeToArray","n","Object","prototype","toString","call","slice","constructor","name","Array","from","test","len","length","arr2","_i","Symbol","iterator","_s","_e","_x","_r","_arr","_n","_d","next","done","push","value","err","isArray","useMoveNode","props","position","draggedNode","getNodeStyle","useCallback","options","list","startNode","direction","destination","_options$isAnotherLis","isAnotherList","_draggedNode$node","node","draggedNodeIndex","axis","horizontal","startRectProp","endRectProp","_node","_node2","prev","nodeSetStyle","nodeIndex","_prev","prevNodeRef","prevNodeSetStyle","prevNodeIndex","prevNodeRect","getNodeRect","_node3","_node4","_next","nextNodeRef","nextNodeSetStyle","nextNodeIndex","nextNodeRect","_default","exports"],"sources":["../../../src/utils/useMoveNode.ts"],"sourcesContent":["import { Position } from '@os-design/use-drag';\nimport { useCallback } from 'react';\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":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAwC,SAAAE,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAAA,SAAAE,eAAAC,GAAA,EAAAC,CAAA,WAAAC,eAAA,CAAAF,GAAA,KAAAG,qBAAA,CAAAH,GAAA,EAAAC,CAAA,KAAAG,2BAAA,CAAAJ,GAAA,EAAAC,CAAA,KAAAI,gBAAA;AAAA,SAAAA,iBAAA,cAAAC,SAAA;AAAA,SAAAF,4BAAAG,CAAA,EAAAC,MAAA,SAAAD,CAAA,qBAAAA,CAAA,sBAAAE,iBAAA,CAAAF,CAAA,EAAAC,MAAA,OAAAE,CAAA,GAAAC,MAAA,CAAAC,SAAA,CAAAC,QAAA,CAAAC,IAAA,CAAAP,CAAA,EAAAQ,KAAA,aAAAL,CAAA,iBAAAH,CAAA,CAAAS,WAAA,EAAAN,CAAA,GAAAH,CAAA,CAAAS,WAAA,CAAAC,IAAA,MAAAP,CAAA,cAAAA,CAAA,mBAAAQ,KAAA,CAAAC,IAAA,CAAAZ,CAAA,OAAAG,CAAA,+DAAAU,IAAA,CAAAV,CAAA,UAAAD,iBAAA,CAAAF,CAAA,EAAAC,MAAA;AAAA,SAAAC,kBAAAT,GAAA,EAAAqB,GAAA,QAAAA,GAAA,YAAAA,GAAA,GAAArB,GAAA,CAAAsB,MAAA,EAAAD,GAAA,GAAArB,GAAA,CAAAsB,MAAA,WAAArB,CAAA,MAAAsB,IAAA,OAAAL,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D;QAEAH,IAAI,GAAGpB,IAAI;MACb;IACF;EACF,CAAC,EACD,CAACS,WAAW,EAAEC,YAAY,EAAEF,QAAQ,CACtC,CAAC;AACH,CAAC;AAAC,IAAAoC,QAAA,GAEatC,WAAW;AAAAuC,OAAA,cAAAD,QAAA"}
1
+ {"version":3,"file":"useMoveNode.js","names":["_react","require","_getNodeRect","_interopRequireDefault","obj","__esModule","_slicedToArray","arr","i","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","o","minLen","_arrayLikeToArray","n","Object","prototype","toString","call","slice","constructor","name","Array","from","test","len","length","arr2","r","l","t","Symbol","iterator","e","u","a","f","next","done","push","value","isArray","useMoveNode","props","position","draggedNode","getNodeStyle","useCallback","options","list","startNode","direction","destination","_options$isAnotherLis","isAnotherList","_draggedNode$node","node","draggedNodeIndex","axis","horizontal","startRectProp","endRectProp","_node","_node2","prev","nodeSetStyle","nodeIndex","_prev","prevNodeRef","prevNodeSetStyle","prevNodeIndex","prevNodeRect","getNodeRect","_node3","_node4","_next","nextNodeRef","nextNodeSetStyle","nextNodeIndex","nextNodeRect","_default","exports"],"sources":["../../../src/utils/useMoveNode.ts"],"sourcesContent":["import { Position } from '@os-design/use-drag';\nimport { useCallback } from 'react';\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":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAwC,SAAAE,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAAA,SAAAE,eAAAC,GAAA,EAAAC,CAAA,WAAAC,eAAA,CAAAF,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UAAvCpC,IAAI,GAAAqC,MAAA;UAAIT,aAAY,GAAAS,MAAA;UAAER,UAAS,GAAAQ,MAAA;QACxC,IAAI,CAACrC,IAAI,EAAE,OAAOmB,IAAI;QAEtB,IAAAmB,KAAA,GAAAxE,cAAA,CAA2DkC,IAAI;UAApDuC,WAAW,GAAAD,KAAA;UAAEE,gBAAgB,GAAAF,KAAA;UAAEG,aAAa,GAAAH,KAAA;QAEvD,IAAIvB,WAAW,KAAK,QAAQ,EAAE;UAC5B,IAAM2B,YAAY,GAAG,IAAAP,uBAAW,EAACI,WAAW,CAAC;UAC7C,IAAIG,YAAY,IAAInC,QAAQ,CAACc,IAAI,CAAC,GAAGqB,YAAY,CAACnB,aAAa,CAAC,EAAE;YAChE,OAAOJ,IAAI;UACb;QACF;QAEA,IAAIF,aAAa,IAAIY,UAAS,GAAGT,gBAAgB,EAAE;UACjDQ,aAAY,CAACnB,YAAY,CAAC,MAAM,EAAEG,IAAI,CAACU,UAAU,CAAC,CAAC;QACrD,CAAC,MAAM,IAAImB,aAAa,GAAGrB,gBAAgB,EAAE;UAC3CoB,gBAAgB,CAAC/B,YAAY,CAAC,IAAI,EAAEG,IAAI,CAACU,UAAU,CAAC,CAAC;QACvD;QAEAH,IAAI,GAAGnB,IAAI;MACb;IACF;EACF,CAAC,EACD,CAACQ,WAAW,EAAEC,YAAY,EAAEF,QAAQ,CACtC,CAAC;AACH,CAAC;AAAC,IAAAoC,QAAA,GAAAC,OAAA,cAEavC,WAAW"}
@@ -53,6 +53,5 @@ var useScrollEventByPoint = function useScrollEventByPoint(point, listener) {
53
53
  });
54
54
  }, [eventListener, point]);
55
55
  };
56
- var _default = useScrollEventByPoint;
57
- exports["default"] = _default;
56
+ var _default = exports["default"] = useScrollEventByPoint;
58
57
  //# sourceMappingURL=useScrollEventByPoint.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useScrollEventByPoint.js","names":["_useAutoScroll","require","_react","compare","prevArr","nextArr","remove","add","forEach","item","includes","push","useScrollEventByPoint","point","listener","listenerRef","useRef","useEffect","current","eventListener","useCallback","e","elementsRef","scrollableElements","getScrollableElements","x","y","_compare","getTarget","document","body","window","index","indexOf","splice","removeEventListener","addEventListener","_default","exports"],"sources":["../../../src/utils/useScrollEventByPoint.ts"],"sourcesContent":["import { getScrollableElements } from '@os-design/use-auto-scroll';\nimport { useCallback, useEffect, useRef } from 'react';\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,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAME,OAAO,GAAG,SAAVA,OAAOA,CAAOC,OAAY,EAAEC,OAAY,EAAK;EACjD,IAAMC,MAAW,GAAG,EAAE;EACtB,IAAMC,GAAQ,GAAG,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AS,GAAG,SAAZA,SAASA,CAAInB,IAAa;MAAA,OAC9BA,IAAI,KAAKoB,QAAQ,CAACC,IAAI,GAAGC,MAAM,GAAGtB,IAAI;IAAA;IAExCH,MAAM,CAACE,OAAO,CAAC,UAACC,IAAI,EAAK;MACvB,IAAMuB,KAAK,GAAGV,WAAW,CAACJ,OAAO,CAACe,OAAO,CAACxB,IAAI,CAAC;MAC/C,IAAIuB,KAAK,IAAI,CAAC,EAAEV,WAAW,CAACJ,OAAO,CAACgB,MAAM,CAACF,KAAK,EAAE,CAAC,CAAC;MACpDJ,SAAS,CAACnB,IAAI,CAAC,CAAC0B,mBAAmB,CAAC,QAAQ,EAAEhB,aAAa,CAAC;IAC9D,CAAC,CAAC;IACFZ,GAAG,CAACC,OAAO,CAAC,UAACC,IAAI,EAAK;MACpBa,WAAW,CAACJ,OAAO,CAACP,IAAI,CAACF,IAAI,CAAC;MAC9BmB,SAAS,CAACnB,IAAI,CAAC,CAAC2B,gBAAgB,CAAC,QAAQ,EAAEjB,aAAa,CAAC;IAC3D,CAAC,CAAC;EACJ,CAAC,EAAE,CAACA,aAAa,EAAEN,KAAK,CAAC,CAAC;AAC5B,CAAC;AAAC,IAAAwB,QAAA,GAEazB,qBAAqB;AAAA0B,OAAA,cAAAD,QAAA"}
1
+ {"version":3,"file":"useScrollEventByPoint.js","names":["_useAutoScroll","require","_react","compare","prevArr","nextArr","remove","add","forEach","item","includes","push","useScrollEventByPoint","point","listener","listenerRef","useRef","useEffect","current","eventListener","useCallback","e","elementsRef","scrollableElements","getScrollableElements","x","y","_compare","getTarget","document","body","window","index","indexOf","splice","removeEventListener","addEventListener","_default","exports"],"sources":["../../../src/utils/useScrollEventByPoint.ts"],"sourcesContent":["import { getScrollableElements } from '@os-design/use-auto-scroll';\nimport { useCallback, useEffect, useRef } from 'react';\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,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAME,OAAO,GAAG,SAAVA,OAAOA,CAAOC,OAAY,EAAEC,OAAY,EAAK;EACjD,IAAMC,MAAW,GAAG,EAAE;EACtB,IAAMC,GAAQ,GAAG,EAAE;EACnBH,OAAO,CAACI,OAAO,CAAC,UAACC,IAAI,EAAK;IACxB,IAAI,CAACJ,OAAO,CAACK,QAAQ,CAACD,IAAI,CAAC,EAAEH,MAAM,CAACK,IAAI,CAACF,IAAI,CAAC;EAChD,CAAC,CAAC;EACFJ,OAAO,CAACG,OAAO,CAAC,UAACC,IAAI,EAAK;IACxB,IAAI,CAACL,OAAO,CAACM,QAAQ,CAACD,IAAI,CAAC,EAAEF,GAAG,CAACI,IAAI,CAACF,IAAI,CAAC;EAC7C,CAAC,CAAC;EACF,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AC;MACpDJ,SAAS,CAACnB,IAAI,CAAC,CAAC0B,mBAAmB,CAAC,QAAQ,EAAEhB,aAAa,CAAC;IAC9D,CAAC,CAAC;IACFZ,GAAG,CAACC,OAAO,CAAC,UAACC,IAAI,EAAK;MACpBa,WAAW,CAACJ,OAAO,CAACP,IAAI,CAACF,IAAI,CAAC;MAC9BmB,SAAS,CAACnB,IAAI,CAAC,CAAC2B,gBAAgB,CAAC,QAAQ,EAAEjB,aAAa,CAAC;IAC3D,CAAC,CAAC;EACJ,CAAC,EAAE,CAACA,aAAa,EAAEN,KAAK,CAAC,CAAC;AAC5B,CAAC;AAAC,IAAAwB,QAAA,GAAAC,OAAA,cAEa1B,qBAAqB"}
@@ -12,7 +12,7 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArra
12
12
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
13
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14
14
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
15
- function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
15
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
16
16
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
17
  var useTargetList = function useTargetList(position, listStoreRef) {
18
18
  var _useState = (0, _react.useState)(0),
@@ -40,6 +40,5 @@ var useTargetList = function useTargetList(position, listStoreRef) {
40
40
  (0, _useScrollEventByPoint["default"])(position, throttledForceUpdate);
41
41
  return targetList;
42
42
  };
43
- var _default = useTargetList;
44
- exports["default"] = _default;
43
+ var _default = exports["default"] = useTargetList;
45
44
  //# sourceMappingURL=useTargetList.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useTargetList.js","names":["_useThrottle3","_interopRequireDefault","require","_react","_useScrollEventByPoint","obj","__esModule","_slicedToArray","arr","i","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","o","minLen","_arrayLikeToArray","n","Object","prototype","toString","call","slice","constructor","name","Array","from","test","len","length","arr2","_i","Symbol","iterator","_s","_e","_x","_r","_arr","_n","_d","next","done","push","value","err","isArray","useTargetList","position","listStoreRef","_useState","useState","_useState2","number","setNumber","targetList","useMemo","current","x","y","list","findByPosition","forceUpdate","useCallback","_useThrottle","useThrottle","_useThrottle2","throttledForceUpdate","useScrollEventByPoint","_default","exports"],"sources":["../../../src/utils/useTargetList.ts"],"sourcesContent":["import { Position } from '@os-design/use-drag';\nimport useThrottle from '@os-design/use-throttle';\nimport { RefObject, useCallback, useMemo, useState } from 'react';\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":";;;;;;AACA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,sBAAA,GAAAH,sBAAA,CAAAC,OAAA;AAA4D,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAAA,SAAAE,eAAAC,GAAA,EAAAC,CAAA,WAAAC,eAAA,CAAAF,GAAA,KAAAG,qBAAA,CAAAH,GAAA,EAAAC,CAAA,KAAAG,2BAAA,CAAAJ,GAAA,EAAAC,CAAA,KAAAI,gBAAA;AAAA,SAAAA,iBAAA,cAAAC,SAAA;AAAA,SAAAF,4BAAAG,CAAA,EAAAC,MAAA,SAAAD,CAAA,qBAAAA,CAAA,sBAAAE,iBAAA,CAAAF,CAAA,EAAAC,MAAA,OAAAE,CAAA,GAAAC,MAAA,CAAAC,SAAA,CAAAC,QAAA,CAAAC,IAAA,CAAAP,CAAA,EAAAQ,KAAA,aAAAL,CAAA,iBAAAH,CAAA,CAAAS,WAAA,EAAAN,CAAA,GAAAH,CAAA,CAAAS,WAAA,CAAAC,IAAA,MAAAP,CA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_interopRequireDefault","require","_react","_useScrollEventByPoint","obj","__esModule","_slicedToArray","arr","i","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","o","minLen","_arrayLikeToArray","n","Object","prototype","toString","call","slice","constructor","name","Array","from","test","len","length","arr2","r","l","t","Symbol","iterator","e","u","a","f","next","done","push","value","isArray","useTargetList","position","listStoreRef","_useState","useState","_useState2","number","setNumber","targetList","useMemo","current","x","y","list","findByPosition","forceUpdate","useCallback","_useThrottle","useThrottle","_useThrottle2","throttledForceUpdate","useScrollEventByPoint","_default","exports"],"sources":["../../../src/utils/useTargetList.ts"],"sourcesContent":["import { Position } from '@os-design/use-drag';\nimport useThrottle from '@os-design/use-throttle';\nimport { RefObject, useCallback, useMemo, useState } from 'react';\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":";;;;;;AACA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,sBAAA,GAAAH,sBAAA,CAAAC,OAAA;AAA4D,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAAA,SAAAE,eAAAC,GAAA,EAAAC,CAAA,WAAAC,eAAA,CAA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ACpCT,SAAS,CAAC,UAACnC,CAAC;MAAA,OAAKA,CAAC,GAAG,CAAC;IAAA,EAAC;EACzB,CAAC,EAAE,EAAE,CAAC;;EAEN;EACA,IAAA6C,YAAA,GAA+B,IAAAC,wBAAW,EAACH,WAAW,EAAE,GAAG,CAAC;IAAAI,aAAA,GAAA1D,cAAA,CAAAwD,YAAA;IAArDG,oBAAoB,GAAAD,aAAA;EAC3B,IAAAE,iCAAqB,EAACpB,QAAQ,EAAEmB,oBAAoB,CAAC;EAErD,OAAOZ,UAAU;AACnB,CAAC;AAAC,IAAAc,QAAA,GAAAC,OAAA,cAEavB,aAAa"}
@@ -22,6 +22,5 @@ var useTransitionStyle = function useTransitionStyle(props) {
22
22
  };
23
23
  }, [className, enabled, ms]);
24
24
  };
25
- var _default = useTransitionStyle;
26
- exports["default"] = _default;
25
+ var _default = exports["default"] = useTransitionStyle;
27
26
  //# sourceMappingURL=useTransitionStyle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useTransitionStyle.js","names":["_react","require","useTransitionStyle","props","className","ms","enabled","useEffect","style","document","createElement","innerHTML","concat","child","head","appendChild","removeChild","_default","exports"],"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,IAAAA,MAAA,GAAAC,OAAA;AAQA;AACA;AACA;AACA,IAAMC,kBAAkB,GAAG,SAArBA,kBAAkBA,CAAIC,KAA8B,EAAK;EAC7D,IAAQC,SAAS,GAAkBD,KAAK,CAAhCC,SAAS;IAAEC,EAAE,GAAcF,KAAK,CAArBE,EAAE;IAAEC,OAAO,GAAKH,KAAK,CAAjBG,OAAO;EAE9B,IAAAC,gBAAS,EAAC,YAAM;IACd,IAAI,CAACD,OAAO,EAAE,OAAO,YAAM,CAAC,CAAC;IAC7B,IAAME,KAAK,GAAGC,QAAQ,CAACC,aAAa,CAAC,OAAO,CAAC;IAC7CF,KAAK,CAACG,SAAS,OAAAC,MAAA,CAAOR,SAAS,4BAAAQ,MAAA,CAAyBP,EAAE,SAAM;IAChE,IAAMQ,KAAK,GAAGJ,QAAQ,CAACK,IAAI,CAACC,WAAW,CAACP,KAAK,CAAC;IAC9C,OAAO,YAAM;MACXC,QAAQ,CAACK,IAAI,CAACE,WAAW,CAACH,KAAK,CAAC;IAClC,CAAC;EACH,CAAC,EAAE,CAACT,SAAS,EAAEE,OAAO,EAAED,EAAE,CAAC,CAAC;AAC9B,CAAC;AAAC,IAAAY,QAAA,GAEaf,kBAAkB;AAAAgB,OAAA,cAAAD,QAAA"}
1
+ {"version":3,"file":"useTransitionStyle.js","names":["_react","require","useTransitionStyle","props","className","ms","enabled","useEffect","style","document","createElement","innerHTML","concat","child","head","appendChild","removeChild","_default","exports"],"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,IAAAA,MAAA,GAAAC,OAAA;AAQA;AACA;AACA;AACA,IAAMC,kBAAkB,GAAG,SAArBA,kBAAkBA,CAAIC,KAA8B,EAAK;EAC7D,IAAQC,SAAS,GAAkBD,KAAK,CAAhCC,SAAS;IAAEC,EAAE,GAAcF,KAAK,CAArBE,EAAE;IAAEC,OAAO,GAAKH,KAAK,CAAjBG,OAAO;EAE9B,IAAAC,gBAAS,EAAC,YAAM;IACd,IAAI,CAACD,OAAO,EAAE,OAAO,YAAM,CAAC,CAAC;IAC7B,IAAME,KAAK,GAAGC,QAAQ,CAACC,aAAa,CAAC,OAAO,CAAC;IAC7CF,KAAK,CAACG,SAAS,OAAAC,MAAA,CAAOR,SAAS,4BAAAQ,MAAA,CAAyBP,EAAE,SAAM;IAChE,IAAMQ,KAAK,GAAGJ,QAAQ,CAACK,IAAI,CAACC,WAAW,CAACP,KAAK,CAAC;IAC9C,OAAO,YAAM;MACXC,QAAQ,CAACK,IAAI,CAACE,WAAW,CAACH,KAAK,CAAC;IAClC,CAAC;EACH,CAAC,EAAE,CAACT,SAAS,EAAEE,OAAO,EAAED,EAAE,CAAC,CAAC;AAC9B,CAAC;AAAC,IAAAY,QAAA,GAAAC,OAAA,cAEahB,kBAAkB"}
@@ -1 +1 @@
1
- {"version":3,"file":"Droppable.js","names":["useMemoObject","React","useCallback","useEffect","useMemo","useRef","NodeList","useDragAndDrop","DroppableContext","useGeneratedId","Droppable","renderDraggedNode","id","horizontal","children","ref","innerRef","generatedId","droppableId","listRef","current","registerList","deregisterList","onMouseDown","onTouchStart","listId","registerNode","props","add","deregisterNode","node","remove","mouseDownHandler","e","touchStartHandler","droppableContext","createElement","Provider","value"],"sources":["../../src/Droppable.tsx"],"sourcesContent":["import useMemoObject from '@os-design/use-memo-object';\nimport React, {\n MouseEvent,\n RefObject,\n TouchEvent,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from 'react';\nimport NodeList, {\n ExistingNode,\n NodeProps,\n RenderDraggedNode,\n} from './utils/NodeList';\nimport useDragAndDrop from './utils/useDragAndDrop';\nimport { DroppableContext } from './utils/useDroppable';\nimport useGeneratedId from './utils/useGeneratedId';\n\nexport interface DroppableChildrenProps {\n /**\n * The reference to the list.\n * If a virtual list is used, pass it to the outerRef prop.\n */\n ref: RefObject<HTMLDivElement>;\n /**\n * The reference to the container inside the virtual list.\n * Pass it to the innerRef prop.\n */\n innerRef: RefObject<HTMLDivElement>;\n}\n\nexport interface DroppableProps {\n /**\n * The function that renders the dragged node.\n */\n renderDraggedNode: RenderDraggedNode;\n /**\n * The ID of the list with draggable nodes.\n * Used to determine in which list the dragged node was dropped.\n * @default undefined\n */\n id?: string;\n /**\n * Whether the list is horizontal.\n * @default false\n */\n horizontal?: boolean;\n /**\n * The function that renders the list with draggable nodes.\n */\n children: (props: DroppableChildrenProps) => React.ReactNode;\n}\n\nconst Droppable: React.FC<DroppableProps> = ({\n renderDraggedNode,\n id,\n horizontal = false,\n children,\n}) => {\n // The reference to the list\n const ref = useRef<HTMLDivElement>(null);\n // The reference to the container inside the virtual list\n const innerRef = useRef<HTMLDivElement>(null);\n // The unique ID of the list. If no ID was specified, the generated one is used.\n const generatedId = useGeneratedId();\n const droppableId = useMemo(() => id || generatedId, [generatedId, id]);\n // The reference to the list of nodes\n const listRef = useRef(\n new NodeList({\n id: droppableId,\n ref,\n innerRef,\n horizontal,\n renderDraggedNode,\n })\n );\n\n // Update the ID of the list if it changes\n useEffect(() => {\n listRef.current.id = droppableId;\n }, [droppableId]);\n\n // Update the list orientation if it changes.\n // There is no need to check the order of the nodes in the list because it will be the same.\n useEffect(() => {\n listRef.current.horizontal = horizontal;\n }, [horizontal]);\n\n // Update the callback that renders the dragged node if it changes\n useEffect(() => {\n listRef.current.renderDraggedNode = renderDraggedNode;\n }, [renderDraggedNode]);\n\n const { registerList, deregisterList, onMouseDown, onTouchStart } =\n useDragAndDrop();\n\n // Register the list in the store\n useEffect(() => {\n registerList(listRef.current);\n const listId = listRef.current.id;\n return () => deregisterList(listId);\n }, [deregisterList, registerList]);\n\n const registerNode = useCallback(\n (props: NodeProps) => listRef.current.add(props),\n []\n );\n const deregisterNode = useCallback((node: ExistingNode) => {\n listRef.current.remove(node);\n }, []);\n\n // Handlers that determine whether a user clicks on the node\n const mouseDownHandler = useCallback(\n (e: MouseEvent, node: ExistingNode) => {\n onMouseDown(e, listRef.current, node);\n },\n [onMouseDown]\n );\n const touchStartHandler = useCallback(\n (e: TouchEvent, node: ExistingNode) => {\n onTouchStart(e, listRef.current, node);\n },\n [onTouchStart]\n );\n\n const droppableContext = useMemoObject({\n registerNode,\n deregisterNode,\n onMouseDown: mouseDownHandler,\n onTouchStart: touchStartHandler,\n });\n\n return (\n <DroppableContext.Provider value={droppableContext}>\n {(children as Function)({ ref, innerRef })}\n </DroppableContext.Provider>\n );\n};\n\nexport default Droppable;\n"],"mappings":"AAAA,OAAOA,aAAa,MAAM,4BAA4B;AACtD,OAAOC,KAAK,IAIVC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,QACD,OAAO;AACd,OAAOC,QAAQ,MAIR,kBAAkB;AACzB,OAAOC,cAAc,MAAM,wBAAwB;AACnD,SAASC,gBAAgB,QAAQ,sBAAsB;AACvD,OAAOC,cAAc,MAAM,wBAAwB;AAqCnD,MAAMC,SAAmC,GAAGA,CAAC;EAC3CC,iBAAiB;EACjBC,EAAE;EACFC,UAAU,GAAG,KAAK;EAClBC;AACF,CAAC,KAAK;EACJ;EACA,MAAMC,GAAG,GAAGV,MAAM,CAAiB,IAAI,CAAC;EACxC;EACA,MAAMW,QAAQ,GAAGX,MAAM,CAAiB,IAAI,CAAC;EAC7C;EACA,MAAMY,WAAW,GAAGR,cAAc,CAAC,CAAC;EACpC,MAAMS,WAAW,GAAGd,OAAO,CAAC,MAAMQ,EAAE,IAAIK,WAAW,EAAE,CAACA,WAAW,EAAEL,EAAE,CAAC,CAAC;EACvE;EACA,MAAMO,OAAO,GAAGd,MAAM,CACpB,IAAIC,QAAQ,CAAC;IACXM,EAAE,EAAEM,WAAW;IACfH,GAAG;IACHC,QAAQ;IACRH,U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WAAW,CACnC,CAAC+B,CAAa,EAAEH,IAAkB,KAAK;IACrCN,YAAY,CAACS,CAAC,EAAEd,OAAO,CAACC,OAAO,EAAEU,IAAI,CAAC;EACxC,CAAC,EACD,CAACN,YAAY,CACf,CAAC;EAED,MAAMW,gBAAgB,GAAGnC,aAAa,CAAC;IACrC0B,YAAY;IACZG,cAAc;IACdN,WAAW,EAAES,gBAAgB;IAC7BR,YAAY,EAAEU;EAChB,CAAC,CAAC;EAEF,oBACEjC,KAAA,CAAAmC,aAAA,CAAC5B,gBAAgB,CAAC6B,QAAQ;IAACC,KAAK,EAAEH;EAAiB,GAC/CrB,QAAQ,CAAc;IAAEC,GAAG;IAAEC;EAAS,CAAC,CAChB,CAAC;AAEhC,CAAC;AAED,eAAeN,SAAS"}
1
+ {"version":3,"file":"Droppable.js","names":["useMemoObject","React","useCallback","useEffect","useMemo","useRef","NodeList","useDragAndDrop","DroppableContext","useGeneratedId","Droppable","renderDraggedNode","id","horizontal","children","ref","innerRef","generatedId","droppableId","listRef","current","registerList","deregisterList","onMouseDown","onTouchStart","listId","registerNode","props","add","deregisterNode","node","remove","mouseDownHandler","e","touchStartHandler","droppableContext","createElement","Provider","value"],"sources":["../../src/Droppable.tsx"],"sourcesContent":["import useMemoObject from '@os-design/use-memo-object';\nimport React, {\n MouseEvent,\n RefObject,\n TouchEvent,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from 'react';\nimport NodeList, {\n ExistingNode,\n NodeProps,\n RenderDraggedNode,\n} from './utils/NodeList';\nimport useDragAndDrop from './utils/useDragAndDrop';\nimport { DroppableContext } from './utils/useDroppable';\nimport useGeneratedId from './utils/useGeneratedId';\n\nexport interface DroppableChildrenProps {\n /**\n * The reference to the list.\n * If a virtual list is used, pass it to the outerRef prop.\n */\n ref: RefObject<HTMLDivElement>;\n /**\n * The reference to the container inside the virtual list.\n * Pass it to the innerRef prop.\n */\n innerRef: RefObject<HTMLDivElement>;\n}\n\nexport interface DroppableProps {\n /**\n * The function that renders the dragged node.\n */\n renderDraggedNode: RenderDraggedNode;\n /**\n * The ID of the list with draggable nodes.\n * Used to determine in which list the dragged node was dropped.\n * @default undefined\n */\n id?: string;\n /**\n * Whether the list is horizontal.\n * @default false\n */\n horizontal?: boolean;\n /**\n * The function that renders the list with draggable nodes.\n */\n children: (props: DroppableChildrenProps) => React.ReactNode;\n}\n\nconst Droppable: React.FC<DroppableProps> = ({\n renderDraggedNode,\n id,\n horizontal = false,\n children,\n}) => {\n // The reference to the list\n const ref = useRef<HTMLDivElement>(null);\n // The reference to the container inside the virtual list\n const innerRef = useRef<HTMLDivElement>(null);\n // The unique ID of the list. If no ID was specified, the generated one is used.\n const generatedId = useGeneratedId();\n const droppableId = useMemo(() => id || generatedId, [generatedId, id]);\n // The reference to the list of nodes\n const listRef = useRef(\n new NodeList({\n id: droppableId,\n ref,\n innerRef,\n horizontal,\n renderDraggedNode,\n })\n );\n\n // Update the ID of the list if it changes\n useEffect(() => {\n listRef.current.id = droppableId;\n }, [droppableId]);\n\n // Update the list orientation if it changes.\n // There is no need to check the order of the nodes in the list because it will be the same.\n useEffect(() => {\n listRef.current.horizontal = horizontal;\n }, [horizontal]);\n\n // Update the callback that renders the dragged node if it changes\n useEffect(() => {\n listRef.current.renderDraggedNode = renderDraggedNode;\n }, [renderDraggedNode]);\n\n const { registerList, deregisterList, onMouseDown, onTouchStart } =\n useDragAndDrop();\n\n // Register the list in the store\n useEffect(() => {\n registerList(listRef.current);\n const listId = listRef.current.id;\n return () => deregisterList(listId);\n }, [deregisterList, registerList]);\n\n const registerNode = useCallback(\n (props: NodeProps) => listRef.current.add(props),\n []\n );\n const deregisterNode = useCallback((node: ExistingNode) => {\n listRef.current.remove(node);\n }, []);\n\n // Handlers that determine whether a user clicks on the node\n const mouseDownHandler = useCallback(\n (e: MouseEvent, node: ExistingNode) => {\n onMouseDown(e, listRef.current, node);\n },\n [onMouseDown]\n );\n const touchStartHandler = useCallback(\n (e: TouchEvent, node: ExistingNode) => {\n onTouchStart(e, listRef.current, node);\n },\n [onTouchStart]\n );\n\n const droppableContext = useMemoObject({\n registerNode,\n deregisterNode,\n onMouseDown: mouseDownHandler,\n onTouchStart: touchStartHandler,\n });\n\n return (\n <DroppableContext.Provider value={droppableContext}>\n {(children as (props: DroppableChildrenProps) => React.ReactNode)({\n ref,\n innerRef,\n })}\n </DroppableContext.Provider>\n );\n};\n\nexport default Droppable;\n"],"mappings":"AAAA,OAAOA,aAAa,MAAM,4BAA4B;AACtD,OAAOC,KAAK,IAIVC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,QACD,OAAO;AACd,OAAOC,QAAQ,MAIR,kBAAkB;AACzB,OAAOC,cAAc,MAAM,wBAAwB;AACnD,SAASC,gBAAgB,QAAQ,sBAAsB;AACvD,OAAOC,cAAc,MAAM,wBAAwB;AAqCnD,MAAMC,SAAmC,GAAGA,CAAC;EAC3CC,iBAAiB;EACjBC,EAAE;EACFC,UAAU,GAAG,KAAK;EAClBC;AACF,CAAC,KAAK;EACJ;EACA,MAAMC,GAAG,GAAGV,MAAM,CAAiB,IAAI,CAAC;EACxC;EACA,MAAMW,QAAQ,GAAGX,MAAM,CAAiB,IAAI,CAAC;EAC7C;EACA,MAAMY,WAAW,GAAGR,cAAc,CAAC,CAAC;EACpC,MAAMS,WAAW,GAAGd,OAAO,CAAC,MAAMQ,EAAE,IAAIK,WAAW,EAAE,CAACA,WAAW,EAAEL,EAAE,CAAC,CAAC;EACvE;EACA,MAAMO,OAAO,GAAGd,MAAM,CACpB,IAAIC,QAAQ,CAAC;IACXM,EAAE,EAAEM,WAAW;IACfH,GAAG;IACHC,QAAQ;IACRH,UAAU;IACVF;EACF,CAAC,CACH,CAAC;;EAED;EACAR,SAAS,CAAC,MAAM;IACdgB,OAAO,CAACC,OAAO,CAACR,EAAE,GAAGM,WAAW;EAClC,CAAC,EAAE,CAACA,WAAW,CAAC,CAAC;;EAEjB;EACA;EACAf,SAAS,CAAC,MAAM;IACdgB,OAAO,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YAAY;IACZG,cAAc;IACdN,WAAW,EAAES,gBAAgB;IAC7BR,YAAY,EAAEU;EAChB,CAAC,CAAC;EAEF,oBACEjC,KAAA,CAAAmC,aAAA,CAAC5B,gBAAgB,CAAC6B,QAAQ;IAACC,KAAK,EAAEH;EAAiB,GAC/CrB,QAAQ,CAAwD;IAChEC,GAAG;IACHC;EACF,CAAC,CACwB,CAAC;AAEhC,CAAC;AAED,eAAeN,SAAS"}
@@ -1,4 +1,7 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any,no-param-reassign,prefer-destructuring,no-constant-condition */ // [prev, next, ref, setStyle, index, id]
1
+ /* eslint-disable @typescript-eslint/no-explicit-any,no-param-reassign,prefer-destructuring,no-constant-condition */
2
+
3
+ // [prev, next, ref, setStyle, index, id]
4
+
2
5
  /**
3
6
  * Stores all the draggable items in the list.
4
7
  * The structure of the doubly linked list is used.
@@ -1 +1 @@
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,qHAEA;AAyCA;AACA;AACA;AACA;AACA,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IAAI,CAACR,IAAI,GAAG,IAAI;MAChB,IAAI,CAACC,IAAI,GAAG,IAAI;MAChB;IACF;IACA,IAAI,CAACS,IAAI,IAAIF,IAAI,EAAE;MACjBA,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI;MACd,IAAI,CAACR,IAAI,GAAGQ,IAAI;MAChB;IACF;IACA,IAAIE,IAAI,IAAI,CAACF,IAAI,EAAE;MACjBE,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI;MACd,IAAI,CAACT,IAAI,GAAGS,IAAI;MAChB;IACF;IACA,IAAIA,IAAI,IAAIF,IAAI,EAAE;MAChBE,IAAI,CAAC,CAAC,CAAC,GAAGF,IAAI;MACdA,IAAI,CAAC,CAAC,CAAC,GAAGE,IAAI;IAChB;EACF;EAEOU,WAAWA,CAACC,QAAoC,EAAE;IACvD,IAAI,CAACnB,SAAS,CAACoB,IAAI,CAACD,QAAQ,CAAC;EAC/B;EAEOE,cAAcA,CAACF,QAAoC,EAAE;IAC1D,MAAMd,KAAK,GAAG,IAAI,CAACL,SAAS,CAACsB,SAAS,CAAET,QAAQ,IAAKA,QAAQ,KAAKM,QAAQ,CAAC;IAC3E,IAAI,CAACnB,SAAS,CAACuB,MAAM,CAAClB,KAAK,EAAE,CAAC,CAAC;EACjC;AACF;AAEA,eAAef,QAAQ"}
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,QAAQ,CAAC;EA0CNC,WAAWA,CAACC,KAAgB,EAAE;IAzCrC;AACF;AACA;IAFE,KAGOC,EAAE;IAET;AACF;AACA;IAFE,KAGOC,GAAG;IAEV;AACF;AACA;AACA;IAHE,KAIOC,QAAQ;IAEf;AACF;AACA;IAFE,KAGOC,UAAU;IAEjB;AACF;AACA;IAFE,KAGOC,iBAAiB;IAExB;AACF;AACA;IAFE,KAGQC,IAAI;IAEZ;AACF;AACA;IAFE,KAGQC,IAAI;IAEZ;AACF;AACA;IAFE,KAGQC,SAAS;IAGf,IAAI,CAACP,EAAE,GAAGD,KAAK,CAACC,EAAE;IAClB,IAAI,CAACC,GAAG,GAAGF,KAAK,CAACE,GAAG;IACpB,IAAI,CAACC,QAAQ,GAAGH,KAAK,CAACG,QAAQ;IAC9B,IAAI,CAACC,UAAU,GAAGJ,KAAK,CAACI,UAAU;IAClC,IAAI,CAACC,iBAAiB,GAAGL,KAAK,CAACK,iBAAiB;IAChD,IAAI,CAACC,IAAI,GAAG,IAAI;IAChB,IAAI,CAACC,IAAI,GAAG,IAAI;IAChB,IAAI,CAACC,SAAS,GAAG,EAAE;EACrB;EAEOC,OAAOA,CAAA,EAAG;IACf,OAAO,IAAI,CAACH,IAAI;EAClB;EAEOI,OAAOA,CAAA,EAAG;IACf,OAAO,IAAI,CAACH,IAAI;EAClB;;EAEA;AACF;AACA;AACA;EACUI,iBAAiBA,CAACX,KAAgB,EAAgB;IACxD,IAAI,CAACM,IAAI,GAAG,CACV,IAAI,EACJ,IAAI,CAACA,IAAI,EACTN,KAA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GJ,IAAI;IACb;IACA,OAAOhB,QAAQ,CAACmB,QAAQ,CAACC,IAAI,EAAElB,KAAK,CAAC;EACvC;;EAEA;AACF;AACA;AACA;AACA;EACSyB,MAAMA,CAACP,IAAkB,EAAE;IAChC,MAAM,CAACF,IAAI,EAAEF,IAAI,CAAC,GAAGI,IAAI;IACzB,IAAI,CAACF,IAAI,IAAI,CAACF,IAAI,EAAE;MAClB,IAAI,CAACR,IAAI,GAAG,IAAI;MAChB,IAAI,CAACC,IAAI,GAAG,IAAI;MAChB;IACF;IACA,IAAI,CAACS,IAAI,IAAIF,IAAI,EAAE;MACjBA,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI;MACd,IAAI,CAACR,IAAI,GAAGQ,IAAI;MAChB;IACF;IACA,IAAIE,IAAI,IAAI,CAACF,IAAI,EAAE;MACjBE,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI;MACd,IAAI,CAACT,IAAI,GAAGS,IAAI;MAChB;IACF;IACA,IAAIA,IAAI,IAAIF,IAAI,EAAE;MAChBE,IAAI,CAAC,CAAC,CAAC,GAAGF,IAAI;MACdA,IAAI,CAAC,CAAC,CAAC,GAAGE,IAAI;IAChB;EACF;EAEOU,WAAWA,CAACC,QAAoC,EAAE;IACvD,IAAI,CAACnB,SAAS,CAACoB,IAAI,CAACD,QAAQ,CAAC;EAC/B;EAEOE,cAAcA,CAACF,QAAoC,EAAE;IAC1D,MAAMd,KAAK,GAAG,IAAI,CAACL,SAAS,CAACsB,SAAS,CAAET,QAAQ,IAAKA,QAAQ,KAAKM,QAAQ,CAAC;IAC3E,IAAI,CAACnB,SAAS,CAACuB,MAAM,CAAClB,KAAK,EAAE,CAAC,CAAC;EACjC;AACF;AAEA,eAAef,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"Droppable.d.ts","sourceRoot":"","sources":["../../src/Droppable.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAEZ,SAAS,EAMV,MAAM,OAAO,CAAC;AACf,OAAiB,EAGf,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAK1B,MAAM,WAAW,sBAAsB;IAKrC,GAAG,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;IAK/B,QAAQ,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,cAAc;IAI7B,iBAAiB,EAAE,iBAAiB,CAAC;IAMrC,EAAE,CAAC,EAAE,MAAM,CAAC;IAKZ,UAAU,CAAC,EAAE,OAAO,CAAC;IAIrB,QAAQ,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,KAAK,CAAC,SAAS,CAAC;CAC9D;AAED,QAAA,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAoFvC,CAAC;AAEF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"Droppable.d.ts","sourceRoot":"","sources":["../../src/Droppable.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAEZ,SAAS,EAMV,MAAM,OAAO,CAAC;AACf,OAAiB,EAGf,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAK1B,MAAM,WAAW,sBAAsB;IAKrC,GAAG,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;IAK/B,QAAQ,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,cAAc;IAI7B,iBAAiB,EAAE,iBAAiB,CAAC;IAMrC,EAAE,CAAC,EAAE,MAAM,CAAC;IAKZ,UAAU,CAAC,EAAE,OAAO,CAAC;IAIrB,QAAQ,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,KAAK,CAAC,SAAS,CAAC;CAC9D;AAED,QAAA,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAuFvC,CAAC;AAEF,eAAe,SAAS,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@os-design/drag-sort",
3
- "version": "1.0.25",
3
+ "version": "1.0.27",
4
4
  "license": "UNLICENSED",
5
5
  "repository": "git@gitlab.com:os-team/libs/os-design.git",
6
6
  "main": "dist/cjs/index.js",
@@ -23,29 +23,29 @@
23
23
  "build:esm": "cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts,.tsx --out-dir dist/esm --source-maps",
24
24
  "build:cjs": "cross-env BABEL_ENV=cjs babel src --root-mode upward --extensions .ts,.tsx --out-dir dist/cjs --source-maps",
25
25
  "build:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist/types",
26
- "build": "yarn clean && npm-run-all build:*",
26
+ "build": "yarn clean && npm-run-all 'build:*'",
27
27
  "ncu": "ncu -u"
28
28
  },
29
29
  "publishConfig": {
30
30
  "access": "public"
31
31
  },
32
32
  "dependencies": {
33
- "@os-design/portal": "^1.0.15",
34
- "@os-design/use-auto-scroll": "^1.0.17",
35
- "@os-design/use-drag": "^1.0.15",
36
- "@os-design/use-event": "^1.0.18",
37
- "@os-design/use-memo-object": "^1.0.13",
38
- "@os-design/use-prevent-default-event": "^1.0.15",
39
- "@os-design/use-throttle": "^1.0.19"
33
+ "@os-design/portal": "^1.0.16",
34
+ "@os-design/use-auto-scroll": "^1.0.18",
35
+ "@os-design/use-drag": "^1.0.16",
36
+ "@os-design/use-event": "^1.0.19",
37
+ "@os-design/use-memo-object": "^1.0.14",
38
+ "@os-design/use-prevent-default-event": "^1.0.16",
39
+ "@os-design/use-throttle": "^1.0.20"
40
40
  },
41
41
  "devDependencies": {
42
- "@os-design/omit-emotion-props": "^1.0.17",
43
- "@os-design/use-size": "^1.0.19",
44
- "react-window": "^1.8.9"
42
+ "@os-design/omit-emotion-props": "^1.0.18",
43
+ "@os-design/use-size": "^1.0.20",
44
+ "react-window": "^1.8.10"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "react": ">=18",
48
48
  "react-dom": ">=18"
49
49
  },
50
- "gitHead": "f838bd8885cdaf45e62a3b61fa2f83f2d2036e09"
50
+ "gitHead": "60a50e7c10af17bd9da35a631e74cc3df33d3e7b"
51
51
  }
package/src/Droppable.tsx CHANGED
@@ -133,7 +133,10 @@ const Droppable: React.FC<DroppableProps> = ({
133
133
 
134
134
  return (
135
135
  <DroppableContext.Provider value={droppableContext}>
136
- {(children as Function)({ ref, innerRef })}
136
+ {(children as (props: DroppableChildrenProps) => React.ReactNode)({
137
+ ref,
138
+ innerRef,
139
+ })}
137
140
  </DroppableContext.Provider>
138
141
  );
139
142
  };