A unit output (unitOutput) state variable represents a numeric value with multiple possible units. The app may provide the user a choice of their desired units for the number. The app can also choose which units it wants to compute with independent of the user's choice. Each rendered component will display according to the format and limits specified for the chosen unit in the state variable.
The unit output contains several child numericOutput state variables, one for each unit is supports. Each child state variable is published with a subName corresponding to its unit (e.g., 'myPage_mySv_kg' and 'myPage_mySv_lb'). When one child state variable changes, the others are updated with the new value converted to their respective units.
Each unit output has an associated unitClass string. Each unitClass is associated with a unitSelector state variable. The unitSelector state variable controls which unit each rendered component will be displayed to the user. Many unitInput and unitOutput state variables can have the same unitClass, and, therefore will be controlled by the same unitSelector.
The unitOutput state variable's component instance will display the currently selected unit sibling. If the showUnits attribute or the '{{...@}}' template syntax is used, the component will also display the appropriate unit abbreviations for the currently selected unit.
The app code or a component template may also refer to a specific child numericOutput state variable. Any modification to that child will also update its siblings with converted values.
'unitOutput', class: UnitOutputSvctl.createPage({
...,
stateVarInfo:[
{type:'unitOutput', ...},
],
})
info
An object containing the state variable properties. The info object can contain the following properties, but subclasses of StateVar may have additional properties:
info properties.info properties.info properties.unitClassunitClass string for the unitSelector that controls which unit sibling is current for this state variable.unitsinfo object.The object for each unit has the following keys:
fmt (optional)fmtStr). A NumFmt instance is not accepted. If no fmt is provided, a format string of '8' is assumed. Any min or max for a unit is ignored.dflt (optional)INVALID_NONE.Note: The component() method is inherited from OutputSv and wraps render(). The parent's render() returns a <When> that renders a <StateVar> for the current unit sibling, and re-renders it when the unitSelector value changes. The component that is ultimately displayed is the current sibling's NumOutputSvCmp, so the numericOutput component attributes apply.
The following methods operate on the current unit sibling (curSv):
val([value]), isValid(...), setDflt(), fmtVal(), fmtUnit(), and userChange(value).getUnitSv(unit)unit. Asserts if there is none.siblings()unitSiblingId(unit)unit (<id>_<unit>).Setting the value of any sibling converts and sets the value of all the other siblings.
isNumberNot set on the unitOutput parent. It is true for each unit sibling numericOutput.
A Boolean.
isUnitAlways true for unitOutput.
A Boolean.
isUnitParentAlways true for unitOutput.
A Boolean.
unitClassThe unitClass string for the unitSelector that controls which unit sibling is current for this state variable.
A String.
fmtGetter that returns the current unit sibling's fmt. There are no min or max properties on a numericOutput.
classNameGets/sets the className of the current sibling; setting applies to all siblings.
unitSiblingsA Map from unit to sibling state variable.
<span> with the value attribute set according to the current unit sibling value.<span> contents will be synchronized with the current unit sibling value.<span> element will have a className that contains 'svIo_numOutput' (the current sibling's class; there is no svIo_unitOutput class).