UNPKG

@schema-render/form-render-react

Version:

Out-of-the-box form rendering library based on Core and Antd.

49 lines (48 loc) 2.01 kB
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; import { createElement as _createElement } from "react"; import { QuestionCircleOutlined } from "@ant-design/icons"; import { RendererIterator } from "@schema-render/core-react"; import { Collapse, Popover } from "antd"; import { useState } from "react"; /** * 不能命名为 Object,否则编译为 commonjs 文件后与关键字 Object 对象冲突 */ const ObjectRenderer = ({ schema, path, objectStyle })=>{ var _schema_renderOptions, _schema_renderOptions1; const [collapsed, setCollapsed] = useState(false); const header = /*#__PURE__*/ _jsxs(_Fragment, { children: [ /*#__PURE__*/ _jsx("span", { children: schema.title }), !!schema.titleDescription && /*#__PURE__*/ _jsx(Popover, { placement: "top", trigger: "hover", content: schema.titleDescription, children: /*#__PURE__*/ _jsx(QuestionCircleOutlined, { style: { marginLeft: 4 } }) }) ] }); return /*#__PURE__*/ _jsx(Collapse, { ...(_schema_renderOptions = schema.renderOptions) === null || _schema_renderOptions === void 0 ? void 0 : _schema_renderOptions.headerOptions, activeKey: String(collapsed), onChange: ()=>setCollapsed(!collapsed), children: /*#__PURE__*/ _createElement(Collapse.Panel, { ...(_schema_renderOptions1 = schema.renderOptions) === null || _schema_renderOptions1 === void 0 ? void 0 : _schema_renderOptions1.panelOptions, header: header, key: "false" }, /*#__PURE__*/ _jsx("div", { style: objectStyle, children: /*#__PURE__*/ _jsx(RendererIterator, { schema: schema, path: path }) })) }); }; export default { formItem: ObjectRenderer };