AbstractComponent
The base class for all view components.
Kind: global abstract class
- AbstractComponent
- new AbstractComponent(props, context)
- ._utils :
Object.<string, \*>
- .utils ⇒
Object.<string, \*>
- .localize(key, [params]) ⇒
string
- .link(name, [params]) ⇒
string
- .cssClasses(classRules, includeComponentClassName) ⇒
string
- .fire(eventName, [data])
- .listen(eventTarget, eventName, listener)
- .unlisten(eventTarget, eventName, listener)
new AbstractComponent(props, context)
Initializes the component.
Param | Type | Description |
---|---|---|
props | Object.<string, \*> |
The component properties. |
context | Object.<string, \*> |
The component context. |
abstractComponent._utils : Object.<string, \*>
The view utilities, initialized lazily upon first use from either the context, or the component’s props.
Kind: instance property of AbstractComponent
abstractComponent.utils ⇒ Object.<string, \*>
Returns the utilities for the view components. The returned value is the
value bound to the $Utils
object container constant.
Kind: instance property of AbstractComponent
Returns: Object.<string, \*>
- The utilities for the view components.
abstractComponent.localize(key, [params]) ⇒ string
Returns the localized phrase identified by the specified key. The placeholders in the localization phrase will be replaced by the provided values.
Kind: instance method of AbstractComponent
Returns: string
- Localized phrase.
Param | Type | Description |
---|---|---|
key | string |
Localization key. |
[params] | Object.<string, (number\|string)> |
Values for replacing the placeholders in the localization phrase. |
abstractComponent.link(name, [params]) ⇒ string
Generates an absolute URL using the provided route name (see the
app/config/routes.js
file). The provided parameters will
replace the placeholders in the route pattern, while the extraneous
parameters will be appended to the generated URL’s query string.
Kind: instance method of AbstractComponent
Returns: string
- The generated URL.
Param | Type | Description |
---|---|---|
name | string |
The route name. |
[params] | Object.<string, (number\|string)> |
Router parameters and extraneous parameters to add to the URL as a query string. |
abstractComponent.cssClasses(classRules, includeComponentClassName) ⇒ string
Generate a string of CSS classes from the properties of the passed-in object that resolve to true.
Kind: instance method of AbstractComponent
Returns: string
- String of CSS classes that had their property resolved
to true
.
Param | Type | Default | Description |
---|---|---|---|
classRules | string | Object.<string, boolean> |
CSS classes in a string separated by whitespace, or a map of CSS class names to boolean values. The CSS class name will be included in the result only if the value is true . |
|
includeComponentClassName | boolean |
false |
Example
this.cssClasses('my-class my-class-modificator', true);
Example
this.cssClasses({
'my-class': true,
'my-class-modificator': this.props.modificator
}, true);
abstractComponent.fire(eventName, [data])
Creates and sends a new IMA.js DOM custom event from this component.
Kind: instance method of AbstractComponent
Param | Type | Description |
---|---|---|
eventName | string |
The name of the event. |
[data] | \* |
Data to send within the event. |
abstractComponent.listen(eventTarget, eventName, listener)
Registers the provided event listener for execution whenever an IMA.js DOM custom event of the specified name occurs at the specified event target.
Kind: instance method of AbstractComponent
Param | Type | Description |
---|---|---|
eventTarget | React.Element | EventTarget |
The react component or event target at which the listener should listen for the event. |
eventName | string |
The name of the event for which to listen. |
listener | function |
The listener for event to register. |
abstractComponent.unlisten(eventTarget, eventName, listener)
Deregisters the provided event listener for an IMA.js DOM custom event of the specified name at the specified event target.
Kind: instance method of AbstractComponent
Param | Type | Description |
---|---|---|
eventTarget | React.Element | EventTarget |
The react component or event target at which the listener should listen for the event. |
eventName | string |
The name of the event for which to listen. |
listener | function |
The listener for event to register. |