glints-aries 4.0.379 → 4.0.380

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
- var _excluded = ["children", "icon", "iconPosition", "active", "fullWidth", "loading"];
3
+ var _excluded = ["children", "icon", "iconPosition", "active", "fullWidth", "loading", "disabled", "onClick"];
4
4
  import React from 'react';
5
5
  import { Spinner } from '../Spinner/Spinner';
6
6
  import { Typography } from '../Typography';
@@ -13,6 +13,8 @@ export var Button = /*#__PURE__*/React.forwardRef(function Button(_ref, ref) {
13
13
  active = _ref.active,
14
14
  fullWidth = _ref.fullWidth,
15
15
  loading = _ref.loading,
16
+ disabled = _ref.disabled,
17
+ onClick = _ref.onClick,
16
18
  otherProps = _objectWithoutPropertiesLoose(_ref, _excluded);
17
19
  var content = typeof children === 'string' ? /*#__PURE__*/React.createElement(Typography, {
18
20
  variant: "button"
@@ -23,6 +25,15 @@ export var Button = /*#__PURE__*/React.forwardRef(function Button(_ref, ref) {
23
25
  }
24
26
  return null;
25
27
  };
28
+ var onClickHandler = function onClickHandler() {
29
+ if (loading || disabled) {
30
+ return;
31
+ }
32
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
33
+ args[_key] = arguments[_key];
34
+ }
35
+ return onClick == null ? void 0 : onClick.apply(void 0, args);
36
+ };
26
37
  return /*#__PURE__*/React.createElement(StyledButton, _extends({
27
38
  ref: ref,
28
39
  "data-active": active,
@@ -32,6 +43,8 @@ export var Button = /*#__PURE__*/React.forwardRef(function Button(_ref, ref) {
32
43
  }, otherProps, {
33
44
  onMouseUp: function onMouseUp(e) {
34
45
  return e.currentTarget.blur();
35
- }
46
+ },
47
+ onClick: onClickHandler,
48
+ disabled: disabled
36
49
  }), loading && /*#__PURE__*/React.createElement(Spinner, null), renderIcon('left'), content, renderIcon('right'));
37
50
  });
@@ -9,7 +9,7 @@ var _react = _interopRequireDefault(require("react"));
9
9
  var _Spinner = require("../Spinner/Spinner");
10
10
  var _Typography = require("../Typography");
11
11
  var _ButtonStyle = require("./ButtonStyle");
12
- var _excluded = ["children", "icon", "iconPosition", "active", "fullWidth", "loading"];
12
+ var _excluded = ["children", "icon", "iconPosition", "active", "fullWidth", "loading", "disabled", "onClick"];
13
13
  var Button = /*#__PURE__*/_react["default"].forwardRef(function Button(_ref, ref) {
14
14
  var children = _ref.children,
15
15
  icon = _ref.icon,
@@ -18,6 +18,8 @@ var Button = /*#__PURE__*/_react["default"].forwardRef(function Button(_ref, ref
18
18
  active = _ref.active,
19
19
  fullWidth = _ref.fullWidth,
20
20
  loading = _ref.loading,
21
+ disabled = _ref.disabled,
22
+ onClick = _ref.onClick,
21
23
  otherProps = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
22
24
  var content = typeof children === 'string' ? /*#__PURE__*/_react["default"].createElement(_Typography.Typography, {
23
25
  variant: "button"
@@ -28,6 +30,15 @@ var Button = /*#__PURE__*/_react["default"].forwardRef(function Button(_ref, ref
28
30
  }
29
31
  return null;
30
32
  };
33
+ var onClickHandler = function onClickHandler() {
34
+ if (loading || disabled) {
35
+ return;
36
+ }
37
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
38
+ args[_key] = arguments[_key];
39
+ }
40
+ return onClick == null ? void 0 : onClick.apply(void 0, args);
41
+ };
31
42
  return /*#__PURE__*/_react["default"].createElement(_ButtonStyle.StyledButton, (0, _extends2["default"])({
32
43
  ref: ref,
33
44
  "data-active": active,
@@ -37,7 +48,9 @@ var Button = /*#__PURE__*/_react["default"].forwardRef(function Button(_ref, ref
37
48
  }, otherProps, {
38
49
  onMouseUp: function onMouseUp(e) {
39
50
  return e.currentTarget.blur();
40
- }
51
+ },
52
+ onClick: onClickHandler,
53
+ disabled: disabled
41
54
  }), loading && /*#__PURE__*/_react["default"].createElement(_Spinner.Spinner, null), renderIcon('left'), content, renderIcon('right'));
42
55
  });
43
56
  exports.Button = Button;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glints-aries",
3
- "version": "4.0.379",
3
+ "version": "4.0.380",
4
4
  "description": "Glints ui-kit for frontend",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./es/index.js",