Overview
The@tempad-dev/plugins package exports several helper functions that make it easier to work with design nodes and build component trees:
h()- Hyperscript helper for building DevComponent treesraw()- Create raw markup nodes- Query helpers - Find and filter design nodes (findChild, findChildren, findOne, findAll, queryAll, queryOne)
h()
Hyperscript helper to composeDevComponent trees from plugin code with a clean JSX-like syntax.
Signature
Parameters
Component name or tag to render
Optional props object with component properties
Optional children - can be a single child, an array of children, or a string
Returns
A dev component tree node ready for serialization
Examples
Simple text node:raw()
Helper to create a raw markup node. This allows you to inject HTML or other markup directly into the component tree.Signature
Parameters
The raw markup content to inject
Optional properties to inject into the markup
Returns
A dev component with name
__tempad_raw__ containing the raw contentExample
The
RAW_TAG_NAME constant ('__tempad_raw__') is exported for checking if a component is a raw node.Query Helpers
These functions help you find and filter design nodes within a component tree. All query helpers accept aNodeQuery parameter which can be:
- A property-based query:
{ type: 'TEXT', name: /title/i } - A predicate function:
(node) => node.visible && node.name.startsWith('btn')
findChild()
Find the first direct child that matches the query.Signature
Parameters
Parent container to search
Predicate or property query description
Returns
The first matching direct child ornull when none found.
Example
findChildren()
Find all direct children that match the query.Signature
Parameters
Parent container to search
Predicate or property query description
Returns
An array of matching direct children.Example
findOne()
Depth-first search for the first node that matches the query (searches recursively through all descendants).Signature
Parameters
Root container to search recursively
Predicate or property query description
Returns
The first nested node that matches ornull.
Example
findAll()
Depth-first search returning every node that matches the query (searches recursively through all descendants).Signature
Parameters
Root container to search recursively
Predicate or property query description
Returns
All nodes within the subtree that satisfy the query.Example
queryAll()
Execute a sequence of queries, returning the final node collection. This is useful for chaining multiple query operations.Signature
Parameters
Root container to start the pipeline from
Ordered list describing how each query step should behaveEach query object includes a
query field specifying the query type:'child'- Use findChild for this step'children'- Use findChildren for this step'one'- Use findOne for this step'all'- Use findAll for this step
Returns
The collection of nodes produced by the final query step.Example
queryOne()
Execute a sequence of queries and return only the first match.Signature
Parameters
Root container to start the pipeline from
Ordered list describing how each query step should behave
Returns
The first node produced by the query sequence ornull.
Example
NodeQuery Type
TheNodeQuery type accepts either a property-based query or a predicate function:
Property-Based Queries
Query by node properties with support for:- Exact match:
{ type: 'TEXT' } - Array of options:
{ name: ['Button', 'Submit'] } - Regular expression:
{ name: /button/i }
Predicate Functions
Use a custom function for complex matching logic:See Also
- Transform Hooks - Learn about plugin transform hooks
- Types Reference - Complete type definitions
- Creating Plugins - Plugin development guide