@atlaskit/button 16.5.3 → 16.5.4

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/button-group.js +3 -11
  3. package/dist/cjs/button.js +14 -34
  4. package/dist/cjs/custom-theme-button/custom-theme-button.js +41 -76
  5. package/dist/cjs/custom-theme-button/index.js +0 -3
  6. package/dist/cjs/custom-theme-button/theme.js +31 -38
  7. package/dist/cjs/entry-points/button-group.js +0 -2
  8. package/dist/cjs/entry-points/custom-theme-button.js +0 -4
  9. package/dist/cjs/entry-points/loading-button.js +0 -2
  10. package/dist/cjs/entry-points/standard-button.js +0 -3
  11. package/dist/cjs/index.js +0 -8
  12. package/dist/cjs/loading-button.js +4 -12
  13. package/dist/cjs/shared/block-events.js +0 -6
  14. package/dist/cjs/shared/button-base.js +48 -66
  15. package/dist/cjs/shared/colors.js +0 -5
  16. package/dist/cjs/shared/css.js +17 -28
  17. package/dist/cjs/shared/get-is-only-single-icon.js +2 -7
  18. package/dist/cjs/shared/loading-spinner.js +4 -15
  19. package/dist/cjs/version.json +1 -1
  20. package/dist/es2019/button-group.js +1 -3
  21. package/dist/es2019/button.js +7 -7
  22. package/dist/es2019/custom-theme-button/custom-theme-button.js +19 -25
  23. package/dist/es2019/custom-theme-button/theme.js +21 -16
  24. package/dist/es2019/index.js +3 -1
  25. package/dist/es2019/loading-button.js +2 -2
  26. package/dist/es2019/shared/block-events.js +0 -4
  27. package/dist/es2019/shared/button-base.js +19 -18
  28. package/dist/es2019/shared/css.js +22 -14
  29. package/dist/es2019/shared/get-is-only-single-icon.js +0 -3
  30. package/dist/es2019/shared/loading-spinner.js +0 -5
  31. package/dist/es2019/version.json +1 -1
  32. package/dist/esm/button-group.js +2 -4
  33. package/dist/esm/button.js +14 -18
  34. package/dist/esm/custom-theme-button/custom-theme-button.js +41 -61
  35. package/dist/esm/custom-theme-button/theme.js +31 -31
  36. package/dist/esm/index.js +3 -1
  37. package/dist/esm/loading-button.js +4 -5
  38. package/dist/esm/shared/block-events.js +0 -4
  39. package/dist/esm/shared/button-base.js +51 -51
  40. package/dist/esm/shared/css.js +17 -19
  41. package/dist/esm/shared/get-is-only-single-icon.js +2 -6
  42. package/dist/esm/shared/loading-spinner.js +4 -11
  43. package/dist/esm/version.json +1 -1
  44. package/package.json +1 -1
  45. package/report.api.md +13 -0
@@ -5,7 +5,6 @@ import ButtonBase from '../shared/button-base';
5
5
  import getIsOnlySingleIcon from '../shared/get-is-only-single-icon';
6
6
  import LoadingSpinner from '../shared/loading-spinner';
7
7
  import Theme, { defaultThemeFn, getSpecifiers } from './theme';
