@atlaskit/button 16.10.1 → 16.10.2

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 (80) hide show
  1. package/CHANGELOG.md +66 -60
  2. package/dist/cjs/containers/button-group.js +1 -0
  3. package/dist/cjs/new-button/variants/default/button.js +1 -2
  4. package/dist/cjs/new-button/variants/default/link.js +1 -2
  5. package/dist/cjs/new-button/variants/default/use-default-button.js +11 -16
  6. package/dist/cjs/new-button/variants/icon/button.js +1 -2
  7. package/dist/cjs/new-button/variants/icon/link.js +1 -2
  8. package/dist/cjs/new-button/variants/icon/use-icon-button.js +6 -10
  9. package/dist/cjs/new-button/variants/shared/colors.js +1 -2
  10. package/dist/cjs/new-button/variants/shared/content.js +51 -0
  11. package/dist/cjs/new-button/variants/shared/use-button-base.js +14 -4
  12. package/dist/cjs/new-button/variants/shared/xcss.js +1 -43
  13. package/dist/cjs/old-button/button.js +1 -2
  14. package/dist/cjs/old-button/custom-theme-button/custom-theme-button.js +1 -2
  15. package/dist/cjs/old-button/custom-theme-button/theme.js +1 -2
  16. package/dist/cjs/old-button/loading-button.js +1 -2
  17. package/dist/cjs/old-button/shared/button-base.js +9 -9
  18. package/dist/cjs/old-button/shared/colors.js +1 -2
  19. package/dist/cjs/old-button/shared/css.js +2 -3
  20. package/dist/cjs/old-button/shared/get-if-visually-hidden-children.js +2 -3
  21. package/dist/cjs/utils/appearances.js +1 -2
  22. package/dist/cjs/utils/spacing.js +1 -2
  23. package/dist/cjs/utils/variants.js +2 -4
  24. package/dist/es2019/containers/button-group.js +1 -0
  25. package/dist/es2019/new-button/variants/default/use-default-button.js +10 -14
  26. package/dist/es2019/new-button/variants/icon/use-icon-button.js +5 -8
  27. package/dist/es2019/new-button/variants/shared/content.js +43 -0
  28. package/dist/es2019/new-button/variants/shared/use-button-base.js +14 -3
  29. package/dist/es2019/new-button/variants/shared/xcss.js +1 -38
  30. package/dist/es2019/old-button/shared/button-base.js +7 -6
  31. package/dist/esm/containers/button-group.js +1 -0
  32. package/dist/esm/new-button/variants/default/use-default-button.js +10 -14
  33. package/dist/esm/new-button/variants/icon/use-icon-button.js +5 -8
  34. package/dist/esm/new-button/variants/shared/content.js +44 -0
  35. package/dist/esm/new-button/variants/shared/use-button-base.js +14 -3
  36. package/dist/esm/new-button/variants/shared/xcss.js +1 -37
  37. package/dist/esm/old-button/shared/button-base.js +7 -6
  38. package/dist/types/new-button/variants/shared/content.d.ts +13 -0
  39. package/dist/types/new-button/variants/shared/xcss.d.ts +0 -6
  40. package/package.json +6 -6
  41. package/dist/types-ts4.5/containers/button-group.d.ts +0 -12
  42. package/dist/types-ts4.5/entry-points/button-group.d.ts +0 -1
  43. package/dist/types-ts4.5/entry-points/custom-theme-button.d.ts +0 -2
  44. package/dist/types-ts4.5/entry-points/loading-button.d.ts +0 -2
  45. package/dist/types-ts4.5/entry-points/new.d.ts +0 -5
  46. package/dist/types-ts4.5/entry-points/standard-button.d.ts +0 -7
  47. package/dist/types-ts4.5/entry-points/types.d.ts +0 -4
  48. package/dist/types-ts4.5/entry-points/unsafe.d.ts +0 -1
  49. package/dist/types-ts4.5/index.d.ts +0 -8
  50. package/dist/types-ts4.5/new-button/variants/default/button.d.ts +0 -19
  51. package/dist/types-ts4.5/new-button/variants/default/link.d.ts +0 -17
  52. package/dist/types-ts4.5/new-button/variants/default/types.d.ts +0 -15
  53. package/dist/types-ts4.5/new-button/variants/default/use-default-button.d.ts +0 -15
  54. package/dist/types-ts4.5/new-button/variants/icon/button.d.ts +0 -17
  55. package/dist/types-ts4.5/new-button/variants/icon/link.d.ts +0 -17
  56. package/dist/types-ts4.5/new-button/variants/icon/types.d.ts +0 -8
  57. package/dist/types-ts4.5/new-button/variants/icon/use-icon-button.d.ts +0 -15
  58. package/dist/types-ts4.5/new-button/variants/shared/block-events.d.ts +0 -2
  59. package/dist/types-ts4.5/new-button/variants/shared/colors.d.ts +0 -18
  60. package/dist/types-ts4.5/new-button/variants/shared/use-button-base.d.ts +0 -37
  61. package/dist/types-ts4.5/new-button/variants/shared/xcss.d.ts +0 -24
  62. package/dist/types-ts4.5/new-button/variants/types.d.ts +0 -69
  63. package/dist/types-ts4.5/old-button/button.d.ts +0 -15
  64. package/dist/types-ts4.5/old-button/custom-theme-button/custom-theme-button-types.d.ts +0 -22
  65. package/dist/types-ts4.5/old-button/custom-theme-button/custom-theme-button.d.ts +0 -10
  66. package/dist/types-ts4.5/old-button/custom-theme-button/index.d.ts +0 -2
  67. package/dist/types-ts4.5/old-button/custom-theme-button/theme.d.ts +0 -21
  68. package/dist/types-ts4.5/old-button/loading-button.d.ts +0 -15
  69. package/dist/types-ts4.5/old-button/shared/block-events.d.ts +0 -4
  70. package/dist/types-ts4.5/old-button/shared/button-base.d.ts +0 -10
  71. package/dist/types-ts4.5/old-button/shared/colors.d.ts +0 -23
  72. package/dist/types-ts4.5/old-button/shared/css.d.ts +0 -22
  73. package/dist/types-ts4.5/old-button/shared/get-if-visually-hidden-children.d.ts +0 -2
  74. package/dist/types-ts4.5/old-button/shared/get-is-only-single-icon.d.ts +0 -2
  75. package/dist/types-ts4.5/old-button/shared/loading-spinner.d.ts +0 -5
  76. package/dist/types-ts4.5/old-button/types.d.ts +0 -94
  77. package/dist/types-ts4.5/utils/appearances.d.ts +0 -3
  78. package/dist/types-ts4.5/utils/spacing.d.ts +0 -3
  79. package/dist/types-ts4.5/utils/variants.d.ts +0 -15
  80. package/tmp/api-report-tmp.d.ts +0 -133
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ var _react = _interopRequireDefault(require("react"));
10
+ var _primitives = require("@atlaskit/primitives");
11
+ var textStyles = (0, _primitives.xcss)({
12
+ // content can grow and shrink
13
+ flexGrow: 1,
14
+ flexShrink: 1,
15
+ // ellipsis for overflow text
16
+ overflow: 'hidden',
17
+ textOverflow: 'ellipsis',
18
+ whiteSpace: 'nowrap'
19
+ });
20
+ var iconStyles = (0, _primitives.xcss)({
21
+ display: 'flex',
22
+ // icon size cannot grow and shrink
23
+ flexGrow: 0,
24
+ flexShrink: 0,
25
+ alignSelf: 'center',
26
+ fontSize: 0,
27
+ lineHeight: 0,
28
+ userSelect: 'none'
29
+ });
30
+ var commonStyles = (0, _primitives.xcss)({
31
+ transition: 'opacity 0.3s'
32
+ });
33
+ var fadeStyles = (0, _primitives.xcss)({
34
+ opacity: 0
35
+ });
36
+ /**
37
+ * __Content__
38
+ *
39
+ * Used for slots within a Button, including icons and text content.
40
+ */
41
+ var Content = function Content(_ref) {
42
+ var children = _ref.children,
43
+ _ref$type = _ref.type,
44
+ type = _ref$type === void 0 ? 'text' : _ref$type,
45
+ hasOverlay = _ref.hasOverlay;
46
+ return /*#__PURE__*/_react.default.createElement(_primitives.Box, {
47
+ as: "span",
48
+ xcss: [commonStyles].concat((0, _toConsumableArray2.default)(type === 'text' ? [textStyles] : [iconStyles]), (0, _toConsumableArray2.default)(hasOverlay ? [fadeStyles] : []))
49
+ }, children);
50
+ };
51
+ var _default = exports.default = Content;
@@ -21,6 +21,17 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
21
21
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } // eslint-disable-next-line no-duplicate-imports
22
22
  // Include modified onClick with analytics
