ElementHandle
A mounted view as code reaches it through a ref: to focus it, set a native prop directly, or listen for and dispatch events.
Usage
Fade a view on entry or removal.
This type is used by Box
// Fade a view on entry or removal.
import { Box, fade, slide, spring } from 'kuito';
<Box enter={fade.and(slide.up(12))} exit={fade} layout={spring()} />;Type declaration
export interface ElementHandle {
readonly id: string;
readonly parent: ElementHandle | null;
readonly children: ElementHandle[];
focus(): void;
blur(): void;
/** Sets a native prop on the view now, until its binding writes it again. */
setProperty<K extends keyof ElementProperties>(key: K, value: ElementProperties[K] | null): void;
addEventListener(
type: string,
fn: (e: KuitoNativeEvent) => void,
options?: boolean | { capture?: boolean; once?: boolean; signal?: AbortSignal },
): void;
removeEventListener(
type: string,
fn: (e: KuitoNativeEvent) => void,
options?: boolean | { capture?: boolean },
): void;
/**
* Sends an event through the tree, capture to bubble, as a native one travels:
* a `KuitoCustomEvent`, or any object with a `type`. False when a listener
* called `preventDefault()` on a cancelable event.
*/
dispatchEvent(event: { type: string; bubbles?: boolean; cancelable?: boolean }): boolean;
}Members 9
| Name | Type | Required | Description |
|---|---|---|---|
idreadonly | string | Yes | — |
parentreadonly | ElementHandle | Yes | — |
childrenreadonly | ElementHandle[] | Yes | — |
focus | () => void | Yes | — |
blur | () => void | Yes | — |
setProperty | <K extends keyof ElementProperties>(key: K, value: ElementProperties[K] | null) => void | Yes | Sets a native prop on the view now, until its binding writes it again. |
addEventListener | (type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean; once?: boolean; signal?: AbortSignal;}) => void | Yes | — |
removeEventListener | (type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean;}) => void | Yes | — |
dispatchEvent | (event: { type: string; bubbles?: boolean; cancelable?: boolean;}) => boolean | Yes | Sends an event through the tree, capture to bubble, as a native one travels:
a KuitoCustomEvent, or any object with a type. False when a listener
called preventDefault() on a cancelable event. |
focus — method signatures
Signatures
(): voidParameters
No parameters.
Returns
void
blur — method signatures
Signatures
(): voidParameters
No parameters.
Returns
void
setProperty — method signatures
Signatures
<K extends keyof ElementProperties>(key: K, value: ElementProperties[K] | null): voidType parameters
| Name | Constraint | Default |
|---|---|---|
K | keyof ElementProperties | — |
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
key | K | Yes | — |
value | ElementProperties[K] | Yes | — |
Returns
void
addEventListener — method signatures
Signatures
(type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean; once?: boolean; signal?: AbortSignal; }): voidParameters
| Name | Type | Required | Description |
|---|---|---|---|
type | string | Yes | — |
fn | (e: KuitoNativeEvent) => void | Yes | — |
options | boolean | { capture?: boolean; once?: boolean; signal?: AbortSignal;} | No | — |
Returns
void
removeEventListener — method signatures
Signatures
(type: string, fn: (e: KuitoNativeEvent) => void, options?: boolean | { capture?: boolean; }): voidParameters
| Name | Type | Required | Description |
|---|---|---|---|
type | string | Yes | — |
fn | (e: KuitoNativeEvent) => void | Yes | — |
options | boolean | { capture?: boolean;} | No | — |
Returns
void
dispatchEvent — method signatures
Signatures
(event: { type: string; bubbles?: boolean; cancelable?: boolean; }): booleanParameters
| Name | Type | Required | Description |
|---|---|---|---|
event | { type: string; bubbles?: boolean; cancelable?: boolean;} | Yes | — |
Returns
boolean
Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.