1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
8 |
|
9 | var _FormGroup = require("./FormGroup");
|
10 |
|
11 | var _FormGroup2 = _interopRequireDefault(_FormGroup);
|
12 |
|
13 | var _react = require("react");
|
14 |
|
15 | var _react2 = _interopRequireDefault(_react);
|
16 |
|
17 | var _reactRte = require("react-rte");
|
18 |
|
19 | var _reactRte2 = _interopRequireDefault(_reactRte);
|
20 |
|
21 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
22 |
|
23 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
24 |
|
25 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
26 |
|
27 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
28 |
|
29 | var TextAreaFormGroup = function (_React$Component) {
|
30 | _inherits(TextAreaFormGroup, _React$Component);
|
31 |
|
32 | _createClass(TextAreaFormGroup, [{
|
33 | key: "componentWillReceiveProps",
|
34 | value: function componentWillReceiveProps(props) {
|
35 | this.updateStateFromProps(props);
|
36 | }
|
37 | }]);
|
38 |
|
39 | function TextAreaFormGroup(props) {
|
40 | _classCallCheck(this, TextAreaFormGroup);
|
41 |
|
42 | var _this = _possibleConstructorReturn(this, (TextAreaFormGroup.__proto__ || Object.getPrototypeOf(TextAreaFormGroup)).call(this, props));
|
43 |
|
44 | _this.updateStateFromProps(props);
|
45 | return _this;
|
46 | }
|
47 |
|
48 | _createClass(TextAreaFormGroup, [{
|
49 | key: "changeThis",
|
50 | value: function changeThis(value) {
|
51 | this.setState({ value: value });
|
52 | if (this.props.onChange) {
|
53 | this.props.onChange({
|
54 | target: {
|
55 | id: this.props.id,
|
56 | value: value.toString('markdown')
|
57 | }
|
58 | });
|
59 | }
|
60 | }
|
61 | }, {
|
62 | key: "render",
|
63 | value: function render() {
|
64 | var _props = this.props,
|
65 | disabled = _props.disabled,
|
66 | error = _props.error,
|
67 | id = _props.id,
|
68 | label = _props.label,
|
69 | onChange = _props.onChange,
|
70 | placeholder = _props.placeholder,
|
71 | required = _props.required,
|
72 | value = _props.value;
|
73 |
|
74 | return _react2.default.createElement(
|
75 | _FormGroup2.default,
|
76 | { label: label, id: id, error: error, required: required },
|
77 | _react2.default.createElement(_reactRte2.default, { onChange: this.changeThis.bind(this), value: this.state.value })
|
78 | );
|
79 | }
|
80 | }, {
|
81 | key: "updateStateFromProps",
|
82 | value: function updateStateFromProps(props) {
|
83 | var value = null;
|
84 | if (props.value) {
|
85 | value = _reactRte2.default.createValueFromString(props.value, "markdown");
|
86 | } else {
|
87 | value = _reactRte2.default.createEmptyValue();
|
88 | }
|
89 | this.state = {
|
90 | value: value
|
91 | };
|
92 | }
|
93 | }]);
|
94 |
|
95 | return TextAreaFormGroup;
|
96 | }(_react2.default.Component);
|
97 |
|
98 | exports.default = TextAreaFormGroup; |
\ | No newline at end of file |