Skip to main content

Introducing Workflow Engine, try for FREE workflowengine.io.

Class: ComponentData

This tree of elements contains the data required to display the component. It is synchronized with the ComponentStore tree.

Implements

Constructors

new ComponentData()

new ComponentData(componentStore, model, field, childFactory, formValidators?): ComponentData

Constructor.

Parameters

componentStore: ComponentStore

the component settings.

model: Model<any>

the component metadata for the form viewer.

field: undefined | Field

the field with the form data.

childFactory

the factory function that creates ComponentData instance.

formValidators?: FormValidators

the array of functions that validate the form data.

Returns

ComponentData

Properties

children

children: ComponentData[] = []

The child nodes in the component data tree.


field?

readonly optional field: Field

The field with the form data.


id

readonly id: string

The unique identifier.


model

readonly model: Model<any>

The component metadata.


parent?

optional parent: ComponentData

The parent node in the component data tree.


store

readonly store: ComponentStore

The component settings.


userDefinedProps?

optional userDefinedProps: Record<string, any>

User defined properties of the React component.


validating

validating: boolean = false

If true, then validation is in progress.

Accessors

data

get data(): Record<string, unknown>

Returns

Record<string, unknown>

the Record with all the form data.

Implementation of

IFormData.data


errors

get errors(): Record<string, unknown>

Returns

Record<string, unknown>

the Record with all validation error messages.

Implementation of

IFormData.errors


events

get events(): ComponentDataEvents

Returns

ComponentDataEvents

the ComponentDataEvents object.


fields

get fields(): Map<string, Field>

Returns

Map<string, Field>

all the fields in the tree as a map. Starts from this node.


fluentData

get fluentData(): Record<string, FluentVariable>

Returns

Record<string, FluentVariable>

all the form data that is of the FluentVariable type. Additionally, the keys of the returned object are converted to the snake case.


hasErrors

get hasErrors(): boolean

true if the form contains errors, otherwise false.

Returns

boolean

Implementation of

IFormData.hasErrors


isRoot

get isRoot(): boolean

Returns

boolean

true if it has no parent ComponentData, false otherwise.


isValidating

get isValidating(): boolean

If true, then validation is in progress.

Returns

boolean

Implementation of

IFormData.isValidating


key

get key(): string

Returns

string

the key of this node (same as the key of the ComponentStore).


state

get state(): Record<string, unknown>

Returns

Record<string, unknown>

A user-defined key-value observable storage. Utilize it to store and share any custom data.

Implementation of

IFormData.state

Methods

clear()

clear(): void

Clears the form data.

Returns

void

Inherit Doc

Implementation of

IFormData.clear


delete()

delete(): void

Deletes this node from the tree.

Returns

void


dispose()

dispose(): void

Dispose method that releases resources used by the object. It disposes the field and all the children objects.

Returns

void


findByKey()

findByKey(key): undefined | ComponentData

Find the node with the given key.

Parameters

key: string

the key to find.

Returns

undefined | ComponentData

the node or undefined if not found.


getValidationResult()

getValidationResult(): Promise<undefined>

Returns the validation results without triggering an events and changing the state of the form.

Returns

Promise<undefined>

the ValidationMessages validation results.

Implementation of

IFormData.getValidationResult


insertAfterMe()

insertAfterMe(inserted): void

Inserts the given node after this node.

Parameters

inserted: ComponentData

the node to insert.

Returns

void


insertBeforeMe()

insertBeforeMe(inserted): void

Inserts the given node before this node.

Parameters

inserted: ComponentData

the node to insert.

Returns

void


reset()

reset(): void

Sets the form to its default value.

Returns

void

Inherit Doc

Implementation of

IFormData.reset


setAllErrors()

setAllErrors(message?): void

Sets the validation error message for all form data fields.

Parameters

message?: string

Returns

void

Inherit Doc

Implementation of

IFormData.setAllErrors


setParent()

setParent(newParent): void

Sets the new parent for this node.

Parameters

newParent: ComponentData

the new parent.

Returns

void


unifyKeys()

unifyKeys(root): Map<string, string>

Assigns unique keys to the items in the tree.

Parameters

root: ComponentData

the root of the tree to unify keys. Defaults to the root of this tree.

Returns

Map<string, string>

the map of new keys to old keys.


validate()

validate(): Promise<void>

Validates the data in the form.

Returns

Promise<void>

Inherit Doc

Implementation of

IFormData.validate