({ outputAnchor, data, disabled = false })
| 19 | // ===========================|| NodeOutputHandler ||=========================== // |
| 20 | |
| 21 | const NodeOutputHandler = ({ outputAnchor, data, disabled = false }) => { |
| 22 | const theme = useTheme() |
| 23 | const ref = useRef(null) |
| 24 | const updateNodeInternals = useUpdateNodeInternals() |
| 25 | const [position, setPosition] = useState(0) |
| 26 | const [clientHeight, setClientHeight] = useState(0) |
| 27 | const [offsetTop, setOffsetTop] = useState(0) |
| 28 | const [dropdownValue, setDropdownValue] = useState(null) |
| 29 | const { reactFlowInstance } = useContext(flowContext) |
| 30 | |
| 31 | const getAvailableOptions = (options = []) => { |
| 32 | return options.filter((option) => !option.hidden && !option.isAnchor) |
| 33 | } |
| 34 | |
| 35 | const getAnchorOptions = (options = []) => { |
| 36 | return options.filter((option) => !option.hidden && option.isAnchor) |
| 37 | } |
| 38 | |
| 39 | const getAnchorPosition = (options, index) => { |
| 40 | const spacing = clientHeight / (getAnchorOptions(options).length + 1) |
| 41 | return offsetTop + spacing * (index + 1) |
| 42 | } |
| 43 | |
| 44 | useEffect(() => { |
| 45 | if (ref.current && ref.current?.offsetTop && ref.current?.clientHeight) { |
| 46 | setTimeout(() => { |
| 47 | setClientHeight(ref.current?.clientHeight) |
| 48 | setOffsetTop(ref.current?.offsetTop) |
| 49 | setPosition(ref.current?.offsetTop + ref.current?.clientHeight / 2) |
| 50 | updateNodeInternals(data.id) |
| 51 | }, 0) |
| 52 | } |
| 53 | }, [data.id, ref, updateNodeInternals]) |
| 54 | |
| 55 | useEffect(() => { |
| 56 | setTimeout(() => { |
| 57 | updateNodeInternals(data.id) |
| 58 | }, 0) |
| 59 | }, [data.id, position, updateNodeInternals]) |
| 60 | |
| 61 | useEffect(() => { |
| 62 | if (dropdownValue) { |
| 63 | setTimeout(() => { |
| 64 | updateNodeInternals(data.id) |
| 65 | }, 0) |
| 66 | } |
| 67 | }, [data.id, dropdownValue, updateNodeInternals]) |
| 68 | |
| 69 | return ( |
| 70 | <div ref={ref}> |
| 71 | {outputAnchor.type !== 'options' && !outputAnchor.options && ( |
| 72 | <> |
| 73 | <CustomWidthTooltip placement='right' title={outputAnchor.type}> |
| 74 | <Handle |
| 75 | type='source' |
| 76 | position={Position.Right} |
| 77 | key={outputAnchor.id} |
| 78 | id={outputAnchor.id} |
nothing calls this directly
no test coverage detected