23
23
 
24
+ var overlayStyles = (0, _primitives.xcss)({
25
+ position: 'absolute',
26
+ insetInlineStart: 'space.0',
27
+ insetBlockStart: 'space.0',
28
+ insetInlineEnd: 'space.0',
29
+ insetBlockEnd: 'space.0',
30
+ display: 'flex',
31
+ alignItems: 'center',
32
+ justifyContent: 'center'
33
+ });
34
+
24
35
  /**
25
36
  * __Use button base__
26
37
  *
@@ -95,7 +106,7 @@ var useButtonBase = function useButtonBase(_ref) {
95
106
  action: 'clicked',
96
107
  componentName: 'button',
97
108
  packageName: "@atlaskit/button",
98
- packageVersion: "16.10.1",
109
+ packageVersion: "16.10.2",
99
110
  analyticsData: analyticsContext,
100
111
  actionSubject: buttonType
101
112
  });
@@ -121,7 +132,7 @@ var useButtonBase = function useButtonBase(_ref) {
121
132
  isDisabled: isEffectivelyDisabled,
122
133
  children: /*#__PURE__*/_react.default.createElement(_react.Fragment, null, children, overlay ? /*#__PURE__*/_react.default.createElement(_primitives.Box, {
123
134
  as: "span",
124
- xcss: _xcss.overlayStyles
135
+ xcss: overlayStyles
125
136
  }, overlay) : null)
