Selector Component Reference

Table of Contents


Introduction

Syntax

tml`<Selector .../>`

The Selector component renders selector inputs. It is a separate component used by the Selector Input State Variable Reference so that it can be reused by other components.

The Selector component normally selector field that shows and currently selected value and will show a popup scrollable list of options when clicked. The HTML <select> element is not used because the presentation can be highly variable between platforms.

The Selector component has several methods that can be used to allow parent components to dynamically manipulate the state of the rendered elements. See [Instance methods](#instance methods).

Radio buttons

If the radio attribute is truthy, the options are presented as a set of radio buttons. The radio buttons can be laid out horizontally with button labels on the top or bottom, or vertically with the button labels to the left or right. The layout is controlled by the orientation attribute. The button labels are the test associated with each option.

Attributes


Instance methods

These methods are intended to be used by parent components to dynamically change the properties of the rendered components without re-rendering.


getText()

Syntax

getText()

Returns the text associated with the currently selected option.

Return value

A String.


setClassName()

Syntax

setClassName(cn)

Sets the rendered element's className to cn.

Parameters


setDisabled()

Syntax

setDisabled(b)

if b is truthy, the selector input is disabled and appears greyed out. If b is falsey, the selector input is enabled. This has no effect on a valueOnly selector.

Parameters


setOptions()

Syntax

setOptions(options)
setOptions(options, value)

Sets the component options according to the array in options and remounts the component. If value is present, then the selected option value is set to value after the options are set. Calling setOptions() with no options makes no change.

Return value

The component's current array of (normalized) options.

Parameters


setValue()

Syntax

setValue(value)

Sets the rendered element's value.

Parameters


Children

The Selector component ignores all children.


Base class

The value-only, popup and radio renderings all extend the exported SelectorBaseCmp class (also the base class of ListSelector). SelectorBaseCmp removes the options, value and disabled attributes from the component props, keeps them in _options, _value and disabled, and implements setValue(), getText() and setOptions().


DOM element properties

The Selector is rendered in several different ways: