Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
1 line
4.9 KiB
Plaintext
1 line
4.9 KiB
Plaintext
{"version":3,"file":"index.js","names":["c","_c","React","useEffect","useRef","useRouteTransition","transitionDuration","baseClass","initialDelay","ProgressBar","$","isTransitioning","transitionProgress","progressToShow","setProgressToShow","useState","shouldDelayProgress","t0","t1","clearTimerID","delayTimerID","current","clearTimeout","t2","t3","filter","Boolean","t4","join","t5","_jsx","className","style","children","width"],"sources":["../../../../src/providers/RouteTransition/ProgressBar/index.tsx"],"sourcesContent":["'use client'\nimport React, { useEffect, useRef } from 'react'\n\nimport { useRouteTransition } from '../index.js'\nimport './index.scss'\n\nconst transitionDuration = 200\nconst baseClass = 'progress-bar'\nconst initialDelay = 150\n\n/**\n * Renders a progress bar that shows the progress of a route transition.\n * Place this at the root of your application, inside of the `RouteTransitionProvider`.\n * When a transition is triggered, the progress bar will show the progress of that transition and exit when the transition is complete.\n * @returns A progress bar that shows the progress of a route transition\n * @example\n * import { RouteTransitionProvider, ProgressBar, Link } from '@payloadcms/ui'\n * const App = () => (\n * <RouteTransitionProvider>\n * <ProgressBar />\n * <Link href=\"/somewhere\">Go Somewhere</Link>\n * </RouteTransitionProvider>\n */\nexport const ProgressBar = () => {\n const { isTransitioning, transitionProgress } = useRouteTransition()\n const [progressToShow, setProgressToShow] = React.useState<null | number>(null)\n const shouldDelayProgress = useRef(true)\n\n useEffect(() => {\n let clearTimerID: NodeJS.Timeout\n let delayTimerID: NodeJS.Timeout\n\n if (isTransitioning) {\n if (shouldDelayProgress.current) {\n delayTimerID = setTimeout(() => {\n setProgressToShow(transitionProgress)\n shouldDelayProgress.current = false\n }, initialDelay)\n } else {\n setProgressToShow(transitionProgress)\n }\n } else {\n shouldDelayProgress.current = true\n\n // Fast forward to 100% when the transition is complete\n // Then fade out the progress bar directly after\n setProgressToShow(1)\n\n // Wait for CSS transition to finish before hiding the progress bar\n // This includes both the fast-forward to 100% and the subsequent fade-out\n clearTimerID = setTimeout(() => {\n setProgressToShow(null)\n }, transitionDuration * 2)\n }\n\n return () => {\n clearTimeout(clearTimerID)\n clearTimeout(delayTimerID)\n }\n }, [isTransitioning, transitionProgress])\n\n if (typeof progressToShow === 'number') {\n return (\n <div\n className={[baseClass, progressToShow === 1 && `${baseClass}--fade-out`]\n .filter(Boolean)\n .join(' ')}\n style={{\n // @ts-expect-error - TS doesn't like custom CSS properties\n '--transition-duration': `${transitionDuration}ms`,\n }}\n >\n <div\n className={`${baseClass}__progress`}\n style={{\n width: `${(progressToShow || 0) * 100}%`,\n }}\n />\n </div>\n )\n }\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AACA,OAAOC,KAAA,IAASC,SAAS,EAAEC,MAAM,QAAQ;AAEzC,SAASC,kBAAkB,QAAQ;AACnC,OAAO;AAEP,MAAMC,kBAAA,GAAqB;AAC3B,MAAMC,SAAA,GAAY;AAClB,MAAMC,YAAA,GAAe;AAErB;;;;;;;;;;;;;AAaA,OAAO,MAAMC,WAAA,GAAcA,CAAA;EAAA,MAAAC,CAAA,GAAAT,EAAA;EACzB;IAAAU,eAAA;IAAAC;EAAA,IAAgDP,kBAAA;EAChD,OAAAQ,cAAA,EAAAC,iBAAA,IAA4CZ,KAAA,CAAAa,QAAA,KAA8B;EAC1E,MAAAC,mBAAA,GAA4BZ,MAAA,KAAO;EAAA,IAAAa,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAR,CAAA,QAAAC,eAAA,IAAAD,CAAA,QAAAE,kBAAA;IAEzBK,EAAA,GAAAA,CAAA;MACJE,GAAA,CAAAA,YAAA;MACAC,GAAA,CAAAA,YAA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