You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
portainer/app/react/components/ImageConfigFieldset/InputSearch.tsx

42 lines
917 B

import { useMemo } from 'react';
import { AutomationTestingProps } from '@/types';
import { AutocompleteSelect } from '@@/form-components/AutocompleteSelect';
import { Option } from '@@/form-components/PortainerSelect';
export function InputSearch({
value,
onChange,
options,
placeholder,
inputId,
'data-cy': dataCy,
}: {
value: string;
onChange: (value: string) => void;
options: Option<string>[];
placeholder?: string;
inputId: string;
} & AutomationTestingProps) {
const searchResults = useMemo(() => {
if (!value) {
return [];
}
return options.filter((option) =>
option.value.toLowerCase().includes(value.toLowerCase())
);
}, [options, value]);
return (
<AutocompleteSelect
searchResults={searchResults}
value={value}
onChange={onChange}
placeholder={placeholder}
inputId={inputId}
data-cy={dataCy}
/>
);
}