Files
portainer/app/react/components/form-components/Input/Select.tsx
T
Chaim Lev-Ari dd68560ad0 chore(deps): upgrade prettier (#2592)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 16:39:58 +03:00

44 lines
1023 B
TypeScript

import clsx from 'clsx';
import { SelectHTMLAttributes } from 'react';
import { AutomationTestingProps } from '@/types';
export interface Option<
T extends string | number,
> extends Partial<AutomationTestingProps> {
value: T;
label: string;
disabled?: boolean;
}
interface Props<T extends string | number> extends AutomationTestingProps {
options: Array<Option<T>> | ReadonlyArray<Option<T>>;
}
export function Select<T extends number | string>({
options,
className,
'data-cy': dataCy,
...props
}: Props<T> & SelectHTMLAttributes<HTMLSelectElement>) {
return (
<select
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
className={clsx('form-control', className)}
data-cy={dataCy}
>
{options.map((item) => (
<option
value={item.value}
key={item.value}
disabled={item.disabled}
data-cy={`${dataCy}-${item.value}`}
>
{item.label}
</option>
))}
</select>
);
}