import { Button } from "@workspace/ui/components/button" import { Tooltip, TooltipContent, TooltipTrigger, } from "@workspace/ui/components/tooltip" import { useLexicalActionContext } from "./context" import { useLexicalMessage } from "./i18n" import type { LexicalControlProps } from "./types" export function LexicalControl({ action, label, presentation = "control", render, value, }: LexicalControlProps) { const context = useLexicalActionContext() const active = action.isActive?.(context) ?? false const disabled = action.isDisabled?.(context) ?? false const resolvedLabel = useLexicalMessage(label ?? action.label) const execute = (nextValue?: Value) => action.execute(context, nextValue ?? value) const onClick = () => execute() const renderProps = { active, disabled, execute, label: resolvedLabel, onClick, } if (render) return render(renderProps) if (action.control) { const ActionControl = action.control return ( ) } const Icon = action.icon return ( event.preventDefault()} onClick={onClick} /> } > {Icon ? : null} {resolvedLabel} ) }