2021-08-20 10:49:20 +05:00
|
|
|
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>
|
|
|
|
|
2021-08-30 15:11:21 +05:00
|
|
|
const tdStyle = editing
|
|
|
|
? { padding:0 }
|
|
|
|
: null
|
|
|
|
|
|
|
|
return (<td style={tdStyle}>
|
2021-08-20 10:49:20 +05:00
|
|
|
{editing ? editor: children}
|
|
|
|
</td>)
|
|
|
|
}
|