UNPKG

@yamada-ui/react

Version:

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

1 lines 2.84 kB
{"version":3,"file":"background.cjs","names":["variants: Variants","Background: FC<BackgroundProps>","useLoadingComponent","motion","isValidElement","Text"],"sources":["../../../../src/components/loading/background.tsx"],"sourcesContent":["import type { Variants } from \"motion/react\"\nimport type { FC } from \"react\"\nimport type { LoadingSharedProps } from \"./loading-provider\"\nimport { memo } from \"react\"\nimport { useTimeout } from \"../../hooks/use-timeout\"\nimport { isValidElement } from \"../../utils\"\nimport { motion } from \"../motion\"\nimport { Text } from \"../text\"\nimport { useLoadingComponent } from \"./use-loading-component\"\n\nconst variants: Variants = {\n animate: {\n opacity: 1,\n scale: 1,\n transition: {\n duration: 0.4,\n ease: [0.4, 0, 0.2, 1],\n },\n },\n exit: {\n opacity: 0,\n scale: 0.95,\n transition: {\n duration: 0.4,\n ease: [0.4, 0, 1, 1],\n },\n },\n initial: {\n opacity: 0,\n scale: 0.95,\n },\n}\n\nexport interface BackgroundProps extends LoadingSharedProps {}\n\nexport const Background: FC<BackgroundProps> = memo(\n ({ duration, initial, loadingScheme, message, onFinish }) => {\n const Component = useLoadingComponent(loadingScheme)\n\n useTimeout(onFinish, duration)\n\n return (\n <motion.div\n data-loading\n alignItems=\"center\"\n animate=\"animate\"\n bg=\"bg.panel\"\n bottom=\"md\"\n boxShadow=\"lg\"\n display=\"flex\"\n exit=\"exit\"\n gap=\"sm\"\n initial={initial}\n justifyContent=\"center\"\n maxW=\"20rem\"\n p=\"sm\"\n position=\"fixed\"\n right=\"md\"\n rounded=\"l2\"\n variants={variants}\n zIndex=\"beerus\"\n >\n <Component fontSize=\"xl\" />\n\n {message ? (\n isValidElement(message) ? (\n message\n ) : (\n <Text fontSize=\"sm\" lineClamp={1}>\n {message}\n </Text>\n )\n ) : null}\n </motion.div>\n )\n },\n)\n\nBackground.displayName = \"Background\"\n"],"mappings":";;;;;;;;;;;;AAUA,MAAMA,WAAqB;CACzB,SAAS;EACP,SAAS;EACT,OAAO;EACP,YAAY;GACV,UAAU;GACV,MAAM;IAAC;IAAK;IAAG;IAAK;IAAE;GACvB;EACF;CACD,MAAM;EACJ,SAAS;EACT,OAAO;EACP,YAAY;GACV,UAAU;GACV,MAAM;IAAC;IAAK;IAAG;IAAG;IAAE;GACrB;EACF;CACD,SAAS;EACP,SAAS;EACT,OAAO;EACR;CACF;AAID,MAAaC,8BACV,EAAE,UAAU,SAAS,eAAe,SAAS,eAAe;CAC3D,MAAM,YAAYC,kDAAoB,cAAc;AAEpD,4CAAW,UAAU,SAAS;AAE9B,QACE,4CAACC,uBAAO;EACN;EACA,YAAW;EACX,SAAQ;EACR,IAAG;EACH,QAAO;EACP,WAAU;EACV,SAAQ;EACR,MAAK;EACL,KAAI;EACK;EACT,gBAAe;EACf,MAAK;EACL,GAAE;EACF,UAAS;EACT,OAAM;EACN,SAAQ;EACE;EACV,QAAO;aAEP,2CAAC,aAAU,UAAS,OAAO,EAE1B,UACCC,gCAAe,QAAQ,GACrB,UAEA,2CAACC;GAAK,UAAS;GAAK,WAAW;aAC5B;IACI,GAEP;GACO;EAGlB;AAED,WAAW,cAAc"}