@atlaskit/button 16.17.1 → 16.17.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 (32) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/new-button/variants/icon/button.js +8 -4
  3. package/dist/cjs/new-button/variants/icon/link.js +5 -3
  4. package/dist/cjs/new-button/variants/icon/use-icon-button.js +9 -3
  5. package/dist/cjs/new-button/variants/shared/use-button-base.js +1 -1
  6. package/dist/cjs/old-button/shared/button-base.js +1 -1
  7. package/dist/cjs/utils/variants.js +3 -61
  8. package/dist/es2019/new-button/variants/icon/button.js +7 -3
  9. package/dist/es2019/new-button/variants/icon/link.js +4 -2
  10. package/dist/es2019/new-button/variants/icon/use-icon-button.js +9 -5
  11. package/dist/es2019/new-button/variants/shared/use-button-base.js +1 -1
  12. package/dist/es2019/old-button/shared/button-base.js +1 -1
  13. package/dist/es2019/utils/variants.js +2 -59
  14. package/dist/esm/new-button/variants/icon/button.js +8 -4
  15. package/dist/esm/new-button/variants/icon/link.js +5 -3
  16. package/dist/esm/new-button/variants/icon/use-icon-button.js +9 -3
  17. package/dist/esm/new-button/variants/shared/use-button-base.js +1 -1
  18. package/dist/esm/old-button/shared/button-base.js +1 -1
  19. package/dist/esm/utils/variants.js +3 -64
  20. package/dist/types/new-button/variants/icon/button.d.ts +2 -2
  21. package/dist/types/new-button/variants/icon/link.d.ts +3 -3
  22. package/dist/types/new-button/variants/icon/types.d.ts +19 -4
  23. package/dist/types/new-button/variants/icon/use-icon-button.d.ts +1 -1
  24. package/dist/types/new-button/variants/types.d.ts +5 -4
  25. package/dist/types/utils/variants.d.ts +3 -15
  26. package/dist/types-ts4.5/new-button/variants/icon/button.d.ts +2 -2
  27. package/dist/types-ts4.5/new-button/variants/icon/link.d.ts +3 -3
  28. package/dist/types-ts4.5/new-button/variants/icon/types.d.ts +19 -4
  29. package/dist/types-ts4.5/new-button/variants/icon/use-icon-button.d.ts +1 -1
  30. package/dist/types-ts4.5/new-button/variants/types.d.ts +5 -4
  31. package/dist/types-ts4.5/utils/variants.d.ts +3 -15
  32. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/button
2
2
 
3
+ ## 16.17.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#43263](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/43263) [`09f29df6245`](https://bitbucket.org/atlassian/atlassian-frontend/commits/09f29df6245) - Update IconButton API to be bounded with unsafe fallback for icon sizing
8
+
3
9
  ## 16.17.1
4
10
 
5
11
  ### Patch Changes
@@ -10,7 +10,7 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
10
10
  var _react = _interopRequireDefault(require("react"));
11
11
  var _pressable = _interopRequireDefault(require("@atlaskit/primitives/pressable"));
12
12
  var _useIconButton = _interopRequireDefault(require("./use-icon-button"));
