@bigfishtv/cockpit
Version:
60 lines (48 loc) • 2.37 kB
JavaScript
var _class, _temp;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
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; }
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; }
import React, { Component } from 'react';
import { titleCase } from '../utils/stringUtils';
var StopShouting = (_temp = _class = function (_Component) {
_inherits(StopShouting, _Component);
function StopShouting() {
_classCallCheck(this, StopShouting);
return _possibleConstructorReturn(this, _Component.apply(this, arguments));
}
StopShouting.prototype.render = function render() {
var _props = this.props,
value = _props.value,
onChange = _props.onChange;
var uppercase = typeof value == 'string' && value.match(/[A-Z]/) && value.indexOf(' ') >= 0 && value.toUpperCase() == value && titleCase(value) != value;
if (!uppercase) return null;
return React.createElement(
'div',
{ className: 'alert warning', style: { height: 35, marginBottom: 15 } },
React.createElement(
'div',
{ className: 'alert-content' },
React.createElement(
'div',
{ className: 'alert-message gutter-left' },
'Please don\'t shout at me',
' ',
React.createElement(
'button',
{ className: 'button button-small', type: 'button', onClick: function onClick(e) {
return onChange(titleCase(value));
} },
'OK, I\'m sorry'
)
)
)
);
};
return StopShouting;
}(Component), _class.defaultProps = {
value: '',
onChange: function onChange() {
return console.warn('No onChange prop provided for TitleCaseHelper');
}
}, _temp);
export { StopShouting as default };