"use strict";

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

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

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

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

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 _icon = _interopRequireDefault(require("../icon"));

var _input = _interopRequireDefault(require("../input"));

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

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

  function Search() {
    var _this;

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

    _this.handleChange = function (e) {
      var onChange = _this.props.onChange;

      if (onChange) {
        onChange(e);
      }
    };

    _this.handleClear = function (e) {
      e.preventDefault();
      var handleClear = _this.props.handleClear;

      if (handleClear) {
        handleClear(e);
      }
    };

    return _this;
  }

  (0, _createClass2["default"])(Search, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
          placeholder = _this$props.placeholder,
          value = _this$props.value,
          prefixCls = _this$props.prefixCls,
          inputProps = _this$props.inputProps;
      var icon = value && value.length > 0 ? /*#__PURE__*/_react["default"].createElement("a", {
        href: "#",
        className: "".concat(prefixCls, "-action"),
        onClick: this.handleClear
      }, /*#__PURE__*/_react["default"].createElement(_icon["default"], {
        type: "cross-circle"
      })) : /*#__PURE__*/_react["default"].createElement("span", {
        className: "".concat(prefixCls, "-action")
      }, /*#__PURE__*/_react["default"].createElement(_icon["default"], {
        type: "search"
      }));
      return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_input["default"], (0, _extends2["default"])({}, inputProps, {
        placeholder: placeholder,
        className: prefixCls,
        value: value,
        onChange: this.handleChange
      })), icon);
    }
  }]);
  return Search;
}(_react.Component);

exports["default"] = Search;
Search.displayName = 'TransferSearch';
Search.defaultProps = {
  placeholder: ''
};
//# sourceMappingURL=search.js.map
