import { raf } from '@utils/helpers'; export interface ClickController { handleClickCapture: (ev: Event) => void; } /** * The content slotted into a form control's start or end slot that a click * started on, or `null` when the click did not start on slotted content. * * The slotted element is compared against the host in case the form control * itself is slotted into, for example, an item. Without that check a control * carrying slot="start"/"end" would treat every click on itself as a slotted * click. */ export const getSlottedClickContent = (ev: Event, el: HTMLElement): HTMLElement | null => { const slotted = (ev.target as HTMLElement).closest('[slot="start"], [slot="end"]'); return slotted !== null && slotted !== el && el.contains(slotted) ? slotted : null; }; /** * Whether a click started on content slotted into a form control's start or * end slot. */ const isSlottedClick = (ev: Event, el: HTMLElement): boolean => getSlottedClickContent(ev, el) !== null; /** * A utility for form components that wrap their content in a