import { FieldComponent } from '../../form/types'
import { ObjectListField } from './ObjectListField'
import { RequiredConnectionListField } from './RequiredConnectionListField'
import { SimpleListField } from './SimpleListField'

export const ListField: FieldComponent<any[]> = (props) => {
  switch (props.variable.config.metadata?.input?.type) {
    case 'object': return <ObjectListField {...props} />
    case 'int': return <SimpleListField {...props} type="int" pattern={props.variable.config.metadata?.input?.pattern} />
    case 'text': return <SimpleListField {...props} type="text" pattern={props.variable.config.metadata?.input?.pattern} />
    case 'required-connection': return <RequiredConnectionListField {...props} />
  }
  return undefined
}
