'use strict';

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;
};

var React = require('react');
var blacklist = require('blacklist');
var classNames = require('classnames');

var NOTE_TYPES = ['default', 'primary', 'success', 'warning', 'danger'];

module.exports = React.createClass({
	displayName: 'FormNote',
	propTypes: {
		className: React.PropTypes.string,
		note: React.PropTypes.string,
		type: React.PropTypes.oneOf(NOTE_TYPES)
	},
	getDefaultProps: function getDefaultProps() {
		return {
			type: 'default'
		};
	},
	render: function render() {
		// classes
		var componentClass = classNames('FormNote', this.props.type ? 'FormNote--' + this.props.type : null, this.props.className);

		// props
		var props = blacklist(this.props, 'className', 'note', 'type');

		// allow users to pass through the note as an attribute or as children
		return React.createElement('div', _extends({ className: componentClass, dangerouslySetInnerHTML: this.props.note ? { __html: this.props.note } : null }, props), this.props.children);
	}
});