import { isMacLike } from "../../common/util.ts"; import { FilterList } from "./filter.tsx"; import { faPersonRunning } from "https://esm.sh/@fortawesome/free-solid-svg-icons@6.2.0"; import { AppCommand } from "../hooks/command.ts"; import { FilterOption } from "../../common/types.ts"; import {React} from "../../../dep_web.ts" export function CommandPalette({ commands, recentCommands, onTrigger, }: { commands: Map; recentCommands: Map; onTrigger: (command: AppCommand | undefined) => void; }) { let options: FilterOption[] = []; const isMac = isMacLike(); for (let [name, def] of commands.entries()) { options.push({ name: name, hint: isMac && def.command.mac ? def.command.mac : def.command.key, orderId: recentCommands.has(name) ? -recentCommands.get(name)!.getTime() : 0, }); } return ( { if (opt) { onTrigger(commands.get(opt.name)); } else { onTrigger(undefined); } }} /> ); }