mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-08-24 20:34:05 +02:00
24 lines
775 B
TypeScript
24 lines
775 B
TypeScript
import { useAtomValue } from "jotai";
|
|
import { contextMenusAtom, hideContextMenu } from "../lib/contextMenu";
|
|
import { ContextMenu } from "./core/Dropdown";
|
|
import { ErrorBoundary } from "./ErrorBoundary";
|
|
|
|
/** Renders menus opened by {@link showContextMenu}, the way {@link Dialogs} renders dialogs. */
|
|
export function ContextMenus() {
|
|
const menus = useAtomValue(contextMenusAtom);
|
|
return (
|
|
<>
|
|
{menus.map(({ id, items, triggerPosition, triggerRect }) => (
|
|
<ErrorBoundary key={id} name={`ContextMenu ${id}`}>
|
|
<ContextMenu
|
|
items={items}
|
|
triggerPosition={triggerPosition}
|
|
triggerRect={triggerRect}
|
|
onClose={() => hideContextMenu(id)}
|
|
/>
|
|
</ErrorBoundary>
|
|
))}
|
|
</>
|
|
);
|
|
}
|