import type { ReactNode } from "react"; import { DropdownMenuItem } from "./dropdown-menu"; import { cn } from "../lib/cn"; /** * One action row for composer drill-ins, as a menu item inside the + menu and * as a button when the same panel is shown in a dialog. Kept apart from the * lazily loaded connector list so the + menu can use it without loading that. */ export function ConnectorAction(props: { presentation?: "menu" | "dialog" | undefined; checked?: boolean | undefined; label?: string | undefined; disabled?: boolean | undefined; /** * Reachable with the keyboard and read as unavailable, but does nothing: a * current value shown in a menu (Radix skips `disabled` items entirely). */ readOnly?: boolean | undefined; locked?: boolean | undefined; className?: string | undefined; keepOpen?: boolean | undefined; onAction: () => void; children: ReactNode; }) { if (props.readOnly) { return props.presentation === "dialog" ? ( ) : ( event.preventDefault()} > {props.children} ); } if (props.locked) { return (
{props.children}
); } if (props.presentation === "dialog") { return ( ); } return ( { if (props.keepOpen) event.preventDefault(); props.onAction(); }} > {props.children} ); }