UNPKG

loners-form

Version:

为工作而生,基于 antd 而生的可配置化表单

76 lines (58 loc) 3.85 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; require("antd/es/input/style"); var _input = _interopRequireDefault(require("antd/es/input")); var _react = _interopRequireDefault(require("react")); var _classnames = _interopRequireDefault(require("classnames")); var _QA = _interopRequireDefault(require("../QA")); var _constants = require("../constants"); require("../index.less"); var _excluded = ["fixedWidth", "style", "placeholder", "showCount", "maxLength", "allowClear", "autoSize", "showQA"]; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } var TextArea = _input.default.TextArea; var TextareaGo = function TextareaGo(props) { var _props$fixedWidth = props.fixedWidth, fixedWidth = _props$fixedWidth === void 0 ? false : _props$fixedWidth, style = props.style, _props$placeholder = props.placeholder, placeholder = _props$placeholder === void 0 ? '请输入' : _props$placeholder, _props$showCount = props.showCount, showCount = _props$showCount === void 0 ? true : _props$showCount, _props$maxLength = props.maxLength, maxLength = _props$maxLength === void 0 ? 300 : _props$maxLength, _props$allowClear = props.allowClear, allowClear = _props$allowClear === void 0 ? true : _props$allowClear, _props$autoSize = props.autoSize, autoSize = _props$autoSize === void 0 ? { minRows: 3, maxRows: 6 } : _props$autoSize, showQA = props.showQA, rawProps = _objectWithoutProperties(props, _excluded); var ownStyle = fixedWidth ? { width: _constants.WIDTH_SIZE_ENUM.s } : style; var formItemClassName = _constants.FORM_ITEM_CLASS_NAME; return /*#__PURE__*/_react.default.createElement("div", { className: (0, _classnames.default)("".concat(formItemClassName, "-box"), _defineProperty({}, "".concat(formItemClassName, "-mg-r"), showQA)) }, /*#__PURE__*/_react.default.createElement(TextArea, _extends({ showCount: showCount, maxLength: maxLength, allowClear: allowClear, placeholder: placeholder, autoSize: autoSize, style: ownStyle }, rawProps)), showQA && /*#__PURE__*/_react.default.createElement(_QA.default, { className: (0, _classnames.default)("".concat(formItemClassName, "-qa"), "".concat(formItemClassName, "-textarea-qa")), title: typeof showQA === 'boolean' ? '' : showQA.title })); }; var _default = TextareaGo; exports.default = _default;