import _ from 'lodash' import { observer } from 'mobx-react' import React, { ChangeEvent } from 'react' import { Editor } from './file-model' import { Select, SelectItem } from '../select' interface Props { chosen?: Partial editors: Editor[] onSelect: (editor: Editor) => any onUpdateOtherPath: (path: string) => any } const EditorPicker = observer(({ chosen = {}, editors, onSelect, onUpdateOtherPath }: Props) => { const editorOptions = _.reject(editors, { isOther: true }) const otherOption = _.find(editors, { isOther: true }) const onChange = (id: string) => { const editor = _.find(editors, { id }) editor && onSelect(editor) } const updateOtherPath = (event: ChangeEvent) => { onUpdateOtherPath(_.trim(event.target.value || '')) } const otherInput = ( ) return ( ) }) export default EditorPicker