shineout
Version:
Shein 前端组件库
52 lines (42 loc) • 1.6 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
import React, { PureComponent } from 'react';
import Button from '../Button';
var Submit =
/*#__PURE__*/
function (_PureComponent) {
_inheritsLoose(Submit, _PureComponent);
function Submit(props) {
var _this;
_this = _PureComponent.call(this, props) || this;
_this.handleClick = _this.handleClick.bind(_assertThisInitialized(_assertThisInitialized(_this)));
return _this;
}
var _proto = Submit.prototype;
_proto.handleClick = function handleClick(e) {
var _this2 = this;
e.persist();
setTimeout(function () {
if (_this2.props.onSubmit) _this2.props.onSubmit(e.target);
}, 50);
};
_proto.render = function render() {
var _this$props = this.props,
onSubmit = _this$props.onSubmit,
loading = _this$props.loading,
children = _this$props.children,
formStatus = _this$props.formStatus,
other = _objectWithoutPropertiesLoose(_this$props, ["onSubmit", "loading", "children", "formStatus"]);
return React.createElement(Button, _extends({
type: "primary"
}, other, {
disabled: other.disabled || formStatus === 'disabled',
loading: formStatus === 'pending' || loading,
onClick: this.handleClick
}), children);
};
return Submit;
}(PureComponent);
export default Submit;