initAppElement
Parameters
appElementConfig
AppElementClientConfiguration<A>
RequiredConfiguration for an AppElementClient
render
AppElementRenderer<A>
RequiredRegisters a callback that renders an app element based on the data it receives.
Parameters
appElementData
A
RequiredThe data the callback must use to render the app element.
Returns
An array of one or more elements to render as output of an app element.
AppElementRendererOutput
Returns
A client that provides methods for creating and managing the lifecycle of an app element.
addOrUpdateElement
function
This type has been superseded, use addElement
or registerOnElementChange
instead.
If an app element is selected, the element's data is overwritten and the element is re-rendered.
Otherwise, the provided data is used to create a new app element.
Parameters
appElementData
A
RequiredThe data to attach to the app element. Existing data will be overwritten.
placement
Placement
OptionalThe position, dimensions, and rotation of the app element.
top
number
RequiredThe distance from the top edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
left
number
RequiredThe distance from the left edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
width
number
RequiredA width, in pixels.
- The pixels are relative to their container.
Minimum: 0
Maximum: 32767
height
number
RequiredA height, in pixels.
- The pixels are relative to their container.
Minimum: 0
Maximum: 32767
rotation
number
OptionalA rotation, in degrees.
Minimum: -180
Maximum: 180
Returns
Promise<void>
addElement
function
Adds a new app element to the design.
Parameters
opts
AppElementOptions<A>
RequiredThe data and placement of the app element.
data
A
RequiredThe data to attach to the app element.
placement
Placement
OptionalThe position, dimensions, and rotation of the app element.
top
number
RequiredThe distance from the top edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
left
number
RequiredThe distance from the left edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
width
number
RequiredA width, in pixels.
- The pixels are relative to their container.
Minimum: 0
Maximum: 32767
height
number
RequiredA height, in pixels.
- The pixels are relative to their container.
Minimum: 0
Maximum: 32767
rotation
number
OptionalA rotation, in degrees.
Minimum: -180
Maximum: 180
Returns
Promise<void>
registerOnElementChange
function
A callback that runs when:
- the app element is created
- the app element's data is updated
- the user selects an existing app element
Parameters
handler
AppElementChangeHandler<A>
RequiredThe callback to run when the app element changes.
Parameters
appElement
object | undefined
RequiredInformation about the app element that was changed.
data
A
RequiredThe app element data in its most recent state.
version
number
RequiredThe version number of the app.
update
function
RequiredFunction to update the app element data.
Parameters
opts
AppElementOptions<A>
RequiredUsed to add or update an app element to the design. The update function is provided in the AppElementChangeHandler callback (registerOnElementChange).
data
A
RequiredThe data to attach to the app element.
placement
Placement
OptionalThe position, dimensions, and rotation of the app element.
top
number
RequiredThe distance from the top edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
left
number
RequiredThe distance from the left edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
width
number
RequiredA width, in pixels.
- The pixels are relative to their container.
Minimum: 0
Maximum: 32767
height
number
RequiredA height, in pixels.
- The pixels are relative to their container.
Minimum: 0
Maximum: 32767
rotation
number
OptionalA rotation, in degrees.
Minimum: -180
Maximum: 180
Returns
Promise<void>
Returns
void
Returns
void