@atlaskit/button 16.4.1 → 16.5.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 +11 -0
- package/dist/cjs/shared/button-base.js +11 -3
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/shared/button-base.js +11 -3
- package/dist/es2019/version.json +1 -1
- package/dist/esm/shared/button-base.js +12 -4
- package/dist/esm/version.json +1 -1
- package/dist/types/types.d.ts +5 -0
- package/package.json +4 -3
- package/report.api.md +18 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @atlaskit/button
|
|
2
2
|
|
|
3
|
+
## 16.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`71799e16ae6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/71799e16ae6) - Introduce InteractionContext to @atlaskit/button
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [`3c76f243e7f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/3c76f243e7f) - InteractionContext is nullable
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
3
14
|
## 16.4.1
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -23,13 +23,15 @@ var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
|
|
|
23
23
|
|
|
24
24
|
var _useAutoFocus = _interopRequireDefault(require("@atlaskit/ds-lib/use-auto-focus"));
|
|
25
25
|
|
|
26
|
+
var _interactionContext = _interopRequireDefault(require("@atlaskit/interaction-context"));
|
|
27
|
+
|
|
26
28
|
var _colors = require("@atlaskit/theme/colors");
|
|
27
29
|
|
|
28
30
|
var _blockEvents = _interopRequireDefault(require("./block-events"));
|
|
29
31
|
|
|
30
32
|
var _css = require("./css");
|
|
31
33
|
|
|
32
|
-
var _excluded = ["appearance", "buttonCss", "spacing", "autoFocus", "isDisabled", "shouldFitContainer", "isSelected", "iconBefore", "iconAfter", "children", "className", "href", "overlay", "tabIndex", "type", "onMouseDown", "onClick", "component", "testId", "analyticsContext"];
|
|
34
|
+
var _excluded = ["appearance", "buttonCss", "spacing", "autoFocus", "isDisabled", "shouldFitContainer", "isSelected", "iconBefore", "iconAfter", "children", "className", "href", "overlay", "tabIndex", "type", "onMouseDown", "onClick", "component", "testId", "interactionName", "analyticsContext"];
|
|
33
35
|
|
|
34
36
|
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); }
|
|
35
37
|
|
|
@@ -76,6 +78,7 @@ var _default = /*#__PURE__*/_react.default.forwardRef(function ButtonBase(props,
|
|
|
76
78
|
_props$component = props.component,
|
|
77
79
|
Component = _props$component === void 0 ? href ? 'a' : 'button' : _props$component,
|
|
78
80
|
testId = props.testId,
|
|
81
|
+
interactionName = props.interactionName,
|
|
79
82
|
analyticsContext = props.analyticsContext,
|
|
80
83
|
rest = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
81
84
|
var ourRef = (0, _react.useRef)();
|
|
@@ -96,12 +99,17 @@ var _default = /*#__PURE__*/_react.default.forwardRef(function ButtonBase(props,
|
|
|
96
99
|
}, [ourRef, ref]); // Cross browser auto focusing is pretty broken, so we are doing it ourselves
|
|
97
100
|
|
|
98
101
|
(0, _useAutoFocus.default)(ourRef, autoFocus);
|
|
102
|
+
var interactionContext = (0, _react.useContext)(_interactionContext.default);
|
|
103
|
+
var handleClick = (0, _react.useCallback)(function (e, analyticsEvent) {
|
|
104
|
+
interactionContext && interactionContext.tracePress(interactionName, e.timeStamp);
|
|
105
|
+
providedOnClick(e, analyticsEvent);
|
|
106
|
+
}, [providedOnClick, interactionContext, interactionName]);
|
|
99
107
|
var onClick = (0, _analyticsNext.usePlatformLeafEventHandler)({
|
|
100
|
-
fn:
|
|
108
|
+
fn: handleClick,
|
|
101
109
|
action: 'clicked',
|
|
102
110
|
componentName: 'button',
|
|
103
111
|
packageName: "@atlaskit/button",
|
|
104
|
-
packageVersion: "16.
|
|
112
|
+
packageVersion: "16.5.0",
|
|
105
113
|
analyticsData: analyticsContext
|
|
106
114
|
}); // Button currently calls preventDefault, which is not standard button behaviour
|
|
107
115
|
|
package/dist/cjs/version.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
|
-
import React, { useCallback, useEffect, useRef } from 'react';
|
|
4
|
+
import React, { useCallback, useContext, useEffect, useRef } from 'react';
|
|
5
5
|
import { css, jsx } from '@emotion/react';
|
|
6
6
|
import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next';
|
|
7
7
|
import noop from '@atlaskit/ds-lib/noop';
|
|
8
8
|
import useAutoFocus from '@atlaskit/ds-lib/use-auto-focus';
|
|
9
|
+
// eslint-disable-next-line no-duplicate-imports
|
|
10
|
+
import InteractionContext from '@atlaskit/interaction-context';
|
|
9
11
|
import { N500 } from '@atlaskit/theme/colors';
|
|
10
12
|
import blockEvents from './block-events';
|
|
11
13
|
import { getContentStyle, getFadingCss, getIconStyle, overlayCss } from './css'; // Disabled buttons will still publish events for nested elements in webkit.
|
|
@@ -41,6 +43,7 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
|
|
|
41
43
|
// else default to anchor if there is a href, and button if there is no href
|
|
42
44
|
component: Component = href ? 'a' : 'button',
|
|
43
45
|
testId,
|
|
46
|
+
interactionName,
|
|
44
47
|
// I don't think this should be in button, but for now it is
|
|
45
48
|
analyticsContext,
|
|
46
49
|
...rest
|
|
@@ -63,12 +66,17 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
|
|
|
63
66
|
}, [ourRef, ref]); // Cross browser auto focusing is pretty broken, so we are doing it ourselves
|
|
64
67
|
|
|
65
68
|
useAutoFocus(ourRef, autoFocus);
|
|
69
|
+
const interactionContext = useContext(InteractionContext);
|
|
70
|
+
const handleClick = useCallback((e, analyticsEvent) => {
|
|
71
|
+
interactionContext && interactionContext.tracePress(interactionName, e.timeStamp);
|
|
72
|
+
providedOnClick(e, analyticsEvent);
|
|
73
|
+
}, [providedOnClick, interactionContext, interactionName]);
|
|
66
74
|
const onClick = usePlatformLeafEventHandler({
|
|
67
|
-
fn:
|
|
75
|
+
fn: handleClick,
|
|
68
76
|
action: 'clicked',
|
|
69
77
|
componentName: 'button',
|
|
70
78
|
packageName: "@atlaskit/button",
|
|
71
|
-
packageVersion: "16.
|
|
79
|
+
packageVersion: "16.5.0",
|
|
72
80
|
analyticsData: analyticsContext
|
|
73
81
|
}); // Button currently calls preventDefault, which is not standard button behaviour
|
|
74
82
|
|
package/dist/es2019/version.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["appearance", "buttonCss", "spacing", "autoFocus", "isDisabled", "shouldFitContainer", "isSelected", "iconBefore", "iconAfter", "children", "className", "href", "overlay", "tabIndex", "type", "onMouseDown", "onClick", "component", "testId", "analyticsContext"];
|
|
3
|
+
var _excluded = ["appearance", "buttonCss", "spacing", "autoFocus", "isDisabled", "shouldFitContainer", "isSelected", "iconBefore", "iconAfter", "children", "className", "href", "overlay", "tabIndex", "type", "onMouseDown", "onClick", "component", "testId", "interactionName", "analyticsContext"];
|
|
4
4
|
|
|
5
5
|
/** @jsx jsx */
|
|
6
|
-
import React, { useCallback, useEffect, useRef } from 'react';
|
|
6
|
+
import React, { useCallback, useContext, useEffect, useRef } from 'react';
|
|
7
7
|
import { css, jsx } from '@emotion/react';
|
|
8
8
|
import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next';
|
|
9
9
|
import noop from '@atlaskit/ds-lib/noop';
|
|
10
10
|
import useAutoFocus from '@atlaskit/ds-lib/use-auto-focus';
|
|
11
|
+
// eslint-disable-next-line no-duplicate-imports
|
|
12
|
+
import InteractionContext from '@atlaskit/interaction-context';
|
|
11
13
|
import { N500 } from '@atlaskit/theme/colors';
|
|
12
14
|
import blockEvents from './block-events';
|
|
13
15
|
import { getContentStyle, getFadingCss, getIconStyle, overlayCss } from './css'; // Disabled buttons will still publish events for nested elements in webkit.
|
|
@@ -51,6 +53,7 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
|
|
|
51
53
|
_props$component = props.component,
|
|
52
54
|
Component = _props$component === void 0 ? href ? 'a' : 'button' : _props$component,
|
|
53
55
|
testId = props.testId,
|
|
56
|
+
interactionName = props.interactionName,
|
|
54
57
|
analyticsContext = props.analyticsContext,
|
|
55
58
|
rest = _objectWithoutProperties(props, _excluded);
|
|
56
59
|
|
|
@@ -72,12 +75,17 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
|
|
|
72
75
|
}, [ourRef, ref]); // Cross browser auto focusing is pretty broken, so we are doing it ourselves
|
|
73
76
|
|
|
74
77
|
useAutoFocus(ourRef, autoFocus);
|
|
78
|
+
var interactionContext = useContext(InteractionContext);
|
|
79
|
+
var handleClick = useCallback(function (e, analyticsEvent) {
|
|
80
|
+
interactionContext && interactionContext.tracePress(interactionName, e.timeStamp);
|
|
81
|
+
providedOnClick(e, analyticsEvent);
|
|
82
|
+
}, [providedOnClick, interactionContext, interactionName]);
|
|
75
83
|
var onClick = usePlatformLeafEventHandler({
|
|
76
|
-
fn:
|
|
84
|
+
fn: handleClick,
|
|
77
85
|
action: 'clicked',
|
|
78
86
|
componentName: 'button',
|
|
79
87
|
packageName: "@atlaskit/button",
|
|
80
|
-
packageVersion: "16.
|
|
88
|
+
packageVersion: "16.5.0",
|
|
81
89
|
analyticsData: analyticsContext
|
|
82
90
|
}); // Button currently calls preventDefault, which is not standard button behaviour
|
|
83
91
|
|
package/dist/esm/version.json
CHANGED
package/dist/types/types.d.ts
CHANGED
|
@@ -77,6 +77,11 @@ export declare type BaseOwnProps = {
|
|
|
77
77
|
*/
|
|
78
78
|
testId?: string;
|
|
79
79
|
component?: React.ComponentType<React.AllHTMLAttributes<HTMLElement>> | React.ElementType;
|
|
80
|
+
/**
|
|
81
|
+
* An optional name used to identify this component to press listeners. E.g. interaction tracing
|
|
82
|
+
* @see https://hello.atlassian.net/wiki/spaces/UFO/pages/2010358949/UFO+Integration+into+Design+System+components
|
|
83
|
+
*/
|
|
84
|
+
interactionName?: string;
|
|
80
85
|
/**
|
|
81
86
|
* Additional information to be included in the `context` of analytics events that come from button
|
|
82
87
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/button",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.5.0",
|
|
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/"
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@atlaskit/analytics-next": "^8.2.0",
|
|
36
36
|
"@atlaskit/ds-lib": "^2.1.0",
|
|
37
|
-
"@atlaskit/
|
|
37
|
+
"@atlaskit/interaction-context": "^2.0.0",
|
|
38
|
+
"@atlaskit/spinner": "^15.3.0",
|
|
38
39
|
"@atlaskit/theme": "^12.2.0",
|
|
39
40
|
"@atlaskit/tokens": "^0.11.0",
|
|
40
41
|
"@babel/runtime": "^7.0.0",
|
|
@@ -49,7 +50,7 @@
|
|
|
49
50
|
"@atlaskit/icon": "^21.11.0",
|
|
50
51
|
"@atlaskit/logo": "^13.10.0",
|
|
51
52
|
"@atlaskit/section-message": "^6.3.0",
|
|
52
|
-
"@atlaskit/select": "^
|
|
53
|
+
"@atlaskit/select": "^16.0.0",
|
|
53
54
|
"@atlaskit/ssr": "*",
|
|
54
55
|
"@atlaskit/visual-regression": "*",
|
|
55
56
|
"@atlaskit/webdriver-runner": "*",
|
package/report.api.md
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
<!-- API Report Version: 2.2 -->
|
|
2
|
+
|
|
1
3
|
## API Report File for "@atlaskit/button"
|
|
2
4
|
|
|
3
|
-
> Do not edit this file.
|
|
5
|
+
> Do not edit this file. This report is auto-generated using [API Extractor](https://api-extractor.com/).
|
|
6
|
+
> [Learn more about API reports](https://hello.atlassian.net/wiki/spaces/UR/pages/1825484529/Package+API+Reports)
|
|
7
|
+
|
|
8
|
+
### Table of contents
|
|
9
|
+
|
|
10
|
+
- [Main Entry Types](#main-entry-types)
|
|
4
11
|
|
|
5
|
-
|
|
6
|
-
Generated API Report version: 2.0
|
|
7
|
-
-->
|
|
12
|
+
### Main Entry Types
|
|
8
13
|
|
|
9
|
-
|
|
14
|
+
<!--SECTION START: Main Entry Types-->
|
|
10
15
|
|
|
11
16
|
```ts
|
|
12
17
|
/// <reference types="react" />
|
|
@@ -23,8 +28,8 @@ import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
|
23
28
|
|
|
24
29
|
// @public (undocumented)
|
|
25
30
|
export type Appearance =
|
|
26
|
-
| 'default'
|
|
27
31
|
| 'danger'
|
|
32
|
+
| 'default'
|
|
28
33
|
| 'link'
|
|
29
34
|
| 'primary'
|
|
30
35
|
| 'subtle'
|
|
@@ -57,6 +62,7 @@ export type BaseOwnProps = {
|
|
|
57
62
|
component?:
|
|
58
63
|
| React_2.ComponentType<React_2.AllHTMLAttributes<HTMLElement>>
|
|
59
64
|
| React_2.ElementType;
|
|
65
|
+
interactionName?: string;
|
|
60
66
|
analyticsContext?: Record<string, any>;
|
|
61
67
|
};
|
|
62
68
|
|
|
@@ -122,13 +128,13 @@ export type CustomThemeButtonProps = Omit<BaseProps, 'overlay'> &
|
|
|
122
128
|
|
|
123
129
|
// @public (undocumented)
|
|
124
130
|
export type InteractionState =
|
|
131
|
+
| 'active'
|
|
132
|
+
| 'default'
|
|
125
133
|
| 'disabled'
|
|
134
|
+
| 'focus'
|
|
126
135
|
| 'focusSelected'
|
|
127
|
-
| 'selected'
|
|
128
|
-
| 'active'
|
|
129
136
|
| 'hover'
|
|
130
|
-
| '
|
|
131
|
-
| 'default';
|
|
137
|
+
| 'selected';
|
|
132
138
|
|
|
133
139
|
// @public
|
|
134
140
|
export const LoadingButton: React_2.ForwardRefExoticComponent<
|
|
@@ -182,3 +188,5 @@ export type ThemeTokens = {
|
|
|
182
188
|
|
|
183
189
|
// (No @packageDocumentation comment for this package)
|
|
184
190
|
```
|
|
191
|
+
|
|
192
|
+
<!--SECTION END: Main Entry Types-->
|