@atlaskit/button 16.5.3 → 16.5.5
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/button-group.js +3 -11
- package/dist/cjs/button.js +14 -34
- package/dist/cjs/custom-theme-button/custom-theme-button.js +41 -76
- package/dist/cjs/custom-theme-button/index.js +0 -3
- package/dist/cjs/custom-theme-button/theme.js +31 -38
- package/dist/cjs/entry-points/button-group.js +0 -2
- package/dist/cjs/entry-points/custom-theme-button.js +0 -4
- package/dist/cjs/entry-points/loading-button.js +0 -2
- package/dist/cjs/entry-points/standard-button.js +0 -3
- package/dist/cjs/index.js +0 -8
- package/dist/cjs/loading-button.js +4 -12
- package/dist/cjs/shared/block-events.js +0 -6
- package/dist/cjs/shared/button-base.js +48 -66
- package/dist/cjs/shared/colors.js +0 -5
- package/dist/cjs/shared/css.js +17 -28
- package/dist/cjs/shared/get-is-only-single-icon.js +2 -7
- package/dist/cjs/shared/loading-spinner.js +4 -15
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/button-group.js +1 -3
- package/dist/es2019/button.js +7 -7
- package/dist/es2019/custom-theme-button/custom-theme-button.js +19 -25
- package/dist/es2019/custom-theme-button/theme.js +21 -16
- package/dist/es2019/index.js +3 -1
- package/dist/es2019/loading-button.js +2 -2
- package/dist/es2019/shared/block-events.js +0 -4
- package/dist/es2019/shared/button-base.js +19 -18
- package/dist/es2019/shared/css.js +22 -14
- package/dist/es2019/shared/get-is-only-single-icon.js +0 -3
- package/dist/es2019/shared/loading-spinner.js +0 -5
- package/dist/es2019/version.json +1 -1
- package/dist/esm/button-group.js +2 -4
- package/dist/esm/button.js +14 -18
- package/dist/esm/custom-theme-button/custom-theme-button.js +41 -61
- package/dist/esm/custom-theme-button/theme.js +31 -31
- package/dist/esm/index.js +3 -1
- package/dist/esm/loading-button.js +4 -5
- package/dist/esm/shared/block-events.js +0 -4
- package/dist/esm/shared/button-base.js +51 -51
- package/dist/esm/shared/css.js +17 -19
- package/dist/esm/shared/get-is-only-single-icon.js +2 -6
- package/dist/esm/shared/loading-spinner.js +4 -11
- package/dist/esm/version.json +1 -1
- package/package.json +2 -2
- package/report.api.md +13 -0
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
-
|
|
12
9
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
13
|
-
|
|
14
10
|
var _react = _interopRequireDefault(require("react"));
|
|
15
|
-
|
|
16
11
|
var _button = _interopRequireDefault(require("./button"));
|
|
17
|
-
|
|
18
12
|
var _loadingSpinner = _interopRequireDefault(require("./shared/loading-spinner"));
|
|
19
|
-
|
|
20
13
|
var _excluded = ["isLoading"];
|
|
21
|
-
|
|
22
14
|
/**
|
|
23
15
|
* __Loading button__
|
|
24
16
|
*
|
|
@@ -28,16 +20,16 @@ var _excluded = ["isLoading"];
|
|
|
28
20
|
*/
|
|
29
21
|
var LoadingButton = /*#__PURE__*/_react.default.forwardRef(function LoadingButton(_ref, ref) {
|
|
30
22
|
var _ref$isLoading = _ref.isLoading,
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
|
|
24
|
+
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
33
25
|
// Button already has React.memo, so just leaning on that
|
|
34
26
|
return /*#__PURE__*/_react.default.createElement(_button.default, (0, _extends2.default)({}, rest, {
|
|
35
27
|
ref: ref,
|
|
36
28
|
overlay: isLoading ? /*#__PURE__*/_react.default.createElement(_loadingSpinner.default, rest) : null
|
|
37
29
|
}));
|
|
38
|
-
});
|
|
39
|
-
|
|
30
|
+
});
|
|
40
31
|
|
|
32
|
+
// Tools including enzyme rely on components having a display name
|
|
41
33
|
LoadingButton.displayName = 'LoadingButton';
|
|
42
34
|
var _default = LoadingButton;
|
|
43
35
|
exports.default = _default;
|
|
@@ -4,23 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = blockEvents;
|
|
7
|
-
|
|
8
7
|
function abort(event) {
|
|
9
8
|
event.preventDefault();
|
|
10
9
|
event.stopPropagation();
|
|
11
10
|
}
|
|
12
|
-
|
|
13
11
|
var tabKeyCode = 9;
|
|
14
|
-
|
|
15
12
|
function onKey(event) {
|
|
16
13
|
// Allowing tab so that a user can move focus away
|
|
17
14
|
if (event.keyCode === tabKeyCode) {
|
|
18
15
|
return;
|
|
19
16
|
}
|
|
20
|
-
|
|
21
17
|
abort(event);
|
|
22
18
|
}
|
|
23
|
-
|
|
24
19
|
var block = {
|
|
25
20
|
onMouseDownCapture: abort,
|
|
26
21
|
onMouseUpCapture: abort,
|
|
@@ -37,7 +32,6 @@ var block = {
|
|
|
37
32
|
onClick: abort
|
|
38
33
|
};
|
|
39
34
|
var doNotBlock = {};
|
|
40
|
-
|
|
41
35
|
function blockEvents(_ref) {
|
|
42
36
|
var isInteractive = _ref.isInteractive;
|
|
43
37
|
return isInteractive ? doNotBlock : block;
|
|
@@ -1,42 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.default = void 0;
|
|
11
|
-
|
|
12
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
10
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
15
|
-
|
|
16
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
-
|
|
18
12
|
var _react2 = require("@emotion/react");
|
|
19
|
-
|
|
20
13
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
21
|
-
|
|
22
14
|
var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
|
|
23
|
-
|
|
24
15
|
var _useAutoFocus = _interopRequireDefault(require("@atlaskit/ds-lib/use-auto-focus"));
|
|
25
|
-
|
|
26
16
|
var _interactionContext = _interopRequireDefault(require("@atlaskit/interaction-context"));
|
|
27
|
-
|
|
28
17
|
var _colors = require("@atlaskit/theme/colors");
|
|
29
|
-
|
|
30
18
|
var _blockEvents = _interopRequireDefault(require("./block-events"));
|
|
31
|
-
|
|
32
19
|
var _css = require("./css");
|
|
33
|
-
|
|
34
20
|
var _excluded = ["appearance", "buttonCss", "spacing", "autoFocus", "isDisabled", "shouldFitContainer", "isSelected", "iconBefore", "iconAfter", "children", "className", "href", "overlay", "tabIndex", "type", "onMouseDown", "onClick", "component", "testId", "interactionName", "analyticsContext"];
|
|
35
|
-
|
|
36
21
|
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); }
|
|
37
|
-
|
|
38
22
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
39
|
-
|
|
40
23
|
// Disabled buttons will still publish events for nested elements in webkit.
|
|
41
24
|
// We are disabling pointer events on child elements so that
|
|
42
25
|
// the button will always be the target of events
|
|
@@ -46,58 +29,56 @@ var noPointerEventsOnChildrenCss = {
|
|
|
46
29
|
pointerEvents: 'none'
|
|
47
30
|
}
|
|
48
31
|
};
|
|
49
|
-
|
|
50
32
|
var _default = /*#__PURE__*/_react.default.forwardRef(function ButtonBase(props, ref) {
|
|
51
33
|
var _props$appearance = props.appearance,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
34
|
+
appearance = _props$appearance === void 0 ? 'default' : _props$appearance,
|
|
35
|
+
buttonCss = props.buttonCss,
|
|
36
|
+
_props$spacing = props.spacing,
|
|
37
|
+
spacing = _props$spacing === void 0 ? 'default' : _props$spacing,
|
|
38
|
+
_props$autoFocus = props.autoFocus,
|
|
39
|
+
autoFocus = _props$autoFocus === void 0 ? false : _props$autoFocus,
|
|
40
|
+
_props$isDisabled = props.isDisabled,
|
|
41
|
+
isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled,
|
|
42
|
+
_props$shouldFitConta = props.shouldFitContainer,
|
|
43
|
+
shouldFitContainer = _props$shouldFitConta === void 0 ? false : _props$shouldFitConta,
|
|
44
|
+
_props$isSelected = props.isSelected,
|
|
45
|
+
isSelected = _props$isSelected === void 0 ? false : _props$isSelected,
|
|
46
|
+
iconBefore = props.iconBefore,
|
|
47
|
+
iconAfter = props.iconAfter,
|
|
48
|
+
children = props.children,
|
|
49
|
+
className = props.className,
|
|
50
|
+
href = props.href,
|
|
51
|
+
overlay = props.overlay,
|
|
52
|
+
_props$tabIndex = props.tabIndex,
|
|
53
|
+
tabIndex = _props$tabIndex === void 0 ? 0 : _props$tabIndex,
|
|
54
|
+
_props$type = props.type,
|
|
55
|
+
type = _props$type === void 0 ? !href ? 'button' : undefined : _props$type,
|
|
56
|
+
_props$onMouseDown = props.onMouseDown,
|
|
57
|
+
providedOnMouseDown = _props$onMouseDown === void 0 ? _noop.default : _props$onMouseDown,
|
|
58
|
+
_props$onClick = props.onClick,
|
|
59
|
+
providedOnClick = _props$onClick === void 0 ? _noop.default : _props$onClick,
|
|
60
|
+
_props$component = props.component,
|
|
61
|
+
Component = _props$component === void 0 ? href ? 'a' : 'button' : _props$component,
|
|
62
|
+
testId = props.testId,
|
|
63
|
+
interactionName = props.interactionName,
|
|
64
|
+
analyticsContext = props.analyticsContext,
|
|
65
|
+
rest = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
84
66
|
var ourRef = (0, _react.useRef)();
|
|
85
67
|
var setRef = (0, _react.useCallback)(function (node) {
|
|
86
68
|
ourRef.current = node;
|
|
87
|
-
|
|
88
69
|
if (ref == null) {
|
|
89
70
|
return;
|
|
90
71
|
}
|
|
91
|
-
|
|
92
72
|
if (typeof ref === 'function') {
|
|
93
73
|
ref(node);
|
|
94
74
|
return;
|
|
95
|
-
}
|
|
96
|
-
|
|
75
|
+
}
|
|
97
76
|
|
|
77
|
+
// @ts-ignore
|
|
98
78
|
ref.current = node;
|
|
99
|
-
}, [ourRef, ref]);
|
|
79
|
+
}, [ourRef, ref]);
|
|
100
80
|
|
|
81
|
+
// Cross browser auto focusing is pretty broken, so we are doing it ourselves
|
|
101
82
|
(0, _useAutoFocus.default)(ourRef, autoFocus);
|
|
102
83
|
var interactionContext = (0, _react.useContext)(_interactionContext.default);
|
|
103
84
|
var handleClick = (0, _react.useCallback)(function (e, analyticsEvent) {
|
|
@@ -109,36 +90,37 @@ var _default = /*#__PURE__*/_react.default.forwardRef(function ButtonBase(props,
|
|
|
109
90
|
action: 'clicked',
|
|
110
91
|
componentName: 'button',
|
|
111
92
|
packageName: "@atlaskit/button",
|
|
112
|
-
packageVersion: "16.5.
|
|
93
|
+
packageVersion: "16.5.5",
|
|
113
94
|
analyticsData: analyticsContext
|
|
114
|
-
});
|
|
95
|
+
});
|
|
115
96
|
|
|
97
|
+
// Button currently calls preventDefault, which is not standard button behaviour
|
|
116
98
|
var onMouseDown = (0, _react.useCallback)(function (event) {
|
|
117
99
|
event.preventDefault();
|
|
118
100
|
providedOnMouseDown(event);
|
|
119
|
-
}, [providedOnMouseDown]);
|
|
101
|
+
}, [providedOnMouseDown]);
|
|
120
102
|
|
|
103
|
+
// Lose focus when becoming disabled (standard button behaviour)
|
|
121
104
|
(0, _react.useEffect)(function () {
|
|
122
105
|
var el = ourRef.current;
|
|
123
|
-
|
|
124
106
|
if (isDisabled && el && el === document.activeElement) {
|
|
125
107
|
el.blur();
|
|
126
108
|
}
|
|
127
|
-
}, [isDisabled]);
|
|
109
|
+
}, [isDisabled]);
|
|
128
110
|
|
|
111
|
+
// we are 'disabling' input with a button when there is an overlay
|
|
129
112
|
var hasOverlay = Boolean(overlay);
|
|
130
113
|
var fadeCss = (0, _react2.css)((0, _css.getFadingCss)({
|
|
131
114
|
hasOverlay: hasOverlay
|
|
132
115
|
}));
|
|
133
116
|
var isInteractive = !isDisabled && !hasOverlay;
|
|
117
|
+
|
|
134
118
|
/**
|
|
135
119
|
* HACK: Spinner needs to have different colours in the "new" tokens design compared to the old design.
|
|
136
120
|
* For now, while we support both, these styles reach into Spinner when a theme is set, applies the right color.
|
|
137
121
|
* Ticket to remove: https://product-fabric.atlassian.net/browse/DSP-2067
|
|
138
122
|
*/
|
|
139
|
-
|
|
140
123
|
var spinnerHackCss = {};
|
|
141
|
-
|
|
142
124
|
if (isSelected || isDisabled || appearance === 'warning') {
|
|
143
125
|
spinnerHackCss = {
|
|
144
126
|
'[data-theme] & svg': {
|
|
@@ -146,7 +128,6 @@ var _default = /*#__PURE__*/_react.default.forwardRef(function ButtonBase(props,
|
|
|
146
128
|
}
|
|
147
129
|
};
|
|
148
130
|
}
|
|
149
|
-
|
|
150
131
|
return (0, _react2.jsx)(Component, (0, _extends2.default)({}, rest, {
|
|
151
132
|
css: [buttonCss, isInteractive ? null : noPointerEventsOnChildrenCss],
|
|
152
133
|
className: className,
|
|
@@ -154,11 +135,13 @@ var _default = /*#__PURE__*/_react.default.forwardRef(function ButtonBase(props,
|
|
|
154
135
|
onClick: onClick,
|
|
155
136
|
onMouseDown: onMouseDown,
|
|
156
137
|
disabled: isDisabled,
|
|
157
|
-
href: isInteractive ? href : undefined
|
|
138
|
+
href: isInteractive ? href : undefined
|
|
139
|
+
// using undefined so that the property doesn't exist when false
|
|
158
140
|
,
|
|
159
141
|
"data-has-overlay": hasOverlay ? true : undefined,
|
|
160
142
|
"data-testid": testId,
|
|
161
|
-
type: type
|
|
143
|
+
type: type
|
|
144
|
+
// Adding a tab index so element is always focusable, even when not a <button> or <a>
|
|
162
145
|
// Disabling focus via keyboard navigation when disabled
|
|
163
146
|
// as this is standard button behaviour
|
|
164
147
|
,
|
|
@@ -181,5 +164,4 @@ var _default = /*#__PURE__*/_react.default.forwardRef(function ButtonBase(props,
|
|
|
181
164
|
css: [_css.overlayCss, spinnerHackCss]
|
|
182
165
|
}, overlay) : null);
|
|
183
166
|
});
|
|
184
|
-
|
|
185
167
|
exports.default = _default;
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var colors = _interopRequireWildcard(require("@atlaskit/theme/colors"));
|
|
11
|
-
|
|
12
9
|
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); }
|
|
13
|
-
|
|
14
10
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
-
|
|
16
11
|
// Hard coding the active rgba color value rather than using a helper to convert it
|
|
17
12
|
// With helper it would be: hex2rgba(colors.B75, 0.6)
|
|
18
13
|
var fadedB75 = 'rgba(179, 212, 255, 0.6)';
|
package/dist/cjs/shared/css.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -10,22 +9,17 @@ exports.getCss = getCss;
|
|
|
10
9
|
exports.getFadingCss = getFadingCss;
|
|
11
10
|
exports.getIconStyle = getIconStyle;
|
|
12
11
|
exports.overlayCss = void 0;
|
|
13
|
-
|
|
14
12
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
-
|
|
16
13
|
var _react = require("@emotion/react");
|
|
17
|
-
|
|
18
14
|
var _constants = require("@atlaskit/theme/constants");
|
|
19
|
-
|
|
20
15
|
var _colors = _interopRequireDefault(require("./colors"));
|
|
21
|
-
|
|
22
16
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
23
|
-
|
|
24
17
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
25
|
-
|
|
26
18
|
var borderRadius = (0, _constants.borderRadius)();
|
|
27
19
|
var gridSize = (0, _constants.gridSize)();
|
|
28
|
-
var fontSize = (0, _constants.fontSize)();
|
|
20
|
+
var fontSize = (0, _constants.fontSize)();
|
|
21
|
+
|
|
22
|
+
// ## Button layout
|
|
29
23
|
//
|
|
30
24
|
// /------------------------------------------------------------------------------------------------------------------\
|
|
31
25
|
// | → | ← | | → | ← | | → | ← | | → | ← |
|
|
@@ -37,7 +31,6 @@ var fontSize = (0, _constants.fontSize)(); // ## Button layout
|
|
|
37
31
|
// ↑ ↑
|
|
38
32
|
// Margins don't collapse with inline-flex
|
|
39
33
|
//
|
|
40
|
-
|
|
41
34
|
var heights = {
|
|
42
35
|
default: "".concat(gridSize * 4 / fontSize, "em"),
|
|
43
36
|
// 32px
|
|
@@ -70,19 +63,17 @@ var innerMargin = {
|
|
|
70
63
|
content: "0 ".concat(gridSize / 4, "px"),
|
|
71
64
|
icon: "0 ".concat(gridSize / 4, "px")
|
|
72
65
|
};
|
|
73
|
-
|
|
74
66
|
function getColor(_ref) {
|
|
75
67
|
var group = _ref.group,
|
|
76
|
-
|
|
77
|
-
|
|
68
|
+
key = _ref.key,
|
|
69
|
+
mode = _ref.mode;
|
|
78
70
|
var rule = group[key] || group.default;
|
|
79
71
|
return rule[mode];
|
|
80
72
|
}
|
|
81
|
-
|
|
82
73
|
function getColors(_ref2) {
|
|
83
74
|
var appearance = _ref2.appearance,
|
|
84
|
-
|
|
85
|
-
|
|
75
|
+
key = _ref2.key,
|
|
76
|
+
mode = _ref2.mode;
|
|
86
77
|
return {
|
|
87
78
|
background: getColor({
|
|
88
79
|
group: _colors.default.background[appearance],
|
|
@@ -97,14 +88,13 @@ function getColors(_ref2) {
|
|
|
97
88
|
}), " !important")
|
|
98
89
|
};
|
|
99
90
|
}
|
|
100
|
-
|
|
101
91
|
function getCss(_ref3) {
|
|
102
92
|
var appearance = _ref3.appearance,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
93
|
+
spacing = _ref3.spacing,
|
|
94
|
+
mode = _ref3.mode,
|
|
95
|
+
isSelected = _ref3.isSelected,
|
|
96
|
+
shouldFitContainer = _ref3.shouldFitContainer,
|
|
97
|
+
isOnlySingleIcon = _ref3.isOnlySingleIcon;
|
|
108
98
|
var baseColors = getColors({
|
|
109
99
|
appearance: appearance,
|
|
110
100
|
key: isSelected ? 'selected' : 'default',
|
|
@@ -141,6 +131,7 @@ function getCss(_ref3) {
|
|
|
141
131
|
justifyContent: 'center',
|
|
142
132
|
// Note: we cannot disable pointer events when there is an overlay.
|
|
143
133
|
// That would be easy for styling, but it would start letting events through on disabled buttons
|
|
134
|
+
|
|
144
135
|
// Disabling visited styles (just using the base colors)
|
|
145
136
|
'&:visited': _objectSpread({}, baseColors),
|
|
146
137
|
'&:hover': _objectSpread(_objectSpread({}, getColors({
|
|
@@ -209,9 +200,9 @@ function getCss(_ref3) {
|
|
|
209
200
|
padding: 0
|
|
210
201
|
}
|
|
211
202
|
});
|
|
212
|
-
}
|
|
213
|
-
|
|
203
|
+
}
|
|
214
204
|
|
|
205
|
+
// inline-flex child
|
|
215
206
|
function getIconStyle(_ref4) {
|
|
216
207
|
var spacing = _ref4.spacing;
|
|
217
208
|
return (0, _react.css)({
|
|
@@ -225,9 +216,9 @@ function getIconStyle(_ref4) {
|
|
|
225
216
|
lineHeight: 0,
|
|
226
217
|
userSelect: 'none'
|
|
227
218
|
});
|
|
228
|
-
}
|
|
229
|
-
|
|
219
|
+
}
|
|
230
220
|
|
|
221
|
+
// inline-flex child
|
|
231
222
|
function getContentStyle(_ref5) {
|
|
232
223
|
var spacing = _ref5.spacing;
|
|
233
224
|
return (0, _react.css)({
|
|
@@ -241,7 +232,6 @@ function getContentStyle(_ref5) {
|
|
|
241
232
|
whiteSpace: 'nowrap'
|
|
242
233
|
});
|
|
243
234
|
}
|
|
244
|
-
|
|
245
235
|
function getFadingCss(_ref6) {
|
|
246
236
|
var hasOverlay = _ref6.hasOverlay;
|
|
247
237
|
return (0, _react.css)({
|
|
@@ -249,7 +239,6 @@ function getFadingCss(_ref6) {
|
|
|
249
239
|
transition: 'opacity 0.3s'
|
|
250
240
|
});
|
|
251
241
|
}
|
|
252
|
-
|
|
253
242
|
var overlayCss = {
|
|
254
243
|
// stretching to full width / height of button
|
|
255
244
|
// this is important as we need it to still block
|
|
@@ -4,23 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = getIsOnlySingleIcon;
|
|
7
|
-
|
|
8
7
|
function getIsOnlySingleIcon(_ref) {
|
|
9
8
|
var children = _ref.children,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
iconBefore = _ref.iconBefore,
|
|
10
|
+
iconAfter = _ref.iconAfter;
|
|
13
11
|
if (children) {
|
|
14
12
|
return false;
|
|
15
13
|
}
|
|
16
|
-
|
|
17
14
|
if (iconBefore && !iconAfter) {
|
|
18
15
|
return true;
|
|
19
16
|
}
|
|
20
|
-
|
|
21
17
|
if (!iconBefore && iconAfter) {
|
|
22
18
|
return true;
|
|
23
19
|
}
|
|
24
|
-
|
|
25
20
|
return false;
|
|
26
21
|
}
|
|
@@ -1,44 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = LoadingSpinner;
|
|
9
|
-
|
|
10
8
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
|
-
|
|
12
9
|
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
|
|
14
10
|
var _spinner = _interopRequireDefault(require("@atlaskit/spinner"));
|
|
15
|
-
|
|
16
11
|
var _excluded = ["spacing"];
|
|
17
|
-
|
|
18
12
|
function getSpinnerAppearance(_ref) {
|
|
19
13
|
var appearance = _ref.appearance,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
isDisabled = _ref.isDisabled,
|
|
15
|
+
isSelected = _ref.isSelected;
|
|
23
16
|
if (isDisabled) {
|
|
24
17
|
return 'inherit';
|
|
25
18
|
}
|
|
26
|
-
|
|
27
19
|
if (isSelected) {
|
|
28
20
|
return 'invert';
|
|
29
21
|
}
|
|
30
|
-
|
|
31
22
|
if (appearance === 'primary' || appearance === 'danger') {
|
|
32
23
|
return 'invert';
|
|
33
24
|
}
|
|
34
|
-
|
|
35
25
|
return 'inherit';
|
|
36
26
|
}
|
|
37
|
-
|
|
38
27
|
function LoadingSpinner(_ref2) {
|
|
39
28
|
var _ref2$spacing = _ref2.spacing,
|
|
40
|
-
|
|
41
|
-
|
|
29
|
+
spacing = _ref2$spacing === void 0 ? 'default' : _ref2$spacing,
|
|
30
|
+
rest = (0, _objectWithoutProperties2.default)(_ref2, _excluded);
|
|
42
31
|
var size = spacing === 'default' ? 'medium' : 'small';
|
|
43
32
|
return /*#__PURE__*/_react.default.createElement(_spinner.default, {
|
|
44
33
|
size: size,
|
package/dist/cjs/version.json
CHANGED
|
@@ -3,8 +3,7 @@ import React, { Fragment } from 'react';
|
|
|
3
3
|
import { css, jsx } from '@emotion/react';
|
|
4
4
|
const buttonGroupStyles = css({
|
|
5
5
|
display: 'inline-flex',
|
|
6
|
-
|
|
7
|
-
gap: "var(--ds-scale-050, 4px)",
|
|
6
|
+
gap: "var(--ds-space-050, 4px)",
|
|
8
7
|
'> *': {
|
|
9
8
|
flex: '1 0 auto'
|
|
10
9
|
}
|
|
@@ -19,7 +18,6 @@ export default function ButtonGroup({
|
|
|
19
18
|
if (!child) {
|
|
20
19
|
return null;
|
|
21
20
|
}
|
|
22
|
-
|
|
23
21
|
return jsx(Fragment, {
|
|
24
22
|
key: idx
|
|
25
23
|
}, appearance ?
|
package/dist/es2019/button.js
CHANGED
|
@@ -6,7 +6,6 @@ import ButtonBase from './shared/button-base';
|
|
|
6
6
|
import { getCss } from './shared/css';
|
|
7
7
|
import getIsOnlySingleIcon from './shared/get-is-only-single-icon';
|
|
8
8
|
const isFirefox = typeof navigator !== 'undefined' && navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
|
9
|
-
|
|
10
9
|
/**
|
|
11
10
|
* __Button__
|
|
12
11
|
*
|
|
@@ -29,19 +28,18 @@ const Button = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function B
|
|
|
29
28
|
const shouldFitContainer = Boolean(rest.shouldFitContainer);
|
|
30
29
|
const isSelected = Boolean(rest.isSelected);
|
|
31
30
|
const isOnlySingleIcon = getIsOnlySingleIcon(rest);
|
|
32
|
-
const [isActive, setIsActive] = useState(false);
|
|
33
|
-
// in Firefox
|
|
31
|
+
const [isActive, setIsActive] = useState(false);
|
|
34
32
|
|
|
33
|
+
// Wrap onMouseDown / onMouseUp to manually trigger active state
|
|
34
|
+
// in Firefox
|
|
35
35
|
const onMouseDown = useCallback(event => {
|
|
36
36
|
providedOnMouseDown(event);
|
|
37
|
-
|
|
38
37
|
if (isFirefox) {
|
|
39
38
|
setIsActive(true);
|
|
40
39
|
}
|
|
41
40
|
}, [providedOnMouseDown, setIsActive]);
|
|
42
41
|
const onMouseUp = useCallback(event => {
|
|
43
42
|
providedOnMouseUp(event);
|
|
44
|
-
|
|
45
43
|
if (isFirefox) {
|
|
46
44
|
setIsActive(false);
|
|
47
45
|
}
|
|
@@ -56,14 +54,16 @@ const Button = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function B
|
|
|
56
54
|
}), [appearance, spacing, mode, isSelected, shouldFitContainer, isOnlySingleIcon]);
|
|
57
55
|
return /*#__PURE__*/React.createElement(ButtonBase, _extends({}, rest, {
|
|
58
56
|
ref: ref,
|
|
59
|
-
buttonCss: buttonCss
|
|
57
|
+
buttonCss: buttonCss
|
|
58
|
+
// Due to how click events are set, we need to set active styles
|
|
60
59
|
// manually in Firefox and wrap onMouseDown/onMouseUp
|
|
61
60
|
,
|
|
62
61
|
"data-firefox-is-active": isActive ? true : undefined,
|
|
63
62
|
onMouseDown: onMouseDown,
|
|
64
63
|
onMouseUp: onMouseUp
|
|
65
64
|
}));
|
|
66
|
-
}));
|
|
65
|
+
}));
|
|
67
66
|
|
|
67
|
+
// Tools including enzyme rely on components having a display name
|
|
68
68
|
Button.displayName = 'Button';
|
|
69
69
|
export default Button;
|