import { ArrowDown, ArrowUp, RotateCcw } from "lucide-react"; import { useEffect, useMemo, useState } from "react"; import { useI18n } from "../i18n"; import { ORDERABLE_KINDS, hasCustomOrder, isOrderDirty, moveWedge, orderWedgeIds, presetWedgeIds, savedOrderFor, wedgeLabelKey, type FileKind, type RadialRing, type WedgeOrders, } from "../lib/radialOrder"; /** * The reorder screen for the radial rings. * * It edits one preset at a time — a file kind plus a ring — and can only rearrange the * wedges that ring actually offers, so a preset can never invent an action. The list is * always the live catalogue in a saved order; saving an empty list (Reset) hands the * ring back to the built-in order. Every rule the screen applies lives in * `src/lib/radialOrder.ts`, which keeps them testable without mounting this panel. */ export function RadialOrderPanel({ orders, onApply, }: { orders: WedgeOrders; onApply: (kind: FileKind, ring: RadialRing, order: string[]) => void; }) { const { t } = useI18n(); const [kind, setKind] = useState("image"); const [ring, setRing] = useState("actions"); const [draft, setDraft] = useState([]); const catalogue = useMemo(() => presetWedgeIds(kind, ring), [ring, kind]); const saved = savedOrderFor(orders, kind, ring); useEffect(() => { setDraft(orderWedgeIds(catalogue, saved)); }, [catalogue, saved]); const custom = Boolean(saved); return ( <>
{t("radialKind")}
{ORDERABLE_KINDS.map((entry) => ( ))}
{t("radialOrder", { count: draft.length })}

{t("radialOrderBody")}

    {draft.map((id, index) => (
  1. {index + 1} {t(wedgeLabelKey(id))}
  2. ))}
); }