gradum-kit - v0.1.0
    Preparing search index...

    Class GradumSelect<ValueType, SecondaryValueType, EntryType>

    GradumSelect

    Base class for creating a selection menu

    Type Parameters

    • ValueType = string
    • SecondaryValueType = string
    • EntryType extends object = HTMLElement

    Hierarchy (View Summary)

    Index

    The properties this element was created with.

    defaultProperties: GradumSelectProperties = ...

    Default properties assigned to a new selection: selected entries get the selected class, and disabled entries are hidden.

    getValue: (entry: EntryType) => ValueType
    getSecondaryValue: (entry: EntryType) => SecondaryValueType
    createEntry: (value: ValueType) => EntryType
    forceSelection: boolean
    selectedEntriesClasses: string | string[]
    entriesClasses: string | string[]
    initialized: boolean

    Whether the element was initialized already or not.

    defaultFeedforwardProperties: GradumElementProperties

    The properties passed on to children created through feedforward, letting a parent seed its descendants with shared defaults.

    • get onSelect(): Delegate<(b: boolean, entry: EntryType, index: number) => void>

      Returns Delegate<(b: boolean, entry: EntryType, index: number) => void>

      Fired whenever an entry is selected or deselected, with the new state, the entry, and its index. Assigning a function subscribes it rather than replacing the existing subscribers.

    • set onSelect(value: (b: boolean, entry: EntryType, index: number) => void): void

      Parameters

      • value: (b: boolean, entry: EntryType, index: number) => void

      Returns void

    • get onEnabled(): Delegate<(b: boolean, entry: EntryType, index: number) => void>

      Returns Delegate<(b: boolean, entry: EntryType, index: number) => void>

      Fired whenever an entry is enabled or disabled. Assigning a function subscribes it rather than replacing the existing subscribers.

    • set onEnabled(
          value: (b: boolean, entry: EntryType, index: number) => void,
      ): void

      Parameters

      • value: (b: boolean, entry: EntryType, index: number) => void

      Returns void

    • get onEntryAdded(): Delegate<(entry: EntryType, index: number) => void>

      Returns Delegate<(entry: EntryType, index: number) => void>

      Fired whenever an entry is added. Assigning a function subscribes it rather than replacing the existing subscribers.

    • set onEntryAdded(value: (entry: EntryType, index: number) => void): void

      Parameters

      • value: (entry: EntryType, index: number) => void

      Returns void

    • get onEntryRemoved(): Delegate<(entry: EntryType) => void>

      Returns Delegate<(entry: EntryType) => void>

      Fired whenever an entry is removed. Assigning a function subscribes it rather than replacing the existing subscribers.

    • set onEntryRemoved(value: (entry: EntryType) => void): void

      Parameters

      Returns void

    • get onEntryClicked(): Delegate<(entry: EntryType, e: Event) => void>

      Returns Delegate<(entry: EntryType, e: Event) => void>

      Fired whenever an entry is clicked, whether or not the click changes the selection. Assigning a function subscribes it rather than replacing the existing subscribers.

    • set onEntryClicked(value: (entry: EntryType, e: Event) => void): void

      Parameters

      Returns void

    • get values(): ValueType[]

      Returns ValueType[]

      The values of this selection's entries. Assigning a new list rebuilds the entries to match.

    • set values(values: ValueType[]): void

      Parameters

      Returns void

    • get selectedEntries(): EntryType[]

      Returns EntryType[]

    • set selectedEntries(value: EntryType[]): void

      Parameters

      Returns void

    • set parent(value: Element): void

      Parameters

      Returns void

    • get inputName(): string

      The dropdown's underlying hidden input. Might be undefined.

      Returns string

    • set inputName(value: string): void

      Parameters

      • value: string

      Returns void

    • set multiSelection(value: boolean): void

      Parameters

      • value: boolean

      Returns void

    • get enabledEntries(): EntryType[]

      Returns EntryType[]

    • get enabledValues(): ValueType[]

      Returns ValueType[]

    • get selectedEntry(): EntryType

      Returns EntryType

      The dropdown's currently selected entries

    • get selectedIndex(): number

      Returns number

    • set selectedIndex(value: number): void

      Parameters

      • value: number

      Returns void

    • get selectedIndices(): number[]

      Returns number[]

    • get selectedValues(): ValueType[]

      Returns ValueType[]

      The dropdown's currently selected values

    • set selectedValues(values: ValueType[]): void

      Parameters

      Returns void

    • get selectedValue(): ValueType

      Returns ValueType

    • get stringSelectedValue(): string

      Returns string

    • Protected Function

      customCreate

      Parameters

      Returns object

      The created selection.

      Build a selection, deferring the initial entries and selected values until the element exists so they are not lost during construction.

    • Parameters

      Returns EntryData

    • Parameters

      Returns void

    • Parameters

      Returns void

    • Parameters

      Returns boolean

    • Function

      select

      Parameters

      • value: ValueType | EntryType

        The entry to select, or the value identifying it.

      • Optionalselected: boolean = true

        Whether to select the entry, or deselect it.

      Returns this

      Itself, allowing for method chaining.

      Select or deselect an entry. In single-selection mode selecting one entry deselects whichever was selected before.

    • Function

      selectByIndex

      Parameters

      • index: number

        The index of the entry to select.

      • Optionalpreprocess: (index: number, entriesCount: number, zero?: number) => number = trim

        Applied to the index before use. Defaults to trim, which clamps it into range; pass mod to wrap around instead.

      Returns this

      Itself, allowing for method chaining.

      Select the entry at the given index.

    • Parameters

      Returns number

    • Returns void

    • Returns void

    • Parameters

      Returns void

    • Parameters

      • disableObserver: boolean = true

      Returns void

    • Returns void

    • Parameters

      • value: boolean

      Returns void

    • Returns void

    • Returns void

    • Function

      initialize

      Returns void

      Initializes the element. It sets up the UI by calling the methods setupUIElements, setupUILayout, setupUIListeners, and setupChangedCallbacks (in this order, if they are defined). This function is called automatically in .setProperties() and when instantiating an element via element(). It is called only once per element (as it checks with the reflected initialized flag).

    • Function

      feedforward

      Parameters

      • Optionalproperties: FeedforwardProperties

        Properties to feed forward. Defaults to defaultFeedforwardProperties.

      Returns this

      Itself, allowing for method chaining.

      Push this element's feedforward properties down to its children, so newly added descendants pick up the same defaults.

    • Function

      clone

      Parameters

      Returns this

      The cloned element.

      Create a copy of this element. By default the copy carries the same properties and children but none of the bound listeners.