@atlaskit/button 16.17.0 → 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 (35) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/new-button/containers/split-button/split-button.js +16 -12
  3. package/dist/cjs/new-button/variants/icon/button.js +8 -4
  4. package/dist/cjs/new-button/variants/icon/link.js +5 -3
  5. package/dist/cjs/new-button/variants/icon/use-icon-button.js +9 -3
  6. package/dist/cjs/new-button/variants/shared/use-button-base.js +1 -1
  7. package/dist/cjs/old-button/shared/button-base.js +1 -1
  8. package/dist/cjs/utils/variants.js +3 -61
  9. package/dist/es2019/new-button/containers/split-button/split-button.js +16 -12
  10. package/dist/es2019/new-button/variants/icon/button.js +7 -3
  11. package/dist/es2019/new-button/variants/icon/link.js +4 -2
  12. package/dist/es2019/new-button/variants/icon/use-icon-button.js +9 -5
  13. package/dist/es2019/new-button/variants/shared/use-button-base.js +1 -1
  14. package/dist/es2019/old-button/shared/button-base.js +1 -1
  15. package/dist/es2019/utils/variants.js +2 -59
  16. package/dist/esm/new-button/containers/split-button/split-button.js +16 -12
  17. package/dist/esm/new-button/variants/icon/button.js +8 -4
  18. package/dist/esm/new-button/variants/icon/link.js +5 -3
  19. package/dist/esm/new-button/variants/icon/use-icon-button.js +9 -3
  20. package/dist/esm/new-button/variants/shared/use-button-base.js +1 -1
  21. package/dist/esm/old-button/shared/button-base.js +1 -1
  22. package/dist/esm/utils/variants.js +3 -64
  23. package/dist/types/new-button/variants/icon/button.d.ts +2 -2
  24. package/dist/types/new-button/variants/icon/link.d.ts +3 -3
  25. package/dist/types/new-button/variants/icon/types.d.ts +19 -4
  26. package/dist/types/new-button/variants/icon/use-icon-button.d.ts +1 -1
  27. package/dist/types/new-button/variants/types.d.ts +5 -4
  28. package/dist/types/utils/variants.d.ts +3 -15
  29. package/dist/types-ts4.5/new-button/variants/icon/button.d.ts +2 -2
  30. package/dist/types-ts4.5/new-button/variants/icon/link.d.ts +3 -3
  31. package/dist/types-ts4.5/new-button/variants/icon/types.d.ts +19 -4
  32. package/dist/types-ts4.5/new-button/variants/icon/use-icon-button.d.ts +1 -1
  33. package/dist/types-ts4.5/new-button/variants/types.d.ts +5 -4
  34. package/dist/types-ts4.5/utils/variants.d.ts +3 -15
  35. package/package.json +3 -3
@@ -1,16 +1,14 @@
1
1
  /** @jsx jsx */
2
2
 
3
3
  import { css, jsx } from '@emotion/react';
4
- import { fontSize as getFontSize } from '@atlaskit/theme/constants';
5
4
  import { SplitButtonContext } from './split-button-context';
6
5
  import { getActions } from './utils';
7
- var fontSize = getFontSize();
8
- var defaultDividerHeight = 20 / fontSize + 'em';
6
+ var defaultDividerHeight = '16px';
9
7
  var defaultDividerStyles = css({
10
8
  height: defaultDividerHeight,
11
9
  margin: "var(--ds-space-075, 6px)".concat(" -0.5px")
12
10
  });
13
- var compactDividerHeight = 16 / fontSize + 'em';
11
+ var compactDividerHeight = '12px';
14
12
  var compactDividerStyles = css({
15
13
  height: compactDividerHeight,
16
14
  margin: "var(--ds-space-050, 4px)".concat(" -0.5px")
@@ -21,27 +19,32 @@ var baseDividerStyles = css({
21
19
  position: 'relative',
22
20
  zIndex: 2
23
21
  });
24
- var disabledStyles = css({
25
- backgroundColor: "var(--ds-border, #091E4224)",
22
+ var dividerDisabledStyles = css({
23
+ backgroundColor: "var(--ds-text-disabled, #091E4224)",
26
24
  cursor: 'not-allowed'
27
25
  });
28
26
  var navigationDividerStyles = css({
29
27
  height: compactDividerHeight,
30
28
  margin: "var(--ds-space-100, 8px)".concat(" -0.5px"),
31
- backgroundColor: "var(--ds-border, #0052cc)"
29
+ backgroundColor: "var(--ds-text-subtle, #0052cc)",
30
+ opacity: 0.62
32
31
  });
33
32
  var dividerAppearance = {
34
33
  default: css({
35
- backgroundColor: "var(--ds-text, #172B4D)"
34
+ backgroundColor: "var(--ds-text, #172B4D)",
35
+ opacity: 0.51
36
36
  }),
37
37
  primary: css({
38
- backgroundColor: "var(--ds-text-inverse, #FFF)"
38
+ backgroundColor: "var(--ds-text-inverse, #FFF)",
39
+ opacity: 0.64
39
40
  }),
40
41
  danger: css({
41
- backgroundColor: "var(--ds-text-inverse, #FFF)"
42
+ backgroundColor: "var(--ds-text-inverse, #FFF)",
43
+ opacity: 0.66
42
44
  }),
43
45
  warning: css({
44
- backgroundColor: "var(--ds-text-warning-inverse, #172B4D)"
46
+ backgroundColor: "var(--ds-text-warning-inverse, #172B4D)",
47
+ opacity: 0.52
45
48
  }),
46
49
  navigation: navigationDividerStyles
47
50
  };
@@ -60,13 +63,14 @@ export var Divider = function Divider(_ref) {
60
63
  return (
61
64
  // I find it funny to provide a div for Divider
62
65
  jsx("div", {
63
- css: [baseDividerStyles, dividerAppearance[appearance], dividerHeight[spacing], isDisabled ? disabledStyles : undefined]
66
+ css: [baseDividerStyles, dividerAppearance[appearance], dividerHeight[spacing], isDisabled ? dividerDisabledStyles : undefined]
64
67
  })
65
68
  );
66
69
  };
67
70
  var splitButtonStyles = css({
68
71
  display: 'inline-flex',
69
72
  position: 'relative',
73
+ alignItems: 'center',
70
74
  whiteSpace: 'nowrap'
71
75
  });
72
76
 
@@ -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.0",
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.0",
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.0",
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": "*",