11import React , { PureComponent } from 'react' ;
22import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' ;
3- import { vsArrowLeft , vsArrowRight , vsSearch } from '@deephaven/icons' ;
3+ import { vsSearch } from '@deephaven/icons' ;
44import classNames from 'classnames' ;
5- import Button from './Button' ;
65import './SearchInput.scss' ;
76
8- interface QueryParams {
9- queriedColumnIndex : number | undefined ;
10- changeQueriedColumnIndex : ( direction : 'forward' | 'back' ) => void ;
11- }
127interface SearchInputProps {
138 value : string ;
149 placeholder : string ;
@@ -20,7 +15,6 @@ interface SearchInputProps {
2015 matchCount : number ;
2116 id : string ;
2217 'data-testid' ?: string ;
23- queryParams ?: QueryParams ;
2418}
2519
2620class SearchInput extends PureComponent < SearchInputProps > {
@@ -33,40 +27,19 @@ class SearchInput extends PureComponent<SearchInputProps> {
3327 } ,
3428 id : '' ,
3529 'data-testid' : undefined ,
36- queryParams : undefined ,
3730 } ;
3831
3932 constructor ( props : SearchInputProps ) {
4033 super ( props ) ;
4134 this . inputField = React . createRef ( ) ;
42- this . searchChangeSelection = React . createRef ( ) ;
43- }
44-
45- componentDidMount ( ) : void {
46- this . setInputPaddingRight ( ) ;
4735 }
4836
49- componentDidUpdate ( ) : void {
50- this . setInputPaddingRight ( ) ;
51- }
37+ inputField : React . RefObject < HTMLInputElement > ;
5238
5339 focus ( ) : void {
5440 this . inputField . current ?. focus ( ) ;
5541 }
5642
57- inputField : React . RefObject < HTMLInputElement > ;
58-
59- searchChangeSelection : React . RefObject < HTMLDivElement > ;
60-
61- setInputPaddingRight ( ) : void {
62- const inputField = this . inputField . current ;
63- const searchChangeSelection = this . searchChangeSelection . current ;
64- if ( inputField && searchChangeSelection ) {
65- const paddingRight = searchChangeSelection . getBoundingClientRect ( ) . width ;
66- inputField . style . paddingRight = `${ paddingRight } px` ;
67- }
68- }
69-
7043 render ( ) : JSX . Element {
7144 const {
7245 value,
@@ -79,47 +52,7 @@ class SearchInput extends PureComponent<SearchInputProps> {
7952 id,
8053 onKeyDown,
8154 'data-testid' : dataTestId ,
82- queryParams,
8355 } = this . props ;
84-
85- let matchCountSection ;
86-
87- if ( queryParams && matchCount > 1 ) {
88- matchCountSection = (
89- < >
90- < Button
91- kind = "ghost"
92- className = "search-change-button"
93- type = "button"
94- onClick = { ( ) => {
95- queryParams . changeQueriedColumnIndex ( 'back' ) ;
96- } }
97- icon = { vsArrowLeft }
98- tooltip = "Next match"
99- />
100- < span className = "search-change-text" >
101- { queryParams . queriedColumnIndex !== undefined &&
102- `${ queryParams . queriedColumnIndex + 1 } of ` }
103- { matchCount }
104- </ span >
105- < Button
106- kind = "ghost"
107- className = "search-change-button"
108- type = "button"
109- onClick = { ( ) => {
110- queryParams . changeQueriedColumnIndex ( 'forward' ) ;
111- } }
112- icon = { vsArrowRight }
113- tooltip = "Next match"
114- />
115- </ >
116- ) ;
117- } else {
118- matchCountSection = matchCount > 0 && (
119- < span className = "match_count" > { matchCount } </ span >
120- ) ;
121- }
122-
12356 return (
12457 < div className = { classNames ( 'search-group' , className ) } >
12558 < input
@@ -135,19 +68,12 @@ class SearchInput extends PureComponent<SearchInputProps> {
13568 id = { id }
13669 data-testid = { dataTestId }
13770 />
138-
139- { matchCount != null ? (
140- < div
141- className = "search-change-selection"
142- ref = { this . searchChangeSelection }
143- >
144- { matchCountSection }
145- </ div >
146- ) : (
147- < span className = "search-icon" >
148- < FontAwesomeIcon icon = { vsSearch } />
149- </ span >
71+ { matchCount != null && (
72+ < span className = "search-match" > { matchCount } </ span >
15073 ) }
74+ < span className = "search-icon" >
75+ < FontAwesomeIcon icon = { vsSearch } />
76+ </ span >
15177 </ div >
15278 ) ;
15379 }
0 commit comments