UNPKG

plot-plan-designer

Version:

Design Editor Tools with React.js + ant.design + fabric.js

32 lines (31 loc) 1.74 kB
import React from 'react'; import { Form, Radio } from 'antd'; import i18n from 'i18next'; import UrlModal from '../../common/UrlModal'; import FileUpload from '../../common/FileUpload'; export default { render(canvasRef, form, data) { const { setFields } = form; if (!data) { return null; } const imageLoadType = data.imageLoadType || 'file'; return (React.createElement(React.Fragment, null, React.createElement(Form.Item, { label: i18n.t('imagemap.image.image-load-type'), colon: false, name: "imageLoadType", initialValue: imageLoadType, labelCol: { span: 24 } }, React.createElement(Radio.Group, { size: "small" }, React.createElement(Radio.Button, { value: "file" }, i18n.t('imagemap.image.file-upload')), React.createElement(Radio.Button, { value: "src" }, i18n.t('imagemap.image.image-url')))), imageLoadType === 'file' ? (React.createElement(Form.Item, { label: i18n.t('common.file'), colon: false, name: "file", initialValue: data.file, rules: [ { required: true, message: i18n.t('validation.enter-property', { arg: i18n.t('common.file') }), }, ], labelCol: { span: 24 } }, React.createElement(FileUpload, { accept: "image/*", bindError: (mess) => setFields({ file: { errors: [new Error(mess)], }, }) }))) : (React.createElement(Form.Item, { name: "src", initialValue: data.src, labelCol: { span: 24 } }, React.createElement(UrlModal, { form: form }))))); }, };