@atlaskit/field-text-area
Version:
Field Text Component
78 lines (58 loc) • 2.98 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
import _inherits from "@babel/runtime/helpers/inherits";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
/* eslint-disable react/prop-types */
import React, { Component } from 'react';
import FieldTextAreaStateless from './FieldTextAreaStateless';
var FieldTextArea = /*#__PURE__*/function (_Component) {
_inherits(FieldTextArea, _Component);
var _super = _createSuper(FieldTextArea);
function FieldTextArea() {
var _this;
_classCallCheck(this, FieldTextArea);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _super.call.apply(_super, [this].concat(args));
_defineProperty(_assertThisInitialized(_this), "input", void 0);
_defineProperty(_assertThisInitialized(_this), "state", {
value: _this.props.value
});
_defineProperty(_assertThisInitialized(_this), "handleOnChange", function (e) {
_this.setState({
value: e.target.value
});
if (_this.props.onChange) _this.props.onChange(e);
});
_defineProperty(_assertThisInitialized(_this), "focus", function () {
_this.input.focus();
});
return _this;
}
_createClass(FieldTextArea, [{
key: "render",
value: function render() {
var _this2 = this;
return /*#__PURE__*/React.createElement(FieldTextAreaStateless, _extends({}, this.props, {
value: this.state.value,
onChange: this.handleOnChange,
ref: function ref(fieldRef) {
_this2.input = fieldRef;
}
}));
}
}]);
return FieldTextArea;
}(Component);
_defineProperty(FieldTextArea, "defaultProps", {
onChange: function onChange() {},
enableResize: false
});
export { FieldTextArea as default };