@sb1/ffe-buttons-react 14.0.2 → 14.0.6

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.
@@ -56,12 +56,8 @@ ActionButton.propTypes = {
56
56
  leftIcon: node,
57
57
 
58
58
  /** Icon shown to the right of the label */
59
- rightIcon: node,
60
-
61
- /** Dark variant */
62
- dark: bool
59
+ rightIcon: node
63
60
  };
64
61
  ActionButton.defaultProps = {
65
- ghost: false,
66
- dark: false
62
+ ghost: false
67
63
  };
package/es/BackButton.js CHANGED
@@ -1,7 +1,7 @@
1
1
  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); }
2
2
 
3
3
  import React from 'react';
4
- import { oneOfType, func, node, string, bool, object, shape, elementType } from 'prop-types';
4
+ import { oneOfType, func, node, string, object, shape, elementType } from 'prop-types';
5
5
  import InlineButton from './InlineBaseButton';
6
6
 
7
7
  var BackButton = function BackButton(props) {
@@ -23,12 +23,6 @@ BackButton.propTypes = {
23
23
  /** Ref-setting function, or ref created by useRef, passed to the button element */
24
24
  innerRef: oneOfType([func, shape({
25
25
  current: object
26
- })]),
27
-
28
- /** Dark variant */
29
- dark: bool
30
- };
31
- BackButton.defaultProps = {
32
- dark: false
26
+ })])
33
27
  };
34
28
  export default BackButton;
package/es/BaseButton.js CHANGED
@@ -1,4 +1,4 @@
1
- var _excluded = ["ariaLoadingMessage", "buttonType", "children", "className", "condensed", "disabled", "element", "innerRef", "isLoading", "leftIcon", "rightIcon"];
1
+ var _excluded = ["ariaLoadingMessage", "buttonType", "children", "className", "condensed", "element", "innerRef", "isLoading", "leftIcon", "rightIcon", "onClick"];
2
2
 
3
3
  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); }
4
4
 
