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";
/**
 * ScaleFade is a component that provides an view with a scaling fade transition.
 */
const ScaleFade = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(({
  children,
  show,
  initialScale = 0.7,
  transition = {},
  exitTransition = {},
  ...rest
}, ref) => {
  const fromStyle = React.useMemo(() => ({
    scale: initialScale,
    opacity: 0
  }), [initialScale]);
  const animateStyle = React.useMemo(() => ({
    scale: 1,
    opacity: 1
  }), []);
  const exitStyle = React.useMemo(() => ({
    scale: initialScale,
    opacity: 0
  }), [initialScale]);
  const transitionProps = React.useMemo(() => ({
    dampingRatio: 1,
    duration: 100,
    type: "spring",
    ...transition
  }), [transition]);
  const exitTransitionProps = 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: transitionProps,
    exitTransition: exitTransitionProps
  }), children));
}));
ScaleFade.displayName = "ScaleFade";
export default ScaleFade;
//# sourceMappingURL=scale-fade.js.map