@shopgate/pwa-common
Version:
Common library for the Shopgate Connect PWA.
64 lines (63 loc) • 1.53 kB
JavaScript
import _createClass from "@babel/runtime/helpers/createClass";
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import style from "./style";
/**
* The button component.
*/
import { jsx as _jsx } from "react/jsx-runtime";
let Button = /*#__PURE__*/function (_Component) {
function Button() {
return _Component.apply(this, arguments) || this;
}
_inheritsLoose(Button, _Component);
var _proto = Button.prototype;
/**
* Renders the component.
* @returns {JSX.Element}
*/
_proto.render = function render() {
return (
/*#__PURE__*/
// eslint-disable-next-line react/button-has-type
_jsx("button", {
"data-test-id": this.props.testId,
...this.buttonProps,
children: this.props.children
})
);
};
return _createClass(Button, [{
key: "buttonProps",
get:
/**
* Getter for the calculated button props.
* @returns {Object}
*/
function () {
const {
children,
testId,
className,
disabled,
onClick,
...props
} = this.props;
const buttonProps = {
className: `${className} ${style} common__button`,
disabled,
onClick: disabled ? null : onClick,
...props
};
return buttonProps;
}
}]);
}(Component);
Button.defaultProps = {
className: '',
disabled: false,
onClick: null,
testId: 'Button'
};
export default Button;