import { InputControl } from '@/containers/dynamicControllerSetting/InputControl' import { CheckboxControl } from '@/containers/dynamicControllerSetting/CheckboxControl' import { DropdownControl } from '@/containers/dynamicControllerSetting/DropdownControl' import { TextareaControl } from '@/containers/dynamicControllerSetting/TextareaControl' import { SliderControl } from '@/containers/dynamicControllerSetting/SliderControl' // Dynamic controller component that renders the appropriate control based on controller_type type DynamicControllerProps = { key?: string title?: string className?: string description?: string readonly?: boolean controllerType: | 'input' | 'checkbox' | 'dropdown' | 'textarea' | 'slider' | string controllerProps: { value?: string | boolean | number placeholder?: string type?: string options?: Array<{ value: number | string; name: string }> input_actions?: string[] rows?: number min?: number max?: number step?: number recommended?: string } onChange: (value: string | boolean | number) => void } export function DynamicControllerSetting({ className, controllerType, controllerProps, onChange, }: DynamicControllerProps) { if (controllerType === 'input') { return ( onChange(newValue)} /> ) } else if (controllerType === 'checkbox') { return ( onChange(newValue)} /> ) } else if (controllerType === 'dropdown') { return ( onChange(newValue)} /> ) } else if (controllerType === 'textarea') { return ( onChange(newValue)} /> ) } else if (controllerType === 'slider') { return ( newValue && onChange(newValue[0])} /> ) } // Default to checkbox if controller type is not recognized return ( onChange(newValue)} /> ) }