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.

43 lines
1.1 KiB

  1. // Package imports.
  2. import PropTypes from 'prop-types';
  3. import React from 'react';
  4. import ImmutablePropTypes from 'react-immutable-proptypes';
  5. // Components.
  6. import ComposerTextareaSuggestionsItem from './item';
  7. // The component.
  8. export default function ComposerTextareaSuggestions ({
  9. hidden,
  10. onSuggestionClick,
  11. suggestions,
  12. value,
  13. }) {
  14. // The result.
  15. return (
  16. <div
  17. className='composer--textarea--suggestions'
  18. hidden={hidden || !suggestions || suggestions.isEmpty()}
  19. >
  20. {!hidden && suggestions ? suggestions.map(
  21. (suggestion, index) => (
  22. <ComposerTextareaSuggestionsItem
  23. index={index}
  24. key={typeof suggestion === 'object' ? suggestion.id : suggestion}
  25. onClick={onSuggestionClick}
  26. selected={index === value}
  27. suggestion={suggestion}
  28. />
  29. )
  30. ) : null}
  31. </div>
  32. );
  33. }
  34. ComposerTextareaSuggestions.propTypes = {
  35. hidden: PropTypes.bool,
  36. onSuggestionClick: PropTypes.func,
  37. suggestions: ImmutablePropTypes.list,
  38. value: PropTypes.number,
  39. };