SimplePicker.tsx 932 B

123456789101112131415161718192021222324252627282930313233
  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. onSelected: (item: any) => {} | void;
  9. getOptionValue: (item: any) => string;
  10. getOptionLabel: (item: any) => string;
  11. }
  12. const SimplePicker: SFC<Props> = ({ className, getOptionLabel, getOptionValue, onSelected, options }) => {
  13. return (
  14. <Select
  15. isSearchable={false}
  16. classNamePrefix={`gf-form-select-box`}
  17. className={`width-7 gf-form-input gf-form-input--form-dropdown ${className || ''}`}
  18. placeholder="Choose"
  19. options={options}
  20. onChange={onSelected}
  21. components={{
  22. Option: DescriptionOption,
  23. }}
  24. styles={ResetStyles}
  25. getOptionValue={getOptionValue}
  26. getOptionLabel={getOptionLabel}
  27. />
  28. );
  29. };
  30. export default SimplePicker;