import React from 'react';
import { Select } from '@cloudflare/component-select';
import { Base, BaseProps } from './Base';
import { SelectOption } from './types';

export type SelectProps<ValueType> = Omit<
  BaseProps<React.ComponentProps<typeof Select>, ValueType>,
  'onChange' | 'value' | 'options'
> & {
  onChange?: (option: SelectOption<ValueType>) => void;
  value?: ValueType;
  options: SelectOption<ValueType>[];
};

export default function FormSelect<ValueType>(props: SelectProps<ValueType>) {
  return (
    <Base<SelectProps<ValueType>, ValueType>
      // @ts-ignore
      Component={Select}
      {...props}
    />
  );
}
