@atlaskit/button 16.11.0 → 16.13.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 +16 -0
- package/dist/cjs/entry-points/unsafe.js +14 -0
- package/dist/cjs/new-button/containers/split-button/split-button.js +4 -0
- package/dist/cjs/new-button/variants/default/button.js +1 -1
- package/dist/cjs/new-button/variants/default/link.js +49 -42
- package/dist/cjs/new-button/variants/icon/button.js +2 -0
- package/dist/cjs/new-button/variants/icon/link.js +49 -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/entry-points/unsafe.js +2 -0
- package/dist/es2019/new-button/containers/split-button/split-button.js +4 -0
- package/dist/es2019/new-button/variants/default/button.js +1 -2
- package/dist/es2019/new-button/variants/default/link.js +47 -44
- package/dist/es2019/new-button/variants/icon/button.js +2 -1
- package/dist/es2019/new-button/variants/icon/link.js +47 -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/entry-points/unsafe.js +2 -0
- package/dist/esm/new-button/containers/split-button/split-button.js +4 -0
- package/dist/esm/new-button/variants/default/button.js +1 -1
- package/dist/esm/new-button/variants/default/link.js +46 -42
- package/dist/esm/new-button/variants/icon/button.js +2 -0
- package/dist/esm/new-button/variants/icon/link.js +46 -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/entry-points/unsafe.d.ts +2 -0
- package/dist/types/new-button/containers/split-button/split-button.d.ts +4 -0
- package/dist/types/new-button/variants/default/button.d.ts +4 -6
- package/dist/types/new-button/variants/default/link.d.ts +12 -7
- package/dist/types/new-button/variants/icon/button.d.ts +5 -5
- package/dist/types/new-button/variants/icon/link.d.ts +13 -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/entry-points/unsafe.d.ts +2 -0
- package/dist/types-ts4.5/new-button/containers/split-button/split-button.d.ts +4 -0
- package/dist/types-ts4.5/new-button/variants/default/button.d.ts +4 -6
- package/dist/types-ts4.5/new-button/variants/default/link.d.ts +12 -7
- package/dist/types-ts4.5/new-button/variants/icon/button.d.ts +5 -5
- package/dist/types-ts4.5/new-button/variants/icon/link.d.ts +13 -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 +35 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/button
|
|
2
2
|
|
|
3
|
+
## 16.13.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#42603](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42603) [`48423992847`](https://bitbucket.org/atlassian/atlassian-frontend/commits/48423992847) - Add new Link Button variants to unsafe entrypoint for internal testing purposes.
|
|
8
|
+
|
|
9
|
+
## 16.12.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#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
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 16.11.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
|
@@ -28,6 +28,18 @@ Object.defineProperty(exports, "UNSAFE_ICON_BUTTON", {
|
|
|
28
28
|
return _button2.default;
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
|
+
Object.defineProperty(exports, "UNSAFE_LINK_BUTTON", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function get() {
|
|
34
|
+
return _link.default;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(exports, "UNSAFE_LINK_ICON_BUTTON", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function get() {
|
|
40
|
+
return _link2.default;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
31
43
|
Object.defineProperty(exports, "UNSAFE_SPLIT_BUTTON", {
|
|
32
44
|
enumerable: true,
|
|
33
45
|
get: function get() {
|
|
@@ -47,6 +59,8 @@ Object.defineProperty(exports, "UNSAFE_SPLIT_BUTTON_CONTEXT", {
|
|
|
47
59
|
}
|
|
48
60
|
});
|
|
49
61
|
var _button = _interopRequireDefault(require("../new-button/variants/default/button"));
|
|
62
|
+
var _link = _interopRequireDefault(require("../new-button/variants/default/link"));
|
|
50
63
|
var _button2 = _interopRequireDefault(require("../new-button/variants/icon/button"));
|
|
64
|
+
var _link2 = _interopRequireDefault(require("../new-button/variants/icon/link"));
|
|
51
65
|
var _splitButton = require("../new-button/containers/split-button");
|
|
52
66
|
var _splitButtonContext = require("../new-button/containers/split-button/split-button-context");
|
|
@@ -86,6 +86,10 @@ var SplitButtonContainer = exports.SplitButtonContainer = function SplitButtonCo
|
|
|
86
86
|
}, children);
|
|
87
87
|
};
|
|
88
88
|
/**
|
|
89
|
+
* __Split Button__
|
|
90
|
+
*
|
|
91
|
+
* @private __UNSAFE__ SplitButton is not yet safe for production use.
|
|
92
|
+
*
|
|
89
93
|
* TODO: Add description when adding docs
|
|
90
94
|
*/
|
|
91
95
|
var SplitButton = exports.SplitButton = function SplitButton(_ref3) {
|
|
@@ -14,7 +14,7 @@ var _excluded = ["analyticsContext", "autoFocus", "appearance", "spacing", "isDi
|
|
|
14
14
|
/**
|
|
15
15
|
* __Button__
|
|
16
16
|
*
|
|
17
|
-
* @
|
|
17
|
+
* @private __UNSAFE__ Button is not yet safe for production use.
|
|
18
18
|
*
|
|
19
19
|
* A button triggers an event or action.
|
|
20
20
|
*
|
|
@@ -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,47 @@ 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
|
+
* @private __UNSAFE__ LinkButton is not yet safe for production use.
|
|
104
|
+
*
|
|
105
|
+
* Renders a link in the style of a button.
|
|
106
|
+
*
|
|
107
|
+
* - [Examples](https://atlassian.design/components/button/examples)
|
|
108
|
+
* - [Code](https://atlassian.design/components/button/code)
|
|
109
|
+
* - [Usage](https://atlassian.design/components/button/usage)
|
|
110
|
+
*/
|
|
111
|
+
var LinkButton = /*#__PURE__*/(0, _react.memo)(WithRef);
|
|
105
112
|
var _default = exports.default = LinkButton;
|
|
@@ -14,6 +14,8 @@ var _excluded = ["analyticsContext", "autoFocus", "appearance", "spacing", "isDi
|
|
|
14
14
|
/**
|
|
15
15
|
* __Icon Button__
|
|
16
16
|
*
|
|
17
|
+
* @private __UNSAFE__ IconButton is not yet safe for production use.
|
|
18
|
+
*
|
|
17
19
|
* TODO: Description
|
|
18
20
|
*
|
|
19
21
|
* - [Examples](https://atlassian.design/components/button/examples)
|
|
@@ -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,47 @@ 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
|
+
* @private __UNSAFE__ LinkIconButton is not yet safe for production use.
|
|
100
|
+
*
|
|
101
|
+
* Renders a link in the style of an icon button.
|
|
102
|
+
*
|
|
103
|
+
* - [Examples](https://atlassian.design/components/button/examples)
|
|
104
|
+
* - [Code](https://atlassian.design/components/button/code)
|
|
105
|
+
* - [Usage](https://atlassian.design/components/button/usage)
|
|
106
|
+
*/
|
|
107
|
+
var LinkIconButton = /*#__PURE__*/(0, _react.memo)(WithRef);
|
|
101
108
|
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.13.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.13.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
|
+
}];
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { default as UNSAFE_BUTTON } from '../new-button/variants/default/button';
|
|
2
|
+
export { default as UNSAFE_LINK_BUTTON } from '../new-button/variants/default/link';
|
|
2
3
|
export { default as UNSAFE_ICON_BUTTON } from '../new-button/variants/icon/button';
|
|
4
|
+
export { default as UNSAFE_LINK_ICON_BUTTON } from '../new-button/variants/icon/link';
|
|
3
5
|
export { SplitButton as UNSAFE_SPLIT_BUTTON, SplitButtonContainer as UNSAFE_SPLIT_BUTTON_CONTAINER, Divider as UNSAFE_DIVIDER, getActions as UNSAFE_GET_ACTIONS } from '../new-button/containers/split-button';
|
|
4
6
|
export { SplitButtonContext as UNSAFE_SPLIT_BUTTON_CONTEXT } from '../new-button/containers/split-button/split-button-context';
|
|
@@ -81,6 +81,10 @@ export const SplitButtonContainer = ({
|
|
|
81
81
|
}, children);
|
|
82
82
|
};
|
|
83
83
|
/**
|
|
84
|
+
* __Split Button__
|
|
85
|
+
*
|
|
86
|
+
* @private __UNSAFE__ SplitButton is not yet safe for production use.
|
|
87
|
+
*
|
|
84
88
|
* TODO: Add description when adding docs
|
|
85
89
|
*/
|
|
86
90
|
export const SplitButton = ({
|
|
@@ -5,7 +5,7 @@ import useDefaultButton from './use-default-button';
|
|
|
5
5
|
/**
|
|
6
6
|
* __Button__
|
|
7
7
|
*
|
|
8
|
-
* @
|
|
8
|
+
* @private __UNSAFE__ Button is not yet safe for production use.
|
|
9
9
|
*
|
|
10
10
|
* A button triggers an event or action.
|
|
11
11
|
*
|
|
@@ -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,47 @@ 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
|
+
* @private __UNSAFE__ LinkButton is not yet safe for production use.
|
|
93
|
+
*
|
|
94
|
+
* Renders a link in the style of a button.
|
|
95
|
+
*
|
|
96
|
+
* - [Examples](https://atlassian.design/components/button/examples)
|
|
97
|
+
* - [Code](https://atlassian.design/components/button/code)
|
|
98
|
+
* - [Usage](https://atlassian.design/components/button/usage)
|
|
99
|
+
*/
|
|
100
|
+
const LinkButton = /*#__PURE__*/memo(WithRef);
|
|
98
101
|
export default LinkButton;
|
|
@@ -5,6 +5,8 @@ import useIconButton from './use-icon-button';
|
|
|
5
5
|
/**
|
|
6
6
|
* __Icon Button__
|
|
7
7
|
*
|
|
8
|
+
* @private __UNSAFE__ IconButton is not yet safe for production use.
|
|
9
|
+
*
|
|
8
10
|
* TODO: Description
|
|
9
11
|
*
|
|
10
12
|
* - [Examples](https://atlassian.design/components/button/examples)
|
|
@@ -12,7 +14,6 @@ import useIconButton from './use-icon-button';
|
|
|
12
14
|
* - [Usage](https://atlassian.design/components/button/usage)
|
|
13
15
|
*/
|
|
14
16
|
const IconButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function Button({
|
|
15
|
-
// Button base
|
|
16
17
|
analyticsContext,
|
|
17
18
|
autoFocus,
|
|
18
19
|
appearance,
|