"use strict";

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

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

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

var _reactImmutableProptypes = _interopRequireDefault(require("react-immutable-proptypes"));

var _react2 = require("@emotion/react");

var _ui = require("../../ui");

const _excluded = ["isActive"];

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

function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

function BooleanBackground(_ref) {
  let {
    isActive
  } = _ref,
      props = _objectWithoutProperties(_ref, _excluded);

  return (0, _react2.jsx)(_ui.ToggleBackground, _extends({
    css: /*#__PURE__*/(0, _react2.css)("background-color:", isActive ? _ui.colors.active : _ui.colors.textFieldBorder, ";;label:BooleanBackground;" + (process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy93aWRnZXRzL2Jvb2xlYW4vQm9vbGVhbkNvbnRyb2wuanMiXSwibmFtZXMiOltdLCJtYXBwaW5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cbiAgICAgICAgICBpZD17Zm9ySUR9XG4gICAgICAgICAgYWN0aXZlPXt2YWx1ZX1cbiAgICAgICAgICBvbkNoYW5nZT17b25DaGFuZ2V9XG4gICAgICAgICAgb25Gb2N1cz17c2V0QWN0aXZlU3R5bGV9XG4gICAgICAgICAgb25CbHVyPXtzZXRJbmFjdGl2ZVN0eWxlfVxuICAgICAgICAgIEJhY2tncm91bmQ9e0Jvb2xlYW5CYWNrZ3JvdW5kfVxuICAgICAgICAvPlxuICAgICAgPC9kaXY+XG4gICAgKTtcbiAgfVxufVxuXG5Cb29sZWFuQ29udHJvbC5wcm9wVHlwZXMgPSB7XG4gIGZpZWxkOiBJbW11dGFibGVQcm9wVHlwZXMubWFwLmlzUmVxdWlyZWQsXG4gIG9uQ2hhbmdlOiBQcm9wVHlwZXMuZnVuYy5pc1JlcXVpcmVkLFxuICBjbGFzc05hbWVXcmFwcGVyOiBQcm9wVHlwZXMuc3RyaW5nLmlzUmVxdWlyZWQsXG4gIHNldEFjdGl2ZVN0eWxlOiBQcm9wVHlwZXMuZnVuYy5pc1JlcXVpcmVkLFxuICBzZXRJbmFjdGl2ZVN0eWxlOiBQcm9wVHlwZXMuZnVuYy5pc1JlcXVpcmVkLFxuICBmb3JJRDogUHJvcFR5cGVzLnN0cmluZyxcbiAgdmFsdWU6IFByb3BUeXBlcy5ib29sLFxufTtcblxuQm9vbGVhbkNvbnRyb2wuZGVmYXVsdFByb3BzID0ge1xuICB2YWx1ZTogZmFsc2UsXG59O1xuIl19 */"))
  }, props));
}

class BooleanControl extends _react.default.Component {
  render() {
    const {
      value,
      forID,
      onChange,
      classNameWrapper,
      setActiveStyle,
      setInactiveStyle
    } = this.props;
    return (0, _react2.jsx)("div", {
      className: classNameWrapper
    }, (0, _react2.jsx)(_ui.Toggle, {
      id: forID,
      active: value,
      onChange: onChange,
      onFocus: setActiveStyle,
      onBlur: setInactiveStyle,
      Background: BooleanBackground
    }));
  }

}

exports.default = BooleanControl;
BooleanControl.propTypes = {
  field: _reactImmutableProptypes.default.map.isRequired,
  onChange: _propTypes.default.func.isRequired,
  classNameWrapper: _propTypes.default.string.isRequired,
  setActiveStyle: _propTypes.default.func.isRequired,
  setInactiveStyle: _propTypes.default.func.isRequired,
  forID: _propTypes.default.string,
  value: _propTypes.default.bool
};
BooleanControl.defaultProps = {
  value: false
};