Base
Used by base renderer to build the node tree
BaseAttributesSchema
The base attributes are resolved in following sequence from the table below. All values could be actual value or resolvable function. The function will take current node as first parameter.
| Name | Type | Description |
|---|---|---|
_tags | [ string ] | Names of the shape's React component. It will be used to construct other attributes if those are not provided explicitly. |
_type | string | Type of the component. Default to first of the tags value if not provided. Primarily used for Infrastructure as Code |
_title | string | Displayed title of the shape |
_name | string | Name of the shape for identification. |
_version | string | Version of the shape if applicable. Parent version are passed down to children automatically. |
_id | string | An unique identifier for the component. |
Base Attributes Example
Given example below,
import { Shape } from "@dinghy/base-components";
const TagLevel1 = (props: any) => <Shape {...props} />;
const TagLevel2 = (props: any) => <TagLevel1 {...props} />;
export default function App() {
return (
<Shape _title="Tags example">
<TagLevel2 />
</Shape>
);
}
The TagLevel2 component has
_tags=[TagLevel2, TagLevel1, Shape]_type=tag_level2_title=Tag Level2_name=tag-level2_id=taglevel2
Fallback Resolution
_title, _name, and _id will fallback to their respective title, name, and id attributes if they are not provided explicitly.
The same resolution logic applies reversely as well e.g. name will fallback to _name if not provided explicitly.
LifecycleSchema
Events been invoked during lifecycle of the node
| Name | Type | Description |
|---|---|---|
_afterDataBind | function(node) | Invoked after all attributes resolved to the node tree |
_beforeGenerate | function(node) | Invoked before the node is generated to target format |