126
137
  }, (0, _blockEvents.default)(isEffectivelyDisabled, {
127
138
  onClick: onClick,
@@ -136,5 +147,4 @@ var useButtonBase = function useButtonBase(_ref) {
136
147
  onClickCapture: onClickCapture
137
148
  }));
138
149
  };
139
- var _default = useButtonBase;
140
- exports.default = _default;
150
+ var _default = exports.default = useButtonBase;
@@ -4,10 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.contentStyles = void 0;
8
- exports.getFadingStyles = getFadingStyles;
9
7
  exports.getXCSS = getXCSS;
10
- exports.overlayStyles = exports.iconStyles = void 0;
11
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
9
  var _primitives = require("@atlaskit/primitives");
13
10
  var _constants = require("@atlaskit/theme/constants");
@@ -149,43 +146,4 @@ function getXCSS(_ref3) {
149
146
  transitionDuration: '0s, 0s'
150
147
  })
151
148
  }));
152
- }
153
- var iconStyles = (0, _primitives.xcss)({
154
- display: 'flex',
155
- // icon size cannot grow and shrink
156
- flexGrow: 0,
157
- flexShrink: 0,
158
- alignSelf: 'center',
159
- fontSize: 0,
160
- lineHeight: 0,
161
- userSelect: 'none'
162
- });
163
- exports.iconStyles = iconStyles;
164
- var contentStyles = (0, _primitives.xcss)({
165
- // content can grow and shrink
166
- flexGrow: 1,
167
- flexShrink: 1,
168
- // ellipsis for overflow text
169
- overflow: 'hidden',
170
- textOverflow: 'ellipsis',
171
- whiteSpace: 'nowrap'
172
- });
173
- exports.contentStyles = contentStyles;
174
- function getFadingStyles(_ref4) {
175
- var hasOverlay = _ref4.hasOverlay;
176
- return (0, _primitives.xcss)({
177
- opacity: hasOverlay ? 0 : 1,
178
- transition: 'opacity 0.3s'
179
- });
180
- }
181
- var overlayStyles = (0, _primitives.xcss)({
182
- position: 'absolute',
183
- left: 'space.0',
184
- top: 'space.0',
185
- right: 'space.0',
186
- bottom: 'space.0',
187
- display: 'flex',
188
- alignItems: 'center',
189
- justifyContent: 'center'
190
- });
191
- exports.overlayStyles = overlayStyles;
149
+ }
@@ -101,5 +101,4 @@ var Button = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.default.forwa
101
101
 
102
102
  // Tools including enzyme rely on components having a display name
103
103
  Button.displayName = 'Button';
104
- var _default = Button;
105
- exports.default = _default;
104
+ var _default = exports.default = Button;
@@ -200,5 +200,4 @@ var CustomThemeButton = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.de
200
200
 
201
201
  // Tools including enzyme rely on components having a display name
202
202
  CustomThemeButton.displayName = 'CustomThemeButton';
203
- var _default = CustomThemeButton;
204
- exports.default = _default;
203
+ var _default = exports.default = CustomThemeButton;
@@ -98,5 +98,4 @@ var Theme = (0, _components.createTheme)(function (themeProps) {
98
98
  });
