@yamada-ui/react
Version:
React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion
1 lines • 4.14 kB
Source Map (JSON)
{"version":3,"file":"fade-scale.cjs","names":["fadeScaleVariants: Variants","createTransition","createComponent","fadeScaleStyle","AnimatePresence","motion"],"sources":["../../../../src/components/fade-scale/fade-scale.tsx"],"sourcesContent":["\"use client\"\n\nimport type { Variants } from \"motion/react\"\nimport type { ThemeProps } from \"../../core\"\nimport type {\n HTMLMotionProps,\n MotionTransitionVariants,\n WithTransitionProps,\n} from \"../motion\"\nimport type { FadeScaleStyle } from \"./fade-scale.style\"\nimport { AnimatePresence } from \"motion/react\"\nimport { useMemo } from \"react\"\nimport { createComponent } from \"../../core\"\nimport { createTransition, motion } from \"../motion\"\nimport { fadeScaleStyle } from \"./fade-scale.style\"\n\nexport const fadeScaleVariants: Variants = {\n enter: ({ delay, duration, enter, transition, transitionEnd } = {}) => ({\n opacity: 1,\n scale: 1,\n transition: createTransition.enter(transition?.enter)(delay, duration),\n transitionEnd: transitionEnd?.enter,\n ...enter,\n }),\n exit: ({\n delay,\n duration,\n exit,\n reverse,\n scale,\n transition,\n transitionEnd,\n } = {}) => ({\n opacity: 0,\n transition: createTransition.exit(transition?.exit)(delay, duration),\n ...(reverse\n ? { scale, transitionEnd: transitionEnd?.exit }\n : { transitionEnd: { scale, ...transitionEnd?.exit } }),\n ...exit,\n }),\n} satisfies MotionTransitionVariants\n\nexport interface FadeScaleProps\n extends WithTransitionProps<HTMLMotionProps>,\n ThemeProps<FadeScaleStyle> {\n /**\n * If `true`, the element will transition back to exit state.\n *\n * @default true\n */\n reverse?: boolean\n /**\n * The initial scale of the element.\n *\n * @default 0.95\n */\n scale?: number\n}\n\nconst {\n PropsContext: FadeScalePropsContext,\n usePropsContext: useFadeScalePropsContext,\n withContext,\n} = createComponent<FadeScaleProps, FadeScaleStyle>(\n \"fade-scale\",\n fadeScaleStyle,\n)\n\nexport { FadeScalePropsContext, useFadeScalePropsContext }\n\n/**\n * `FadeScale` is a component that gradually scales up to reveal or scales down to hide an element.\n *\n * @see https://yamada-ui.com/docs/components/fade-scale\n */\nexport const FadeScale = withContext<\"div\", FadeScaleProps>(\n ({\n delay,\n duration,\n open: openProp,\n reverse = true,\n scale = 0.95,\n transition,\n transitionEnd,\n unmountOnExit,\n ...rest\n }) => {\n const animate = openProp || unmountOnExit ? \"enter\" : \"exit\"\n const open = unmountOnExit ? openProp && unmountOnExit : true\n\n const custom = useMemo(\n () => ({\n delay,\n duration,\n reverse,\n scale,\n transition,\n transitionEnd,\n }),\n [delay, duration, reverse, scale, transition, transitionEnd],\n )\n\n return (\n <AnimatePresence custom={custom}>\n {open ? (\n <motion.div\n animate={animate}\n custom={custom}\n exit=\"exit\"\n initial=\"exit\"\n variants={fadeScaleVariants}\n {...rest}\n />\n ) : null}\n </AnimatePresence>\n )\n },\n)()\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,MAAaA,oBAA8B;CACzC,QAAQ,EAAE,OAAO,UAAU,OAAO,YAAY,kBAAkB,EAAE,MAAM;EACtE,SAAS;EACT,OAAO;EACP,YAAYC,oCAAiB,MAAM,YAAY,MAAM,CAAC,OAAO,SAAS;EACtE,eAAe,eAAe;EAC9B,GAAG;EACJ;CACD,OAAO,EACL,OACA,UACA,MACA,SACA,OACA,YACA,kBACE,EAAE,MAAM;EACV,SAAS;EACT,YAAYA,oCAAiB,KAAK,YAAY,KAAK,CAAC,OAAO,SAAS;EACpE,GAAI,UACA;GAAE;GAAO,eAAe,eAAe;GAAM,GAC7C,EAAE,eAAe;GAAE;GAAO,GAAG,eAAe;GAAM,EAAE;EACxD,GAAG;EACJ;CACF;AAmBD,MAAM,EACJ,cAAc,uBACd,iBAAiB,0BACjB,gBACEC,yCACF,cACAC,wCACD;;;;;;AASD,MAAa,YAAY,aACtB,EACC,OACA,UACA,MAAM,UACN,UAAU,MACV,QAAQ,KACR,YACA,eACA,cACA,GAAG,WACC;CACJ,MAAM,UAAU,YAAY,gBAAgB,UAAU;CACtD,MAAM,OAAO,gBAAgB,YAAY,gBAAgB;CAEzD,MAAM,mCACG;EACL;EACA;EACA;EACA;EACA;EACA;EACD,GACD;EAAC;EAAO;EAAU;EAAS;EAAO;EAAY;EAAc,CAC7D;AAED,QACE,2CAACC;EAAwB;YACtB,OACC,2CAACC,uBAAO;GACG;GACD;GACR,MAAK;GACL,SAAQ;GACR,UAAU;GACV,GAAI;IACJ,GACA;GACY;EAGvB,EAAE"}