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

import './style.scss';

import React from 'react';
import PropTypes from 'prop-types';

/**
 * A simple toggle.
 */
var Toggle = function Toggle(props) {
  var children = props.children,
      className = props.className,
      label = props.label,
      type = props.type;

  var ToggleClasses = ['Toggle', 'Toggle_' + type, className].filter(function (e) {
    return e;
  }).join(' ');

  return React.createElement(
    'label',
    { className: ToggleClasses },
    React.createElement('input', _extends({}, _extends({}, props, { children: null, style: null }), {
      className: 'Toggle-input',
      type: props.type === 'toggle' ? 'checkbox' : props.type
    })),
    React.createElement(
      'div',
      { className: 'Toggle-display' },
      React.createElement('i', { className: 'fa fa-check' })
    ),
    (label || children) && React.createElement(
      'span',
      { className: 'Toggle-label', title: label },
      label || children
    )
  );
};

Toggle.propTypes = process.env.NODE_ENV !== "production" ? {
  className: PropTypes.string,
  label: PropTypes.string,
  type: PropTypes.oneOf(['checkbox', 'radio', 'toggle']),
  value: PropTypes.any
} : {};

Toggle.defaultProps = {
  type: 'checkbox'
};

export default Toggle;