import _Input from "@alifd/next/es/input";
import _Icon from "@alifd/next/es/icon";
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import React from 'react';
import "./index.scss";
import { bizCssPrefix } from "../../variables";
//参照框
var CommonRefer = /*#__PURE__*/function (_React$Component) {
  _inheritsLoose(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.createElement(_Input, {
      className: bizCssPrefix + '-common-refer',
      innerAfter: /*#__PURE__*/React.createElement("span", {
        onClick: function onClick() {
          _this2.onClick();
        }
      }, /*#__PURE__*/React.createElement(_Icon, {
        className: "list-icon",
        type: "list"
      })),
      defaultValue: defaultValue,
      value: this.state.hotValue,
      readOnly: true,
      onChange: function onChange(val) {
        _this2.change(val);
      }
    });
  };
  return CommonRefer;
}(React.Component);
CommonRefer.displayName = 'CommonRefer';
export default CommonRefer;