Class: Component

Component(setup, validationRules)

Class representing a component with validation and rendering capabilities.

Constructor

new Component(setup, validationRules)

Creates an instance of Component.

Parameters:
Name Type Description
setup Object

The configuration for the component instance.

validationRules Object

Validation rules for the component.

Source:

Extends

Members

TEMPLATE_STRING :string

Gets the template string content from the source file.

Type:
  • string
Source:

setters :Object

Retrieves setters for component properties.

Type:
  • Object
Source:

Methods

addSubscription(subscription)

Adds a subscription to the component.

Parameters:
Name Type Description
subscription any

The subscription to be added.

Source:
Throws:

When an error occurs while adding the subscription.

Type
Error.Log

array(itemValueopt, childTypeName) → {string}

Converts an array of items to a string based on the child type name.

Parameters:
Name Type Attributes Default Description
itemValue Array <optional>
[]

Array of items to convert to a string.

childTypeName string

The child type name for rendering items.

Source:
Returns:

The rendered string representation of the array.

Type
string

children(children) → {string}

Converts an array of children components to a concatenated string representation.

Parameters:
Name Type Description
children Array

Array of child components to convert.

Source:
Returns:

The concatenated string representation of children components.

Type
string

date(value) → {string}

Converts the given date value to a formatted string.

Parameters:
Name Type Description
value any

The date value to format.

Source:
Returns:

The formatted date string.

Type
string

json(value) → {string}

Converts the given value to a JSON string.

Parameters:
Name Type Description
value any

The value to convert to a JSON string.

Source:
Throws:

When an error occurs during JSON conversion.

Type
Error.Log
Returns:

The JSON string representation of the value.

Type
string

(async) loadDependencies() → {Promise}

Loads dependencies of the component.

Source:
Throws:

When an error occurs while loading dependencies.

Type
Error.Log
Returns:

A promise resolving to the loaded component with dependencies.

Type
Promise

loadSourceFile(pathopt) → {string}

Loads the source file content and updates the output model of the component.

Parameters:
Name Type Attributes Description
path string <optional>

The path to the source file.

Source:
Throws:

When an error occurs while loading the source file.

Type
Error.Log
Returns:

The loaded output model.

Type
string

placeDefault(customSelfopt) → {Object}

Populates the schema fields with their default values if not provided in the input object.

Parameters:
Name Type Attributes Description
customSelf Object <optional>

The custom object to be populated (optional, uses the instance itself by default).

Overrides:
Source:
Returns:
  • The populated object with default values.
Type
Object

printOnScreen(paramsopt)

Prints the rendered component output on the screen based on provided parameters.

Parameters:
Name Type Attributes Description
params Object <optional>

Parameters for printing the component output.

Source:
Throws:

When an error occurs during printing.

Type
Error.Log

renderToString(paramsopt) → {string}

Renders the component to a string based on provided parameters.

Parameters:
Name Type Attributes Description
params Object <optional>

Parameters for rendering the component.

Source:
Throws:

When an error occurs during rendering.

Type
Error.Log
Returns:

The rendered string output of the component.

Type
string

string(valueopt) → {string}

Converts the given value to a string.

Parameters:
Name Type Attributes Default Description
value any <optional>
''

The value to convert to a string.

Source:
Throws:

When an invalid value format is provided.

Type
Error.Log
Returns:

The converted string value.

Type
string

toMarkdown(paramsopt) → {string}

Converts the component's output model to a markdown string based on provided parameters.

Parameters:
Name Type Attributes Description
params Object <optional>

Parameters for converting the output model to markdown.

Source:
Throws:

When an error occurs during markdown conversion.

Type
Error.Log
Returns:

The converted markdown string.

Type
string

updateMerge(data)

Merges and updates component properties with provided data.

Parameters:
Name Type Description
data Object

Data to update the component with.

Source:
Throws:

When an error occurs during data update.

Type
Error.Log

validate(data, returnValidObjopt) → {ValidationError|Object}

Validates the provided data against the schema and returns the validation result.

Parameters:
Name Type Attributes Default Description
data Object

The data to be validated against the schema.

returnValidObj boolean <optional>
false

A flag indicating whether to return the validated object.

Overrides:
Source:
Returns:
  • If returnValidObj is true, returns the validated object. Otherwise, returns the validation error object.
Type
ValidationError | Object