13
- var _excluded = ["analyticsContext", "autoFocus", "appearance", "spacing", "isDisabled", "isSelected", "icon", "children", "interactionName", "overlay", "onClick", "onMouseDownCapture", "onMouseUpCapture", "onKeyDownCapture", "onKeyUpCapture", "onTouchStartCapture", "onTouchEndCapture", "onPointerDownCapture", "onPointerUpCapture", "onClickCapture", "type", "testId"];
13
+ var _excluded = ["analyticsContext", "autoFocus", "appearance", "spacing", "isDisabled", "isSelected", "icon", "interactionName", "label", "overlay", "onClick", "onMouseDownCapture", "onMouseUpCapture", "onKeyDownCapture", "onKeyUpCapture", "onTouchStartCapture", "onTouchEndCapture", "onPointerDownCapture", "onPointerUpCapture", "onClickCapture", "type", "testId", "UNSAFE_size"];
14
14
  /**
15
15
  * __Icon Button__
16
16
  *
@@ -30,8 +30,8 @@ var IconButton = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.default.f
30
30
  isDisabled = _ref.isDisabled,
31
31
  isSelected = _ref.isSelected,
32
32
  icon = _ref.icon,
33
- children = _ref.children,
34
33
  interactionName = _ref.interactionName,
34
+ label = _ref.label,
35
35
  overlay = _ref.overlay,
36
36
  onClick = _ref.onClick,
37
37
  onMouseDownCapture = _ref.onMouseDownCapture,
@@ -46,6 +46,7 @@ var IconButton = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.default.f
46
46
  _ref$type = _ref.type,
47
47
  type = _ref$type === void 0 ? 'button' : _ref$type,
48
48
  testId = _ref.testId,
49
+ UNSAFE_size = _ref.UNSAFE_size,
49
50
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
50
51
  /**
51
52
  * TODO: At some stage I'll look into re-using more logic across 'default' and 'icon'
@@ -56,11 +57,13 @@ var IconButton = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.default.f
56
57
  appearance: appearance,
57
58
  autoFocus: autoFocus,
58
59
  buttonType: 'button',
59
- children: children,
60
+ children: null,
61
+ // Set in hook.
60
62
  icon: icon,
61
63
  interactionName: interactionName,
62
64
  isDisabled: isDisabled,
63
65
  isSelected: isSelected,
66
+ label: label,
64
67
  onClick: onClick,
65
68
  onMouseDownCapture: onMouseDownCapture,
66
69
  onMouseUpCapture: onMouseUpCapture,
@@ -73,7 +76,8 @@ var IconButton = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.default.f
73
76
  onClickCapture: onClickCapture,
74
77
  overlay: overlay,
75
78
  ref: ref,
76
- spacing: spacing
79
+ spacing: spacing,
80
+ UNSAFE_size: UNSAFE_size
77
81
  });
78
82
  return /*#__PURE__*/_react.default.createElement(_pressable.default, (0, _extends2.default)({}, rest, {
79
83
  ref: baseProps.ref,
@@ -11,7 +11,7 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
11
11
  var _react = _interopRequireWildcard(require("react"));
12
12
  var _link = _interopRequireDefault(require("@atlaskit/primitives/link"));
13
13
  var _useIconButton = _interopRequireDefault(require("./use-icon-button"));
14
- var _excluded = ["analyticsContext", "autoFocus", "appearance", "spacing", "isDisabled", "isSelected", "icon", "children", "interactionName", "overlay", "onClick", "onMouseDownCapture", "onMouseUpCapture", "onKeyDownCapture", "onKeyUpCapture", "onTouchStartCapture", "onTouchEndCapture", "onPointerDownCapture", "onPointerUpCapture", "onClickCapture", "testId", "href"];
14
+ var _excluded = ["analyticsContext", "autoFocus", "appearance", "spacing", "isDisabled", "isSelected", "icon", "interactionName", "label", "overlay", "onClick", "onMouseDownCapture", "onMouseUpCapture", "onKeyDownCapture", "onKeyUpCapture", "onTouchStartCapture", "onTouchEndCapture", "onPointerDownCapture", "onPointerUpCapture", "onClickCapture", "testId", "href"];
15
15
  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); }
16
16
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
17
  var LinkIconButtonBase = function LinkIconButtonBase(_ref, ref) {
@@ -22,8 +22,8 @@ var LinkIconButtonBase = function LinkIconButtonBase(_ref, ref) {
22
22
  isDisabled = _ref.isDisabled,
23
23
  isSelected = _ref.isSelected,
24
24
  icon = _ref.icon,
25
- children = _ref.children,
26
25
  interactionName = _ref.interactionName,
26
+ label = _ref.label,
27
27
  overlay = _ref.overlay,
28
28
  onClick = _ref.onClick,
29
29
  onMouseDownCapture = _ref.onMouseDownCapture,
@@ -43,11 +43,13 @@ var LinkIconButtonBase = function LinkIconButtonBase(_ref, ref) {
43
43
  appearance: appearance,
44
44
  autoFocus: autoFocus,
45
45
  buttonType: 'link',
46
- children: children,
46
+ children: null,
47
+ // Set in hook.
47
48
  icon: icon,
48
49
  interactionName: interactionName,
49
50
  isDisabled: isDisabled,
50
51
  isSelected: isSelected,
52
+ label: label,
51
53
  onClick: onClick,
52
54
  onMouseDownCapture: onMouseDownCapture,
53
55
  onMouseUpCapture: onMouseUpCapture,
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
+ var _visuallyHidden = _interopRequireDefault(require("@atlaskit/visually-hidden"));
9
10
  var _content = _interopRequireDefault(require("../shared/content"));
10
11
  var _useButtonBase = _interopRequireDefault(require("../shared/use-button-base"));
11
12
  /**
@@ -22,10 +23,11 @@ var useIconButton = function useIconButton(_ref) {
22
23
  appearance = _ref.appearance,
23
24
  autoFocus = _ref.autoFocus,
24
25
  buttonType = _ref.buttonType,
25
- icon = _ref.icon,
26
+ Icon = _ref.icon,
26
27
  interactionName = _ref.interactionName,
27
28
  isDisabled = _ref.isDisabled,
28
29
  isSelected = _ref.isSelected,
30
+ label = _ref.label,
29
31
  onClick = _ref.onClick,
30
32
  onMouseDownCapture = _ref.onMouseDownCapture,
31
33
  onMouseUpCapture = _ref.onMouseUpCapture,
@@ -39,7 +41,8 @@ var useIconButton = function useIconButton(_ref) {
39
41
  overlay = _ref.overlay,
40
42
  ref = _ref.ref,
41
43
  shouldFitContainer = _ref.shouldFitContainer,
42
- spacing = _ref.spacing;
44
+ spacing = _ref.spacing,
45
+ UNSAFE_size = _ref.UNSAFE_size;
43
46
  var hasOverlay = Boolean(overlay);
44
47
  var baseProps = (0, _useButtonBase.default)({
45
48
  analyticsContext: analyticsContext,
@@ -53,7 +56,10 @@ var useIconButton = function useIconButton(_ref) {
53
56
  children: /*#__PURE__*/_react.default.createElement(_content.default, {
54
57
  type: "icon",
55
58
  hasOverlay: hasOverlay
56
- }, icon),
59
+ }, /*#__PURE__*/_react.default.createElement(Icon, {
60
+ label: "",
61
+ size: UNSAFE_size
62
+ }), /*#__PURE__*/_react.default.createElement(_visuallyHidden.default, null, label)),
57
63
  interactionName: interactionName,
58
64
  isDisabled: isDisabled,
59
65
  isSelected: isSelected,
@@ -115,7 +115,7 @@ var useButtonBase = function useButtonBase(_ref) {
115
115
  action: 'clicked',
116
116
  componentName: 'button',
117
117
  packageName: "@atlaskit/button",
118
- packageVersion: "16.17.1",
118
+ packageVersion: "16.17.2",
119
119
  analyticsData: analyticsContext,
120
120
  actionSubject: buttonType
121
121
  });
@@ -118,7 +118,7 @@ var _default = exports.default = /*#__PURE__*/_react.default.forwardRef(function
118
118
  action: 'clicked',
119
119
  componentName: 'button',
120
120
  packageName: "@atlaskit/button",
121
- packageVersion: "16.17.1",
121
+ packageVersion: "16.17.2",
122
122
  analyticsData: analyticsContext
123
123
  });
124
124
 
@@ -9,16 +9,10 @@ exports.linkButtonVariants = exports.default = void 0;
9
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
10
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
11
  var _react = _interopRequireWildcard(require("react"));
12
- var _add = _interopRequireDefault(require("@atlaskit/icon/glyph/add"));
13
12
  var _button = _interopRequireDefault(require("../new-button/variants/default/button"));
14
13
  var _link = _interopRequireDefault(require("../new-button/variants/default/link"));
15
- var _link2 = _interopRequireDefault(require("../new-button/variants/icon/link"));
16
- var _appearances = require("../utils/appearances");
17
- var _excluded = ["href", "children"],
18
- _excluded2 = ["href", "children", "icon"]; // eslint-disable-next-line import/no-extraneous-dependencies
19
- // import IconButton, {
20
- // IconButtonProps,
21
- // } from '../new-button/variants/icon/button';
14
+ var _appearances = require("./appearances");
15
+ var _excluded = ["href", "children"];
22
16
  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); }
23
17
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
24
18
  // Add required default props to variants
@@ -32,51 +26,11 @@ var LinkButtonRender = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref)
32
26
  href: href
33
27
  }, rest), children);
34
28
  });
35
-
36
- // TODO: Enable icon button in tests once it's ready
37
- // const IconButtonRender = forwardRef(
38
- // (
39
- // {
40
- // children,
41
- // icon = <AddIcon label="" />,
42
- // ...rest
43
- // }: Omit<IconButtonProps, 'icon'> & {
44
- // icon?: IconButtonProps['icon'];
45
- // },
46
- // ref: React.Ref<HTMLButtonElement>,
47
- // ) => (
48
- // <IconButton ref={ref} icon={icon} {...rest}>
49
- // {children}
50
- // </IconButton>
51
- // ),
52
- // );
53
-
54
- var LinkIconButtonRender = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
55
- var _ref2$href = _ref2.href,
56
- href = _ref2$href === void 0 ? '/home' : _ref2$href,
57
- children = _ref2.children,
58
- _ref2$icon = _ref2.icon,
59
- icon = _ref2$icon === void 0 ? /*#__PURE__*/_react.default.createElement(_add.default, {
60
- label: ""
61
- }) : _ref2$icon,
62
- rest = (0, _objectWithoutProperties2.default)(_ref2, _excluded2);
63
- return /*#__PURE__*/_react.default.createElement(_link2.default, (0, _extends2.default)({
64
- ref: ref,
65
- icon: icon,
66
- href: href
67
- }, rest), children);
68
- });
69
29
  var linkButtonVariants = exports.linkButtonVariants = [{
70
30
  name: 'LinkButton',
71
31
  Component: LinkButtonRender,
72
32
  elementType: HTMLAnchorElement,
73
33
  appearances: _appearances.linkButtonAppearances
74
- }, {
75
- name: 'LinkIconButton',
76
- Component: LinkIconButtonRender,
77
- elementType: HTMLAnchorElement,
78
- // TODO: Make specific to icon button
79
- appearances: _appearances.linkButtonAppearances
80
34
  }];
