"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _box = _interopRequireDefault(require("../box/box"));
var _moti = require("moti");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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); }
/**
 * SlideFade is a component that provides an view with a sliding fade transition.
 */
const SlideFade = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.default.forwardRef(({
  children,
  show,
  offsetX = 0,
  offsetY = 10,
  transition = {},
  exitTransition = {},
  ...rest
}, ref) => {
  const from = _react.default.useMemo(() => ({
    opacity: 0,
    ...(offsetX !== 0 && {
      translateX: offsetX
    }),
    ...(offsetY !== 0 && {
      translateY: offsetY
    })
  }), [offsetX, offsetY]);
  const animate = _react.default.useMemo(() => ({
    opacity: 1,
    translateX: 0,
    translateY: 0
  }), []);
  const exit = _react.default.useMemo(() => ({
    opacity: 0,
    ...(offsetX !== 0 && {
      translateX: offsetX
    }),
    ...(offsetY !== 0 && {
      translateY: offsetY
    })
  }), [offsetX, offsetY]);
  return /*#__PURE__*/_react.default.createElement(_moti.AnimatePresence, null, show && /*#__PURE__*/_react.default.createElement(_box.default, _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";
var _default = exports.default = SlideFade;
//# sourceMappingURL=slide-fade.js.map