import * as React from 'react'; import TextField from 'material-ui/TextField'; import IconButton from 'material-ui/IconButton'; import IconSearch from 'material-ui/svg-icons/action/search'; import IconClear from 'material-ui/svg-icons/content/clear'; import { ContactType } from '../pim-types'; import AddressBook from '../components/AddressBook'; import { getPalette } from '../App'; class SearchableAddressBook extends React.PureComponent { props: { entries: Array, onItemClick: (contact: ContactType) => void, }; state: { searchQuery: string; }; constructor(props: any) { super(props); this.state = {searchQuery: ''}; this.handleInputChange = this.handleInputChange.bind(this); } handleInputChange(event: React.ChangeEvent) { const name = event.target.name; const value = event.target.value; this.setState({ [name]: value }); } render() { const { entries, ...rest } = this.props; const reg = new RegExp(this.state.searchQuery, 'i'); return ( {this.state.searchQuery && this.setState({'searchQuery': ''})}> } ent.fn.match(reg)} {...rest} /> ); } } export default SearchableAddressBook;