import * as React from 'react'; import { useKnobContext } from '../core/context'; export interface PointerProps { /** Built-in shapes. Provide children instead for a custom pointer. */ type?: 'line' | 'circle' | 'triangle'; /** Distance from center to the pointer's outer end. Defaults to size/2 - 4. */ radius?: number; /** Length of the pointer along the radial axis. */ length?: number; width?: number; color?: string; cap?: 'butt' | 'round'; /** Extra SVG props applied to the shape. */ shapeProps?: React.SVGProps; /** Custom pointer content, drawn pointing at 12 o'clock and rotated for you. */ children?: React.ReactNode; } /** Rotating indicator. Children (or the built-in shape) are authored pointing up. */ export const Pointer: React.FC = ({ type = 'line', radius, length = 12, width = 4, color = 'currentColor', cap = 'round', shapeProps, children, }) => { const { size, center, angle } = useKnobContext(); const r = radius ?? size / 2 - 4; let shape: React.ReactNode = children; if (!shape) { if (type === 'line') { shape = ( )} /> ); } else if (type === 'circle') { shape = ( )} /> ); } else { const half = width / 2; const tipY = center - r; shape = ( )} /> ); } } return {shape}; };