@atlaskit/button 17.7.2 → 17.9.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 +12 -0
- package/dist/cjs/entry-points/standard-button.js +0 -1
- package/dist/cjs/new-button/variants/default/button.js +3 -1
- package/dist/cjs/new-button/variants/default/use-default-button.js +10 -2
- package/dist/cjs/new-button/variants/icon/button.js +3 -1
- package/dist/cjs/new-button/variants/icon/use-icon-button.js +9 -2
- package/dist/cjs/new-button/variants/shared/colors.js +44 -36
- package/dist/cjs/new-button/variants/shared/loading-overlay.js +49 -0
- package/dist/cjs/new-button/variants/shared/xcss.js +7 -5
- package/dist/cjs/old-button/shared/button-base.js +1 -1
- package/dist/es2019/entry-points/standard-button.js +0 -5
- package/dist/es2019/new-button/variants/default/button.js +2 -0
- package/dist/es2019/new-button/variants/default/use-default-button.js +9 -2
- package/dist/es2019/new-button/variants/icon/button.js +2 -0
- package/dist/es2019/new-button/variants/icon/use-icon-button.js +9 -2
- package/dist/es2019/new-button/variants/shared/colors.js +44 -36
- package/dist/es2019/new-button/variants/shared/loading-overlay.js +44 -0
- package/dist/es2019/new-button/variants/shared/xcss.js +7 -5
- package/dist/es2019/old-button/shared/button-base.js +1 -1
- package/dist/esm/entry-points/standard-button.js +0 -5
- package/dist/esm/new-button/variants/default/button.js +3 -1
- package/dist/esm/new-button/variants/default/use-default-button.js +10 -2
- package/dist/esm/new-button/variants/icon/button.js +3 -1
- package/dist/esm/new-button/variants/icon/use-icon-button.js +9 -2
- package/dist/esm/new-button/variants/shared/colors.js +44 -36
- package/dist/esm/new-button/variants/shared/loading-overlay.js +42 -0
- package/dist/esm/new-button/variants/shared/xcss.js +7 -5
- package/dist/esm/old-button/shared/button-base.js +1 -1
- package/dist/types/entry-points/standard-button.d.ts +0 -5
- package/dist/types/new-button/variants/default/types.d.ts +4 -0
- package/dist/types/new-button/variants/default/use-default-button.d.ts +1 -1
- package/dist/types/new-button/variants/icon/types.d.ts +4 -0
- package/dist/types/new-button/variants/icon/use-icon-button.d.ts +1 -1
- package/dist/types/new-button/variants/shared/colors.d.ts +5 -3
- package/dist/types/new-button/variants/shared/loading-overlay.d.ts +8 -0
- package/dist/types-ts4.5/entry-points/standard-button.d.ts +0 -5
- package/dist/types-ts4.5/new-button/variants/default/types.d.ts +4 -0
- package/dist/types-ts4.5/new-button/variants/default/use-default-button.d.ts +1 -1
- package/dist/types-ts4.5/new-button/variants/icon/types.d.ts +4 -0
- package/dist/types-ts4.5/new-button/variants/icon/use-icon-button.d.ts +1 -1
- package/dist/types-ts4.5/new-button/variants/shared/colors.d.ts +5 -3
- package/dist/types-ts4.5/new-button/variants/shared/loading-overlay.d.ts +8 -0
- package/package.json +5 -5
|
@@ -15,18 +15,14 @@ const 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, ${colors.N20A})
|
|
19
|
-
// @ts-expect-error
|
|
20
|
-
selected: `var(--ds-background-selected, ${colors.N700})`
|
|
18
|
+
disabled: `var(--ds-background-disabled, ${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, ${colors.N20A})
|
|
28
|
-
// @ts-expect-error
|
|
29
|
-
selected: `var(--ds-background-selected, ${colors.N700})`
|
|
25
|
+
disabled: `var(--ds-background-disabled, ${colors.N20A})`
|
|
30
26
|
},
|
|
31
27
|
warning: {
|
|
32
28
|
default: 'color.background.warning.bold',
|
|
@@ -34,8 +30,14 @@ const values = {
|
|
|
34
30
|
active: 'color.background.warning.bold.pressed',
|
|
35
31
|
// @ts-expect-error
|
|
36
32
|
disabled: `var(--ds-background-disabled, ${colors.N20A})`,
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
selected: {
|
|
34
|
+
// @ts-expect-error
|
|
35
|
+
default: `var(--ds-background-selected, ${colors.Y400})`,
|
|
36
|
+
// @ts-expect-error
|
|
37
|
+
hover: `var(--ds-background-selected-hovered, ${colors.Y400})`,
|
|
38
|
+
// @ts-expect-error
|
|
39
|
+
active: `var(--ds-background-selected-pressed, ${colors.Y400})`
|
|
40
|
+
}
|
|
39
41
|
},
|
|
40
42
|
danger: {
|
|
41
43
|
default: 'color.background.danger.bold',
|
|
@@ -43,27 +45,35 @@ const values = {
|
|
|
43
45
|
active: 'color.background.danger.bold.pressed',
|
|
44
46
|
// @ts-expect-error
|
|
45
47
|
disabled: `var(--ds-background-disabled, ${colors.N20A})`,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
selected: {
|
|
49
|
+
// @ts-expect-error
|
|
50
|
+
default: `var(--ds-background-selected, ${colors.R500})`,
|
|
51
|
+
// @ts-expect-error
|
|
52
|
+
hover: `var(--ds-background-selected-hovered, ${colors.R500})`,
|
|
53
|
+
// @ts-expect-error
|
|
54
|
+
active: `var(--ds-background-selected-pressed, ${colors.R500})`
|
|
55
|
+
}
|
|
48
56
|
},
|
|
49
57
|
link: {
|
|
50
|
-
default: 'color.background.neutral.subtle'
|
|
51
|
-
// @ts-expect-error
|
|
52
|
-
selected: `var(--ds-background-selected, ${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, ${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, ${colors.N700})`,
|
|
73
|
+
// @ts-expect-error
|
|
74
|
+
hover: `var(--ds-background-selected-hovered, ${colors.N700})`,
|
|
65
75
|
// @ts-expect-error
|
|
66
|
-
|
|
76
|
+
active: `var(--ds-background-selected-pressed, ${colors.N700})`
|
|
67
77
|
}
|
|
68
78
|
},
|
|
69
79
|
color: {
|
|
@@ -72,45 +82,41 @@ const values = {
|
|
|
72
82
|
default: `var(--ds-text, ${colors.N500})`,
|
|
73
83
|
// @ts-expect-error
|
|
74
84
|
active: `var(--ds-text, ${colors.B400})`,
|
|
75
|
-
disabled: 'color.text.disabled'
|
|
76
|
-
// @ts-expect-error
|
|
77
|
-
selected: `var(--ds-text-selected, ${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, ${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
|
-
|
|
89
|
-
|
|
94
|
+
selected: {
|
|
95
|
+
// @ts-expect-error
|
|
96
|
+
default: `var(--ds-text-selected, ${colors.N800})`
|
|
97
|
+
}
|
|
90
98
|
},
|
|
91
99
|
danger: {
|
|
92
100
|
default: 'color.text.inverse',
|
|
93
101
|
disabled: 'color.text.disabled',
|
|
94
|
-
|
|
95
|
-
|
|
102
|
+
selected: {
|
|
103
|
+
// @ts-expect-error
|
|
104
|
+
default: `var(--ds-text-selected, ${colors.N0})`
|
|
105
|
+
}
|
|
96
106
|
},
|
|
97
107
|
link: {
|
|
98
108
|
default: 'color.link',
|
|
99
109
|
// @ts-expect-error
|
|
100
110
|
hover: `var(--ds-link, ${colors.B300})`,
|
|
101
111
|
active: 'color.link.pressed',
|
|
102
|
-
disabled: 'color.text.disabled'
|
|
103
|
-
// @ts-expect-error
|
|
104
|
-
selected: `var(--ds-text-selected, ${colors.N20})`
|
|
112
|
+
disabled: 'color.text.disabled'
|
|
105
113
|
},
|
|
106
114
|
subtle: {
|
|
107
115
|
// @ts-expect-error
|
|
108
116
|
default: `var(--ds-text, ${colors.N500})`,
|
|
109
117
|
// @ts-expect-error
|
|
110
118
|
active: `var(--ds-text, ${colors.B400})`,
|
|
111
|
-
disabled: 'color.text.disabled'
|
|
112
|
-
// @ts-expect-error
|
|
113
|
-
selected: `var(--ds-text-selected, ${colors.N20})`
|
|
119
|
+
disabled: 'color.text.disabled'
|
|
114
120
|
},
|
|
115
121
|
'subtle-link': {
|
|
116
122
|
// @ts-expect-error
|
|
@@ -119,9 +125,11 @@ const values = {
|
|
|
119
125
|
hover: `var(--ds-text-subtle, ${colors.N90})`,
|
|
120
126
|
// @ts-expect-error
|
|
121
127
|
active: `var(--ds-text, ${colors.N400})`,
|
|
122
|
-
disabled: 'color.text.disabled'
|
|
128
|
+
disabled: 'color.text.disabled'
|
|
129
|
+
},
|
|
130
|
+
selected: {
|
|
123
131
|
// @ts-expect-error
|
|
124
|
-
|
|
132
|
+
default: `var(--ds-text-selected, ${colors.N20})`
|
|
125
133
|
}
|
|
126
134
|
}
|
|
127
135
|
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Spinner from '@atlaskit/spinner';
|
|
3
|
+
function getIconSpacing(spacing) {
|
|
4
|
+
switch (spacing) {
|
|
5
|
+
case 'compact':
|
|
6
|
+
return 'small';
|
|
7
|
+
case 'none':
|
|
8
|
+
return 'xsmall';
|
|
9
|
+
default:
|
|
10
|
+
return 'medium';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function getSpinnerAppearance({
|
|
14
|
+
appearance,
|
|
15
|
+
isDisabled,
|
|
16
|
+
isSelected
|
|
17
|
+
}) {
|
|
18
|
+
if (isDisabled) {
|
|
19
|
+
return 'inherit';
|
|
20
|
+
}
|
|
21
|
+
if (isSelected) {
|
|
22
|
+
return 'invert';
|
|
23
|
+
}
|
|
24
|
+
if (appearance === 'primary' || appearance === 'danger') {
|
|
25
|
+
return 'invert';
|
|
26
|
+
}
|
|
27
|
+
return 'inherit';
|
|
28
|
+
}
|
|
29
|
+
export default function renderLoadingOverlay({
|
|
30
|
+
appearance,
|
|
31
|
+
spacing,
|
|
32
|
+
isDisabled,
|
|
33
|
+
isSelected
|
|
34
|
+
}) {
|
|
35
|
+
return /*#__PURE__*/React.createElement(Spinner, {
|
|
36
|
+
label: ", Loading",
|
|
37
|
+
size: getIconSpacing(spacing),
|
|
38
|
+
appearance: getSpinnerAppearance({
|
|
39
|
+
appearance,
|
|
40
|
+
isDisabled,
|
|
41
|
+
isSelected
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
}
|
|
@@ -56,21 +56,23 @@ function getColors({
|
|
|
56
56
|
isActiveOverSelected,
|
|
57
57
|
hasOverlay
|
|
58
58
|
}) {
|
|
59
|
+
const showSelectedState = (isSelected || isHighlighted) && !isDisabled && !isActiveOverSelected;
|
|
59
60
|
let key = interactionState;
|
|
60
61
|
// Overlay does not change color on interaction, revert to 'default' or resting state
|
|
61
62
|
key = hasOverlay ? 'default' : key;
|
|
62
|
-
key =
|
|
63
|
+
key = showSelectedState && isActiveOverSelected ? 'active' : key;
|
|
64
|
+
|
|
63
65
|
// Disabled colors overrule everything else
|
|
64
66
|
key = isDisabled ? 'disabled' : key;
|
|
65
67
|
return {
|
|
66
68
|
backgroundColor: getColor({
|
|
67
|
-
group: colors.background[appearance],
|
|
69
|
+
group: showSelectedState && colors.background[appearance]['selected'] || colors.background[showSelectedState ? 'selected' : appearance],
|
|
68
70
|
key
|
|
69
71
|
}),
|
|
70
|
-
color:
|
|
71
|
-
group: colors.color[appearance],
|
|
72
|
+
color: getColor({
|
|
73
|
+
group: showSelectedState && colors.color[appearance]['selected'] || colors.color[showSelectedState ? 'selected' : appearance],
|
|
72
74
|
key
|
|
73
|
-
})
|
|
75
|
+
})
|
|
74
76
|
};
|
|
75
77
|
}
|
|
76
78
|
export function getXCSS({
|
|
@@ -102,7 +102,7 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
|
|
|
102
102
|
action: 'clicked',
|
|
103
103
|
componentName: 'button',
|
|
104
104
|
packageName: "@atlaskit/button",
|
|
105
|
-
packageVersion: "17.
|
|
105
|
+
packageVersion: "17.9.0",
|
|
106
106
|
analyticsData: analyticsContext
|
|
107
107
|
});
|
|
108
108
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["analyticsContext", "interactionName", "autoFocus", "appearance", "spacing", "isDisabled", "isSelected", "iconBefore", "UNSAFE_iconAfter_size", "iconAfter", "UNSAFE_iconBefore_size", "children", "shouldFitContainer", "overlay", "onClick", "onMouseDownCapture", "onMouseUpCapture", "onKeyDownCapture", "onKeyUpCapture", "onTouchStartCapture", "onTouchEndCapture", "onPointerDownCapture", "onPointerUpCapture", "onClickCapture", "type", "testId"];
|
|
3
|
+
var _excluded = ["analyticsContext", "interactionName", "autoFocus", "appearance", "spacing", "isDisabled", "isSelected", "iconBefore", "isLoading", "UNSAFE_iconAfter_size", "iconAfter", "UNSAFE_iconBefore_size", "children", "shouldFitContainer", "overlay", "onClick", "onMouseDownCapture", "onMouseUpCapture", "onKeyDownCapture", "onKeyUpCapture", "onTouchStartCapture", "onTouchEndCapture", "onPointerDownCapture", "onPointerUpCapture", "onClickCapture", "type", "testId"];
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import UNSAFE_PRESSABLE from '@atlaskit/primitives/pressable';
|
|
6
6
|
import useDefaultButton from './use-default-button';
|
|
@@ -22,6 +22,7 @@ var Button = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function But
|
|
|
22
22
|
isDisabled = _ref.isDisabled,
|
|
23
23
|
isSelected = _ref.isSelected,
|
|
24
24
|
iconBefore = _ref.iconBefore,
|
|
25
|
+
isLoading = _ref.isLoading,
|
|
25
26
|
UNSAFE_iconAfter_size = _ref.UNSAFE_iconAfter_size,
|
|
26
27
|
iconAfter = _ref.iconAfter,
|
|
27
28
|
UNSAFE_iconBefore_size = _ref.UNSAFE_iconBefore_size,
|
|
@@ -55,6 +56,7 @@ var Button = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function But
|
|
|
55
56
|
interactionName: interactionName,
|
|
56
57
|
isDisabled: isDisabled,
|
|
57
58
|
isSelected: isSelected,
|
|
59
|
+
isLoading: isLoading,
|
|
58
60
|
onClick: onClick,
|
|
59
61
|
onMouseDownCapture: onMouseDownCapture,
|
|
60
62
|
onMouseUpCapture: onMouseUpCapture,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { Fragment } from 'react';
|
|
2
2
|
import Content from '../shared/content';
|
|
3
|
+
import renderLoadingOverlay from '../shared/loading-overlay';
|
|
3
4
|
import useButtonBase from '../shared/use-button-base';
|
|
4
5
|
/**
|
|
5
6
|
* __Use default button base__
|
|
@@ -22,6 +23,8 @@ var useDefaultButton = function useDefaultButton(_ref) {
|
|
|
22
23
|
interactionName = _ref.interactionName,
|
|
23
24
|
isDisabled = _ref.isDisabled,
|
|
24
25
|
isSelected = _ref.isSelected,
|
|
26
|
+
_ref$isLoading = _ref.isLoading,
|
|
27
|
+
isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
|
|
25
28
|
children = _ref.children,
|
|
26
29
|
onClick = _ref.onClick,
|
|
27
30
|
onMouseDownCapture = _ref.onMouseDownCapture,
|
|
@@ -37,7 +40,7 @@ var useDefaultButton = function useDefaultButton(_ref) {
|
|
|
37
40
|
ref = _ref.ref,
|
|
38
41
|
shouldFitContainer = _ref.shouldFitContainer,
|
|
39
42
|
spacing = _ref.spacing;
|
|
40
|
-
var hasOverlay = Boolean(overlay);
|
|
43
|
+
var hasOverlay = Boolean(overlay || isLoading);
|
|
41
44
|
var baseProps = useButtonBase({
|
|
42
45
|
analyticsContext: analyticsContext,
|
|
43
46
|
appearance: appearance,
|
|
@@ -71,7 +74,12 @@ var useDefaultButton = function useDefaultButton(_ref) {
|
|
|
71
74
|
onPointerDownCapture: onPointerDownCapture,
|
|
72
75
|
onPointerUpCapture: onPointerUpCapture,
|
|
73
76
|
onClickCapture: onClickCapture,
|
|
74
|
-
overlay:
|
|
77
|
+
overlay: isLoading ? renderLoadingOverlay({
|
|
78
|
+
spacing: spacing,
|
|
79
|
+
appearance: appearance,
|
|
80
|
+
isDisabled: isDisabled,
|
|
81
|
+
isSelected: isSelected
|
|
82
|
+
}) : overlay,
|
|
75
83
|
ref: ref,
|
|
76
84
|
shouldFitContainer: shouldFitContainer,
|
|
77
85
|
spacing: spacing,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["analyticsContext", "interactionName", "autoFocus", "appearance", "spacing", "isDisabled", "isSelected", "icon", "label", "overlay", "onClick", "onMouseDownCapture", "onMouseUpCapture", "onKeyDownCapture", "onKeyUpCapture", "onTouchStartCapture", "onTouchEndCapture", "onPointerDownCapture", "onPointerUpCapture", "onClickCapture", "shape", "type", "testId", "UNSAFE_size", "aria-label"];
|
|
3
|
+
var _excluded = ["analyticsContext", "interactionName", "autoFocus", "appearance", "spacing", "isDisabled", "isSelected", "isLoading", "icon", "label", "overlay", "onClick", "onMouseDownCapture", "onMouseUpCapture", "onKeyDownCapture", "onKeyUpCapture", "onTouchStartCapture", "onTouchEndCapture", "onPointerDownCapture", "onPointerUpCapture", "onClickCapture", "shape", "type", "testId", "UNSAFE_size", "aria-label"];
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import UNSAFE_PRESSABLE from '@atlaskit/primitives/pressable';
|
|
6
6
|
import useIconButton from './use-icon-button';
|
|
@@ -21,6 +21,7 @@ var IconButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function
|
|
|
21
21
|
spacing = _ref.spacing,
|
|
22
22
|
isDisabled = _ref.isDisabled,
|
|
23
23
|
isSelected = _ref.isSelected,
|
|
24
|
+
isLoading = _ref.isLoading,
|
|
24
25
|
icon = _ref.icon,
|
|
25
26
|
label = _ref.label,
|
|
26
27
|
overlay = _ref.overlay,
|
|
@@ -54,6 +55,7 @@ var IconButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function
|
|
|
54
55
|
interactionName: interactionName,
|
|
55
56
|
isDisabled: isDisabled,
|
|
56
57
|
isSelected: isSelected,
|
|
58
|
+
isLoading: isLoading,
|
|
57
59
|
label: label,
|
|
58
60
|
onClick: onClick,
|
|
59
61
|
onMouseDownCapture: onMouseDownCapture,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
3
3
|
import Content from '../shared/content';
|
|
4
|
+
import renderLoadingOverlay from '../shared/loading-overlay';
|
|
4
5
|
import useButtonBase from '../shared/use-button-base';
|
|
5
6
|
/**
|
|
6
7
|
* __Use icon button__
|
|
@@ -20,6 +21,7 @@ var useIconButton = function useIconButton(_ref) {
|
|
|
20
21
|
interactionName = _ref.interactionName,
|
|
21
22
|
isDisabled = _ref.isDisabled,
|
|
22
23
|
isSelected = _ref.isSelected,
|
|
24
|
+
isLoading = _ref.isLoading,
|
|
23
25
|
label = _ref.label,
|
|
24
26
|
onClick = _ref.onClick,
|
|
25
27
|
onMouseDownCapture = _ref.onMouseDownCapture,
|
|
@@ -37,7 +39,7 @@ var useIconButton = function useIconButton(_ref) {
|
|
|
37
39
|
shouldFitContainer = _ref.shouldFitContainer,
|
|
38
40
|
spacing = _ref.spacing,
|
|
39
41
|
UNSAFE_size = _ref.UNSAFE_size;
|
|
40
|
-
var hasOverlay = Boolean(overlay);
|
|
42
|
+
var hasOverlay = Boolean(overlay || isLoading);
|
|
41
43
|
var isCircle = shape === 'circle';
|
|
42
44
|
var baseProps = useButtonBase({
|
|
43
45
|
analyticsContext: analyticsContext,
|
|
@@ -66,7 +68,12 @@ var useIconButton = function useIconButton(_ref) {
|
|
|
66
68
|
onPointerDownCapture: onPointerDownCapture,
|
|
67
69
|
onPointerUpCapture: onPointerUpCapture,
|
|
68
70
|
onClickCapture: onClickCapture,
|
|
69
|
-
overlay:
|
|
71
|
+
overlay: isLoading ? renderLoadingOverlay({
|
|
72
|
+
spacing: spacing,
|
|
73
|
+
appearance: appearance,
|
|
74
|
+
isDisabled: isDisabled,
|
|
75
|
+
isSelected: isSelected
|
|
76
|
+
}) : overlay,
|
|
70
77
|
ref: ref,
|
|
71
78
|
shouldFitContainer: shouldFitContainer,
|
|
72
79
|
spacing: spacing
|
|
@@ -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
|
-
|
|
38
|
-
|
|
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
|
-
|
|
47
|
-
|
|
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
|
-
|
|
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
|
-
|
|
89
|
-
|
|
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
|
-
|
|
95
|
-
|
|
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
|
-
|
|
132
|
+
default: "var(--ds-text-selected, ".concat(colors.N20, ")")
|
|
125
133
|
}
|
|
126
134
|
}
|
|
127
135
|
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Spinner from '@atlaskit/spinner';
|
|
3
|
+
function getIconSpacing(spacing) {
|
|
4
|
+
switch (spacing) {
|
|
5
|
+
case 'compact':
|
|
6
|
+
return 'small';
|
|
7
|
+
case 'none':
|
|
8
|
+
return 'xsmall';
|
|
9
|
+
default:
|
|
10
|
+
return 'medium';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function getSpinnerAppearance(_ref) {
|
|
14
|
+
var appearance = _ref.appearance,
|
|
15
|
+
isDisabled = _ref.isDisabled,
|
|
16
|
+
isSelected = _ref.isSelected;
|
|
17
|
+
if (isDisabled) {
|
|
18
|
+
return 'inherit';
|
|
19
|
+
}
|
|
20
|
+
if (isSelected) {
|
|
21
|
+
return 'invert';
|
|
22
|
+
}
|
|
23
|
+
if (appearance === 'primary' || appearance === 'danger') {
|
|
24
|
+
return 'invert';
|
|
25
|
+
}
|
|
26
|
+
return 'inherit';
|
|
27
|
+
}
|
|
28
|
+
export default function renderLoadingOverlay(_ref2) {
|
|
29
|
+
var appearance = _ref2.appearance,
|
|
30
|
+
spacing = _ref2.spacing,
|
|
31
|
+
isDisabled = _ref2.isDisabled,
|
|
32
|
+
isSelected = _ref2.isSelected;
|
|
33
|
+
return /*#__PURE__*/React.createElement(Spinner, {
|
|
34
|
+
label: ", Loading",
|
|
35
|
+
size: getIconSpacing(spacing),
|
|
36
|
+
appearance: getSpinnerAppearance({
|
|
37
|
+
appearance: appearance,
|
|
38
|
+
isDisabled: isDisabled,
|
|
39
|
+
isSelected: isSelected
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
}
|
|
@@ -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 =
|
|
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:
|
|
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) {
|
|
@@ -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.
|
|
111
|
+
packageVersion: "17.9.0",
|
|
112
112
|
analyticsData: analyticsContext
|
|
113
113
|
});
|
|
114
114
|
|
|
@@ -1,6 +1,10 @@
|
|
|
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;
|
|
4
8
|
/**
|
|
5
9
|
* Text content to be rendered in the button. Required so that screen readers always have an accessible label provided for the button.
|
|
6
10
|
*/
|
|
@@ -11,5 +11,5 @@ type UseButtonReturn<TagName extends HTMLElement> = UseButtonBaseReturn<TagName>
|
|
|
11
11
|
*
|
|
12
12
|
* @private
|
|
13
13
|
*/
|
|
14
|
-
declare const useDefaultButton: <TagName extends HTMLElement>({ analyticsContext, appearance, autoFocus, buttonType, iconBefore: IconBefore, UNSAFE_iconBefore_size, iconAfter: IconAfter, UNSAFE_iconAfter_size, interactionName, isDisabled, isSelected, children, onClick, onMouseDownCapture, onMouseUpCapture, onKeyDownCapture, onKeyUpCapture, onTouchStartCapture, onTouchEndCapture, onPointerDownCapture, onPointerUpCapture, onClickCapture, overlay, ref, shouldFitContainer, spacing, }: UseDefaultButtonArgs<TagName>) => UseButtonReturn<TagName>;
|
|
14
|
+
declare const useDefaultButton: <TagName extends HTMLElement>({ analyticsContext, appearance, autoFocus, buttonType, iconBefore: IconBefore, UNSAFE_iconBefore_size, iconAfter: IconAfter, UNSAFE_iconAfter_size, interactionName, isDisabled, isSelected, isLoading, children, onClick, onMouseDownCapture, onMouseUpCapture, onKeyDownCapture, onKeyUpCapture, onTouchStartCapture, onTouchEndCapture, onPointerDownCapture, onPointerUpCapture, onClickCapture, overlay, ref, shouldFitContainer, spacing, }: UseDefaultButtonArgs<TagName>) => UseButtonReturn<TagName>;
|
|
15
15
|
export default useDefaultButton;
|
|
@@ -1,5 +1,9 @@
|
|
|
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;
|
|
3
7
|
/**
|
|
4
8
|
* The button style variation.
|
|
5
9
|
*/
|