@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.
- package/CHANGELOG.md +72 -60
- package/dist/cjs/containers/button-group.js +1 -0
- package/dist/cjs/entry-points/new.js +8 -1
- package/dist/cjs/entry-points/unsafe.js +40 -1
- package/dist/cjs/new-button/containers/split-button/index.js +50 -0
- package/dist/cjs/new-button/containers/split-button/split-button-context.js +37 -0
- package/dist/cjs/new-button/containers/split-button/split-button.js +137 -0
- package/dist/cjs/new-button/containers/split-button/types.js +5 -0
- package/dist/cjs/new-button/containers/split-button/utils.js +23 -0
- package/dist/cjs/new-button/variants/default/button.js +1 -2
- package/dist/cjs/new-button/variants/default/link.js +1 -2
- package/dist/cjs/new-button/variants/default/use-default-button.js +11 -16
- package/dist/cjs/new-button/variants/icon/button.js +1 -2
- package/dist/cjs/new-button/variants/icon/link.js +1 -2
- package/dist/cjs/new-button/variants/icon/use-icon-button.js +6 -10
- package/dist/cjs/new-button/variants/shared/colors.js +1 -2
- package/dist/cjs/new-button/variants/shared/content.js +51 -0
- package/dist/cjs/new-button/variants/shared/use-button-base.js +32 -9
- package/dist/cjs/new-button/variants/shared/xcss.js +53 -53
- package/dist/cjs/old-button/button.js +1 -2
- package/dist/cjs/old-button/custom-theme-button/custom-theme-button.js +1 -2
- package/dist/cjs/old-button/custom-theme-button/theme.js +1 -2
- package/dist/cjs/old-button/loading-button.js +1 -2
- package/dist/cjs/old-button/shared/button-base.js +9 -9
- package/dist/cjs/old-button/shared/colors.js +1 -2
- package/dist/cjs/old-button/shared/css.js +2 -3
- package/dist/cjs/old-button/shared/get-if-visually-hidden-children.js +2 -3
- package/dist/cjs/utils/appearances.js +1 -2
- package/dist/cjs/utils/spacing.js +1 -2
- package/dist/cjs/utils/variants.js +2 -4
- package/dist/es2019/containers/button-group.js +1 -0
- package/dist/es2019/entry-points/new.js +2 -1
- package/dist/es2019/entry-points/unsafe.js +4 -1
- package/dist/es2019/new-button/containers/split-button/index.js +3 -0
- package/dist/es2019/new-button/containers/split-button/split-button-context.js +31 -0
- package/dist/es2019/new-button/containers/split-button/split-button.js +129 -0
- package/dist/es2019/new-button/containers/split-button/types.js +1 -0
- package/dist/es2019/new-button/containers/split-button/utils.js +12 -0
- package/dist/es2019/new-button/variants/default/use-default-button.js +10 -14
- package/dist/es2019/new-button/variants/icon/use-icon-button.js +5 -8
- package/dist/es2019/new-button/variants/shared/content.js +43 -0
- package/dist/es2019/new-button/variants/shared/use-button-base.js +32 -8
- package/dist/es2019/new-button/variants/shared/xcss.js +55 -48
- package/dist/es2019/old-button/shared/button-base.js +7 -6
- package/dist/esm/containers/button-group.js +1 -0
- package/dist/esm/entry-points/new.js +2 -1
- package/dist/esm/entry-points/unsafe.js +4 -1
- package/dist/esm/new-button/containers/split-button/index.js +3 -0
- package/dist/esm/new-button/containers/split-button/split-button-context.js +31 -0
- package/dist/esm/new-button/containers/split-button/split-button.js +131 -0
- package/dist/esm/new-button/containers/split-button/types.js +1 -0
- package/dist/esm/new-button/containers/split-button/utils.js +16 -0
- package/dist/esm/new-button/variants/default/use-default-button.js +10 -14
- package/dist/esm/new-button/variants/icon/use-icon-button.js +5 -8
- package/dist/esm/new-button/variants/shared/content.js +44 -0
- package/dist/esm/new-button/variants/shared/use-button-base.js +32 -8
- package/dist/esm/new-button/variants/shared/xcss.js +52 -47
- package/dist/esm/old-button/shared/button-base.js +7 -6
- package/dist/types/entry-points/new.d.ts +1 -0
- package/dist/types/entry-points/unsafe.d.ts +3 -0
- package/dist/types/new-button/containers/split-button/index.d.ts +3 -0
- package/dist/types/new-button/containers/split-button/split-button-context.d.ts +47 -0
- package/dist/types/new-button/containers/split-button/split-button.d.ts +47 -0
- package/dist/types/new-button/containers/split-button/types.d.ts +4 -0
- package/dist/types/new-button/containers/split-button/utils.d.ts +5 -0
- package/dist/types/new-button/variants/shared/content.d.ts +13 -0
- package/dist/types/new-button/variants/shared/use-button-base.d.ts +1 -1
- package/dist/types/new-button/variants/shared/xcss.d.ts +14 -7
- package/dist/types/old-button/types.d.ts +2 -2
- package/dist/types-ts4.5/entry-points/new.d.ts +1 -0
- package/dist/types-ts4.5/entry-points/unsafe.d.ts +3 -0
- package/dist/types-ts4.5/new-button/containers/split-button/index.d.ts +3 -0
- package/dist/types-ts4.5/new-button/containers/split-button/split-button-context.d.ts +47 -0
- package/dist/types-ts4.5/new-button/containers/split-button/split-button.d.ts +47 -0
- package/dist/types-ts4.5/new-button/containers/split-button/types.d.ts +4 -0
- package/dist/types-ts4.5/new-button/containers/split-button/utils.d.ts +5 -0
- package/dist/types-ts4.5/new-button/variants/shared/content.d.ts +13 -0
- package/dist/types-ts4.5/new-button/variants/shared/use-button-base.d.ts +1 -1
- package/dist/types-ts4.5/new-button/variants/shared/xcss.d.ts +14 -7
- package/dist/types-ts4.5/old-button/types.d.ts +2 -2
- package/package.json +6 -6
|
@@ -5,7 +5,7 @@ import { xcss } from '@atlaskit/primitives';
|
|
|
5
5
|
import { fontSize as getFontSize } from '@atlaskit/theme/constants';
|
|
6
6
|
import colors from './colors';
|
|
7
7
|
var fontSize = getFontSize();
|
|
8
|
-
var heights = {
|
|
8
|
+
export var heights = {
|
|
9
9
|
default: "".concat(32 / fontSize, "em"),
|
|
10
10
|
compact: "".concat(24 / fontSize, "em"),
|
|
11
11
|
none: 'auto'
|
|
@@ -34,6 +34,19 @@ var verticalAlign = {
|
|
|
34
34
|
compact: 'middle',
|
|
35
35
|
none: 'baseline'
|
|
36
36
|
};
|
|
37
|
+
var splitBorderStyles = {
|
|
38
|
+
':first-of-type': {
|
|
39
|
+
borderTopRightRadius: 0,
|
|
40
|
+
borderBottomRightRadius: 0
|
|
41
|
+
},
|
|
42
|
+
':last-of-type': {
|
|
43
|
+
borderTopLeftRadius: 0,
|
|
44
|
+
borderBottomLeftRadius: 0
|
|
45
|
+
},
|
|
46
|
+
':focus-visible': {
|
|
47
|
+
zIndex: 1
|
|
48
|
+
}
|
|
49
|
+
};
|
|
37
50
|
function getColor(_ref) {
|
|
38
51
|
var group = _ref.group,
|
|
39
52
|
key = _ref.key;
|
|
@@ -45,11 +58,13 @@ function getColors(_ref2) {
|
|
|
45
58
|
interactionState = _ref2$interactionStat === void 0 ? 'default' : _ref2$interactionStat,
|
|
46
59
|
isDisabled = _ref2.isDisabled,
|
|
47
60
|
isSelected = _ref2.isSelected,
|
|
61
|
+
isHighlighted = _ref2.isHighlighted,
|
|
62
|
+
isActiveOverSelected = _ref2.isActiveOverSelected,
|
|
48
63
|
hasOverlay = _ref2.hasOverlay;
|
|
49
64
|
var key = interactionState;
|
|
50
65
|
// Overlay does not change color on interaction, revert to 'default' or resting state
|
|
51
66
|
key = hasOverlay ? 'default' : key;
|
|
52
|
-
key = isSelected ? 'selected' : key;
|
|
67
|
+
key = isSelected || isHighlighted ? isActiveOverSelected ? 'active' : 'selected' : key;
|
|
53
68
|
// Disabled colors overrule everything else
|
|
54
69
|
key = isDisabled ? 'disabled' : key;
|
|
55
70
|
return {
|
|
@@ -68,27 +83,51 @@ export function getXCSS(_ref3) {
|
|
|
68
83
|
spacing = _ref3.spacing,
|
|
69
84
|
isDisabled = _ref3.isDisabled,
|
|
70
85
|
isSelected = _ref3.isSelected,
|
|
86
|
+
isHighlighted = _ref3.isHighlighted,
|
|
87
|
+
isActiveOverSelected = _ref3.isActiveOverSelected,
|
|
71
88
|
isIconButton = _ref3.isIconButton,
|
|
72
89
|
shouldFitContainer = _ref3.shouldFitContainer,
|
|
73
90
|
isLink = _ref3.isLink,
|
|
91
|
+
isSplit = _ref3.isSplit,
|
|
92
|
+
isNavigationSplit = _ref3.isNavigationSplit,
|
|
74
93
|
hasOverlay = _ref3.hasOverlay,
|
|
75
94
|
hasIconBefore = _ref3.hasIconBefore,
|
|
76
95
|
hasIconAfter = _ref3.hasIconAfter;
|
|
77
96
|
var baseColors = getColors({
|
|
78
97
|
appearance: appearance,
|
|
79
98
|
isSelected: isSelected,
|
|
99
|
+
isHighlighted: isHighlighted,
|
|
100
|
+
isActiveOverSelected: isActiveOverSelected,
|
|
80
101
|
isDisabled: isDisabled
|
|
81
102
|
});
|
|
82
103
|
var combinedBaseColorStyles = isLink ? _objectSpread(_objectSpread({}, baseColors), {}, {
|
|
83
104
|
textDecoration: 'none',
|
|
84
105
|
// Disabling visited styles (by re-declaring the base colors)
|
|
85
106
|
':visited': baseColors
|
|
107
|
+
}) : isNavigationSplit && !isSelected ? _objectSpread(_objectSpread({}, baseColors), {}, {
|
|
108
|
+
backgroundColor: 'color.background.neutral.subtle'
|
|
86
109
|
}) : baseColors;
|
|
87
110
|
var height = heights[spacing];
|
|
88
111
|
var width = shouldFitContainer ? '100%' : 'auto';
|
|
89
|
-
width = isIconButton ? height : width;
|
|
90
|
-
var
|
|
91
|
-
var
|
|
112
|
+
width = isIconButton ? isNavigationSplit ? '24px' : height : width;
|
|
113
|
+
var defaultPaddingInlineStart = paddingInline[spacing][hasIconBefore ? 'withIcon' : 'default'];
|
|
114
|
+
var defaultPaddingInlineEnd = paddingInline[spacing][hasIconAfter ? 'withIcon' : 'default'];
|
|
115
|
+
var splitButtonStyles = isSplit ? splitBorderStyles : {};
|
|
116
|
+
var getNavigationSplitButtonPaddings = function getNavigationSplitButtonPaddings() {
|
|
117
|
+
if (isNavigationSplit) {
|
|
118
|
+
return {
|
|
119
|
+
paddingInlineStart: 'space.075',
|
|
120
|
+
paddingInlineEnd: 'space.075'
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
paddingInlineStart: isIconButton ? 'space.0' : defaultPaddingInlineStart,
|
|
125
|
+
paddingInlineEnd: isIconButton ? 'space.0' : defaultPaddingInlineEnd
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
var _getNavigationSplitBu = getNavigationSplitButtonPaddings(),
|
|
129
|
+
paddingInlineStart = _getNavigationSplitBu.paddingInlineStart,
|
|
130
|
+
paddingInlineEnd = _getNavigationSplitBu.paddingInlineEnd;
|
|
92
131
|
return xcss(_objectSpread(_objectSpread(_objectSpread({
|
|
93
132
|
alignItems: 'center',
|
|
94
133
|
borderWidth: 'border.width.0',
|
|
@@ -107,8 +146,8 @@ export function getXCSS(_ref3) {
|
|
|
107
146
|
whiteSpace: 'nowrap',
|
|
108
147
|
height: height,
|
|
109
148
|
paddingBlock: 'space.0',
|
|
110
|
-
paddingInlineStart:
|
|
111
|
-
paddingInlineEnd:
|
|
149
|
+
paddingInlineStart: paddingInlineStart,
|
|
150
|
+
paddingInlineEnd: paddingInlineEnd,
|
|
112
151
|
columnGap: gap[spacing],
|
|
113
152
|
verticalAlign: verticalAlign[spacing],
|
|
114
153
|
width: width,
|
|
@@ -119,7 +158,8 @@ export function getXCSS(_ref3) {
|
|
|
119
158
|
} : {}), {}, {
|
|
120
159
|
':hover': _objectSpread(_objectSpread({}, getColors({
|
|
121
160
|
appearance: appearance,
|
|
122
|
-
isSelected: isSelected,
|
|
161
|
+
isSelected: isNavigationSplit && !isSelected ? false : isSelected,
|
|
162
|
+
isActiveOverSelected: isActiveOverSelected,
|
|
123
163
|
isDisabled: isDisabled,
|
|
124
164
|
interactionState: 'hover',
|
|
125
165
|
hasOverlay: hasOverlay
|
|
@@ -130,7 +170,8 @@ export function getXCSS(_ref3) {
|
|
|
130
170
|
}),
|
|
131
171
|
':active': _objectSpread(_objectSpread({}, getColors({
|
|
132
172
|
appearance: appearance,
|
|
133
|
-
isSelected: isSelected,
|
|
173
|
+
isSelected: isNavigationSplit && !isSelected ? false : isSelected,
|
|
174
|
+
isActiveOverSelected: isActiveOverSelected,
|
|
134
175
|
isDisabled: isDisabled,
|
|
135
176
|
interactionState: 'active',
|
|
136
177
|
hasOverlay: hasOverlay
|
|
@@ -138,41 +179,5 @@ export function getXCSS(_ref3) {
|
|
|
138
179
|
// background, box-shadow
|
|
139
180
|
transitionDuration: '0s, 0s'
|
|
140
181
|
})
|
|
141
|
-
}));
|
|
142
|
-
}
|
|
143
|
-
export var iconStyles = xcss({
|
|
144
|
-
display: 'flex',
|
|
145
|
-
// icon size cannot grow and shrink
|
|
146
|
-
flexGrow: 0,
|
|
147
|
-
flexShrink: 0,
|
|
148
|
-
alignSelf: 'center',
|
|
149
|
-
fontSize: 0,
|
|
150
|
-
lineHeight: 0,
|
|
151
|
-
userSelect: 'none'
|
|
152
|
-
});
|
|
153
|
-
export var contentStyles = xcss({
|
|
154
|
-
// content can grow and shrink
|
|
155
|
-
flexGrow: 1,
|
|
156
|
-
flexShrink: 1,
|
|
157
|
-
// ellipsis for overflow text
|
|
158
|
-
overflow: 'hidden',
|
|
159
|
-
textOverflow: 'ellipsis',
|
|
160
|
-
whiteSpace: 'nowrap'
|
|
161
|
-
});
|
|
162
|
-
export function getFadingStyles(_ref4) {
|
|
163
|
-
var hasOverlay = _ref4.hasOverlay;
|
|
164
|
-
return xcss({
|
|
165
|
-
opacity: hasOverlay ? 0 : 1,
|
|
166
|
-
transition: 'opacity 0.3s'
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
export var overlayStyles = xcss({
|
|
170
|
-
position: 'absolute',
|
|
171
|
-
left: 'space.0',
|
|
172
|
-
top: 'space.0',
|
|
173
|
-
right: 'space.0',
|
|
174
|
-
bottom: 'space.0',
|
|
175
|
-
display: 'flex',
|
|
176
|
-
alignItems: 'center',
|
|
177
|
-
justifyContent: 'center'
|
|
178
|
-
});
|
|
182
|
+
}, splitButtonStyles));
|
|
183
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
3
|
var _excluded = ["analyticsContext", "appearance", "autoFocus", "buttonCss", "children", "className", "href", "component", "iconAfter", "iconBefore", "interactionName", "isDisabled", "isSelected", "onBlur", "onClick", "onFocus", "onMouseDown", "overlay", "shouldFitContainer", "spacing", "tabIndex", "type", "testId"];
|
|
4
|
+
/* eslint-disable @atlaskit/design-system/consistent-css-prop-usage */
|
|
4
5
|
/** @jsx jsx */
|
|
5
6
|
import React, { useCallback, useContext, useEffect, useRef } from 'react';
|
|
6
7
|
import { css, jsx } from '@emotion/react';
|
|
@@ -108,7 +109,7 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
|
|
|
108
109
|
action: 'clicked',
|
|
109
110
|
componentName: 'button',
|
|
110
111
|
packageName: "@atlaskit/button",
|
|
111
|
-
packageVersion: "16.
|
|
112
|
+
packageVersion: "16.11.0",
|
|
112
113
|
analyticsData: analyticsContext
|
|
113
114
|
});
|
|
114
115
|
|
|
@@ -128,7 +129,7 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
|
|
|
128
129
|
|
|
129
130
|
// we are 'disabling' input with a button when there is an overlay
|
|
130
131
|
var hasOverlay = Boolean(overlay);
|
|
131
|
-
var
|
|
132
|
+
var fadeStyles = css(getFadingCss({
|
|
132
133
|
hasOverlay: hasOverlay
|
|
133
134
|
}));
|
|
134
135
|
var isInteractive = !isDisabled && !hasOverlay;
|
|
@@ -169,17 +170,17 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
|
|
|
169
170
|
}, blockEvents({
|
|
170
171
|
isInteractive: isInteractive
|
|
171
172
|
})), iconBefore ? jsx("span", {
|
|
172
|
-
css: [
|
|
173
|
+
css: [fadeStyles, getIconStyle({
|
|
173
174
|
spacing: spacing
|
|
174
175
|
}), getSpacingFix(children, iconBeforeSpacingFixStyle)]
|
|
175
176
|
}, iconBefore) : null, !getBooleanFF('platform.design-system-team.icon-button-spacing-fix_o1zc5') && children ? jsx("span", {
|
|
176
|
-
css: [
|
|
177
|
+
css: [fadeStyles, getContentStyle({
|
|
177
178
|
spacing: spacing
|
|
178
179
|
})]
|
|
179
|
-
}, children) : null, getBooleanFF('platform.design-system-team.icon-button-spacing-fix_o1zc5') && getChildren(children, [
|
|
180
|
+
}, children) : null, getBooleanFF('platform.design-system-team.icon-button-spacing-fix_o1zc5') && getChildren(children, [fadeStyles, getContentStyle({
|
|
180
181
|
spacing: spacing
|
|
181
182
|
})]), iconAfter ? jsx("span", {
|
|
182
|
-
css: [
|
|
183
|
+
css: [fadeStyles, getIconStyle({
|
|
183
184
|
spacing: spacing
|
|
184
185
|
}), getSpacingFix(children, iconAfterSpacingFixStyle)]
|
|
185
186
|
}, iconAfter) : null, overlay ? jsx("span", {
|
|
@@ -2,4 +2,5 @@ export { default, type ButtonProps, } from '../new-button/variants/default/butto
|
|
|
2
2
|
export { default as LinkButton, type LinkButtonProps, } from '../new-button/variants/default/link';
|
|
3
3
|
export { default as IconButton, type IconButtonProps, } from '../new-button/variants/icon/button';
|
|
4
4
|
export { default as LinkIconButton, type LinkIconButtonProps, } from '../new-button/variants/icon/link';
|
|
5
|
+
export { SplitButton } from '../new-button/containers/split-button';
|
|
5
6
|
export type { Appearance, Spacing } from '../new-button/variants/types';
|
|
@@ -1 +1,4 @@
|
|
|
1
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,47 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { SplitButtonAppearance, SplitButtonSpacing } from './types';
|
|
3
|
+
type NavigationSplitButtonContextProps = {
|
|
4
|
+
appearance: 'navigation';
|
|
5
|
+
isHighlighted: boolean;
|
|
6
|
+
};
|
|
7
|
+
type MainSplitButtonContextProps = {
|
|
8
|
+
appearance: SplitButtonAppearance;
|
|
9
|
+
spacing: SplitButtonSpacing;
|
|
10
|
+
isDisabled: boolean;
|
|
11
|
+
};
|
|
12
|
+
type SplitButtonContextProps = NavigationSplitButtonContextProps | MainSplitButtonContextProps;
|
|
13
|
+
/**
|
|
14
|
+
* TODO: Add jsdoc
|
|
15
|
+
*/
|
|
16
|
+
export declare const SplitButtonContext: import("react").Context<SplitButtonContextProps | undefined>;
|
|
17
|
+
type UseSplitButtonContext = {
|
|
18
|
+
appearance: SplitButtonAppearance | 'subtle';
|
|
19
|
+
spacing: SplitButtonSpacing;
|
|
20
|
+
isDisabled: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* isSelected state has limited relevance (e.g. dropdown-menu trigger button).
|
|
23
|
+
* There is no isSelected state for color variants (e.g. primary, danger, warning).
|
|
24
|
+
* Hens we provide ability to override the isSelected state with isActiveOverSelected to display `active` state instead of `selected` state.
|
|
25
|
+
*/
|
|
26
|
+
isActiveOverSelected: boolean;
|
|
27
|
+
isNavigationSplitButton: boolean;
|
|
28
|
+
isHighlighted: boolean;
|
|
29
|
+
};
|
|
30
|
+
type NavigationSplitButtonContext = UseSplitButtonContext & {
|
|
31
|
+
appearance: 'subtle';
|
|
32
|
+
spacing: 'default';
|
|
33
|
+
isDisabled: false;
|
|
34
|
+
isActiveOverSelected: false;
|
|
35
|
+
isNavigationSplitButton: true;
|
|
36
|
+
isHighlighted: boolean;
|
|
37
|
+
};
|
|
38
|
+
type MainSplitButtonContext = UseSplitButtonContext & {
|
|
39
|
+
appearance: SplitButtonAppearance;
|
|
40
|
+
spacing: SplitButtonSpacing;
|
|
41
|
+
isDisabled: boolean;
|
|
42
|
+
isActiveOverSelected: true;
|
|
43
|
+
isNavigationSplitButton: false;
|
|
44
|
+
isHighlighted: false;
|
|
45
|
+
};
|
|
46
|
+
export declare const useSplitButtonContext: () => NavigationSplitButtonContext | MainSplitButtonContext | undefined;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
import type { SplitButtonAppearance, SplitButtonContextAppearance, SplitButtonSpacing } from './types';
|
|
5
|
+
type DividerProps = {
|
|
6
|
+
appearance: SplitButtonContextAppearance;
|
|
7
|
+
spacing: SplitButtonSpacing;
|
|
8
|
+
isDisabled?: boolean;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* TODO: Add JSDoc
|
|
12
|
+
*/
|
|
13
|
+
export declare const Divider: ({ appearance, spacing, isDisabled, }: DividerProps) => jsx.JSX.Element;
|
|
14
|
+
/**
|
|
15
|
+
* TODO: Add JSdoc
|
|
16
|
+
*/
|
|
17
|
+
export declare const SplitButtonContainer: ({ children }: {
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
}) => jsx.JSX.Element;
|
|
20
|
+
type SplitButtonProps = {
|
|
21
|
+
/**
|
|
22
|
+
* Only two children are allowed.
|
|
23
|
+
* First child is the primary action, second child is the secondary action.
|
|
24
|
+
* The assumption is that for both children trees there is a button reading the context.
|
|
25
|
+
*/
|
|
26
|
+
children: ReactNode;
|
|
27
|
+
appearance?: SplitButtonAppearance;
|
|
28
|
+
spacing?: SplitButtonSpacing;
|
|
29
|
+
isDisabled?: boolean;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* TODO: Add description when adding docs
|
|
33
|
+
*/
|
|
34
|
+
export declare const SplitButton: ({ children, appearance, spacing, isDisabled, }: SplitButtonProps) => jsx.JSX.Element;
|
|
35
|
+
type SplitButtonWithSlotsProps = {
|
|
36
|
+
primaryAction: ReactNode;
|
|
37
|
+
secondaryAction: ReactNode;
|
|
38
|
+
appearance?: SplitButtonAppearance;
|
|
39
|
+
spacing?: SplitButtonSpacing;
|
|
40
|
+
isDisabled?: boolean;
|
|
41
|
+
isSelected?: boolean;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* TODO: Decide on API
|
|
45
|
+
*/
|
|
46
|
+
export declare const SplitButtonWithSlots: ({ primaryAction, secondaryAction, appearance, spacing, isDisabled, }: SplitButtonWithSlotsProps) => jsx.JSX.Element;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Appearance, Spacing } from '../../variants/types';
|
|
2
|
+
export type SplitButtonAppearance = Extract<Appearance, 'default' | 'primary' | 'danger' | 'warning'>;
|
|
3
|
+
export type SplitButtonContextAppearance = SplitButtonAppearance | 'navigation';
|
|
4
|
+
export type SplitButtonSpacing = Extract<Spacing, 'default' | 'compact'>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export declare const getActions: (children: ReactNode) => {
|
|
3
|
+
PrimaryAction: import("react").ReactChild | import("react").ReactFragment | import("react").ReactPortal;
|
|
4
|
+
SecondaryAction: import("react").ReactChild | import("react").ReactFragment | import("react").ReactPortal;
|
|
5
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type ContentProps = {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
type?: 'text' | 'icon';
|
|
5
|
+
hasOverlay: boolean;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* __Content__
|
|
9
|
+
*
|
|
10
|
+
* Used for slots within a Button, including icons and text content.
|
|
11
|
+
*/
|
|
12
|
+
declare const Content: ({ children, type, hasOverlay }: ContentProps) => JSX.Element;
|
|
13
|
+
export default Content;
|
|
@@ -33,5 +33,5 @@ export type UseButtonBaseReturn<TagName extends HTMLElement> = {
|
|
|
33
33
|
*
|
|
34
34
|
* @private
|
|
35
35
|
*/
|
|
36
|
-
declare const useButtonBase: <TagName extends HTMLElement>({ analyticsContext, appearance, autoFocus, buttonType, interactionName, isDisabled, isSelected, isIconButton, hasIconBefore, hasIconAfter, children, onClick: providedOnClick, onMouseDownCapture, onMouseUpCapture, onKeyDownCapture, onKeyUpCapture, onTouchStartCapture, onTouchEndCapture, onPointerDownCapture, onPointerUpCapture, onClickCapture, overlay, ref, shouldFitContainer, spacing, }: UseButtonBaseArgs<TagName>) => UseButtonBaseReturn<TagName>;
|
|
36
|
+
declare const useButtonBase: <TagName extends HTMLElement>({ analyticsContext, appearance: propAppearance, autoFocus, buttonType, interactionName, isDisabled: propIsDisabled, isSelected, isIconButton, hasIconBefore, hasIconAfter, children, onClick: providedOnClick, onMouseDownCapture, onMouseUpCapture, onKeyDownCapture, onKeyUpCapture, onTouchStartCapture, onTouchEndCapture, onPointerDownCapture, onPointerUpCapture, onClickCapture, overlay, ref, shouldFitContainer, spacing: propSpacing, }: UseButtonBaseArgs<TagName>) => UseButtonBaseReturn<TagName>;
|
|
37
37
|
export default useButtonBase;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { xcss } from '@atlaskit/primitives';
|
|
2
2
|
import { type Appearance, type Spacing } from '../types';
|
|
3
|
+
export declare const heights: {
|
|
4
|
+
[key in Spacing]: string;
|
|
5
|
+
};
|
|
3
6
|
export type GetXCSSArgs = {
|
|
4
7
|
appearance: Appearance;
|
|
5
8
|
spacing: Spacing;
|
|
6
9
|
isDisabled: boolean;
|
|
7
10
|
isSelected: boolean;
|
|
11
|
+
isHighlighted: boolean;
|
|
12
|
+
isActiveOverSelected: boolean;
|
|
8
13
|
shouldFitContainer: boolean;
|
|
9
14
|
hasOverlay: boolean;
|
|
10
15
|
isIconButton: boolean;
|
|
@@ -14,11 +19,13 @@ export type GetXCSSArgs = {
|
|
|
14
19
|
* If the button is a LinkButton
|
|
15
20
|
*/
|
|
16
21
|
isLink: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* If the button is a SplitButton
|
|
24
|
+
*/
|
|
25
|
+
isSplit: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* If the button is a PrimarySplitButton used in atlassian-navigation
|
|
28
|
+
*/
|
|
29
|
+
isNavigationSplit: boolean;
|
|
17
30
|
};
|
|
18
|
-
export declare function getXCSS({ appearance, spacing, isDisabled, isSelected, isIconButton, shouldFitContainer, isLink, hasOverlay, hasIconBefore, hasIconAfter, }: GetXCSSArgs): ReturnType<typeof xcss>;
|
|
19
|
-
export declare const iconStyles: ReturnType<typeof xcss>;
|
|
20
|
-
export declare const contentStyles: ReturnType<typeof xcss>;
|
|
21
|
-
export declare function getFadingStyles({ hasOverlay, }: {
|
|
22
|
-
hasOverlay: boolean;
|
|
23
|
-
}): ReturnType<typeof xcss>;
|
|
24
|
-
export declare const overlayStyles: ReturnType<typeof xcss>;
|
|
31
|
+
export declare function getXCSS({ appearance, spacing, isDisabled, isSelected, isHighlighted, isActiveOverSelected, isIconButton, shouldFitContainer, isLink, isSplit, isNavigationSplit, hasOverlay, hasIconBefore, hasIconAfter, }: GetXCSSArgs): ReturnType<typeof xcss>;
|
|
@@ -78,8 +78,8 @@ export type BaseOwnProps = {
|
|
|
78
78
|
testId?: string;
|
|
79
79
|
component?: React.ComponentType<React.AllHTMLAttributes<HTMLElement>> | React.ElementType;
|
|
80
80
|
/**
|
|
81
|
-
* An optional name used to identify this component to press listeners.
|
|
82
|
-
*
|
|
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)
|
|
83
83
|
*/
|
|
84
84
|
interactionName?: string;
|
|
85
85
|
/**
|
|
@@ -2,4 +2,5 @@ export { default, type ButtonProps, } from '../new-button/variants/default/butto
|
|
|
2
2
|
export { default as LinkButton, type LinkButtonProps, } from '../new-button/variants/default/link';
|
|
3
3
|
export { default as IconButton, type IconButtonProps, } from '../new-button/variants/icon/button';
|
|
4
4
|
export { default as LinkIconButton, type LinkIconButtonProps, } from '../new-button/variants/icon/link';
|
|
5
|
+
export { SplitButton } from '../new-button/containers/split-button';
|
|
5
6
|
export type { Appearance, Spacing } from '../new-button/variants/types';
|
|
@@ -1 +1,4 @@
|
|
|
1
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,47 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { SplitButtonAppearance, SplitButtonSpacing } from './types';
|
|
3
|
+
type NavigationSplitButtonContextProps = {
|
|
4
|
+
appearance: 'navigation';
|
|
5
|
+
isHighlighted: boolean;
|
|
6
|
+
};
|
|
7
|
+
type MainSplitButtonContextProps = {
|
|
8
|
+
appearance: SplitButtonAppearance;
|
|
9
|
+
spacing: SplitButtonSpacing;
|
|
10
|
+
isDisabled: boolean;
|
|
11
|
+
};
|
|
12
|
+
type SplitButtonContextProps = NavigationSplitButtonContextProps | MainSplitButtonContextProps;
|
|
13
|
+
/**
|
|
14
|
+
* TODO: Add jsdoc
|
|
15
|
+
*/
|
|
16
|
+
export declare const SplitButtonContext: import("react").Context<SplitButtonContextProps | undefined>;
|
|
17
|
+
type UseSplitButtonContext = {
|
|
18
|
+
appearance: SplitButtonAppearance | 'subtle';
|
|
19
|
+
spacing: SplitButtonSpacing;
|
|
20
|
+
isDisabled: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* isSelected state has limited relevance (e.g. dropdown-menu trigger button).
|
|
23
|
+
* There is no isSelected state for color variants (e.g. primary, danger, warning).
|
|
24
|
+
* Hens we provide ability to override the isSelected state with isActiveOverSelected to display `active` state instead of `selected` state.
|
|
25
|
+
*/
|
|
26
|
+
isActiveOverSelected: boolean;
|
|
27
|
+
isNavigationSplitButton: boolean;
|
|
28
|
+
isHighlighted: boolean;
|
|
29
|
+
};
|
|
30
|
+
type NavigationSplitButtonContext = UseSplitButtonContext & {
|
|
31
|
+
appearance: 'subtle';
|
|
32
|
+
spacing: 'default';
|
|
33
|
+
isDisabled: false;
|
|
34
|
+
isActiveOverSelected: false;
|
|
35
|
+
isNavigationSplitButton: true;
|
|
36
|
+
isHighlighted: boolean;
|
|
37
|
+
};
|
|
38
|
+
type MainSplitButtonContext = UseSplitButtonContext & {
|
|
39
|
+
appearance: SplitButtonAppearance;
|
|
40
|
+
spacing: SplitButtonSpacing;
|
|
41
|
+
isDisabled: boolean;
|
|
42
|
+
isActiveOverSelected: true;
|
|
43
|
+
isNavigationSplitButton: false;
|
|
44
|
+
isHighlighted: false;
|
|
45
|
+
};
|
|
46
|
+
export declare const useSplitButtonContext: () => NavigationSplitButtonContext | MainSplitButtonContext | undefined;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
import type { SplitButtonAppearance, SplitButtonContextAppearance, SplitButtonSpacing } from './types';
|
|
5
|
+
type DividerProps = {
|
|
6
|
+
appearance: SplitButtonContextAppearance;
|
|
7
|
+
spacing: SplitButtonSpacing;
|
|
8
|
+
isDisabled?: boolean;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* TODO: Add JSDoc
|
|
12
|
+
*/
|
|
13
|
+
export declare const Divider: ({ appearance, spacing, isDisabled, }: DividerProps) => jsx.JSX.Element;
|
|
14
|
+
/**
|
|
15
|
+
* TODO: Add JSdoc
|
|
16
|
+
*/
|
|
17
|
+
export declare const SplitButtonContainer: ({ children }: {
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
}) => jsx.JSX.Element;
|
|
20
|
+
type SplitButtonProps = {
|
|
21
|
+
/**
|
|
22
|
+
* Only two children are allowed.
|
|
23
|
+
* First child is the primary action, second child is the secondary action.
|
|
24
|
+
* The assumption is that for both children trees there is a button reading the context.
|
|
25
|
+
*/
|
|
26
|
+
children: ReactNode;
|
|
27
|
+
appearance?: SplitButtonAppearance;
|
|
28
|
+
spacing?: SplitButtonSpacing;
|
|
29
|
+
isDisabled?: boolean;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* TODO: Add description when adding docs
|
|
33
|
+
*/
|
|
34
|
+
export declare const SplitButton: ({ children, appearance, spacing, isDisabled, }: SplitButtonProps) => jsx.JSX.Element;
|
|
35
|
+
type SplitButtonWithSlotsProps = {
|
|
36
|
+
primaryAction: ReactNode;
|
|
37
|
+
secondaryAction: ReactNode;
|
|
38
|
+
appearance?: SplitButtonAppearance;
|
|
39
|
+
spacing?: SplitButtonSpacing;
|
|
40
|
+
isDisabled?: boolean;
|
|
41
|
+
isSelected?: boolean;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* TODO: Decide on API
|
|
45
|
+
*/
|
|
46
|
+
export declare const SplitButtonWithSlots: ({ primaryAction, secondaryAction, appearance, spacing, isDisabled, }: SplitButtonWithSlotsProps) => jsx.JSX.Element;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Appearance, Spacing } from '../../variants/types';
|
|
2
|
+
export type SplitButtonAppearance = Extract<Appearance, 'default' | 'primary' | 'danger' | 'warning'>;
|
|
3
|
+
export type SplitButtonContextAppearance = SplitButtonAppearance | 'navigation';
|
|
4
|
+
export type SplitButtonSpacing = Extract<Spacing, 'default' | 'compact'>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export declare const getActions: (children: ReactNode) => {
|
|
3
|
+
PrimaryAction: import("react").ReactChild | import("react").ReactFragment | import("react").ReactPortal;
|
|
4
|
+
SecondaryAction: import("react").ReactChild | import("react").ReactFragment | import("react").ReactPortal;
|
|
5
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type ContentProps = {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
type?: 'text' | 'icon';
|
|
5
|
+
hasOverlay: boolean;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* __Content__
|
|
9
|
+
*
|
|
10
|
+
* Used for slots within a Button, including icons and text content.
|
|
11
|
+
*/
|
|
12
|
+
declare const Content: ({ children, type, hasOverlay }: ContentProps) => JSX.Element;
|
|
13
|
+
export default Content;
|
|
@@ -33,5 +33,5 @@ export type UseButtonBaseReturn<TagName extends HTMLElement> = {
|
|
|
33
33
|
*
|
|
34
34
|
* @private
|
|
35
35
|
*/
|
|
36
|
-
declare const useButtonBase: <TagName extends HTMLElement>({ analyticsContext, appearance, autoFocus, buttonType, interactionName, isDisabled, isSelected, isIconButton, hasIconBefore, hasIconAfter, children, onClick: providedOnClick, onMouseDownCapture, onMouseUpCapture, onKeyDownCapture, onKeyUpCapture, onTouchStartCapture, onTouchEndCapture, onPointerDownCapture, onPointerUpCapture, onClickCapture, overlay, ref, shouldFitContainer, spacing, }: UseButtonBaseArgs<TagName>) => UseButtonBaseReturn<TagName>;
|
|
36
|
+
declare const useButtonBase: <TagName extends HTMLElement>({ analyticsContext, appearance: propAppearance, autoFocus, buttonType, interactionName, isDisabled: propIsDisabled, isSelected, isIconButton, hasIconBefore, hasIconAfter, children, onClick: providedOnClick, onMouseDownCapture, onMouseUpCapture, onKeyDownCapture, onKeyUpCapture, onTouchStartCapture, onTouchEndCapture, onPointerDownCapture, onPointerUpCapture, onClickCapture, overlay, ref, shouldFitContainer, spacing: propSpacing, }: UseButtonBaseArgs<TagName>) => UseButtonBaseReturn<TagName>;
|
|
37
37
|
export default useButtonBase;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { xcss } from '@atlaskit/primitives';
|
|
2
2
|
import { type Appearance, type Spacing } from '../types';
|
|
3
|
+
export declare const heights: {
|
|
4
|
+
[key in Spacing]: string;
|
|
5
|
+
};
|
|
3
6
|
export type GetXCSSArgs = {
|
|
4
7
|
appearance: Appearance;
|
|
5
8
|
spacing: Spacing;
|
|
6
9
|
isDisabled: boolean;
|
|
7
10
|
isSelected: boolean;
|
|
11
|
+
isHighlighted: boolean;
|
|
12
|
+
isActiveOverSelected: boolean;
|
|
8
13
|
shouldFitContainer: boolean;
|
|
9
14
|
hasOverlay: boolean;
|
|
10
15
|
isIconButton: boolean;
|
|
@@ -14,11 +19,13 @@ export type GetXCSSArgs = {
|
|
|
14
19
|
* If the button is a LinkButton
|
|
15
20
|
*/
|
|
16
21
|
isLink: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* If the button is a SplitButton
|
|
24
|
+
*/
|
|
25
|
+
isSplit: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* If the button is a PrimarySplitButton used in atlassian-navigation
|
|
28
|
+
*/
|
|
29
|
+
isNavigationSplit: boolean;
|
|
17
30
|
};
|
|
18
|
-
export declare function getXCSS({ appearance, spacing, isDisabled, isSelected, isIconButton, shouldFitContainer, isLink, hasOverlay, hasIconBefore, hasIconAfter, }: GetXCSSArgs): ReturnType<typeof xcss>;
|
|
19
|
-
export declare const iconStyles: ReturnType<typeof xcss>;
|
|
20
|
-
export declare const contentStyles: ReturnType<typeof xcss>;
|
|
21
|
-
export declare function getFadingStyles({ hasOverlay, }: {
|
|
22
|
-
hasOverlay: boolean;
|
|
23
|
-
}): ReturnType<typeof xcss>;
|
|
24
|
-
export declare const overlayStyles: ReturnType<typeof xcss>;
|
|
31
|
+
export declare function getXCSS({ appearance, spacing, isDisabled, isSelected, isHighlighted, isActiveOverSelected, isIconButton, shouldFitContainer, isLink, isSplit, isNavigationSplit, hasOverlay, hasIconBefore, hasIconAfter, }: GetXCSSArgs): ReturnType<typeof xcss>;
|
|
@@ -78,8 +78,8 @@ export type BaseOwnProps = {
|
|
|
78
78
|
testId?: string;
|
|
79
79
|
component?: React.ComponentType<React.AllHTMLAttributes<HTMLElement>> | React.ElementType;
|
|
80
80
|
/**
|
|
81
|
-
* An optional name used to identify this component to press listeners.
|
|
82
|
-
*
|
|
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)
|
|
83
83
|
*/
|
|
84
84
|
interactionName?: string;
|
|
85
85
|
/**
|