81
35
  var variants = [{
82
36
  name: 'Button',
@@ -88,17 +42,5 @@ var variants = [{
88
42
  Component: LinkButtonRender,
89
43
  elementType: HTMLAnchorElement,
90
44
  appearances: _appearances.linkButtonAppearances
91
- }
92
- // TODO: Enable icon buttons in tests once it's ready
93
- // {
94
- // name: 'IconButton',
95
- // Component: IconButtonRender,
96
- // elementType: HTMLButtonElement,
97
- // },
98
- // {
99
- // name: 'LinkIconButton',
100
- // Component: LinkIconButtonRender,
101
- // elementType: HTMLAnchorElement,
102
- // },
103
- ];
45
+ }];
104
46
  var _default = exports.default = variants;
@@ -21,8 +21,8 @@ const IconButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(functi
21
21
  isDisabled,
22
22
  isSelected,
23
23
  icon,
24
- children,
25
24
  interactionName,
25
+ label,
26
26
  overlay,
27
27
  onClick,
28
28
  onMouseDownCapture,
@@ -36,6 +36,7 @@ const IconButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(functi
36
36
  onClickCapture,
37
37
  type = 'button',
38
38
  testId,
39
+ UNSAFE_size,
39
40
  ...rest
40
41
  }, ref) {
41
42
  /**
@@ -47,11 +48,13 @@ const IconButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(functi
47
48
  appearance,
48
49
  autoFocus,
49
50
  buttonType: 'button',
50
- children,
51
+ children: null,
52
+ // Set in hook.
51
53
  icon,
52
54
  interactionName,
53
55
  isDisabled,
54
56
  isSelected,
57
+ label,
55
58
  onClick,
56
59
  onMouseDownCapture,
57
60
  onMouseUpCapture,
@@ -64,7 +67,8 @@ const IconButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(functi
64
67
  onClickCapture,
65
68
  overlay,
66
69
  ref,
67
- spacing
70
+ spacing,
71
+ UNSAFE_size
68
72
  });
69
73
  return /*#__PURE__*/React.createElement(UNSAFE_PRESSABLE, _extends({}, rest, {
70
74
  ref: baseProps.ref,
@@ -10,8 +10,8 @@ const LinkIconButtonBase = ({
10
10
  isDisabled,
11
11
  isSelected,
12
12
  icon,
13
- children,
14
13
  interactionName,
14
+ label,
15
15
  overlay,
16
16
  onClick,
17
17
  onMouseDownCapture,
@@ -32,11 +32,13 @@ const LinkIconButtonBase = ({
32
32
  appearance,
33
33
  autoFocus,
34
34
  buttonType: 'link',
35
- children,
35
+ children: null,
36
+ // Set in hook.
36
37
  icon,
37
38
  interactionName,
38
39
  isDisabled,
39
40
  isSelected,
41
+ label,
40
42
  onClick,
41
43
  onMouseDownCapture,
42
44
  onMouseUpCapture,
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import VisuallyHidden from '@atlaskit/visually-hidden';
2
3
  import Content from '../shared/content';
3
4
  import useButtonBase from '../shared/use-button-base';
4
5
  /**
@@ -15,12 +16,11 @@ const useIconButton = ({
15
16
  appearance,
16
17
  autoFocus,
17
18
  buttonType,
18
- icon,
19
+ icon: Icon,
19
20
  interactionName,
20
21
  isDisabled,
21
22
  isSelected,
22
- // TODO: Will potentially remove children prop from IconButton
23
- // children,
23
+ label,
24
24
  onClick,
25
25
  onMouseDownCapture,
26
26
  onMouseUpCapture,
@@ -34,7 +34,8 @@ const useIconButton = ({
34
34
  overlay,
35
35
  ref,
36
36
  shouldFitContainer,
37
- spacing
37
+ spacing,
38
+ UNSAFE_size
38
39
  }) => {
39
40
  const hasOverlay = Boolean(overlay);
40
41
  const baseProps = useButtonBase({
@@ -49,7 +50,10 @@ const useIconButton = ({
49
50
  children: /*#__PURE__*/React.createElement(Content, {
50
51
  type: "icon",
51
52
  hasOverlay: hasOverlay
52
- }, icon),
53
+ }, /*#__PURE__*/React.createElement(Icon, {
54
+ label: "",
55
+ size: UNSAFE_size
56
+ }), /*#__PURE__*/React.createElement(VisuallyHidden, null, label)),
53
57
  interactionName,
54
58
  isDisabled,
55
59
  isSelected,
@@ -97,7 +97,7 @@ const useButtonBase = ({
97
97
  action: 'clicked',
98
98
  componentName: 'button',
99
99
  packageName: "@atlaskit/button",
100
- packageVersion: "16.17.1",
100
+ packageVersion: "16.17.2",
101
101
  analyticsData: analyticsContext,
102
102
  actionSubject: buttonType
103
103
  });
@@ -103,7 +103,7 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
103
103
  action: 'clicked',
104
104
  componentName: 'button',
105
105
  packageName: "@atlaskit/button",
106
- packageVersion: "16.17.1",
106
+ packageVersion: "16.17.2",
107
107
  analyticsData: analyticsContext
108
108
  });
109
109
 
@@ -1,15 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { forwardRef } from 'react';
3
-
4
- // eslint-disable-next-line import/no-extraneous-dependencies
5
- import AddIcon from '@atlaskit/icon/glyph/add';
6
3
  import Button from '../new-button/variants/default/button';
7
4
  import LinkButton from '../new-button/variants/default/link';
8
- // import IconButton, {
9
- // IconButtonProps,
10
- // } from '../new-button/variants/icon/button';
11
- import LinkIconButton from '../new-button/variants/icon/link';
12
- import { buttonAppearances, linkButtonAppearances } from '../utils/appearances';
5
+ import { buttonAppearances, linkButtonAppearances } from './appearances';
13
6
  // Add required default props to variants
14
7
  const LinkButtonRender = /*#__PURE__*/forwardRef(({
15
8
  href = 'home',
@@ -19,48 +12,11 @@ const LinkButtonRender = /*#__PURE__*/forwardRef(({
19
12
  ref: ref,
20
13
  href: href
21
14
  }, rest), children));
22
-
23
- // TODO: Enable icon button in tests once it's ready
24
- // const IconButtonRender = forwardRef(
25
- // (
26
- // {
27
- // children,
28
- // icon = <AddIcon label="" />,
29
- // ...rest
30
- // }: Omit<IconButtonProps, 'icon'> & {
31
- // icon?: IconButtonProps['icon'];
32
- // },
33
- // ref: React.Ref<HTMLButtonElement>,
34
- // ) => (
35
- // <IconButton ref={ref} icon={icon} {...rest}>
36
- // {children}
37
- // </IconButton>
38
- // ),
39
- // );
40
-
41
- const LinkIconButtonRender = /*#__PURE__*/forwardRef(({
42
- href = '/home',
43
- children,
44
- icon = /*#__PURE__*/React.createElement(AddIcon, {
45
- label: ""
46
- }),
47
- ...rest
48
- }, ref) => /*#__PURE__*/React.createElement(LinkIconButton, _extends({
49
- ref: ref,
50
- icon: icon,
51
- href: href
52
- }, rest), children));
53
15
  export const linkButtonVariants = [{
54
16
  name: 'LinkButton',
55
17
  Component: LinkButtonRender,
56
18
  elementType: HTMLAnchorElement,
57
19
  appearances: linkButtonAppearances
58
- }, {
59
- name: 'LinkIconButton',
60
- Component: LinkIconButtonRender,
61
- elementType: HTMLAnchorElement,
62
- // TODO: Make specific to icon button
63
- appearances: linkButtonAppearances
64
20
  }];
65
21
  const variants = [{
66
22
  name: 'Button',
@@ -72,18 +28,5 @@ const variants = [{
72
28
  Component: LinkButtonRender,
73
29
  elementType: HTMLAnchorElement,
74
30
  appearances: linkButtonAppearances
75
- }
76
- // TODO: Enable icon buttons in tests once it's ready
77
- // {
78
- // name: 'IconButton',
79
- // Component: IconButtonRender,
80
- // elementType: HTMLButtonElement,
81
- // },
82
- // {
83
- // name: 'LinkIconButton',
84
- // Component: LinkIconButtonRender,
85
- // elementType: HTMLAnchorElement,
86
- // },
87
- ];
88
-
31
+ }];
89
32
  export default variants;
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["analyticsContext", "autoFocus", "appearance", "spacing", "isDisabled", "isSelected", "icon", "children", "interactionName", "overlay", "onClick", "onMouseDownCapture", "onMouseUpCapture", "onKeyDownCapture", "onKeyUpCapture", "onTouchStartCapture", "onTouchEndCapture", "onPointerDownCapture", "onPointerUpCapture", "onClickCapture", "type", "testId"];
3
+ var _excluded = ["analyticsContext", "autoFocus", "appearance", "spacing", "isDisabled", "isSelected", "icon", "interactionName", "label", "overlay", "onClick", "onMouseDownCapture", "onMouseUpCapture", "onKeyDownCapture", "onKeyUpCapture", "onTouchStartCapture", "onTouchEndCapture", "onPointerDownCapture", "onPointerUpCapture", "onClickCapture", "type", "testId", "UNSAFE_size"];
4
4
  import React from 'react';
5
5
  import UNSAFE_PRESSABLE from '@atlaskit/primitives/pressable';
6
6
  import useIconButton from './use-icon-button';
@@ -23,8 +23,8 @@ var IconButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function
23
23
  isDisabled = _ref.isDisabled,
24
24
  isSelected = _ref.isSelected,
25
25
  icon = _ref.icon,
26
- children = _ref.children,
27
26
  interactionName = _ref.interactionName,
27
+ label = _ref.label,
28
28
  overlay = _ref.overlay,
29
29
  onClick = _ref.onClick,
30
30
  onMouseDownCapture = _ref.onMouseDownCapture,
@@ -39,6 +39,7 @@ var IconButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function
39
39
  _ref$type = _ref.type,
40
40
  type = _ref$type === void 0 ? 'button' : _ref$type,
41
41
  testId = _ref.testId,
42
+ UNSAFE_size = _ref.UNSAFE_size,
42
43
  rest = _objectWithoutProperties(_ref, _excluded);
43
44
  /**
44
45
  * TODO: At some stage I'll look into re-using more logic across 'default' and 'icon'
@@ -49,11 +50,13 @@ var IconButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function
49
50
  appearance: appearance,
50
51
  autoFocus: autoFocus,
51
52
  buttonType: 'button',
52
- children: children,
53
+ children: null,
54
+ // Set in hook.
53
55
  icon: icon,
54
56
  interactionName: interactionName,
55
57
  isDisabled: isDisabled,
56
58
  isSelected: isSelected,
59
+ label: label,
57
60
  onClick: onClick,
58
61
  onMouseDownCapture: onMouseDownCapture,
59
62
  onMouseUpCapture: onMouseUpCapture,
@@ -66,7 +69,8 @@ var IconButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function
66
69
  onClickCapture: onClickCapture,
67
70
  overlay: overlay,
68
71
  ref: ref,
69
- spacing: spacing
72
+ spacing: spacing,
73
+ UNSAFE_size: UNSAFE_size
70
74
  });
71
75
  return /*#__PURE__*/React.createElement(UNSAFE_PRESSABLE, _extends({}, rest, {
72
76
  ref: baseProps.ref,
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["analyticsContext", "autoFocus", "appearance", "spacing", "isDisabled", "isSelected", "icon", "children", "interactionName", "overlay", "onClick", "onMouseDownCapture", "onMouseUpCapture", "onKeyDownCapture", "onKeyUpCapture", "onTouchStartCapture", "onTouchEndCapture", "onPointerDownCapture", "onPointerUpCapture", "onClickCapture", "testId", "href"];
3
+ var _excluded = ["analyticsContext", "autoFocus", "appearance", "spacing", "isDisabled", "isSelected", "icon", "interactionName", "label", "overlay", "onClick", "onMouseDownCapture", "onMouseUpCapture", "onKeyDownCapture", "onKeyUpCapture", "onTouchStartCapture", "onTouchEndCapture", "onPointerDownCapture", "onPointerUpCapture", "onClickCapture", "testId", "href"];
4
4
  import React, { forwardRef, memo } from 'react';
5
5
  import UNSAFE_LINK from '@atlaskit/primitives/link';
6
6
  import useIconButton from './use-icon-button';
@@ -12,8 +12,8 @@ var LinkIconButtonBase = function LinkIconButtonBase(_ref, ref) {
12
12
  isDisabled = _ref.isDisabled,
13
13
  isSelected = _ref.isSelected,
14
14
  icon = _ref.icon,
15
- children = _ref.children,
16
15
  interactionName = _ref.interactionName,
16
+ label = _ref.label,
17
17
  overlay = _ref.overlay,
18
18
  onClick = _ref.onClick,
19
19
  onMouseDownCapture = _ref.onMouseDownCapture,
@@ -33,11 +33,13 @@ var LinkIconButtonBase = function LinkIconButtonBase(_ref, ref) {
33
33
  appearance: appearance,
34
34
  autoFocus: autoFocus,
35
35
  buttonType: 'link',
36
- children: children,
36
+ children: null,
37
+ // Set in hook.
37
38
  icon: icon,
38
39
  interactionName: interactionName,
39
40
  isDisabled: isDisabled,
40
41
  isSelected: isSelected,
42
+ label: label,
41
43
  onClick: onClick,
42
44
  onMouseDownCapture: onMouseDownCapture,
43
45
  onMouseUpCapture: onMouseUpCapture,
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import VisuallyHidden from '@atlaskit/visually-hidden';
2
3
  import Content from '../shared/content';
3
4
  import useButtonBase from '../shared/use-button-base';
4
5
  /**
@@ -15,10 +16,11 @@ var useIconButton = function useIconButton(_ref) {
15
16
  appearance = _ref.appearance,
16
17
  autoFocus = _ref.autoFocus,
17
18
  buttonType = _ref.buttonType,
18
- icon = _ref.icon,
19
+ Icon = _ref.icon,
19
20
  interactionName = _ref.interactionName,
20
21
  isDisabled = _ref.isDisabled,
21
22
  isSelected = _ref.isSelected,
23
+ label = _ref.label,
22
24
  onClick = _ref.onClick,
23
25
  onMouseDownCapture = _ref.onMouseDownCapture,
24
26
  onMouseUpCapture = _ref.onMouseUpCapture,
@@ -32,7 +34,8 @@ var useIconButton = function useIconButton(_ref) {
32
34
  overlay = _ref.overlay,
33
35
  ref = _ref.ref,
34
36
  shouldFitContainer = _ref.shouldFitContainer,
35
- spacing = _ref.spacing;
37
+ spacing = _ref.spacing,
38
+ UNSAFE_size = _ref.UNSAFE_size;
36
39
  var hasOverlay = Boolean(overlay);
37
40
  var baseProps = useButtonBase({
38
41
  analyticsContext: analyticsContext,
@@ -46,7 +49,10 @@ var useIconButton = function useIconButton(_ref) {
46
49
  children: /*#__PURE__*/React.createElement(Content, {
47
50
  type: "icon",
48
51
  hasOverlay: hasOverlay
49
- }, icon),
52
+ }, /*#__PURE__*/React.createElement(Icon, {
53
+ label: "",
54
+ size: UNSAFE_size
55
+ }), /*#__PURE__*/React.createElement(VisuallyHidden, null, label)),
50
56
  interactionName: interactionName,
51
57
  isDisabled: isDisabled,
52
58
  isSelected: isSelected,
@@ -107,7 +107,7 @@ var useButtonBase = function useButtonBase(_ref) {
107
107
  action: 'clicked',
108
108
  componentName: 'button',
109
109
  packageName: "@atlaskit/button",
110
- packageVersion: "16.17.1",
110
+ packageVersion: "16.17.2",
111
111
  analyticsData: analyticsContext,
112
112
  actionSubject: buttonType
113
113
  });
@@ -109,7 +109,7 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
109
109
  action: 'clicked',
110
110
  componentName: 'button',
111
111
  packageName: "@atlaskit/button",
112
- packageVersion: "16.17.1",
112
+ packageVersion: "16.17.2",
113
113
  analyticsData: analyticsContext
114
114
  });
115
115
 
@@ -1,18 +1,10 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["href", "children"],
4
- _excluded2 = ["href", "children", "icon"];
3
+ var _excluded = ["href", "children"];
5
4
  import React, { forwardRef } from 'react';
6
-
7
- // eslint-disable-next-line import/no-extraneous-dependencies
8
- import AddIcon from '@atlaskit/icon/glyph/add';
9
5
  import Button from '../new-button/variants/default/button';
10
6
  import LinkButton from '../new-button/variants/default/link';
11
- // import IconButton, {
12
- // IconButtonProps,
13
- // } from '../new-button/variants/icon/button';
14
- import LinkIconButton from '../new-button/variants/icon/link';
15
- import { buttonAppearances, linkButtonAppearances } from '../utils/appearances';
7
+ import { buttonAppearances, linkButtonAppearances } from './appearances';
16
8
  // Add required default props to variants
17
9
  var LinkButtonRender = /*#__PURE__*/forwardRef(function (_ref, ref) {
18
10
  var _ref$href = _ref.href,
@@ -24,51 +16,11 @@ var LinkButtonRender = /*#__PURE__*/forwardRef(function (_ref, ref) {
24
16
  href: href
25
17
  }, rest), children);
26
18
  });
27
-
28
- // TODO: Enable icon button in tests once it's ready
29
- // const IconButtonRender = forwardRef(
30
- // (
31
- // {
32
- // children,
33
- // icon = <AddIcon label="" />,
34
- // ...rest
35
- // }: Omit<IconButtonProps, 'icon'> & {
36
- // icon?: IconButtonProps['icon'];
37
- // },
38
- // ref: React.Ref<HTMLButtonElement>,
39
- // ) => (
40
- // <IconButton ref={ref} icon={icon} {...rest}>
41
- // {children}
42
- // </IconButton>
43
- // ),
44
- // );
45
-
46
- var LinkIconButtonRender = /*#__PURE__*/forwardRef(function (_ref2, ref) {
47
- var _ref2$href = _ref2.href,
48
- href = _ref2$href === void 0 ? '/home' : _ref2$href,
49
- children = _ref2.children,
50
- _ref2$icon = _ref2.icon,
51
- icon = _ref2$icon === void 0 ? /*#__PURE__*/React.createElement(AddIcon, {
52
- label: ""
53
- }) : _ref2$icon,
54
- rest = _objectWithoutProperties(_ref2, _excluded2);
55
- return /*#__PURE__*/React.createElement(LinkIconButton, _extends({
56
- ref: ref,
57
- icon: icon,
58
- href: href
59
- }, rest), children);
60
- });
61
19
  export var linkButtonVariants = [{
62
20
  name: 'LinkButton',
63
21
  Component: LinkButtonRender,
64
22
  elementType: HTMLAnchorElement,
65
23
  appearances: linkButtonAppearances
66
- }, {
67
- name: 'LinkIconButton',
68
- Component: LinkIconButtonRender,
69
- elementType: HTMLAnchorElement,
70
- // TODO: Make specific to icon button
71
- appearances: linkButtonAppearances
72
24
  }];
73
25
  var variants = [{
74
26
  name: 'Button',
@@ -80,18 +32,5 @@ var variants = [{
80
32
  Component: LinkButtonRender,
81
33
  elementType: HTMLAnchorElement,
82
34
  appearances: linkButtonAppearances
83
- }
84
- // TODO: Enable icon buttons in tests once it's ready
85
- // {
86
- // name: 'IconButton',
87
- // Component: IconButtonRender,
88
- // elementType: HTMLButtonElement,
89
- // },
90
- // {
91
- // name: 'LinkIconButton',
92
- // Component: LinkIconButtonRender,
93
- // elementType: HTMLAnchorElement,
94
- // },
95
- ];
96
-
35
+ }];
97
36
  export default variants;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { type CommonButtonVariantProps } from '../types';
3
3
  import { type CommonIconButtonProps } from './types';
4
- export type IconButtonProps = CommonIconButtonProps & CommonButtonVariantProps;
4
+ export type IconButtonProps = CommonIconButtonProps & Omit<CommonButtonVariantProps, 'children' | 'appearance'>;
5
5
  /**
6
6
  * __Icon Button__
7
7
  *
@@ -13,5 +13,5 @@ export type IconButtonProps = CommonIconButtonProps & CommonButtonVariantProps;
13
13
  * - [Code](https://atlassian.design/components/button/code)
14
14
  * - [Usage](https://atlassian.design/components/button/usage)
15
15
  */
16
- declare const IconButton: React.MemoExoticComponent<React.ForwardRefExoticComponent<CommonIconButtonProps & import("../types").AdditionalButtonVariantProps & Omit<import("../types").AdditionalHTMLElementPropsExtender<React.ButtonHTMLAttributes<HTMLButtonElement>>, keyof import("../types").CommonButtonProps<TagName>> & import("../types").CommonButtonProps<HTMLButtonElement> & React.RefAttributes<HTMLButtonElement>>>;
16
+ declare const IconButton: React.MemoExoticComponent<React.ForwardRefExoticComponent<CommonIconButtonProps & Omit<CommonButtonVariantProps, "children" | "appearance"> & React.RefAttributes<HTMLButtonElement>>>;
17
17
  export default IconButton;
@@ -1,8 +1,8 @@
1
1
  import React, { type Ref } from 'react';
2
2
  import { type CommonLinkVariantProps } from '../types';
3
3
  import { type CommonIconButtonProps } from './types';
4
- export type LinkIconButtonProps<RouterLinkConfig extends Record<string, any> = never> = CommonIconButtonProps & CommonLinkVariantProps<RouterLinkConfig>;
5
- declare const LinkIconButtonBase: <RouterLinkConfig extends Record<string, any> = never>({ analyticsContext, autoFocus, appearance, spacing, isDisabled, isSelected, icon, children, interactionName, overlay, onClick, onMouseDownCapture, onMouseUpCapture, onKeyDownCapture, onKeyUpCapture, onTouchStartCapture, onTouchEndCapture, onPointerDownCapture, onPointerUpCapture, onClickCapture, testId, href, ...rest }: LinkIconButtonProps<RouterLinkConfig>, ref: Ref<HTMLAnchorElement>) => JSX.Element;
4
+ export type LinkIconButtonProps<RouterLinkConfig extends Record<string, any> = never> = CommonIconButtonProps & Omit<CommonLinkVariantProps<RouterLinkConfig>, 'children' | 'appearance'>;
5
+ declare const LinkIconButtonBase: <RouterLinkConfig extends Record<string, any> = never>({ analyticsContext, autoFocus, appearance, spacing, isDisabled, isSelected, icon, interactionName, label, overlay, onClick, onMouseDownCapture, onMouseUpCapture, onKeyDownCapture, onKeyUpCapture, onTouchStartCapture, onTouchEndCapture, onPointerDownCapture, onPointerUpCapture, onClickCapture, testId, href, ...rest }: LinkIconButtonProps<RouterLinkConfig>, ref: Ref<HTMLAnchorElement>) => JSX.Element;
6
6
  /**
7
7
  * __Link Icon Button__
8
8
  *
@@ -14,7 +14,7 @@ declare const LinkIconButtonBase: <RouterLinkConfig extends Record<string, any>
14
14
  * - [Code](https://atlassian.design/components/button/code)
15
15
  * - [Usage](https://atlassian.design/components/button/usage)
16
16
  */
17
- declare const LinkIconButton: <RouterLinkConfig extends Record<string, any> = never>(props: CommonIconButtonProps & import("../types").AdditionalLinkVariantProps<RouterLinkConfig> & Omit<import("../types").AdditionalHTMLElementPropsExtender<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "href">>, keyof import("../types").CommonButtonProps<TagName>> & import("../types").CommonButtonProps<HTMLAnchorElement> & {
17
+ declare const LinkIconButton: <RouterLinkConfig extends Record<string, any> = never>(props: CommonIconButtonProps & Omit<CommonLinkVariantProps<RouterLinkConfig>, "children" | "appearance"> & {
18
18
  ref?: React.Ref<HTMLAnchorElement> | undefined;
19
19
  }) => ReturnType<typeof LinkIconButtonBase>;
20
20
  export default LinkIconButton;
@@ -1,8 +1,23 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
+ import { type IconProps, type Size } from '@atlaskit/icon/types';
3
+ import { type IconButtonAppearance } from '../types';
2
4
  export type CommonIconButtonProps = {
3
5
  /**
4
- * TODO: Consider locking-down icon props by converting from slot props to component props
5
- * Places an icon within the button, after the button's text
6
+ * The button style variation
6
7
  */
7
- icon: React.ReactChild;
8
+ appearance?: IconButtonAppearance;
9
+ /**
10
+ * Places an icon within the button
11
+ */
12
+ icon: React.ComponentType<IconProps>;
13
+ /**
14
+ * Provide an accessible label, often used by screen readers
15
+ */
16
+ label: string;
17
+ /**
18
+ * Set the size of the icon
19
+ *
20
+ * Set to UNSAFE as it will be removed in future in favour of a 100% bounded API
21
+ */
22
+ UNSAFE_size?: Size;
8
23
  };
@@ -11,5 +11,5 @@ type UseIconButtonReturn<TagName extends HTMLElement> = UseButtonBaseReturn<TagN
11
11
  *
12
12
  * @private
13
13
  */
14
- declare const useIconButton: <TagName extends HTMLElement>({ analyticsContext, appearance, autoFocus, buttonType, icon, interactionName, isDisabled, isSelected, onClick, onMouseDownCapture, onMouseUpCapture, onKeyDownCapture, onKeyUpCapture, onTouchStartCapture, onTouchEndCapture, onPointerDownCapture, onPointerUpCapture, onClickCapture, overlay, ref, shouldFitContainer, spacing, }: UseIconButtonArgs<TagName>) => UseIconButtonReturn<TagName>;
14
+ declare const useIconButton: <TagName extends HTMLElement>({ analyticsContext, appearance, autoFocus, buttonType, icon: Icon, interactionName, isDisabled, isSelected, label, onClick, onMouseDownCapture, onMouseUpCapture, onKeyDownCapture, onKeyUpCapture, onTouchStartCapture, onTouchEndCapture, onPointerDownCapture, onPointerUpCapture, onClickCapture, overlay, ref, shouldFitContainer, spacing, UNSAFE_size, }: UseIconButtonArgs<TagName>) => UseIconButtonReturn<TagName>;
15
15
  export default useIconButton;
@@ -2,7 +2,8 @@ import React from 'react';
2
2
  import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
3
3
  export type ButtonAppearance = 'default' | 'danger' | 'primary' | 'subtle' | 'warning';
4
4
  export type LinkButtonAppearance = 'default' | 'danger' | 'link' | 'primary' | 'subtle' | 'subtle-link' | 'warning';
5
- export type Appearance = ButtonAppearance | LinkButtonAppearance;
5
+ export type IconButtonAppearance = 'default' | 'primary' | 'subtle';
6
+ export type Appearance = ButtonAppearance | LinkButtonAppearance | IconButtonAppearance;
6
7
  export type Spacing = 'compact' | 'default' | 'none';
7
8
  type Combine<First, Second> = Omit<First, keyof Second> & Second;
8
9
  export type CommonButtonProps<TagName extends HTMLElement> = {
@@ -39,11 +40,11 @@ export type CommonButtonProps<TagName extends HTMLElement> = {
39
40
  */
40
41
  spacing?: Spacing;
41
42
  /**
42
- * Text content to be rendered in the button. Required so that screen readers always have an accessible label provided for the button.
43
+ * Text content to be rendered in the button. Required so that screen readers always have an accessible label provided for the button
43
44
  */
44
45
  children: React.ReactNode;
45
46
  /**
46
- * A unique string that appears as data attribute `data-testid` in the rendered code, serving as a hook for automated tests.
47
+ * A unique string that appears as data attribute `data-testid` in the rendered code, serving as a hook for automated tests
47
48
  */
48
49
  testId?: string;
49
50
  /**
@@ -71,7 +72,7 @@ export type AdditionalButtonVariantProps = {
71
72
  appearance?: ButtonAppearance;
72
73
  };
73
74
  /**
74
- * Combines common button props with additional HTML attributes.
75
+ * Combines common button props with additional HTML attributes
75
76
  */
76
77
  export type CombinedButtonProps<TagName extends HTMLElement, HTMLAttributes extends SupportedElementAttributes> = Combine<HTMLAttributes, CommonButtonProps<TagName>>;
77
78
  /**
@@ -1,8 +1,7 @@
1
1
  import React from 'react';
2
2
  import Button from '../new-button/variants/default/button';
3
3
  import { LinkButtonProps } from '../new-button/variants/default/link';
4
- import { LinkIconButtonProps } from '../new-button/variants/icon/link';
5
- import { buttonAppearances, linkButtonAppearances } from '../utils/appearances';
4
+ import { buttonAppearances, linkButtonAppearances } from './appearances';
6
5
  export type Variant = {
7
6
  name: 'Button';
8
7
  Component: typeof Button;
@@ -17,7 +16,7 @@ export type Variant = {
17
16
  declare const LinkButtonRender: React.ForwardRefExoticComponent<Omit<LinkButtonProps<never>, "href"> & {
18
17
  href?: string | undefined;
19
18
  } & React.RefAttributes<HTMLAnchorElement>>;
20
- export declare const linkButtonVariants: ({
19
+ export declare const linkButtonVariants: {
21
20
  name: string;
22
21
  Component: React.ForwardRefExoticComponent<Omit<LinkButtonProps<never>, "href"> & {
23
22
  href?: string | undefined;
@@ -27,17 +26,6 @@ export declare const linkButtonVariants: ({
27
26
  prototype: HTMLAnchorElement;
28
27
  };
29
28
  appearances: import("../new-button/variants/types").LinkButtonAppearance[];
30
- } | {
31
- name: string;
32
- Component: React.ForwardRefExoticComponent<Omit<LinkIconButtonProps<never>, "href" | "icon"> & {
33
- href?: string | undefined;
34
- icon?: React.ReactChild | undefined;
35
- } & React.RefAttributes<HTMLAnchorElement>>;
36
- elementType: {
37
- new (): HTMLAnchorElement;
38
- prototype: HTMLAnchorElement;
39
- };
40
- appearances: import("../new-button/variants/types").LinkButtonAppearance[];
41
- })[];
29
+ }[];
42
30
  declare const variants: Variant[];
43
31
  export default variants;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { type CommonButtonVariantProps } from '../types';
3
3
  import { type CommonIconButtonProps } from './types';
4
- export type IconButtonProps = CommonIconButtonProps & CommonButtonVariantProps;
4
+ export type IconButtonProps = CommonIconButtonProps & Omit<CommonButtonVariantProps, 'children' | 'appearance'>;
5
5
  /**
6
6
  * __Icon Button__
7
7
  *
@@ -13,5 +13,5 @@ export type IconButtonProps = CommonIconButtonProps & CommonButtonVariantProps;
13
13
  * - [Code](https://atlassian.design/components/button/code)
14
14
  * - [Usage](https://atlassian.design/components/button/usage)
15
15
  */
16
- declare const IconButton: React.MemoExoticComponent<React.ForwardRefExoticComponent<CommonIconButtonProps & import("../types").AdditionalButtonVariantProps & Omit<import("../types").AdditionalHTMLElementPropsExtender<React.ButtonHTMLAttributes<HTMLButtonElement>>, keyof import("../types").CommonButtonProps<TagName>> & import("../types").CommonButtonProps<HTMLButtonElement> & React.RefAttributes<HTMLButtonElement>>>;
16
+ declare const IconButton: React.MemoExoticComponent<React.ForwardRefExoticComponent<CommonIconButtonProps & Omit<CommonButtonVariantProps, "children" | "appearance"> & React.RefAttributes<HTMLButtonElement>>>;
17
17
  export default IconButton;
@@ -1,8 +1,8 @@
1
1
  import React, { type Ref } from 'react';
2
2
  import { type CommonLinkVariantProps } from '../types';
3
3
  import { type CommonIconButtonProps } from './types';
4
- export type LinkIconButtonProps<RouterLinkConfig extends Record<string, any> = never> = CommonIconButtonProps & CommonLinkVariantProps<RouterLinkConfig>;
5
- declare const LinkIconButtonBase: <RouterLinkConfig extends Record<string, any> = never>({ analyticsContext, autoFocus, appearance, spacing, isDisabled, isSelected, icon, children, interactionName, overlay, onClick, onMouseDownCapture, onMouseUpCapture, onKeyDownCapture, onKeyUpCapture, onTouchStartCapture, onTouchEndCapture, onPointerDownCapture, onPointerUpCapture, onClickCapture, testId, href, ...rest }: LinkIconButtonProps<RouterLinkConfig>, ref: Ref<HTMLAnchorElement>) => JSX.Element;
4
+ export type LinkIconButtonProps<RouterLinkConfig extends Record<string, any> = never> = CommonIconButtonProps & Omit<CommonLinkVariantProps<RouterLinkConfig>, 'children' | 'appearance'>;
5
+ declare const LinkIconButtonBase: <RouterLinkConfig extends Record<string, any> = never>({ analyticsContext, autoFocus, appearance, spacing, isDisabled, isSelected, icon, interactionName, label, overlay, onClick, onMouseDownCapture, onMouseUpCapture, onKeyDownCapture, onKeyUpCapture, onTouchStartCapture, onTouchEndCapture, onPointerDownCapture, onPointerUpCapture, onClickCapture, testId, href, ...rest }: LinkIconButtonProps<RouterLinkConfig>, ref: Ref<HTMLAnchorElement>) => JSX.Element;
6
6
  /**
7
7
  * __Link Icon Button__
8
8
  *
@@ -14,7 +14,7 @@ declare const LinkIconButtonBase: <RouterLinkConfig extends Record<string, any>
14
14
  * - [Code](https://atlassian.design/components/button/code)
15
15
  * - [Usage](https://atlassian.design/components/button/usage)
16
16
  */
17
- declare const LinkIconButton: <RouterLinkConfig extends Record<string, any> = never>(props: CommonIconButtonProps & import("../types").AdditionalLinkVariantProps<RouterLinkConfig> & Omit<import("../types").AdditionalHTMLElementPropsExtender<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "href">>, keyof import("../types").CommonButtonProps<TagName>> & import("../types").CommonButtonProps<HTMLAnchorElement> & {
17
+ declare const LinkIconButton: <RouterLinkConfig extends Record<string, any> = never>(props: CommonIconButtonProps & Omit<CommonLinkVariantProps<RouterLinkConfig>, "children" | "appearance"> & {
18
18
  ref?: React.Ref<HTMLAnchorElement> | undefined;
19
19
  }) => ReturnType<typeof LinkIconButtonBase>;
20
20
  export default LinkIconButton;
@@ -1,8 +1,23 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
+ import { type IconProps, type Size } from '@atlaskit/icon/types';
3
+ import { type IconButtonAppearance } from '../types';
2
4
  export type CommonIconButtonProps = {
3
5
  /**
4
- * TODO: Consider locking-down icon props by converting from slot props to component props
5
- * Places an icon within the button, after the button's text
6
+ * The button style variation
6
7
  */
7
- icon: React.ReactChild;
8
+ appearance?: IconButtonAppearance;
9
+ /**
10
+ * Places an icon within the button
11
+ */
12
+ icon: React.ComponentType<IconProps>;
13
+ /**
14
+ * Provide an accessible label, often used by screen readers
15
+ */
16
+ label: string;
17
+ /**
18
+ * Set the size of the icon
19
+ *
20
+ * Set to UNSAFE as it will be removed in future in favour of a 100% bounded API
21
+ */
22
+ UNSAFE_size?: Size;
8
23
  };
@@ -11,5 +11,5 @@ type UseIconButtonReturn<TagName extends HTMLElement> = UseButtonBaseReturn<TagN
11
11
  *
12
12
  * @private
13
13
  */
14
- declare const useIconButton: <TagName extends HTMLElement>({ analyticsContext, appearance, autoFocus, buttonType, icon, interactionName, isDisabled, isSelected, onClick, onMouseDownCapture, onMouseUpCapture, onKeyDownCapture, onKeyUpCapture, onTouchStartCapture, onTouchEndCapture, onPointerDownCapture, onPointerUpCapture, onClickCapture, overlay, ref, shouldFitContainer, spacing, }: UseIconButtonArgs<TagName>) => UseIconButtonReturn<TagName>;
14
+ declare const useIconButton: <TagName extends HTMLElement>({ analyticsContext, appearance, autoFocus, buttonType, icon: Icon, interactionName, isDisabled, isSelected, label, onClick, onMouseDownCapture, onMouseUpCapture, onKeyDownCapture, onKeyUpCapture, onTouchStartCapture, onTouchEndCapture, onPointerDownCapture, onPointerUpCapture, onClickCapture, overlay, ref, shouldFitContainer, spacing, UNSAFE_size, }: UseIconButtonArgs<TagName>) => UseIconButtonReturn<TagName>;
15
15
  export default useIconButton;
@@ -2,7 +2,8 @@ import React from 'react';
2
2
  import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
3
3
  export type ButtonAppearance = 'default' | 'danger' | 'primary' | 'subtle' | 'warning';
4
4
  export type LinkButtonAppearance = 'default' | 'danger' | 'link' | 'primary' | 'subtle' | 'subtle-link' | 'warning';
5
- export type Appearance = ButtonAppearance | LinkButtonAppearance;
5
+ export type IconButtonAppearance = 'default' | 'primary' | 'subtle';
6
+ export type Appearance = ButtonAppearance | LinkButtonAppearance | IconButtonAppearance;
6
7
  export type Spacing = 'compact' | 'default' | 'none';
7
8
  type Combine<First, Second> = Omit<First, keyof Second> & Second;
8
9
  export type CommonButtonProps<TagName extends HTMLElement> = {
@@ -39,11 +40,11 @@ export type CommonButtonProps<TagName extends HTMLElement> = {
39
40
  */
40
41
  spacing?: Spacing;
41
42
  /**
42
- * Text content to be rendered in the button. Required so that screen readers always have an accessible label provided for the button.
43
+ * Text content to be rendered in the button. Required so that screen readers always have an accessible label provided for the button
43
44
  */
44
45
  children: React.ReactNode;
45
46
  /**
46
- * A unique string that appears as data attribute `data-testid` in the rendered code, serving as a hook for automated tests.
47
+ * A unique string that appears as data attribute `data-testid` in the rendered code, serving as a hook for automated tests
47
48
  */
48
49
  testId?: string;
49
50
  /**
@@ -71,7 +72,7 @@ export type AdditionalButtonVariantProps = {
71
72
  appearance?: ButtonAppearance;
72
73
  };
73
74
  /**
74
- * Combines common button props with additional HTML attributes.
75
+ * Combines common button props with additional HTML attributes
75
76
  */
76
77
  export type CombinedButtonProps<TagName extends HTMLElement, HTMLAttributes extends SupportedElementAttributes> = Combine<HTMLAttributes, CommonButtonProps<TagName>>;
77
78
  /**
@@ -1,8 +1,7 @@
1
1
  import React from 'react';
2
2
  import Button from '../new-button/variants/default/button';
3
3
  import { LinkButtonProps } from '../new-button/variants/default/link';
4
- import { LinkIconButtonProps } from '../new-button/variants/icon/link';
5
- import { buttonAppearances, linkButtonAppearances } from '../utils/appearances';
4
+ import { buttonAppearances, linkButtonAppearances } from './appearances';
6
5
  export type Variant = {
7
6
  name: 'Button';
8
7
  Component: typeof Button;
@@ -17,7 +16,7 @@ export type Variant = {
17
16
  declare const LinkButtonRender: React.ForwardRefExoticComponent<Omit<LinkButtonProps<never>, "href"> & {
18
17
  href?: string | undefined;
19
18
  } & React.RefAttributes<HTMLAnchorElement>>;
20
- export declare const linkButtonVariants: ({
19
+ export declare const linkButtonVariants: {
21
20
  name: string;
22
21
  Component: React.ForwardRefExoticComponent<Omit<LinkButtonProps<never>, "href"> & {
23
22
  href?: string | undefined;
@@ -27,17 +26,6 @@ export declare const linkButtonVariants: ({
27
26
  prototype: HTMLAnchorElement;
28
27
  };
29
28
  appearances: import("../new-button/variants/types").LinkButtonAppearance[];
30
- } | {
31
- name: string;
32
- Component: React.ForwardRefExoticComponent<Omit<LinkIconButtonProps<never>, "href" | "icon"> & {
33
- href?: string | undefined;
34
- icon?: React.ReactChild | undefined;
35
- } & React.RefAttributes<HTMLAnchorElement>>;
36
- elementType: {
37
- new (): HTMLAnchorElement;
38
- prototype: HTMLAnchorElement;
39
- };
40
- appearances: import("../new-button/variants/types").LinkButtonAppearance[];
41
- })[];
29
+ }[];
42
30
  declare const variants: Variant[];
43
31
  export default variants;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/button",
3
- "version": "16.17.1",
3
+ "version": "16.17.2",
4
4
  "description": "A button triggers an event or action. They let users know what will happen next.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -79,9 +79,10 @@
79
79
  "@atlaskit/analytics-next": "^9.1.0",
80
80
  "@atlaskit/ds-lib": "^2.2.0",
81
81
  "@atlaskit/focus-ring": "^1.3.0",
82
+ "@atlaskit/icon": "^22.0.0",
82
83
  "@atlaskit/interaction-context": "^2.1.0",
83
84
  "@atlaskit/platform-feature-flags": "^0.2.0",
84
- "@atlaskit/primitives": "^1.11.0",
85
+ "@atlaskit/primitives": "^1.12.0",
85
86
  "@atlaskit/spinner": "^16.0.0",
86
87
  "@atlaskit/theme": "^12.6.0",
87
88
  "@atlaskit/tokens": "^1.28.0",
@@ -97,7 +98,6 @@
97
98
  "@af/integration-testing": "*",
98
99
  "@af/visual-regression": "*",
99
100
  "@atlaskit/app-provider": "^0.4.0",
100
- "@atlaskit/icon": "^22.0.0",
101
101
  "@atlaskit/ssr": "*",
102
102
  "@atlaskit/visual-regression": "*",
103
103
  "@atlaskit/webdriver-runner": "*",