import type { ReactNode } from 'react' import { Input } from './ui/input' import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from './ui/select' import { Switch } from './ui/switch' type SelectOption = { value: string; label: string } type ControlWidth = 'auto' | 'compact' | 'default' | 'wide' const SETTINGS_GROUP_ITEM_CLASS = 'border-b border-border px-4 py-3 last:border-b-0' function sanitizePositiveInteger(value: number | null | undefined, fallback: number): number { if (value === null || value === undefined || !Number.isFinite(value) || value < 1) return fallback return Math.round(value) } export function SettingsSection({ children, id, }: { children: ReactNode id?: string showDivider?: boolean }) { return (
{children}
) } export function SectionHeading({ icon, title, }: { icon?: ReactNode title: string description?: string }) { return (
{icon ? {icon} : null}
{title}
) } export function SettingsGroup({ children }: { children: ReactNode }) { return
{children}
} export function SettingsGroupItem({ children, testId, }: { children: ReactNode testId?: string }) { return
{children}
} function controlWidthClass(width: ControlWidth): string { if (width === 'auto') return 'lg:w-auto' if (width === 'compact') return 'lg:w-56' if (width === 'wide') return 'lg:w-[420px]' return 'lg:w-80' } export function SettingsRow({ label, description, children, controlWidth = 'default', testId, }: { label: string description?: string children: ReactNode controlWidth?: ControlWidth testId?: string }) { return (
{label}
{description ?
{description}
: null}
{children}
) } export function SelectControl({ value, onValueChange, options, testId, ariaLabel, autoFocus = false, }: { value: string onValueChange: (value: string) => void options: SelectOption[] testId: string ariaLabel: string autoFocus?: boolean }) { return ( ) } export function NumberInputControl({ value, onValueChange, testId, ariaLabel, disabled = false, }: { value: number onValueChange: (value: number) => void testId: string ariaLabel: string disabled?: boolean }) { return ( onValueChange(sanitizePositiveInteger(Number(event.target.value), value))} data-testid={testId} className="w-full bg-transparent" /> ) } export function SettingsSwitchControl({ label, checked, onChange, disabled = false, }: { label: string checked: boolean onChange: (value: boolean) => void disabled?: boolean }) { return } export function LabeledSelect({ label, value, onValueChange, options, testId, autoFocus = false, }: { label: string value: string onValueChange: (value: string) => void options: Array<{ value: string; label: string }> testId: string autoFocus?: boolean }) { return (
) } export function LabeledNumberInput({ label, value, onValueChange, testId, disabled = false, }: { label: string value: number onValueChange: (value: number) => void testId: string disabled?: boolean }) { return (
) } export function SettingsSwitchRow({ label, description, checked, onChange, disabled = false, testId, }: { label: string description: string checked: boolean onChange: (value: boolean) => void disabled?: boolean testId?: string }) { return ( ) }