import Combobox from "./ui/Combobox"; // Pick one registered user by name or email: the download quota's "any user" picker and the share // dialog's recipient. Both used to hand-roll an input over an absolute list that only a mouse could // reach (no arrow keys, no listbox for a screen reader, closed by a blur timer); this is the shared // Combobox in single-select, which brings all of that. A pick is an ACTION here, not a value to show, // so nothing stays selected: the field clears for the next one. export interface PickableUser { id: number; email: string; display_name?: string | null; } export default function UserPicker({ users, onPick, label, placeholder, loading, }: { users: readonly U[]; onPick: (u: U) => void; label: string; placeholder: string; loading?: boolean; }) { const byId = new Map(users.map((u) => [String(u.id), u])); return ( ({ value: String(u.id), label: u.display_name ? `${u.display_name} ยท ${u.email}` : u.email, }))} onChange={(next) => { const u = next[0] != null ? byId.get(next[0]) : undefined; if (u) onPick(u); }} renderOption={(o) => { const u = byId.get(o.value); return ( {u?.display_name || u?.email} {u?.display_name && {u.email}} ); }} /> ); }