@atlaskit/button 16.11.0 → 16.12.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 +10 -0
- package/dist/cjs/new-button/variants/default/link.js +47 -42
- package/dist/cjs/new-button/variants/icon/link.js +47 -42
- package/dist/cjs/new-button/variants/shared/use-button-base.js +1 -1
- package/dist/cjs/old-button/shared/button-base.js +1 -1
- package/dist/cjs/utils/variants.js +73 -8
- package/dist/es2019/new-button/variants/default/button.js +0 -1
- package/dist/es2019/new-button/variants/default/link.js +45 -44
- package/dist/es2019/new-button/variants/icon/button.js +0 -1
- package/dist/es2019/new-button/variants/icon/link.js +45 -44
- package/dist/es2019/new-button/variants/shared/use-button-base.js +1 -1
- package/dist/es2019/old-button/shared/button-base.js +1 -1
- package/dist/es2019/utils/variants.js +69 -6
- package/dist/esm/new-button/variants/default/link.js +44 -42
- package/dist/esm/new-button/variants/icon/link.js +44 -42
- package/dist/esm/new-button/variants/shared/use-button-base.js +1 -1
- package/dist/esm/old-button/shared/button-base.js +1 -1
- package/dist/esm/utils/variants.js +75 -6
- package/dist/types/new-button/variants/default/button.d.ts +3 -5
- package/dist/types/new-button/variants/default/link.d.ts +10 -7
- package/dist/types/new-button/variants/icon/button.d.ts +3 -5
- package/dist/types/new-button/variants/icon/link.d.ts +11 -8
- package/dist/types/new-button/variants/types.d.ts +11 -1
- package/dist/types/utils/variants.d.ts +25 -3
- package/dist/types-ts4.5/new-button/variants/default/button.d.ts +3 -5
- package/dist/types-ts4.5/new-button/variants/default/link.d.ts +10 -7
- package/dist/types-ts4.5/new-button/variants/icon/button.d.ts +3 -5
- package/dist/types-ts4.5/new-button/variants/icon/link.d.ts +11 -8
- package/dist/types-ts4.5/new-button/variants/types.d.ts +11 -1
- package/dist/types-ts4.5/utils/variants.d.ts +25 -3
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/button
|
|
2
2
|
|
|
3
|
+
## 16.12.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#42305](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42305) [`4c9d4a7be34`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4c9d4a7be34) - - Link button variants (still in Alpha) `<LinkButton>` and `<LinkIconButton>` now support router link components through use of an app provider
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
3
13
|
## 16.11.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.default = void 0;
|
|
8
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
10
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
|
-
var _react =
|
|
11
|
-
var
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _link = _interopRequireDefault(require("@atlaskit/primitives/link"));
|
|
12
13
|
var _useDefaultButton = _interopRequireDefault(require("./use-default-button"));
|
|
13
14
|
var _excluded = ["analyticsContext", "autoFocus", "appearance", "spacing", "isDisabled", "isSelected", "iconBefore", "iconAfter", "children", "shouldFitContainer", "interactionName", "overlay", "onClick", "onMouseDownCapture", "onMouseUpCapture", "onKeyDownCapture", "onKeyUpCapture", "onTouchStartCapture", "onTouchEndCapture", "onPointerDownCapture", "onPointerUpCapture", "onClickCapture", "testId", "href"];
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* A link button renders a link in the style of a button.
|
|
18
|
-
*
|
|
19
|
-
* - [Examples](https://atlassian.design/components/button/examples)
|
|
20
|
-
* - [Code](https://atlassian.design/components/button/code)
|
|
21
|
-
* - [Usage](https://atlassian.design/components/button/usage)
|
|
22
|
-
*/
|
|
23
|
-
var LinkButton = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.default.forwardRef(function LinkButton(_ref, ref) {
|
|
15
|
+
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); }
|
|
16
|
+
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; }
|
|
17
|
+
var LinkButtonBase = function LinkButtonBase(_ref, ref) {
|
|
24
18
|
var analyticsContext = _ref.analyticsContext,
|
|
25
19
|
autoFocus = _ref.autoFocus,
|
|
26
20
|
appearance = _ref.appearance,
|
|
@@ -72,34 +66,45 @@ var LinkButton = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.default.f
|
|
|
72
66
|
shouldFitContainer: shouldFitContainer,
|
|
73
67
|
spacing: spacing
|
|
74
68
|
});
|
|
75
|
-
return (
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
69
|
+
return /*#__PURE__*/_react.default.createElement(_link.default
|
|
70
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
71
|
+
, (0, _extends2.default)({}, rest, {
|
|
72
|
+
ref: baseProps.ref,
|
|
73
|
+
xcss: baseProps.xcss,
|
|
74
|
+
onClick: baseProps.onClick,
|
|
75
|
+
onMouseDownCapture: baseProps.onMouseDownCapture,
|
|
76
|
+
onMouseUpCapture: baseProps.onMouseUpCapture,
|
|
77
|
+
onKeyDownCapture: baseProps.onKeyDownCapture,
|
|
78
|
+
onKeyUpCapture: baseProps.onKeyUpCapture,
|
|
79
|
+
onTouchStartCapture: baseProps.onTouchStartCapture,
|
|
80
|
+
onTouchEndCapture: baseProps.onTouchEndCapture,
|
|
81
|
+
onPointerDownCapture: baseProps.onPointerDownCapture,
|
|
82
|
+
onPointerUpCapture: baseProps.onPointerUpCapture,
|
|
83
|
+
onClickCapture: baseProps.onClickCapture,
|
|
84
|
+
testId: testId
|
|
85
|
+
/**
|
|
86
|
+
* Disable link in an accessible way using `href`, `role`, and `aria-disabled`.
|
|
87
|
+
* @see https://a11y-guidelines.orange.com/en/articles/disable-elements/#disable-a-link
|
|
88
|
+
*/
|
|
89
|
+
// @ts-expect-error (`href` is required, we could make it optional but don't want to encourage this pattern elsewhere)
|
|
90
|
+
,
|
|
91
|
+
href: baseProps.isDisabled ? undefined : href,
|
|
92
|
+
role: baseProps.isDisabled ? 'link' : undefined,
|
|
93
|
+
"aria-disabled": baseProps.isDisabled === true ? true : undefined
|
|
94
|
+
}), baseProps.children);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// Workarounds to support generic types with forwardRef + memo
|
|
98
|
+
var WithRef = /*#__PURE__*/(0, _react.forwardRef)(LinkButtonBase);
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* __Link Button__
|
|
102
|
+
*
|
|
103
|
+
* Renders a link in the style of a button.
|
|
104
|
+
*
|
|
105
|
+
* - [Examples](https://atlassian.design/components/button/examples)
|
|
106
|
+
* - [Code](https://atlassian.design/components/button/code)
|
|
107
|
+
* - [Usage](https://atlassian.design/components/button/usage)
|
|
108
|
+
*/
|
|
109
|
+
var LinkButton = /*#__PURE__*/(0, _react.memo)(WithRef);
|
|
105
110
|
var _default = exports.default = LinkButton;
|
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.default = void 0;
|
|
8
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
10
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
|
-
var _react =
|
|
11
|
-
var
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _link = _interopRequireDefault(require("@atlaskit/primitives/link"));
|
|
12
13
|
var _useIconButton = _interopRequireDefault(require("./use-icon-button"));
|
|
13
14
|
var _excluded = ["analyticsContext", "autoFocus", "appearance", "spacing", "isDisabled", "isSelected", "icon", "children", "interactionName", "overlay", "onClick", "onMouseDownCapture", "onMouseUpCapture", "onKeyDownCapture", "onKeyUpCapture", "onTouchStartCapture", "onTouchEndCapture", "onPointerDownCapture", "onPointerUpCapture", "onClickCapture", "testId", "href"];
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* A link button renders a link in the style of a button.
|
|
18
|
-
*
|
|
19
|
-
* - [Examples](https://atlassian.design/components/button/examples)
|
|
20
|
-
* - [Code](https://atlassian.design/components/button/code)
|
|
21
|
-
* - [Usage](https://atlassian.design/components/button/usage)
|
|
22
|
-
*/
|
|
23
|
-
var LinkIconButton = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.default.forwardRef(function LinkIconButton(_ref, ref) {
|
|
15
|
+
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); }
|
|
16
|
+
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; }
|
|
17
|
+
var LinkIconButtonBase = function LinkIconButtonBase(_ref, ref) {
|
|
24
18
|
var analyticsContext = _ref.analyticsContext,
|
|
25
19
|
autoFocus = _ref.autoFocus,
|
|
26
20
|
appearance = _ref.appearance,
|
|
@@ -68,34 +62,45 @@ var LinkIconButton = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.defau
|
|
|
68
62
|
ref: ref,
|
|
69
63
|
spacing: spacing
|
|
70
64
|
});
|
|
71
|
-
return (
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
65
|
+
return /*#__PURE__*/_react.default.createElement(_link.default
|
|
66
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
67
|
+
, (0, _extends2.default)({}, rest, {
|
|
68
|
+
ref: baseProps.ref,
|
|
69
|
+
xcss: baseProps.xcss,
|
|
70
|
+
onClick: baseProps.onClick,
|
|
71
|
+
onMouseDownCapture: baseProps.onMouseDownCapture,
|
|
72
|
+
onMouseUpCapture: baseProps.onMouseUpCapture,
|
|
73
|
+
onKeyDownCapture: baseProps.onKeyDownCapture,
|
|
74
|
+
onKeyUpCapture: baseProps.onKeyUpCapture,
|
|
75
|
+
onTouchStartCapture: baseProps.onTouchStartCapture,
|
|
76
|
+
onTouchEndCapture: baseProps.onTouchEndCapture,
|
|
77
|
+
onPointerDownCapture: baseProps.onPointerDownCapture,
|
|
78
|
+
onPointerUpCapture: baseProps.onPointerUpCapture,
|
|
79
|
+
onClickCapture: baseProps.onClickCapture,
|
|
80
|
+
testId: testId
|
|
81
|
+
/**
|
|
82
|
+
* Disable link in an accessible way using `href`, `role`, and `aria-disabled`.
|
|
83
|
+
* @see https://a11y-guidelines.orange.com/en/articles/disable-elements/#disable-a-link
|
|
84
|
+
*/
|
|
85
|
+
// @ts-expect-error (`href` is required, we could make it optional but don't want to encourage this pattern elsewhere)
|
|
86
|
+
,
|
|
87
|
+
href: baseProps.isDisabled ? undefined : href,
|
|
88
|
+
role: baseProps.isDisabled ? 'link' : undefined,
|
|
89
|
+
"aria-disabled": baseProps.isDisabled === true ? true : undefined
|
|
90
|
+
}), baseProps.children);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// Workarounds to support generic types with forwardRef + memo
|
|
94
|
+
var WithRef = /*#__PURE__*/(0, _react.forwardRef)(LinkIconButtonBase);
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* __Link Icon Button__
|
|
98
|
+
*
|
|
99
|
+
* Renders a link in the style of an icon button.
|
|
100
|
+
*
|
|
101
|
+
* - [Examples](https://atlassian.design/components/button/examples)
|
|
102
|
+
* - [Code](https://atlassian.design/components/button/code)
|
|
103
|
+
* - [Usage](https://atlassian.design/components/button/usage)
|
|
104
|
+
*/
|
|
105
|
+
var LinkIconButton = /*#__PURE__*/(0, _react.memo)(WithRef);
|
|
101
106
|
var _default = exports.default = LinkIconButton;
|
|
@@ -115,7 +115,7 @@ var useButtonBase = function useButtonBase(_ref) {
|
|
|
115
115
|
action: 'clicked',
|
|
116
116
|
componentName: 'button',
|
|
117
117
|
packageName: "@atlaskit/button",
|
|
118
|
-
packageVersion: "16.
|
|
118
|
+
packageVersion: "16.12.0",
|
|
119
119
|
analyticsData: analyticsContext,
|
|
120
120
|
actionSubject: buttonType
|
|
121
121
|
});
|
|
@@ -118,7 +118,7 @@ var _default = exports.default = /*#__PURE__*/_react.default.forwardRef(function
|
|
|
118
118
|
action: 'clicked',
|
|
119
119
|
componentName: 'button',
|
|
120
120
|
packageName: "@atlaskit/button",
|
|
121
|
-
packageVersion: "16.
|
|
121
|
+
packageVersion: "16.12.0",
|
|
122
122
|
analyticsData: analyticsContext
|
|
123
123
|
});
|
|
124
124
|
|
|
@@ -5,21 +5,65 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.variants = exports.default = void 0;
|
|
8
|
+
exports.variants = exports.linkButtonVariants = exports.default = void 0;
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _add = _interopRequireDefault(require("@atlaskit/icon/glyph/add"));
|
|
11
13
|
var _button = _interopRequireDefault(require("../new-button/variants/default/button"));
|
|
12
14
|
var _link = _interopRequireDefault(require("../new-button/variants/default/link"));
|
|
15
|
+
var _link2 = _interopRequireDefault(require("../new-button/variants/icon/link"));
|
|
16
|
+
var _excluded = ["href", "children"],
|
|
17
|
+
_excluded2 = ["href", "children", "icon"]; // eslint-disable-next-line import/no-extraneous-dependencies
|
|
18
|
+
// import IconButton, {
|
|
19
|
+
// IconButtonProps,
|
|
20
|
+
// } from '../new-button/variants/icon/button';
|
|
13
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); }
|
|
14
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; }
|
|
15
|
-
/* eslint-disable @repo/internal/react/no-unsafe-spread-props */
|
|
16
|
-
|
|
17
23
|
// Add required default props to variants
|
|
18
|
-
var LinkButtonRender = /*#__PURE__*/(0, _react.forwardRef)(function (
|
|
24
|
+
var LinkButtonRender = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
25
|
+
var _ref$href = _ref.href,
|
|
26
|
+
href = _ref$href === void 0 ? 'home' : _ref$href,
|
|
27
|
+
children = _ref.children,
|
|
28
|
+
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
19
29
|
return /*#__PURE__*/_react.default.createElement(_link.default, (0, _extends2.default)({
|
|
20
30
|
ref: ref,
|
|
21
|
-
href:
|
|
22
|
-
},
|
|
31
|
+
href: href
|
|
32
|
+
}, rest), children);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// TODO: Enable icon button in tests once it's ready
|
|
36
|
+
// const IconButtonRender = forwardRef(
|
|
37
|
+
// (
|
|
38
|
+
// {
|
|
39
|
+
// children,
|
|
40
|
+
// icon = <AddIcon label="" />,
|
|
41
|
+
// ...rest
|
|
42
|
+
// }: Omit<IconButtonProps, 'icon'> & {
|
|
43
|
+
// icon?: IconButtonProps['icon'];
|
|
44
|
+
// },
|
|
45
|
+
// ref: React.Ref<HTMLButtonElement>,
|
|
46
|
+
// ) => (
|
|
47
|
+
// <IconButton ref={ref} icon={icon} {...rest}>
|
|
48
|
+
// {children}
|
|
49
|
+
// </IconButton>
|
|
50
|
+
// ),
|
|
51
|
+
// );
|
|
52
|
+
|
|
53
|
+
var LinkIconButtonRender = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
54
|
+
var _ref2$href = _ref2.href,
|
|
55
|
+
href = _ref2$href === void 0 ? '/home' : _ref2$href,
|
|
56
|
+
children = _ref2.children,
|
|
57
|
+
_ref2$icon = _ref2.icon,
|
|
58
|
+
icon = _ref2$icon === void 0 ? /*#__PURE__*/_react.default.createElement(_add.default, {
|
|
59
|
+
label: ""
|
|
60
|
+
}) : _ref2$icon,
|
|
61
|
+
rest = (0, _objectWithoutProperties2.default)(_ref2, _excluded2);
|
|
62
|
+
return /*#__PURE__*/_react.default.createElement(_link2.default, (0, _extends2.default)({
|
|
63
|
+
ref: ref,
|
|
64
|
+
icon: icon,
|
|
65
|
+
href: href
|
|
66
|
+
}, rest), children);
|
|
23
67
|
});
|
|
24
68
|
var variants = exports.variants = [{
|
|
25
69
|
name: 'Button',
|
|
@@ -29,5 +73,26 @@ var variants = exports.variants = [{
|
|
|
29
73
|
name: 'LinkButton',
|
|
30
74
|
Component: LinkButtonRender,
|
|
31
75
|
elementType: HTMLAnchorElement
|
|
32
|
-
}
|
|
33
|
-
|
|
76
|
+
}
|
|
77
|
+
// TODO: Enable icon buttons in tests once it's ready
|
|
78
|
+
// {
|
|
79
|
+
// name: 'IconButton',
|
|
80
|
+
// Component: IconButtonRender,
|
|
81
|
+
// elementType: HTMLButtonElement,
|
|
82
|
+
// },
|
|
83
|
+
// {
|
|
84
|
+
// name: 'LinkIconButton',
|
|
85
|
+
// Component: LinkIconButtonRender,
|
|
86
|
+
// elementType: HTMLAnchorElement,
|
|
87
|
+
// },
|
|
88
|
+
];
|
|
89
|
+
var _default = exports.default = variants;
|
|
90
|
+
var linkButtonVariants = exports.linkButtonVariants = [{
|
|
91
|
+
name: 'LinkButton',
|
|
92
|
+
Component: LinkButtonRender,
|
|
93
|
+
elementType: HTMLAnchorElement
|
|
94
|
+
}, {
|
|
95
|
+
name: 'LinkIconButton',
|
|
96
|
+
Component: LinkIconButtonRender,
|
|
97
|
+
elementType: HTMLAnchorElement
|
|
98
|
+
}];
|
|
@@ -14,7 +14,6 @@ import useDefaultButton from './use-default-button';
|
|
|
14
14
|
* - [Usage](https://atlassian.design/components/button/usage)
|
|
15
15
|
*/
|
|
16
16
|
const Button = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function Button({
|
|
17
|
-
// Button base
|
|
18
17
|
analyticsContext,
|
|
19
18
|
autoFocus,
|
|
20
19
|
appearance,
|
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import
|
|
2
|
+
import React, { forwardRef, memo } from 'react';
|
|
3
|
+
import UNSAFE_LINK from '@atlaskit/primitives/link';
|
|
4
4
|
import useDefaultButton from './use-default-button';
|
|
5
|
-
|
|
6
|
-
* __Link Button__
|
|
7
|
-
*
|
|
8
|
-
* A link button renders a link in the style of a button.
|
|
9
|
-
*
|
|
10
|
-
* - [Examples](https://atlassian.design/components/button/examples)
|
|
11
|
-
* - [Code](https://atlassian.design/components/button/code)
|
|
12
|
-
* - [Usage](https://atlassian.design/components/button/usage)
|
|
13
|
-
*/
|
|
14
|
-
const LinkButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function LinkButton({
|
|
15
|
-
// Button base
|
|
5
|
+
const LinkButtonBase = ({
|
|
16
6
|
analyticsContext,
|
|
17
7
|
autoFocus,
|
|
18
8
|
appearance,
|
|
@@ -38,7 +28,7 @@ const LinkButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(functi
|
|
|
38
28
|
testId,
|
|
39
29
|
href,
|
|
40
30
|
...rest
|
|
41
|
-
}, ref) {
|
|
31
|
+
}, ref) => {
|
|
42
32
|
const baseProps = useDefaultButton({
|
|
43
33
|
analyticsContext,
|
|
44
34
|
appearance,
|
|
@@ -65,34 +55,45 @@ const LinkButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(functi
|
|
|
65
55
|
shouldFitContainer,
|
|
66
56
|
spacing
|
|
67
57
|
});
|
|
68
|
-
return (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
58
|
+
return /*#__PURE__*/React.createElement(UNSAFE_LINK
|
|
59
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
60
|
+
, _extends({}, rest, {
|
|
61
|
+
ref: baseProps.ref,
|
|
62
|
+
xcss: baseProps.xcss,
|
|
63
|
+
onClick: baseProps.onClick,
|
|
64
|
+
onMouseDownCapture: baseProps.onMouseDownCapture,
|
|
65
|
+
onMouseUpCapture: baseProps.onMouseUpCapture,
|
|
66
|
+
onKeyDownCapture: baseProps.onKeyDownCapture,
|
|
67
|
+
onKeyUpCapture: baseProps.onKeyUpCapture,
|
|
68
|
+
onTouchStartCapture: baseProps.onTouchStartCapture,
|
|
69
|
+
onTouchEndCapture: baseProps.onTouchEndCapture,
|
|
70
|
+
onPointerDownCapture: baseProps.onPointerDownCapture,
|
|
71
|
+
onPointerUpCapture: baseProps.onPointerUpCapture,
|
|
72
|
+
onClickCapture: baseProps.onClickCapture,
|
|
73
|
+
testId: testId
|
|
74
|
+
/**
|
|
75
|
+
* Disable link in an accessible way using `href`, `role`, and `aria-disabled`.
|
|
76
|
+
* @see https://a11y-guidelines.orange.com/en/articles/disable-elements/#disable-a-link
|
|
77
|
+
*/
|
|
78
|
+
// @ts-expect-error (`href` is required, we could make it optional but don't want to encourage this pattern elsewhere)
|
|
79
|
+
,
|
|
80
|
+
href: baseProps.isDisabled ? undefined : href,
|
|
81
|
+
role: baseProps.isDisabled ? 'link' : undefined,
|
|
82
|
+
"aria-disabled": baseProps.isDisabled === true ? true : undefined
|
|
83
|
+
}), baseProps.children);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// Workarounds to support generic types with forwardRef + memo
|
|
87
|
+
const WithRef = /*#__PURE__*/forwardRef(LinkButtonBase);
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* __Link Button__
|
|
91
|
+
*
|
|
92
|
+
* Renders a link in the style of a button.
|
|
93
|
+
*
|
|
94
|
+
* - [Examples](https://atlassian.design/components/button/examples)
|
|
95
|
+
* - [Code](https://atlassian.design/components/button/code)
|
|
96
|
+
* - [Usage](https://atlassian.design/components/button/usage)
|
|
97
|
+
*/
|
|
98
|
+
const LinkButton = /*#__PURE__*/memo(WithRef);
|
|
98
99
|
export default LinkButton;
|
|
@@ -12,7 +12,6 @@ import useIconButton from './use-icon-button';
|
|
|
12
12
|
* - [Usage](https://atlassian.design/components/button/usage)
|
|
13
13
|
*/
|
|
14
14
|
const IconButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function Button({
|
|
15
|
-
// Button base
|
|
16
15
|
analyticsContext,
|
|
17
16
|
autoFocus,
|
|
18
17
|
appearance,
|
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import
|
|
2
|
+
import React, { forwardRef, memo } from 'react';
|
|
3
|
+
import UNSAFE_LINK from '@atlaskit/primitives/link';
|
|
4
4
|
import useIconButton from './use-icon-button';
|
|
5
|
-
|
|
6
|
-
* __Link Button__
|
|
7
|
-
*
|
|
8
|
-
* A link button renders a link in the style of a button.
|
|
9
|
-
*
|
|
10
|
-
* - [Examples](https://atlassian.design/components/button/examples)
|
|
11
|
-
* - [Code](https://atlassian.design/components/button/code)
|
|
12
|
-
* - [Usage](https://atlassian.design/components/button/usage)
|
|
13
|
-
*/
|
|
14
|
-
const LinkIconButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function LinkIconButton({
|
|
15
|
-
// Button base
|
|
5
|
+
const LinkIconButtonBase = ({
|
|
16
6
|
analyticsContext,
|
|
17
7
|
autoFocus,
|
|
18
8
|
appearance,
|
|
@@ -36,7 +26,7 @@ const LinkIconButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(fu
|
|
|
36
26
|
testId,
|
|
37
27
|
href,
|
|
38
28
|
...rest
|
|
39
|
-
}, ref) {
|
|
29
|
+
}, ref) => {
|
|
40
30
|
const baseProps = useIconButton({
|
|
41
31
|
analyticsContext,
|
|
42
32
|
appearance,
|
|
@@ -61,34 +51,45 @@ const LinkIconButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(fu
|
|
|
61
51
|
ref,
|
|
62
52
|
spacing
|
|
63
53
|
});
|
|
64
|
-
return (
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
54
|
+
return /*#__PURE__*/React.createElement(UNSAFE_LINK
|
|
55
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
56
|
+
, _extends({}, rest, {
|
|
57
|
+
ref: baseProps.ref,
|
|
58
|
+
xcss: baseProps.xcss,
|
|
59
|
+
onClick: baseProps.onClick,
|
|
60
|
+
onMouseDownCapture: baseProps.onMouseDownCapture,
|
|
61
|
+
onMouseUpCapture: baseProps.onMouseUpCapture,
|
|
62
|
+
onKeyDownCapture: baseProps.onKeyDownCapture,
|
|
63
|
+
onKeyUpCapture: baseProps.onKeyUpCapture,
|
|
64
|
+
onTouchStartCapture: baseProps.onTouchStartCapture,
|
|
65
|
+
onTouchEndCapture: baseProps.onTouchEndCapture,
|
|
66
|
+
onPointerDownCapture: baseProps.onPointerDownCapture,
|
|
67
|
+
onPointerUpCapture: baseProps.onPointerUpCapture,
|
|
68
|
+
onClickCapture: baseProps.onClickCapture,
|
|
69
|
+
testId: testId
|
|
70
|
+
/**
|
|
71
|
+
* Disable link in an accessible way using `href`, `role`, and `aria-disabled`.
|
|
72
|
+
* @see https://a11y-guidelines.orange.com/en/articles/disable-elements/#disable-a-link
|
|
73
|
+
*/
|
|
74
|
+
// @ts-expect-error (`href` is required, we could make it optional but don't want to encourage this pattern elsewhere)
|
|
75
|
+
,
|
|
76
|
+
href: baseProps.isDisabled ? undefined : href,
|
|
77
|
+
role: baseProps.isDisabled ? 'link' : undefined,
|
|
78
|
+
"aria-disabled": baseProps.isDisabled === true ? true : undefined
|
|
79
|
+
}), baseProps.children);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// Workarounds to support generic types with forwardRef + memo
|
|
83
|
+
const WithRef = /*#__PURE__*/forwardRef(LinkIconButtonBase);
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* __Link Icon Button__
|
|
87
|
+
*
|
|
88
|
+
* Renders a link in the style of an icon button.
|
|
89
|
+
*
|
|
90
|
+
* - [Examples](https://atlassian.design/components/button/examples)
|
|
91
|
+
* - [Code](https://atlassian.design/components/button/code)
|
|
92
|
+
* - [Usage](https://atlassian.design/components/button/usage)
|
|
93
|
+
*/
|
|
94
|
+
const LinkIconButton = /*#__PURE__*/memo(WithRef);
|
|
94
95
|
export default LinkIconButton;
|
|
@@ -103,7 +103,7 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
|
|
|
103
103
|
action: 'clicked',
|
|
104
104
|
componentName: 'button',
|
|
105
105
|
packageName: "@atlaskit/button",
|
|
106
|
-
packageVersion: "16.
|
|
106
|
+
packageVersion: "16.12.0",
|
|
107
107
|
analyticsData: analyticsContext
|
|
108
108
|
});
|
|
109
109
|
|