11import React , { useEffect , useRef , useState } from 'react'
2- import cx from 'classnames'
32
43import * as keys from 'uiSrc/constants/keys'
5- import { TextInput } from 'uiSrc/components/base/inputs'
64import { GroupBadge , RiTooltip } from 'uiSrc/components'
75import { OutsideClickDetector } from 'uiSrc/components/base/utils'
86import { Nullable } from 'uiSrc/utils'
@@ -12,49 +10,23 @@ import {
1210 SearchIcon ,
1311 SwitchIcon ,
1412} from 'uiSrc/components/base/icons'
15- import {
16- ActionIconButton ,
17- IconButton ,
18- } from 'uiSrc/components/base/forms/buttons'
13+ import { IconButton } from 'uiSrc/components/base/forms/buttons'
1914import { RiIcon } from 'uiSrc/components/base/icons/RiIcon'
2015import { ProgressBarLoader } from 'uiSrc/components/base/display'
21- import styles from './styles.module.scss'
22- import styled from 'styled-components'
23- import { Theme } from 'uiSrc/components/base/theme/types'
24-
25- interface StyledMultiSearchProps extends React . HTMLAttributes < HTMLDivElement > {
26- $isFocused : boolean
27- }
28-
29- const StyledMultiSearch = styled . div < StyledMultiSearchProps > `
30- border: 1px solid
31- ${ ( { theme, $isFocused } : { theme : Theme ; $isFocused : boolean } ) =>
32- $isFocused
33- ? theme . components . input . states . focused . borderColor
34- : theme . components . input . states . normal . borderColor } ;
35- background-color: ${ ( { theme } : { theme : Theme } ) =>
36- theme . components . input . states . normal . bgColor } ;
37- border-radius: 4px;
38- `
39- const StyledAutoSuggestions = styled . div < React . HTMLAttributes < HTMLDivElement >> `
40- background-color: ${ ( { theme } : { theme : Theme } ) =>
41- theme . components . select . dropdown . bgColor } ;
42- border-color: ${ ( { theme } : { theme : Theme } ) =>
43- theme . components . select . states . disabled . borderColor } ;
44- `
45- const StyledSuggestion = styled . li < React . HTMLAttributes < HTMLLIElement >> `
46- &:hover {
47- background: ${ ( { theme } : { theme : Theme } ) =>
48- theme . components . select . dropdown . option . states . highlighted . bgColor } ;
49- }
50- `
16+ import {
17+ StyledAutoSuggestions ,
18+ StyledClearButton ,
19+ StyledClearHistory ,
20+ StyledMultiSearch ,
21+ StyledMultiSearchWrapper ,
22+ StyledSearchInput ,
23+ StyledSuggestion ,
24+ StyledSuggestionOption ,
25+ StyledSuggestionRemoveBtn ,
26+ StyledSuggestionText ,
27+ } from './MultiSearch.styles'
5128
52- const StyledClearHistory = styled . li < React . HTMLAttributes < HTMLDivElement >> `
53- &:hover {
54- background: ${ ( { theme } : { theme : Theme } ) =>
55- theme . components . select . dropdown . option . states . highlighted . bgColor } ;
56- }
57- `
29+ import { Text } from 'uiSrc/components/base/text'
5830
5931interface MultiSearchSuggestion {
6032 options : null | Array < {
@@ -201,18 +173,14 @@ const MultiSearch = (props: Props) => {
201173
202174 return (
203175 < OutsideClickDetector onOutsideClick = { exitAutoSuggestions } >
204- < div
205- className = { cx ( styles . multiSearchWrapper , className ) }
176+ < StyledMultiSearchWrapper
177+ align = "center"
178+ className = { className }
206179 onKeyDown = { handleKeyDown }
207180 role = "presentation"
208181 data-testid = "multi-search"
209182 >
210- < StyledMultiSearch
211- $isFocused = { isInputFocus }
212- className = { cx ( styles . multiSearch , {
213- [ styles . isFocused ] : isInputFocus ,
214- } ) }
215- >
183+ < StyledMultiSearch align = "center" gap = "m" $isFocused = { isInputFocus } >
216184 < div >
217185 { options . map ( ( option ) => (
218186 < GroupBadge
@@ -223,8 +191,7 @@ const MultiSearch = (props: Props) => {
223191 />
224192 ) ) }
225193 </ div >
226- < TextInput
227- className = { styles . multiSearchInput }
194+ < StyledSearchInput
228195 placeholder = { placeholder }
229196 value = { value }
230197 onKeyDown = { handleKeyDown }
@@ -237,7 +204,6 @@ const MultiSearch = (props: Props) => {
237204 { showAutoSuggestions && ! ! suggestionOptions ?. length && (
238205 < StyledAutoSuggestions
239206 role = "presentation"
240- className = { styles . autoSuggestions }
241207 data-testid = "suggestions"
242208 >
243209 { suggestions ?. loading && (
@@ -252,28 +218,21 @@ const MultiSearch = (props: Props) => {
252218 value && (
253219 < StyledSuggestion
254220 key = { id }
255- className = { cx ( styles . suggestion , {
256- [ styles . focused ] : focusedItem === index ,
257- } ) }
221+ $isFocused = { focusedItem === index }
258222 onClick = { ( ) => handleApplySuggestion ( index ) }
259223 role = "presentation"
260224 data-testid = { `suggestion-item-${ id } ` }
261225 >
262226 { option && (
263- < GroupBadge
227+ < StyledSuggestionOption
264228 type = { option }
265229 compressed = { compressed }
266- className = { styles . suggestionOption }
267230 />
268231 ) }
269- < span
270- className = { styles . suggestionText }
271- data-testid = "suggestion-item-text"
272- >
232+ < StyledSuggestionText data-testid = "suggestion-item-text" >
273233 { value }
274- </ span >
275- < IconButton
276- className = { styles . suggestionRemoveBtn }
234+ </ StyledSuggestionText >
235+ < StyledSuggestionRemoveBtn
277236 icon = { CancelSlimIcon }
278237 color = "primary"
279238 aria-label = "Remove History Record"
@@ -289,7 +248,6 @@ const MultiSearch = (props: Props) => {
289248 </ ul >
290249 < StyledClearHistory
291250 role = "presentation"
292- className = { styles . clearHistory }
293251 onClick = { ( ) =>
294252 handleDeleteSuggestion (
295253 suggestionOptions ?. map ( ( item ) => item . id ) ,
@@ -298,18 +256,19 @@ const MultiSearch = (props: Props) => {
298256 data-testid = "clear-history-btn"
299257 >
300258 < RiIcon type = "EraserIcon" style = { { marginRight : 6 } } />
301- < span > Clear history</ span >
259+ < Text component = "span" size = "m" >
260+ Clear history
261+ </ Text >
302262 </ StyledClearHistory >
303263 </ StyledAutoSuggestions >
304264 ) }
305265 { ( value || ! ! options . length ) && (
306266 < RiTooltip content = "Reset Filters" position = "bottom" >
307- < ActionIconButton
267+ < StyledClearButton
308268 icon = { CancelSlimIcon }
309269 size = "XS"
310270 aria-label = "Reset Filters"
311271 onClick = { onClear }
312- className = { styles . clearButton }
313272 data-testid = "reset-filter-btn"
314273 variant = "secondary"
315274 />
@@ -336,15 +295,14 @@ const MultiSearch = (props: Props) => {
336295 { disableSubmit && (
337296 < RiTooltip
338297 position = "top"
339- anchorClassName = { styles . anchorSubmitBtn }
340298 content = "Please choose index in order to preform the search"
341299 >
342300 { SubmitBtn ( ) }
343301 </ RiTooltip >
344302 ) }
345303 { ! disableSubmit && SubmitBtn ( ) }
346304 </ StyledMultiSearch >
347- </ div >
305+ </ StyledMultiSearchWrapper >
348306 </ OutsideClickDetector >
349307 )
350308}
0 commit comments