import React from 'react'; import { ButtonComponent } from './ButtonComponent'; import { NumberComponent } from './NumberComponent'; import { SliderComponent } from './SliderComponent'; import { EnumComponent } from './EnumComponent'; import { MethodComponent } from './MethodComponent'; import { AsyncMethodComponent } from './AsyncMethodComponent'; import { StringComponent } from './StringComponent'; import { ListComponent } from './ListComponent'; import { DataServiceComponent, DataServiceJSON } from './DataServiceComponent'; import { ImageComponent } from './ImageComponent'; import { ColouredEnumComponent } from './ColouredEnumComponent'; import { LevelName } from './NotificationsComponent'; type AttributeType = | 'str' | 'bool' | 'float' | 'int' | 'Quantity' | 'list' | 'method' | 'DataService' | 'Enum' | 'NumberSlider' | 'Image' | 'ColouredEnum'; type ValueType = boolean | string | number | object; export interface Attribute { type: AttributeType; value?: ValueType | ValueType[]; readonly: boolean; doc?: string | null; parameters?: Record; async?: boolean; enum?: Record; } type GenericComponentProps = { attribute: Attribute; name: string; parentPath: string; isInstantUpdate: boolean; addNotification: (message: string, levelname?: LevelName) => void; }; export const GenericComponent = React.memo( ({ attribute, name, parentPath, isInstantUpdate, addNotification }: GenericComponentProps) => { if (attribute.type === 'bool') { return ( ); } else if (attribute.type === 'float' || attribute.type === 'int') { return ( ); } else if (attribute.type === 'Quantity') { return ( ); } else if (attribute.type === 'NumberSlider') { return ( ); } else if (attribute.type === 'Enum') { return ( ); } else if (attribute.type === 'method') { if (!attribute.async) { return ( ); } else { return ( } addNotification={addNotification} /> ); } } else if (attribute.type === 'str') { return ( ); } else if (attribute.type === 'DataService') { return ( ); } else if (attribute.type === 'list') { return ( ); } else if (attribute.type === 'Image') { return ( ); } else if (attribute.type === 'ColouredEnum') { console.log(attribute); return ( ); } else { return
{name}
; } } );