Usage
Signature:
interface CSwitchElement
Typescript Import Format
//To typecheck the element APIs, import as below.
import { CSwitchElement } from "oj-c/switch";
//For the transpiled javascript to load the element's module, import as below
import "oj-c/switch";
For additional information visit:
Note: Application logic should not interact with the component's properties or invoke its methods until the BusyContext indicates that the component is ready for interaction.
Global Attributes
Note: In addition to the component's custom attributes, the following global attributes are also supported by this component (note the differences in data binding syntax between component and global attributes described here)
-
aria-describedby :string
-
Identifies the element (or elements) that describes the switch.
Names
Item Name Property aria-describedbyProperty change event aria-describedbyChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-aria-describedby-changed -
id :string
-
Unique identifier for the component.
Names
Item Name Property idProperty change event idChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-id-changed
Attributes
-
column-span :number
-
Specifies how many columns this component should span. This only takes effect when this component is a child of a form layout that has direction 'row'.
- Default Value:
1
Names
Item Name Property columnSpanProperty change event columnSpanChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-column-span-changed -
container-readonly :boolean
-
Specifies whether an ancestor container, like oj-c-form-layout, is readonly.
Names
Item Name Property containerReadonlyProperty change event containerReadonlyChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-container-readonly-changed -
disabled :boolean
-
Whether the component is disabled.
- Default Value:
false
Names
Item Name Property disabledProperty change event disabledChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-disabled-changed -
display-options :oj-c.Switch.DisplayOptionsProps
-
Display options for auxiliary content that determines whether or not it should be displayed.
Names
Item Name Property displayOptionsProperty change event displayOptionsChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-display-options-changed -
help :oj-c.Switch.Help
-
Form component help information.
Names
Item Name Property helpProperty change event helpChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-help-changed -
help-hints :oj-c.Switch.HelpHints
-
The helpHints object contains a definition property, sourceText property, and a source property.
Names
Item Name Property helpHintsProperty change event helpHintsChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-help-hints-changed -
label-edge :"inside"|"none"|"start"|"top"
-
Specifies how the label of the component is positioned when the label-hint attribute is set on the component.
Supported Values:
Value Description insideThe label will be placed on top of the switch, but is smaller than 'top' option. noneThe switch will not create a label, but instead set the aria-label property on the switch. startThe label will be placed before the start of the switch. topThe label will be placed on top of the switch. Names
Item Name Property labelEdgeProperty change event labelEdgeChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-label-edge-changed -
label-hint* :string
-
Represents a hint for rendering a label on the component. Used in combination with label-edge.
Names
Item Name Property labelHintProperty change event labelHintChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-label-hint-changed -
label-start-width :(number|string)
-
The width of the label when labelEdge is 'start'.
Names
Item Name Property labelStartWidthProperty change event labelStartWidthChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-label-start-width-changed -
label-wrapping :"truncate"|"wrap"
-
Should the labels wrap or truncate when there is not enough available space.
- Deprecated:
-
Since Description 21.0.0Label truncation for 'start' and 'top' aligned labels is no longer recommended by the Redwood Design System. The default for labelWrapping was 'wrap' and that is now the only suggested pattern by UX design for 'start' and 'top' aligned labels. 'inside' aligned labels are always truncated per UX design and are not affected by this property's value.
Supported Values:
Value Description truncateLabel will truncate if needed. wrapLabel will wrap if needed. Names
Item Name Property labelWrappingProperty change event labelWrappingChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-label-wrapping-changed -
messages-custom :Array.<oj-c.Switch.ComponentMessageItem>
-
List of messages an app would add to the component when it has business/custom validation errors that it wants the component to show. This allows the app to perform further validation before sending data to the server. When this option is set the message shows to the user right away. To clear the custom message, set
messagesCustomback to an empty array.
See the Validation and Messaging section for details on when the component clears
messagesCustom; for example, when the value changes.- Default Value:
[]
- Supports writeback:
true
Names
Item Name Property messagesCustomProperty change event messagesCustomChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-messages-custom-changed -
readonly :boolean
-
Whether the component is readonly.
Names
Item Name Property readonlyProperty change event readonlyChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-readonly-changed -
readonly-user-assistance-shown :"none"|"confirmationAndInfoMessages"
-
Specifies which user assistance types should be shown when the component is readonly.
- Default Value:
'none'
Names
Item Name Property readonlyUserAssistanceShownProperty change event readonlyUserAssistanceShownChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-readonly-user-assistance-shown-changed -
user-assistance-density :"reflow"|"efficient"|"compact"
-
Specifies the density of the form component's user assistance presentation.
If the property value is not set either directly on the component or inherited from a parent form layout, then the property is treated as if its value were "reflow".
Supported Values:
Value Description reflowMessages, help, and hints are all shown inline under the field with no reserved space. Layout will reflow when text is displayed. efficientMessages, help, and hints are all shown inline under the field with reserved space. compactMessages, help, and hints are all shown inline under the field with reserved space. Names
Item Name Property userAssistanceDensityProperty change event userAssistanceDensityChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-user-assistance-density-changed -
(readonly) valid :"valid"|"pending"|"invalidHidden"|"invalidShown"
-
The current valid state of the component. It is evaluated on initial render. Since oj-c-switch does not support converters, validators, or the
requiredproperty, the valid state is re-evaluated:- when
messagesCustomis updated - when the
valuechanges (user interaction or programmatic intervention), since the component clearsmessagesCustom - when
reset()is called
Note: New valid states may be added to the list of valid values in future releases. Any new values will start with "invalid" if it is an invalid state, "pending" if it is pending state, and "valid" if it is a valid state.
- Supports writeback:
true
Supported Values:
Value Description validThe component is valid pendingThe component is waiting for the validation state to be determined. The 'pending' state is set at the start of the validation process. invalidHiddenThe component has invalid messages hidden and no invalid messages showing. An invalid message is one with severity 'error'. invalidShownThe component has invalid messages showing. An invalid message is one with severity 'error'. Names
Item Name Property validProperty change event validChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-valid-changed - when
-
value :boolean
-
The boolean state of the switch component.
When the
valueproperty changes due to programmatic intervention, the component clears all messages includingmessagesCustom.- Default Value:
false
- Supports writeback:
true
Names
Item Name Property valueProperty change event valueChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-value-changed
Methods
-
getProperty(property) : {any}
-
Retrieves the value of a property or a subproperty.
Parameters:
Name Type Description propertystring The property name to get. Supports dot notation for subproperty access. Returns:
- Type
- any
-
reset : {void}
-
Resets the component by clearing all messages.
Returns:
- Type
- void
-
setProperties(properties) : {void}
-
Performs a batch set of properties.
Parameters:
Name Type Description propertiesobject An object containing the property and value pairs to set. Returns:
- Type
- void
-
setProperty(property, value) : {void}
-
Sets a property or a single subproperty for complex properties and notifies the component of the change, triggering a corresponding event.
Parameters:
Name Type Description propertystring The property name to set. Supports dot notation for subproperty access. valueany The new value to set the property to. Returns:
- Type
- void
Type Definitions
Documentation-only Types
Note: Type definitions in this section have been provided for documentation purposes and cannot be imported into application code.
-
ComponentMessageItem
-
A type for a single component message
Properties:
Name Type Argument detailstring <optional>
severity"error" | "confirmation" | "info" | "warning" <optional>
summarystring <optional>
-
DisplayOptionsProps
-
Display options for auxiliary content that determines whether or not it should be displayed.
Properties:
Name Type Argument Default Description messages"none" | "display" <optional>
'display' Display options for auxiliary message text. -
Help
-
Form component help information.
Properties:
Name Type Argument Default Description instructionstring <optional>
'' A type of user assistance text. User assistance text is used to provide guidance to help the user understand what data to enter or select. -
HelpHints
-
The helpHints object contains a definition property and a source property.
Properties:
Name Type Argument Default Description definitionstring <optional>
'' A type of user assistance text. User assistance text is used to provide guidance to help the user understand what data to enter or select. help-hints could come from a help system. sourcestring <optional>
'' Help source URL associated with the component. sourceTextstring <optional>
'' Custom text to be used for the source link.