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";
/**
 * Slide is a component that provides an view with a sliding transition.
 */
const Slide = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(({
  children,
  show,
  direction = "right",
  transition = {},
  exitTransition = {},
  ...rest
}, ref) => {
  const from = React.useMemo(() => {
    switch (direction) {
      case "bottom":
        return {
          translateY: -500
        };
      case "top":
        return {
          translateY: 500
        };
      case "right":
        return {
          translateX: -500
        };
      case "left":
        return {
          translateX: 500
        };
      default:
        return {};
    }
  }, [direction]);
  const animate = React.useMemo(() => {
    switch (direction) {
      case "bottom":
      case "top":
        return {
          translateY: 0
        };
      case "right":
      case "left":
        return {
          translateX: 0
        };
      default:
        return {};
    }
  }, [direction]);
  const exit = React.useMemo(() => {
    switch (direction) {
      case "bottom":
        return {
          translateY: -500
        };
      case "top":
        return {
          translateY: 500
        };
      case "right":
        return {
          translateX: -500
        };
      case "left":
        return {
          translateX: 500
        };
      default:
        return {};
    }
  }, [direction]);
  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: 200,
      type: "spring",
      ...transition
    },
    exitTransition: {
      dampingRatio: 1,
      duration: 200,
      type: "spring",
      ...exitTransition
    }
  }), children));
}));
Slide.displayName = "Slide";
export default Slide;
//# sourceMappingURL=slide.js.map