@atlaskit/button 16.1.2 → 16.1.6
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 +28 -0
- package/dist/cjs/button.js +10 -15
- package/dist/cjs/custom-theme-button/custom-theme-button.js +5 -3
- package/dist/cjs/custom-theme-button/index.js +4 -4
- package/dist/cjs/custom-theme-button/theme.js +4 -4
- package/dist/cjs/entry-points/custom-theme-button.js +4 -4
- package/dist/cjs/index.js +8 -8
- package/dist/cjs/loading-button.js +3 -1
- package/dist/cjs/shared/button-base.js +22 -4
- package/dist/cjs/shared/colors.js +160 -162
- package/dist/cjs/shared/css.js +4 -4
- package/dist/cjs/shared/loading-spinner.js +3 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/button.js +5 -13
- package/dist/es2019/shared/button-base.js +18 -2
- package/dist/es2019/shared/colors.js +160 -161
- package/dist/es2019/version.json +1 -1
- package/dist/esm/button.js +8 -14
- package/dist/esm/custom-theme-button/custom-theme-button.js +4 -3
- package/dist/esm/custom-theme-button/theme.js +2 -2
- package/dist/esm/loading-button.js +2 -1
- package/dist/esm/shared/button-base.js +20 -3
- package/dist/esm/shared/colors.js +160 -161
- package/dist/esm/shared/css.js +2 -2
- package/dist/esm/shared/loading-spinner.js +2 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/shared/loading-spinner.d.ts +1 -0
- package/package.json +8 -7
|
@@ -13,6 +13,8 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
13
13
|
|
|
14
14
|
var _spinner = _interopRequireDefault(require("@atlaskit/spinner"));
|
|
15
15
|
|
|
16
|
+
var _excluded = ["spacing"];
|
|
17
|
+
|
|
16
18
|
function getSpinnerAppearance(_ref) {
|
|
17
19
|
var appearance = _ref.appearance,
|
|
18
20
|
isDisabled = _ref.isDisabled,
|
|
@@ -36,7 +38,7 @@ function getSpinnerAppearance(_ref) {
|
|
|
36
38
|
function LoadingSpinner(_ref2) {
|
|
37
39
|
var _ref2$spacing = _ref2.spacing,
|
|
38
40
|
spacing = _ref2$spacing === void 0 ? 'default' : _ref2$spacing,
|
|
39
|
-
rest = (0, _objectWithoutProperties2.default)(_ref2,
|
|
41
|
+
rest = (0, _objectWithoutProperties2.default)(_ref2, _excluded);
|
|
40
42
|
var size = spacing === 'default' ? 'medium' : 'small';
|
|
41
43
|
return /*#__PURE__*/_react.default.createElement(_spinner.default, {
|
|
42
44
|
size: size,
|
package/dist/cjs/version.json
CHANGED
package/dist/es2019/button.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React, { useCallback, useMemo, useState } from 'react';
|
|
3
|
-
import
|
|
3
|
+
import { useGlobalTheme } from '@atlaskit/theme/components';
|
|
4
4
|
import ButtonBase from './shared/button-base';
|
|
5
5
|
import { getCss } from './shared/css';
|
|
6
6
|
import getIsOnlySingleIcon from './shared/get-is-only-single-icon';
|
|
@@ -8,12 +8,14 @@ import getIsOnlySingleIcon from './shared/get-is-only-single-icon';
|
|
|
8
8
|
function noop() {}
|
|
9
9
|
|
|
10
10
|
const isFirefox = typeof navigator !== 'undefined' && navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
|
11
|
-
const
|
|
12
|
-
mode,
|
|
11
|
+
const Button = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function Button({
|
|
13
12
|
onMouseDown: providedOnMouseDown = noop,
|
|
14
13
|
onMouseUp: providedOnMouseUp = noop,
|
|
15
14
|
...rest
|
|
16
15
|
}, ref) {
|
|
16
|
+
const {
|
|
17
|
+
mode
|
|
18
|
+
} = useGlobalTheme();
|
|
17
19
|
const appearance = rest.appearance || 'default';
|
|
18
20
|
const spacing = rest.spacing || 'default';
|
|
19
21
|
const shouldFitContainer = Boolean(rest.shouldFitContainer);
|
|
@@ -53,16 +55,6 @@ const ButtonWithMode = /*#__PURE__*/React.forwardRef(function ButtonWithMode({
|
|
|
53
55
|
onMouseDown: onMouseDown,
|
|
54
56
|
onMouseUp: onMouseUp
|
|
55
57
|
}));
|
|
56
|
-
});
|
|
57
|
-
const Button = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function Button(props, ref) {
|
|
58
|
-
return /*#__PURE__*/React.createElement(GlobalTheme.Consumer, null, ({
|
|
59
|
-
mode
|
|
60
|
-
}) => {
|
|
61
|
-
return /*#__PURE__*/React.createElement(ButtonWithMode, _extends({}, props, {
|
|
62
|
-
ref: ref,
|
|
63
|
-
mode: mode
|
|
64
|
-
}));
|
|
65
|
-
});
|
|
66
58
|
})); // Tools including enzyme rely on components having a display name
|
|
67
59
|
|
|
68
60
|
Button.displayName = 'Button';
|
|
@@ -5,6 +5,7 @@ import React, { useCallback, useEffect, useRef } from 'react';
|
|
|
5
5
|
import { jsx } from '@emotion/core';
|
|
6
6
|
import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next';
|
|
7
7
|
import useAutoFocus from '@atlaskit/ds-lib/use-auto-focus';
|
|
8
|
+
import { N500 } from '@atlaskit/theme/colors';
|
|
8
9
|
import blockEvents from './block-events';
|
|
9
10
|
import { getContentStyle, getFadingCss, getIconStyle, overlayCss } from './css';
|
|
10
11
|
|
|
@@ -69,7 +70,7 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
|
|
|
69
70
|
action: 'clicked',
|
|
70
71
|
componentName: 'button',
|
|
71
72
|
packageName: "@atlaskit/button",
|
|
72
|
-
packageVersion: "16.1.
|
|
73
|
+
packageVersion: "16.1.6",
|
|
73
74
|
analyticsData: analyticsContext
|
|
74
75
|
}); // Button currently calls preventDefault, which is not standard button behaviour
|
|
75
76
|
|
|
@@ -91,6 +92,21 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
|
|
|
91
92
|
hasOverlay
|
|
92
93
|
});
|
|
93
94
|
const isInteractive = !isDisabled && !hasOverlay;
|
|
95
|
+
/** HACK: Spinner needs to have different colours in the "new" tokens design compared to the old design.
|
|
96
|
+
* For now, while we support both, these styles reach into Spinner when a theme is set, applies the right color.
|
|
97
|
+
* Ticket to remove: https://product-fabric.atlassian.net/browse/DSP-2067
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
var spinnerHackCss = {};
|
|
101
|
+
|
|
102
|
+
if (isSelected || isDisabled || appearance === 'warning') {
|
|
103
|
+
spinnerHackCss = {
|
|
104
|
+
'[data-theme] & svg': {
|
|
105
|
+
stroke: isSelected || isDisabled ? `var(--ds-text-subtle, ${N500})` : `var(--ds-text-warning-inverse, ${N500})`
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
94
110
|
return jsx(Component, _extends({}, rest, {
|
|
95
111
|
css: [buttonCss, isInteractive ? null : noPointerEventsOnChildrenCss],
|
|
96
112
|
className: className,
|
|
@@ -122,6 +138,6 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
|
|
|
122
138
|
spacing
|
|
123
139
|
})]
|
|
124
140
|
}, iconAfter) : null, overlay ? jsx("span", {
|
|
125
|
-
css: overlayCss
|
|
141
|
+
css: [overlayCss, spinnerHackCss]
|
|
126
142
|
}, overlay) : null);
|
|
127
143
|
});
|