UNPKG

@wufengteam/inputs

Version:

平台提供的右侧属性编辑器,需要在主工程中注册

100 lines 2.45 kB
/* eslint-disable */ import React, { useMemo } from 'react'; import { Form, Select } from 'antd'; var InnerColSpan = function InnerColSpan(props) { var _a, _b, _c; var value = props.value, _onChange = props.onChange; var FormNode = props.DSLCore.querySelectAll('.Form'); var colSpan = (_c = (_b = (_a = FormNode === null || FormNode === void 0 ? void 0 : FormNode[0]) === null || _a === void 0 ? void 0 : _a.attribute) === null || _b === void 0 ? void 0 : _b.props) === null || _c === void 0 ? void 0 : _c.colSpan; var options = useMemo(function () { var result = []; switch (colSpan) { case 24: result = [{ label: '一列', value: 24 }]; break; case 12: result = [{ label: '一列', value: 12 }, { label: '两列', value: 24 }]; break; case 8: result = [{ label: '一列', value: 8 }, { label: '两列', value: 16 }, { label: '三列', value: 24 }]; break; case 6: result = [{ label: '一列', value: 6 }, { label: '两列', value: 12 }, { label: '三列', value: 18 }, { label: '四列', value: 24 }]; break; case 4: result = [{ label: '一列', value: 4 }, { label: '两列', value: 8 }, { label: '三列', value: 12 }, { label: '四列', value: 16 }, { label: '五列', value: 20 }, { label: '六列', value: 24 }]; break; default: result = []; } return result; }, [colSpan]); return /*#__PURE__*/React.createElement(Select, { value: value || colSpan, onChange: function onChange(value) { _onChange === null || _onChange === void 0 ? void 0 : _onChange(value); }, style: { width: '100%' }, options: options }); }; var ColSpan = function ColSpan(props) { var name = props.name, label = props.label; return /*#__PURE__*/React.createElement(Form.Item, { label: label, name: name }, /*#__PURE__*/React.createElement(InnerColSpan, Object.assign({}, props))); }; export default ColSpan;