Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

InputList.tsx 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import React from 'react';
  2. import { Input, Form, Button, Space } from 'antd';
  3. import { PlusOutlined, DeleteOutlined } from '@ant-design/icons';
  4. const InputList: React.FC = () => {
  5. return (
  6. <div className='mt-2'>
  7. <Form.List name="weblinks">
  8. {(fields, { add, remove }) => (
  9. <div style={{ width: '100%' }}>
  10. {fields.map(({ key, name, ...restField }) => (
  11. <Space key={key} align="baseline" style={{ width: '100%' }}>
  12. <Form.Item
  13. {...restField}
  14. name={[name, 'first']}
  15. rules={[{ required: true, message: 'Missing link' }]}
  16. style={{ flex: 1 }}
  17. >
  18. <Input placeholder="https://example.com/faq" />
  19. </Form.Item>
  20. <DeleteOutlined
  21. className='!text-red-500'
  22. onClick={() => remove(name)}
  23. />
  24. </Space>
  25. ))}
  26. {fields.length < 5 && (
  27. <Form.Item>
  28. <Button
  29. type="dashed"
  30. onClick={() => add()}
  31. block
  32. icon={<PlusOutlined />}
  33. >
  34. Add field
  35. </Button>
  36. </Form.Item>
  37. )}
  38. </div>
  39. )}
  40. </Form.List>
  41. </div>
  42. );
  43. };
  44. export default InputList;