import { type ReactNode } from "react"; // Shared MATCH / segmented primitive — a rounded-full pill track where exactly ONE option is active // (radio-like). Backs the feed any/all + or/and "Match" toggles and the feed Mine/Library scope bar, // and the Plex any/all combine toggles. The active paint comes entirely from the // `.pill[aria-pressed="true"]` recipe (index.css) — do NOT add bg/text/border-colour utilities on the // buttons here or a utility-layer class would beat the pressed fill. export interface SegmentedOption { value: T; label: string; icon?: ReactNode; title?: string; // optional per-option tooltip } export default function SegmentedToggle({ options, value, onChange, ariaLabel, label, title, fullWidth = false, size = "sm", className, }: { options: readonly SegmentedOption[]; value: T; onChange: (v: T) => void; ariaLabel: string; // Optional left-hand caption; when set the control renders as a justify-between row (the feed/Plex // "Match" toggles). Omit for a standalone bar (the Mine/Library scope switch). label?: ReactNode; title?: string; // tooltip on the whole row (caption mode only) // Full-width track with flex-1 buttons (the scope bar); default is intrinsic width. fullWidth?: boolean; // sm = text-3xs, compact padding (the captioned match toggles); md = text-xs (the scope bar). size?: "sm" | "md"; className?: string; }) { const track = (
{options.map((o) => ( ))}
); if (label == null) { return className ?
{track}
: track; } return (
{label} {track}
); }