import React from 'react';
import { useCollapse } from '../../providers/useCollapse';
/** Toggle is a component to solve ReactTransitionGroup bug with lagging collapse and expand transitions. */
const Toggle = ({ children, dataHook, mountOnEnter, show, timeout, unmountOnExit, onEnd, onStart, }) => {
    const { getCollapseProps, exitAnimationEnded } = useCollapse({
        isExpanded: show,
        duration: process.env.NODE_ENV === 'test' ? 0 : timeout,
        onCollapseStart: onEnd,
        onExpandStart: onStart,
    });
    return (React.createElement("div", { "data-hook": dataHook, ...getCollapseProps() }, !show &&
        (unmountOnExit || (mountOnEnter && unmountOnExit === false)) &&
        exitAnimationEnded
        ? null
        : children));
};
Toggle.displayName = 'Toggle';
export default Toggle;
//# sourceMappingURL=Toggle.js.map