99
99
 
100
100
  // eslint-disable-next-line @repo/internal/react/require-jsdoc
101
- var _default = Theme;
102
- exports.default = _default;
101
+ var _default = exports.default = Theme;
@@ -45,5 +45,4 @@ var LoadingButton = /*#__PURE__*/_react.default.forwardRef(function LoadingButto
45
45
 
46
46
  // Tools including enzyme rely on components having a display name
47
47
  LoadingButton.displayName = 'LoadingButton';
48
- var _default = LoadingButton;
49
- exports.default = _default;
48
+ var _default = exports.default = LoadingButton;
@@ -21,6 +21,7 @@ var _blockEvents = _interopRequireDefault(require("./block-events"));
21
21
  var _css = require("./css");
22
22
  var _getIfVisuallyHiddenChildren = require("./get-if-visually-hidden-children");
23
23
  var _excluded = ["analyticsContext", "appearance", "autoFocus", "buttonCss", "children", "className", "href", "component", "iconAfter", "iconBefore", "interactionName", "isDisabled", "isSelected", "onBlur", "onClick", "onFocus", "onMouseDown", "overlay", "shouldFitContainer", "spacing", "tabIndex", "type", "testId"];
24
+ /* eslint-disable @atlaskit/design-system/consistent-css-prop-usage */
24
25
  /** @jsx jsx */
25
26
  // eslint-disable-next-line no-duplicate-imports
26
27
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -54,7 +55,7 @@ var getChildren = function getChildren(children, childrenStyles) {
54
55
  css: childrenStyles
55
56
  }, children) : null;
56
57
  };
57
- var _default = /*#__PURE__*/_react.default.forwardRef(function ButtonBase(props, ref) {
58
+ var _default = exports.default = /*#__PURE__*/_react.default.forwardRef(function ButtonBase(props, ref) {
58
59
  var analyticsContext = props.analyticsContext,
59
60
  _props$appearance = props.appearance,
60
61
  appearance = _props$appearance === void 0 ? 'default' : _props$appearance,
@@ -117,7 +118,7 @@ var _default = /*#__PURE__*/_react.default.forwardRef(function ButtonBase(props,
117
118
  action: 'clicked',
118
119
  componentName: 'button',
119
120
  packageName: "@atlaskit/button",
120
- packageVersion: "16.10.1",
121
+ packageVersion: "16.10.2",
121
122
  analyticsData: analyticsContext
122
123
  });
123
124
 
@@ -137,7 +138,7 @@ var _default = /*#__PURE__*/_react.default.forwardRef(function ButtonBase(props,
137
138
 
138
139
  // we are 'disabling' input with a button when there is an overlay
139
140
  var hasOverlay = Boolean(overlay);
140
- var fadeCss = (0, _react2.css)((0, _css.getFadingCss)({
141
+ var fadeStyles = (0, _react2.css)((0, _css.getFadingCss)({
141
142
  hasOverlay: hasOverlay
142
143
  }));
143
144
  var isInteractive = !isDisabled && !hasOverlay;
@@ -178,21 +179,20 @@ var _default = /*#__PURE__*/_react.default.forwardRef(function ButtonBase(props,
178
179
  }, (0, _blockEvents.default)({
179
180
  isInteractive: isInteractive
180
181
  })), iconBefore ? (0, _react2.jsx)("span", {
181
- css: [fadeCss, (0, _css.getIconStyle)({
182
+ css: [fadeStyles, (0, _css.getIconStyle)({
182
183
  spacing: spacing
183
184
  }), getSpacingFix(children, iconBeforeSpacingFixStyle)]
184
185
  }, iconBefore) : null, !(0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.icon-button-spacing-fix_o1zc5') && children ? (0, _react2.jsx)("span", {
185
- css: [fadeCss, (0, _css.getContentStyle)({
186
+ css: [fadeStyles, (0, _css.getContentStyle)({
186
187
  spacing: spacing
187
188
  })]
188
- }, children) : null, (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.icon-button-spacing-fix_o1zc5') && getChildren(children, [fadeCss, (0, _css.getContentStyle)({
189
+ }, children) : null, (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.icon-button-spacing-fix_o1zc5') && getChildren(children, [fadeStyles, (0, _css.getContentStyle)({
189
190
  spacing: spacing
190
191
  })]), iconAfter ? (0, _react2.jsx)("span", {
191
- css: [fadeCss, (0, _css.getIconStyle)({
192
+ css: [fadeStyles, (0, _css.getIconStyle)({
192
193
  spacing: spacing
193
194
  }), getSpacingFix(children, iconAfterSpacingFixStyle)]
194
195
  }, iconAfter) : null, overlay ? (0, _react2.jsx)("span", {
195
196
  css: [_css.overlayCss, spinnerHackCss]
196
197
  }, overlay) : null));
197
- });
198
- exports.default = _default;
198
+ });
@@ -326,5 +326,4 @@ var values = {
326
326
  }
327
327
  }
328
328
  };
329
- var _default = values;
330
- exports.default = _default;
329
+ var _default = exports.default = values;
@@ -229,7 +229,7 @@ function getFadingCss(_ref6) {
229
229
  transition: 'opacity 0.3s'
230
230
  });
231
231
  }
232
- var overlayCss = {
232
+ var overlayCss = exports.overlayCss = {
233
233
  // stretching to full width / height of button
234
234
  // this is important as we need it to still block
235
235
  // event if clicking in the button's own padding
@@ -242,5 +242,4 @@ var overlayCss = {
242
242
  display: 'flex',
243
243
  justifyContent: 'center',
244
244
  alignItems: 'center'
245
- };
246
- exports.overlayCss = overlayCss;
245
+ };
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.getIfVisuallyHiddenChildren = void 0;
8
8
  var _react = require("react");
9
9
  var _visuallyHidden = _interopRequireDefault(require("@atlaskit/visually-hidden"));
10
- var getIfVisuallyHiddenChildren = function getIfVisuallyHiddenChildren(children) {
10
+ var getIfVisuallyHiddenChildren = exports.getIfVisuallyHiddenChildren = function getIfVisuallyHiddenChildren(children) {
11
11
  return children && /*#__PURE__*/(0, _react.isValidElement)(children) && children.type === _visuallyHidden.default;
12
- };
13
- exports.getIfVisuallyHiddenChildren = getIfVisuallyHiddenChildren;
12
+ };
@@ -5,5 +5,4 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var appearances = ['default', 'primary', 'link', 'subtle', 'subtle-link', 'warning', 'danger'];
8
- var _default = appearances;
9
- exports.default = _default;
8
+ var _default = exports.default = appearances;
@@ -5,5 +5,4 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var spacing = ['default', 'compact', 'none'];
8
- var _default = spacing;
9
- exports.default = _default;
8
+ var _default = exports.default = spacing;
@@ -21,7 +21,7 @@ var LinkButtonRender = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
21
21
  href: "#"
22
22
  }, props), props.children);
23
23
  });
