'use client' import * as React from 'react' import { LazyMotion, domAnimation, m } from 'motion/react' import { useReducedMotion } from '../../hooks/use-reduced-motion' import { cn } from '../../internal/utils' type LoaderVariant = 'bar' | 'dots' interface LoaderProps extends Omit, 'children'> { /** * The animated shape. * @default 'bar' */ variant?: LoaderVariant /** * Inherit the surrounding text color (`currentColor`) instead of the primary accent. * @default false */ currentColor?: boolean } type VariantColors = { indicator: string; track: string } type VariantInnerProps = { colors: VariantColors; reduced: boolean } const LOADER_SIZE = 'text-[2.5rem]' const PRIMARY_COLORS: VariantColors = { indicator: 'text-primary', track: 'text-primary-soft' } const CURRENT_COLORS: VariantColors = { indicator: 'text-current', track: 'text-current/20' } const FLOW_CYCLE = 2.4 const FLOW_CENTER = 14 const FLOW_CX_KEYFRAMES: number[] = [FLOW_CENTER + 14, FLOW_CENTER, FLOW_CENTER - 14] const FLOW_TIMES: number[] = [0.01, 0.5, 1] const FLOW_CY = 6 const DOT_R_KEYFRAMES: number[] = [0, 6, 0] function Dots({ colors, reduced }: VariantInnerProps) { return ( ) } function Bar({ colors, reduced }: VariantInnerProps) { const clipId = React.useId() return ( ) } const VARIANT_COMPONENTS: Record> = { bar: Bar, dots: Dots, } function Loader({ variant = 'bar', currentColor = false, 'aria-label': ariaLabel = 'Loading', className, ...props }: LoaderProps) { const reduced = useReducedMotion() const colors = currentColor ? CURRENT_COLORS : PRIMARY_COLORS const Variant = VARIANT_COMPONENTS[variant] const inner = return ( {reduced ? ( inner ) : ( {inner} )} ) } export { Loader } export type { LoaderProps }