"use client"; import { useState } from "react"; import { isDisabled, type ChartState, } from "yt-dlp-transcript-common/lib/homepageChart"; import { Segmented } from "./Segmented"; // The power-user matrix, hidden behind a disclosure. Each control is a Segmented // group; invalid options are greyed via isDisabled (e.g. Symlog is unavailable // on a stacked chart, Share on a non-stacked one) so the UI shows *why* rather // than silently flipping a choice. The exclude-outlier toggle drops the top site. export function CustomizePanel({ state, onPatch, topSiteLabel, }: { state: ChartState; onPatch: (patch: Partial) => void; topSiteLabel: string | null; }) { const [open, setOpen] = useState(false); const dis = (key: Parameters[0], value: string) => isDisabled(key, value, state); return (
{open && (
onPatch({ metric: v })} options={[ { value: "transcribed", label: "Transcribed" }, { value: "downloaded", label: "Downloaded" }, ]} /> onPatch({ breakdown: v })} options={[ { value: "site", label: "By site" }, { value: "channel", label: "By channel" }, ]} /> onPatch({ chartType: v })} options={[ { value: "line", label: "Lines" }, { value: "area", label: "Area" }, { value: "bar", label: "Bars" }, { value: "barH", label: "Ranked" }, { value: "small", label: "Small" }, ]} /> onPatch({ bucket: v })} options={[ { value: "day", label: "Day" }, { value: "week", label: "Week" }, { value: "month", label: "Month" }, { value: "cumulative", label: "Cumulative" }, ]} /> onPatch({ range: v })} options={[ { value: "2w", label: "2w" }, { value: "6w", label: "6w" }, { value: "90d", label: "90d" }, { value: "12mo", label: "12mo" }, { value: "all", label: "All" }, ]} /> onPatch({ scale: v })} options={[ { value: "linear", label: "Linear" }, { value: "symlog", label: "Symlog", disabled: dis("scale", "symlog") }, ]} /> onPatch({ valueMode: v })} options={[ { value: "counts", label: "Counts" }, { value: "share", label: "Share", disabled: dis("valueMode", "share") }, { value: "indexed", label: "Indexed", disabled: dis("valueMode", "indexed") }, ]} /> {topSiteLabel && ( )}
)}
); }