'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }

var inherits = require('../inherits-c86d64c1.js');
var React = require('react');
var React__default = _interopDefault(React);
require('react-dom');
var Modal = require('../Modal/index.js');
var styleInject_es = require('../style-inject.es-dcee06b6.js');
require('../defineProperty-ba7cd53d.js');
require('../index-1143667e.js');
require('antd');
var WantedPublishView = require('../WantedPublishView/index.js');
var WantedPublish = require('../WantedPublish-761aab8e.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_es.styleInject(css);

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

  function WantedPublishModal(props) {
    var _this;

    inherits._classCallCheck(this, WantedPublishModal);

    _this = inherits._possibleConstructorReturn(this, inherits._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;
  }

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

      var current_wanted = this.state.current_wanted;
      return React__default.createElement(WantedPublishView.default, 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__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
        onClick: function onClick() {
          return _this3.setState({
            modalVisible: true
          });
        }
      }, this.props.children), React__default.createElement(Modal.default, Object.assign({
        visible: this.state.modalVisible,
        onCancel: function onCancel() {
          _this3.setState({
            modalVisible: false
          });
        }
      }, this.props.modalConfig), this.renderMain()));
    }
  }]);

  return WantedPublishModal;
}(WantedPublish.WatnedPublishBase);

exports.WantedPublishModal = WantedPublishModal;
exports.default = WantedPublishModal;
//# sourceMappingURL=index.js.map
