UNPKG

@react-awesome-query-builder/antd

Version:
72 lines 3.09 kB
import _extends from "@babel/runtime/helpers/extends"; import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; import _createClass from "@babel/runtime/helpers/createClass"; import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf"; import _inherits from "@babel/runtime/helpers/inherits"; function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } import React, { PureComponent } from "react"; import PropTypes from "prop-types"; import { Input, Col } from "antd"; var TextArea = Input.TextArea; var TextAreaWidget = /*#__PURE__*/function (_PureComponent) { function TextAreaWidget() { var _this; _classCallCheck(this, TextAreaWidget); for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this = _callSuper(this, TextAreaWidget, [].concat(args)); _this.handleChange = function (ev) { var v = ev.target.value; var val = v === "" ? undefined : v; // don't allow empty value _this.props.setValue(val); }; return _this; } _inherits(TextAreaWidget, _PureComponent); return _createClass(TextAreaWidget, [{ key: "render", value: function render() { var _this$props = this.props, config = _this$props.config, placeholder = _this$props.placeholder, customProps = _this$props.customProps, value = _this$props.value, readonly = _this$props.readonly, maxLength = _this$props.maxLength, maxRows = _this$props.maxRows, fullWidth = _this$props.fullWidth; var _config$settings = config.settings, renderSize = _config$settings.renderSize, defaultMaxRows = _config$settings.defaultMaxRows; var aValue = value != undefined ? value : null; return /*#__PURE__*/React.createElement(Col, null, /*#__PURE__*/React.createElement(TextArea, _extends({ autoSize: { minRows: 1, maxRows: maxRows || defaultMaxRows }, maxLength: maxLength, disabled: readonly, key: "widget-textarea", size: renderSize, value: aValue, placeholder: placeholder, onChange: this.handleChange }, customProps))); } }]); }(PureComponent); TextAreaWidget.propTypes = { setValue: PropTypes.func.isRequired, placeholder: PropTypes.string, config: PropTypes.object.isRequired, value: PropTypes.string, field: PropTypes.any, readonly: PropTypes.bool, customProps: PropTypes.object, maxLength: PropTypes.number, maxRows: PropTypes.number }; export { TextAreaWidget as default };