您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

SpeakerStatsSearch.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* @flow */
  2. import { FieldTextStateless as TextField } from '@atlaskit/field-text';
  3. import { makeStyles } from '@material-ui/core/styles';
  4. import React, { useCallback, useState } from 'react';
  5. import { useTranslation } from 'react-i18next';
  6. import { useSelector } from 'react-redux';
  7. import { getFieldValue } from '../../base/react';
  8. import { isSpeakerStatsSearchDisabled } from '../functions';
  9. const useStyles = makeStyles(() => {
  10. return {
  11. speakerStatsSearch: {
  12. position: 'absolute',
  13. right: '50px',
  14. top: '-5px'
  15. }
  16. };
  17. });
  18. /**
  19. * The type of the React {@code Component} props of {@link SpeakerStatsSearch}.
  20. */
  21. type Props = {
  22. /**
  23. * The function to initiate the change in the speaker stats table.
  24. */
  25. onSearch: Function,
  26. };
  27. /**
  28. * React component for display an individual user's speaker stats.
  29. *
  30. * @returns {React$Element<any>}
  31. */
  32. function SpeakerStatsSearch({ onSearch }: Props) {
  33. const classes = useStyles();
  34. const { t } = useTranslation();
  35. const [ searchValue, setSearchValue ] = useState<string>('');
  36. const onChange = useCallback((evt: Event) => {
  37. const value = getFieldValue(evt);
  38. setSearchValue(value);
  39. onSearch && onSearch(value);
  40. }, []);
  41. const disableSpeakerStatsSearch = useSelector(isSpeakerStatsSearchDisabled);
  42. if (disableSpeakerStatsSearch) {
  43. return null;
  44. }
  45. return (
  46. <div className = { classes.speakerStatsSearch }>
  47. <TextField
  48. autoComplete = 'off'
  49. autoFocus = { false }
  50. compact = { true }
  51. name = 'speakerStatsSearch'
  52. onChange = { onChange }
  53. placeholder = { t('speakerStats.search') }
  54. shouldFitContainer = { false }
  55. type = 'text'
  56. value = { searchValue } />
  57. </div>
  58. );
  59. }
  60. export default SpeakerStatsSearch;