import { useEffect, useState } from "react"; import styles from "./DropdownButton.module.css"; import { OutsideClickListener } from "../../../hooks/_utils/outsideClick"; import { formatShortcut } from "../../../features/_utils/string.utils"; export function DropdownButton({ label, options, shortcuts }: { label: string; options: { [s: string]: Function; }; shortcuts: { [s: string]: string[]; }; }) { const [open, setOpen] = useState(false); const [tabIndex, setTabIndex] = useState(-1); useEffect(() => { setTabIndex(open ? 0 : -1); }, [open]); return ( { setOpen(false); }}>
{open && options ? (
{Object.entries(options).map(([label, callback]: [label: string, callback: Function]) => )}
) : null }
); }