import * as React from 'react'; import { FormControl, FormGroup } from 'react-bootstrap'; import { Icon } from 'react-fa'; import { Observable } from 'rxjs'; import { BaseView, BaseViewProps } from '../../React'; import { BindableInput } from '../BindableInput/BindableInput'; import { CommandButton } from '../CommandButton/CommandButton'; import { SearchViewModel } from './SearchViewModel'; const EnterKey = 13; export interface SearchProps { placeholder?: string; } export interface SearchViewProps extends SearchProps, BaseViewProps {} export class SearchView extends BaseView { public static displayName = 'SearchView'; static defaultProps: Partial = { placeholder: 'Search', }; updateOn(viewModel: Readonly) { return [viewModel.searchPending.changed]; } render() { const { className, rest } = this.restProps(x => { const { placeholder } = x; return { placeholder }; }); return (
x.search, undefined, (e: React.KeyboardEvent) => e.keyCode === EnterKey, )} /> {this.wxr.renderConditional( this.viewModel.searchPending, () => ( ), () => this.wxr.renderConditional( String.isNullOrEmpty(this.viewModel.filter.value) === false, () => ( ), ), )}
); } }