Class: 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
,childFactory
,getFormValidationResult?
):ComponentData
Constructor.
Parameters
componentStore
the component settings.
model
the component metadata for the form viewer.
childFactory
(componentStore
) => ComponentData
the factory function that creates ComponentData instance.
getFormValidationResult?
() => Promise
<Record
<string
, string
>[]>
the function that returns a form validation results.
Returns
ComponentData
Properties
children
children:
ComponentData
[] =[]
The child nodes in the component data tree.
componentState
componentState:
IComponentState
=defaultComponentState
The state of the component. **Internal use only.
dataRootProvider?
optional
dataRootProvider:IDataRootProvider
Specifies the root component for the data in the component tree. Internal use only.
field?
optional
field:Field
The field with the form data.
getInitialData()?
optional
getInitialData: () =>unknown
The function for getting initial data.
Returns
unknown
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
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
allChildren
Get Signature
get allChildren():
ComponentData
[]
Returns
ComponentData
[]
an array of all children components.
allComponentFields
Get Signature
get allComponentFields():
ComponentField
[]
Returns
an array of all component fields, including non-unique data keys.
allFields
Get Signature
get allFields():
Field
[]
Returns
Field
[]
an array of all fields, including non-unique data keys.
data
Get Signature
get data():
Record
<string
,unknown
>
Returns
Record
<string
, unknown
>
the Record with all the form data.
Implementation of
dataRoot
Get Signature
get dataRoot():
ComponentData
Returns
ComponentData
the root component for the data in the component tree.
errors
Get Signature
get errors():
Record
<string
,unknown
>
Returns
Record
<string
, unknown
>
the Record with all validation error messages.
Set Signature
set errors(
errors
):void
Sets the form error messages.
Parameters
errors
Record
<string
, unknown
>
Returns
void
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
initialData
Get Signature
get initialData():
unknown
Returns
unknown
the initial data.
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
ComponentData
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
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
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
Returns
void
Inherit Doc
Implementation of
setAllErrors()
setAllErrors(
message?
):void
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.
unifyTree()
unifyTree():
void
Assigns unique keys to the items in the tree.
Returns
void
validate()
validate():
Promise
<ValidationMessages
>
Returns
Promise
<ValidationMessages
>
the ValidationMessages validation results.