UNPKG

@chatterton/angular2-schema-form

Version:

Angular2 Schema Form (DISCLAIMER: it is not related to angular-schema-form)

32 lines (23 loc) 566 B
export class WidgetRegistry { private widgets: { [type: string]: any } = {}; private defaultWidget: any; constructor() { } setDefaultWidget(widget: any) { this.defaultWidget = widget; } getDefaultWidget() { return this.defaultWidget; } hasWidget(type: string) { return this.widgets.hasOwnProperty(type); } register(type: string, widget: any) { this.widgets[type] = widget; } getWidgetType(type: string): any { if (this.hasWidget(type)) { return this.widgets[type]; } return this.defaultWidget; } }