/******************************************************************************** * Copyright (c) 2020 TypeFox and others * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. * * SPDX-License-Identifier: EPL-2.0 ********************************************************************************/ import { ChangeEvent, FunctionComponent, KeyboardEvent, useContext } from 'react'; import SearchIcon from '@mui/icons-material/Search'; import { Paper, IconButton, InputBase } from '@mui/material'; import { MainContext } from '../../context'; interface ExtensionListSearchfieldProps { onSearchChanged: (s: string) => void; onSearchSubmit?: (s: string) => void; searchQuery?: string; placeholder: string; hideIconButton?: boolean; error?: boolean; autoFocus?: boolean; } export const ExtensionListSearchfield: FunctionComponent = props => { const { pageSettings } = useContext(MainContext); const handleSearchChange = (event: ChangeEvent) => { props.onSearchChanged(event.target.value); }; const handleSearchButtonClick = () => { if (props.onSearchSubmit) { props.onSearchSubmit(props.searchQuery ?? ''); } }; const searchIconColor = pageSettings?.themeType === 'dark' ? '#111111' : '#ffffff'; return { if (e.key === 'Enter' && props.onSearchSubmit) { props.onSearchSubmit(props.searchQuery ?? ''); } }} /> { props.hideIconButton ? '' : } ; };