@jdcfe/yep-react
Version:
一套移动端的React组件库
80 lines (70 loc) • 3.32 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _inherits from "@babel/runtime/helpers/inherits";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
import * as React from 'react';
import classNames from 'classnames';
import ButtonGroup from './ButtonGroup';
import TouchFeedback from '../touch-feedback';
var Button = /*#__PURE__*/function (_React$PureComponent) {
_inherits(Button, _React$PureComponent);
var _super = _createSuper(Button);
function Button() {
_classCallCheck(this, Button);
return _super.apply(this, arguments);
}
_createClass(Button, [{
key: "render",
value: function render() {
var _this$props = this.props,
prefixCls = _this$props.prefixCls,
className = _this$props.className,
type = _this$props.type,
submit = _this$props.submit,
disabled = _this$props.disabled,
onClick = _this$props.onClick,
inline = _this$props.inline,
style = _this$props.style,
size = _this$props.size,
activeStyle = _this$props.activeStyle,
activeClassName = _this$props.activeClassName,
children = _this$props.children;
var El = submit ? 'button' : 'a';
var cls = classNames(prefixCls, className, {
'btn-primary': type === 'primary',
'btn-disabled': disabled,
'btn-ghost': type === 'ghost',
'btn-inline': !!inline,
'btn-sm': size === 'sm',
'btn-md': size === 'md'
});
return /*#__PURE__*/React.createElement(TouchFeedback // tslint:disable-next-line:jsx-no-multiline-js
, {
activeClassName: activeClassName || (activeStyle ? "".concat(prefixCls, "-active") : undefined),
disabled: disabled,
activeStyle: activeStyle
}, /*#__PURE__*/React.createElement(El, _extends({
className: cls,
"aria-disabled": disabled,
onClick: disabled ? undefined : onClick,
style: style
}, submit ? {
type: 'submit'
} : {}), children));
}
}]);
return Button;
}(React.PureComponent);
export { Button as default };
Button.ButtonGroup = ButtonGroup;
Button.defaultProps = {
prefixCls: 'Yep-btn',
disabled: false,
activeStyle: {},
onClick: function onClick() {}
};
Button.ButtonGroup = ButtonGroup;