24
- var variants = [{
24
+ var variants = exports.variants = [{
25
25
  name: 'Button',
26
26
  Component: _button.default,
27
27
  elementType: HTMLButtonElement
@@ -30,6 +30,4 @@ var variants = [{
30
30
  Component: LinkButtonRender,
31
31
  elementType: HTMLAnchorElement
32
32
  }];
33
- exports.variants = variants;
34
- var _default = variants;
35
- exports.default = _default;
33
+ var _default = exports.default = variants;
@@ -4,6 +4,7 @@ import { css, jsx } from '@emotion/react';
4
4
  const buttonGroupStyles = css({
5
5
  display: 'inline-flex',
6
6
  gap: "var(--ds-space-050, 4px)",
7
+ // eslint-disable-next-line @atlaskit/design-system/no-nested-styles
7
8
  '> *': {
8
9
  flex: '1 0 auto'
9
10
  }
@@ -1,7 +1,6 @@
1
1
  import React, { Fragment } from 'react';
2
- import { Box } from '@atlaskit/primitives';
2
+ import Content from '../shared/content';
3
3
  import useButtonBase from '../shared/use-button-base';
4
- import { contentStyles, getFadingStyles, iconStyles } from '../shared/xcss';
5
4
  /**
6
5
  * __Use default button base__
7
6
  *
@@ -37,23 +36,20 @@ const useDefaultButton = ({
37
36
  shouldFitContainer,
38
37
  spacing
39
38
  }) => {
40
- const fadeStyles = getFadingStyles({
41
- hasOverlay: Boolean(overlay)
42
- });
39
+ const hasOverlay = Boolean(overlay);
43
40
  const baseProps = useButtonBase({
44
41
  analyticsContext,
45
42
  appearance,
46
43
  autoFocus,
47
44
  buttonType,
48
- children: /*#__PURE__*/React.createElement(Fragment, null, iconBefore && /*#__PURE__*/React.createElement(Box, {
49
- as: "span",
50
- xcss: [fadeStyles, iconStyles]
51
- }, iconBefore), children && /*#__PURE__*/React.createElement(Box, {
52
- as: "span",
53
- xcss: [fadeStyles, contentStyles]
54
- }, children), iconAfter && /*#__PURE__*/React.createElement(Box, {
55
- as: "span",
56
- xcss: [fadeStyles, iconStyles]
45
+ children: /*#__PURE__*/React.createElement(Fragment, null, iconBefore && /*#__PURE__*/React.createElement(Content, {
46
+ type: "icon",
47
+ hasOverlay: hasOverlay
48
+ }, iconBefore), children && /*#__PURE__*/React.createElement(Content, {
49
+ hasOverlay: hasOverlay
50
+ }, children), iconAfter && /*#__PURE__*/React.createElement(Content, {
51
+ type: "icon",
52
+ hasOverlay: hasOverlay
57
53
  }, iconAfter)),
58
54
  interactionName,
59
55
  isDisabled,
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
- import { Box } from '@atlaskit/primitives';
2
+ import Content from '../shared/content';
3
3
  import useButtonBase from '../shared/use-button-base';
4
- import { getFadingStyles, iconStyles } from '../shared/xcss';
5
4
  /**
6
5
  * __Use icon button__
7
6
  *
@@ -37,9 +36,7 @@ const useIconButton = ({
37
36
  shouldFitContainer,
38
37
  spacing
39
38
  }) => {
40
- const fadeStyles = getFadingStyles({
41
- hasOverlay: Boolean(overlay)
42
- });
39
+ const hasOverlay = Boolean(overlay);
43
40
  const baseProps = useButtonBase({
44
41
  analyticsContext,
45
42
  appearance,
@@ -49,9 +46,9 @@ const useIconButton = ({
49
46
  * TODO: Have not finished IconButton yet. It also needs a required accessible
50
47
  * label - likely implemented using VisuallyHidden
51
48
  */
52
- children: /*#__PURE__*/React.createElement(Box, {
53
- as: "span",
54
- xcss: [fadeStyles, iconStyles]
49
+ children: /*#__PURE__*/React.createElement(Content, {
50
+ type: "icon",
51
+ hasOverlay: hasOverlay
55
52
  }, icon),
56
53
  interactionName,
57
54
  isDisabled,
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+ import { Box, xcss } from '@atlaskit/primitives';
3
+ const textStyles = xcss({
4
+ // content can grow and shrink
5
+ flexGrow: 1,
6
+ flexShrink: 1,
7
+ // ellipsis for overflow text
8
+ overflow: 'hidden',
9
+ textOverflow: 'ellipsis',
10
+ whiteSpace: 'nowrap'
11
+ });
12
+ const iconStyles = xcss({
13
+ display: 'flex',
14
+ // icon size cannot grow and shrink
15
+ flexGrow: 0,
16
+ flexShrink: 0,
17
+ alignSelf: 'center',
18
+ fontSize: 0,
19
+ lineHeight: 0,
20
+ userSelect: 'none'
21
+ });
22
+ const commonStyles = xcss({
23
+ transition: 'opacity 0.3s'
24
+ });
25
+ const fadeStyles = xcss({
26
+ opacity: 0
27
+ });
28
+ /**
29
+ * __Content__
30
+ *
31
+ * Used for slots within a Button, including icons and text content.
32
+ */
33
+ const Content = ({
34
+ children,
35
+ type = 'text',
36
+ hasOverlay
37
+ }) => {
38
+ return /*#__PURE__*/React.createElement(Box, {
39
+ as: "span",
40
+ xcss: [commonStyles, ...(type === 'text' ? [textStyles] : [iconStyles]), ...(hasOverlay ? [fadeStyles] : [])]
41
+ }, children);
42
+ };
43
+ export default Content;
@@ -4,12 +4,23 @@ import noop from '@atlaskit/ds-lib/noop';
4
4
  import useAutoFocus from '@atlaskit/ds-lib/use-auto-focus';
5
5
  // eslint-disable-next-line no-duplicate-imports
6
6
  import InteractionContext from '@atlaskit/interaction-context';
7
- import { Box } from '@atlaskit/primitives';
7
+ import { Box, xcss } from '@atlaskit/primitives';
8
8
  import blockEvents from './block-events';
9
- import { getXCSS, overlayStyles } from './xcss';
9
+ import { getXCSS } from './xcss';
10
10
 
11
11
  // Include modified onClick with analytics
12
12
 
13
+ const overlayStyles = xcss({
14
+ position: 'absolute',
15
+ insetInlineStart: 'space.0',
16
+ insetBlockStart: 'space.0',
17
+ insetInlineEnd: 'space.0',
18
+ insetBlockEnd: 'space.0',
19
+ display: 'flex',
20
+ alignItems: 'center',
21
+ justifyContent: 'center'
22
+ });
23
+
13
24
  /**
14
25
  * __Use button base__
15
26
  *
@@ -77,7 +88,7 @@ const useButtonBase = ({
77
88
  action: 'clicked',
78
89
  componentName: 'button',
79
90
  packageName: "@atlaskit/button",
80
- packageVersion: "16.10.1",
91
+ packageVersion: "16.10.2",
81
92
  analyticsData: analyticsContext,
82
93
  actionSubject: buttonType
83
94
  });
@@ -142,41 +142,4 @@ export function getXCSS({
142
142
  transitionDuration: '0s, 0s'
143
143
  }
144
144
  });
145
- }
146
- export const iconStyles = xcss({
147
- display: 'flex',
148
- // icon size cannot grow and shrink
149
- flexGrow: 0,
150
- flexShrink: 0,
151
- alignSelf: 'center',
152
- fontSize: 0,
153
- lineHeight: 0,
154
- userSelect: 'none'
155
- });
156
- export const contentStyles = xcss({
157
- // content can grow and shrink
158
- flexGrow: 1,
159
- flexShrink: 1,
160
- // ellipsis for overflow text
161
- overflow: 'hidden',
162
- textOverflow: 'ellipsis',
163
- whiteSpace: 'nowrap'
164
- });
165
- export function getFadingStyles({
166
- hasOverlay
167
- }) {
168
- return xcss({
169
- opacity: hasOverlay ? 0 : 1,
170
- transition: 'opacity 0.3s'
171
- });
172
- }
173
- export const overlayStyles = xcss({
174
- position: 'absolute',
175
- left: 'space.0',
176
- top: 'space.0',
177
- right: 'space.0',
178
- bottom: 'space.0',
179
- display: 'flex',
180
- alignItems: 'center',
181
- justifyContent: 'center'
182
- });
145
+ }
@@ -1,4 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ /* eslint-disable @atlaskit/design-system/consistent-css-prop-usage */
2
3
  /** @jsx jsx */
3
4
  import React, { useCallback, useContext, useEffect, useRef } from 'react';
4
5
  import { css, jsx } from '@emotion/react';
@@ -102,7 +103,7 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
102
103
  action: 'clicked',
103
104
  componentName: 'button',
104
105
  packageName: "@atlaskit/button",
105
- packageVersion: "16.10.1",
106
+ packageVersion: "16.10.2",
106
107
  analyticsData: analyticsContext
107
108
  });
108
109
 
@@ -122,7 +123,7 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
122
123
 
123
124
  // we are 'disabling' input with a button when there is an overlay
124
125
  const hasOverlay = Boolean(overlay);
125
- const fadeCss = css(getFadingCss({
126
+ const fadeStyles = css(getFadingCss({
126
127
  hasOverlay
127
128
  }));
128
129
  const isInteractive = !isDisabled && !hasOverlay;
@@ -163,17 +164,17 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
163
164
  }, blockEvents({
164
165
  isInteractive
165
166
  })), iconBefore ? jsx("span", {
166
- css: [fadeCss, getIconStyle({
167
+ css: [fadeStyles, getIconStyle({
167
168
  spacing
168
169
  }), getSpacingFix(children, iconBeforeSpacingFixStyle)]
169
170
  }, iconBefore) : null, !getBooleanFF('platform.design-system-team.icon-button-spacing-fix_o1zc5') && children ? jsx("span", {
170
- css: [fadeCss, getContentStyle({
171
+ css: [fadeStyles, getContentStyle({
171
172
  spacing
172
173
  })]
173
- }, children) : null, getBooleanFF('platform.design-system-team.icon-button-spacing-fix_o1zc5') && getChildren(children, [fadeCss, getContentStyle({
174
+ }, children) : null, getBooleanFF('platform.design-system-team.icon-button-spacing-fix_o1zc5') && getChildren(children, [fadeStyles, getContentStyle({
174
175
  spacing
175
176
  })]), iconAfter ? jsx("span", {
176
- css: [fadeCss, getIconStyle({
177
+ css: [fadeStyles, getIconStyle({
177
178
  spacing
178
179
  }), getSpacingFix(children, iconAfterSpacingFixStyle)]
179
180
  }, iconAfter) : null, overlay ? jsx("span", {
@@ -4,6 +4,7 @@ import { css, jsx } from '@emotion/react';
4
4
  var buttonGroupStyles = css({
5
5
  display: 'inline-flex',
6
6
  gap: "var(--ds-space-050, 4px)",
7
+ // eslint-disable-next-line @atlaskit/design-system/no-nested-styles
7
8
  '> *': {
8
9
  flex: '1 0 auto'
9
10
  }
@@ -1,7 +1,6 @@
1
1
  import React, { Fragment } from 'react';
2
- import { Box } from '@atlaskit/primitives';
2
+ import Content from '../shared/content';
3
3
  import useButtonBase from '../shared/use-button-base';
4
- import { contentStyles, getFadingStyles, iconStyles } from '../shared/xcss';
5
4
  /**
6
5
  * __Use default button base__
7
6
  *
@@ -36,23 +35,20 @@ var useDefaultButton = function useDefaultButton(_ref) {
36
35
  ref = _ref.ref,
37
36
  shouldFitContainer = _ref.shouldFitContainer,
38
37
  spacing = _ref.spacing;
39
- var fadeStyles = getFadingStyles({
40
- hasOverlay: Boolean(overlay)
41
- });
38
+ var hasOverlay = Boolean(overlay);
42
39
  var baseProps = useButtonBase({
43
40
  analyticsContext: analyticsContext,
44
41
  appearance: appearance,
45
42
  autoFocus: autoFocus,
46
43
  buttonType: buttonType,
47
- children: /*#__PURE__*/React.createElement(Fragment, null, iconBefore && /*#__PURE__*/React.createElement(Box, {
48
- as: "span",
49
- xcss: [fadeStyles, iconStyles]
50
- }, iconBefore), children && /*#__PURE__*/React.createElement(Box, {
51
- as: "span",
52
- xcss: [fadeStyles, contentStyles]
53
- }, children), iconAfter && /*#__PURE__*/React.createElement(Box, {
54
- as: "span",
55
- xcss: [fadeStyles, iconStyles]
44
+ children: /*#__PURE__*/React.createElement(Fragment, null, iconBefore && /*#__PURE__*/React.createElement(Content, {
45
+ type: "icon",
46
+ hasOverlay: hasOverlay
47
+ }, iconBefore), children && /*#__PURE__*/React.createElement(Content, {
48
+ hasOverlay: hasOverlay
49
+ }, children), iconAfter && /*#__PURE__*/React.createElement(Content, {
50
+ type: "icon",
51
+ hasOverlay: hasOverlay
56
52
  }, iconAfter)),
57
53
  interactionName: interactionName,
58
54
  isDisabled: isDisabled,
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
- import { Box } from '@atlaskit/primitives';
2
+ import Content from '../shared/content';
3
3
  import useButtonBase from '../shared/use-button-base';
4
- import { getFadingStyles, iconStyles } from '../shared/xcss';
5
4
  /**
6
5
  * __Use icon button__
7
6
  *
@@ -34,9 +33,7 @@ var useIconButton = function useIconButton(_ref) {
34
33
  ref = _ref.ref,
35
34
  shouldFitContainer = _ref.shouldFitContainer,
36
35
  spacing = _ref.spacing;
37
- var fadeStyles = getFadingStyles({
38
- hasOverlay: Boolean(overlay)
39
- });
36
+ var hasOverlay = Boolean(overlay);
40
37
  var baseProps = useButtonBase({
41
38
  analyticsContext: analyticsContext,
42
39
  appearance: appearance,
@@ -46,9 +43,9 @@ var useIconButton = function useIconButton(_ref) {
46
43
  * TODO: Have not finished IconButton yet. It also needs a required accessible
47
44
  * label - likely implemented using VisuallyHidden
48
45
  */
49
- children: /*#__PURE__*/React.createElement(Box, {
50
- as: "span",
51
- xcss: [fadeStyles, iconStyles]
46
+ children: /*#__PURE__*/React.createElement(Content, {
47
+ type: "icon",
48
+ hasOverlay: hasOverlay
52
49
  }, icon),
53
50
  interactionName: interactionName,
54
51
  isDisabled: isDisabled,