UNPKG

@yamada-ui/react

Version:

React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion

73 lines (69 loc) 2.14 kB
"use client"; import { createComponent } from "../../core/components/create-component.js"; import { motion as motion$1 } from "../motion/factory.js"; import { createTransition } from "../motion/transition.js"; import { fadeScaleStyle } from "./fade-scale.style.js"; import { useMemo } from "react"; import { jsx } from "react/jsx-runtime"; import { AnimatePresence } from "motion/react"; //#region src/components/fade-scale/fade-scale.tsx const fadeScaleVariants = { enter: ({ delay, duration, enter, transition, transitionEnd } = {}) => ({ opacity: 1, scale: 1, transition: createTransition.enter(transition?.enter)(delay, duration), transitionEnd: transitionEnd?.enter, ...enter }), exit: ({ delay, duration, exit, reverse, scale, transition, transitionEnd } = {}) => ({ opacity: 0, transition: createTransition.exit(transition?.exit)(delay, duration), ...reverse ? { scale, transitionEnd: transitionEnd?.exit } : { transitionEnd: { scale, ...transitionEnd?.exit } }, ...exit }) }; const { PropsContext: FadeScalePropsContext, usePropsContext: useFadeScalePropsContext, withContext } = createComponent("fade-scale", fadeScaleStyle); /** * `FadeScale` is a component that gradually scales up to reveal or scales down to hide an element. * * @see https://yamada-ui.com/docs/components/fade-scale */ const FadeScale = withContext(({ delay, duration, open: openProp, reverse = true, scale = .95, transition, transitionEnd, unmountOnExit,...rest }) => { const animate = openProp || unmountOnExit ? "enter" : "exit"; const open = unmountOnExit ? openProp && unmountOnExit : true; const custom = useMemo(() => ({ delay, duration, reverse, scale, transition, transitionEnd }), [ delay, duration, reverse, scale, transition, transitionEnd ]); return /* @__PURE__ */ jsx(AnimatePresence, { custom, children: open ? /* @__PURE__ */ jsx(motion$1.div, { animate, custom, exit: "exit", initial: "exit", variants: fadeScaleVariants, ...rest }) : null }); })(); //#endregion export { FadeScale, fadeScaleVariants }; //# sourceMappingURL=fade-scale.js.map