UNPKG

@razorpay/blade

Version:

The Design System that powers Razorpay

49 lines (46 loc) 2.51 kB
import _defineProperty from '@babel/runtime/helpers/defineProperty'; import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties'; import 'react'; import '../BaseMotion/index.js'; import { useMemoizedStyles } from '../Box/BaseBox/useMemoizedStyles.web.js'; import '../../utils/index.js'; import { cssBezierToArray } from '../../utils/cssBezierToArray.js'; import { msToSeconds } from '../../utils/msToSeconds.js'; import { jsx } from 'react/jsx-runtime'; import useTheme from '../BladeProvider/useTheme.js'; import { MotionDiv } from '../BaseMotion/BaseMotion.js'; import { castWebType } from '../../utils/platform/castUtils.js'; var _excluded = ["borderRadius", "backgroundColor"]; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } var Morph = function Morph(_ref) { var children = _ref.children, layoutId = _ref.layoutId; // Apart from framer-motion's layout morphing, we also support morph of backgroundColor and borderRadius var _children$props = children.props, borderRadius = _children$props.borderRadius, backgroundColor = _children$props.backgroundColor, rest = _objectWithoutProperties(_children$props, _excluded); var _useTheme = useTheme(), theme = _useTheme.theme; var cssProps = useMemoizedStyles({ borderRadius: borderRadius, backgroundColor: backgroundColor, theme: theme }); return /*#__PURE__*/jsx(MotionDiv, _objectSpread(_objectSpread({ as: children.type }, rest), {}, { layout: true, layoutId: layoutId // The animations that are not supported by layout animation are animated using `animate` prop here , animate: cssProps, transition: { duration: msToSeconds(theme.motion.duration.moderate), ease: cssBezierToArray(castWebType(theme.motion.easing.standard)) } })); }; export { Morph }; //# sourceMappingURL=Morph.web.js.map