-
-
Notifications
You must be signed in to change notification settings - Fork 435
/
Copy pathsearch-bar.tsx
50 lines (44 loc) · 1.31 KB
/
search-bar.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { nls } from '@theia/core/lib/common';
import * as React from '@theia/core/shared/react';
export class SearchBar extends React.Component<SearchBar.Props> {
constructor(props: Readonly<SearchBar.Props>) {
super(props);
this.handleFilterTextChange = this.handleFilterTextChange.bind(this);
}
override render(): React.ReactNode {
return (
<input
ref={this.setRef}
className={`theia-input ${SearchBar.Styles.SEARCH_BAR_CLASS}`}
type="text"
placeholder={nls.localize(
'arduino/component/filterSearch',
'Filter your search...'
)}
size={1}
value={this.props.filterText}
onChange={this.handleFilterTextChange}
/>
);
}
private setRef = (element: HTMLElement | null) => {
if (this.props.resolveFocus) {
this.props.resolveFocus(element || undefined);
}
};
private handleFilterTextChange(
event: React.ChangeEvent<HTMLInputElement>
): void {
this.props.onFilterTextChanged(event.target.value);
}
}
export namespace SearchBar {
export interface Props {
filterText: string;
onFilterTextChanged(filterText: string): void;
readonly resolveFocus?: (element: HTMLElement | undefined) => void;
}
export namespace Styles {
export const SEARCH_BAR_CLASS = 'search-bar';
}
}