@atlaskit/button 16.8.2 → 16.8.4
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/loading-button.js +16 -3
- package/dist/cjs/shared/button-base.js +33 -29
- package/dist/cjs/shared/loading-spinner.js +10 -6
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/loading-button.js +14 -1
- package/dist/es2019/shared/button-base.js +30 -24
- package/dist/es2019/shared/loading-spinner.js +9 -3
- package/dist/es2019/version.json +1 -1
- package/dist/esm/loading-button.js +16 -3
- package/dist/esm/shared/button-base.js +33 -29
- package/dist/esm/shared/loading-spinner.js +10 -6
- package/dist/esm/version.json +1 -1
- package/dist/types/shared/loading-spinner.d.ts +1 -1
- package/dist/types-ts4.5/shared/loading-spinner.d.ts +1 -1
- package/package.json +2 -2
- package/tmp/api-report-tmp.d.ts +133 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/button
|
|
2
2
|
|
|
3
|
+
## 16.8.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`4b3cfb2276b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4b3cfb2276b) - Refactor button base to remove rest props and make props more explicit.
|
|
8
|
+
|
|
9
|
+
## 16.8.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`11cd2f83450`](https://bitbucket.org/atlassian/atlassian-frontend/commits/11cd2f83450) - Refactor loading button to use less rest props to pass props more explicitly.
|
|
14
|
+
|
|
3
15
|
## 16.8.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -10,7 +10,7 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
|
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
var _button = _interopRequireDefault(require("./button"));
|
|
12
12
|
var _loadingSpinner = _interopRequireDefault(require("./shared/loading-spinner"));
|
|
13
|
-
var _excluded = ["isLoading"];
|
|
13
|
+
var _excluded = ["appearance", "isDisabled", "isSelected", "isLoading", "spacing"];
|
|
14
14
|
/**
|
|
15
15
|
* __Loading button__
|
|
16
16
|
*
|
|
@@ -19,14 +19,27 @@ var _excluded = ["isLoading"];
|
|
|
19
19
|
* - [Examples](https://atlassian.design/components/button/examples#loading-button)
|
|
20
20
|
*/
|
|
21
21
|
var LoadingButton = /*#__PURE__*/_react.default.forwardRef(function LoadingButton(_ref, ref) {
|
|
22
|
-
var
|
|
22
|
+
var appearance = _ref.appearance,
|
|
23
|
+
isDisabled = _ref.isDisabled,
|
|
24
|
+
isSelected = _ref.isSelected,
|
|
25
|
+
_ref$isLoading = _ref.isLoading,
|
|
23
26
|
isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
|
|
27
|
+
spacing = _ref.spacing,
|
|
24
28
|
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
25
29
|
// Button already has React.memo, so just leaning on that
|
|
26
30
|
return /*#__PURE__*/_react.default.createElement(_button.default, (0, _extends2.default)({}, rest, {
|
|
27
31
|
ref: ref,
|
|
32
|
+
appearance: appearance,
|
|
28
33
|
"aria-busy": isLoading,
|
|
29
|
-
|
|
34
|
+
isDisabled: isDisabled,
|
|
35
|
+
isSelected: isSelected,
|
|
36
|
+
overlay: isLoading ? /*#__PURE__*/_react.default.createElement(_loadingSpinner.default, {
|
|
37
|
+
spacing: spacing,
|
|
38
|
+
appearance: appearance,
|
|
39
|
+
isDisabled: isDisabled,
|
|
40
|
+
isSelected: isSelected
|
|
41
|
+
}) : null,
|
|
42
|
+
spacing: spacing
|
|
30
43
|
}));
|
|
31
44
|
});
|
|
32
45
|
|
|
@@ -19,7 +19,7 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
|
19
19
|
var _colors = require("@atlaskit/theme/colors");
|
|
20
20
|
var _blockEvents = _interopRequireDefault(require("./block-events"));
|
|
21
21
|
var _css = require("./css");
|
|
22
|
-
var _excluded = ["appearance", "buttonCss", "
|
|
22
|
+
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"];
|
|
23
23
|
/** @jsx jsx */
|
|
24
24
|
// eslint-disable-next-line no-duplicate-imports
|
|
25
25
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -34,38 +34,39 @@ var noPointerEventsOnChildrenCss = {
|
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
var _default = /*#__PURE__*/_react.default.forwardRef(function ButtonBase(props, ref) {
|
|
37
|
-
var
|
|
37
|
+
var analyticsContext = props.analyticsContext,
|
|
38
|
+
_props$appearance = props.appearance,
|
|
38
39
|
appearance = _props$appearance === void 0 ? 'default' : _props$appearance,
|
|
39
|
-
buttonCss = props.buttonCss,
|
|
40
|
-
_props$spacing = props.spacing,
|
|
41
|
-
spacing = _props$spacing === void 0 ? 'default' : _props$spacing,
|
|
42
40
|
_props$autoFocus = props.autoFocus,
|
|
43
41
|
autoFocus = _props$autoFocus === void 0 ? false : _props$autoFocus,
|
|
42
|
+
buttonCss = props.buttonCss,
|
|
43
|
+
children = props.children,
|
|
44
|
+
className = props.className,
|
|
45
|
+
href = props.href,
|
|
46
|
+
_props$component = props.component,
|
|
47
|
+
Component = _props$component === void 0 ? href ? 'a' : 'button' : _props$component,
|
|
48
|
+
iconAfter = props.iconAfter,
|
|
49
|
+
iconBefore = props.iconBefore,
|
|
50
|
+
interactionName = props.interactionName,
|
|
44
51
|
_props$isDisabled = props.isDisabled,
|
|
45
52
|
isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled,
|
|
46
|
-
_props$shouldFitConta = props.shouldFitContainer,
|
|
47
|
-
shouldFitContainer = _props$shouldFitConta === void 0 ? false : _props$shouldFitConta,
|
|
48
53
|
_props$isSelected = props.isSelected,
|
|
49
54
|
isSelected = _props$isSelected === void 0 ? false : _props$isSelected,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
onBlur = props.onBlur,
|
|
56
|
+
_props$onClick = props.onClick,
|
|
57
|
+
providedOnClick = _props$onClick === void 0 ? _noop.default : _props$onClick,
|
|
58
|
+
onFocus = props.onFocus,
|
|
59
|
+
_props$onMouseDown = props.onMouseDown,
|
|
60
|
+
providedOnMouseDown = _props$onMouseDown === void 0 ? _noop.default : _props$onMouseDown,
|
|
55
61
|
overlay = props.overlay,
|
|
62
|
+
shouldFitContainer = props.shouldFitContainer,
|
|
63
|
+
_props$spacing = props.spacing,
|
|
64
|
+
spacing = _props$spacing === void 0 ? 'default' : _props$spacing,
|
|
56
65
|
_props$tabIndex = props.tabIndex,
|
|
57
66
|
tabIndex = _props$tabIndex === void 0 ? !props.component && (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.clove-sprint-a11y-button_5rz5j') ? undefined : 0 : _props$tabIndex,
|
|
58
67
|
_props$type = props.type,
|
|
59
68
|
type = _props$type === void 0 ? !href ? 'button' : undefined : _props$type,
|
|
60
|
-
_props$onMouseDown = props.onMouseDown,
|
|
61
|
-
providedOnMouseDown = _props$onMouseDown === void 0 ? _noop.default : _props$onMouseDown,
|
|
62
|
-
_props$onClick = props.onClick,
|
|
63
|
-
providedOnClick = _props$onClick === void 0 ? _noop.default : _props$onClick,
|
|
64
|
-
_props$component = props.component,
|
|
65
|
-
Component = _props$component === void 0 ? href ? 'a' : 'button' : _props$component,
|
|
66
69
|
testId = props.testId,
|
|
67
|
-
interactionName = props.interactionName,
|
|
68
|
-
analyticsContext = props.analyticsContext,
|
|
69
70
|
rest = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
70
71
|
var ourRef = (0, _react.useRef)();
|
|
71
72
|
var setRef = (0, _react.useCallback)(function (node) {
|
|
@@ -78,6 +79,7 @@ var _default = /*#__PURE__*/_react.default.forwardRef(function ButtonBase(props,
|
|
|
78
79
|
return;
|
|
79
80
|
}
|
|
80
81
|
|
|
82
|
+
// We can write to ref's `current` property, but Typescript does not like it.
|
|
81
83
|
// @ts-ignore
|
|
82
84
|
ref.current = node;
|
|
83
85
|
}, [ourRef, ref]);
|
|
@@ -94,7 +96,7 @@ var _default = /*#__PURE__*/_react.default.forwardRef(function ButtonBase(props,
|
|
|
94
96
|
action: 'clicked',
|
|
95
97
|
componentName: 'button',
|
|
96
98
|
packageName: "@atlaskit/button",
|
|
97
|
-
packageVersion: "16.8.
|
|
99
|
+
packageVersion: "16.8.4",
|
|
98
100
|
analyticsData: analyticsContext
|
|
99
101
|
});
|
|
100
102
|
|
|
@@ -133,23 +135,25 @@ var _default = /*#__PURE__*/_react.default.forwardRef(function ButtonBase(props,
|
|
|
133
135
|
};
|
|
134
136
|
}
|
|
135
137
|
return (0, _react2.jsx)(_focusRing.default, null, (0, _react2.jsx)(Component, (0, _extends2.default)({}, rest, {
|
|
136
|
-
css: [buttonCss, isInteractive ? null : noPointerEventsOnChildrenCss],
|
|
137
|
-
className: className,
|
|
138
138
|
ref: setRef,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
disabled: isDisabled,
|
|
142
|
-
href: isInteractive ? href : undefined
|
|
139
|
+
className: className,
|
|
140
|
+
css: [buttonCss, isInteractive ? null : noPointerEventsOnChildrenCss]
|
|
143
141
|
// using undefined so that the property doesn't exist when false
|
|
144
142
|
,
|
|
145
143
|
"data-has-overlay": hasOverlay ? true : undefined,
|
|
146
144
|
"data-testid": testId,
|
|
147
|
-
|
|
145
|
+
disabled: isDisabled,
|
|
146
|
+
href: isInteractive ? href : undefined,
|
|
147
|
+
onBlur: onBlur,
|
|
148
|
+
onClick: onClick,
|
|
149
|
+
onFocus: onFocus,
|
|
150
|
+
onMouseDown: onMouseDown
|
|
148
151
|
// Adding a tab index so element is always focusable, even when not a <button> or <a>
|
|
149
152
|
// Disabling focus via keyboard navigation when disabled
|
|
150
153
|
// as this is standard button behaviour
|
|
151
154
|
,
|
|
152
|
-
tabIndex: isDisabled ? -1 : tabIndex
|
|
155
|
+
tabIndex: isDisabled ? -1 : tabIndex,
|
|
156
|
+
type: type
|
|
153
157
|
}, (0, _blockEvents.default)({
|
|
154
158
|
isInteractive: isInteractive
|
|
155
159
|
})), iconBefore ? (0, _react2.jsx)("span", {
|
|
@@ -5,10 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = LoadingSpinner;
|
|
8
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
9
8
|
var _react = _interopRequireDefault(require("react"));
|
|
10
9
|
var _spinner = _interopRequireDefault(require("@atlaskit/spinner"));
|
|
11
|
-
var _excluded = ["spacing"];
|
|
12
10
|
function getSpinnerAppearance(_ref) {
|
|
13
11
|
var appearance = _ref.appearance,
|
|
14
12
|
isDisabled = _ref.isDisabled,
|
|
@@ -25,12 +23,18 @@ function getSpinnerAppearance(_ref) {
|
|
|
25
23
|
return 'inherit';
|
|
26
24
|
}
|
|
27
25
|
function LoadingSpinner(_ref2) {
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
var appearance = _ref2.appearance,
|
|
27
|
+
isDisabled = _ref2.isDisabled,
|
|
28
|
+
isSelected = _ref2.isSelected,
|
|
29
|
+
_ref2$spacing = _ref2.spacing,
|
|
30
|
+
spacing = _ref2$spacing === void 0 ? 'default' : _ref2$spacing;
|
|
31
31
|
var size = spacing === 'default' ? 'medium' : 'small';
|
|
32
32
|
return /*#__PURE__*/_react.default.createElement(_spinner.default, {
|
|
33
33
|
size: size,
|
|
34
|
-
appearance: getSpinnerAppearance(
|
|
34
|
+
appearance: getSpinnerAppearance({
|
|
35
|
+
appearance: appearance,
|
|
36
|
+
isDisabled: isDisabled,
|
|
37
|
+
isSelected: isSelected
|
|
38
|
+
})
|
|
35
39
|
});
|
|
36
40
|
}
|
package/dist/cjs/version.json
CHANGED
|
@@ -10,14 +10,27 @@ import LoadingSpinner from './shared/loading-spinner';
|
|
|
10
10
|
* - [Examples](https://atlassian.design/components/button/examples#loading-button)
|
|
11
11
|
*/
|
|
12
12
|
const LoadingButton = /*#__PURE__*/React.forwardRef(function LoadingButton({
|
|
13
|
+
appearance,
|
|
14
|
+
isDisabled,
|
|
15
|
+
isSelected,
|
|
13
16
|
isLoading = false,
|
|
17
|
+
spacing,
|
|
14
18
|
...rest
|
|
15
19
|
}, ref) {
|
|
16
20
|
// Button already has React.memo, so just leaning on that
|
|
17
21
|
return /*#__PURE__*/React.createElement(Button, _extends({}, rest, {
|
|
18
22
|
ref: ref,
|
|
23
|
+
appearance: appearance,
|
|
19
24
|
"aria-busy": isLoading,
|
|
20
|
-
|
|
25
|
+
isDisabled: isDisabled,
|
|
26
|
+
isSelected: isSelected,
|
|
27
|
+
overlay: isLoading ? /*#__PURE__*/React.createElement(LoadingSpinner, {
|
|
28
|
+
spacing: spacing,
|
|
29
|
+
appearance: appearance,
|
|
30
|
+
isDisabled: isDisabled,
|
|
31
|
+
isSelected: isSelected
|
|
32
|
+
}) : null,
|
|
33
|
+
spacing: spacing
|
|
21
34
|
}));
|
|
22
35
|
});
|
|
23
36
|
|
|
@@ -24,33 +24,36 @@ const noPointerEventsOnChildrenCss = {
|
|
|
24
24
|
};
|
|
25
25
|
export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
|
|
26
26
|
const {
|
|
27
|
+
// I don't think analytics should be in button, but for now it is
|
|
28
|
+
analyticsContext,
|
|
27
29
|
appearance = 'default',
|
|
28
|
-
buttonCss,
|
|
29
|
-
spacing = 'default',
|
|
30
30
|
autoFocus = false,
|
|
31
|
-
|
|
32
|
-
shouldFitContainer = false,
|
|
33
|
-
isSelected = false,
|
|
34
|
-
iconBefore,
|
|
35
|
-
iconAfter,
|
|
31
|
+
buttonCss,
|
|
36
32
|
children,
|
|
37
33
|
className,
|
|
38
34
|
href,
|
|
35
|
+
// use the provided component prop,
|
|
36
|
+
// else default to anchor if there is a href, and button if there is no href
|
|
37
|
+
component: Component = href ? 'a' : 'button',
|
|
38
|
+
iconAfter,
|
|
39
|
+
iconBefore,
|
|
40
|
+
interactionName,
|
|
41
|
+
isDisabled = false,
|
|
42
|
+
isSelected = false,
|
|
43
|
+
onBlur,
|
|
44
|
+
onClick: providedOnClick = noop,
|
|
45
|
+
onFocus,
|
|
46
|
+
onMouseDown: providedOnMouseDown = noop,
|
|
39
47
|
overlay,
|
|
48
|
+
// Pulling out so it doesn't spread on rendered component
|
|
49
|
+
shouldFitContainer,
|
|
50
|
+
spacing = 'default',
|
|
40
51
|
// Don't set unnecessary tabIndex for focus if using standard <button> or <a>
|
|
41
52
|
// html elements. Set to `0` for custom components to ensure other elements can
|
|
42
53
|
// be focused (although the custom component could be a <button> or <a>...)
|
|
43
54
|
tabIndex = !props.component && getBooleanFF('platform.design-system-team.clove-sprint-a11y-button_5rz5j') ? undefined : 0,
|
|
44
55
|
type = !href ? 'button' : undefined,
|
|
45
|
-
onMouseDown: providedOnMouseDown = noop,
|
|
46
|
-
onClick: providedOnClick = noop,
|
|
47
|
-
// use the provided component prop,
|
|
48
|
-
// else default to anchor if there is a href, and button if there is no href
|
|
49
|
-
component: Component = href ? 'a' : 'button',
|
|
50
56
|
testId,
|
|
51
|
-
interactionName,
|
|
52
|
-
// I don't think this should be in button, but for now it is
|
|
53
|
-
analyticsContext,
|
|
54
57
|
...rest
|
|
55
58
|
} = props;
|
|
56
59
|
const ourRef = useRef();
|
|
@@ -64,6 +67,7 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
|
|
|
64
67
|
return;
|
|
65
68
|
}
|
|
66
69
|
|
|
70
|
+
// We can write to ref's `current` property, but Typescript does not like it.
|
|
67
71
|
// @ts-ignore
|
|
68
72
|
ref.current = node;
|
|
69
73
|
}, [ourRef, ref]);
|
|
@@ -80,7 +84,7 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
|
|
|
80
84
|
action: 'clicked',
|
|
81
85
|
componentName: 'button',
|
|
82
86
|
packageName: "@atlaskit/button",
|
|
83
|
-
packageVersion: "16.8.
|
|
87
|
+
packageVersion: "16.8.4",
|
|
84
88
|
analyticsData: analyticsContext
|
|
85
89
|
});
|
|
86
90
|
|
|
@@ -119,23 +123,25 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
|
|
|
119
123
|
};
|
|
120
124
|
}
|
|
121
125
|
return jsx(FocusRing, null, jsx(Component, _extends({}, rest, {
|
|
122
|
-
css: [buttonCss, isInteractive ? null : noPointerEventsOnChildrenCss],
|
|
123
|
-
className: className,
|
|
124
126
|
ref: setRef,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
disabled: isDisabled,
|
|
128
|
-
href: isInteractive ? href : undefined
|
|
127
|
+
className: className,
|
|
128
|
+
css: [buttonCss, isInteractive ? null : noPointerEventsOnChildrenCss]
|
|
129
129
|
// using undefined so that the property doesn't exist when false
|
|
130
130
|
,
|
|
131
131
|
"data-has-overlay": hasOverlay ? true : undefined,
|
|
132
132
|
"data-testid": testId,
|
|
133
|
-
|
|
133
|
+
disabled: isDisabled,
|
|
134
|
+
href: isInteractive ? href : undefined,
|
|
135
|
+
onBlur: onBlur,
|
|
136
|
+
onClick: onClick,
|
|
137
|
+
onFocus: onFocus,
|
|
138
|
+
onMouseDown: onMouseDown
|
|
134
139
|
// Adding a tab index so element is always focusable, even when not a <button> or <a>
|
|
135
140
|
// Disabling focus via keyboard navigation when disabled
|
|
136
141
|
// as this is standard button behaviour
|
|
137
142
|
,
|
|
138
|
-
tabIndex: isDisabled ? -1 : tabIndex
|
|
143
|
+
tabIndex: isDisabled ? -1 : tabIndex,
|
|
144
|
+
type: type
|
|
139
145
|
}, blockEvents({
|
|
140
146
|
isInteractive
|
|
141
147
|
})), iconBefore ? jsx("span", {
|
|
@@ -17,12 +17,18 @@ function getSpinnerAppearance({
|
|
|
17
17
|
return 'inherit';
|
|
18
18
|
}
|
|
19
19
|
export default function LoadingSpinner({
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
appearance,
|
|
21
|
+
isDisabled,
|
|
22
|
+
isSelected,
|
|
23
|
+
spacing = 'default'
|
|
22
24
|
}) {
|
|
23
25
|
const size = spacing === 'default' ? 'medium' : 'small';
|
|
24
26
|
return /*#__PURE__*/React.createElement(Spinner, {
|
|
25
27
|
size: size,
|
|
26
|
-
appearance: getSpinnerAppearance(
|
|
28
|
+
appearance: getSpinnerAppearance({
|
|
29
|
+
appearance,
|
|
30
|
+
isDisabled,
|
|
31
|
+
isSelected
|
|
32
|
+
})
|
|
27
33
|
});
|
|
28
34
|
}
|
package/dist/es2019/version.json
CHANGED
|
@@ -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 = ["isLoading"];
|
|
3
|
+
var _excluded = ["appearance", "isDisabled", "isSelected", "isLoading", "spacing"];
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import Button from './button';
|
|
6
6
|
import LoadingSpinner from './shared/loading-spinner';
|
|
@@ -12,14 +12,27 @@ import LoadingSpinner from './shared/loading-spinner';
|
|
|
12
12
|
* - [Examples](https://atlassian.design/components/button/examples#loading-button)
|
|
13
13
|
*/
|
|
14
14
|
var LoadingButton = /*#__PURE__*/React.forwardRef(function LoadingButton(_ref, ref) {
|
|
15
|
-
var
|
|
15
|
+
var appearance = _ref.appearance,
|
|
16
|
+
isDisabled = _ref.isDisabled,
|
|
17
|
+
isSelected = _ref.isSelected,
|
|
18
|
+
_ref$isLoading = _ref.isLoading,
|
|
16
19
|
isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
|
|
20
|
+
spacing = _ref.spacing,
|
|
17
21
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
18
22
|
// Button already has React.memo, so just leaning on that
|
|
19
23
|
return /*#__PURE__*/React.createElement(Button, _extends({}, rest, {
|
|
20
24
|
ref: ref,
|
|
25
|
+
appearance: appearance,
|
|
21
26
|
"aria-busy": isLoading,
|
|
22
|
-
|
|
27
|
+
isDisabled: isDisabled,
|
|
28
|
+
isSelected: isSelected,
|
|
29
|
+
overlay: isLoading ? /*#__PURE__*/React.createElement(LoadingSpinner, {
|
|
30
|
+
spacing: spacing,
|
|
31
|
+
appearance: appearance,
|
|
32
|
+
isDisabled: isDisabled,
|
|
33
|
+
isSelected: isSelected
|
|
34
|
+
}) : null,
|
|
35
|
+
spacing: spacing
|
|
23
36
|
}));
|
|
24
37
|
});
|
|
25
38
|
|
|
@@ -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 = ["appearance", "buttonCss", "
|
|
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
4
|
/** @jsx jsx */
|
|
5
5
|
import React, { useCallback, useContext, useEffect, useRef } from 'react';
|
|
6
6
|
import { css, jsx } from '@emotion/react';
|
|
@@ -25,38 +25,39 @@ var noPointerEventsOnChildrenCss = {
|
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
|
|
28
|
-
var
|
|
28
|
+
var analyticsContext = props.analyticsContext,
|
|
29
|
+
_props$appearance = props.appearance,
|
|
29
30
|
appearance = _props$appearance === void 0 ? 'default' : _props$appearance,
|
|
30
|
-
buttonCss = props.buttonCss,
|
|
31
|
-
_props$spacing = props.spacing,
|
|
32
|
-
spacing = _props$spacing === void 0 ? 'default' : _props$spacing,
|
|
33
31
|
_props$autoFocus = props.autoFocus,
|
|
34
32
|
autoFocus = _props$autoFocus === void 0 ? false : _props$autoFocus,
|
|
33
|
+
buttonCss = props.buttonCss,
|
|
34
|
+
children = props.children,
|
|
35
|
+
className = props.className,
|
|
36
|
+
href = props.href,
|
|
37
|
+
_props$component = props.component,
|
|
38
|
+
Component = _props$component === void 0 ? href ? 'a' : 'button' : _props$component,
|
|
39
|
+
iconAfter = props.iconAfter,
|
|
40
|
+
iconBefore = props.iconBefore,
|
|
41
|
+
interactionName = props.interactionName,
|
|
35
42
|
_props$isDisabled = props.isDisabled,
|
|
36
43
|
isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled,
|
|
37
|
-
_props$shouldFitConta = props.shouldFitContainer,
|
|
38
|
-
shouldFitContainer = _props$shouldFitConta === void 0 ? false : _props$shouldFitConta,
|
|
39
44
|
_props$isSelected = props.isSelected,
|
|
40
45
|
isSelected = _props$isSelected === void 0 ? false : _props$isSelected,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
onBlur = props.onBlur,
|
|
47
|
+
_props$onClick = props.onClick,
|
|
48
|
+
providedOnClick = _props$onClick === void 0 ? noop : _props$onClick,
|
|
49
|
+
onFocus = props.onFocus,
|
|
50
|
+
_props$onMouseDown = props.onMouseDown,
|
|
51
|
+
providedOnMouseDown = _props$onMouseDown === void 0 ? noop : _props$onMouseDown,
|
|
46
52
|
overlay = props.overlay,
|
|
53
|
+
shouldFitContainer = props.shouldFitContainer,
|
|
54
|
+
_props$spacing = props.spacing,
|
|
55
|
+
spacing = _props$spacing === void 0 ? 'default' : _props$spacing,
|
|
47
56
|
_props$tabIndex = props.tabIndex,
|
|
48
57
|
tabIndex = _props$tabIndex === void 0 ? !props.component && getBooleanFF('platform.design-system-team.clove-sprint-a11y-button_5rz5j') ? undefined : 0 : _props$tabIndex,
|
|
49
58
|
_props$type = props.type,
|
|
50
59
|
type = _props$type === void 0 ? !href ? 'button' : undefined : _props$type,
|
|
51
|
-
_props$onMouseDown = props.onMouseDown,
|
|
52
|
-
providedOnMouseDown = _props$onMouseDown === void 0 ? noop : _props$onMouseDown,
|
|
53
|
-
_props$onClick = props.onClick,
|
|
54
|
-
providedOnClick = _props$onClick === void 0 ? noop : _props$onClick,
|
|
55
|
-
_props$component = props.component,
|
|
56
|
-
Component = _props$component === void 0 ? href ? 'a' : 'button' : _props$component,
|
|
57
60
|
testId = props.testId,
|
|
58
|
-
interactionName = props.interactionName,
|
|
59
|
-
analyticsContext = props.analyticsContext,
|
|
60
61
|
rest = _objectWithoutProperties(props, _excluded);
|
|
61
62
|
var ourRef = useRef();
|
|
62
63
|
var setRef = useCallback(function (node) {
|
|
@@ -69,6 +70,7 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
|
|
|
69
70
|
return;
|
|
70
71
|
}
|
|
71
72
|
|
|
73
|
+
// We can write to ref's `current` property, but Typescript does not like it.
|
|
72
74
|
// @ts-ignore
|
|
73
75
|
ref.current = node;
|
|
74
76
|
}, [ourRef, ref]);
|
|
@@ -85,7 +87,7 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
|
|
|
85
87
|
action: 'clicked',
|
|
86
88
|
componentName: 'button',
|
|
87
89
|
packageName: "@atlaskit/button",
|
|
88
|
-
packageVersion: "16.8.
|
|
90
|
+
packageVersion: "16.8.4",
|
|
89
91
|
analyticsData: analyticsContext
|
|
90
92
|
});
|
|
91
93
|
|
|
@@ -124,23 +126,25 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
|
|
|
124
126
|
};
|
|
125
127
|
}
|
|
126
128
|
return jsx(FocusRing, null, jsx(Component, _extends({}, rest, {
|
|
127
|
-
css: [buttonCss, isInteractive ? null : noPointerEventsOnChildrenCss],
|
|
128
|
-
className: className,
|
|
129
129
|
ref: setRef,
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
disabled: isDisabled,
|
|
133
|
-
href: isInteractive ? href : undefined
|
|
130
|
+
className: className,
|
|
131
|
+
css: [buttonCss, isInteractive ? null : noPointerEventsOnChildrenCss]
|
|
134
132
|
// using undefined so that the property doesn't exist when false
|
|
135
133
|
,
|
|
136
134
|
"data-has-overlay": hasOverlay ? true : undefined,
|
|
137
135
|
"data-testid": testId,
|
|
138
|
-
|
|
136
|
+
disabled: isDisabled,
|
|
137
|
+
href: isInteractive ? href : undefined,
|
|
138
|
+
onBlur: onBlur,
|
|
139
|
+
onClick: onClick,
|
|
140
|
+
onFocus: onFocus,
|
|
141
|
+
onMouseDown: onMouseDown
|
|
139
142
|
// Adding a tab index so element is always focusable, even when not a <button> or <a>
|
|
140
143
|
// Disabling focus via keyboard navigation when disabled
|
|
141
144
|
// as this is standard button behaviour
|
|
142
145
|
,
|
|
143
|
-
tabIndex: isDisabled ? -1 : tabIndex
|
|
146
|
+
tabIndex: isDisabled ? -1 : tabIndex,
|
|
147
|
+
type: type
|
|
144
148
|
}, blockEvents({
|
|
145
149
|
isInteractive: isInteractive
|
|
146
150
|
})), iconBefore ? jsx("span", {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
|
-
var _excluded = ["spacing"];
|
|
3
1
|
import React from 'react';
|
|
4
2
|
import Spinner from '@atlaskit/spinner';
|
|
5
3
|
function getSpinnerAppearance(_ref) {
|
|
@@ -18,12 +16,18 @@ function getSpinnerAppearance(_ref) {
|
|
|
18
16
|
return 'inherit';
|
|
19
17
|
}
|
|
20
18
|
export default function LoadingSpinner(_ref2) {
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
var appearance = _ref2.appearance,
|
|
20
|
+
isDisabled = _ref2.isDisabled,
|
|
21
|
+
isSelected = _ref2.isSelected,
|
|
22
|
+
_ref2$spacing = _ref2.spacing,
|
|
23
|
+
spacing = _ref2$spacing === void 0 ? 'default' : _ref2$spacing;
|
|
24
24
|
var size = spacing === 'default' ? 'medium' : 'small';
|
|
25
25
|
return /*#__PURE__*/React.createElement(Spinner, {
|
|
26
26
|
size: size,
|
|
27
|
-
appearance: getSpinnerAppearance(
|
|
27
|
+
appearance: getSpinnerAppearance({
|
|
28
|
+
appearance: appearance,
|
|
29
|
+
isDisabled: isDisabled,
|
|
30
|
+
isSelected: isSelected
|
|
31
|
+
})
|
|
28
32
|
});
|
|
29
33
|
}
|
package/dist/esm/version.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { BaseProps } from '../types';
|
|
3
3
|
type LoadingSpinnerProps = Pick<BaseProps, 'appearance' | 'isDisabled' | 'isSelected' | 'spacing'>;
|
|
4
|
-
export default function LoadingSpinner({ spacing,
|
|
4
|
+
export default function LoadingSpinner({ appearance, isDisabled, isSelected, spacing, }: LoadingSpinnerProps): JSX.Element;
|
|
5
5
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { BaseProps } from '../types';
|
|
3
3
|
type LoadingSpinnerProps = Pick<BaseProps, 'appearance' | 'isDisabled' | 'isSelected' | 'spacing'>;
|
|
4
|
-
export default function LoadingSpinner({ spacing,
|
|
4
|
+
export default function LoadingSpinner({ appearance, isDisabled, isSelected, spacing, }: LoadingSpinnerProps): JSX.Element;
|
|
5
5
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/button",
|
|
3
|
-
"version": "16.8.
|
|
3
|
+
"version": "16.8.4",
|
|
4
4
|
"description": "A button triggers an event or action. They let users know what will happen next.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@atlaskit/platform-feature-flags": "^0.2.0",
|
|
52
52
|
"@atlaskit/spinner": "^15.5.0",
|
|
53
53
|
"@atlaskit/theme": "^12.5.0",
|
|
54
|
-
"@atlaskit/tokens": "^1.
|
|
54
|
+
"@atlaskit/tokens": "^1.13.0",
|
|
55
55
|
"@babel/runtime": "^7.0.0",
|
|
56
56
|
"@emotion/react": "^11.7.1"
|
|
57
57
|
},
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
## API Report File for "@atlaskit/button"
|
|
2
|
+
|
|
3
|
+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
|
|
7
|
+
/// <reference types="react" />
|
|
8
|
+
|
|
9
|
+
import { ComponentType } from 'react';
|
|
10
|
+
import { CSSObject } from '@emotion/react';
|
|
11
|
+
import { jsx } from '@emotion/react';
|
|
12
|
+
import { default as React_2 } from 'react';
|
|
13
|
+
import { ReactNode } from 'react';
|
|
14
|
+
import { ThemeModes } from '@atlaskit/theme/types';
|
|
15
|
+
import { ThemeModes as ThemeModes_2 } from '@atlaskit/theme';
|
|
16
|
+
import { ThemeProp } from '@atlaskit/theme/components';
|
|
17
|
+
import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
18
|
+
|
|
19
|
+
// @public (undocumented)
|
|
20
|
+
export type Appearance = 'danger' | 'default' | 'link' | 'primary' | 'subtle' | 'subtle-link' | 'warning';
|
|
21
|
+
|
|
22
|
+
// @public (undocumented)
|
|
23
|
+
export type BaseOwnProps = {
|
|
24
|
+
appearance?: Appearance;
|
|
25
|
+
autoFocus?: boolean;
|
|
26
|
+
className?: string;
|
|
27
|
+
overlay?: React_2.ReactNode;
|
|
28
|
+
href?: string;
|
|
29
|
+
iconAfter?: React_2.ReactChild;
|
|
30
|
+
iconBefore?: React_2.ReactChild;
|
|
31
|
+
isDisabled?: boolean;
|
|
32
|
+
isSelected?: boolean;
|
|
33
|
+
onBlur?: React_2.FocusEventHandler<HTMLElement>;
|
|
34
|
+
onClick?: (e: React_2.MouseEvent<HTMLElement>, analyticsEvent: UIAnalyticsEvent) => void;
|
|
35
|
+
onFocus?: React_2.FocusEventHandler<HTMLElement>;
|
|
36
|
+
spacing?: Spacing;
|
|
37
|
+
target?: React_2.AnchorHTMLAttributes<HTMLAnchorElement>['target'];
|
|
38
|
+
type?: React_2.ButtonHTMLAttributes<HTMLButtonElement>['type'];
|
|
39
|
+
shouldFitContainer?: boolean;
|
|
40
|
+
children?: React_2.ReactNode;
|
|
41
|
+
testId?: string;
|
|
42
|
+
component?: React_2.ComponentType<React_2.AllHTMLAttributes<HTMLElement>> | React_2.ElementType;
|
|
43
|
+
interactionName?: string;
|
|
44
|
+
analyticsContext?: Record<string, any>;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// @public (undocumented)
|
|
48
|
+
export type BaseProps = Combine<Combine<Omit<React_2.AllHTMLAttributes<HTMLElement>, 'disabled'>, {
|
|
49
|
+
'data-testid'?: never;
|
|
50
|
+
'data-has-overlay'?: never;
|
|
51
|
+
}>, BaseOwnProps>;
|
|
52
|
+
|
|
53
|
+
// @public
|
|
54
|
+
const Button: React_2.MemoExoticComponent<React_2.ForwardRefExoticComponent<ButtonProps & React_2.RefAttributes<HTMLElement>>>;
|
|
55
|
+
export default Button;
|
|
56
|
+
|
|
57
|
+
// @public (undocumented)
|
|
58
|
+
export function ButtonGroup({ appearance, children, }: ButtonGroupProps): jsx.JSX.Element;
|
|
59
|
+
|
|
60
|
+
// @public (undocumented)
|
|
61
|
+
type ButtonGroupProps = {
|
|
62
|
+
appearance?: Appearance;
|
|
63
|
+
children?: React_2.ReactNode;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// @public (undocumented)
|
|
67
|
+
export interface ButtonProps extends BaseProps {
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// @public (undocumented)
|
|
71
|
+
type Combine<First, Second> = Omit<First, keyof Second> & Second;
|
|
72
|
+
|
|
73
|
+
// @public
|
|
74
|
+
export const CustomThemeButton: React_2.MemoExoticComponent<React_2.ForwardRefExoticComponent<Omit<BaseProps, "overlay"> & CustomThemeButtonOwnProps & React_2.RefAttributes<HTMLElement>>>;
|
|
75
|
+
|
|
76
|
+
// @public (undocumented)
|
|
77
|
+
export type CustomThemeButtonOwnProps = {
|
|
78
|
+
isLoading?: boolean;
|
|
79
|
+
theme?: (current: (props: ThemeProps) => ThemeTokens, props: ThemeProps) => ThemeTokens;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// @public (undocumented)
|
|
83
|
+
export type CustomThemeButtonProps = Omit<BaseProps, 'overlay'> & CustomThemeButtonOwnProps;
|
|
84
|
+
|
|
85
|
+
// @public (undocumented)
|
|
86
|
+
export type InteractionState = 'active' | 'default' | 'disabled' | 'focus' | 'focusSelected' | 'hover' | 'selected';
|
|
87
|
+
|
|
88
|
+
// @public
|
|
89
|
+
export const LoadingButton: React_2.ForwardRefExoticComponent<Omit<BaseProps, "overlay"> & LoadingButtonOwnProps & React_2.RefAttributes<HTMLElement>>;
|
|
90
|
+
|
|
91
|
+
// @public (undocumented)
|
|
92
|
+
export type LoadingButtonOwnProps = {
|
|
93
|
+
isLoading?: boolean;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// @public (undocumented)
|
|
97
|
+
export type LoadingButtonProps = Omit<BaseProps, 'overlay'> & LoadingButtonOwnProps;
|
|
98
|
+
|
|
99
|
+
// @public (undocumented)
|
|
100
|
+
export type Spacing = 'compact' | 'default' | 'none';
|
|
101
|
+
|
|
102
|
+
// @public (undocumented)
|
|
103
|
+
export const Theme: {
|
|
104
|
+
Consumer: ComponentType< {
|
|
105
|
+
children: (tokens: ThemeTokens) => ReactNode;
|
|
106
|
+
} & Partial<CustomThemeButtonProps> & {
|
|
107
|
+
state: InteractionState;
|
|
108
|
+
iconIsOnlyChild?: boolean | undefined;
|
|
109
|
+
mode?: ThemeModes_2 | undefined;
|
|
110
|
+
}>;
|
|
111
|
+
Provider: ComponentType< {
|
|
112
|
+
children?: ReactNode;
|
|
113
|
+
value?: ThemeProp<ThemeTokens, ThemeProps> | undefined;
|
|
114
|
+
}>;
|
|
115
|
+
useTheme: (props: ThemeProps) => ThemeTokens;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// @public (undocumented)
|
|
119
|
+
export type ThemeProps = Partial<CustomThemeButtonProps> & {
|
|
120
|
+
state: InteractionState;
|
|
121
|
+
iconIsOnlyChild?: boolean;
|
|
122
|
+
mode?: ThemeModes;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// @public (undocumented)
|
|
126
|
+
export type ThemeTokens = {
|
|
127
|
+
buttonStyles: CSSObject;
|
|
128
|
+
spinnerStyles: CSSObject;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// (No @packageDocumentation comment for this package)
|
|
132
|
+
|
|
133
|
+
```
|