(item, monitor)
| 74 | >({ |
| 75 | accept: DragTypes.SCRIPT, |
| 76 | hover(item, monitor) { |
| 77 | if (!ref.current || !monitor.isOver()) { |
| 78 | return; |
| 79 | } |
| 80 | |
| 81 | if (!ref.current || !monitor || !item || item.id === id) { |
| 82 | return { |
| 83 | handlerId: null, |
| 84 | hoveredDownwards: false, |
| 85 | hoveredUpwards: false, |
| 86 | }; |
| 87 | } |
| 88 | |
| 89 | const hoverBoundingRect = ref.current.getBoundingClientRect(); |
| 90 | const clientOffset = monitor.getClientOffset(); |
| 91 | if (!clientOffset) { |
| 92 | return; |
| 93 | } |
| 94 | |
| 95 | const hoverClientY = clientOffset.y - hoverBoundingRect.top; |
| 96 | |
| 97 | const hoveredTop = hoverClientY < hoverBoundingRect.height / 2; |
| 98 | const hoveredBottom = hoverClientY > hoverBoundingRect.height / 2; |
| 99 | |
| 100 | if (hoveredTop) { |
| 101 | const newRank = calculateTopHoveredRank( |
| 102 | index, |
| 103 | item.index, |
| 104 | script.collectionId, |
| 105 | item.collectionId, |
| 106 | ); |
| 107 | if (newRank === item.index && item.collectionId === script.collectionId) { |
| 108 | return; |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | if (hoveredBottom) { |
| 113 | const newRank = calculateBottomHoveredRank( |
| 114 | index, |
| 115 | item.index, |
| 116 | script.collectionId, |
| 117 | item.collectionId, |
| 118 | ); |
| 119 | if (newRank === item.index && item.collectionId === script.collectionId) { |
| 120 | return; |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | setIsTopHovered(hoveredTop); |
| 125 | setIsBottomHovered(hoveredBottom); |
| 126 | }, |
| 127 | collect(monitor) { |
| 128 | if (!ref.current || !monitor || !monitor.getItem() || monitor.getItem().id === id) { |
| 129 | setIsTopHovered(false); |
nothing calls this directly
no test coverage detected