"use strict";

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

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];

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

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

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

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

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

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

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

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

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

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

var _ConfigContext = _interopRequireDefault(require("../config-provider/ConfigContext"));

var _excluded = ["prefixCls", "className", "checked"];

var CheckableTag = /*#__PURE__*/function (_Component) {
  (0, _inherits2["default"])(CheckableTag, _Component);

  var _super = (0, _createSuper2["default"])(CheckableTag);

  function CheckableTag() {
    var _this;

    (0, _classCallCheck2["default"])(this, CheckableTag);
    _this = _super.apply(this, arguments);

    _this.handleClick = function () {
      var _this$props = _this.props,
          checked = _this$props.checked,
          onChange = _this$props.onChange;

      if (onChange) {
        onChange(!checked);
      }
    };

    return _this;
  }

  (0, _createClass2["default"])(CheckableTag, [{
    key: "render",
    value: function render() {
      var _classNames;

      var _this$props2 = this.props,
          customizePrefixCls = _this$props2.prefixCls,
          className = _this$props2.className,
          checked = _this$props2.checked,
          restProps = (0, _objectWithoutProperties2["default"])(_this$props2, _excluded);
      var getPrefixCls = this.context.getPrefixCls;
      var prefixCls = getPrefixCls('tag', customizePrefixCls);
      var cls = (0, _classnames["default"])(prefixCls, (_classNames = {}, (0, _defineProperty2["default"])(_classNames, "".concat(prefixCls, "-checkable"), true), (0, _defineProperty2["default"])(_classNames, "".concat(prefixCls, "-checkable-checked"), checked), _classNames), className);
      delete restProps.onChange; // TypeScript cannot check delete now.

      return /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({}, restProps, {
        className: cls,
        onClick: this.handleClick
      }));
    }
  }], [{
    key: "contextType",
    get: function get() {
      return _ConfigContext["default"];
    }
  }]);
  return CheckableTag;
}(_react.Component);

exports["default"] = CheckableTag;
CheckableTag.displayName = 'CheckableTag';
//# sourceMappingURL=CheckableTag.js.map
