11import React , { useState } from 'react'
22
3- import { RiTooltip } from 'uiSrc/components'
43import { TextInput } from 'uiSrc/components/base/inputs'
54import { TagSuggestions } from './TagSuggestions'
6-
7- type TagInputFieldProps = {
8- value : string
9- disabled ?: boolean
10- currentTagKeys : Set < string >
11- suggestedTagKey ?: string
12- rightContent ?: React . ReactNode
13- errorMessage ?: string
14- placeholder ?: string
15- onChange : ( value : string ) => void
16- }
5+ import { TagInputFieldProps } from './TagInputField.types'
176
187export const TagInputField = ( {
198 value,
@@ -30,35 +19,33 @@ export const TagInputField = ({
3019
3120 return (
3221 < div >
33- < RiTooltip content = { errorMessage } position = "top" >
34- < TextInput
35- value = { value }
36- disabled = { disabled }
37- valid = { ! isInvalid ? false : undefined }
38- error = { isInvalid ? errorMessage : undefined }
39- onChange = { ( value ) => onChange ( value ) }
40- placeholder = { placeholder }
41- onFocusCapture = { ( ) => {
42- setIsFocused ( true )
43- } }
44- onBlurCapture = { ( ) => {
45- setTimeout ( ( ) => {
46- isFocused && setIsFocused ( false )
47- } , 150 )
22+ < TextInput
23+ value = { value }
24+ disabled = { disabled }
25+ valid = { ! isInvalid ? false : undefined }
26+ error = { isInvalid ? errorMessage : undefined }
27+ onChange = { ( value ) => onChange ( value ) }
28+ placeholder = { placeholder }
29+ onFocusCapture = { ( ) => {
30+ setIsFocused ( true )
31+ } }
32+ onBlurCapture = { ( ) => {
33+ setTimeout ( ( ) => {
34+ isFocused && setIsFocused ( false )
35+ } , 150 )
36+ } }
37+ />
38+ { isFocused && ! isInvalid && (
39+ < TagSuggestions
40+ targetKey = { suggestedTagKey }
41+ searchTerm = { value }
42+ currentTagKeys = { currentTagKeys }
43+ onChange = { ( value ) => {
44+ setIsFocused ( false )
45+ onChange ( value )
4846 } }
4947 />
50- { isFocused && ! isInvalid && (
51- < TagSuggestions
52- targetKey = { suggestedTagKey }
53- searchTerm = { value }
54- currentTagKeys = { currentTagKeys }
55- onChange = { ( value ) => {
56- setIsFocused ( false )
57- onChange ( value )
58- } }
59- />
60- ) }
61- </ RiTooltip >
48+ ) }
6249 { rightContent }
6350 </ div >
6451 )
0 commit comments