Selector Component Referencetml`<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).
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.
Selector component accepts the standard attributes.disabledonUserChangefn(value) where value is the value associated with the selected option. The displayed list reflects the newly selected option. The onUserChange function may, of course, subsequently override the selection by setting calling the setValue() method if required.optionstexttext is omitted, then value coerced to a string is used.value The value of the state variable if this option is selected.
If an element is a number, the displayed text is the number coerced to a string, and the value is the element. If an element is a string, it is used for both the displayed text and value.
orientationradio attribute is not truthy, orientation is ignored. The button labels are the test associated with each option. The possible values are:labelBottom (default)labelLeftlabelRightlabelTopradioorientation attribute. If no orientation is specified, the radio buttons will be laid out horizontally with the labels below each button.valuevalueOnlyThese methods are intended to be used by parent components to dynamically change the properties of the rendered components without re-rendering.
getText()getText()
Returns the text associated with the currently selected option.
A String.
setClassName()setClassName(cn)
Sets the rendered element's className to cn.
cnsetDisabled()setDisabled(b)
if b is truthy, the selector input is disabled and appears greyed out. If b is falsey, the selector input is enabled.
bsetOptions()setOptions(options)
setOptions(options, value)
Sets the component options according to the array in options. If value is present, then the selected option value is set to value after the options are set.
optionstexttext is omitted, then value coerced to a string is used.value The value of the state variable if this option is selected.
If an element is a number, the displayed text is the number coerced to a string, and the value is the element. If an element is a string, it is used for both the displayed text and value.
value (optional)options array.setValue()setValue(value)
Sets the rendered element's value.
valueThe Selector component ignores all children.
The Selector is rendered in several different ways:
valueOnly attribute is truthy:<span> element. The element will have selector_value and selector_value-valueOnly CSS class strings.valueOnly and radio attributes are not truthy:<span> element containing two child <span> elements containing the text associated with the selected value and a selector glyph. When the outer <span> is clicked, a scrollable list of option text appears over the input field. The popup list disappears when an option is selected.<span> element has the CSS class strings passed in the className attribute plus popupInput and selector.<span> element containing the currently selected option text has a CSS class name of selector_value.<span> element containing selector glyph has a CSS class name of selector_symbol.valueOnly attribute is not truthy and radio attribute is truthy:Table component with radio buttons and labels in the desired orientaion.Table element has a CSS class name of radioInput.XXX