'use strict';

Object.defineProperty(exports, "__esModule", {
	value: true
});

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/**
 * The Toggle component is basically a fancy checkbox like you have in your iphone.
 * Properties:
 * @param id {string}: the id to be used for htmlFor and maybe QA
 * @param onChange {function}: an event callback called each time the state is changed
 * @param checked {boolean}: sets the state of the toggle to be On or Off
 * @param disabled {boolean}: enables the read-only no-interaction mode
 * @param label {string}: a status label to be shown near toggle
 * @param className {string}: className to be added to root div
 *
 * Required: [ id, onChange ]
 * Defaults: { checked: false, disabled: false, label: '', className: 'switch checkbox' }
 *
 * @return XML(JSX) React pure component
 * **/
function Toggle(_ref) {
	var id = _ref.id,
	    onChange = _ref.onChange,
	    onBlur = _ref.onBlur,
	    label = _ref.label,
	    checked = _ref.checked,
	    disabled = _ref.disabled,
	    className = _ref.className;

	return _react2.default.createElement(
		'div',
		{ className: (0, _classnames2.default)('checkbox tc-toggle', className) },
		_react2.default.createElement(
			'label',
			{ htmlFor: id },
			_react2.default.createElement('input', {
				type: 'checkbox',
				id: id,
				onChange: onChange,
				onBlur: onBlur,
				checked: checked,
				disabled: disabled
			}),
			_react2.default.createElement(
				'span',
				null,
				label
			)
		)
	);
}

Toggle.defaultProps = {
	disabled: false,
	checked: false,
	label: '',
	className: 'switch checkbox'
};

Toggle.propTypes = {
	id: _react.PropTypes.string.isRequired,
	label: _react.PropTypes.string,
	onChange: _react.PropTypes.func.isRequired,
	onBlur: _react.PropTypes.func,
	checked: _react.PropTypes.bool,
	disabled: _react.PropTypes.bool,
	className: _react.PropTypes.string
};

exports.default = Toggle;