import type { ExplicitSink, Sink } from "../types/sink"; import type { RMLTemplateExpressions, SinkBindingConfiguration } from "../types/internal"; import type { FocusableElement } from '../types/rml'; import { SINK_TAG } from "../constants"; export const FOCUS_SINK_TAG = 'focus'; export const FocusSink: Sink = (node: FocusableElement) => (state: boolean) => { state ? node.focus?.() : node.blur?.(); }; ; /** * A specialised sink for the "rml:focus" RML attribute * @param source A present or future boolean value * @returns RMLTemplateExpression A template expression for the "rml:focus" RML attribute * @example * @example * @example * @example */ export const Focus: ExplicitSink<'rml:focus'> = (source: RMLTemplateExpressions.BooleanAttributeValue<'rml:focus'>) => >({ type: SINK_TAG, t: FOCUS_SINK_TAG, source, sink: FocusSink, }) ;