import type { FC } from 'react' import React, { useCallback, useState } from 'react' import { t } from 'i18next' import { RiArrowDownSLine, } from '@remixicon/react' import type { CodeDependency } from './types' import { PortalToFollowElem, PortalToFollowElemContent, PortalToFollowElemTrigger } from '@/app/components/base/portal-to-follow-elem' import Input from '@/app/components/base/input' import { Check } from '@/app/components/base/icons/src/vender/line/general' type Props = { value: CodeDependency available_dependencies: CodeDependency[] onChange: (dependency: CodeDependency) => void } const DependencyPicker: FC = ({ available_dependencies, value, onChange, }) => { const [open, setOpen] = useState(false) const [searchText, setSearchText] = useState('') const handleChange = useCallback((dependency: CodeDependency) => { return () => { setOpen(false) onChange(dependency) } }, [onChange]) return ( setOpen(!open)} className='flex-grow cursor-pointer'>
{value.name}
setSearchText(e.target.value)} onClear={() => setSearchText('')} autoFocus />
{available_dependencies.filter((v) => { if (!searchText) return true return v.name.toLowerCase().includes(searchText.toLowerCase()) }).map(dependency => (
{dependency.name}
{dependency.name === value.name && }
))}
) } export default React.memo(DependencyPicker)