3.5 KiB
Trait
Properties
idString Trait id, eg.my-trait-id.typeString Trait type, defines how the trait should be rendered. Possible values:text(default),number,select,checkbox,color,buttonlabelString The trait label to show for the rendered trait.nameString The name of the trait used as a key for the attribute/property. By default, the name is used as attribute name or property in casechangePropin enabled.defaultString Default value to use in case the value is not defined on the component.placeholderString Placeholder to show inside the default input (if the UI type allows it).categoryString? Trait category.changePropBoolean Iftrue, the trait value is applied on the component property, otherwise, on component attributes.
getId
Get the trait id.
Returns String
getType
Get the trait type.
Returns String
getName
Get the trait name.
Returns String
getLabel
Get the trait label.
Parameters
-
optsObject Options. (optional, default{})opts.localeBoolean Use the locale string from i18n module. (optional, defaulttrue)
Returns String
getValue
Get the trait value.
The value is taken from component attributes by default or from properties if the trait has the changeProp enabled.
Parameters
-
optsObject Options. (optional, default{})opts.useTypeBoolean Get the value based on type (eg. the checkbox will always return a boolean). (optional, defaultfalse)
Returns any
setValue
Update the trait value.
The value is applied on component attributes by default or on properties if the trait has the changeProp enabled.
Parameters
-
valueany Value of the trait. -
optsObject Options. (optional, default{})opts.partialBoolean? Iftruethe update won't be considered complete (not stored in UndoManager).
getDefault
Get default value.
getOptions
Get trait options.
Returns Array<TraitOption>
getOption
Get current selected option or by id.
Parameters
idString? Option id.
Returns (Object | null)
getOptionId
Get the option id from the option object.
Parameters
optionObject Option object
Returns String Option id
getOptionLabel
Get option label.
Parameters
-
optsObject Options (optional, default{})opts.localeBoolean Use the locale string from i18n module (optional, defaulttrue)
Returns String Option label
getCategoryLabel
Get category label.
Parameters
-
optsObject Options. (optional, default{})opts.localeBoolean Use the locale string from i18n module. (optional, defaulttrue)
Returns String
runCommand
Run the trait command (used on the button trait type).