Class: AbstractComponent

AbstractComponent

The base class for all view components.


<abstract> new AbstractComponent(props, context)

Initializes the component.

Parameters:
Name Type Description
props Object.<string, *>

The component properties.

context Object.<string, *>

The component context.

Members


<nullable> _utils :Object.<string, *>

The view utilities, initialized lazily upon first use from either the context, or the component's props.

Type:
  • Object.<string, *>

utils

Returns the utilities for the view components. The returned value is the value bound to the $Utils object container constant.

Methods


cssClasses(classRules, includeComponentClassName)

Generate a string of CSS classes from the properties of the passed-in object that resolve to true.

Parameters:
Name 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
Returns:

String of CSS classes that had their property resolved to true.

Type
string
Examples
this.cssClasses('my-class my-class-modificator', true);
this.cssClasses({
           'my-class': true,
           'my-class-modificator': this.props.modificator
       }, true);

fire(eventName [, data])

Creates and sends a new IMA.js DOM custom event from this component.

Parameters:
Name Type Argument Default Description
eventName string

The name of the event.

data * <optional>
null

Data to send within the event.


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.

Parameters:
Name Type Argument Description
name string

The route name.

params Object.<string, (number|string)> <optional>

Router parameters and extraneous parameters to add to the URL as a query string.

Returns:

The generated URL.

Type
string

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.

Parameters:
Name 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.


localize(key [, params])

Returns the localized phrase identified by the specified key. The placeholders in the localization phrase will be replaced by the provided values.

Parameters:
Name Type Argument Description
key string

Localization key.

params Object.<string, (number|string)> <optional>

Values for replacing the placeholders in the localization phrase.

Returns:

Localized phrase.

Type
string

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.

Parameters:
Name 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.