@atlaskit/button 16.10.1 → 16.11.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 (81) hide show
  1. package/CHANGELOG.md +72 -60
  2. package/dist/cjs/containers/button-group.js +1 -0
  3. package/dist/cjs/entry-points/new.js +8 -1
  4. package/dist/cjs/entry-points/unsafe.js +40 -1
  5. package/dist/cjs/new-button/containers/split-button/index.js +50 -0
  6. package/dist/cjs/new-button/containers/split-button/split-button-context.js +37 -0
  7. package/dist/cjs/new-button/containers/split-button/split-button.js +137 -0
  8. package/dist/cjs/new-button/containers/split-button/types.js +5 -0
  9. package/dist/cjs/new-button/containers/split-button/utils.js +23 -0
  10. package/dist/cjs/new-button/variants/default/button.js +1 -2
  11. package/dist/cjs/new-button/variants/default/link.js +1 -2
  12. package/dist/cjs/new-button/variants/default/use-default-button.js +11 -16
  13. package/dist/cjs/new-button/variants/icon/button.js +1 -2
  14. package/dist/cjs/new-button/variants/icon/link.js +1 -2
  15. package/dist/cjs/new-button/variants/icon/use-icon-button.js +6 -10
  16. package/dist/cjs/new-button/variants/shared/colors.js +1 -2
  17. package/dist/cjs/new-button/variants/shared/content.js +51 -0
  18. package/dist/cjs/new-button/variants/shared/use-button-base.js +32 -9
  19. package/dist/cjs/new-button/variants/shared/xcss.js +53 -53
  20. package/dist/cjs/old-button/button.js +1 -2
  21. package/dist/cjs/old-button/custom-theme-button/custom-theme-button.js +1 -2
  22. package/dist/cjs/old-button/custom-theme-button/theme.js +1 -2
  23. package/dist/cjs/old-button/loading-button.js +1 -2
  24. package/dist/cjs/old-button/shared/button-base.js +9 -9
  25. package/dist/cjs/old-button/shared/colors.js +1 -2
  26. package/dist/cjs/old-button/shared/css.js +2 -3
  27. package/dist/cjs/old-button/shared/get-if-visually-hidden-children.js +2 -3
  28. package/dist/cjs/utils/appearances.js +1 -2
  29. package/dist/cjs/utils/spacing.js +1 -2
  30. package/dist/cjs/utils/variants.js +2 -4
  31. package/dist/es2019/containers/button-group.js +1 -0
  32. package/dist/es2019/entry-points/new.js +2 -1
  33. package/dist/es2019/entry-points/unsafe.js +4 -1
  34. package/dist/es2019/new-button/containers/split-button/index.js +3 -0
  35. package/dist/es2019/new-button/containers/split-button/split-button-context.js +31 -0
  36. package/dist/es2019/new-button/containers/split-button/split-button.js +129 -0
  37. package/dist/es2019/new-button/containers/split-button/types.js +1 -0
  38. package/dist/es2019/new-button/containers/split-button/utils.js +12 -0
  39. package/dist/es2019/new-button/variants/default/use-default-button.js +10 -14
  40. package/dist/es2019/new-button/variants/icon/use-icon-button.js +5 -8
  41. package/dist/es2019/new-button/variants/shared/content.js +43 -0
  42. package/dist/es2019/new-button/variants/shared/use-button-base.js +32 -8
  43. package/dist/es2019/new-button/variants/shared/xcss.js +55 -48
  44. package/dist/es2019/old-button/shared/button-base.js +7 -6
  45. package/dist/esm/containers/button-group.js +1 -0
  46. package/dist/esm/entry-points/new.js +2 -1
  47. package/dist/esm/entry-points/unsafe.js +4 -1
  48. package/dist/esm/new-button/containers/split-button/index.js +3 -0
  49. package/dist/esm/new-button/containers/split-button/split-button-context.js +31 -0
  50. package/dist/esm/new-button/containers/split-button/split-button.js +131 -0
  51. package/dist/esm/new-button/containers/split-button/types.js +1 -0
  52. package/dist/esm/new-button/containers/split-button/utils.js +16 -0
  53. package/dist/esm/new-button/variants/default/use-default-button.js +10 -14
  54. package/dist/esm/new-button/variants/icon/use-icon-button.js +5 -8
  55. package/dist/esm/new-button/variants/shared/content.js +44 -0
  56. package/dist/esm/new-button/variants/shared/use-button-base.js +32 -8
  57. package/dist/esm/new-button/variants/shared/xcss.js +52 -47
  58. package/dist/esm/old-button/shared/button-base.js +7 -6
  59. package/dist/types/entry-points/new.d.ts +1 -0
  60. package/dist/types/entry-points/unsafe.d.ts +3 -0
  61. package/dist/types/new-button/containers/split-button/index.d.ts +3 -0
  62. package/dist/types/new-button/containers/split-button/split-button-context.d.ts +47 -0
  63. package/dist/types/new-button/containers/split-button/split-button.d.ts +47 -0
  64. package/dist/types/new-button/containers/split-button/types.d.ts +4 -0
  65. package/dist/types/new-button/containers/split-button/utils.d.ts +5 -0
  66. package/dist/types/new-button/variants/shared/content.d.ts +13 -0
  67. package/dist/types/new-button/variants/shared/use-button-base.d.ts +1 -1
  68. package/dist/types/new-button/variants/shared/xcss.d.ts +14 -7
  69. package/dist/types/old-button/types.d.ts +2 -2
  70. package/dist/types-ts4.5/entry-points/new.d.ts +1 -0
  71. package/dist/types-ts4.5/entry-points/unsafe.d.ts +3 -0
  72. package/dist/types-ts4.5/new-button/containers/split-button/index.d.ts +3 -0
  73. package/dist/types-ts4.5/new-button/containers/split-button/split-button-context.d.ts +47 -0
  74. package/dist/types-ts4.5/new-button/containers/split-button/split-button.d.ts +47 -0
  75. package/dist/types-ts4.5/new-button/containers/split-button/types.d.ts +4 -0
  76. package/dist/types-ts4.5/new-button/containers/split-button/utils.d.ts +5 -0
  77. package/dist/types-ts4.5/new-button/variants/shared/content.d.ts +13 -0
  78. package/dist/types-ts4.5/new-button/variants/shared/use-button-base.d.ts +1 -1
  79. package/dist/types-ts4.5/new-button/variants/shared/xcss.d.ts +14 -7
  80. package/dist/types-ts4.5/old-button/types.d.ts +2 -2
  81. package/package.json +6 -6
