React API Reference
BuilderEntityInstance
This interface describes the properties of a builder entity instance, which is usually injected as a prop into builder entities components.
Reference
BuilderEntityInstance<TEntity>
import { type BuilderEntityInstance } from "@coltorapps/builder-react";
import { textFieldEntity } from "./text-field-entity";
type BuilderTextFieldInstance = BuilderEntityInstance<typeof textFieldEntity>;
Properties
The BuilderEntityInstance
interfaces has the following properties:
Prop | Type | Description |
---|---|---|
id | string | The unique identifier of the entity. |
type | string | The type identifier of the entity. Corresponds to the key of the entity definition in the builder definition. |
children | array optional | Optional array of child entity IDs. |
parentId | string optional | Optional ID of the parent entity. If undefined, the entity is considered a root-level entity. |
attributes | object | A record of all attribute instances for the entity, keyed by attribute name. |
metadata | unknown | Your custom metadata associated with the entity. |
setParent | function | Sets the parent of the entity by parentId . Optionally accepts an index to specify the position among siblings. |
unsetParent | function | Unsets an entity's parent and moves it to the root. Optionally accepts an index to target a specific child slot. |
setIndex | function | Sets the index of the entity among its siblings. |
setAttribute | function | Updates a single attribute value on the entity by name. |
delete | function | Deletes the entity from the builder store. |
clone | function | Clones the entity, creating a new one with the same attributes and children. |
validateAttribute | function | Validates a specific attribute and returns its validated value. |
validateAttributes | function | Validates all attributes of the entity. |
resetAttributeError | function | Clears the validation error for a specific attribute. |
resetAttributesErrors | function | Clears all attribute validation errors for the entity. |
setAttributesErrors | function | Sets multiple attribute validation errors at once for the entity. |
setAttributeError | function | Sets a validation error for a specific attribute. |
getAttributesValues | function | Returns the current values of all attributes for the entity. |
getAttributesErrors | function | Returns the current validation errors for the entity's attributes. |
subscribeToAttributesValues | function | Subscribes to attribute value changes. Returns an unsubscribe function. Optionally accepts a comparator for change detection. |
subscribeToAttributesErrors | function | Subscribes to attribute error changes. Returns an unsubscribe function. Optionally accepts a comparator for change detection. |