@atlaskit/button 16.10.2 → 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 +16 -0
- package/dist/cjs/entry-points/new.js +8 -1
- package/dist/cjs/entry-points/unsafe.js +40 -1
- package/dist/cjs/new-button/containers/split-button/index.js +50 -0
- package/dist/cjs/new-button/containers/split-button/split-button-context.js +37 -0
- package/dist/cjs/new-button/containers/split-button/split-button.js +137 -0
- package/dist/cjs/new-button/containers/split-button/types.js +5 -0
- package/dist/cjs/new-button/containers/split-button/utils.js +23 -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 +19 -6
- package/dist/cjs/new-button/variants/shared/xcss.js +52 -10
- package/dist/cjs/old-button/shared/button-base.js +1 -1
- package/dist/cjs/utils/variants.js +73 -8
- package/dist/es2019/entry-points/new.js +2 -1
- package/dist/es2019/entry-points/unsafe.js +4 -1
- package/dist/es2019/new-button/containers/split-button/index.js +3 -0
- package/dist/es2019/new-button/containers/split-button/split-button-context.js +31 -0
- package/dist/es2019/new-button/containers/split-button/split-button.js +129 -0
- package/dist/es2019/new-button/containers/split-button/types.js +1 -0
- package/dist/es2019/new-button/containers/split-button/utils.js +12 -0
- 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 +19 -6
- package/dist/es2019/new-button/variants/shared/xcss.js +54 -10
- package/dist/es2019/old-button/shared/button-base.js +1 -1
- package/dist/es2019/utils/variants.js +69 -6
- package/dist/esm/entry-points/new.js +2 -1
- package/dist/esm/entry-points/unsafe.js +4 -1
- package/dist/esm/new-button/containers/split-button/index.js +3 -0
- package/dist/esm/new-button/containers/split-button/split-button-context.js +31 -0
- package/dist/esm/new-button/containers/split-button/split-button.js +131 -0
- package/dist/esm/new-button/containers/split-button/types.js +1 -0
- package/dist/esm/new-button/containers/split-button/utils.js +16 -0
- 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 +19 -6
- package/dist/esm/new-button/variants/shared/xcss.js +51 -10
- package/dist/esm/old-button/shared/button-base.js +1 -1
- package/dist/esm/utils/variants.js +75 -6
- package/dist/types/entry-points/new.d.ts +1 -0
- package/dist/types/entry-points/unsafe.d.ts +3 -0
- package/dist/types/new-button/containers/split-button/index.d.ts +3 -0
- package/dist/types/new-button/containers/split-button/split-button-context.d.ts +47 -0
- package/dist/types/new-button/containers/split-button/split-button.d.ts +47 -0
- package/dist/types/new-button/containers/split-button/types.d.ts +4 -0
- package/dist/types/new-button/containers/split-button/utils.d.ts +5 -0
- 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/shared/use-button-base.d.ts +1 -1
- package/dist/types/new-button/variants/shared/xcss.d.ts +14 -1
- package/dist/types/new-button/variants/types.d.ts +11 -1
- package/dist/types/old-button/types.d.ts +2 -2
- package/dist/types/utils/variants.d.ts +25 -3
- package/dist/types-ts4.5/containers/button-group.d.ts +12 -0
- package/dist/types-ts4.5/entry-points/button-group.d.ts +1 -0
- package/dist/types-ts4.5/entry-points/custom-theme-button.d.ts +2 -0
- package/dist/types-ts4.5/entry-points/loading-button.d.ts +2 -0
- package/dist/types-ts4.5/entry-points/new.d.ts +6 -0
- package/dist/types-ts4.5/entry-points/standard-button.d.ts +7 -0
- package/dist/types-ts4.5/entry-points/types.d.ts +4 -0
- package/dist/types-ts4.5/entry-points/unsafe.d.ts +4 -0
- package/dist/types-ts4.5/index.d.ts +8 -0
- package/dist/types-ts4.5/new-button/containers/split-button/index.d.ts +3 -0
- package/dist/types-ts4.5/new-button/containers/split-button/split-button-context.d.ts +47 -0
- package/dist/types-ts4.5/new-button/containers/split-button/split-button.d.ts +47 -0
- package/dist/types-ts4.5/new-button/containers/split-button/types.d.ts +4 -0
- package/dist/types-ts4.5/new-button/containers/split-button/utils.d.ts +5 -0
- package/dist/types-ts4.5/new-button/variants/default/button.d.ts +17 -0
- package/dist/types-ts4.5/new-button/variants/default/link.d.ts +20 -0
- package/dist/types-ts4.5/new-button/variants/default/types.d.ts +15 -0
- package/dist/types-ts4.5/new-button/variants/default/use-default-button.d.ts +15 -0
- package/dist/types-ts4.5/new-button/variants/icon/button.d.ts +15 -0
- package/dist/types-ts4.5/new-button/variants/icon/link.d.ts +20 -0
- package/dist/types-ts4.5/new-button/variants/icon/types.d.ts +8 -0
- package/dist/types-ts4.5/new-button/variants/icon/use-icon-button.d.ts +15 -0
- package/dist/types-ts4.5/new-button/variants/shared/block-events.d.ts +2 -0
- package/dist/types-ts4.5/new-button/variants/shared/colors.d.ts +18 -0
- package/dist/types-ts4.5/new-button/variants/shared/content.d.ts +13 -0
- package/dist/types-ts4.5/new-button/variants/shared/use-button-base.d.ts +37 -0
- package/dist/types-ts4.5/new-button/variants/shared/xcss.d.ts +31 -0
- package/dist/types-ts4.5/new-button/variants/types.d.ts +79 -0
- package/dist/types-ts4.5/old-button/button.d.ts +15 -0
- package/dist/types-ts4.5/old-button/custom-theme-button/custom-theme-button-types.d.ts +22 -0
- package/dist/types-ts4.5/old-button/custom-theme-button/custom-theme-button.d.ts +10 -0
- package/dist/types-ts4.5/old-button/custom-theme-button/index.d.ts +2 -0
- package/dist/types-ts4.5/old-button/custom-theme-button/theme.d.ts +21 -0
- package/dist/types-ts4.5/old-button/loading-button.d.ts +15 -0
- package/dist/types-ts4.5/old-button/shared/block-events.d.ts +4 -0
- package/dist/types-ts4.5/old-button/shared/button-base.d.ts +10 -0
- package/dist/types-ts4.5/old-button/shared/colors.d.ts +23 -0
- package/dist/types-ts4.5/old-button/shared/css.d.ts +22 -0
- package/dist/types-ts4.5/old-button/shared/get-if-visually-hidden-children.d.ts +2 -0
- package/dist/types-ts4.5/old-button/shared/get-is-only-single-icon.d.ts +2 -0
- package/dist/types-ts4.5/old-button/shared/loading-spinner.d.ts +5 -0
- package/dist/types-ts4.5/old-button/types.d.ts +94 -0
- package/dist/types-ts4.5/utils/appearances.d.ts +3 -0
- package/dist/types-ts4.5/utils/spacing.d.ts +3 -0
- package/dist/types-ts4.5/utils/variants.d.ts +37 -0
- package/package.json +4 -3
- package/tmp/api-report-tmp.d.ts +133 -0
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
3
|
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"];
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import
|
|
4
|
+
import React, { forwardRef, memo } from 'react';
|
|
5
|
+
import UNSAFE_LINK from '@atlaskit/primitives/link';
|
|
6
6
|
import useDefaultButton from './use-default-button';
|
|
7
|
-
|
|
8
|
-
* __Link Button__
|
|
9
|
-
*
|
|
10
|
-
* A link button renders a link in the style of a button.
|
|
11
|
-
*
|
|
12
|
-
* - [Examples](https://atlassian.design/components/button/examples)
|
|
13
|
-
* - [Code](https://atlassian.design/components/button/code)
|
|
14
|
-
* - [Usage](https://atlassian.design/components/button/usage)
|
|
15
|
-
*/
|
|
16
|
-
var LinkButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function LinkButton(_ref, ref) {
|
|
7
|
+
var LinkButtonBase = function LinkButtonBase(_ref, ref) {
|
|
17
8
|
var analyticsContext = _ref.analyticsContext,
|
|
18
9
|
autoFocus = _ref.autoFocus,
|
|
19
10
|
appearance = _ref.appearance,
|
|
@@ -65,34 +56,45 @@ var LinkButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function
|
|
|
65
56
|
shouldFitContainer: shouldFitContainer,
|
|
66
57
|
spacing: spacing
|
|
67
58
|
});
|
|
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
|
-
|
|
59
|
+
return /*#__PURE__*/React.createElement(UNSAFE_LINK
|
|
60
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
61
|
+
, _extends({}, rest, {
|
|
62
|
+
ref: baseProps.ref,
|
|
63
|
+
xcss: baseProps.xcss,
|
|
64
|
+
onClick: baseProps.onClick,
|
|
65
|
+
onMouseDownCapture: baseProps.onMouseDownCapture,
|
|
66
|
+
onMouseUpCapture: baseProps.onMouseUpCapture,
|
|
67
|
+
onKeyDownCapture: baseProps.onKeyDownCapture,
|
|
68
|
+
onKeyUpCapture: baseProps.onKeyUpCapture,
|
|
69
|
+
onTouchStartCapture: baseProps.onTouchStartCapture,
|
|
70
|
+
onTouchEndCapture: baseProps.onTouchEndCapture,
|
|
71
|
+
onPointerDownCapture: baseProps.onPointerDownCapture,
|
|
72
|
+
onPointerUpCapture: baseProps.onPointerUpCapture,
|
|
73
|
+
onClickCapture: baseProps.onClickCapture,
|
|
74
|
+
testId: testId
|
|
75
|
+
/**
|
|
76
|
+
* Disable link in an accessible way using `href`, `role`, and `aria-disabled`.
|
|
77
|
+
* @see https://a11y-guidelines.orange.com/en/articles/disable-elements/#disable-a-link
|
|
78
|
+
*/
|
|
79
|
+
// @ts-expect-error (`href` is required, we could make it optional but don't want to encourage this pattern elsewhere)
|
|
80
|
+
,
|
|
81
|
+
href: baseProps.isDisabled ? undefined : href,
|
|
82
|
+
role: baseProps.isDisabled ? 'link' : undefined,
|
|
83
|
+
"aria-disabled": baseProps.isDisabled === true ? true : undefined
|
|
84
|
+
}), baseProps.children);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// Workarounds to support generic types with forwardRef + memo
|
|
88
|
+
var WithRef = /*#__PURE__*/forwardRef(LinkButtonBase);
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* __Link Button__
|
|
92
|
+
*
|
|
93
|
+
* Renders a link in the style of a button.
|
|
94
|
+
*
|
|
95
|
+
* - [Examples](https://atlassian.design/components/button/examples)
|
|
96
|
+
* - [Code](https://atlassian.design/components/button/code)
|
|
97
|
+
* - [Usage](https://atlassian.design/components/button/usage)
|
|
98
|
+
*/
|
|
99
|
+
var LinkButton = /*#__PURE__*/memo(WithRef);
|
|
98
100
|
export default LinkButton;
|
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
3
|
var _excluded = ["analyticsContext", "autoFocus", "appearance", "spacing", "isDisabled", "isSelected", "icon", "children", "interactionName", "overlay", "onClick", "onMouseDownCapture", "onMouseUpCapture", "onKeyDownCapture", "onKeyUpCapture", "onTouchStartCapture", "onTouchEndCapture", "onPointerDownCapture", "onPointerUpCapture", "onClickCapture", "testId", "href"];
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import
|
|
4
|
+
import React, { forwardRef, memo } from 'react';
|
|
5
|
+
import UNSAFE_LINK from '@atlaskit/primitives/link';
|
|
6
6
|
import useIconButton from './use-icon-button';
|
|
7
|
-
|
|
8
|
-
* __Link Button__
|
|
9
|
-
*
|
|
10
|
-
* A link button renders a link in the style of a button.
|
|
11
|
-
*
|
|
12
|
-
* - [Examples](https://atlassian.design/components/button/examples)
|
|
13
|
-
* - [Code](https://atlassian.design/components/button/code)
|
|
14
|
-
* - [Usage](https://atlassian.design/components/button/usage)
|
|
15
|
-
*/
|
|
16
|
-
var LinkIconButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function LinkIconButton(_ref, ref) {
|
|
7
|
+
var LinkIconButtonBase = function LinkIconButtonBase(_ref, ref) {
|
|
17
8
|
var analyticsContext = _ref.analyticsContext,
|
|
18
9
|
autoFocus = _ref.autoFocus,
|
|
19
10
|
appearance = _ref.appearance,
|
|
@@ -61,34 +52,45 @@ var LinkIconButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(func
|
|
|
61
52
|
ref: ref,
|
|
62
53
|
spacing: spacing
|
|
63
54
|
});
|
|
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
|
-
|
|
55
|
+
return /*#__PURE__*/React.createElement(UNSAFE_LINK
|
|
56
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
57
|
+
, _extends({}, rest, {
|
|
58
|
+
ref: baseProps.ref,
|
|
59
|
+
xcss: baseProps.xcss,
|
|
60
|
+
onClick: baseProps.onClick,
|
|
61
|
+
onMouseDownCapture: baseProps.onMouseDownCapture,
|
|
62
|
+
onMouseUpCapture: baseProps.onMouseUpCapture,
|
|
63
|
+
onKeyDownCapture: baseProps.onKeyDownCapture,
|
|
64
|
+
onKeyUpCapture: baseProps.onKeyUpCapture,
|
|
65
|
+
onTouchStartCapture: baseProps.onTouchStartCapture,
|
|
66
|
+
onTouchEndCapture: baseProps.onTouchEndCapture,
|
|
67
|
+
onPointerDownCapture: baseProps.onPointerDownCapture,
|
|
68
|
+
onPointerUpCapture: baseProps.onPointerUpCapture,
|
|
69
|
+
onClickCapture: baseProps.onClickCapture,
|
|
70
|
+
testId: testId
|
|
71
|
+
/**
|
|
72
|
+
* Disable link in an accessible way using `href`, `role`, and `aria-disabled`.
|
|
73
|
+
* @see https://a11y-guidelines.orange.com/en/articles/disable-elements/#disable-a-link
|
|
74
|
+
*/
|
|
75
|
+
// @ts-expect-error (`href` is required, we could make it optional but don't want to encourage this pattern elsewhere)
|
|
76
|
+
,
|
|
77
|
+
href: baseProps.isDisabled ? undefined : href,
|
|
78
|
+
role: baseProps.isDisabled ? 'link' : undefined,
|
|
79
|
+
"aria-disabled": baseProps.isDisabled === true ? true : undefined
|
|
80
|
+
}), baseProps.children);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// Workarounds to support generic types with forwardRef + memo
|
|
84
|
+
var WithRef = /*#__PURE__*/forwardRef(LinkIconButtonBase);
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* __Link Icon Button__
|
|
88
|
+
*
|
|
89
|
+
* Renders a link in the style of an icon button.
|
|
90
|
+
*
|
|
91
|
+
* - [Examples](https://atlassian.design/components/button/examples)
|
|
92
|
+
* - [Code](https://atlassian.design/components/button/code)
|
|
93
|
+
* - [Usage](https://atlassian.design/components/button/usage)
|
|
94
|
+
*/
|
|
95
|
+
var LinkIconButton = /*#__PURE__*/memo(WithRef);
|
|
94
96
|
export default LinkIconButton;
|
|
@@ -8,6 +8,7 @@ import useAutoFocus from '@atlaskit/ds-lib/use-auto-focus';
|
|
|
8
8
|
// eslint-disable-next-line no-duplicate-imports
|
|
9
9
|
import InteractionContext from '@atlaskit/interaction-context';
|
|
10
10
|
import { Box, xcss } from '@atlaskit/primitives';
|
|
11
|
+
import { useSplitButtonContext } from '../../containers/split-button/split-button-context';
|
|
11
12
|
import blockEvents from './block-events';
|
|
12
13
|
import { getXCSS } from './xcss';
|
|
13
14
|
|
|
@@ -40,13 +41,13 @@ var overlayStyles = xcss({
|
|
|
40
41
|
var useButtonBase = function useButtonBase(_ref) {
|
|
41
42
|
var analyticsContext = _ref.analyticsContext,
|
|
42
43
|
_ref$appearance = _ref.appearance,
|
|
43
|
-
|
|
44
|
+
propAppearance = _ref$appearance === void 0 ? 'default' : _ref$appearance,
|
|
44
45
|
_ref$autoFocus = _ref.autoFocus,
|
|
45
46
|
autoFocus = _ref$autoFocus === void 0 ? false : _ref$autoFocus,
|
|
46
47
|
buttonType = _ref.buttonType,
|
|
47
48
|
interactionName = _ref.interactionName,
|
|
48
49
|
_ref$isDisabled = _ref.isDisabled,
|
|
49
|
-
|
|
50
|
+
propIsDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
|
|
50
51
|
_ref$isSelected = _ref.isSelected,
|
|
51
52
|
isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected,
|
|
52
53
|
_ref$isIconButton = _ref.isIconButton,
|
|
@@ -72,8 +73,16 @@ var useButtonBase = function useButtonBase(_ref) {
|
|
|
72
73
|
_ref$shouldFitContain = _ref.shouldFitContainer,
|
|
73
74
|
shouldFitContainer = _ref$shouldFitContain === void 0 ? false : _ref$shouldFitContain,
|
|
74
75
|
_ref$spacing = _ref.spacing,
|
|
75
|
-
|
|
76
|
+
propSpacing = _ref$spacing === void 0 ? 'default' : _ref$spacing;
|
|
76
77
|
var ourRef = useRef();
|
|
78
|
+
var splitButtonContext = useSplitButtonContext();
|
|
79
|
+
var isSplitButton = Boolean(splitButtonContext);
|
|
80
|
+
var isNavigationSplitButton = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.isNavigationSplitButton) || false;
|
|
81
|
+
var appearance = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.appearance) || propAppearance;
|
|
82
|
+
var spacing = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.spacing) || propSpacing;
|
|
83
|
+
var isDisabled = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.isDisabled) || propIsDisabled;
|
|
84
|
+
var isHighlighted = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.isHighlighted) || false;
|
|
85
|
+
var isActiveOverSelected = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.isActiveOverSelected) || false;
|
|
77
86
|
var setRef = useCallback(function (node) {
|
|
78
87
|
ourRef.current = node;
|
|
79
88
|
if (ref === null) {
|
|
@@ -98,7 +107,7 @@ var useButtonBase = function useButtonBase(_ref) {
|
|
|
98
107
|
action: 'clicked',
|
|
99
108
|
componentName: 'button',
|
|
100
109
|
packageName: "@atlaskit/button",
|
|
101
|
-
packageVersion: "16.
|
|
110
|
+
packageVersion: "16.12.0",
|
|
102
111
|
analyticsData: analyticsContext,
|
|
103
112
|
actionSubject: buttonType
|
|
104
113
|
});
|
|
@@ -108,14 +117,18 @@ var useButtonBase = function useButtonBase(_ref) {
|
|
|
108
117
|
spacing: spacing,
|
|
109
118
|
isDisabled: isDisabled,
|
|
110
119
|
isSelected: isSelected,
|
|
120
|
+
isHighlighted: isHighlighted,
|
|
121
|
+
isActiveOverSelected: isActiveOverSelected,
|
|
111
122
|
shouldFitContainer: shouldFitContainer,
|
|
112
123
|
isIconButton: isIconButton,
|
|
113
124
|
hasOverlay: Boolean(overlay),
|
|
114
125
|
isLink: buttonType === 'link',
|
|
115
126
|
hasIconBefore: hasIconBefore,
|
|
116
|
-
hasIconAfter: hasIconAfter
|
|
127
|
+
hasIconAfter: hasIconAfter,
|
|
128
|
+
isSplit: isSplitButton,
|
|
129
|
+
isNavigationSplit: isNavigationSplitButton
|
|
117
130
|
});
|
|
118
|
-
}, [appearance, buttonType, spacing, isDisabled, isSelected, isIconButton, shouldFitContainer, overlay, hasIconBefore, hasIconAfter]);
|
|
131
|
+
}, [appearance, buttonType, spacing, isDisabled, isSelected, isHighlighted, isActiveOverSelected, isIconButton, shouldFitContainer, overlay, hasIconBefore, hasIconAfter, isSplitButton, isNavigationSplitButton]);
|
|
119
132
|
var isEffectivelyDisabled = isDisabled || Boolean(overlay);
|
|
120
133
|
return _objectSpread({
|
|
121
134
|
ref: setRef,
|
|
@@ -5,7 +5,7 @@ import { xcss } from '@atlaskit/primitives';
|
|
|
5
5
|
import { fontSize as getFontSize } from '@atlaskit/theme/constants';
|
|
6
6
|
import colors from './colors';
|
|
7
7
|
var fontSize = getFontSize();
|
|
8
|
-
var heights = {
|
|
8
|
+
export var heights = {
|
|
9
9
|
default: "".concat(32 / fontSize, "em"),
|
|
10
10
|
compact: "".concat(24 / fontSize, "em"),
|
|
11
11
|
none: 'auto'
|
|
@@ -34,6 +34,19 @@ var verticalAlign = {
|
|
|
34
34
|
compact: 'middle',
|
|
35
35
|
none: 'baseline'
|
|
36
36
|
};
|
|
37
|
+
var splitBorderStyles = {
|
|
38
|
+
':first-of-type': {
|
|
39
|
+
borderTopRightRadius: 0,
|
|
40
|
+
borderBottomRightRadius: 0
|
|
41
|
+
},
|
|
42
|
+
':last-of-type': {
|
|
43
|
+
borderTopLeftRadius: 0,
|
|
44
|
+
borderBottomLeftRadius: 0
|
|
45
|
+
},
|
|
46
|
+
':focus-visible': {
|
|
47
|
+
zIndex: 1
|
|
48
|
+
}
|
|
49
|
+
};
|
|
37
50
|
function getColor(_ref) {
|
|
38
51
|
var group = _ref.group,
|
|
39
52
|
key = _ref.key;
|
|
@@ -45,11 +58,13 @@ function getColors(_ref2) {
|
|
|
45
58
|
interactionState = _ref2$interactionStat === void 0 ? 'default' : _ref2$interactionStat,
|
|
46
59
|
isDisabled = _ref2.isDisabled,
|
|
47
60
|
isSelected = _ref2.isSelected,
|
|
61
|
+
isHighlighted = _ref2.isHighlighted,
|
|
62
|
+
isActiveOverSelected = _ref2.isActiveOverSelected,
|
|
48
63
|
hasOverlay = _ref2.hasOverlay;
|
|
49
64
|
var key = interactionState;
|
|
50
65
|
// Overlay does not change color on interaction, revert to 'default' or resting state
|
|
51
66
|
key = hasOverlay ? 'default' : key;
|
|
52
|
-
key = isSelected ? 'selected' : key;
|
|
67
|
+
key = isSelected || isHighlighted ? isActiveOverSelected ? 'active' : 'selected' : key;
|
|
53
68
|
// Disabled colors overrule everything else
|
|
54
69
|
key = isDisabled ? 'disabled' : key;
|
|
55
70
|
return {
|
|
@@ -68,27 +83,51 @@ export function getXCSS(_ref3) {
|
|
|
68
83
|
spacing = _ref3.spacing,
|
|
69
84
|
isDisabled = _ref3.isDisabled,
|
|
70
85
|
isSelected = _ref3.isSelected,
|
|
86
|
+
isHighlighted = _ref3.isHighlighted,
|
|
87
|
+
isActiveOverSelected = _ref3.isActiveOverSelected,
|
|
71
88
|
isIconButton = _ref3.isIconButton,
|
|
72
89
|
shouldFitContainer = _ref3.shouldFitContainer,
|
|
73
90
|
isLink = _ref3.isLink,
|
|
91
|
+
isSplit = _ref3.isSplit,
|
|
92
|
+
isNavigationSplit = _ref3.isNavigationSplit,
|
|
74
93
|
hasOverlay = _ref3.hasOverlay,
|
|
75
94
|
hasIconBefore = _ref3.hasIconBefore,
|
|
76
95
|
hasIconAfter = _ref3.hasIconAfter;
|
|
77
96
|
var baseColors = getColors({
|
|
78
97
|
appearance: appearance,
|
|
79
98
|
isSelected: isSelected,
|
|
99
|
+
isHighlighted: isHighlighted,
|
|
100
|
+
isActiveOverSelected: isActiveOverSelected,
|
|
80
101
|
isDisabled: isDisabled
|
|
81
102
|
});
|
|
82
103
|
var combinedBaseColorStyles = isLink ? _objectSpread(_objectSpread({}, baseColors), {}, {
|
|
83
104
|
textDecoration: 'none',
|
|
84
105
|
// Disabling visited styles (by re-declaring the base colors)
|
|
85
106
|
':visited': baseColors
|
|
107
|
+
}) : isNavigationSplit && !isSelected ? _objectSpread(_objectSpread({}, baseColors), {}, {
|
|
108
|
+
backgroundColor: 'color.background.neutral.subtle'
|
|
86
109
|
}) : baseColors;
|
|
87
110
|
var height = heights[spacing];
|
|
88
111
|
var width = shouldFitContainer ? '100%' : 'auto';
|
|
89
|
-
width = isIconButton ? height : width;
|
|
90
|
-
var
|
|
91
|
-
var
|
|
112
|
+
width = isIconButton ? isNavigationSplit ? '24px' : height : width;
|
|
113
|
+
var defaultPaddingInlineStart = paddingInline[spacing][hasIconBefore ? 'withIcon' : 'default'];
|
|
114
|
+
var defaultPaddingInlineEnd = paddingInline[spacing][hasIconAfter ? 'withIcon' : 'default'];
|
|
115
|
+
var splitButtonStyles = isSplit ? splitBorderStyles : {};
|
|
116
|
+
var getNavigationSplitButtonPaddings = function getNavigationSplitButtonPaddings() {
|
|
117
|
+
if (isNavigationSplit) {
|
|
118
|
+
return {
|
|
119
|
+
paddingInlineStart: 'space.075',
|
|
120
|
+
paddingInlineEnd: 'space.075'
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
paddingInlineStart: isIconButton ? 'space.0' : defaultPaddingInlineStart,
|
|
125
|
+
paddingInlineEnd: isIconButton ? 'space.0' : defaultPaddingInlineEnd
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
var _getNavigationSplitBu = getNavigationSplitButtonPaddings(),
|
|
129
|
+
paddingInlineStart = _getNavigationSplitBu.paddingInlineStart,
|
|
130
|
+
paddingInlineEnd = _getNavigationSplitBu.paddingInlineEnd;
|
|
92
131
|
return xcss(_objectSpread(_objectSpread(_objectSpread({
|
|
93
132
|
alignItems: 'center',
|
|
94
133
|
borderWidth: 'border.width.0',
|
|
@@ -107,8 +146,8 @@ export function getXCSS(_ref3) {
|
|
|
107
146
|
whiteSpace: 'nowrap',
|
|
108
147
|
height: height,
|
|
109
148
|
paddingBlock: 'space.0',
|
|
110
|
-
paddingInlineStart:
|
|
111
|
-
paddingInlineEnd:
|
|
149
|
+
paddingInlineStart: paddingInlineStart,
|
|
150
|
+
paddingInlineEnd: paddingInlineEnd,
|
|
112
151
|
columnGap: gap[spacing],
|
|
113
152
|
verticalAlign: verticalAlign[spacing],
|
|
114
153
|
width: width,
|
|
@@ -119,7 +158,8 @@ export function getXCSS(_ref3) {
|
|
|
119
158
|
} : {}), {}, {
|
|
120
159
|
':hover': _objectSpread(_objectSpread({}, getColors({
|
|
121
160
|
appearance: appearance,
|
|
122
|
-
isSelected: isSelected,
|
|
161
|
+
isSelected: isNavigationSplit && !isSelected ? false : isSelected,
|
|
162
|
+
isActiveOverSelected: isActiveOverSelected,
|
|
123
163
|
isDisabled: isDisabled,
|
|
124
164
|
interactionState: 'hover',
|
|
125
165
|
hasOverlay: hasOverlay
|
|
@@ -130,7 +170,8 @@ export function getXCSS(_ref3) {
|
|
|
130
170
|
}),
|
|
131
171
|
':active': _objectSpread(_objectSpread({}, getColors({
|
|
132
172
|
appearance: appearance,
|
|
133
|
-
isSelected: isSelected,
|
|
173
|
+
isSelected: isNavigationSplit && !isSelected ? false : isSelected,
|
|
174
|
+
isActiveOverSelected: isActiveOverSelected,
|
|
134
175
|
isDisabled: isDisabled,
|
|
135
176
|
interactionState: 'active',
|
|
136
177
|
hasOverlay: hasOverlay
|
|
@@ -138,5 +179,5 @@ export function getXCSS(_ref3) {
|
|
|
138
179
|
// background, box-shadow
|
|
139
180
|
transitionDuration: '0s, 0s'
|
|
140
181
|
})
|
|
141
|
-
}));
|
|
182
|
+
}, splitButtonStyles));
|
|
142
183
|
}
|
|
@@ -109,7 +109,7 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
|
|
|
109
109
|
action: 'clicked',
|
|
110
110
|
componentName: 'button',
|
|
111
111
|
packageName: "@atlaskit/button",
|
|
112
|
-
packageVersion: "16.
|
|
112
|
+
packageVersion: "16.12.0",
|
|
113
113
|
analyticsData: analyticsContext
|
|
114
114
|
});
|
|
115
115
|
|
|
@@ -1,14 +1,61 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["href", "children"],
|
|
4
|
+
_excluded2 = ["href", "children", "icon"];
|
|
3
5
|
import React, { forwardRef } from 'react';
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
8
|
+
import AddIcon from '@atlaskit/icon/glyph/add';
|
|
4
9
|
import Button from '../new-button/variants/default/button';
|
|
5
10
|
import LinkButton from '../new-button/variants/default/link';
|
|
11
|
+
// import IconButton, {
|
|
12
|
+
// IconButtonProps,
|
|
13
|
+
// } from '../new-button/variants/icon/button';
|
|
14
|
+
import LinkIconButton from '../new-button/variants/icon/link';
|
|
6
15
|
// Add required default props to variants
|
|
7
|
-
var LinkButtonRender = /*#__PURE__*/forwardRef(function (
|
|
16
|
+
var LinkButtonRender = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
17
|
+
var _ref$href = _ref.href,
|
|
18
|
+
href = _ref$href === void 0 ? 'home' : _ref$href,
|
|
19
|
+
children = _ref.children,
|
|
20
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
8
21
|
return /*#__PURE__*/React.createElement(LinkButton, _extends({
|
|
9
22
|
ref: ref,
|
|
10
|
-
href:
|
|
11
|
-
},
|
|
23
|
+
href: href
|
|
24
|
+
}, rest), children);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// TODO: Enable icon button in tests once it's ready
|
|
28
|
+
// const IconButtonRender = forwardRef(
|
|
29
|
+
// (
|
|
30
|
+
// {
|
|
31
|
+
// children,
|
|
32
|
+
// icon = <AddIcon label="" />,
|
|
33
|
+
// ...rest
|
|
34
|
+
// }: Omit<IconButtonProps, 'icon'> & {
|
|
35
|
+
// icon?: IconButtonProps['icon'];
|
|
36
|
+
// },
|
|
37
|
+
// ref: React.Ref<HTMLButtonElement>,
|
|
38
|
+
// ) => (
|
|
39
|
+
// <IconButton ref={ref} icon={icon} {...rest}>
|
|
40
|
+
// {children}
|
|
41
|
+
// </IconButton>
|
|
42
|
+
// ),
|
|
43
|
+
// );
|
|
44
|
+
|
|
45
|
+
var LinkIconButtonRender = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
46
|
+
var _ref2$href = _ref2.href,
|
|
47
|
+
href = _ref2$href === void 0 ? '/home' : _ref2$href,
|
|
48
|
+
children = _ref2.children,
|
|
49
|
+
_ref2$icon = _ref2.icon,
|
|
50
|
+
icon = _ref2$icon === void 0 ? /*#__PURE__*/React.createElement(AddIcon, {
|
|
51
|
+
label: ""
|
|
52
|
+
}) : _ref2$icon,
|
|
53
|
+
rest = _objectWithoutProperties(_ref2, _excluded2);
|
|
54
|
+
return /*#__PURE__*/React.createElement(LinkIconButton, _extends({
|
|
55
|
+
ref: ref,
|
|
56
|
+
icon: icon,
|
|
57
|
+
href: href
|
|
58
|
+
}, rest), children);
|
|
12
59
|
});
|
|
13
60
|
export var variants = [{
|
|
14
61
|
name: 'Button',
|
|
@@ -18,5 +65,27 @@ export var variants = [{
|
|
|
18
65
|
name: 'LinkButton',
|
|
19
66
|
Component: LinkButtonRender,
|
|
20
67
|
elementType: HTMLAnchorElement
|
|
21
|
-
}
|
|
22
|
-
|
|
68
|
+
}
|
|
69
|
+
// TODO: Enable icon buttons in tests once it's ready
|
|
70
|
+
// {
|
|
71
|
+
// name: 'IconButton',
|
|
72
|
+
// Component: IconButtonRender,
|
|
73
|
+
// elementType: HTMLButtonElement,
|
|
74
|
+
// },
|
|
75
|
+
// {
|
|
76
|
+
// name: 'LinkIconButton',
|
|
77
|
+
// Component: LinkIconButtonRender,
|
|
78
|
+
// elementType: HTMLAnchorElement,
|
|
79
|
+
// },
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
export default variants;
|
|
83
|
+
export var linkButtonVariants = [{
|
|
84
|
+
name: 'LinkButton',
|
|
85
|
+
Component: LinkButtonRender,
|
|
86
|
+
elementType: HTMLAnchorElement
|
|
87
|
+
}, {
|
|
88
|
+
name: 'LinkIconButton',
|
|
89
|
+
Component: LinkIconButtonRender,
|
|
90
|
+
elementType: HTMLAnchorElement
|
|
91
|
+
}];
|
|
@@ -2,4 +2,5 @@ export { default, type ButtonProps, } from '../new-button/variants/default/butto
|
|
|
2
2
|
export { default as LinkButton, type LinkButtonProps, } from '../new-button/variants/default/link';
|
|
3
3
|
export { default as IconButton, type IconButtonProps, } from '../new-button/variants/icon/button';
|
|
4
4
|
export { default as LinkIconButton, type LinkIconButtonProps, } from '../new-button/variants/icon/link';
|
|
5
|
+
export { SplitButton } from '../new-button/containers/split-button';
|
|
5
6
|
export type { Appearance, Spacing } from '../new-button/variants/types';
|
|
@@ -1 +1,4 @@
|
|
|
1
1
|
export { default as UNSAFE_BUTTON } from '../new-button/variants/default/button';
|
|
2
|
+
export { default as UNSAFE_ICON_BUTTON } from '../new-button/variants/icon/button';
|
|
3
|
+
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
|
+
export { SplitButtonContext as UNSAFE_SPLIT_BUTTON_CONTEXT } from '../new-button/containers/split-button/split-button-context';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { SplitButtonAppearance, SplitButtonSpacing } from './types';
|
|
3
|
+
type NavigationSplitButtonContextProps = {
|
|
4
|
+
appearance: 'navigation';
|
|
5
|
+
isHighlighted: boolean;
|
|
6
|
+
};
|
|
7
|
+
type MainSplitButtonContextProps = {
|
|
8
|
+
appearance: SplitButtonAppearance;
|
|
9
|
+
spacing: SplitButtonSpacing;
|
|
10
|
+
isDisabled: boolean;
|
|
11
|
+
};
|
|
12
|
+
type SplitButtonContextProps = NavigationSplitButtonContextProps | MainSplitButtonContextProps;
|
|
13
|
+
/**
|
|
14
|
+
* TODO: Add jsdoc
|
|
15
|
+
*/
|
|
16
|
+
export declare const SplitButtonContext: import("react").Context<SplitButtonContextProps | undefined>;
|
|
17
|
+
type UseSplitButtonContext = {
|
|
18
|
+
appearance: SplitButtonAppearance | 'subtle';
|
|
19
|
+
spacing: SplitButtonSpacing;
|
|
20
|
+
isDisabled: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* isSelected state has limited relevance (e.g. dropdown-menu trigger button).
|
|
23
|
+
* There is no isSelected state for color variants (e.g. primary, danger, warning).
|
|
24
|
+
* Hens we provide ability to override the isSelected state with isActiveOverSelected to display `active` state instead of `selected` state.
|
|
25
|
+
*/
|
|
26
|
+
isActiveOverSelected: boolean;
|
|
27
|
+
isNavigationSplitButton: boolean;
|
|
28
|
+
isHighlighted: boolean;
|
|
29
|
+
};
|
|
30
|
+
type NavigationSplitButtonContext = UseSplitButtonContext & {
|
|
31
|
+
appearance: 'subtle';
|
|
32
|
+
spacing: 'default';
|
|
33
|
+
isDisabled: false;
|
|
34
|
+
isActiveOverSelected: false;
|
|
35
|
+
isNavigationSplitButton: true;
|
|
36
|
+
isHighlighted: boolean;
|
|
37
|
+
};
|
|
38
|
+
type MainSplitButtonContext = UseSplitButtonContext & {
|
|
39
|
+
appearance: SplitButtonAppearance;
|
|
40
|
+
spacing: SplitButtonSpacing;
|
|
41
|
+
isDisabled: boolean;
|
|
42
|
+
isActiveOverSelected: true;
|
|
43
|
+
isNavigationSplitButton: false;
|
|
44
|
+
isHighlighted: false;
|
|
45
|
+
};
|
|
46
|
+
export declare const useSplitButtonContext: () => NavigationSplitButtonContext | MainSplitButtonContext | undefined;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
import type { SplitButtonAppearance, SplitButtonContextAppearance, SplitButtonSpacing } from './types';
|
|
5
|
+
type DividerProps = {
|
|
6
|
+
appearance: SplitButtonContextAppearance;
|
|
7
|
+
spacing: SplitButtonSpacing;
|
|
8
|
+
isDisabled?: boolean;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* TODO: Add JSDoc
|
|
12
|
+
*/
|
|
13
|
+
export declare const Divider: ({ appearance, spacing, isDisabled, }: DividerProps) => jsx.JSX.Element;
|
|
14
|
+
/**
|
|
15
|
+
* TODO: Add JSdoc
|
|
16
|
+
*/
|
|
17
|
+
export declare const SplitButtonContainer: ({ children }: {
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
}) => jsx.JSX.Element;
|
|
20
|
+
type SplitButtonProps = {
|
|
21
|
+
/**
|
|
22
|
+
* Only two children are allowed.
|
|
23
|
+
* First child is the primary action, second child is the secondary action.
|
|
24
|
+
* The assumption is that for both children trees there is a button reading the context.
|
|
25
|
+
*/
|
|
26
|
+
children: ReactNode;
|
|
27
|
+
appearance?: SplitButtonAppearance;
|
|
28
|
+
spacing?: SplitButtonSpacing;
|
|
29
|
+
isDisabled?: boolean;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* TODO: Add description when adding docs
|
|
33
|
+
*/
|
|
34
|
+
export declare const SplitButton: ({ children, appearance, spacing, isDisabled, }: SplitButtonProps) => jsx.JSX.Element;
|
|
35
|
+
type SplitButtonWithSlotsProps = {
|
|
36
|
+
primaryAction: ReactNode;
|
|
37
|
+
secondaryAction: ReactNode;
|
|
38
|
+
appearance?: SplitButtonAppearance;
|
|
39
|
+
spacing?: SplitButtonSpacing;
|
|
40
|
+
isDisabled?: boolean;
|
|
41
|
+
isSelected?: boolean;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* TODO: Decide on API
|
|
45
|
+
*/
|
|
46
|
+
export declare const SplitButtonWithSlots: ({ primaryAction, secondaryAction, appearance, spacing, isDisabled, }: SplitButtonWithSlotsProps) => jsx.JSX.Element;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Appearance, Spacing } from '../../variants/types';
|
|
2
|
+
export type SplitButtonAppearance = Extract<Appearance, 'default' | 'primary' | 'danger' | 'warning'>;
|
|
3
|
+
export type SplitButtonContextAppearance = SplitButtonAppearance | 'navigation';
|
|
4
|
+
export type SplitButtonSpacing = Extract<Spacing, 'default' | 'compact'>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export declare const getActions: (children: ReactNode) => {
|
|
3
|
+
PrimaryAction: import("react").ReactChild | import("react").ReactFragment | import("react").ReactPortal;
|
|
4
|
+
SecondaryAction: import("react").ReactChild | import("react").ReactFragment | import("react").ReactPortal;
|
|
5
|
+
};
|