import * as React from 'react' import { cn } from '../../internal/utils' type BorderBeamTrigger = 'hover' | 'press' interface BorderBeamProps extends React.ComponentProps<'div'> { /** * Beam color. It lights the head of the comet and fades to transparent along the tail, so pass a solid color * rather than a gradient. * @default 'var(--primary)' */ color?: string /** * How much of the border the comet spans, in percent of one lap. * @default 10 */ length?: number /** * Beam thickness in px. * @default 1 */ thickness?: number /** * Seconds for one full lap around the border. * @default 5 */ speed?: number /** * Seconds before the first lap starts. Negative values start the beam mid-lap, which is how you desynchronize a * group of cards. * @default 0 */ delay?: number /** * Reveal only on interaction. `'hover'` is pointer-only; `'press'` works on touch. Combine via an array. Omit for * always-on. */ revealOn?: BorderBeamTrigger | BorderBeamTrigger[] /** Controlled visibility for programmatic states (loading, etc.); OR-ed with `revealOn`. */ reveal?: boolean /** * With `revealOn="hover"`, keep the beam visible on touch devices (which have no hover) instead of hidden. * @default false */ showOnTouch?: boolean /** * Scale the beam down while pressed, to track a child `Button`'s own active-press scale. * @default false */ pressScale?: boolean } /* A conic sweep clipped to the border ring by an XOR mask (same trick as GradientGlow's border), so the comet follows the wrapper's radius at any corner. The RTL mirror uses `transform`, not `scale`, so it composes with `pressScale` instead of losing to it. */ const RING_MASK = 'linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)' function BorderBeam({ color = 'var(--primary)', length = 10, thickness = 1, speed = 5, delay = 0, revealOn, reveal, showOnTouch = false, pressScale = false, className, style, children, ...props }: BorderBeamProps) { const triggers = revealOn == null ? [] : Array.isArray(revealOn) ? revealOn : [revealOn] const managed = triggers.length > 0 || reveal !== undefined const grouped = managed || pressScale return (
{children}
) } export { BorderBeam } export type { BorderBeamProps }