function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import React from "react";
import Box from "../box/box";
import { AnimatePresence } from "moti";
/**
 * Fade is a component that provides an view with a fade transition.
 */
const Fade = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(({
  children,
  show,
  transition = {},
  exitTransition = {},
  ...rest
}, ref) => {
  const fromStyle = React.useMemo(() => ({
    opacity: 0
  }), []);
  const animateStyle = React.useMemo(() => ({
    opacity: 1
  }), []);
  const exitStyle = React.useMemo(() => ({
    opacity: 0
  }), []);
  const transitionStyle = React.useMemo(() => ({
    dampingRatio: 1,
    duration: 100,
    type: "spring",
    ...transition
  }), [transition]);
  const exitTransitionStyle = React.useMemo(() => ({
    dampingRatio: 1,
    duration: 100,
    type: "spring",
    ...exitTransition
  }), [exitTransition]);
  return /*#__PURE__*/React.createElement(AnimatePresence, null, show && /*#__PURE__*/React.createElement(Box, _extends({
    ref: ref
  }, rest, {
    from: fromStyle,
    animate: animateStyle,
    exit: exitStyle,
    transition: transitionStyle,
    exitTransition: exitTransitionStyle
  }), children));
}));
Fade.displayName = "Fade";
export default Fade;
//# sourceMappingURL=fade.js.map