import { useId, type ReactNode } from 'react'; import { useTranslation } from 'react-i18next'; import { Button, Form, Input, InputNumber, Select, Space, Switch } from 'antd'; import { MinusOutlined, PlusOutlined } from '@ant-design/icons'; import { useFieldArray, useFormContext } from 'react-hook-form'; import { selectTagRender } from '@/components/form'; import { FormField } from '@/components/form/rhf'; interface StringListProps { name: string[]; label: ReactNode; tooltip?: string; placeholder: (index: number) => string; } function StringList({ name, label, tooltip, placeholder }: StringListProps) { const { t } = useTranslation(); const labelId = useId(); const { control } = useFormContext(); const { fields, append, remove } = useFieldArray({ control, name: name.join('.') }); return ( {label}} tooltip={tooltip}> {fields.map((field, j) => ( ))} {tooltip && ( )} ); } // Named autoSystemWfpBlockLeak values; xray-core 26.10.31 also takes typed "tcp/" or "udp/". const WFP_BLOCK_LEAK_OPTIONS = [ { value: 'dns', label: 'dns' }, { value: 'windnsclient', label: 'windnsclient' }, { value: 'misconfigtun', label: 'misconfigtun' }, ]; export default function TunFields() { const { t } = useTranslation(); return ( <> (j === 0 ? '10.0.0.1/16' : 'fc00::1/64')} /> (j === 0 ? '1.1.1.1' : '8.8.8.8')} /> (j === 0 ? '0.0.0.0/0' : '::/0')} />