@@ -2,7 +2,7 @@ import { xcss } from '@atlaskit/primitives';
2
2
  import { fontSize as getFontSize } from '@atlaskit/theme/constants';
3
3
  import colors from './colors';
4
4
  const fontSize = getFontSize();
5
- const heights = {
5
+ export const heights = {
6
6
  default: `${32 / fontSize}em`,
7
7
  compact: `${24 / fontSize}em`,
8
8
  none: 'auto'
@@ -31,6 +31,19 @@ const verticalAlign = {
31
31
  compact: 'middle',
32
32
  none: 'baseline'
33
33
  };
34
+ const splitBorderStyles = {
35
+ ':first-of-type': {
36
+ borderTopRightRadius: 0,
37
+ borderBottomRightRadius: 0
38
+ },
39
+ ':last-of-type': {
40
+ borderTopLeftRadius: 0,
41
+ borderBottomLeftRadius: 0
42
+ },
43
+ ':focus-visible': {
44
+ zIndex: 1
45
+ }
46
+ };
34
47
  function getColor({
35
48
  group,
36
49
  key
@@ -42,12 +55,14 @@ function getColors({
42
55
  interactionState = 'default',
43
56
  isDisabled,
44
57
  isSelected,
58
+ isHighlighted,
59
+ isActiveOverSelected,
45
60
  hasOverlay
46
61
  }) {
47
62
  let key = interactionState;
48
63
  // Overlay does not change color on interaction, revert to 'default' or resting state
49
64
  key = hasOverlay ? 'default' : key;
50
- key = isSelected ? 'selected' : key;
65
+ key = isSelected || isHighlighted ? isActiveOverSelected ? 'active' : 'selected' : key;
51
66
  // Disabled colors overrule everything else
52
67
  key = isDisabled ? 'disabled' : key;
53
68
  return {
@@ -66,9 +81,13 @@ export function getXCSS({
66
81
  spacing,
67
82
  isDisabled,
68
83
  isSelected,
84
+ isHighlighted,
85
+ isActiveOverSelected,
69
86
  isIconButton,
70
87
  shouldFitContainer,
71
88
  isLink,
89
+ isSplit,
90
+ isNavigationSplit,
72
91
  hasOverlay,
73
92
  hasIconBefore,
74
93
  hasIconAfter
@@ -76,6 +95,8 @@ export function getXCSS({
76
95
  const baseColors = getColors({
77
96
  appearance,
78
97
  isSelected,
98
+ isHighlighted,
99
+ isActiveOverSelected,
79
100
  isDisabled
80
101
  });
81
102
  const combinedBaseColorStyles = isLink ? {
@@ -83,12 +104,32 @@ export function getXCSS({
83
104
  textDecoration: 'none',
84
105
  // Disabling visited styles (by re-declaring the base colors)
85
106
  ':visited': baseColors
107
+ } : isNavigationSplit && !isSelected ? {
108
+ ...baseColors,
109
+ backgroundColor: 'color.background.neutral.subtle'
86
110
  } : baseColors;
87
111
  const height = heights[spacing];
88
112
  let width = shouldFitContainer ? '100%' : 'auto';
89
- width = isIconButton ? height : width;
90
- const paddingInlineStart = paddingInline[spacing][hasIconBefore ? 'withIcon' : 'default'];
91
- const paddingInlineEnd = paddingInline[spacing][hasIconAfter ? 'withIcon' : 'default'];
113
+ width = isIconButton ? isNavigationSplit ? '24px' : height : width;
114
+ const defaultPaddingInlineStart = paddingInline[spacing][hasIconBefore ? 'withIcon' : 'default'];
115
+ const defaultPaddingInlineEnd = paddingInline[spacing][hasIconAfter ? 'withIcon' : 'default'];
116
+ const splitButtonStyles = isSplit ? splitBorderStyles : {};
117
+ const getNavigationSplitButtonPaddings = () => {
118
+ if (isNavigationSplit) {
119
+ return {
120
+ paddingInlineStart: 'space.075',
121
+ paddingInlineEnd: 'space.075'
122
+ };
123
+ }
124
+ return {
125
+ paddingInlineStart: isIconButton ? 'space.0' : defaultPaddingInlineStart,
126
+ paddingInlineEnd: isIconButton ? 'space.0' : defaultPaddingInlineEnd
127
+ };
128
+ };
129
+ const {
130
+ paddingInlineStart,
131
+ paddingInlineEnd
132
+ } = getNavigationSplitButtonPaddings();
92
133
  return xcss({
93
134
  alignItems: 'center',
94
135
  borderWidth: 'border.width.0',
@@ -107,8 +148,8 @@ export function getXCSS({
107
148
  whiteSpace: 'nowrap',
108
149
  height,
109
150
  paddingBlock: 'space.0',
110
- paddingInlineStart: isIconButton ? 'space.0' : paddingInlineStart,
111
- paddingInlineEnd: isIconButton ? 'space.0' : paddingInlineEnd,
151
+ paddingInlineStart,
152
+ paddingInlineEnd,
112
153
  columnGap: gap[spacing],
113
154
  verticalAlign: verticalAlign[spacing],
114
155
  width,
@@ -121,7 +162,8 @@ export function getXCSS({
121
162
  ':hover': {
122
163
  ...getColors({
123
164
  appearance,
124
- isSelected,
165
+ isSelected: isNavigationSplit && !isSelected ? false : isSelected,
166
+ isActiveOverSelected,
125
167
  isDisabled,
126
168
  interactionState: 'hover',
127
169
  hasOverlay
@@ -133,50 +175,15 @@ export function getXCSS({
133
175
  ':active': {
134
176
  ...getColors({
135
177
  appearance,
136
- isSelected,
178
+ isSelected: isNavigationSplit && !isSelected ? false : isSelected,
179
+ isActiveOverSelected,
137
180
  isDisabled,
138
181
  interactionState: 'active',
139
182
  hasOverlay
140
183
  }),
141
184
  // background, box-shadow
142
185
  transitionDuration: '0s, 0s'
143
- }
144
- });
145
- }
146
- export const iconStyles = xcss({
147
- display: 'flex',
148
- // icon size cannot grow and shrink
149
- flexGrow: 0,
150
- flexShrink: 0,
151
- alignSelf: 'center',
152
- fontSize: 0,
153
- lineHeight: 0,
154
- userSelect: 'none'
155
- });
156
- export const contentStyles = xcss({
157
- // content can grow and shrink
158
- flexGrow: 1,
159
- flexShrink: 1,
160
- // ellipsis for overflow text
161
- overflow: 'hidden',
162
- textOverflow: 'ellipsis',
163
- whiteSpace: 'nowrap'
164
- });
165
- export function getFadingStyles({
166
- hasOverlay
167
- }) {
168
- return xcss({
169
- opacity: hasOverlay ? 0 : 1,
170
- transition: 'opacity 0.3s'
186
+ },
187
+ ...splitButtonStyles
171
188
  });
172
- }
173
- export const overlayStyles = xcss({
174
- position: 'absolute',
175
- left: 'space.0',
176
- top: 'space.0',
177
- right: 'space.0',
178
- bottom: 'space.0',
179
- display: 'flex',
180
- alignItems: 'center',
181
- justifyContent: 'center'
182
- });
189
+ }
@@ -1,4 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ /* eslint-disable @atlaskit/design-system/consistent-css-prop-usage */
2
3
  /** @jsx jsx */
3
4
  import React, { useCallback, useContext, useEffect, useRef } from 'react';
4
5
  import { css, jsx } from '@emotion/react';
@@ -102,7 +103,7 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
102
103
  action: 'clicked',
103
104
  componentName: 'button',
104
105
  packageName: "@atlaskit/button",
105
- packageVersion: "16.10.1",
106
+ packageVersion: "16.11.0",
106
107
  analyticsData: analyticsContext
107
108
  });
108
109
 
@@ -122,7 +123,7 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
122
123
 
123
124
  // we are 'disabling' input with a button when there is an overlay
124
125
  const hasOverlay = Boolean(overlay);
125
- const fadeCss = css(getFadingCss({
126
+ const fadeStyles = css(getFadingCss({
126
127
  hasOverlay
127
128
  }));
128
129
  const isInteractive = !isDisabled && !hasOverlay;
@@ -163,17 +164,17 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
163
164
  }, blockEvents({
164
165
  isInteractive
165
166
  })), iconBefore ? jsx("span", {
166
- css: [fadeCss, getIconStyle({
167
+ css: [fadeStyles, getIconStyle({
167
168
  spacing
168
169
  }), getSpacingFix(children, iconBeforeSpacingFixStyle)]
169
170
  }, iconBefore) : null, !getBooleanFF('platform.design-system-team.icon-button-spacing-fix_o1zc5') && children ? jsx("span", {
170
- css: [fadeCss, getContentStyle({
171
+ css: [fadeStyles, getContentStyle({
171
172
  spacing
172
173
  })]
173
- }, children) : null, getBooleanFF('platform.design-system-team.icon-button-spacing-fix_o1zc5') && getChildren(children, [fadeCss, getContentStyle({
174
+ }, children) : null, getBooleanFF('platform.design-system-team.icon-button-spacing-fix_o1zc5') && getChildren(children, [fadeStyles, getContentStyle({
174
175
  spacing
175
176
  })]), iconAfter ? jsx("span", {
176
- css: [fadeCss, getIconStyle({
177
+ css: [fadeStyles, getIconStyle({
177
178
  spacing
178
179
  }), getSpacingFix(children, iconAfterSpacingFixStyle)]
179
180
  }, iconAfter) : null, overlay ? jsx("span", {
@@ -4,6 +4,7 @@ import { css, jsx } from '@emotion/react';
4
4
  var buttonGroupStyles = css({
5
5
  display: 'inline-flex',
6
6
  gap: "var(--ds-space-050, 4px)",
7
+ // eslint-disable-next-line @atlaskit/design-system/no-nested-styles
7
8
  '> *': {
8
9
  flex: '1 0 auto'
9
10
  }
@@ -1,4 +1,5 @@
1
1
  export { default } from '../new-button/variants/default/button';
2
2
  export { default as LinkButton } from '../new-button/variants/default/link';
3
3
  export { default as IconButton } from '../new-button/variants/icon/button';
4
- export { default as LinkIconButton } from '../new-button/variants/icon/link';
4
+ export { default as LinkIconButton } from '../new-button/variants/icon/link';
5
+ export { SplitButton } from '../new-button/containers/split-button';
@@ -1 +1,4 @@
1
- export { default as UNSAFE_BUTTON } from '../new-button/variants/default/button';
1
+ export { default as UNSAFE_BUTTON } from '../new-button/variants/default/button';
2
+ export { default as UNSAFE_ICON_BUTTON } from '../new-button/variants/icon/button';
3
+ export { SplitButton as UNSAFE_SPLIT_BUTTON, SplitButtonContainer as UNSAFE_SPLIT_BUTTON_CONTAINER, Divider as UNSAFE_DIVIDER, getActions as UNSAFE_GET_ACTIONS } from '../new-button/containers/split-button';
4
+ export { SplitButtonContext as UNSAFE_SPLIT_BUTTON_CONTEXT } from '../new-button/containers/split-button/split-button-context';
@@ -0,0 +1,3 @@
1
+ export { SplitButton, SplitButtonWithSlots, Divider, SplitButtonContainer } from './split-button';
2
+ export { getActions } from './utils';
3
+ export { SplitButtonContext, useSplitButtonContext } from './split-button-context';
@@ -0,0 +1,31 @@
1
+ import { createContext, useContext } from 'react';
2
+ /**
3
+ * TODO: Add jsdoc
4
+ */
5
+ export var SplitButtonContext = /*#__PURE__*/createContext(undefined);
6
+ export var useSplitButtonContext = function useSplitButtonContext() {
7
+ var context = useContext(SplitButtonContext);
8
+ if (!context) {
9
+ return undefined;
10
+ }
11
+ if (context.appearance === 'navigation') {
12
+ var newContext = {
13
+ spacing: 'default',
14
+ appearance: 'subtle',
15
+ isDisabled: false,
16
+ isActiveOverSelected: false,
17
+ isNavigationSplitButton: true,
18
+ isHighlighted: context.isHighlighted
19
+ };
20
+ return newContext;
21
+ }
22
+ var splitButtonContext = {
23
+ spacing: context.spacing,
24
+ appearance: context.appearance,
25
+ isDisabled: context.isDisabled,
26
+ isActiveOverSelected: true,
27
+ isNavigationSplitButton: false,
28
+ isHighlighted: false
29
+ };
30
+ return splitButtonContext;
31
+ };
@@ -0,0 +1,131 @@
1
+ /** @jsx jsx */
2
+
3
+ import { css, jsx } from '@emotion/react';
4
+ import { fontSize as getFontSize } from '@atlaskit/theme/constants';
5
+ import { SplitButtonContext } from './split-button-context';
6
+ import { getActions } from './utils';
7
+ var fontSize = getFontSize();
8
+ var defaultDividerHeight = 20 / fontSize + 'em';
9
+ var defaultDividerStyles = css({
10
+ height: defaultDividerHeight,
11
+ margin: "var(--ds-space-075, 6px)".concat(" -0.5px")
12
+ });
13
+ var compactDividerHeight = 16 / fontSize + 'em';
14
+ var compactDividerStyles = css({
15
+ height: compactDividerHeight,
16
+ margin: "var(--ds-space-050, 4px)".concat(" -0.5px")
17
+ });
18
+ var baseDividerStyles = css({
19
+ display: 'inline-flex',
20
+ width: '1px',
21
+ position: 'relative',
22
+ zIndex: 2
23
+ });
24
+ var disabledStyles = css({
25
+ backgroundColor: "var(--ds-border, #091E4224)",
26
+ cursor: 'not-allowed'
27
+ });
28
+ var navigationDividerStyles = css({
29
+ height: compactDividerHeight,
30
+ margin: "var(--ds-space-100, 8px)".concat(" -0.5px"),
31
+ backgroundColor: "var(--ds-border, #0052cc)"
32
+ });
33
+ var dividerAppearance = {
34
+ default: css({
35
+ backgroundColor: "var(--ds-text, #172B4D)"
36
+ }),
37
+ primary: css({
38
+ backgroundColor: "var(--ds-text-inverse, #FFF)"
39
+ }),
40
+ danger: css({
41
+ backgroundColor: "var(--ds-text-inverse, #FFF)"
42
+ }),
43
+ warning: css({
44
+ backgroundColor: "var(--ds-text-warning-inverse, #172B4D)"
45
+ }),
46
+ navigation: navigationDividerStyles
47
+ };
48
+ var dividerHeight = {
49
+ default: defaultDividerStyles,
50
+ compact: compactDividerStyles
51
+ };
52
+ /**
53
+ * TODO: Add JSDoc
54
+ */
55
+ export var Divider = function Divider(_ref) {
56
+ var appearance = _ref.appearance,
57
+ spacing = _ref.spacing,
58
+ _ref$isDisabled = _ref.isDisabled,
59
+ isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled;
60
+ return (
61
+ // I find it funny to provide a div for Divider
62
+ jsx("div", {
63
+ css: [baseDividerStyles, dividerAppearance[appearance], dividerHeight[spacing], isDisabled ? disabledStyles : undefined]
64
+ })
65
+ );
66
+ };
67
+ var splitButtonStyles = css({
68
+ display: 'inline-flex',
69
+ position: 'relative',
70
+ whiteSpace: 'nowrap'
71
+ });
72
+
73
+ /**
74
+ * TODO: Add JSdoc
75
+ */
76
+ export var SplitButtonContainer = function SplitButtonContainer(_ref2) {
77
+ var children = _ref2.children;
78
+ return jsx("div", {
79
+ css: splitButtonStyles
80
+ }, children);
81
+ };
82
+ /**
83
+ * TODO: Add description when adding docs
84
+ */
85
+ export var SplitButton = function SplitButton(_ref3) {
86
+ var children = _ref3.children,
87
+ _ref3$appearance = _ref3.appearance,
88
+ appearance = _ref3$appearance === void 0 ? 'default' : _ref3$appearance,
89
+ _ref3$spacing = _ref3.spacing,
90
+ spacing = _ref3$spacing === void 0 ? 'default' : _ref3$spacing,
91
+ _ref3$isDisabled = _ref3.isDisabled,
92
+ isDisabled = _ref3$isDisabled === void 0 ? false : _ref3$isDisabled;
93
+ var _getActions = getActions(children),
94
+ PrimaryAction = _getActions.PrimaryAction,
95
+ SecondaryAction = _getActions.SecondaryAction;
96
+ return jsx(SplitButtonContainer, null, jsx(SplitButtonContext.Provider, {
97
+ value: {
98
+ appearance: appearance,
99
+ spacing: spacing,
100
+ isDisabled: isDisabled
101
+ }
102
+ }, PrimaryAction, jsx(Divider, {
103
+ appearance: appearance,
104
+ spacing: spacing,
105
+ isDisabled: isDisabled
106
+ }), SecondaryAction));
107
+ };
108
+ /**
109
+ * TODO: Decide on API
110
+ */
111
+ export var SplitButtonWithSlots = function SplitButtonWithSlots(_ref4) {
112
+ var primaryAction = _ref4.primaryAction,
113
+ secondaryAction = _ref4.secondaryAction,
114
+ _ref4$appearance = _ref4.appearance,
115
+ appearance = _ref4$appearance === void 0 ? 'default' : _ref4$appearance,
116
+ _ref4$spacing = _ref4.spacing,
117
+ spacing = _ref4$spacing === void 0 ? 'default' : _ref4$spacing,
118
+ _ref4$isDisabled = _ref4.isDisabled,
119
+ isDisabled = _ref4$isDisabled === void 0 ? false : _ref4$isDisabled;
120
+ return jsx(SplitButtonContainer, null, jsx(SplitButtonContext.Provider, {
121
+ value: {
122
+ appearance: appearance,
123
+ spacing: spacing,
124
+ isDisabled: isDisabled
125
+ }
126
+ }, primaryAction, jsx(Divider, {
127
+ appearance: appearance,
128
+ spacing: spacing,
129
+ isDisabled: isDisabled
130
+ }), secondaryAction));
131
+ };
@@ -0,0 +1,16 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import { Children } from 'react';
3
+ export var getActions = function getActions(children) {
4
+ var _Children$toArray = Children.toArray(children),
5
+ _Children$toArray2 = _slicedToArray(_Children$toArray, 2),
6
+ PrimaryAction = _Children$toArray2[0],
7
+ SecondaryAction = _Children$toArray2[1];
8
+ if (typeof process !== 'undefined' && process.env.NODE_ENV === 'development' && (!PrimaryAction || !SecondaryAction)) {
9
+ // TODO: i18n?
10
+ throw new SyntaxError('SplitButton requires two children to be provided');
11
+ }
12
+ return {
13
+ PrimaryAction: PrimaryAction,
14
+ SecondaryAction: SecondaryAction
15
+ };
16
+ };
@@ -1,7 +1,6 @@
1
1
  import React, { Fragment } from 'react';
2
- import { Box } from '@atlaskit/primitives';
2
+ import Content from '../shared/content';
3
3
  import useButtonBase from '../shared/use-button-base';
4
- import { contentStyles, getFadingStyles, iconStyles } from '../shared/xcss';
5
4
  /**
6
5
  * __Use default button base__
7
6
  *
@@ -36,23 +35,20 @@ var useDefaultButton = function useDefaultButton(_ref) {
36
35
  ref = _ref.ref,
37
36
  shouldFitContainer = _ref.shouldFitContainer,
38
37
  spacing = _ref.spacing;
39
- var fadeStyles = getFadingStyles({
40
- hasOverlay: Boolean(overlay)
41
- });
38
+ var hasOverlay = Boolean(overlay);
42
39
  var baseProps = useButtonBase({
43
40
  analyticsContext: analyticsContext,
44
41
  appearance: appearance,
45
42
  autoFocus: autoFocus,
46
43
  buttonType: buttonType,
47
- children: /*#__PURE__*/React.createElement(Fragment, null, iconBefore && /*#__PURE__*/React.createElement(Box, {
48
- as: "span",
49
- xcss: [fadeStyles, iconStyles]
50
- }, iconBefore), children && /*#__PURE__*/React.createElement(Box, {
51
- as: "span",
52
- xcss: [fadeStyles, contentStyles]
53
- }, children), iconAfter && /*#__PURE__*/React.createElement(Box, {
54
- as: "span",
55
- xcss: [fadeStyles, iconStyles]
44
+ children: /*#__PURE__*/React.createElement(Fragment, null, iconBefore && /*#__PURE__*/React.createElement(Content, {
45
+ type: "icon",
46
+ hasOverlay: hasOverlay
47
+ }, iconBefore), children && /*#__PURE__*/React.createElement(Content, {
48
+ hasOverlay: hasOverlay
49
+ }, children), iconAfter && /*#__PURE__*/React.createElement(Content, {
50
+ type: "icon",
51
+ hasOverlay: hasOverlay
56
52
  }, iconAfter)),
57
53
  interactionName: interactionName,
58
54
  isDisabled: isDisabled,
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
- import { Box } from '@atlaskit/primitives';
2
+ import Content from '../shared/content';
3
3
  import useButtonBase from '../shared/use-button-base';
4
- import { getFadingStyles, iconStyles } from '../shared/xcss';
5
4
  /**
6
5
  * __Use icon button__
7
6
  *
@@ -34,9 +33,7 @@ var useIconButton = function useIconButton(_ref) {
34
33
  ref = _ref.ref,
35
34
  shouldFitContainer = _ref.shouldFitContainer,
36
35
  spacing = _ref.spacing;
37
- var fadeStyles = getFadingStyles({
38
- hasOverlay: Boolean(overlay)
39
- });
36
+ var hasOverlay = Boolean(overlay);
40
37
  var baseProps = useButtonBase({
41
38
  analyticsContext: analyticsContext,
42
39
  appearance: appearance,
@@ -46,9 +43,9 @@ var useIconButton = function useIconButton(_ref) {
46
43
  * TODO: Have not finished IconButton yet. It also needs a required accessible
47
44
  * label - likely implemented using VisuallyHidden
48
45
  */
49
- children: /*#__PURE__*/React.createElement(Box, {
50
- as: "span",
51
- xcss: [fadeStyles, iconStyles]
46
+ children: /*#__PURE__*/React.createElement(Content, {
47
+ type: "icon",
48
+ hasOverlay: hasOverlay
52
49
  }, icon),
53
50
  interactionName: interactionName,
54
51
  isDisabled: isDisabled,
@@ -0,0 +1,44 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import React from 'react';
3
+ import { Box, xcss } from '@atlaskit/primitives';
4
+ var textStyles = xcss({
5
+ // content can grow and shrink
6
+ flexGrow: 1,
7
+ flexShrink: 1,
8
+ // ellipsis for overflow text
9
+ overflow: 'hidden',
10
+ textOverflow: 'ellipsis',
11
+ whiteSpace: 'nowrap'
12
+ });
13
+ var iconStyles = xcss({
14
+ display: 'flex',
15
+ // icon size cannot grow and shrink
16
+ flexGrow: 0,
17
+ flexShrink: 0,
18
+ alignSelf: 'center',
19
+ fontSize: 0,
20
+ lineHeight: 0,
21
+ userSelect: 'none'
22
+ });
23
+ var commonStyles = xcss({
24
+ transition: 'opacity 0.3s'
25
+ });
26
+ var fadeStyles = xcss({
27
+ opacity: 0
28
+ });
29
+ /**
30
+ * __Content__
31
+ *
32
+ * Used for slots within a Button, including icons and text content.
33
+ */
34
+ var Content = function Content(_ref) {
35
+ var children = _ref.children,
36
+ _ref$type = _ref.type,
37
+ type = _ref$type === void 0 ? 'text' : _ref$type,
38
+ hasOverlay = _ref.hasOverlay;
39
+ return /*#__PURE__*/React.createElement(Box, {
40
+ as: "span",
41
+ xcss: [commonStyles].concat(_toConsumableArray(type === 'text' ? [textStyles] : [iconStyles]), _toConsumableArray(hasOverlay ? [fadeStyles] : []))
42
+ }, children);
43
+ };
44
+ export default Content;
@@ -7,12 +7,24 @@ import noop from '@atlaskit/ds-lib/noop';
7
7
  import useAutoFocus from '@atlaskit/ds-lib/use-auto-focus';
8
8
  // eslint-disable-next-line no-duplicate-imports
9
9
  import InteractionContext from '@atlaskit/interaction-context';
10
- import { Box } from '@atlaskit/primitives';
10
+ import { Box, xcss } from '@atlaskit/primitives';
11
+ import { useSplitButtonContext } from '../../containers/split-button/split-button-context';
11
12
  import blockEvents from './block-events';
12
- import { getXCSS, overlayStyles } from './xcss';
13
+ import { getXCSS } from './xcss';
13
14
 
14
15
  // Include modified onClick with analytics
15
16
 
17
+ var overlayStyles = xcss({
18
+ position: 'absolute',
19
+ insetInlineStart: 'space.0',
20
+ insetBlockStart: 'space.0',
21
+ insetInlineEnd: 'space.0',
22
+ insetBlockEnd: 'space.0',
23
+ display: 'flex',
24
+ alignItems: 'center',
25
+ justifyContent: 'center'
26
+ });
27
+
16
28
  /**
17
29
  * __Use button base__
18
30
  *
@@ -29,13 +41,13 @@ import { getXCSS, overlayStyles } from './xcss';
29
41
  var useButtonBase = function useButtonBase(_ref) {
30
42
  var analyticsContext = _ref.analyticsContext,
31
43
  _ref$appearance = _ref.appearance,
32
- appearance = _ref$appearance === void 0 ? 'default' : _ref$appearance,
44
+ propAppearance = _ref$appearance === void 0 ? 'default' : _ref$appearance,
33
45
  _ref$autoFocus = _ref.autoFocus,
34
46
  autoFocus = _ref$autoFocus === void 0 ? false : _ref$autoFocus,
35
47
  buttonType = _ref.buttonType,
36
48
  interactionName = _ref.interactionName,
37
49
  _ref$isDisabled = _ref.isDisabled,
38
- isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
50
+ propIsDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
39
51
  _ref$isSelected = _ref.isSelected,
40
52
  isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected,
41
53
  _ref$isIconButton = _ref.isIconButton,
@@ -61,8 +73,16 @@ var useButtonBase = function useButtonBase(_ref) {
61
73
  _ref$shouldFitContain = _ref.shouldFitContainer,
62
74
  shouldFitContainer = _ref$shouldFitContain === void 0 ? false : _ref$shouldFitContain,
63
75
  _ref$spacing = _ref.spacing,
64
- spacing = _ref$spacing === void 0 ? 'default' : _ref$spacing;
76
+ propSpacing = _ref$spacing === void 0 ? 'default' : _ref$spacing;
65
77
  var ourRef = useRef();
78
+ var splitButtonContext = useSplitButtonContext();
79
+ var isSplitButton = Boolean(splitButtonContext);
80
+ var isNavigationSplitButton = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.isNavigationSplitButton) || false;
81
+ var appearance = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.appearance) || propAppearance;
82
+ var spacing = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.spacing) || propSpacing;
83
+ var isDisabled = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.isDisabled) || propIsDisabled;
84
+ var isHighlighted = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.isHighlighted) || false;
85
+ var isActiveOverSelected = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.isActiveOverSelected) || false;
66
86
  var setRef = useCallback(function (node) {
67
87
  ourRef.current = node;
68
88
  if (ref === null) {
@@ -87,7 +107,7 @@ var useButtonBase = function useButtonBase(_ref) {
87
107
  action: 'clicked',
88
108
  componentName: 'button',
89
109
  packageName: "@atlaskit/button",
90
- packageVersion: "16.10.1",
110
+ packageVersion: "16.11.0",
91
111
  analyticsData: analyticsContext,
92
112
  actionSubject: buttonType
93
113
  });
@@ -97,14 +117,18 @@ var useButtonBase = function useButtonBase(_ref) {
97
117
  spacing: spacing,
98
118
  isDisabled: isDisabled,
99
119
  isSelected: isSelected,
120
+ isHighlighted: isHighlighted,
121
+ isActiveOverSelected: isActiveOverSelected,
100
122
  shouldFitContainer: shouldFitContainer,
101
123
  isIconButton: isIconButton,
102
124
  hasOverlay: Boolean(overlay),
103
125
  isLink: buttonType === 'link',
104
126
  hasIconBefore: hasIconBefore,
105
- hasIconAfter: hasIconAfter
127
+ hasIconAfter: hasIconAfter,
128
+ isSplit: isSplitButton,
129
+ isNavigationSplit: isNavigationSplitButton
106
130
  });
107
- }, [appearance, buttonType, spacing, isDisabled, isSelected, isIconButton, shouldFitContainer, overlay, hasIconBefore, hasIconAfter]);
131
+ }, [appearance, buttonType, spacing, isDisabled, isSelected, isHighlighted, isActiveOverSelected, isIconButton, shouldFitContainer, overlay, hasIconBefore, hasIconAfter, isSplitButton, isNavigationSplitButton]);
108
132
  var isEffectivelyDisabled = isDisabled || Boolean(overlay);
109
133
  return _objectSpread({
110
134
  ref: setRef,