# Trait
# Properties
id
String (opens new window) Trait id, eg.my-trait-id
.type
String (opens new window) Trait type, defines how the trait should be rendered. Possible values:text
(default),number
,select
,checkbox
,color
,button
label
String (opens new window) The trait label to show for the rendered trait.name
String (opens new window) 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 casechangeProp
in enabled.default
String (opens new window) Default value to use in case the value is not defined on the component.placeholder
String (opens new window) Placeholder to show inside the default input (if the UI type allows it).category
String (opens new window)? Trait category.changeProp
Boolean (opens new window) Iftrue
, the trait value is applied on the component property, otherwise, on component attributes.
# getId
Get the trait id.
Returns String (opens new window)
# getType
Get the trait type.
Returns String (opens new window)
# getName
Get the trait name.
Returns String (opens new window)
# getLabel
Get the trait label.
# Parameters
opts
Object (opens new window) Options. (optional, default{}
)opts.locale
Boolean (opens new window) Use the locale string from i18n module. (optional, defaulttrue
)
Returns String (opens new window)
# 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
opts
Object (opens new window) Options. (optional, default{}
)opts.useType
Boolean (opens new window) 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
value
any Value of the trait.opts
Object (opens new window) Options. (optional, default{}
)opts.partial
Boolean (opens new window)? Iftrue
the update won't be considered complete (not stored in UndoManager).
# getDefault
Get default value.
# getOptions
Get trait options.
Returns Array (opens new window)<TraitOption>
# getOption
Get current selected option or by id.
# Parameters
id
String (opens new window)? Option id.
Returns (Object (opens new window) | null)
# getOptionId
Get the option id from the option object.
# Parameters
option
Object (opens new window) Option object
Returns String (opens new window) Option id
# getOptionLabel
Get option label.
# Parameters
id
(String (opens new window) | Object (opens new window)) Option id or the option objectopts
Object (opens new window) Options (optional, default{}
)opts.locale
Boolean (opens new window) Use the locale string from i18n module (optional, defaulttrue
)
Returns String (opens new window) Option label
# getCategoryLabel
Get category label.
# Parameters
opts
Object (opens new window) Options. (optional, default{}
)opts.locale
Boolean (opens new window) Use the locale string from i18n module. (optional, defaulttrue
)
Returns String (opens new window)
# runCommand
Run the trait command (used on the button trait type).