@@ -11,10 +11,10 @@ import {
1111 LinkBox ,
1212 icons ,
1313 DropdownInput ,
14+ InputWithLabelIcon ,
1415} from '..' ;
1516import { handleUpdateNumericInput } from '../../../utils/input' ;
1617import { iconColors } from '../../../constants/icons' ;
17- import OutsideClickHandler from 'react-outside-click-handler' ;
1818import ReactTooltip from 'react-tooltip' ;
1919
2020export const FormValidationError = ( props : {
@@ -199,69 +199,112 @@ export const MakeSecretField = (
199199 placeholder : any ;
200200 value : string ;
201201 onChange ?: any ;
202-
203- secretLabel : string ;
204- secretLabelColor : any ;
205- secretPlaceholder : any ;
206- secretValue : string ;
207202 secretOnChange ?: any ;
208-
203+ handleClick ?: any ;
209204 dropdownOptions ?: Array < any > ;
205+ tooltipText ?: string ;
210206 } & any ,
211207) : any => {
212-
213- const handleClick = ( ) => {
214- return null
215- } ;
216208
217- const [ popup , setPopup ] = useState ( false )
218-
219- const options = props ?. dropdownOptions ?. filter ( ( e : any ) => e ?. label ?. toLowerCase ( ) . includes ( props ?. value ?. toLowerCase ( ) ) )
209+ const options = props ?. dropdownOptions ?. filter ( ( e : any ) =>
210+ e ?. label ?. toLowerCase ( ) . includes ( props ?. value ?. toLowerCase ( ) ) ,
211+ ) ;
220212
221- useEffect ( ( ) => {
222- if ( props ?. value ?. slice ( 0 , 2 ) === '{{' ) {
223- setPopup ( true )
224- }
225- // eslint-disable-next-line
226- } , [ props ?. value ] )
227-
213+ // useEffect(() => {
214+ // if (props?.value?.slice(0, 2) === '{{' && props?.value?.length < 3) {
215+ // setPopup(true);
216+ // }
217+ // // eslint-disable-next-line
218+ // }, [props?.value]);
219+
220+ const handleClick = async ( option : any ) => {
221+ await props . secretOnChange ( option ) ;
222+ // await setPopup(false);
223+ } ;
228224
229225 return (
230226 < FlexBox . Column fullWidth >
231-
232227 < FlexBox alignItems = "center" fullWidth style = { { position : 'relative' } } >
233- < InputWithLabel
228+ < InputWithLabelIcon
234229 name = { props . name }
235230 label = { props . label }
236231 labelColor = { props . labelColor }
237- InputComponent = { < TextInput { ...props } style = { { border : '1px solid #C9CBD0' } } value = { props . value } placeholder = { props . placeholder } onChangeText = { props . onChange } /> }
232+ tooltipText = { props . tooltipText }
233+ InputComponent = {
234+ < TextInput
235+ { ...props }
236+ style = { { border : '1px solid #C9CBD0' } }
237+ value = { props . value }
238+ placeholder = { props . placeholder }
239+ onChangeText = { props . onChange }
240+ />
241+ }
238242 />
239-
240- { popup && (
241- < Box style = { { backgroundColor : '#fff' , borderRadius : '4px' , boxShadow : '0px 2px 4px rgba(0, 0, 0, 0.05)' , width : '100%' , position : 'absolute' , zIndex : 2 , top : '7rem' } } >
242- < OutsideClickHandler onOutsideClick = { ( ) => setPopup ( false ) } >
243-
244- < Box marginVertical = "sm" marginHorizontal = "md" style = { { width : '100%' , height : '100%' } } >
245- { options ?. map ( ( option : any , index : number ) => (
246- < Box marginTop = "md" onClick = { ( ) => { } } key = { index } >
247- < div data-tip data-for = { option . name } onClick = { ( ) => { props . onChange ( ( ) => option . label ) ; setPopup ( false ) } } style = { { cursor : 'pointer' } } >
248- < Paragraph > { option . label } </ Paragraph >
249- </ div >
250243
251- < ReactTooltip id = { option . label } place = "top" effect = "solid" >
252- < Paragraph color = "white" > { option . label } </ Paragraph >
253- </ ReactTooltip >
254- </ Box >
255- ) ) }
256- </ Box >
257-
258- </ OutsideClickHandler >
244+ { props ?. value ?. length > 0 && props ?. value ?. slice ( 0 , 2 ) !== '{{' && (
245+ < Box
246+ style = { {
247+ position : 'absolute' ,
248+ right : '10px' ,
249+ top : '40px' ,
250+ display : 'flex' ,
251+ alignItems : 'center' ,
252+ background : '#fff' ,
253+ borderLeft : '1px solid grey' ,
254+ paddingLeft : '10px' ,
255+ cursor : 'pointer' ,
256+ } }
257+ onClick = { ( ) => props . handleClick ( ) }
258+ >
259+ < icons . lock
260+ color = { iconColors . primary }
261+ style = { { marginRight : '5px' } }
262+ />
263+ < Paragraph color = "primary" > Make it Secret</ Paragraph >
259264 </ Box >
260265 ) }
266+
267+ < If condition = { props ?. value ?. slice ( 0 , 2 ) === '{{' && props ?. value ?. slice ( - 2 ) !== '}}' && props ?. dropdownOptions ?. length > 0 } >
268+ { ( ) => (
269+ < Box
270+ style = { {
271+ backgroundColor : '#fff' ,
272+ borderRadius : '4px' ,
273+ boxShadow : '0px 2px 4px rgba(0, 0, 0, 0.05)' ,
274+ width : '100%' ,
275+ position : 'absolute' ,
276+ zIndex : 2 ,
277+ top : '7rem' ,
278+ } }
279+ >
280+ < Box
281+ marginVertical = "sm"
282+ marginHorizontal = "md"
283+ style = { { width : '100%' , height : '100%' } }
284+ >
285+ { options ?. map ( ( option : any , index : number ) => (
286+ < Box marginTop = "md" onClick = { ( ) => { } } key = { index } >
287+ < div
288+ data-tip
289+ data-for = { option . name }
290+ onClick = { ( ) => handleClick ( option ) }
291+ style = { { cursor : 'pointer' } }
292+ >
293+ < Paragraph > { option . label } </ Paragraph >
294+ </ div >
261295
296+ < ReactTooltip id = { option . label } place = "top" effect = "solid" >
297+ < Paragraph color = "white" > { option . label } </ Paragraph >
298+ </ ReactTooltip >
299+ </ Box >
300+ ) ) }
301+ </ Box >
302+ </ Box >
303+ ) }
304+ </ If >
262305 </ FlexBox >
263306
264- { props ?. value ?. length > 0 &&
307+ { /* { props?.value?.length > 0 &&
265308 props?.value?.slice(0, 2) !== '{{' && (
266309 <FlexBox marginTop='lg' alignItems="center" fullWidth style={{ position: 'relative' }}>
267310 <InputWithLabel
@@ -283,8 +326,7 @@ export const MakeSecretField = (
283326 <Paragraph color='primary'>Make it Secret</Paragraph>
284327 </Box>
285328 </FlexBox>
286- ) }
287-
329+ )} */ }
288330 </ FlexBox . Column >
289331 ) ;
290332} ;
0 commit comments