import * as React from 'react'; import { cn } from '@/lib/utils'; import { Switch } from '@/components/ui/switch'; /** * Toggle — a labelled switch row for settings. * * Wraps the Switch primitive with the label/description layout it is almost * always used with, and makes the whole row a label so the hit target is the * full width rather than the 36px control. */ export function Toggle({ checked, onCheckedChange, label, description, disabled, /** `end` puts the switch on the right (settings rows); `start` on the left. */ align = 'end', className, id: providedId, }) { const reactId = React.useId(); const id = providedId || reactId; const descriptionId = description ? `${id}-description` : undefined; const control = ( ); const text = ( {label} {description && ( {description} )} ); return ( ); } /** * SegmentedToggle — a small pill group for switching between 2–4 mutually * exclusive views. Used where Tabs would be too heavy (chart ranges, EN/ES). */ export function SegmentedToggle({ options = [], value, onChange, size = 'default', className, ariaLabel }) { const normalized = options.map((o) => (typeof o === 'string' ? { value: o, label: o } : o)); return (
{normalized.map((option) => { const active = option.value === value; return ( ); })}
); }