Skip to main content

Introducing Workflow Engine, try for FREE workflowengine.io.

Class: ComponentData

@react-form-builder/core.ComponentData

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

Implements

Constructors

constructor

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

Constructor.

Parameters

NameTypeDescription
componentStoreComponentStorethe component settings.
modelModel<any>the component metadata for the form viewer.
fieldundefined | Fieldthe field with the form data.
childFactory(componentStore: ComponentStore) => ComponentDatathe factory function that creates ComponentData instance.
formValidators?FormValidatorsthe array of functions that validate the form data.

Properties

children

children: ComponentData[] = []

The child nodes in the component data tree.


field

Optional Readonly 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

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

NameTypeDescription
keystringthe 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

NameTypeDescription
insertedComponentDatathe node to insert.

Returns

void


insertBeforeMe

insertBeforeMe(inserted): void

Inserts the given node before this node.

Parameters

NameTypeDescription
insertedComponentDatathe node to insert.

Returns

void


reset

reset(): void

Sets the form to its default value.

Returns

void

Implementation of

IFormData.reset


setAllErrors

setAllErrors(message?): void

Sets the validation error message for all form data fields.

Parameters

NameTypeDescription
message?stringthe validation error message.

Returns

void

Implementation of

IFormData.setAllErrors


setParent

setParent(newParent): void

Sets the new parent for this node.

Parameters

NameTypeDescription
newParentComponentDatathe new parent.

Returns

void


unifyKeys

unifyKeys(root): Map<string, string>

Assigns unique keys to the items in the tree.

Parameters

NameTypeDescription
rootComponentDatathe 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>

Implementation of

IFormData.validate