1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | var _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; };
|
8 |
|
9 | 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; }; }();
|
10 |
|
11 | var _react = require('react');
|
12 |
|
13 | var _react2 = _interopRequireDefault(_react);
|
14 |
|
15 | var _propTypes = require('prop-types');
|
16 |
|
17 | var _propTypes2 = _interopRequireDefault(_propTypes);
|
18 |
|
19 | var _index = require('./index');
|
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 TextAreaRedux = function (_Component) {
|
30 | _inherits(TextAreaRedux, _Component);
|
31 |
|
32 | function TextAreaRedux(props) {
|
33 | _classCallCheck(this, TextAreaRedux);
|
34 |
|
35 | var _this = _possibleConstructorReturn(this, (TextAreaRedux.__proto__ || Object.getPrototypeOf(TextAreaRedux)).call(this, props));
|
36 |
|
37 | _this.state = { textareaVal: '' };
|
38 | return _this;
|
39 | }
|
40 |
|
41 | _createClass(TextAreaRedux, [{
|
42 | key: 'render',
|
43 | value: function render() {
|
44 | var _this2 = this;
|
45 |
|
46 | return _react2.default.createElement(
|
47 | _index.TextAreaStyled,
|
48 | {
|
49 | isValid: this.props.isValid,
|
50 | isInvalid: this.props.isInvalid,
|
51 | textSize: this.props.textSize
|
52 | },
|
53 | _react2.default.createElement(
|
54 | _index.Button,
|
55 | {
|
56 | buttonLink: true,
|
57 | success: true,
|
58 | inline: true,
|
59 | small: true,
|
60 | onClick: function onClick() {
|
61 | var textVal = _this2.textAreaRedux;
|
62 | var cursorStart = textVal.selectionStart;
|
63 | var cursorEnd = textVal.selectionEnd;
|
64 | var text = _this2.state.textareaVal;
|
65 | _this2.setState({
|
66 | textareaVal: text.substr(0, cursorStart) + '***' + text.substr(cursorStart, cursorEnd - cursorStart) + '***' + text.substr(cursorEnd)
|
67 | });
|
68 | }
|
69 | },
|
70 | 'Bold'
|
71 | ),
|
72 | _react2.default.createElement(
|
73 | 'label',
|
74 | { htmlFor: this.props.input.name },
|
75 | this.props.label
|
76 | ),
|
77 | _react2.default.createElement('textarea', _extends({}, this.props.input, {
|
78 | ref: function ref(c) {
|
79 | _this2.textAreaRedux = c;
|
80 | },
|
81 | value: this.state.textareaVal,
|
82 | onChange: function onChange(event) {
|
83 | _this2.setState({
|
84 | textareaVal: event.target.value
|
85 | });
|
86 | }
|
87 | }))
|
88 | );
|
89 | }
|
90 | }]);
|
91 |
|
92 | return TextAreaRedux;
|
93 | }(_react.Component);
|
94 |
|
95 | exports.default = TextAreaRedux;
|
96 |
|
97 |
|
98 | TextAreaRedux.defaultProps = {
|
99 | name: '',
|
100 | label: '',
|
101 | input: {},
|
102 | isValid: false,
|
103 | isInvalid: false,
|
104 | textSize: '16px'
|
105 | };
|
106 |
|
107 | TextAreaRedux.propTypes = {
|
108 | name: _propTypes2.default.string,
|
109 | label: _propTypes2.default.string,
|
110 | input: _propTypes2.default.object,
|
111 | isValid: _propTypes2.default.bool,
|
112 | isInvalid: _propTypes2.default.bool,
|
113 | textSize: _propTypes2.default.string
|
114 | }; |
\ | No newline at end of file |