Clusters class
📖 Description
The Clusters
class represents a collection of clusters (sections) of a form definition in the builder. Each cluster in the collection is a Cluster
instance.
🗃️ Fields
🏷️ all
Retrieves all the clusters that are in the collection.
Type
🏷️ branch
Retrieves the parent branch.
Type
🏷️ count
Retrieves the number of clusters in the collection.
Type
number
🏷️ firstItem
Retrieves the first cluster in the collection.
Type
Cluster
| undefined
🏷️ lastItem
Retrieves the last cluster in the collection.
Type
Cluster
| undefined
▶️ Methods
🔧 append
Appends a new cluster to the end of the collection.
Signature
append(): Cluster
Return value
Returns a reference to the new Cluster
instance.
🔧 appendBranch
Appends a new branch cluster to the end of the collection.
Signature
appendBranch(): [Branch, Cluster]
Return value
Returns a reference to the new Branch
and Cluster
instances.
🔧 appendNestedBranch
Appends a new nested branch cluster to the end of the collection.
Signature
appendNestedBranch(): [Branch, Cluster]
Return value
Returns a reference to the new Branch
and Cluster
instances.
🔧 each
Iterates through all clusters in the collection.
Signature
each(fn: (cluster: Cluster) => boolean | void): boolean
Parameters
Name | Type | Optional | Description |
---|---|---|---|
fn | (cluster: Cluster ) => boolean | void | No | Function that is called for each cluster in the collection. If you want to stop the iteration, you can return true from this function to do so. |
Return value
Returns true
if the iteration was stopped (break).
🔧 insert
Inserts a new cluster at the top of the collection.
Signature
insert(): Cluster
Return value
Returns a reference to the new Cluster
instance.
🔧 insertAfter
Inserts a new cluster after the supplied cluster.
Signature
insertAfter(cluster: Cluster): Cluster
Parameters
Name | Type | Optional | Description |
---|---|---|---|
cluster | Cluster | No | Specifies the cluster after which the new cluster is inserted. |
Return value
Returns a reference to the new Cluster
instance.
🔧 insertBefore
Inserts a new cluster before the supplied cluster.
Signature
insertBefore(cluster: Cluster): Cluster
Parameters
Name | Type | Optional | Description |
---|---|---|---|
cluster | Cluster | No | Specifies the cluster for which the new cluster is inserted. |
Return value
Returns a reference to the new Cluster
instance.
🔧 insertBranch
Inserts a new branch cluster at the top of the collection.
Signature
insertBranch(): [Branch, Cluster]
Return value
Returns a reference to the new Branch
and Cluster
instances.
🔧 insertBranchAfter
Inserts a new branch cluster after the supplied cluster.
Signature
insertBranchAfter(cluster: Cluster): [Branch, Cluster]
Parameters
Name | Type | Optional | Description |
---|---|---|---|
cluster | Cluster | No | Specifies the cluster after which the new cluster is inserted. |
Return value
Returns a reference to the new Branch
and Cluster
instances.
🔧 insertBranchBefore
Inserts a new branch cluster before the supplied cluster.
Signature
insertBranchBefore(cluster: Cluster): [Branch, Cluster]
Parameters
Name | Type | Optional | Description |
---|---|---|---|
cluster | Cluster | No | Specifies the cluster after which the new cluster is inserted. |
Return value
Returns a reference to the new Branch
and Cluster
instances.
🔧 insertNestedBranch
Inserts a new nested branch cluster at the top of the collection.
Signature
insertNestedBranch(): [Branch, Cluster]
Return value
Returns a reference to the new Branch
and Cluster
instances.
🔧 insertNestedBranchAfter
Inserts a new nested branch cluster after the supplied cluster.
Signature
insertNestedBranchAfter(cluster: Cluster): [Branch, Cluster]
Parameters
Name | Type | Optional | Description |
---|---|---|---|
cluster | Cluster | No | Specifies the cluster after which the new cluster is inserted. |
Return value
Returns a reference to the new Branch
and Cluster
instances.
🔧 insertNestedBranchBefore
Inserts a new nested branch cluster before the supplied cluster.
Signature
insertNestedBranchBefore(cluster: Cluster): [Branch, Cluster]
Parameters
Name | Type | Optional | Description |
---|---|---|---|
cluster | Cluster | No | Specifies the cluster after which the new cluster is inserted. |
Return value
Returns a reference to the new Branch
and Cluster
instances.
🔧 reverseEach
Iterates through all clusters in the collection in reverse direction (starting with the last cluster).
Signature
reverseEach(fn: (cluster: Cluster) => boolean | void): boolean
Parameters
Name | Type | Optional | Description |
---|---|---|---|
fn | (cluster: Cluster ) => boolean | void | No | Function that is called for each cluster in the collection. If you want to stop the iteration, you can return true from this function to do so. |
Return value
Returns true
if the iteration was stopped (break).
🔧 sort
Sorts the clusters using the supplied compare function.
Signature
sort(fn: (a: Cluster, b: Cluster) => number): boolean
Parameters
Name | Type | Optional | Description |
---|---|---|---|
fn | (a: Cluster , b: Cluster ) => boolean | No | Specifies the compare function. The compare function should return a number according to the following rules: - a is less than b return -1;- a is greater than b return 1;- a is equal to b return 0. |
Return value
Returns true
if the sort invoked a cluster position change.