"use strict";

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

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

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

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

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

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

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

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

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

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

var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));

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

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

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

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }

var PartialScoringConfig = /*#__PURE__*/function (_React$Component) {
  (0, _inherits2["default"])(PartialScoringConfig, _React$Component);

  var _super = _createSuper(PartialScoringConfig);

  function PartialScoringConfig(props) {
    var _this;

    (0, _classCallCheck2["default"])(this, PartialScoringConfig);
    _this = _super.call(this, props);
    (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
      checked: false
    });
    (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onCheckboxChanged", function () {
      var checked = !_this.state.checked;
      var onChange = _this.props.onChange;

      _this.setState({
        checked: checked
      });

      onChange(checked);
    });
    var partialScoring = props.partialScoring;
    _this.state.checked = partialScoring;
    return _this;
  }

  (0, _createClass2["default"])(PartialScoringConfig, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
          classes = _this$props.classes,
          label = _this$props.label;
      var checked = this.state.checked;
      var textLabel = label || 'Each correct response is worth 1/X where X is the number of correct answer selections.';
      return /*#__PURE__*/_react["default"].createElement("div", {
        className: classes.scoringConfig
      }, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
        type: "subheading"
      }, "Partial Scoring Rules"), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement(_Typography["default"], null, textLabel), /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
        checked: checked,
        onChange: this.onCheckboxChanged,
        label: ''
      }));
    }
  }]);
  return PartialScoringConfig;
}(_react["default"].Component);

exports.PartialScoringConfig = PartialScoringConfig;
(0, _defineProperty2["default"])(PartialScoringConfig, "propTypes", {
  label: _propTypes["default"].string,
  partialScoring: _propTypes["default"].bool,
  classes: _propTypes["default"].object.isRequired,
  onChange: _propTypes["default"].func
});

var _default = (0, _styles.withStyles)(function (theme) {
  return {
    scoringConfig: {
      paddingTop: theme.spacing.unit
    }
  };
})(PartialScoringConfig);

exports["default"] = _default;
//# sourceMappingURL=index.js.map