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";
/**
 * SlideFade is a component that provides an view with a sliding fade transition.
 */
const SlideFade = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(({
  children,
  show,
  offsetX = 0,
  offsetY = 10,
  transition = {},
  exitTransition = {},
  ...rest
}, ref) => {
  const from = React.useMemo(() => ({
    opacity: 0,
    ...(offsetX !== 0 && {
      translateX: offsetX
    }),
    ...(offsetY !== 0 && {
      translateY: offsetY
    })
  }), [offsetX, offsetY]);
  const animate = React.useMemo(() => ({
    opacity: 1,
    translateX: 0,
    translateY: 0
  }), []);
  const exit = React.useMemo(() => ({
    opacity: 0,
    ...(offsetX !== 0 && {
      translateX: offsetX
    }),
    ...(offsetY !== 0 && {
      translateY: offsetY
    })
  }), [offsetX, offsetY]);
  return /*#__PURE__*/React.createElement(AnimatePresence, null, show && /*#__PURE__*/React.createElement(Box, _extends({
    ref: ref
  }, rest, {
    from: from,
    animate: animate,
    exit: exit,
    transition: {
      dampingRatio: 1,
      duration: 100,
      type: "spring",
      ...transition
    },
    exitTransition: {
      dampingRatio: 1,
      duration: 100,
      type: "spring",
      ...exitTransition
    }
  }), children));
}));
SlideFade.displayName = "SlideFade";
export default SlideFade;
//# sourceMappingURL=slide-fade.js.map