@wasl-flow/vanilla
v1.0.1
Published
Vanilla DOM renderer for Wasl Flow
Maintainers
Readme
@wasl-flow/vanilla
Vanilla DOM renderer for wasl-flow. It renders content models into DOM nodes.
Install
npm install wasl-flow @wasl-flow/vanilla
# or
pnpm add wasl-flow @wasl-flow/vanillaQuick Start
import { VanillaRenderer } from '@wasl-flow/vanilla';
type ButtonModel = { type: 'button'; text: string };
const renderer = new VanillaRenderer({ showValidationErrors: true });
renderer.register({
type: 'button',
parse: model => ({ data: model as ButtonModel }),
factory: ({ model }) => {
const button = document.createElement('button');
button.textContent = model.text;
return button;
},
});
const node = renderer.render({ type: 'button', text: 'Click me' }) as Node;
document.body.appendChild(node);Renderer Behavior
renderreturns a DOMNode(or aDocumentFragmentwhen aggregating).renderArrayaggregates outputs into aDocumentFragmentand filters out non-node values.- Default
nullValueis an emptyDocumentFragmentfor DOM interoperability. - When
showValidationErrorsis enabled, errors are rendered as styled DOM elements with sanitized details. - In non-DOM environments, error rendering falls back to a lightweight element-like object.
Configuration
All RendererConfiguration options from the core package are supported. This renderer only changes the default nullValue to an empty DocumentFragment.
For details on registration, parsing, and safety limits, see the core package README.