8
-
9
8
  function getInteractionState({
10
9
  isDisabled = false,
11
10
  isActive = false,
@@ -17,36 +16,30 @@ function getInteractionState({
17
16
  if (isDisabled) {
18
17
  return 'disabled';
19
18
  }
20
-
21
19
  if (isSelected && isFocus) {
22
20
  return 'focusSelected';
23
21
  }
24
-
25
22
  if (isSelected) {
26
23
  return 'selected';
27
- } // not allowing active or focus style changes while loading
28
-
29
-
24
+ }
25
+ // not allowing active or focus style changes while loading
30
26
  if (!isLoading && isActive) {
31
27
  return 'active';
32
28
  }
33
-
34
29
  if (!isLoading && isHover) {
35
30
  return 'hover';
36
31
  }
37
-
38
32
  if (isFocus) {
39
33
  return 'focus';
40
34
  }
41
-
42
35
  return 'default';
43
36
  }
44
-
45
37
  const initial = {
46
38
  isHover: false,
47
39
  isActive: false,
48
40
  isFocus: false
49
41
  };
42
+
50
43
  /**
51
44
  * __Custom theme button__
52
45
  *
@@ -54,7 +47,6 @@ const initial = {
54
47
  *
55
48
  * - [Examples](https://atlassian.design/components/button/examples#custom-theme-button)
56
49
  */
57
-
58
50
  const CustomThemeButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function CustomThemeButton({
59
51
  // Calculate default props for use in custom themes
60
52
  appearance = 'default',
@@ -86,56 +78,56 @@ const CustomThemeButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef
86
78
  };
87
79
  const [state, setState] = useState(initial);
88
80
  const onMouseEnter = useCallback(event => {
89
- setState(current => ({ ...current,
81
+ setState(current => ({
82
+ ...current,
90
83
  isHover: true
91
84
  }));
92
-
93
85
  if (providedOnMouseEnter) {
94
86
  providedOnMouseEnter(event);
95
87
  }
96
88
  }, [providedOnMouseEnter]);
97
89
  const onMouseLeave = useCallback(event => {
98
- setState(current => ({ ...current,
90
+ setState(current => ({
91
+ ...current,
99
92
  isHover: false,
100
93
  isActive: false
101
94
  }));
102
-
103
95
  if (providedOnMouseLeave) {
104
96
  providedOnMouseLeave(event);
105
97
  }
106
98
  }, [providedOnMouseLeave]);
107
99
  const onMouseDown = useCallback(event => {
108
- setState(current => ({ ...current,
100
+ setState(current => ({
101
+ ...current,
109
102
  isActive: true
110
103
  }));
111
-
112
104
  if (providedOnMouseDown) {
113
105
  providedOnMouseDown(event);
114
106
  }
115
107
  }, [providedOnMouseDown]);
116
108
  const onMouseUp = useCallback(event => {
117
- setState(current => ({ ...current,
109
+ setState(current => ({
110
+ ...current,
118
111
  isActive: false
119
112
  }));
120
-
121
113
  if (providedOnMouseUp) {
122
114
  providedOnMouseUp(event);
123
115
  }
124
116
  }, [providedOnMouseUp]);
125
117
  const onFocus = useCallback(event => {
126
- setState(current => ({ ...current,
118
+ setState(current => ({
119
+ ...current,
127
120
  isFocus: true
128
121
  }));
129
-
130
122
  if (providedOnFocus) {
131
123
  providedOnFocus(event);
132
124
  }
133
125
  }, [providedOnFocus]);
134
126
  const onBlur = useCallback(event => {
135
- setState(current => ({ ...current,
127
+ setState(current => ({
128
+ ...current,
136
129
  isFocus: false
137
130
  }));
138
-
139
131
  if (providedOnBlur) {
140
132
  providedOnBlur(event);
141
133
  }
@@ -146,7 +138,8 @@ const CustomThemeButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef
146
138
  mode
147
139
  }) => /*#__PURE__*/React.createElement(Theme.Consumer, _extends({
148
140
  mode: mode,
149
- state: getInteractionState({ ...state,
141
+ state: getInteractionState({
142
+ ...state,
150
143
  isLoading,
151
144
  isSelected: restProps.isSelected,
152
145
  isDisabled: restProps.isDisabled
@@ -166,7 +159,8 @@ const CustomThemeButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef
166
159
  onBlur: onBlur,
167
160
  buttonCss: getSpecifiers(buttonStyles)
168
161
  })))));
169
- })); // Tools including enzyme rely on components having a display name
162
+ }));
170
163
 
164
+ // Tools including enzyme rely on components having a display name
171
165
  CustomThemeButton.displayName = 'CustomThemeButton';
172
166
  export default CustomThemeButton;
@@ -6,10 +6,11 @@ const stateToSelectorMap = {
6
6
  hover: '&:hover',
7
7
  active: '&:active',
8
8
  disabled: '&[disabled]'
9
- }; // Mapping the new clean css back to the legacy theme format.
9
+ };
10
+
11
+ // Mapping the new clean css back to the legacy theme format.
10
12
  // The legacy theme format has all styles at the top level (no nested selectors)
11
13
  // and uses `getSpecifiers()` to apply the style to all pseudo states
12
-
13
14
  export function getCustomCss({
14
15
  appearance = 'default',
15
16
  spacing = 'default',
@@ -27,42 +28,45 @@ export function getCustomCss({
27
28
  isSelected,
28
29
  shouldFitContainer,
29
30
  isOnlySingleIcon: iconIsOnlyChild
30
- }); // we need to disable the default browser focus styles always
31
- // this is because we are not expressing that we can have two pseudo states at a time
31
+ });
32
32
 
33
- result.outline = 'none'; // Pulling relevant styles up to the top level
33
+ // we need to disable the default browser focus styles always
34
+ // this is because we are not expressing that we can have two pseudo states at a time
35
+ result.outline = 'none';
34
36
 
37
+ // Pulling relevant styles up to the top level
35
38
  const selector = stateToSelectorMap[state];
36
-
37
39
  if (selector) {
38
- result = { ...result,
40
+ result = {
41
+ ...result,
39
42
  ...result[selector]
40
43
  };
41
44
  }
42
-
43
45
  if (isLoading) {
44
- result = { ...result,
46
+ result = {
47
+ ...result,
45
48
  // Pull overlay styles up to the top
46
49
  ...result['&[data-has-overlay="true"]']
47
50
  };
48
- } // Delete all selectors and just keep root styles
49
-
51
+ }
50
52
 
53
+ // Delete all selectors and just keep root styles
51
54
  Object.keys(result).forEach(key => {
52
55
  // want to keep this one
53
56
  if (key === '&::-moz-focus-inner') {
54
57
  return;
55
- } // Not using .startsWith for ie11
56
-
58
+ }
57
59
 
60
+ // Not using .startsWith for ie11
58
61
  if (key.indexOf('&') === 0) {
59
62
  delete result[key];
60
63
  }
61
64
  });
62
65
  return result;
63
- } // This styling approach works by generating a 'style' and applying with maximum specificity
64
- // To do this we are overwriting all pseudo selectors
66
+ }
65
67
 
68
+ // This styling approach works by generating a 'style' and applying with maximum specificity
69
+ // To do this we are overwriting all pseudo selectors
66
70
  export function getSpecifiers(styles) {
67
71
  return {
68
72
  '&, &:hover, &:active, &:focus, &:visited, &:disabled, &[disabled]': styles
@@ -77,6 +81,7 @@ const Theme = createTheme(themeProps => ({
77
81
  // Keeping this for legacy compat. We could remove it, but given
78
82
  // that we are changing theme soon there is no point
79
83
  spinnerStyles: {}
80
- })); // eslint-disable-next-line @repo/internal/react/require-jsdoc
84
+ }));
81
85
 
86
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
82
87
  export default Theme;
@@ -1,5 +1,7 @@
1
1
  // Ideally this file is not used directly. But rather, you go through the entry points
2
- export { // default export is Button
2
+
3
+ export {
4
+ // default export is Button
3
5
  default } from './entry-points/standard-button';
4
6
  export { default as LoadingButton } from './entry-points/loading-button';
5
7
  export { default as CustomThemeButton, Theme } from './entry-points/custom-theme-button';
@@ -2,7 +2,6 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import React from 'react';
3
3
  import Button from './button';
4
4
  import LoadingSpinner from './shared/loading-spinner';
5
-
6
5
  /**
7
6
  * __Loading button__
8
7
  *
@@ -19,7 +18,8 @@ const LoadingButton = /*#__PURE__*/React.forwardRef(function LoadingButton({
19
18
  ref: ref,
20
19
  overlay: isLoading ? /*#__PURE__*/React.createElement(LoadingSpinner, rest) : null
21
20
  }));
22
- }); // Tools including enzyme rely on components having a display name
21
+ });
23
22
 
23
+ // Tools including enzyme rely on components having a display name
24
24
  LoadingButton.displayName = 'LoadingButton';
25
25
  export default LoadingButton;
@@ -2,18 +2,14 @@ function abort(event) {
2
2
  event.preventDefault();
3
3
  event.stopPropagation();
4
4
  }
5
-
6
5
  const tabKeyCode = 9;
7
-
8
6
  function onKey(event) {
9
7
  // Allowing tab so that a user can move focus away
10
8
  if (event.keyCode === tabKeyCode) {
11
9
  return;
12
10
  }
13
-
14
11
  abort(event);
15
12
  }
16
-
17
13
  const block = {
18
14
  onMouseDownCapture: abort,
19
15
  onMouseUpCapture: abort,
@@ -1,5 +1,4 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
-
3
2
  /** @jsx jsx */
4
3
  import React, { useCallback, useContext, useEffect, useRef } from 'react';
5
4
  import { css, jsx } from '@emotion/react';
@@ -10,11 +9,12 @@ import useAutoFocus from '@atlaskit/ds-lib/use-auto-focus';
10
9
  import InteractionContext from '@atlaskit/interaction-context';
11
10
  import { N500 } from '@atlaskit/theme/colors';
12
11
  import blockEvents from './block-events';
13
- import { getContentStyle, getFadingCss, getIconStyle, overlayCss } from './css'; // Disabled buttons will still publish events for nested elements in webkit.
12
+ import { getContentStyle, getFadingCss, getIconStyle, overlayCss } from './css';
13
+
14
+ // Disabled buttons will still publish events for nested elements in webkit.
14
15
  // We are disabling pointer events on child elements so that
15
16
  // the button will always be the target of events
16
17
  // Note: firefox does not have this behaviour for child elements
17
-
18
18
  const noPointerEventsOnChildrenCss = {
19
19
  '> *': {
20
20
  pointerEvents: 'none'
@@ -51,20 +51,19 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
51
51
  const ourRef = useRef();
52
52
  const setRef = useCallback(node => {
53
53
  ourRef.current = node;
54
-
55
54
  if (ref == null) {
56
55
  return;
57
56
  }
58
-
59
57
  if (typeof ref === 'function') {
60
58
  ref(node);
61
59
  return;
62
- } // @ts-ignore
63
-
60
+ }
64
61
 
62
+ // @ts-ignore
65
63
  ref.current = node;
66
- }, [ourRef, ref]); // Cross browser auto focusing is pretty broken, so we are doing it ourselves
64
+ }, [ourRef, ref]);
67
65
 
66
+ // Cross browser auto focusing is pretty broken, so we are doing it ourselves
68
67
  useAutoFocus(ourRef, autoFocus);
69
68
  const interactionContext = useContext(InteractionContext);
70
69
  const handleClick = useCallback((e, analyticsEvent) => {
@@ -76,36 +75,37 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
76
75
  action: 'clicked',
77
76
  componentName: 'button',
78
77
  packageName: "@atlaskit/button",
79
- packageVersion: "16.5.3",
78
+ packageVersion: "16.5.4",
80
79
  analyticsData: analyticsContext
81
- }); // Button currently calls preventDefault, which is not standard button behaviour
80
+ });
82
81
 
82
+ // Button currently calls preventDefault, which is not standard button behaviour
83
83
  const onMouseDown = useCallback(event => {
84
84
  event.preventDefault();
85
85
  providedOnMouseDown(event);
86
- }, [providedOnMouseDown]); // Lose focus when becoming disabled (standard button behaviour)
86
+ }, [providedOnMouseDown]);
87
87
 
88
+ // Lose focus when becoming disabled (standard button behaviour)
88
89
  useEffect(() => {
89
90
  const el = ourRef.current;
90
-
91
91
  if (isDisabled && el && el === document.activeElement) {
92
92
  el.blur();
93
93
  }
94
- }, [isDisabled]); // we are 'disabling' input with a button when there is an overlay
94
+ }, [isDisabled]);
95
95
 
96
+ // we are 'disabling' input with a button when there is an overlay
96
97
  const hasOverlay = Boolean(overlay);
97
98
  const fadeCss = css(getFadingCss({
98
99
  hasOverlay
99
100
  }));
100
101
  const isInteractive = !isDisabled && !hasOverlay;
102
+
101
103
  /**
102
104
  * HACK: Spinner needs to have different colours in the "new" tokens design compared to the old design.
103
105
  * For now, while we support both, these styles reach into Spinner when a theme is set, applies the right color.
104
106
  * Ticket to remove: https://product-fabric.atlassian.net/browse/DSP-2067
105
107
  */
106
-
107
108
  var spinnerHackCss = {};
108
-
109
109
  if (isSelected || isDisabled || appearance === 'warning') {
110
110
  spinnerHackCss = {
111
111
  '[data-theme] & svg': {
@@ -113,7 +113,6 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
113
113
  }
114
114
  };
115
115
  }
116
-
117
116
  return jsx(Component, _extends({}, rest, {
118
117
  css: [buttonCss, isInteractive ? null : noPointerEventsOnChildrenCss],
119
118
  className: className,
@@ -121,11 +120,13 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
121
120
  onClick: onClick,
122
121
  onMouseDown: onMouseDown,
123
122
  disabled: isDisabled,
124
- href: isInteractive ? href : undefined // using undefined so that the property doesn't exist when false
123
+ href: isInteractive ? href : undefined
124
+ // using undefined so that the property doesn't exist when false
125
125
  ,
126
126
  "data-has-overlay": hasOverlay ? true : undefined,
127
127
  "data-testid": testId,
128
- type: type // Adding a tab index so element is always focusable, even when not a <button> or <a>
128
+ type: type
129
+ // Adding a tab index so element is always focusable, even when not a <button> or <a>
129
130
  // Disabling focus via keyboard navigation when disabled
130
131
  // as this is standard button behaviour
131
132
  ,
@@ -3,7 +3,9 @@ import { borderRadius as getBorderRadius, fontSize as getFontSize, gridSize as g
3
3
  import colors from './colors';
4
4
  const borderRadius = getBorderRadius();
5
5
  const gridSize = getGridSize();
6
- const fontSize = getFontSize(); // ## Button layout
6
+ const fontSize = getFontSize();
7
+
8
+ // ## Button layout
7
9
  //
8
10
  // /------------------------------------------------------------------------------------------------------------------\
9
11
  // | → | ← | | → | ← | | → | ← | | → | ← |
@@ -15,7 +17,6 @@ const fontSize = getFontSize(); // ## Button layout
15
17
  // ↑ ↑
16
18
  // Margins don't collapse with inline-flex
17
19
  //
18
-
19
20
  const heights = {
20
21
  default: `${gridSize * 4 / fontSize}em`,
21
22
  // 32px
@@ -48,7 +49,6 @@ const innerMargin = {
48
49
  content: `0 ${gridSize / 4}px`,
49
50
  icon: `0 ${gridSize / 4}px`
50
51
  };
51
-
52
52
  function getColor({
53
53
  group,
54
54
  key,
@@ -57,7 +57,6 @@ function getColor({
57
57
  const rule = group[key] || group.default;
58
58
  return rule[mode];
59
59
  }
60
-
61
60
  function getColors({
62
61
  appearance,
63
62
  key,
@@ -77,7 +76,6 @@ function getColors({
77
76
  })} !important`
78
77
  };
79
78
  }
80
-
81
79
  export function getCss({
82
80
  appearance,
83
81
  spacing,
@@ -123,10 +121,13 @@ export function getCss({
123
121
  justifyContent: 'center',
124
122
  // Note: we cannot disable pointer events when there is an overlay.
125
123
  // That would be easy for styling, but it would start letting events through on disabled buttons
124
+
126
125
  // Disabling visited styles (just using the base colors)
127
- '&:visited': { ...baseColors
126
+ '&:visited': {
127
+ ...baseColors
128
128
  },
129
- '&:hover': { ...getColors({
129
+ '&:hover': {
130
+ ...getColors({
130
131
  appearance,
131
132
  key: isSelected ? 'selected' : 'hover',
132
133
  mode
@@ -135,7 +136,8 @@ export function getCss({
135
136
  // background, box-shadow
136
137
  transitionDuration: '0s, 0.15s'
137
138
  },
138
- '&:focus': { ...getColors({
139
+ '&:focus': {
140
+ ...getColors({
139
141
  appearance,
140
142
  key: isSelected ? 'focusSelected' : 'focus',
141
143
  mode
@@ -147,7 +149,8 @@ export function getCss({
147
149
  outline: 'none'
148
150
  },
149
151
  // giving active styles preference by listing them after focus
150
- '&:active': { ...getColors({
152
+ '&:active': {
153
+ ...getColors({
151
154
  appearance,
152
155
  key: isSelected ? 'selected' : 'active',
153
156
  mode
@@ -156,7 +159,8 @@ export function getCss({
156
159
  transitionDuration: '0s, 0s'
157
160
  },
158
161
  // preventDefault prevents regular active styles from applying in Firefox
159
- '&[data-firefox-is-active="true"]': { ...getColors({
162
+ '&[data-firefox-is-active="true"]': {
163
+ ...getColors({
160
164
  appearance,
161
165
  key: isSelected ? 'selected' : 'active',
162
166
  mode
@@ -168,7 +172,8 @@ export function getCss({
168
172
  // Not using '&:disabled' because :disabled is not a valid state for all element types
169
173
  // so we are targeting the attribute
170
174
  // Attributes have the same specificity a pseudo classes so we are overriding :disabled here
171
- '&[disabled]': { // always using 'disabled' even when selected
175
+ '&[disabled]': {
176
+ // always using 'disabled' even when selected
172
177
  ...getColors({
173
178
  appearance,
174
179
  key: 'disabled',
@@ -182,7 +187,8 @@ export function getCss({
182
187
  textDecoration: 'none'
183
188
  },
184
189
  // disabling hover and active color changes when there is an overlay, but the button is not disabled
185
- '&[data-has-overlay="true"]:not([disabled]):hover, &[data-has-overlay="true"]:not([disabled]):active': { ...getColors({
190
+ '&[data-has-overlay="true"]:not([disabled]):hover, &[data-has-overlay="true"]:not([disabled]):active': {
191
+ ...getColors({
186
192
  appearance,
187
193
  key: isSelected ? 'selected' : 'default',
188
194
  mode
@@ -194,8 +200,9 @@ export function getCss({
194
200
  padding: 0
195
201
  }
196
202
  };
197
- } // inline-flex child
203
+ }
198
204
 
205
+ // inline-flex child
199
206
  export function getIconStyle({
200
207
  spacing
201
208
  }) {
@@ -210,8 +217,9 @@ export function getIconStyle({
210
217
  lineHeight: 0,
211
218
  userSelect: 'none'
212
219
  });
213
- } // inline-flex child
220
+ }
214
221
 
222
+ // inline-flex child
215
223
  export function getContentStyle({
216
224
  spacing
217
225
  }) {
@@ -6,14 +6,11 @@ export default function getIsOnlySingleIcon({
6
6
  if (children) {
7
7
  return false;
8
8
  }
9
-
10
9
  if (iconBefore && !iconAfter) {
11
10
  return true;
12
11
  }
13
-
14
12
  if (!iconBefore && iconAfter) {
15
13
  return true;
16
14
  }
17
-
18
15
  return false;
19
16
  }
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
2
  import Spinner from '@atlaskit/spinner';
3
-
4
3
  function getSpinnerAppearance({
5
4
  appearance,
6
5
  isDisabled,
@@ -9,18 +8,14 @@ function getSpinnerAppearance({
9
8
  if (isDisabled) {
10
9
  return 'inherit';
11
10
  }
12
-
13
11
  if (isSelected) {
14
12
  return 'invert';
15
13
  }
16
-
17
14
  if (appearance === 'primary' || appearance === 'danger') {
18
15
  return 'invert';
19
16
  }
20
-
21
17
  return 'inherit';
22
18
  }
23
-
24
19
  export default function LoadingSpinner({
25
20
  spacing = 'default',
26
21
  ...rest
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/button",
3
- "version": "16.5.3",
3
+ "version": "16.5.4",
4
4
  "sideEffects": false
5
5
  }
@@ -3,22 +3,20 @@ import React, { Fragment } from 'react';
3
3
  import { css, jsx } from '@emotion/react';
4
4
  var buttonGroupStyles = css({
5
5
  display: 'inline-flex',
6
- // TODO Delete this comment after verifying spacing token -> previous value `4`
7
- gap: "var(--ds-scale-050, 4px)",
6
+ gap: "var(--ds-space-050, 4px)",
8
7
  '> *': {
9
8
  flex: '1 0 auto'
10
9
  }
11
10
  });
12
11
  export default function ButtonGroup(_ref) {
13
12
  var appearance = _ref.appearance,
14
- children = _ref.children;
13
+ children = _ref.children;
15
14
  return jsx("div", {
16
15
  css: buttonGroupStyles
17
16
  }, React.Children.map(React.Children.toArray(children), function (child, idx) {
18
17
  if (!child) {
19
18
  return null;
20
19
  }
21
-
22
20
  return jsx(Fragment, {
23
21
  key: idx
24
22
  }, appearance ?
@@ -9,7 +9,6 @@ import ButtonBase from './shared/button-base';
9
9
  import { getCss } from './shared/css';
10
10
  import getIsOnlySingleIcon from './shared/get-is-only-single-icon';
11
11
  var isFirefox = typeof navigator !== 'undefined' && navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
12
-
13
12
  /**
14
13
  * __Button__
15
14
  *
@@ -21,37 +20,32 @@ var isFirefox = typeof navigator !== 'undefined' && navigator.userAgent.toLowerC
21
20
  */
22
21
  var Button = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function Button(_ref, ref) {
23
22
  var _ref$onMouseDown = _ref.onMouseDown,
24
- providedOnMouseDown = _ref$onMouseDown === void 0 ? noop : _ref$onMouseDown,
25
- _ref$onMouseUp = _ref.onMouseUp,
26
- providedOnMouseUp = _ref$onMouseUp === void 0 ? noop : _ref$onMouseUp,
27
- rest = _objectWithoutProperties(_ref, _excluded);
28
-
23
+ providedOnMouseDown = _ref$onMouseDown === void 0 ? noop : _ref$onMouseDown,
24
+ _ref$onMouseUp = _ref.onMouseUp,
25
+ providedOnMouseUp = _ref$onMouseUp === void 0 ? noop : _ref$onMouseUp,
26
+ rest = _objectWithoutProperties(_ref, _excluded);
29
27
  var _useGlobalTheme = useGlobalTheme(),
30
- mode = _useGlobalTheme.mode;
31
-
28
+ mode = _useGlobalTheme.mode;
32
29
  var appearance = rest.appearance || 'default';
33
30
  var spacing = rest.spacing || 'default';
34
31
  var shouldFitContainer = Boolean(rest.shouldFitContainer);
35
32
  var isSelected = Boolean(rest.isSelected);
36
33
  var isOnlySingleIcon = getIsOnlySingleIcon(rest);
37
-
38
34
  var _useState = useState(false),
39
- _useState2 = _slicedToArray(_useState, 2),
40
- isActive = _useState2[0],
41
- setIsActive = _useState2[1]; // Wrap onMouseDown / onMouseUp to manually trigger active state
42
- // in Firefox
43
-
35
+ _useState2 = _slicedToArray(_useState, 2),
36
+ isActive = _useState2[0],
37
+ setIsActive = _useState2[1];
44
38
 
39
+ // Wrap onMouseDown / onMouseUp to manually trigger active state
40
+ // in Firefox
45
41
  var onMouseDown = useCallback(function (event) {
46
42
  providedOnMouseDown(event);
47
-
48
43
  if (isFirefox) {
49
44
  setIsActive(true);
50
45
  }
51
46
  }, [providedOnMouseDown, setIsActive]);
52
47
  var onMouseUp = useCallback(function (event) {
53
48
  providedOnMouseUp(event);
54
-
55
49
  if (isFirefox) {
56
50
  setIsActive(false);
57
51
  }
@@ -68,14 +62,16 @@ var Button = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function But
68
62
  }, [appearance, spacing, mode, isSelected, shouldFitContainer, isOnlySingleIcon]);
69
63
  return /*#__PURE__*/React.createElement(ButtonBase, _extends({}, rest, {
70
64
  ref: ref,
71
- buttonCss: buttonCss // Due to how click events are set, we need to set active styles
65
+ buttonCss: buttonCss
66
+ // Due to how click events are set, we need to set active styles
72
67
  // manually in Firefox and wrap onMouseDown/onMouseUp
73
68
  ,
74
69
  "data-firefox-is-active": isActive ? true : undefined,
75
70
  onMouseDown: onMouseDown,
76
71
  onMouseUp: onMouseUp
77
72
  }));
78
- })); // Tools including enzyme rely on components having a display name
73
+ }));
79
74
 
75
+ // Tools including enzyme rely on components having a display name
80
76
  Button.displayName = 'Button';
81
77
  export default Button;