UNPKG

@wufengteam/wform

Version:

@wufengteam/wform

71 lines 3.54 kB
var __rest = this && this.__rest || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import React from 'react'; // import type { Rule } from 'antd/lib/form'; import FieldItem from '../components/FieldItem'; import { mergeFieldAttrAndStatus, mergeFieldAttrAndVisible } from '../utils/props'; import TextRecognitionPC from './TextRecognitionPC'; import TextRecognitionH5 from './TextRecognitionH5'; import FieldItemPc from '../components/FieldItemPc'; import "./index.css"; import withTransformProps from '../utils/withTransformProps'; import FieldItemH5 from '../components/FieldItemH5'; // interface TextProps1 { // name: string; // label: string; // rules?: any[]; // placeholder?: string; // fieldAttr?: string[]; // 字段属性 read--只读 hide--隐藏 addHide--新增时隐藏 // initialValue?: any[]; // fieldDes?: string; // idenTemplate?: string; // fieldMapping: any; // disabled?: boolean; // 是否禁用 // $$componentItem: { // platform: 'h5' | 'pc'; // Field?: any; // [key: string]: any; // }; // basicStatus?: string; // pc 显隐,只读 // visible?: boolean; // } var Text = function Text(props) { var label = props.label, name = props.name, _props$fieldAttr = props.fieldAttr, fieldAttr = _props$fieldAttr === void 0 ? [] : _props$fieldAttr, _props$fieldDes = props.fieldDes, fieldDes = _props$fieldDes === void 0 ? '' : _props$fieldDes, _props$$$componentIte = props.$$componentItem, $$componentItem = _props$$$componentIte === void 0 ? { platform: 'pc' } : _props$$$componentIte, basicStatus = props.basicStatus, _props$visible = props.visible, visible = _props$visible === void 0 ? true : _props$visible, restProps = __rest(props, ["label", "name", "fieldAttr", "fieldDes", "$$componentItem", "basicStatus", "visible"]); var finalFieldAttr = mergeFieldAttrAndVisible({ fieldAttr: mergeFieldAttrAndStatus(fieldAttr, basicStatus), visible: visible }); var renderType = $$componentItem.renderType, platform = $$componentItem.platform; return /*#__PURE__*/React.createElement(React.Fragment, null, renderType === 'editor' ? ( /*#__PURE__*/React.createElement(FieldItem, Object.assign({ label: label, name: name, fieldAttr: finalFieldAttr, fieldDes: fieldDes, platform: $$componentItem === null || $$componentItem === void 0 ? void 0 : $$componentItem.platform, Field: $$componentItem.Field, renderType: $$componentItem.renderType }, restProps), $$componentItem.platform === 'h5' ? /*#__PURE__*/React.createElement(TextRecognitionH5, Object.assign({}, restProps)) : /*#__PURE__*/React.createElement(TextRecognitionPC, Object.assign({}, props)))) : ( /*#__PURE__*/React.createElement(React.Fragment, null, platform === 'pc' ? ( /*#__PURE__*/React.createElement(FieldItemPc, Object.assign({}, props), /*#__PURE__*/React.createElement(TextRecognitionPC, Object.assign({}, props)))) : ( /*#__PURE__*/React.createElement(FieldItemH5, Object.assign({}, props, { fieldAttr: finalFieldAttr }), /*#__PURE__*/React.createElement(TextRecognitionH5, Object.assign({}, restProps))))))); }; export default withTransformProps(Text);