@atlaskit/button 17.8.0 → 17.10.0

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 (46) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/entry-points/standard-button.js +0 -1
  3. package/dist/cjs/new-button/variants/default/use-default-button.js +1 -0
  4. package/dist/cjs/new-button/variants/icon/use-icon-button.js +1 -0
  5. package/dist/cjs/new-button/variants/shared/colors.js +44 -36
  6. package/dist/cjs/new-button/variants/shared/loading-overlay.js +1 -4
  7. package/dist/cjs/new-button/variants/shared/use-button-base.js +4 -1
  8. package/dist/cjs/new-button/variants/shared/xcss.js +16 -8
  9. package/dist/cjs/old-button/shared/button-base.js +1 -1
  10. package/dist/es2019/entry-points/standard-button.js +0 -5
  11. package/dist/es2019/new-button/variants/default/use-default-button.js +1 -0
  12. package/dist/es2019/new-button/variants/icon/use-icon-button.js +1 -0
  13. package/dist/es2019/new-button/variants/shared/colors.js +44 -36
  14. package/dist/es2019/new-button/variants/shared/loading-overlay.js +1 -4
  15. package/dist/es2019/new-button/variants/shared/use-button-base.js +3 -1
  16. package/dist/es2019/new-button/variants/shared/xcss.js +15 -7
  17. package/dist/es2019/old-button/shared/button-base.js +1 -1
  18. package/dist/esm/entry-points/standard-button.js +0 -5
  19. package/dist/esm/new-button/variants/default/use-default-button.js +1 -0
  20. package/dist/esm/new-button/variants/icon/use-icon-button.js +1 -0
  21. package/dist/esm/new-button/variants/shared/colors.js +44 -36
  22. package/dist/esm/new-button/variants/shared/loading-overlay.js +1 -4
  23. package/dist/esm/new-button/variants/shared/use-button-base.js +4 -1
  24. package/dist/esm/new-button/variants/shared/xcss.js +16 -8
  25. package/dist/esm/old-button/shared/button-base.js +1 -1
  26. package/dist/types/containers/button-group.d.ts +4 -4
  27. package/dist/types/entry-points/standard-button.d.ts +0 -5
  28. package/dist/types/new-button/variants/default/types.d.ts +0 -4
  29. package/dist/types/new-button/variants/icon/types.d.ts +0 -4
  30. package/dist/types/new-button/variants/shared/colors.d.ts +5 -3
  31. package/dist/types/new-button/variants/shared/use-button-base.d.ts +2 -1
  32. package/dist/types/new-button/variants/shared/xcss.d.ts +2 -1
  33. package/dist/types/new-button/variants/types.d.ts +4 -0
  34. package/dist/types/old-button/types.d.ts +20 -20
  35. package/dist/types-ts4.5/containers/button-group.d.ts +4 -4
  36. package/dist/types-ts4.5/entry-points/standard-button.d.ts +0 -5
  37. package/dist/types-ts4.5/new-button/variants/default/types.d.ts +0 -4
  38. package/dist/types-ts4.5/new-button/variants/icon/types.d.ts +0 -4
  39. package/dist/types-ts4.5/new-button/variants/shared/colors.d.ts +5 -3
  40. package/dist/types-ts4.5/new-button/variants/shared/use-button-base.d.ts +2 -1
  41. package/dist/types-ts4.5/new-button/variants/shared/xcss.d.ts +2 -1
  42. package/dist/types-ts4.5/new-button/variants/types.d.ts +4 -0
  43. package/dist/types-ts4.5/old-button/types.d.ts +20 -20
  44. package/extract-react-types/new-button/variants/default/{common-props.tsx → common-default-button-props.tsx} +1 -1
  45. package/extract-react-types/new-button/variants/icon-button/icon-button-props.tsx +5 -0
  46. package/package.json +4 -4
@@ -15,18 +15,14 @@ var values = {
15
15
  hover: 'color.background.neutral.hovered',
16
16
  active: 'color.background.neutral.pressed',
17
17
  // @ts-expect-error
18
- disabled: "var(--ds-background-disabled, ".concat(colors.N20A, ")"),
19
- // @ts-expect-error
20
- selected: "var(--ds-background-selected, ".concat(colors.N700, ")")
18
+ disabled: "var(--ds-background-disabled, ".concat(colors.N20A, ")")
21
19
  },
