UNPKG

fx-form-widget

Version:
59 lines (58 loc) 3.18 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); exports.__esModule = true; exports["default"] = void 0; var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var _input = _interopRequireDefault(require("antd/lib/input")); var React = _interopRequireWildcard(require("react")); var _tools = require("./tools"); require("./index.less"); function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; } var TextArea = _input["default"].TextArea; var Textarea = function Textarea(_ref) { var _ref$schema = _ref.schema, schema = _ref$schema === void 0 ? {} : _ref$schema, _ref$onChange = _ref.onChange, onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange, _ref$value = _ref.value, value = _ref$value === void 0 ? (0, _tools.isNotNullValue)(schema.data) ? schema.data : '' : _ref$value; var _schema$rows = schema.rows, rows = _schema$rows === void 0 ? 1 : _schema$rows, _schema$readonly = schema.readonly, readonly = _schema$readonly === void 0 ? false : _schema$readonly, _schema$required = schema.required, required = _schema$required === void 0 ? false : _schema$required, _schema$placeholder = schema.placeholder, placeholder = _schema$placeholder === void 0 ? '请输入' : _schema$placeholder, _schema$allowClear = schema.allowClear, allowClear = _schema$allowClear === void 0 ? false : _schema$allowClear, _schema$minLength = schema.minLength, minLength = _schema$minLength === void 0 ? undefined : _schema$minLength, _schema$maxLength = schema.maxLength, maxLength = _schema$maxLength === void 0 ? undefined : _schema$maxLength, _schema$showCount = schema.showCount, showCount = _schema$showCount === void 0 ? false : _schema$showCount; var handleChange = function handleChange(e) { return onChange(e.target.value); }; var options = { rows: rows, placeholder: placeholder, required: required, showCount: showCount, maxLength: maxLength, minLength: minLength, allowClear: allowClear, disabled: readonly }; var defaultUi = { width: '100%' }; var ui = (0, _extends2["default"])({}, defaultUi, options); return /*#__PURE__*/React.createElement(TextArea, (0, _extends2["default"])({}, ui, { value: value, onChange: handleChange })); }; var _default = exports["default"] = Textarea;