import * as React from 'react' import { Progress as BaseProgress } from '@base-ui/react/progress' import { cn } from '../../internal/utils' type ProgressVariant = 'bar' | 'circular' type ProgressLabelProps = BaseProgress.Label.Props type ProgressValueProps = BaseProgress.Value.Props interface ProgressProps extends Omit { /** * Horizontal track or SVG ring. * @default 'bar' */ variant?: ProgressVariant /** * Diameter of the ring in pixels (`circular` only). * @default 56 */ size?: number /** * Track weight in pixels. Defaults to `6` for `bar`, `4` for `circular`. * @default 6` / `4 */ thickness?: number /** * Any CSS color for the fill (e.g. `var(--success-emphasis)`). * @default primary token */ indicatorColor?: string /** Current value, from `min` to `max`. Pass `null` for an indeterminate state. */ value?: number | null } function Progress({ variant = 'bar', size, thickness, indicatorColor, className, style, children, value, min = 0, max = 100, ...props }: ProgressProps) { const resolvedThickness = thickness ?? (variant === 'circular' ? 4 : 6) const resolvedSize = size ?? 56 const rootStyle = { ...style, '--progress-color': indicatorColor ?? 'var(--primary)', } as unknown as React.CSSProperties return ( {children} {variant === 'bar' ? ( ) : ( )} ) } interface ProgressCircularProps { value: number | null min: number max: number size: number thickness: number } function ProgressCircular({ value, min, max, size, thickness }: ProgressCircularProps) { const indeterminate = value == null const pct = indeterminate ? 0 : Math.max(0, Math.min(100, ((value - min) / (max - min)) * 100)) const center = size / 2 const radius = (size - thickness) / 2 const circumference = 2 * Math.PI * radius const offset = circumference - (pct / 100) * circumference return ( ) } function ProgressLabel({ className, ...props }: BaseProgress.Label.Props) { return ( ) } function ProgressValue({ className, ...props }: BaseProgress.Value.Props) { return ( ) } export { Progress, ProgressLabel, ProgressValue } export type { ProgressProps, ProgressLabelProps, ProgressValueProps }