UNPKG

@yamada-ui/react

Version:

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

62 lines (58 loc) 1.87 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 { fadeStyle } from "./fade.style.js"; import { useMemo } from "react"; import { jsx } from "react/jsx-runtime"; import { AnimatePresence } from "motion/react"; //#region src/components/fade/fade.tsx const fadeVariants = { enter: ({ delay, duration, enter, transition, transitionEnd } = {}) => ({ opacity: 1, transition: createTransition.enter(transition?.enter)(delay, duration), transitionEnd: transitionEnd?.enter, ...enter }), exit: ({ delay, duration, exit, transition, transitionEnd } = {}) => ({ opacity: 0, transition: createTransition.exit(transition?.exit)(delay, duration), transitionEnd: transitionEnd?.exit, ...exit }) }; const { PropsContext: FadePropsContext, usePropsContext: useFadePropsContext, withContext } = createComponent("fade", fadeStyle); /** * `Fade` is a component that gradually shows or hides an element. * * @see https://yamada-ui.com/docs/components/fade */ const Fade = withContext(({ delay, duration, open: openProp, transition, transitionEnd, unmountOnExit,...rest }) => { const animate = openProp || unmountOnExit ? "enter" : "exit"; const open = unmountOnExit ? openProp && unmountOnExit : true; const custom = useMemo(() => ({ delay, duration, transition, transitionEnd }), [ delay, duration, transition, transitionEnd ]); return /* @__PURE__ */ jsx(AnimatePresence, { custom, children: open ? /* @__PURE__ */ jsx(motion$1.div, { animate, custom, exit: "exit", initial: "exit", variants: fadeVariants, ...rest }) : null }); })(); //#endregion export { Fade, FadePropsContext, fadeVariants, useFadePropsContext }; //# sourceMappingURL=fade.js.map