@@ -19,25 +19,32 @@ var BaseButton = function BaseButton(props) {
19
19
  children = props.children,
20
20
  className = props.className,
21
21
  condensed = props.condensed,
22
- disabled = props.disabled,
23
22
  Element = props.element,
24
23
  innerRef = props.innerRef,
25
24
  isLoading = props.isLoading,
26
25
  leftIcon = props.leftIcon,
27
26
  rightIcon = props.rightIcon,
27
+ _onClick = props.onClick,
28
28
  rest = _objectWithoutProperties(props, _excluded);
29
29
 
30
30
  var supportsSpinner = ['action', 'primary', 'secondary'].includes(buttonType);
31
31
  return /*#__PURE__*/React.createElement(Element, _extends({
32
32
  "aria-busy": isLoading && supportsSpinner,
33
- "aria-disabled": disabled || isLoading && supportsSpinner,
33
+ "aria-disabled": rest.disabled || isLoading && supportsSpinner,
34
34
  className: classNames('ffe-button', "ffe-button--".concat(buttonType), {
35
35
  'ffe-button--condensed': condensed
36
36
  }, {
37
37
  'ffe-button--loading': isLoading && supportsSpinner
38
38
  }, className),
39
- disabled: disabled || isLoading && supportsSpinner,
40
- ref: innerRef
39
+ ref: innerRef,
40
+ onClick: function onClick(event) {
41
+ if (isLoading && supportsSpinner) {
42
+ event.preventDefault();
43
+ event.stopPropagation();
44
+ } else if (_onClick) {
45
+ _onClick(event);
46
+ }
47
+ }
41
48
  }, rest), /*#__PURE__*/React.createElement("span", {
42
49
  className: "ffe-button__label"
43
50
  }, leftIcon && /*#__PURE__*/React.cloneElement(leftIcon, {
@@ -88,7 +95,10 @@ BaseButton.propTypes = {
88
95
  leftIcon: node,
89
96
 
90
97
  /** Icon shown to the right of the label */
91
- rightIcon: node
98
+ rightIcon: node,
99
+
100
+ /** Called when button is clicked if not loading or disabled */
101
+ onClick: func
92
102
  };
93
103
  BaseButton.defaultProps = {
94
104
  ariaLoadingMessage: 'Vennligst vent',
@@ -77,7 +77,6 @@ describe('<BaseButton />', function () {
77
77
  isLoading: true
78
78
  });
79
79
  expect(wrapper.prop('aria-disabled')).toBe(true);
80
- expect(wrapper.prop('disabled')).toBe(true);
81
80
  });
82
81
  it('does nothing for unsupported button type', function () {
83
82
  var wrapper = getWrapper({
@@ -87,7 +86,6 @@ describe('<BaseButton />', function () {
87
86
  expect(wrapper.hasClass('ffe-button--loading')).toBe(false);
88
87
  expect(wrapper.prop('aria-busy')).toBe(false);
89
88
  expect(wrapper.prop('aria-disabled')).toBe(false);
90
- expect(wrapper.prop('disabled')).toBe(false);
91
89
  });
92
90
  });
93
91
  });
@@ -41,12 +41,6 @@ PrimaryButton.propTypes = {
41
41
  leftIcon: node,
42
42
 
43
43
  /** Icon shown to the right of the label */
44
- rightIcon: node,
45
-
46
- /** Dark variant */
47
- dark: bool
48
- };
49
- PrimaryButton.defaultProps = {
50
- dark: false
44
+ rightIcon: node
51
45
  };
52
46
  export default PrimaryButton;
@@ -41,12 +41,6 @@ SecondaryButton.propTypes = {
41
41
  leftIcon: node,
42
42
 
43
43
  /** Icon shown to the right of the label */
44
- rightIcon: node,
45
-
46
- /** Dark variant */
47
- dark: bool
48
- };
49
- SecondaryButton.defaultProps = {
50
- dark: false
44
+ rightIcon: node
51
45
  };
52
46
  export default SecondaryButton;
@@ -1,7 +1,7 @@
1
1
  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); }
2
2
 
3
3
  import React from 'react';
4
- import { func, node, oneOfType, string, bool, object, shape, elementType } from 'prop-types';
4
+ import { func, node, oneOfType, string, object, shape, elementType } from 'prop-types';
5
5
  import InlineButton from './InlineBaseButton';
6
6
 
7
7
  var TertiaryButton = function TertiaryButton(props) {
@@ -29,12 +29,6 @@ TertiaryButton.propTypes = {
29
29
  leftIcon: node,
30
30
 
31
31
  /** Icon shown to the right of the label */
32
- rightIcon: node,
33
-
34
- /** Dark variant */
35
- dark: bool
36
- };
37
- TertiaryButton.defaultProps = {
38
- dark: false
32
+ rightIcon: node
39
33
  };
40
34
  export default TertiaryButton;
@@ -70,12 +70,8 @@ ActionButton.propTypes = {
70
70
  leftIcon: _propTypes.node,
71
71
 
72
72
  /** Icon shown to the right of the label */
73
- rightIcon: _propTypes.node,
74
-
75
- /** Dark variant */
76
- dark: _propTypes.bool
73
+ rightIcon: _propTypes.node
77
74
  };
78
75
  ActionButton.defaultProps = {
79
- ghost: false,
80
- dark: false
76
+ ghost: false
81
77
  };
package/lib/BackButton.js CHANGED
@@ -34,13 +34,7 @@ BackButton.propTypes = {
34
34
  /** Ref-setting function, or ref created by useRef, passed to the button element */
35
35
  innerRef: (0, _propTypes.oneOfType)([_propTypes.func, (0, _propTypes.shape)({
36
36
  current: _propTypes.object
37
- })]),
38
-
39
- /** Dark variant */
40
- dark: _propTypes.bool
41
- };
42
- BackButton.defaultProps = {
43
- dark: false
37
+ })])
44
38
  };
