mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-15 17:31:25 +08:00
8114516496
* update tree deps * add part of style * flex grid * update disabled * update demo * second demo * add draggable style * update demo * update rc-tree version * temp md * update tree deps * update icon demo * update style * update less * update deps * clean up * update test case * fix show line * update snapshot * fix lint * update style * update deps
34 lines
764 B
TypeScript
34 lines
764 B
TypeScript
import * as React from 'react';
|
|
import { List } from 'rc-field-form';
|
|
import warning from '../_util/warning';
|
|
|
|
interface FieldData {
|
|
name: number;
|
|
key: number;
|
|
fieldKey: number;
|
|
}
|
|
|
|
interface Operation {
|
|
add: () => void;
|
|
remove: (index: number) => void;
|
|
}
|
|
|
|
interface FormListProps {
|
|
name: string | number | (string | number)[];
|
|
children: (fields: FieldData[], operation: Operation) => React.ReactNode;
|
|
}
|
|
|
|
const FormList: React.FC<FormListProps> = ({ children, ...props }) => {
|
|
warning(!!props.name, 'Form.List', 'Miss `name` prop.');
|
|
|
|
return (
|
|
<List {...props}>
|
|
{(fields, operation) => {
|
|
return children(fields.map(field => ({ ...field, fieldKey: field.key })), operation);
|
|
}}
|
|
</List>
|
|
);
|
|
};
|
|
|
|
export default FormList;
|