/** * Controls whose pointer-originated focus is released once the click that * produced it completes. Text entry is deliberately absent: a click into a * field must not end typing. Neither the shared controls bar nor the vendor * chrome holds one today. */ export const POINTER_FOCUS_RELEASE_SELECTOR = 'button, input[type="range"], [role="slider"]'; export interface BlurFocusedControlOptions { /** Controls eligible for release; defaults to the shared selector. */ selector?: string; } /** * What a click's own `pointerType` says about its origin: `true` for a * pointer (mouse, touch, pen); `false` for keyboard activation or script, * since current engines dispatch Enter/Space on a focused button and * `element.click()` as a PointerEvent with an empty `pointerType`; `null` * for a legacy MouseEvent click that carries no pointer type at all, which * the caller must attribute some other way or leave alone. */ export function clickPointerOrigin(event: MouseEvent): boolean | null { const pointerType = (event as Partial).pointerType; return typeof pointerType === 'string' ? pointerType !== '' : null; } /** * Blur the focused control inside `root` when it is eligible. Chromium * focuses a clicked `