BookmarkFolderNameInput.tsx 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { useTranslation } from 'next-i18next';
  2. import ClosableTextInput, { AlertInfo, AlertType } from '~/components/Common/ClosableTextInput';
  3. type Props = {
  4. onClickOutside: () => void
  5. onPressEnter: (folderName: string) => void
  6. value?: string
  7. }
  8. const BookmarkFolderNameInput = (props: Props): JSX.Element => {
  9. const {
  10. onClickOutside, onPressEnter, value,
  11. } = props;
  12. const { t } = useTranslation();
  13. const inputValidator = (title: string | null): AlertInfo | null => {
  14. if (title == null || title === '' || title.trim() === '') {
  15. return {
  16. type: AlertType.WARNING,
  17. message: t('form_validation.title_required'),
  18. };
  19. }
  20. return null;
  21. };
  22. return (
  23. <div className="flex-fill">
  24. <ClosableTextInput
  25. value={ value }
  26. placeholder={t('bookmark_folder.input_placeholder')}
  27. onClickOutside={onClickOutside}
  28. onPressEnter={onPressEnter}
  29. inputValidator={inputValidator}
  30. />
  31. </div>
  32. );
  33. };
  34. export default BookmarkFolderNameInput;