import { forwardRef, type ComponentPropsWithoutRef, type ReactNode } from 'react' import { cn } from 'ui' export type StateDotVariant = 'success' | 'warning' | 'destructive' | 'default' const DOT_CLASS_NAME: Record = { success: 'bg-brand', warning: 'bg-warning', destructive: 'bg-destructive', default: 'bg-foreground-muted', } interface StateDotProps extends ComponentPropsWithoutRef<'span'> { variant: StateDotVariant children: ReactNode /** Pulse for states that are in motion, such as starting or restarting. */ isPulsing?: boolean /** Offsets `animate-ping` so neighbouring pulsing dots don't flash in lockstep. */ pulseDelayMs?: number labelClassName?: string } /** A coloured dot with a label for compact operational states. */ export const StateDot = forwardRef( ( { variant, children, isPulsing = false, pulseDelayMs = 0, className, labelClassName, ...props }, ref ) => ( {isPulsing && ( 0 ? { animationDelay: `${pulseDelayMs}ms` } : undefined} /> )} {children} ) ) StateDot.displayName = 'StateDot'