22
20
  primary: {
23
21
  default: 'color.background.brand.bold',
24
22
  hover: 'color.background.brand.bold.hovered',
25
23
  active: 'color.background.brand.bold.pressed',
26
24
  // @ts-expect-error
27
- disabled: "var(--ds-background-disabled, ".concat(colors.N20A, ")"),
28
- // @ts-expect-error
29
- selected: "var(--ds-background-selected, ".concat(colors.N700, ")")
25
+ disabled: "var(--ds-background-disabled, ".concat(colors.N20A, ")")
30
26
  },
31
27
  warning: {
32
28
  default: 'color.background.warning.bold',
@@ -34,8 +30,14 @@ var values = {
34
30
  active: 'color.background.warning.bold.pressed',
35
31
  // @ts-expect-error
36
32
  disabled: "var(--ds-background-disabled, ".concat(colors.N20A, ")"),
37
- // @ts-expect-error
38
- selected: "var(--ds-background-selected, ".concat(colors.Y400, ")")
33
+ selected: {
34
+ // @ts-expect-error
35
+ default: "var(--ds-background-selected, ".concat(colors.Y400, ")"),
36
+ // @ts-expect-error
37
+ hover: "var(--ds-background-selected-hovered, ".concat(colors.Y400, ")"),
38
+ // @ts-expect-error
39
+ active: "var(--ds-background-selected-pressed, ".concat(colors.Y400, ")")
40
+ }
39
41
  },
40
42
  danger: {
41
43
  default: 'color.background.danger.bold',
@@ -43,27 +45,35 @@ var values = {
43
45
  active: 'color.background.danger.bold.pressed',
44
46
  // @ts-expect-error
45
47
  disabled: "var(--ds-background-disabled, ".concat(colors.N20A, ")"),
46
- // @ts-expect-error
47
- selected: "var(--ds-background-selected, ".concat(colors.R500, ")")
48
+ selected: {
49
+ // @ts-expect-error
50
+ default: "var(--ds-background-selected, ".concat(colors.R500, ")"),
51
+ // @ts-expect-error
52
+ hover: "var(--ds-background-selected-hovered, ".concat(colors.R500, ")"),
53
+ // @ts-expect-error
54
+ active: "var(--ds-background-selected-pressed, ".concat(colors.R500, ")")
55
+ }
48
56
  },
49
57
  link: {
50
- default: 'color.background.neutral.subtle',
51
- // @ts-expect-error
52
- selected: "var(--ds-background-selected, ".concat(colors.N700, ")")
58
+ default: 'color.background.neutral.subtle'
53
59
  },
54
60
  subtle: {
55
61
  default: 'color.background.neutral.subtle',
56
62
  hover: 'color.background.neutral.subtle.hovered',
57
63
  active: 'color.background.neutral.subtle.pressed',
58
64
  // @ts-expect-error
59
- disabled: "var(--ds-background-neutral-subtle, none)",
60
- // @ts-expect-error
61
- selected: "var(--ds-background-selected, ".concat(colors.N700, ")")
65
+ disabled: "var(--ds-background-neutral-subtle, none)"
62
66
  },
63
67
  'subtle-link': {
64
- default: 'color.background.neutral.subtle',
68
+ default: 'color.background.neutral.subtle'
69
+ },
70
+ selected: {
71
+ // @ts-expect-error
72
+ default: "var(--ds-background-selected, ".concat(colors.N700, ")"),
73
+ // @ts-expect-error
74
+ hover: "var(--ds-background-selected-hovered, ".concat(colors.N700, ")"),
65
75
  // @ts-expect-error
66
- selected: "var(--ds-background-selected, ".concat(colors.N700, ")")
76
+ active: "var(--ds-background-selected-pressed, ".concat(colors.N700, ")")
67
77
  }
68
78
  },
69
79
  color: {
@@ -72,45 +82,41 @@ var values = {
72
82
  default: "var(--ds-text, ".concat(colors.N500, ")"),
73
83
  // @ts-expect-error
74
84
  active: "var(--ds-text, ".concat(colors.B400, ")"),
75
- disabled: 'color.text.disabled',
76
- // @ts-expect-error
77
- selected: "var(--ds-text-selected, ".concat(colors.N20, ")")
85
+ disabled: 'color.text.disabled'
78
86
  },
79
87
  primary: {
80
88
  default: 'color.text.inverse',
81
- disabled: 'color.text.disabled',
82
- // @ts-expect-error
83
- selected: "var(--ds-text-selected, ".concat(colors.N20, ")")
89
+ disabled: 'color.text.disabled'
84
90
  },
85
91
  warning: {
86
92
  default: 'color.text.warning.inverse',
87
93
  disabled: 'color.text.disabled',
88
- // @ts-expect-error
89
- selected: "var(--ds-text-selected, ".concat(colors.N800, ")")
94
+ selected: {
95
+ // @ts-expect-error
96
+ default: "var(--ds-text-selected, ".concat(colors.N800, ")")
97
+ }
90
98
  },
91
99
  danger: {
92
100
  default: 'color.text.inverse',
93
101
  disabled: 'color.text.disabled',
94
- // @ts-expect-error
95
- selected: "var(--ds-text-selected, ".concat(colors.N0, ")")
102
+ selected: {
103
+ // @ts-expect-error
104
+ default: "var(--ds-text-selected, ".concat(colors.N0, ")")
105
+ }
96
106
  },
97
107
  link: {
98
108
  default: 'color.link',
99
109
  // @ts-expect-error
100
110
  hover: "var(--ds-link, ".concat(colors.B300, ")"),
101
111
  active: 'color.link.pressed',
102
- disabled: 'color.text.disabled',
103
- // @ts-expect-error
104
- selected: "var(--ds-text-selected, ".concat(colors.N20, ")")
112
+ disabled: 'color.text.disabled'
105
113
  },
106
114
  subtle: {
107
115
  // @ts-expect-error
108
116
  default: "var(--ds-text, ".concat(colors.N500, ")"),
109
117
  // @ts-expect-error
110
118
  active: "var(--ds-text, ".concat(colors.B400, ")"),
111
- disabled: 'color.text.disabled',
112
- // @ts-expect-error
113
- selected: "var(--ds-text-selected, ".concat(colors.N20, ")")
119
+ disabled: 'color.text.disabled'
114
120
  },
115
121
  'subtle-link': {
116
122
  // @ts-expect-error
@@ -119,9 +125,11 @@ var values = {
119
125
  hover: "var(--ds-text-subtle, ".concat(colors.N90, ")"),
120
126
  // @ts-expect-error
121
127
  active: "var(--ds-text, ".concat(colors.N400, ")"),
122
- disabled: 'color.text.disabled',
128
+ disabled: 'color.text.disabled'
129
+ },
130
+ selected: {
123
131
  // @ts-expect-error
124
- selected: "var(--ds-text-selected, ".concat(colors.N20, ")")
132
+ default: "var(--ds-text-selected, ".concat(colors.N20, ")")
125
133
  }
126
134
  }
127
135
  };
@@ -14,12 +14,9 @@ function getSpinnerAppearance(_ref) {
14
14
  var appearance = _ref.appearance,
15
15
  isDisabled = _ref.isDisabled,
16
16
  isSelected = _ref.isSelected;
17
- if (isDisabled) {
17
+ if (isDisabled || isSelected) {
18
18
  return 'inherit';
19
19
  }
20
- if (isSelected) {
21
- return 'invert';
22
- }
23
20
  if (appearance === 'primary' || appearance === 'danger') {
24
21
  return 'invert';
25
22
  }
@@ -39,6 +39,8 @@ var useButtonBase = function useButtonBase(_ref) {
39
39
  buttonType = _ref.buttonType,
40
40
  _ref$isDisabled = _ref.isDisabled,
41
41
  propIsDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
42
+ _ref$isLoading = _ref.isLoading,
43
+ isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
42
44
  _ref$isSelected = _ref.isSelected,
43
45
  isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected,
44
46
  _ref$isIconButton = _ref.isIconButton,
@@ -94,6 +96,7 @@ var useButtonBase = function useButtonBase(_ref) {
94
96
  appearance: appearance,
95
97
  spacing: spacing,
96
98
  isDisabled: isDisabled,
99
+ isLoading: isLoading,
97
100
  isSelected: isSelected,
98
101
  isHighlighted: isHighlighted,
99
102
  isActiveOverSelected: isActiveOverSelected,
@@ -107,7 +110,7 @@ var useButtonBase = function useButtonBase(_ref) {
107
110
  isSplit: isSplitButton,
108
111
  isNavigationSplit: isNavigationSplitButton
109
112
  });
110
- }, [appearance, buttonType, spacing, isDisabled, isSelected, isHighlighted, isActiveOverSelected, isIconButton, isCircle, shouldFitContainer, overlay, hasIconBefore, hasIconAfter, isSplitButton, isNavigationSplitButton]);
113
+ }, [appearance, buttonType, spacing, isDisabled, isLoading, isSelected, isHighlighted, isActiveOverSelected, isIconButton, isCircle, shouldFitContainer, overlay, hasIconBefore, hasIconAfter, isSplitButton, isNavigationSplitButton]);
111
114
  var isEffectivelyDisabled = isDisabled || Boolean(overlay);
