1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports["default"] = void 0;
|
7 |
|
8 | var _react = _interopRequireDefault(require("react"));
|
9 |
|
10 | var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
|
11 |
|
12 | var _CircularProgress = _interopRequireDefault(require("@material-ui/core/CircularProgress"));
|
13 |
|
14 | var _withStyles = _interopRequireDefault(require("@material-ui/core/styles/withStyles"));
|
15 |
|
16 | var _classnames = _interopRequireDefault(require("classnames"));
|
17 |
|
18 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
19 |
|
20 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
21 |
|
22 | function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
23 |
|
24 | function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
25 |
|
26 | function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
27 |
|
28 | function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
29 |
|
30 | var CustomButtonJSX = function CustomButtonJSX(_ref) {
|
31 | var css = _ref.classes,
|
32 | muiClasses = _ref.muiClasses,
|
33 | _ref$colorType = _ref.colorType,
|
34 | colorType = _ref$colorType === void 0 ? '' : _ref$colorType,
|
35 | _ref$height = _ref.height,
|
36 | height = _ref$height === void 0 ? 'short' : _ref$height,
|
37 | isWidthLimited = _ref.isWidthLimited,
|
38 | isLoading = _ref.isLoading,
|
39 | children = _ref.children,
|
40 | className = _ref.className,
|
41 | disabled = _ref.disabled,
|
42 | rest = _objectWithoutProperties(_ref, ["classes", "muiClasses", "colorType", "height", "isWidthLimited", "isLoading", "children", "className", "disabled"]);
|
43 |
|
44 | var buildProps = {};
|
45 |
|
46 | if (colorType === 'primary') {
|
47 | buildProps.color = 'primary';
|
48 | }
|
49 |
|
50 | return _react["default"].createElement(_Button["default"], _extends({
|
51 | className: (0, _classnames["default"])(css["".concat(colorType, "Button")], css["".concat(height, "Button")], isWidthLimited && css.limitedSizeButton, className),
|
52 | disabled: disabled || isLoading,
|
53 | classes: muiClasses
|
54 | }, rest, buildProps), isLoading && _react["default"].createElement(_CircularProgress["default"], {
|
55 | size: height === 'short' ? 25 : 40,
|
56 | className: css.spinner
|
57 | }), children);
|
58 | };
|
59 |
|
60 | CustomButtonJSX.propTypes = {
|
61 | classes: _propTypes["default"].object.isRequired,
|
62 | muiClasses: _propTypes["default"].object,
|
63 | colorType: _propTypes["default"].oneOf(["primary", "secondary", "tertiary", "error", "success", "yellow", "green", "blue"]),
|
64 | height: _propTypes["default"].oneOf(["tall", "short", "medium"]),
|
65 | isWidthLimited: _propTypes["default"].bool,
|
66 | isLoading: _propTypes["default"].bool,
|
67 | disabled: _propTypes["default"].bool,
|
68 | children: _propTypes["default"].any,
|
69 | className: _propTypes["default"].string
|
70 | };
|
71 | var CustomButton = (0, _withStyles["default"])(function (theme) {
|
72 | return {
|
73 | shortButton: {
|
74 | paddingTop: '0.59rem',
|
75 | paddingBottom: '0.59rem'
|
76 | },
|
77 | mediumButton: {
|
78 | paddingTop: '0.8rem',
|
79 | paddingBottom: '0.8rem'
|
80 | },
|
81 | tallButton: {
|
82 | paddingTop: '1.25rem',
|
83 | paddingBottom: '1.25rem'
|
84 | },
|
85 | secondaryButton: {
|
86 | backgroundColor: theme.palette.secondary.dark,
|
87 | color: '#FFFFFF',
|
88 | '&:hover': {
|
89 | backgroundColor: theme.palette.secondary.main
|
90 | }
|
91 | },
|
92 | tertiaryButton: {
|
93 | backgroundColor: theme.palette.secondary.light,
|
94 | color: theme.palette.secondary.dark
|
95 | },
|
96 | errorButton: {
|
97 | backgroundColor: theme.palette.error.main,
|
98 | color: 'white',
|
99 | '&:hover': {
|
100 | backgroundColor: theme.palette.error.light
|
101 | }
|
102 | },
|
103 | successButton: {
|
104 | backgroundColor: theme.palette.success.light,
|
105 | color: 'white',
|
106 | '&:hover': {
|
107 | backgroundColor: theme.palette.success.main
|
108 | }
|
109 | },
|
110 | greenButton: {
|
111 | backgroundColor: theme.palette.success.main,
|
112 | color: 'white',
|
113 | '&:hover': {
|
114 | backgroundColor: 'rgba(6, 136, 87, 0.8)'
|
115 | }
|
116 | },
|
117 | yellowButton: {
|
118 | backgroundColor: theme.palette.yellow.main,
|
119 | color: 'white',
|
120 | '&:hover': {
|
121 | backgroundColor: theme.palette.yellow.light
|
122 | }
|
123 | },
|
124 | blueButton: {
|
125 | backgroundColor: theme.palette.blue.main,
|
126 | color: 'white',
|
127 | '&:hover': {
|
128 | backgroundColor: 'rgba(100, 149, 237, 0.8)'
|
129 | }
|
130 | },
|
131 | limitedSizeButton: _defineProperty({}, theme.breakpoints.up('sm'), {
|
132 | maxWidth: 350
|
133 | }),
|
134 | spinner: {
|
135 | color: 'inherit',
|
136 | position: 'absolute'
|
137 | }
|
138 | };
|
139 | })(CustomButtonJSX);
|
140 | var _default = CustomButton;
|
141 | exports["default"] = _default; |
\ | No newline at end of file |