asb_cloud_front/src/components/Table/EditableCell.jsx

34 lines
601 B
React
Raw Normal View History

import { Form, Input} from "antd"
export const EditableCell = ({
editing,
record,
dataIndex,
input,
isRequired,
title,
formItemClass,
formItemRules,
children,
initialValue,
}) => {
const inputNode = input ?? <Input/>
const rules = formItemRules ?? [{
required: isRequired,
message: `Please Input ${title}!`,
}]
const editor = <Form.Item
name={dataIndex}
style={{margin:0}}
className={formItemClass}
rules={rules}
initialValue={initialValue}>
{inputNode}
</Form.Item>
return (<td>
{editing ? editor: children}
</td>)
}