import React, { Fragment } from 'react'; import { LoadingOverlay, Stack, } from '@biom3/react'; import { AnimatePresence, motion } from 'framer-motion'; import { useHandover } from '../../lib/hooks/useHandover'; import { HandoverAnimation } from './HandoverAnimation'; const contentAnimation = { hidden: { y: 8, opacity: 0 }, show: (i) => ({ height: '100%', y: 0, opacity: 1, transition: { delay: i * 0.1, duration: 0.2, ease: 'easeOut', }, }), exit: { y: -8, opacity: 0 }, }; export function Handover({ id, children }: { id: string, children?: React.ReactNode }) { const { handover, loader } = useHandover({ id }); let renderChildren: any = []; if (handover?.children) { if (React.isValidElement(handover.children) && handover.children.type === Fragment) { renderChildren = handover.children.props.children; } else { renderChildren = handover.children; } } return ( <> {children} {/* Keep LoadingOverlay mounted and toggle `visible`. Conditionally mounting `{loader && }` orphans the modal under React 19 (biom3 useControlledOverlay cleanup race). */} {handover && (renderChildren || handover.animationUrl) && ( {handover?.animationUrl?.length && ( )} {React.Children.map(renderChildren, (child, index) => ( {child} ))} )} ); }