/**
 * @license MIT
 * author: Cube Dev Team
 * @cube-dev/ui-kit v0.0.0-canary-43d3dd9
 * Released under the MIT license.
 */

import { jsx as _jsx } from "react/jsx-runtime";
import { Children, cloneElement, createContext, useContext, useRef, } from 'react';
import { Transition } from 'react-transition-group';
const OPEN_STATES = {
    entering: false,
    entered: true,
};
const OpenTransitionContext = createContext(null);
export function useOpenTransitionContext() {
    return useContext(OpenTransitionContext);
}
export function OpenTransition(props) {
    const nodeRef = useRef(null);
    return (_jsx(Transition, { nodeRef: nodeRef, timeout: { enter: 0, exit: 350 }, ...props, children: (state) => (_jsx("div", { ref: nodeRef, children: _jsx(OpenTransitionContext.Provider, { value: { transitionState: state }, children: Children.map(props.children, (child) => child &&
                    cloneElement(child, {
                        isOpen: !!OPEN_STATES[state],
                        transitionState: state,
                    })) }) })) }));
}

        