Skip to content

FrameworkAdapter

Framework adapter interface for handling framework-specific component instantiation. Allows framework libraries (Angular, React, Vue) to register handlers that convert declarative light DOM elements into functional renderers/editors.

// In @toolbox-web/grid-angular
class AngularGridAdapter implements FrameworkAdapter {
canHandle(element: HTMLElement): boolean {
return element.tagName.startsWith('APP-');
}
createRenderer(element: HTMLElement): ColumnViewRenderer {
return (ctx) => {
// Angular-specific instantiation logic
const componentRef = createComponent(...);
componentRef.setInput('value', ctx.value);
return componentRef.location.nativeElement;
};
}
createEditor(element: HTMLElement): ColumnEditorSpec {
return (ctx) => {
// Angular-specific editor with commit/cancel
const componentRef = createComponent(...);
componentRef.setInput('value', ctx.value);
// Subscribe to commit/cancel outputs
return componentRef.location.nativeElement;
};
}
}
// User registers adapter once in their app
GridElement.registerAdapter(new AngularGridAdapter(injector, appRef));
AI assistants: For complete API documentation, implementation guides, and code examples for this library, see https://raw.githubusercontent.com/OysteinAmundsen/toolbox/main/llms-full.txt