'use client'; import * as React from 'react'; import { Progress as ProgressPrimitives } from '@base-ui-components/react/progress'; import { motion, type Transition } from 'motion/react'; import { cn } from '@workspace/ui/lib/utils'; import { CountingNumber, type CountingNumberProps, } from '@/registry/text/counting-number'; type ProgressContextType = { value: number | null; }; const ProgressContext = React.createContext( undefined, ); const useProgress = (): ProgressContextType => { const context = React.useContext(ProgressContext); if (!context) { throw new Error('useProgress must be used within a Progress'); } return context; }; type ProgressProps = React.ComponentProps; const Progress = ({ value, ...props }: ProgressProps) => { return ( {props.children} ); }; const MotionProgressIndicator = motion.create(ProgressPrimitives.Indicator); type ProgressTrackProps = React.ComponentProps< typeof ProgressPrimitives.Track > & { transition?: Transition; }; function ProgressTrack({ className, transition = { type: 'spring', stiffness: 100, damping: 30 }, ...props }: ProgressTrackProps) { const { value } = useProgress(); return ( ); } type ProgressLabelProps = React.ComponentProps; function ProgressLabel(props: ProgressLabelProps) { return ; } type ProgressValueProps = Omit< React.ComponentProps, 'render' > & { countingNumberProps?: CountingNumberProps; }; function ProgressValue({ countingNumberProps, ...props }: ProgressValueProps) { const { value } = useProgress(); return ( } {...props} /> ); } export { Progress, ProgressTrack, ProgressLabel, ProgressValue, useProgress, type ProgressProps, type ProgressTrackProps, type ProgressLabelProps, type ProgressValueProps, };