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
Properties
children
children:
ComponentData
[] =[]
The child nodes in the component data tree.
dataRootProvider?
optional
dataRootProvider:IDataRootProvider
Specifies the root component for the data in the component tree. Internal use only.
field?
readonly
optional
field:Field
The field with the form data.
id
readonly
id:string
The unique identifier.
index?
optional
index:number
Specifies the index in the array if the component is in the component array. This is not an index in a parent-child structure.
Implementation of
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 Signature
get data():
Record
<string
,unknown
>
Returns
Record
<string
, unknown
>
the Record with all the form data.
Implementation of
errors
Get Signature
get errors():
Record
<string
,unknown
>
Returns
Record
<string
, unknown
>
the Record with all validation error messages.
Implementation of
events
Get Signature
get events():
ComponentDataEvents
Returns
the ComponentDataEvents object.
fields
Get Signature
get fields():
Map
<string
,Field
>
Returns
Map
<string
, Field
>
all the fields in the tree as a map. Starts from this node.
fluentData
Get Signature
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.
Implementation of
hasErrors
Get Signature
get hasErrors():
boolean
true if the form contains errors, otherwise false.
Returns
boolean
Implementation of
isRoot
Get Signature
get isRoot():
boolean
Returns
boolean
true if it has no parent ComponentData, false otherwise.
isValidating
Get Signature
get isValidating():
boolean
If true, then validation is in progress.
Returns
boolean
Implementation of
key
Get Signature
get key():
string
Returns
string
the key of this node (same as the key of the ComponentStore).
nearestIndex
Get Signature
get nearestIndex():
undefined
|number
Returns
undefined
| number
the index in the array if the component is in the component array (looks for the nearest index in the component hierarchy).
parentData
Get Signature
get parentData():
undefined
|Record
<string
,unknown
>
Returns
undefined
| Record
<string
, unknown
>
the object to read and modify parent data (available for array elements).
Implementation of
root
Get Signature
get root():
ComponentData
Returns
the root of the component tree.
rootData
Get Signature
get rootData():
Record
<string
,unknown
>
Returns
Record
<string
, unknown
>
the object to read and modify root form data.
Implementation of
state
Get Signature
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
Methods
clear()
clear():
void
Clears the form data.
Returns
void
Inherit Doc
Implementation of
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
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
setAllErrors()
setAllErrors(
message
?):void
Sets the validation error message for all form data fields.
Parameters
• message?: string
Returns
void
Inherit Doc
Implementation of
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
>