import _extends from "@babel/runtime/helpers/extends";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _inherits from "@babel/runtime/helpers/inherits";
import _createSuper from "@babel/runtime/helpers/createSuper";
var _excluded = ["prefixCls", "className", "checked"];
import React, { Component } from 'react';
import classNames from 'classnames';
import ConfigContext from '../config-provider/ConfigContext';

var CheckableTag = /*#__PURE__*/function (_Component) {
  _inherits(CheckableTag, _Component);

  var _super = _createSuper(CheckableTag);

  function CheckableTag() {
    var _this;

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

  _createClass(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 = _objectWithoutProperties(_this$props2, _excluded);

      var getPrefixCls = this.context.getPrefixCls;
      var prefixCls = getPrefixCls('tag', customizePrefixCls);
      var cls = classNames(prefixCls, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-checkable"), true), _defineProperty(_classNames, "".concat(prefixCls, "-checkable-checked"), checked), _classNames), className);
      delete restProps.onChange; // TypeScript cannot check delete now.

      return /*#__PURE__*/React.createElement("div", _extends({}, restProps, {
        className: cls,
        onClick: this.handleClick
      }));
    }
  }], [{
    key: "contextType",
    get: function get() {
      return ConfigContext;
    }
  }]);

  return CheckableTag;
}(Component);

export { CheckableTag as default };
CheckableTag.displayName = 'CheckableTag';
//# sourceMappingURL=CheckableTag.js.map
