"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.InputSwitch = exports.InputRadio = exports.InputCheckbox = void 0;

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _Checkbox = _interopRequireDefault(require("@material-ui/core/Checkbox"));

var _Radio = _interopRequireDefault(require("@material-ui/core/Radio"));

var _renderUi = require("../render-ui");

var _propTypes = _interopRequireDefault(require("prop-types"));

var _react = _interopRequireDefault(require("react"));

var _Switch = _interopRequireDefault(require("@material-ui/core/Switch"));

var _styles = require("@material-ui/core/styles");

var _classnames = _interopRequireDefault(require("classnames"));

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

var InputTypes = {
  classes: _propTypes["default"].object.isRequired,
  className: _propTypes["default"].string,
  label: _propTypes["default"].string,
  checked: _propTypes["default"].bool,
  onChange: _propTypes["default"].func,
  disabled: _propTypes["default"].bool,
  error: _propTypes["default"].string
};

var RawInputSwitch = function RawInputSwitch(_ref) {
  var classes = _ref.classes,
      className = _ref.className,
      label = _ref.label,
      checked = _ref.checked,
      onChange = _ref.onChange;
  return /*#__PURE__*/_react["default"].createElement(_renderUi.InputContainer, {
    className: className,
    label: label
  }, /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
    className: classes.switchRoot,
    checked: checked,
    onChange: onChange,
    "aria-label": label
  }));
};

RawInputSwitch.propTypes = _objectSpread({}, InputTypes);
var InputSwitch = (0, _styles.withStyles)({
  switchRoot: {
    justifyContent: 'inherit',
    transform: 'translate(-20%, 20%)'
  }
})(RawInputSwitch);
exports.InputSwitch = InputSwitch;

var RawInputCheckbox = function RawInputCheckbox(props) {
  var classes = props.classes,
      className = props.className,
      label = props.label,
      checked = props.checked,
      onChange = props.onChange,
      disabled = props.disabled,
      error = props.error;
  return /*#__PURE__*/_react["default"].createElement(_renderUi.InputContainer, {
    className: className,
    label: label
  }, /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
    className: (0, _classnames["default"])(classes.checkboxRoot, error && classes.error),
    disabled: disabled,
    checked: checked,
    onChange: onChange,
    "aria-label": label
  }));
};

RawInputCheckbox.propTypes = _objectSpread({}, InputTypes);

var RawInputRadio = function RawInputRadio(props) {
  var classes = props.classes,
      className = props.className,
      label = props.label,
      checked = props.checked,
      onChange = props.onChange,
      disabled = props.disabled,
      error = props.error;
  return /*#__PURE__*/_react["default"].createElement(_renderUi.InputContainer, {
    className: className,
    label: label
  }, /*#__PURE__*/_react["default"].createElement(_Radio["default"], {
    className: (0, _classnames["default"])(classes.radioRoot, error && classes.error),
    disabled: disabled,
    checked: checked,
    onChange: onChange,
    "aria-label": label
  }));
};

RawInputRadio.propTypes = _objectSpread({}, InputTypes);
var InputCheckbox = (0, _styles.withStyles)(function (theme) {
  return {
    checkboxRoot: {
      transform: 'translate(-25%, 20%)'
    },
    error: {
      color: theme.palette.error.main
    }
  };
})(RawInputCheckbox);
exports.InputCheckbox = InputCheckbox;
var InputRadio = (0, _styles.withStyles)(function (theme) {
  return {
    radioRoot: {
      transform: 'translate(-20%, 20%)'
    },
    error: {
      color: theme.palette.error.main
    }
  };
})(RawInputRadio);
exports.InputRadio = InputRadio;
//# sourceMappingURL=inputs.js.map