import TemplateWidgetFactory from "../Factory/TemplateWidgetFactory"; /* eslint-disable @typescript-eslint/no-explicit-any */ const FactoryRenderer = (props: any) => { const standardWidgets = TemplateWidgetFactory.getStandardFactory()?.getWidgets(); const customWidgets = TemplateWidgetFactory.getCustomFactory()?.getWidgets(); const templateWidgets = TemplateWidgetFactory.getTemplateWidgets(); const WidgetComponent = customWidgets?.get?.(props.widgetType) ?? templateWidgets?.get?.(props.widgetType) ?? standardWidgets?.get?.(props.widgetType); // The previous fallback was `?? <>` — a React *element*, which then became // the type argument of createElement and threw "Element type is invalid". // An unresolved widgetType must render nothing, not crash the screen; the warn // keeps a misconfigured schema diagnosable. if (!WidgetComponent) { console.warn(`[vs-template] No widget registered for type "${props.widgetType}"`); return null; } return ; }; export default FactoryRenderer;