"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _input = _interopRequireDefault(require("@alifd/next/lib/input"));
var _icon = _interopRequireDefault(require("@alifd/next/lib/icon"));
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
var _react = _interopRequireDefault(require("react"));
require("./index.scss");
var _variables = require("../../variables");
//参照框
var CommonRefer = /*#__PURE__*/function (_React$Component) {
  (0, _inheritsLoose2["default"])(CommonRefer, _React$Component);
  function CommonRefer(props) {
    var _this;
    _this = _React$Component.call(this, props) || this;
    _this.change = function (val) {
      var onChange = _this.props.onChange;
      _this.setState({
        hotValue: val
      });
      onChange && onChange(val);
    };
    //点击图标
    _this.onClick = function () {
      var showReferPage = _this.props.showReferPage;
      showReferPage();
    };
    _this.state = {
      hotValue: props.value
    };
    // console.log(props.showReferPage())
    return _this;
  }
  var _proto = CommonRefer.prototype;
  _proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState, snapshot) {
    if (prevProps.value != this.props.value) {
      this.setState({
        hotValue: this.props.value
      });
    }
  };
  _proto.render = function render() {
    var _this2 = this;
    var defaultValue = this.props.defaultValue;
    return /*#__PURE__*/_react["default"].createElement(_input["default"], {
      className: _variables.bizCssPrefix + '-common-refer',
      innerAfter: /*#__PURE__*/_react["default"].createElement("span", {
        onClick: function onClick() {
          _this2.onClick();
        }
      }, /*#__PURE__*/_react["default"].createElement(_icon["default"], {
        className: "list-icon",
        type: "list"
      })),
      defaultValue: defaultValue,
      value: this.state.hotValue,
      readOnly: true,
      onChange: function onChange(val) {
        _this2.change(val);
      }
    });
  };
  return CommonRefer;
}(_react["default"].Component);
CommonRefer.displayName = 'CommonRefer';
var _default = CommonRefer;
exports["default"] = _default;