@thi.ng/rdom
Version:
Lightweight, reactive, VDOM-less UI/DOM components with async lifecycle and @thi.ng/hiccup compatible
63 lines • 2.01 kB
TypeScript
import type { ISubscriber, ISubscription } from "@thi.ng/rstream";
/**
* HOF DOM event listener to emit element's value on given stream.
*
* @example
* ```ts
* import { $compile, $input } from "@thi.ng/rdom";
* import { reactive } from "@thi.ng/rstream";
*
* const name = reactive("");
*
* $compile(
* ["input", { oninput: $input(name), value: name }]
* ).mount(document.body);
* ```
*
* @param stream -
*/
export declare const $input: <T extends string = string>(stream: ISubscriber<T>) => (e: Event) => void;
/**
* Similar to {@link $input}, but attempts to first coerce value using
* `parseFloat()`. Uses given `fallback` value (default: 0) if coercion failed
* (i.e. if the event target's `.value` isn't numeric).
*
* @param stream -
* @param fallback -
*/
export declare const $inputNum: (stream: ISubscriber<number>, fallback?: number) => (e: Event) => void;
/**
* HOF DOM event listener to emit a checkbox input's value on given stream.
*
* @param stream -
*/
export declare const $inputCheckbox: (stream: ISubscriber<boolean>) => (e: Event) => void;
/**
* HOF DOM event listener to emit `true` on given stream when event is
* triggered.
*
* @param stream -
*/
export declare const $inputTrigger: (stream: ISubscriber<boolean>) => () => void;
/**
* HOF DOM event listener to emit the complement value of the given stream's
* current value when event is triggered (i.e. a switch/toggle behavior).
*
* @param stream -
*/
export declare const $inputToggle: (stream: ISubscription<boolean, boolean>) => () => void;
/**
* HOF DOM event listener to emit a file input's first selected file on given
* stream.
*
* @param stream -
*/
export declare const $inputFile: (stream: ISubscriber<File>) => (e: Event) => void;
/**
* HOF DOM event listener to emit a file input's entire selected list of files
* on given stream.
*
* @param stream -
*/
export declare const $inputFiles: (stream: ISubscriber<FileList>) => (e: Event) => void;
//# sourceMappingURL=event.d.ts.map