| 1 | /** |
| 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | * |
| 4 | * This source code is licensed under the MIT license found in the |
| 5 | * LICENSE file in the root directory of this source tree. |
| 6 | * |
| 7 | * @flow |
| 8 | */ |
| 9 | |
| 10 | import * as React from 'react'; |
| 11 | import {useContext} from 'react'; |
| 12 | |
| 13 | import SearchInput from 'react-devtools-shared/src/devtools/views/SearchInput'; |
| 14 | import {ProfilerContext} from './ProfilerContext'; |
| 15 | |
| 16 | export default function ProfilerSearchInput(): React.Node { |
| 17 | const { |
| 18 | searchText, |
| 19 | setSearchText, |
| 20 | searchResults, |
| 21 | searchIndex, |
| 22 | searchIsPending, |
| 23 | goToNextSearchResult, |
| 24 | goToPreviousSearchResult, |
| 25 | goToSearchResult, |
| 26 | hideSearchInput, |
| 27 | } = useContext(ProfilerContext); |
| 28 | |
| 29 | return ( |
| 30 | <SearchInput |
| 31 | autoFocus={true} |
| 32 | goToNextResult={goToNextSearchResult} |
| 33 | goToPreviousResult={goToPreviousSearchResult} |
| 34 | goToResult={goToSearchResult} |
| 35 | iconType="find" |
| 36 | isPending={searchIsPending} |
| 37 | onClose={hideSearchInput} |
| 38 | placeholder="Search this commit (text or /regex/)" |
| 39 | search={setSearchText} |
| 40 | searchIndex={searchIndex} |
| 41 | searchResultsCount={searchResults.length} |
| 42 | searchText={searchText} |
| 43 | testName="ProfilerSearchInput" |
| 44 | /> |
| 45 | ); |
| 46 | } |