An abstract base class designed to standardize the behavior for a multi-select UI component. Multi-select components return an array of values as part of form submission. Different implementations may provide different experiences around how inputs are presented to the user.

Hierarchy (view full)

Properties

_options: (HTMLOptGroupElement | HTMLOptionElement)[]

Predefined elements which were defined in the original HTML.

_choices: Record<string, string> = {}

An object which maps option values to displayed labels.

_internals: ElementInternals

Attached ElementInternals which provides form handling functionality.

_primaryInput: HTMLElement

The primary input (if any). Used to determine what element should receive focus when an associated label is clicked on.

tagName: string

The HTML tag name used by this element.

formAssociated: boolean = true

Declare that this custom element provides form element functionality.

Accessors

  • get form(): HTMLFormElement
  • The form this element belongs to.

    Returns HTMLFormElement

  • get name(): string
  • The input element name.

    Returns string

  • get disabled(): boolean
  • Is this element disabled?

    Returns boolean

  • get editable(): boolean
  • Is this field editable? The field can be neither disabled nor readonly.

    Returns boolean

Methods

  • Mark a choice as selected.

    Parameters

    • value: string

      The value to add to the chosen set

    Returns void

  • Mark a choice as un-selected.

    Parameters

    • value: string

      The value to delete from the chosen set

    Returns void

  • Internal

    Apply key attributes on the containing custom HTML element to input elements contained within it.

    Parameters

    • input: any

    Returns void

  • Protected

    Preserve existing elements which are defined in the original HTML.

    Returns void

  • Protected

    Special behaviors that the subclass should implement when toggling the disabled state of the input.

    Parameters

    • disabled: boolean

      The new disabled state

    Returns void

  • Protected

    Create the HTML elements that should be included in this custom element. Elements are returned as an array of ordered children.

    Returns HTMLElement[]

  • Protected

    Special handling when the custom element is clicked. This should be implemented to transfer focus to an appropriate internal element.

    Parameters

    • event: PointerEvent

    Returns void