import { useActions } from '../../../context/actions' import { useActionState } from '../../../hooks/useActionState' import { TldrawUiMenuCheckboxItem, type TLUiMenuCheckboxItemProps, } from './TldrawUiMenuCheckboxItem' /** @public */ export type TLUiMenuActionCheckboxItemProps = { actionId?: string /** What to do when the item is disabled, by `disabled` or the action's `isEnabled`. Defaults to `'disable'`. */ whenDisabled?: 'hide' | 'disable' } & Pick /** @public @react */ export function TldrawUiMenuActionCheckboxItem({ actionId = '', whenDisabled = 'disable', disabled = false, checked, ...rest }: TLUiMenuActionCheckboxItemProps) { const actions = useActions() const action = actions[actionId] const { available, enabled, checked: isChecked } = useActionState(action) if (!action || !available) return null if ((disabled || !enabled) && whenDisabled === 'hide') return null return ( ) }