import { type Memo } from '@zeix/cause-effect'; import type { ComponentProps, EffectDescriptor, Falsy } from '../types'; type EventType = K extends keyof HTMLElementEventMap ? HTMLElementEventMap[K] : Event; /** * Handler for `on()`. Receives `(event, element)`. * * Return `{ prop: value }` to batch-apply updates to host properties (sync only). * Return `Promise` for fire-and-forget side effects — the Promise is not awaited * and its value cannot update host properties. */ type OnEventHandler

= (event: Evt, element: E) => { [K in keyof P]?: P[K]; } | Falsy | void | Promise; /** * `on` helper bound to a component host. Accepts a single element or `Memo` target * and typed event names. Returns an `EffectDescriptor`. */ type OnHelper

= { (target: Memo | Falsy, type: T, handler: OnEventHandler, options?: AddEventListenerOptions): EffectDescriptor; (target: Memo | Falsy, type: string, handler: OnEventHandler, options?: AddEventListenerOptions): EffectDescriptor; (target: E | Falsy, type: T, handler: OnEventHandler, options?: AddEventListenerOptions): EffectDescriptor; (target: E | Falsy, type: string, handler: OnEventHandler, options?: AddEventListenerOptions): EffectDescriptor; }; /** * Create an `on` helper bound to a component host. * * The returned `on` attaches a typed event listener to a single element or `Memo` * collection. Handlers receive `(event, element)`. Returning `{ prop: value }` synchronously * batch-applies those updates to host properties; returning `Promise` is valid for * fire-and-forget side effects. For async state updates use a trigger-state + `Task`: * * ```ts * const trigger = createState(null) * return [ * on(form, 'submit', e => { e.preventDefault(); trigger.set(new FormData(form)) }), * watch(createTask(async () => { ... trigger.get() ... }), { ok: ..., err: ... }), * ] * ``` * * For `Memo` targets, uses event delegation (one listener on the shadow root or host). * Non-bubbling events fall back to per-element listeners; a DEV_MODE warning points toward * `each()` + `on()`. * * @since 2.0 * @param {HTMLElement & P} host - The component host element * @returns {OnHelper

} Bound `on` function for the given host */ declare const makeOn:

(host: HTMLElement & P) => OnHelper

; export { type EventType, makeOn, type OnEventHandler, type OnHelper };