Class Input

Represents an input UI state. It acts as a domain store but also provides a separate input value state and state for querying assistive input choices.

Type parameters

Type parameter Description
TValue

the input's value type.

constructor

  • Instantiates the input state.

    Parameters

    • defaultValue: TValue

      Specifies the input's initial value.

    • Optional options: InputOptions<TValue>

      Customizes normalization and general responses to user interactions.

    Returns Input

boundsQuery

boundsQuery: BoundsQuery

defaultValue

defaultValue: TValue

Specifies the input's initial value.

devOptions

devOptions: StateDevOptions

Development-time settings

focusState

focusState: FocusState

hoverState

hoverState: HoverState

options

options: InputOptions<TValue>

Customizes normalization and general responses to user interactions.

form

  • get form(): null | Form<any, any, any>
  • Return the singleton form that this input is associated to, only in the case where this input is indeed associated to that single form. Returns null if the input is not associated to any form or is associated to multiple forms.

    Returns null | Form<any, any, any>

forms

  • get forms(): Form<any, any, any>[]
  • Returns all forms associated with this input.

    Returns Form<any, any, any>[]

hasChanged

  • get hasChanged(): boolean
  • Returns true if the input value is different from the last confirmed value.

    Returns boolean

inputValue

  • get inputValue(): TValue
  • Gets the current input value. If the user has not touched the input, this is the same as the store value.

    Returns TValue

isBeingSubmitted

  • get isBeingSubmitted(): boolean
  • Returns true if any of the forms that this input belongs is being submitted.

    Returns boolean

isConfirmed

  • get isConfirmed(): boolean
  • Returns true if the user has ever confirmed the input.

    Returns boolean

isPending

  • get isPending(): boolean
  • Returns true if the input has put content without confirming it. Essentially means input() has been called without calling confirm().

    Returns boolean

isValidated

  • get isValidated(): boolean

name

  • get name(): null | string
  • Returns the UI state's debug name.

    Returns null | string

normalizedInputValue

  • get normalizedInputValue(): TValue
  • Returns the input value, but normalized by the normalizer provided in the input options.

    Returns TValue

validators

  • get validators(): Validator<any, any, any, any>[]
  • Returns all validators associated with this input.

    Returns Validator<any, any, any, any>[]

value

  • get value(): TValue
  • Gets the store value. If the user has pending input, that value is not reflected here.

    Returns TValue

clear

  • clear(): void
  • Clears the current input value. This will make the current input value the same as the store value.

    Returns void

confirm

  • confirm(args?: undefined | object): Promise<void>
  • Commits the input value into the store as a consequence of a user action that confirms an input. For instance, this method should be called when the user blurs out of an input or hits enter on a single-line input.

    The value to confirm is the normalized by the normalizer provided in the input options.

    The method is no-op if the value to confirm is exactly the same as the value of the store and the input has been confirmed already.

    The input will ask its validators to (re-)trigger validation if the value is different from the store value. If the "revalidate" option is configured, the decision whether or not to validate completely depends on this predicate.

    see

    InputOptions.normalizer

    see

    InputOptions.revalidate

    see

    InputOptions.confirmCascade

    Parameters

    • Optional args: undefined | object

      Customizes the nature of the confirm interaction.

    Returns Promise<void>

input

  • input(value: TValue): void
  • Sets the input value as a consequence of the user inputting a value.

    For input with choices, inputting a value will start a new query for possible choices.

    An input that is being submitted by a form will not respond to this method.

    Parameters

    • value: TValue

    Returns void

markAsConfirmed

  • markAsConfirmed(): void
  • Arbitrarily flag the input as having confirmed by the user.

    Returns void

normalizeValue

  • normalizeValue(value: TValue): TValue

reset

  • reset(args?: undefined | object): void
  • Resets the user-confirmed flag. Optionally resets the input value to any arbitrary value.

    Parameters

    • Optional args: undefined | object

    Returns void

validate

  • validate(filter?: "input" | "confirm" | null): Promise<void>
  • Request validation on the input. This goes through all validators that are associated with the input.

    If a validator is not enabled (see the "enabled" validator option) initially, it is not validated but will be checked again after the first set of enabled validators have completed. You can exploit this behavior to write validators that are only enabled based on validity of other validators.

    see

    ValidatorOptions.enabled

    Parameters

    • Default value filter: "input" | "confirm" | null = null

    Returns Promise<void>

Generated using TypeDoc