| 
									
										
										
										
											2023-06-16 21:47:51 +08:00
										 |  |  | import { useCallback } from 'react' | 
					
						
							|  |  |  | import type { ChangeEvent } from 'react' | 
					
						
							|  |  |  | import { useTranslation } from 'react-i18next' | 
					
						
							| 
									
										
										
										
											2025-03-19 11:19:57 +08:00
										 |  |  | import { RiCloseCircleFill, RiSearchLine } from '@remixicon/react' | 
					
						
							| 
									
										
										
										
											2024-07-09 15:05:40 +08:00
										 |  |  | import cn from '@/utils/classnames' | 
					
						
							| 
									
										
										
										
											2023-06-16 21:47:51 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | type SearchInputProps = { | 
					
						
							|  |  |  |   value: string | 
					
						
							|  |  |  |   onChange: (v: string) => void | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | const SearchInput = ({ | 
					
						
							|  |  |  |   value, | 
					
						
							|  |  |  |   onChange, | 
					
						
							|  |  |  | }: SearchInputProps) => { | 
					
						
							|  |  |  |   const { t } = useTranslation() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   const handleClear = useCallback(() => { | 
					
						
							|  |  |  |     onChange('') | 
					
						
							|  |  |  |   }, [onChange]) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return ( | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |     <div className={cn('flex h-8 w-[200px] items-center rounded-lg bg-components-input-bg-normal p-2')}> | 
					
						
							|  |  |  |       <RiSearchLine className={'mr-0.5 h-4 w-4 shrink-0 text-components-input-text-placeholder'} /> | 
					
						
							| 
									
										
										
										
											2023-06-16 21:47:51 +08:00
										 |  |  |       <input | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |         className='min-w-0 grow appearance-none border-0 bg-transparent px-1 text-[13px] leading-[16px] text-components-input-text-filled outline-0 placeholder:text-components-input-text-placeholder' | 
					
						
							| 
									
										
										
										
											2023-06-16 21:47:51 +08:00
										 |  |  |         value={value} | 
					
						
							|  |  |  |         onChange={(e: ChangeEvent<HTMLInputElement>) => onChange(e.target.value)} | 
					
						
							|  |  |  |         placeholder={t('common.dataSource.notion.selector.searchPages') || ''} | 
					
						
							|  |  |  |       /> | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         value && ( | 
					
						
							| 
									
										
										
										
											2025-03-19 11:19:57 +08:00
										 |  |  |           <RiCloseCircleFill | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |             className={'h-4 w-4 shrink-0 cursor-pointer text-components-input-text-placeholder'} | 
					
						
							| 
									
										
										
										
											2023-06-16 21:47:51 +08:00
										 |  |  |             onClick={handleClear} | 
					
						
							|  |  |  |           /> | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     </div> | 
					
						
							|  |  |  |   ) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export default SearchInput |