112
115
  return _objectSpread({
113
116
  ref: setRef,
@@ -58,21 +58,23 @@ function getColors(_ref2) {
58
58
  isHighlighted = _ref2.isHighlighted,
59
59
  isActiveOverSelected = _ref2.isActiveOverSelected,
60
60
  hasOverlay = _ref2.hasOverlay;
61
+ var showSelectedState = (isSelected || isHighlighted) && !isDisabled && !isActiveOverSelected;
61
62
  var key = interactionState;
62
63
  // Overlay does not change color on interaction, revert to 'default' or resting state
63
64
  key = hasOverlay ? 'default' : key;
64
- key = isSelected || isHighlighted ? isActiveOverSelected ? 'active' : 'selected' : key;
65
+ key = showSelectedState && isActiveOverSelected ? 'active' : key;
66
+
65
67
  // Disabled colors overrule everything else
66
68
  key = isDisabled ? 'disabled' : key;
67
69
  return {
68
70
  backgroundColor: getColor({
69
- group: colors.background[appearance],
71
+ group: showSelectedState && colors.background[appearance]['selected'] || colors.background[showSelectedState ? 'selected' : appearance],
70
72
  key: key
71
73
  }),
72
- color: "".concat(getColor({
73
- group: colors.color[appearance],
74
+ color: getColor({
75
+ group: showSelectedState && colors.color[appearance]['selected'] || colors.color[showSelectedState ? 'selected' : appearance],
74
76
  key: key
75
- }))
77
+ })
76
78
  };
77
79
  }
78
80
  export function getXCSS(_ref3) {
@@ -80,6 +82,7 @@ export function getXCSS(_ref3) {
80
82
  spacing = _ref3.spacing,
81
83
  isDisabled = _ref3.isDisabled,
82
84
  isSelected = _ref3.isSelected,
85
+ isLoading = _ref3.isLoading,
83
86
  isHighlighted = _ref3.isHighlighted,
84
87
  isActiveOverSelected = _ref3.isActiveOverSelected,
85
88
  isIconButton = _ref3.isIconButton,
@@ -152,8 +155,8 @@ export function getXCSS(_ref3) {
152
155
  width: width,
153
156
  // justifyContent required for shouldFitContainer buttons with an icon inside
154
157
  justifyContent: 'center'
155
- }, combinedBaseColorStyles), isDisabled || hasOverlay ? {
156
- cursor: 'not-allowed'
158
+ }, combinedBaseColorStyles), isDisabled || hasOverlay || isLoading ? {
159
+ cursor: isLoading ? 'progress' : 'not-allowed'
157
160
  } : {}), {}, {
158
161
  ':hover': _objectSpread(_objectSpread({}, getColors({
159
162
  appearance: appearance,
@@ -177,6 +180,11 @@ export function getXCSS(_ref3) {
177
180
  })), {}, {
178
181
  // background, box-shadow
179
182
  transitionDuration: '0s, 0s'
180
- })
183
+ }),
184
+ ':focus': {
185
+ // Required due to Jira's AUI CSS reset
186
+ // See https://product-fabric.atlassian.net/browse/DSP-15687
187
+ textDecoration: !isSelected && (appearance === 'link' || appearance === 'subtle-link') ? 'underline' : 'none'
188
+ }
181
189
  }, splitButtonStyles));
