UNPKG

form-render

Version:

通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成

40 lines 1.37 kB
import "antd/es/button/style"; import _Button from "antd/es/button"; import "antd/es/space/style"; import _Space from "antd/es/space"; import "antd/es/drawer/style"; import _Drawer from "antd/es/drawer"; import "antd/es/config-provider/style"; import _ConfigProvider from "antd/es/config-provider"; import { __rest } from "tslib"; import React, { useContext } from 'react'; import { translation } from '../utils'; var DrawerForm = function DrawerForm(props) { var children = props.children, onConfirm = props.onConfirm, onClose = props.onClose, ret = __rest(props, ["children", "onConfirm", "onClose"]); var configCtx = useContext(_ConfigProvider.ConfigContext); var t = translation(configCtx); var extraProps = Object.assign(Object.assign({}, ret), { open: true }); if (window.antdVersion === 'v4') { extraProps = Object.assign(Object.assign({}, ret), { visible: true }); } return /*#__PURE__*/React.createElement(_Drawer, Object.assign({ width: 600, title: t('operate') }, extraProps, { onClose: onClose, extra: /*#__PURE__*/React.createElement(_Space, null, /*#__PURE__*/React.createElement(_Button, { onClick: onClose }, t('cancel')), /*#__PURE__*/React.createElement(_Button, { type: "primary", onClick: onConfirm }, t('confirm'))) }), children); }; export default DrawerForm;