Doc Flux allows for creating a structure from a React style component system.
Given a parser and DOM components, you can generate a DOM and apply transforms
for the DOM. This can virtually be used to render anything from a PDF to a JSON
document.
To use with JSX, simply import this package into the file and set the jsx
with a comment @jsx DocFlux.createElement
Methods
-
<static> createElement(JSXComponent)
-
Transforms JSX into parsable elements
Parameters:
Name Type Description JSXComponent
Component | string A String DOM name or Component
Returns:
The component to render with props
- Type
- object
-
<static> render(component, parser)
-
Generates a DOM
Parameters:
Name Type Description component
object An object generated from
createElement
parser
object An object that contains a map between DOM nodes to DOM components
Returns:
The DOM (array if parent node is a div)
- Type
- array | object
-
<static> transform(fluxDOM, builder)
-
Transforms a DOM into a Doc
Parameters:
Name Type Description fluxDOM
array | object The DOM returned from
render
builder
object A document builder, could be a class, an object, or even null
Returns:
The builder object after transformation.
- Type
- object