mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 15:25:59 +00:00
29 lines
649 B
JavaScript
29 lines
649 B
JavaScript
import React from 'react';
|
|
import styled from 'styled-components';
|
|
import keycodes from '../utility/keycodes';
|
|
|
|
const StyledInput = styled.input`
|
|
flex: 1;
|
|
min-width: 10px;
|
|
width: 10px;
|
|
`;
|
|
|
|
export default function SearchInput({ placeholder, filter, setFilter, inputRef = undefined }) {
|
|
const handleKeyDown = ev => {
|
|
if (ev.keyCode == keycodes.escape) {
|
|
setFilter('');
|
|
}
|
|
};
|
|
return (
|
|
<StyledInput
|
|
ref={inputRef}
|
|
type="text"
|
|
placeholder={placeholder}
|
|
value={filter}
|
|
onChange={e => setFilter(e.target.value)}
|
|
onFocus={e => e.target.select()}
|
|
onKeyDown={handleKeyDown}
|
|
/>
|
|
);
|
|
}
|