45
39
  var _default = BackButton;
46
40
  exports.default = _default;
package/lib/BaseButton.js CHANGED
@@ -11,7 +11,7 @@ var _propTypes = require("prop-types");
11
11
 
12
12
  var _classnames = _interopRequireDefault(require("classnames"));
13
13
 
14
- var _excluded = ["ariaLoadingMessage", "buttonType", "children", "className", "condensed", "disabled", "element", "innerRef", "isLoading", "leftIcon", "rightIcon"];
14
+ var _excluded = ["ariaLoadingMessage", "buttonType", "children", "className", "condensed", "element", "innerRef", "isLoading", "leftIcon", "rightIcon", "onClick"];
15
15
 
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
@@ -30,25 +30,32 @@ var BaseButton = function BaseButton(props) {
30
30
  children = props.children,
31
31
  className = props.className,
32
32
  condensed = props.condensed,
33
- disabled = props.disabled,
34
33
  Element = props.element,
35
34
  innerRef = props.innerRef,
36
35
  isLoading = props.isLoading,
37
36
  leftIcon = props.leftIcon,
38
37
  rightIcon = props.rightIcon,
38
+ _onClick = props.onClick,
39
39
  rest = _objectWithoutProperties(props, _excluded);
40
40
 
41
41
  var supportsSpinner = ['action', 'primary', 'secondary'].includes(buttonType);
42
42
  return /*#__PURE__*/_react.default.createElement(Element, _extends({
43
43
  "aria-busy": isLoading && supportsSpinner,
44
- "aria-disabled": disabled || isLoading && supportsSpinner,
44
+ "aria-disabled": rest.disabled || isLoading && supportsSpinner,
45
45
  className: (0, _classnames.default)('ffe-button', "ffe-button--".concat(buttonType), {
46
46
  'ffe-button--condensed': condensed
47
47
  }, {
48
48
  'ffe-button--loading': isLoading && supportsSpinner
49
49
  }, className),
50
- disabled: disabled || isLoading && supportsSpinner,
51
- ref: innerRef
50
+ ref: innerRef,
51
+ onClick: function onClick(event) {
52
+ if (isLoading && supportsSpinner) {
53
+ event.preventDefault();
54
+ event.stopPropagation();
55
+ } else if (_onClick) {
56
+ _onClick(event);
57
+ }
58
+ }
52
59
  }, rest), /*#__PURE__*/_react.default.createElement("span", {
53
60
  className: "ffe-button__label"
54
61
  }, leftIcon && /*#__PURE__*/_react.default.cloneElement(leftIcon, {
@@ -99,7 +106,10 @@ BaseButton.propTypes = {
99
106
  leftIcon: _propTypes.node,
100
107
 
101
108
  /** Icon shown to the right of the label */
102
- rightIcon: _propTypes.node
109
+ rightIcon: _propTypes.node,
110
+
111
+ /** Called when button is clicked if not loading or disabled */
112
+ onClick: _propTypes.func
103
113
  };
104
114
  BaseButton.defaultProps = {
105
115
  ariaLoadingMessage: 'Vennligst vent',
@@ -84,7 +84,6 @@ describe('<BaseButton />', function () {
84
84
  isLoading: true
85
85
  });
86
86
  expect(wrapper.prop('aria-disabled')).toBe(true);
87
- expect(wrapper.prop('disabled')).toBe(true);
88
87
  });
89
88
  it('does nothing for unsupported button type', function () {
90
89
  var wrapper = getWrapper({
@@ -94,7 +93,6 @@ describe('<BaseButton />', function () {
94
93
  expect(wrapper.hasClass('ffe-button--loading')).toBe(false);
95
94
  expect(wrapper.prop('aria-busy')).toBe(false);
96
95
  expect(wrapper.prop('aria-disabled')).toBe(false);
97
- expect(wrapper.prop('disabled')).toBe(false);
98
96
  });
99
97
  });
100
98
  });
@@ -52,13 +52,7 @@ PrimaryButton.propTypes = {
52
52
  leftIcon: _propTypes.node,
53
53
 
54
54
  /** Icon shown to the right of the label */
55
- rightIcon: _propTypes.node,
56
-
57
- /** Dark variant */
58
- dark: _propTypes.bool
59
- };
60
- PrimaryButton.defaultProps = {
61
- dark: false
55
+ rightIcon: _propTypes.node
62
56
  };
63
57
  var _default = PrimaryButton;
64
58
  exports.default = _default;
@@ -52,13 +52,7 @@ SecondaryButton.propTypes = {
52
52
  leftIcon: _propTypes.node,
53
53
 
54
54
  /** Icon shown to the right of the label */
55
- rightIcon: _propTypes.node,
56
-
57
- /** Dark variant */
58
- dark: _propTypes.bool
59
- };
60
- SecondaryButton.defaultProps = {
61
- dark: false
55
+ rightIcon: _propTypes.node
62
56
  };
63
57
  var _default = SecondaryButton;
64
58
  exports.default = _default;
@@ -40,13 +40,7 @@ TertiaryButton.propTypes = {
40
40
  leftIcon: _propTypes.node,
41
41
 
42
42
  /** Icon shown to the right of the label */
43
- rightIcon: _propTypes.node,
44
-
45
- /** Dark variant */
46
- dark: _propTypes.bool
47
- };
48
- TertiaryButton.defaultProps = {
49
- dark: false
43
+ rightIcon: _propTypes.node
50
44
  };
51
45
  var _default = TertiaryButton;
52
46
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sb1/ffe-buttons-react",
3
- "version": "14.0.2",
3
+ "version": "14.0.6",
4
4
  "description": "React implementation of ffe-buttons",
5
5
  "keywords": [
6
6
  "ffe"
@@ -33,7 +33,7 @@
33
33
  "setupTestFrameworkScriptFile": "../../test-setup.js"
34
34
  },
35
35
  "dependencies": {
36
- "@sb1/ffe-icons-react": "^7.2.18",
36
+ "@sb1/ffe-icons-react": "^7.2.19",
37
37
  "classnames": "^2.2.5",
38
38
  "prop-types": "^15.7.0"
39
39
  },
@@ -53,5 +53,5 @@
53
53
  "publishConfig": {
54
54
  "access": "public"
55
55
  },
56
- "gitHead": "53a5f3124f5da484d5c004a2381a480285d4d70b"
56
+ "gitHead": "0fb5a2f3fc9b083939ed70ee4685aa1890d42af7"
57
57
  }
package/types/index.d.ts CHANGED
@@ -24,7 +24,6 @@ export interface BaseButtonProps extends MinimalBaseButtonProps {
24
24
  isLoading?: boolean;
25
25
  leftIcon?: React.ReactNode;
26
26
  rightIcon?: React.ReactNode;
27
- dark?: boolean;
28
27
  }
29
28
 
30
29
  export interface ActionButtonProps extends BaseButtonProps {
@@ -33,7 +32,6 @@ export interface ActionButtonProps extends BaseButtonProps {
33
32
 
34
33
  export interface BackButtonProps extends MinimalBaseButtonProps {
35
34
  children?: React.ReactNode;
36
- dark?: boolean;
37
35
  }
38
36
 
39
37
  export interface ButtonGroupProps {
@@ -80,7 +78,6 @@ export interface TertiaryButtonProps extends MinimalBaseButtonProps {
80
78
  children?: React.ReactNode;
81
79
  leftIcon?: React.ReactNode;
82
80
  rightIcon?: React.ReactNode;
83
- dark?: boolean;
84
81
  }
85
82
 
86
83
  declare class ActionButton extends React.Component<ActionButtonProps, any> {}