Skip to content

InputBinding

Defined in: InputBinding.ts:4, InputBinding.ts:118

Binding for text input elements

Key features:

  • Supports text, number, and date inputs
  • Handles intermediate values during typing
  • Auto-finalizes values on blur
  • Manages error states and ARIA attributes
  • FormBinding

Config = object & ({ getter: () => string | null; setter: (value: string) => void; type?: StringType; valueAs?: "string"; } | { getter: () => number | null; setter: (value: number | null) => void; type?: NumericValueType; valueAs: "number"; } | { getter: () => string | null; setter: (value: Date | null) => void; type?: DateValueType; valueAs: "date"; })

Defined in: InputBinding.ts:23

optional id?: Attrs["id"]

[Override] ID of the input element

optional onBlur?: Attrs["onBlur"]

[Extend] Blur handler

optional onChange?: Attrs["onChange"]

[Extend] Change handler

optional onFocus?: Attrs["onFocus"]

[Extend] Focus handler

{ getter: () => string | null; setter: (value: string) => void; type?: StringType; valueAs?: "string"; }

getter: () => string | null

Get the value from the model

string | null

setter: (value: string) => void

@action

Set the value to the model

string

void

optional type?: StringType

Type of form control.

When unspecified, it is deduced from the valueAs.

"text" - when valueAs is undefined or "string"

optional valueAs?: "string"

Value type of the input element. It determines how getter/setter should handle the value.


{ getter: () => number | null; setter: (value: number | null) => void; type?: NumericValueType; valueAs: "number"; }

getter: () => number | null

Get the value from the model

number | null

setter: (value: number | null) => void

@action

Set the value to the model

number | null

void

optional type?: NumericValueType

Type of form control.

When unspecified, it is deduced from the valueAs.

"number" - when valueAs is "number"

valueAs: "number"

Value type of the input element. It determines how getter/setter should handle the value.


{ getter: () => string | null; setter: (value: Date | null) => void; type?: DateValueType; valueAs: "date"; }

getter: () => string | null

Get the value from the model

String representation of the date. As Date instance has no distinction between date and datetime, it's developers' responsibility to format the date correctly.

type attr Expected format Example
date YYYY-MM-DD 2024-12-31
datetime-local YYYY-MM-DDTHH:mm 2024-12-31T23:59
time HH:mm or HH:mm:ss 23:59 or 23:59:59
week YYYY-Www 2024-W52
month YYYY-MM 2024-12

string | null

date.toISOString().split("T")[0]

setter: (value: Date | null) => void

@action

Set the value to the model

Date | null

void

optional type?: DateValueType

Type of form control.

When unspecified, it is deduced from the valueAs.

"date" - when valueAs is "date"

valueAs: "date"

Value type of the input element. It determines how getter/setter should handle the value.

new InputBinding(field, config): InputBinding

Defined in: InputBinding.ts:119

FormField

InputBinding.Config

InputBinding

config: InputBinding.Config

Defined in: InputBinding.ts:121

FormBinding.config


onBlur: FocusEventHandler<HTMLInputElement>

Defined in: InputBinding.ts:162


onChange: ChangeEventHandler<HTMLInputElement, HTMLInputElement>

Defined in: InputBinding.ts:144

@action


onFocus: FocusEventHandler<HTMLInputElement>

Defined in: InputBinding.ts:167


get errorMessages(): string | null

Defined in: InputBinding.ts:173

string | null

@computed


get props(): object

Defined in: InputBinding.ts:178

Binding properties which passed to the view component

object

aria-errormessage: string | undefined

aria-invalid: boolean | undefined

id: string

onBlur: FocusEventHandler<HTMLInputElement>

onChange: ChangeEventHandler<HTMLInputElement, HTMLInputElement>

onFocus: FocusEventHandler<HTMLInputElement>

type: HTMLInputTypeAttribute

value: string | number | readonly string[]

FormBinding.props


get type(): HTMLInputTypeAttribute

Defined in: InputBinding.ts:130

HTMLInputTypeAttribute


get value(): string | number | readonly string[]

Defined in: InputBinding.ts:126

string | number | readonly string[]