import { a as _inherits, b as _classCallCheck, c as _possibleConstructorReturn, d as _getPrototypeOf, e as _createClass } from '../inherits-6cb67931.js';
import React from 'react';
import 'react-dom';
import Modal from '../Modal/index.js';
import { s as styleInject } from '../style-inject.es-1f59c1d0.js';
import '../defineProperty-18999f8e.js';
import '../index-b8d80d39.js';
import 'antd';
import WantedPublishView from '../WantedPublishView/index.js';
import { W as WatnedPublishBase } from '../WantedPublish-b91e67a7.js';

var css = ".WantedPublishModal_modalBg__3OlNh {\n  background: white;\n  display: flex;\n  justify-content: center;\n  flex-direction: column;\n  align-items: center;\n  padding: 16px;\n  text-align: center;\n  border-radius: 4px;\n}\n";
var styles = {
  "modalBg": "WantedPublishModal_modalBg__3OlNh"
};
styleInject(css);

var WantedPublishModal =
/*#__PURE__*/
function (_WatnedPublishBase) {
  _inherits(WantedPublishModal, _WatnedPublishBase);

  function WantedPublishModal(props) {
    var _this;

    _classCallCheck(this, WantedPublishModal);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(WantedPublishModal).call(this, props));

    _this.handleConfirmButton = function (containerRef) {
      var handleConfirm = _this.props.handleConfirm;

      if (handleConfirm) {
        var value = _this.formatCurrentWanted(_this.state.current_wanted);

        handleConfirm(value ? Number(value).toFixed(2) : value);
      }

      _this.setState({
        modalVisible: false
      });
    };

    _this.state = {
      modalVisible: false,
      current_wanted: null
    };
    return _this;
  }

  _createClass(WantedPublishModal, [{
    key: "renderMain",
    value: function renderMain() {
      var _this2 = this;

      var current_wanted = this.state.current_wanted;
      return React.createElement(WantedPublishView, Object.assign({
        wrapperClass: styles.modalBg,
        current_wanted: current_wanted,
        InputWantedValueChange: function InputWantedValueChange(v) {
          return _this2.setState({
            current_wanted: v
          });
        },
        InputWantedPressEnter: function InputWantedPressEnter(v) {
          var value = _this2.formatCurrentWanted(v);

          if (_this2.props.handleConfirm) _this2.props.handleConfirm(_this2.formatResult(value));

          _this2.setState({
            current_wanted: value,
            modalVisible: false
          });
        },
        InputWantedOnBlur: function InputWantedOnBlur(v) {
          var value = _this2.formatCurrentWanted(v);

          _this2.setState({
            current_wanted: value
          });
        },
        InputWantedClear: function InputWantedClear() {
          _this2.setState({
            current_wanted: null
          }, function () {
            if (_this2.props.handleConfirm) _this2.props.handleConfirm(null);

            _this2.setState({
              modalVisible: false
            });
          });
        },
        InputWantedConfirm: this.handleConfirmButton
      }, this.props.viewConfig));
    }
  }, {
    key: "render",
    value: function render() {
      var _this3 = this;

      return React.createElement(React.Fragment, null, React.createElement("div", {
        onClick: function onClick() {
          return _this3.setState({
            modalVisible: true
          });
        }
      }, this.props.children), React.createElement(Modal, Object.assign({
        visible: this.state.modalVisible,
        onCancel: function onCancel() {
          _this3.setState({
            modalVisible: false
          });
        }
      }, this.props.modalConfig), this.renderMain()));
    }
  }]);

  return WantedPublishModal;
}(WatnedPublishBase);

export default WantedPublishModal;
export { WantedPublishModal };
//# sourceMappingURL=index.js.map
