Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

cross-language-form-field.tsx 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import {
  2. FormControl,
  3. FormField,
  4. FormItem,
  5. FormLabel,
  6. } from '@/components/ui/form';
  7. import { MultiSelect } from '@/components/ui/multi-select';
  8. import { cn } from '@/lib/utils';
  9. import { useFormContext } from 'react-hook-form';
  10. import { useTranslation } from 'react-i18next';
  11. const Languages = [
  12. 'English',
  13. 'Chinese',
  14. 'Spanish',
  15. 'French',
  16. 'German',
  17. 'Japanese',
  18. 'Korean',
  19. 'Vietnamese',
  20. ];
  21. const options = Languages.map((x) => ({ label: x, value: x }));
  22. type CrossLanguageItemProps = {
  23. name?: string;
  24. vertical?: boolean;
  25. };
  26. export const CrossLanguageFormField = ({
  27. name = 'prompt_config.cross_languages',
  28. vertical = true,
  29. }: CrossLanguageItemProps) => {
  30. const { t } = useTranslation();
  31. const form = useFormContext();
  32. return (
  33. <FormField
  34. control={form.control}
  35. name={name}
  36. render={({ field }) => (
  37. <FormItem
  38. className={cn('flex', {
  39. 'gap-2': vertical,
  40. 'flex-col': vertical,
  41. 'justify-between': !vertical,
  42. 'items-center': !vertical,
  43. })}
  44. >
  45. <FormLabel tooltip={t('chat.crossLanguageTip')}>
  46. {t('chat.crossLanguage')}
  47. </FormLabel>
  48. <FormControl>
  49. <MultiSelect
  50. options={options}
  51. placeholder={t('fileManager.pleaseSelect')}
  52. maxCount={100}
  53. {...field}
  54. onValueChange={field.onChange}
  55. modalPopover
  56. />
  57. </FormControl>
  58. </FormItem>
  59. )}
  60. />
  61. );
  62. };