import * as React from 'react'; import { useCallback } from 'react'; import CommandService from '@joplin/lib/services/CommandService'; import { _ } from '@joplin/lib/locale'; import StyledInput from '../../style/StyledInput'; interface Props { inputRef?: React.Ref; value: string; onChange(event: OnChangeEvent): void; onFocus?: React.FocusEventHandler; onBlur?: React.FocusEventHandler; onKeyDown?: React.KeyboardEventHandler; onSearchButtonClick: ()=> void; searchStarted: boolean; placeholder?: string; disabled?: boolean; inputClassName?: string; 'aria-controls'?: string; iconButtonTabIndex?: number; } export interface OnChangeEvent { value: string; } export default function(props: Props) { const iconName = !props.searchStarted ? CommandService.instance().iconName('search') : 'fa fa-times'; const iconLabel = !props.searchStarted ? _('Search') : _('Clear search'); const onChange = useCallback((event: React.ChangeEvent) => { props.onChange({ value: event.currentTarget.value }); }, [props.onChange]); const fieldClassName = ['field']; if (props.inputClassName) fieldClassName.push(props.inputClassName); return (
); }