SimplePicker.tsx 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import React, { SFC } from 'react';
  2. import Select from 'react-select';
  3. import DescriptionOption from './DescriptionOption';
  4. import ResetStyles from './ResetStyles';
  5. interface Props {
  6. options: any[];
  7. className?: string;
  8. placeholder?: string;
  9. width: number;
  10. onSelected: (item: any) => {} | void;
  11. getOptionValue: (item: any) => string;
  12. getOptionLabel: (item: any) => string;
  13. }
  14. const SimplePicker: SFC<Props> = ({
  15. className,
  16. getOptionLabel,
  17. getOptionValue,
  18. onSelected,
  19. options,
  20. placeholder,
  21. width,
  22. }) => {
  23. return (
  24. <Select
  25. isSearchable={false}
  26. classNamePrefix={`gf-form-select-box`}
  27. className={`width-${width} gf-form-input gf-form-input--form-dropdown ${className || ''}`}
  28. placeholder={placeholder || 'Choose'}
  29. options={options}
  30. onChange={onSelected}
  31. components={{
  32. Option: DescriptionOption,
  33. }}
  34. styles={ResetStyles}
  35. getOptionValue={getOptionValue}
  36. getOptionLabel={getOptionLabel}
  37. />
  38. );
  39. };
  40. export default SimplePicker;