import _extends from "@babel/runtime/helpers/extends";
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import React, { Component } from 'react';
import "./index.scss";

// export type ShakeProps = {}
var Shake = /*#__PURE__*/function (_Component) {
  _inheritsLoose(Shake, _Component);
  function Shake() {
    return _Component.apply(this, arguments) || this;
  }
  var _proto = Shake.prototype;
  _proto.render = function render() {
    var _this = this,
      _this$state,
      _this$state2;
    var _this$props = this.props,
      style = _this$props.style,
      btnText = _this$props.btnText,
      btnFn = _this$props.btnFn;
    var btnClick = function btnClick() {
      _this.setState({
        isShake: true
      });
      setTimeout(function () {
        btnFn();
        _this.setState({
          isShake: false
        });
      }, 6000 * Math.random());
    };
    return /*#__PURE__*/React.createElement("div", {
      className: "shake"
    }, /*#__PURE__*/React.createElement("div", _extends({
      className: "shake-component"
    }, style), /*#__PURE__*/React.createElement("div", {
      className: "shake-img-warp " + ((_this$state = this.state) !== null && _this$state !== void 0 && _this$state.isShake ? 'shake-ing' : '')
    }, /*#__PURE__*/React.createElement("img", {
      src: "https://img.maimairen.com/low-code/components/shake/shake-it.png",
      className: "shake-icon " + ((_this$state2 = this.state) !== null && _this$state2 !== void 0 && _this$state2.isShake ? 'shake-ing' : ''),
      alt: "\u6447\u4E00\u6447"
    }))), /*#__PURE__*/React.createElement("div", {
      className: "shake-button",
      onClick: btnClick
    }, btnText));
  };
  return Shake;
}(Component);
export { Shake as default };