182
190
  }
@@ -108,7 +108,7 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
108
108
  action: 'clicked',
109
109
  componentName: 'button',
110
110
  packageName: "@atlaskit/button",
111
- packageVersion: "17.8.0",
111
+ packageVersion: "17.10.0",
112
112
  analyticsData: analyticsContext
113
113
  });
114
114
 
@@ -4,11 +4,11 @@ import { jsx } from '@emotion/react';
4
4
  import { Appearance } from '../old-button/types';
5
5
  export type ButtonGroupProps = {
6
6
  /**
7
- * The appearance to apply to all buttons
7
+ * The appearance to apply to all buttons.
8
8
  */
9
9
  appearance?: Appearance;
10
10
  /**
11
- * The buttons to render inside the Button Group
11
+ * The buttons to render inside the button group.
12
12
  */
13
13
  children?: React.ReactNode;
14
14
  /**
@@ -16,12 +16,12 @@ export type ButtonGroupProps = {
16
16
  */
17
17
  testId?: string;
18
18
  /**
19
- * Refers to an aria-label attribute. Sets an accessible name for ButtonGroup wrapper to announce it to users of assistive technology.
19
+ * Refers to an `aria-label` attribute. Sets an accessible name for the button group wrapper to announce it to users of assistive technology.
20
20
  * Usage of either this, or the `titleId` attribute is strongly recommended.
21
21
  */
22
22
  label?: string;
23
23
  /**
24
- * Id referenced by the ButtonGroup wrapper's aria-labelledby attribute. This id should be assigned to the group-button title element.
24
+ * ID referenced by the button group wrapper's `aria-labelledby` attribute. This ID should be assigned to the group-button title element.
25
25
  * Usage of either this, or the `label` attribute is strongly recommended.
26
26
  */
27
27
  titleId?: string;
@@ -1,7 +1,2 @@
1
- /**
2
- * Must import '@emotion/core' in order to resolve type error
3
- * https://product-fabric.atlassian.net/browse/DSP-3222
4
- */
5
- import '@emotion/react';
6
1
  export { default } from '../old-button/button';
7
2
  export type { ButtonProps } from '../old-button/button';
@@ -1,10 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { type ButtonSpacing, type IconProp, type IconSize } from '../types';
3
3
  export type CommonDefaultButtonProps = {
4
- /**
5
- * Conditionally show a spinner over the top of a button
6
- */
7
- isLoading?: boolean;
8
4
  /**
9
5
  * Text content to be rendered in the button. Required so that screen readers always have an accessible label provided for the button.
10
6
  */
@@ -1,9 +1,5 @@
1
1
  import { type IconButtonAppearance, type IconButtonSpacing, type IconProp, type IconSize } from '../types';
2
2
  export type CommonIconButtonProps = {
3
- /**
4
- * Conditionally show a spinner over the top of a button
5
- */
6
- isLoading?: boolean;
7
3
  /**
8
4
  * The button style variation.
9
5
  */
@@ -5,10 +5,12 @@ export type ColorGroup<T extends BackgroundColor | TextColor> = {
5
5
  hover?: T;
6
6
  active?: T;
7
7
  disabled?: T;
8
- selected?: T;
9
8
  };
10
- export type ColorPreset<T extends BackgroundColor | TextColor> = {
11
- [key in Appearance]: ColorGroup<T>;
9
+ export type ColorGroupWithSelected<T extends BackgroundColor | TextColor> = ColorGroup<T> & {
10
+ selected?: ColorGroup<T>;
11
+ };
12
+ export type ColorPreset<T extends BackgroundColor | TextColor> = Record<Appearance, ColorGroupWithSelected<T>> & {
13
+ selected: ColorGroup<T>;
12
14
  };
13
15
  type Values = {
14
16
  background: ColorPreset<BackgroundColor>;
@@ -16,6 +16,7 @@ export type UseButtonBaseArgs<TagName extends HTMLElement> = {
16
16
  appearance?: Appearance;
17
17
  children: React.ReactNode;
18
18
  spacing?: Spacing;
19
+ isLoading?: boolean;
19
20
  } & Pick<CommonButtonProps<TagName>, 'analyticsContext' | 'autoFocus' | 'interactionName' | 'isDisabled' | 'isSelected' | 'overlay'> & ControlledEvents<TagName>;
20
21
  export type UseButtonBaseReturn<TagName extends HTMLElement> = {
21
22
  xcss: ReturnType<typeof xcss>;
@@ -36,5 +37,5 @@ export type UseButtonBaseReturn<TagName extends HTMLElement> = {
36
37
  *
37
38
  * @private
38
39
  */
39
- declare const useButtonBase: <TagName extends HTMLElement>({ appearance: propAppearance, autoFocus, buttonType, isDisabled: propIsDisabled, isSelected, isIconButton, isCircle, hasIconBefore, hasIconAfter, children, onClick, onMouseDownCapture, onMouseUpCapture, onKeyDownCapture, onKeyUpCapture, onTouchStartCapture, onTouchEndCapture, onPointerDownCapture, onPointerUpCapture, onClickCapture, overlay, ref, shouldFitContainer, spacing: propSpacing, }: UseButtonBaseArgs<TagName>) => UseButtonBaseReturn<TagName>;
40
+ declare const useButtonBase: <TagName extends HTMLElement>({ appearance: propAppearance, autoFocus, buttonType, isDisabled: propIsDisabled, isLoading, isSelected, isIconButton, isCircle, hasIconBefore, hasIconAfter, children, onClick, onMouseDownCapture, onMouseUpCapture, onKeyDownCapture, onKeyUpCapture, onTouchStartCapture, onTouchEndCapture, onPointerDownCapture, onPointerUpCapture, onClickCapture, overlay, ref, shouldFitContainer, spacing: propSpacing, }: UseButtonBaseArgs<TagName>) => UseButtonBaseReturn<TagName>;
40
41
  export default useButtonBase;
@@ -7,6 +7,7 @@ export type GetXCSSArgs = {
7
7
  appearance: Appearance;
8
8
  spacing: Spacing;
9
9
  isDisabled: boolean;
10
+ isLoading: boolean;
10
11
  isSelected: boolean;
11
12
  isHighlighted: boolean;
12
13
  isActiveOverSelected: boolean;
@@ -29,4 +30,4 @@ export type GetXCSSArgs = {
29
30
  */
30
31
  isNavigationSplit: boolean;
31
32
  };
32
- export declare function getXCSS({ appearance, spacing, isDisabled, isSelected, isHighlighted, isActiveOverSelected, isIconButton, isCircle, shouldFitContainer, isLink, isSplit, isNavigationSplit, hasOverlay, hasIconBefore, hasIconAfter, }: GetXCSSArgs): ReturnType<typeof xcss>;
33
+ export declare function getXCSS({ appearance, spacing, isDisabled, isSelected, isLoading, isHighlighted, isActiveOverSelected, isIconButton, isCircle, shouldFitContainer, isLink, isSplit, isNavigationSplit, hasOverlay, hasIconBefore, hasIconAfter, }: GetXCSSArgs): ReturnType<typeof xcss>;
@@ -67,6 +67,10 @@ export type AdditionalButtonVariantProps = {
67
67
  * The button style variation.
68
68
  */
69
69
  appearance?: ButtonAppearance;
70
+ /**
71
+ * Conditionally show a spinner over the top of a button
72
+ */
73
+ isLoading?: boolean;
70
74
  };
71
75
  /**
72
76
  * Combines common button props with additional HTML attributes
@@ -5,85 +5,85 @@ export type Spacing = 'compact' | 'default' | 'none';
5
5
  type Combine<First, Second> = Omit<First, keyof Second> & Second;
6
6
  export type BaseOwnProps = {
7
7
  /**
8
- * The base styling to apply to the button
8
+ * The base styling to apply to the button.
9
9
  */
10
10
  appearance?: Appearance;
11
11
  /**
12
- * Set the button to autofocus on mount
12
+ * Set the button to autofocus on mount.
13
13
  */
14
14
  autoFocus?: boolean;
15
15
  /**
16
- * Add a classname to the button
16
+ * Add a classname to the button.
17
17
  */
18
18
  className?: string;
19
19
  /**
20
- * Used to 'overlay' something over a button. This is commonly used to display a loading spinner
20
+ * Used to 'overlay' something over a button. This is commonly used to display a loading spinner.
21
21
  */
22
22
  overlay?: React.ReactNode;
23
23
  /**
24
- * Provides a url for buttons being used as a link
24
+ * Provides a URL that's used when the button is a link styled as a button.
25
25
  */
26
26
  href?: string;
27
27
  /**
28
- * Places an icon within the button, after the button's text
28
+ * Places an icon within the button, after the button's text.
29
29
  */
30
30
  iconAfter?: React.ReactChild;
31
31
  /**
32
- * Places an icon within the button, before the button's text
32
+ * Places an icon within the button, before the button's text.
33
33
  */
34
34
  iconBefore?: React.ReactChild;
35
35
  /**
36
- * Set if the button is disabled
36
+ * Set if the button is disabled.
37
37
  */
38
38
  isDisabled?: boolean;
39
39
  /**
40
- * Change the style to indicate the button is selected
40
+ * Change the style to indicate the button is selected.
41
41
  */
42
42
  isSelected?: boolean;
43
43
  /**
44
- * Handler to be called on blur
44
+ * Handler to be called on blur.
45
45
  */
46
46
  onBlur?: React.FocusEventHandler<HTMLElement>;
47
47
  /**
48
- * Handler to be called on click. The second argument can be used to track analytics data. See the tutorial in the analytics-next package for details
48
+ * Handler to be called on click. The second argument can be used to track analytics data. See the tutorial in the analytics-next package for details.
49
49
  */
50
50
  onClick?: (e: React.MouseEvent<HTMLElement>, analyticsEvent: UIAnalyticsEvent) => void;
51
51
  /**
52
- * Handler to be called on focus
52
+ * Handler to be called on focus.
53
53
  */
54
54
  onFocus?: React.FocusEventHandler<HTMLElement>;
55
55
  /**
56
- * Set the amount of padding in the button
56
+ * Set the amount of padding in the button.
57
57
  */
58
58
  spacing?: Spacing;
59
59
  /**
60
- * Pass target down to a link within the button component, if a href is provided
60
+ * Pass target down to the button. If a href is provided, this will be a semantic link styled as a button.
61
61
  */
62
62
  target?: React.AnchorHTMLAttributes<HTMLAnchorElement>['target'];
63
63
  /**
64
- * Pass type down to a button
64
+ * Pass type down to the button.
65
65
  */
66
66
  type?: React.ButtonHTMLAttributes<HTMLButtonElement>['type'];
67
67
  /**
68
- * Option to fit button width to its parent width
68
+ * Option to fit button width to its parent width.
69
69
  */
70
70
  shouldFitContainer?: boolean;
71
71
  /**
72
- * Text content to be rendered in the button
72
+ * Text content to be rendered in the button.
73
73
  */
74
74
  children?: React.ReactNode;
75
75
  /**
76
- * A `testId` prop is provided for specified elements, which is a unique string that appears as a data attribute `data-testid` in the rendered code, serving as a hook for automated tests
76
+ * A `testId` prop is provided for specified elements, which is a unique string that appears as a data attribute `data-testid` in the rendered code, serving as a hook for automated tests.
77
77
  */
78
78
  testId?: string;
79
79
  component?: React.ComponentType<React.AllHTMLAttributes<HTMLElement>> | React.ElementType;
80
80
  /**
81
81
  * An optional name used to identify this component to press listeners. For example, interaction tracing. For more information,
82
- * see [UFO integration into Design System components](https://go.atlassian.com/react-ufo-dst-integration)
82
+ * see [UFO integration into Design System components](https://go.atlassian.com/react-ufo-dst-integration).
83
83
  */
84
84
  interactionName?: string;
85
85
  /**
86
- * Additional information to be included in the `context` of analytics events that come from button
86
+ * Additional information to be included in the `context` of analytics events that come from button.
87
87
  */
88
88
  analyticsContext?: Record<string, any>;
89
89
  };
@@ -4,11 +4,11 @@ import { jsx } from '@emotion/react';
4
4
  import { Appearance } from '../old-button/types';
5
5
  export type ButtonGroupProps = {
6
6
  /**
7
- * The appearance to apply to all buttons
7
+ * The appearance to apply to all buttons.
8
8
  */
9
9
  appearance?: Appearance;
10
10
  /**
11
- * The buttons to render inside the Button Group
11
+ * The buttons to render inside the button group.
12
12
  */
13
13
  children?: React.ReactNode;
14
14
  /**
@@ -16,12 +16,12 @@ export type ButtonGroupProps = {
16
16
  */
17
17
  testId?: string;
18
18
  /**
19
- * Refers to an aria-label attribute. Sets an accessible name for ButtonGroup wrapper to announce it to users of assistive technology.
19
+ * Refers to an `aria-label` attribute. Sets an accessible name for the button group wrapper to announce it to users of assistive technology.
20
20
  * Usage of either this, or the `titleId` attribute is strongly recommended.
21
21
  */
22
22
  label?: string;
23
23
  /**
24
- * Id referenced by the ButtonGroup wrapper's aria-labelledby attribute. This id should be assigned to the group-button title element.
24
+ * ID referenced by the button group wrapper's `aria-labelledby` attribute. This ID should be assigned to the group-button title element.
25
25
  * Usage of either this, or the `label` attribute is strongly recommended.
26
26
  */
27
27
  titleId?: string;
@@ -1,7 +1,2 @@
1
- /**
2
- * Must import '@emotion/core' in order to resolve type error
3
- * https://product-fabric.atlassian.net/browse/DSP-3222
4
- */
5
- import '@emotion/react';
6
1
  export { default } from '../old-button/button';
7
2
  export type { ButtonProps } from '../old-button/button';
@@ -1,10 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { type ButtonSpacing, type IconProp, type IconSize } from '../types';
3
3
  export type CommonDefaultButtonProps = {
4
- /**
5
- * Conditionally show a spinner over the top of a button
6
- */
7
- isLoading?: boolean;
8
4
  /**
9
5
  * Text content to be rendered in the button. Required so that screen readers always have an accessible label provided for the button.
10
6
  */
@@ -1,9 +1,5 @@
1
1
  import { type IconButtonAppearance, type IconButtonSpacing, type IconProp, type IconSize } from '../types';
2
2
  export type CommonIconButtonProps = {
3
- /**
4
- * Conditionally show a spinner over the top of a button
5
- */
6
- isLoading?: boolean;
7
3
  /**
8
4
  * The button style variation.
9
5
  */
@@ -5,10 +5,12 @@ export type ColorGroup<T extends BackgroundColor | TextColor> = {
5
5
  hover?: T;
6
6
  active?: T;
7
7
  disabled?: T;
8
- selected?: T;
9
8
  };
10
- export type ColorPreset<T extends BackgroundColor | TextColor> = {
11
- [key in Appearance]: ColorGroup<T>;
9
+ export type ColorGroupWithSelected<T extends BackgroundColor | TextColor> = ColorGroup<T> & {
10
+ selected?: ColorGroup<T>;
11
+ };
12
+ export type ColorPreset<T extends BackgroundColor | TextColor> = Record<Appearance, ColorGroupWithSelected<T>> & {
13
+ selected: ColorGroup<T>;
12
14
  };
13
15
  type Values = {
14
16
  background: ColorPreset<BackgroundColor>;
@@ -16,6 +16,7 @@ export type UseButtonBaseArgs<TagName extends HTMLElement> = {
16
16
  appearance?: Appearance;
17
17
  children: React.ReactNode;
18
18
  spacing?: Spacing;
19
+ isLoading?: boolean;
19
20
  } & Pick<CommonButtonProps<TagName>, 'analyticsContext' | 'autoFocus' | 'interactionName' | 'isDisabled' | 'isSelected' | 'overlay'> & ControlledEvents<TagName>;
20
21
  export type UseButtonBaseReturn<TagName extends HTMLElement> = {
21
22
  xcss: ReturnType<typeof xcss>;
@@ -36,5 +37,5 @@ export type UseButtonBaseReturn<TagName extends HTMLElement> = {
36
37
  *
37
38
  * @private
38
39
  */
39
- declare const useButtonBase: <TagName extends HTMLElement>({ appearance: propAppearance, autoFocus, buttonType, isDisabled: propIsDisabled, isSelected, isIconButton, isCircle, hasIconBefore, hasIconAfter, children, onClick, onMouseDownCapture, onMouseUpCapture, onKeyDownCapture, onKeyUpCapture, onTouchStartCapture, onTouchEndCapture, onPointerDownCapture, onPointerUpCapture, onClickCapture, overlay, ref, shouldFitContainer, spacing: propSpacing, }: UseButtonBaseArgs<TagName>) => UseButtonBaseReturn<TagName>;
40
+ declare const useButtonBase: <TagName extends HTMLElement>({ appearance: propAppearance, autoFocus, buttonType, isDisabled: propIsDisabled, isLoading, isSelected, isIconButton, isCircle, hasIconBefore, hasIconAfter, children, onClick, onMouseDownCapture, onMouseUpCapture, onKeyDownCapture, onKeyUpCapture, onTouchStartCapture, onTouchEndCapture, onPointerDownCapture, onPointerUpCapture, onClickCapture, overlay, ref, shouldFitContainer, spacing: propSpacing, }: UseButtonBaseArgs<TagName>) => UseButtonBaseReturn<TagName>;
40
41
  export default useButtonBase;
@@ -7,6 +7,7 @@ export type GetXCSSArgs = {
7
7
  appearance: Appearance;
8
8
  spacing: Spacing;
9
9
  isDisabled: boolean;
10
+ isLoading: boolean;
10
11
  isSelected: boolean;
11
12
  isHighlighted: boolean;
12
13
  isActiveOverSelected: boolean;
@@ -29,4 +30,4 @@ export type GetXCSSArgs = {
29
30
  */
30
31
  isNavigationSplit: boolean;
31
32
  };
32
- export declare function getXCSS({ appearance, spacing, isDisabled, isSelected, isHighlighted, isActiveOverSelected, isIconButton, isCircle, shouldFitContainer, isLink, isSplit, isNavigationSplit, hasOverlay, hasIconBefore, hasIconAfter, }: GetXCSSArgs): ReturnType<typeof xcss>;
33
+ export declare function getXCSS({ appearance, spacing, isDisabled, isSelected, isLoading, isHighlighted, isActiveOverSelected, isIconButton, isCircle, shouldFitContainer, isLink, isSplit, isNavigationSplit, hasOverlay, hasIconBefore, hasIconAfter, }: GetXCSSArgs): ReturnType<typeof xcss>;
@@ -67,6 +67,10 @@ export type AdditionalButtonVariantProps = {
67
67
  * The button style variation.
68
68
  */
69
69
  appearance?: ButtonAppearance;
70
+ /**
71
+ * Conditionally show a spinner over the top of a button
72
+ */
73
+ isLoading?: boolean;
70
74
  };
71
75
  /**
72
76
  * Combines common button props with additional HTML attributes