UNPKG

2.92 kBJavaScriptView Raw
1'use strict';
2
3var _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; }; }();
4
5function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7function _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; }
8
9function _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; }
10
11var React = require('react');
12var PropTypes = require('prop-types');
13
14/**
15 * An input field in a form in a modal.
16 */
17
18var ModalInput = function (_React$PureComponent) {
19 _inherits(ModalInput, _React$PureComponent);
20
21 function ModalInput() {
22 _classCallCheck(this, ModalInput);
23
24 return _possibleConstructorReturn(this, (ModalInput.__proto__ || Object.getPrototypeOf(ModalInput)).apply(this, arguments));
25 }
26
27 _createClass(ModalInput, [{
28 key: 'render',
29
30
31 /**
32 * Render the input.
33 *
34 * @returns {React.Component} The react component.
35 */
36 value: function render() {
37 return React.createElement(
38 'div',
39 { className: 'form-group' },
40 React.createElement(
41 'p',
42 null,
43 this.props.name
44 ),
45 React.createElement('input', {
46 autoFocus: this.props.autoFocus,
47 id: this.props.id,
48 type: 'text',
49 className: 'form-control',
50 onChange: this.props.onChangeHandler,
51 value: this.props.value })
52 );
53 }
54 }]);
55
56 return ModalInput;
57}(React.PureComponent);
58
59ModalInput.displayName = 'ModalInputComponent';
60
61ModalInput.propTypes = {
62 autoFocus: PropTypes.bool,
63 onChangeHandler: PropTypes.func.isRequired,
64 value: PropTypes.string,
65 name: PropTypes.string.isRequired,
66 id: PropTypes.string.isRequired
67};
68
69ModalInput.defaultProps = {
70 autoFocus: false
71};
72
73module.exports = ModalInput;
\No newline at end of file