@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,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;
|
|
@@ -5,6 +5,7 @@ import useAutoFocus from '@atlaskit/ds-lib/use-auto-focus';
|
|
|
5
5
|
// eslint-disable-next-line no-duplicate-imports
|
|
6
6
|
import InteractionContext from '@atlaskit/interaction-context';
|
|
7
7
|
import { Box, xcss } from '@atlaskit/primitives';
|
|
8
|
+
import { useSplitButtonContext } from '../../containers/split-button/split-button-context';
|
|
8
9
|
import blockEvents from './block-events';
|
|
9
10
|
import { getXCSS } from './xcss';
|
|
10
11
|
|
|
@@ -36,11 +37,11 @@ const overlayStyles = xcss({
|
|
|
36
37
|
*/
|
|
37
38
|
const useButtonBase = ({
|
|
38
39
|
analyticsContext,
|
|
39
|
-
appearance = 'default',
|
|
40
|
+
appearance: propAppearance = 'default',
|
|
40
41
|
autoFocus = false,
|
|
41
42
|
buttonType,
|
|
42
43
|
interactionName,
|
|
43
|
-
isDisabled = false,
|
|
44
|
+
isDisabled: propIsDisabled = false,
|
|
44
45
|
isSelected = false,
|
|
45
46
|
// TODO: Separate Icon Button styling from button base
|
|
46
47
|
isIconButton = false,
|
|
@@ -61,9 +62,17 @@ const useButtonBase = ({
|
|
|
61
62
|
overlay,
|
|
62
63
|
ref,
|
|
63
64
|
shouldFitContainer = false,
|
|
64
|
-
spacing = 'default'
|
|
65
|
+
spacing: propSpacing = 'default'
|
|
65
66
|
}) => {
|
|
66
67
|
const ourRef = useRef();
|
|
68
|
+
const splitButtonContext = useSplitButtonContext();
|
|
69
|
+
const isSplitButton = Boolean(splitButtonContext);
|
|
70
|
+
const isNavigationSplitButton = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.isNavigationSplitButton) || false;
|
|
71
|
+
const appearance = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.appearance) || propAppearance;
|
|
72
|
+
const spacing = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.spacing) || propSpacing;
|
|
73
|
+
const isDisabled = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.isDisabled) || propIsDisabled;
|
|
74
|
+
const isHighlighted = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.isHighlighted) || false;
|
|
75
|
+
const isActiveOverSelected = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.isActiveOverSelected) || false;
|
|
67
76
|
const setRef = useCallback(node => {
|
|
68
77
|
ourRef.current = node;
|
|
69
78
|
if (ref === null) {
|
|
@@ -88,7 +97,7 @@ const useButtonBase = ({
|
|
|
88
97
|
action: 'clicked',
|
|
89
98
|
componentName: 'button',
|
|
90
99
|
packageName: "@atlaskit/button",
|
|
91
|
-
packageVersion: "16.
|
|
100
|
+
packageVersion: "16.12.0",
|
|
92
101
|
analyticsData: analyticsContext,
|
|
93
102
|
actionSubject: buttonType
|
|
94
103
|
});
|
|
@@ -97,13 +106,17 @@ const useButtonBase = ({
|
|
|
97
106
|
spacing,
|
|
98
107
|
isDisabled,
|
|
99
108
|
isSelected,
|
|
109
|
+
isHighlighted,
|
|
110
|
+
isActiveOverSelected,
|
|
100
111
|
shouldFitContainer,
|
|
101
112
|
isIconButton,
|
|
102
113
|
hasOverlay: Boolean(overlay),
|
|
103
114
|
isLink: buttonType === 'link',
|
|
104
115
|
hasIconBefore,
|
|
105
|
-
hasIconAfter
|
|
106
|
-
|
|
116
|
+
hasIconAfter,
|
|
117
|
+
isSplit: isSplitButton,
|
|
118
|
+
isNavigationSplit: isNavigationSplitButton
|
|
119
|
+
}), [appearance, buttonType, spacing, isDisabled, isSelected, isHighlighted, isActiveOverSelected, isIconButton, shouldFitContainer, overlay, hasIconBefore, hasIconAfter, isSplitButton, isNavigationSplitButton]);
|
|
107
120
|
const isEffectivelyDisabled = isDisabled || Boolean(overlay);
|
|
108
121
|
return {
|
|
109
122
|
ref: setRef,
|
|
@@ -2,7 +2,7 @@ import { xcss } from '@atlaskit/primitives';
|
|
|
2
2
|
import { fontSize as getFontSize } from '@atlaskit/theme/constants';
|
|
3
3
|
import colors from './colors';
|
|
4
4
|
const fontSize = getFontSize();
|
|
5
|
-
const heights = {
|
|
5
|
+
export const heights = {
|
|
6
6
|
default: `${32 / fontSize}em`,
|
|
7
7
|
compact: `${24 / fontSize}em`,
|
|
8
8
|
none: 'auto'
|
|
@@ -31,6 +31,19 @@ const verticalAlign = {
|
|
|
31
31
|
compact: 'middle',
|
|
32
32
|
none: 'baseline'
|
|
33
33
|
};
|
|
34
|
+
const splitBorderStyles = {
|
|
35
|
+
':first-of-type': {
|
|
36
|
+
borderTopRightRadius: 0,
|
|
37
|
+
borderBottomRightRadius: 0
|
|
38
|
+
},
|
|
39
|
+
':last-of-type': {
|
|
40
|
+
borderTopLeftRadius: 0,
|
|
41
|
+
borderBottomLeftRadius: 0
|
|
42
|
+
},
|
|
43
|
+
':focus-visible': {
|
|
44
|
+
zIndex: 1
|
|
45
|
+
}
|
|
46
|
+
};
|
|
34
47
|
function getColor({
|
|
35
48
|
group,
|
|
36
49
|
key
|
|
@@ -42,12 +55,14 @@ function getColors({
|
|
|
42
55
|
interactionState = 'default',
|
|
43
56
|
isDisabled,
|
|
44
57
|
isSelected,
|
|
58
|
+
isHighlighted,
|
|
59
|
+
isActiveOverSelected,
|
|
45
60
|
hasOverlay
|
|
46
61
|
}) {
|
|
47
62
|
let key = interactionState;
|
|
48
63
|
// Overlay does not change color on interaction, revert to 'default' or resting state
|
|
49
64
|
key = hasOverlay ? 'default' : key;
|
|
50
|
-
key = isSelected ? 'selected' : key;
|
|
65
|
+
key = isSelected || isHighlighted ? isActiveOverSelected ? 'active' : 'selected' : key;
|
|
51
66
|
// Disabled colors overrule everything else
|
|
52
67
|
key = isDisabled ? 'disabled' : key;
|
|
53
68
|
return {
|
|
@@ -66,9 +81,13 @@ export function getXCSS({
|
|
|
66
81
|
spacing,
|
|
67
82
|
isDisabled,
|
|
68
83
|
isSelected,
|
|
84
|
+
isHighlighted,
|
|
85
|
+
isActiveOverSelected,
|
|
69
86
|
isIconButton,
|
|
70
87
|
shouldFitContainer,
|
|
71
88
|
isLink,
|
|
89
|
+
isSplit,
|
|
90
|
+
isNavigationSplit,
|
|
72
91
|
hasOverlay,
|
|
73
92
|
hasIconBefore,
|
|
74
93
|
hasIconAfter
|
|
@@ -76,6 +95,8 @@ export function getXCSS({
|
|
|
76
95
|
const baseColors = getColors({
|
|
77
96
|
appearance,
|
|
78
97
|
isSelected,
|
|
98
|
+
isHighlighted,
|
|
99
|
+
isActiveOverSelected,
|
|
79
100
|
isDisabled
|
|
80
101
|
});
|
|
81
102
|
const combinedBaseColorStyles = isLink ? {
|
|
@@ -83,12 +104,32 @@ export function getXCSS({
|
|
|
83
104
|
textDecoration: 'none',
|
|
84
105
|
// Disabling visited styles (by re-declaring the base colors)
|
|
85
106
|
':visited': baseColors
|
|
107
|
+
} : isNavigationSplit && !isSelected ? {
|
|
108
|
+
...baseColors,
|
|
109
|
+
backgroundColor: 'color.background.neutral.subtle'
|
|
86
110
|
} : baseColors;
|
|
87
111
|
const height = heights[spacing];
|
|
88
112
|
let width = shouldFitContainer ? '100%' : 'auto';
|
|
89
|
-
width = isIconButton ? height : width;
|
|
90
|
-
const
|
|
91
|
-
const
|
|
113
|
+
width = isIconButton ? isNavigationSplit ? '24px' : height : width;
|
|
114
|
+
const defaultPaddingInlineStart = paddingInline[spacing][hasIconBefore ? 'withIcon' : 'default'];
|
|
115
|
+
const defaultPaddingInlineEnd = paddingInline[spacing][hasIconAfter ? 'withIcon' : 'default'];
|
|
116
|
+
const splitButtonStyles = isSplit ? splitBorderStyles : {};
|
|
117
|
+
const getNavigationSplitButtonPaddings = () => {
|
|
118
|
+
if (isNavigationSplit) {
|
|
119
|
+
return {
|
|
120
|
+
paddingInlineStart: 'space.075',
|
|
121
|
+
paddingInlineEnd: 'space.075'
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
paddingInlineStart: isIconButton ? 'space.0' : defaultPaddingInlineStart,
|
|
126
|
+
paddingInlineEnd: isIconButton ? 'space.0' : defaultPaddingInlineEnd
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
const {
|
|
130
|
+
paddingInlineStart,
|
|
131
|
+
paddingInlineEnd
|
|
132
|
+
} = getNavigationSplitButtonPaddings();
|
|
92
133
|
return xcss({
|
|
93
134
|
alignItems: 'center',
|
|
94
135
|
borderWidth: 'border.width.0',
|
|
@@ -107,8 +148,8 @@ export function getXCSS({
|
|
|
107
148
|
whiteSpace: 'nowrap',
|
|
108
149
|
height,
|
|
109
150
|
paddingBlock: 'space.0',
|
|
110
|
-
paddingInlineStart
|
|
111
|
-
paddingInlineEnd
|
|
151
|
+
paddingInlineStart,
|
|
152
|
+
paddingInlineEnd,
|
|
112
153
|
columnGap: gap[spacing],
|
|
113
154
|
verticalAlign: verticalAlign[spacing],
|
|
114
155
|
width,
|
|
@@ -121,7 +162,8 @@ export function getXCSS({
|
|
|
121
162
|
':hover': {
|
|
122
163
|
...getColors({
|
|
123
164
|
appearance,
|
|
124
|
-
isSelected,
|
|
165
|
+
isSelected: isNavigationSplit && !isSelected ? false : isSelected,
|
|
166
|
+
isActiveOverSelected,
|
|
125
167
|
isDisabled,
|
|
126
168
|
interactionState: 'hover',
|
|
127
169
|
hasOverlay
|
|
@@ -133,13 +175,15 @@ export function getXCSS({
|
|
|
133
175
|
':active': {
|
|
134
176
|
...getColors({
|
|
135
177
|
appearance,
|
|
136
|
-
isSelected,
|
|
178
|
+
isSelected: isNavigationSplit && !isSelected ? false : isSelected,
|
|
179
|
+
isActiveOverSelected,
|
|
137
180
|
isDisabled,
|
|
138
181
|
interactionState: 'active',
|
|
139
182
|
hasOverlay
|
|
140
183
|
}),
|
|
141
184
|
// background, box-shadow
|
|
142
185
|
transitionDuration: '0s, 0s'
|
|
143
|
-
}
|
|
186
|
+
},
|
|
187
|
+
...splitButtonStyles
|
|
144
188
|
});
|
|
145
189
|
}
|
|
@@ -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
|
|
|
@@ -1,13 +1,54 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
/* eslint-disable @repo/internal/react/no-unsafe-spread-props */
|
|
3
2
|
import React, { forwardRef } from 'react';
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
5
|
+
import AddIcon from '@atlaskit/icon/glyph/add';
|
|
4
6
|
import Button from '../new-button/variants/default/button';
|
|
5
7
|
import LinkButton from '../new-button/variants/default/link';
|
|
8
|
+
// import IconButton, {
|
|
9
|
+
// IconButtonProps,
|
|
10
|
+
// } from '../new-button/variants/icon/button';
|
|
11
|
+
import LinkIconButton from '../new-button/variants/icon/link';
|
|
6
12
|
// Add required default props to variants
|
|
7
|
-
const LinkButtonRender = /*#__PURE__*/forwardRef((
|
|
13
|
+
const LinkButtonRender = /*#__PURE__*/forwardRef(({
|
|
14
|
+
href = 'home',
|
|
15
|
+
children,
|
|
16
|
+
...rest
|
|
17
|
+
}, ref) => /*#__PURE__*/React.createElement(LinkButton, _extends({
|
|
8
18
|
ref: ref,
|
|
9
|
-
href:
|
|
10
|
-
},
|
|
19
|
+
href: href
|
|
20
|
+
}, rest), children));
|
|
21
|
+
|
|
22
|
+
// TODO: Enable icon button in tests once it's ready
|
|
23
|
+
// const IconButtonRender = forwardRef(
|
|
24
|
+
// (
|
|
25
|
+
// {
|
|
26
|
+
// children,
|
|
27
|
+
// icon = <AddIcon label="" />,
|
|
28
|
+
// ...rest
|
|
29
|
+
// }: Omit<IconButtonProps, 'icon'> & {
|
|
30
|
+
// icon?: IconButtonProps['icon'];
|
|
31
|
+
// },
|
|
32
|
+
// ref: React.Ref<HTMLButtonElement>,
|
|
33
|
+
// ) => (
|
|
34
|
+
// <IconButton ref={ref} icon={icon} {...rest}>
|
|
35
|
+
// {children}
|
|
36
|
+
// </IconButton>
|
|
37
|
+
// ),
|
|
38
|
+
// );
|
|
39
|
+
|
|
40
|
+
const LinkIconButtonRender = /*#__PURE__*/forwardRef(({
|
|
41
|
+
href = '/home',
|
|
42
|
+
children,
|
|
43
|
+
icon = /*#__PURE__*/React.createElement(AddIcon, {
|
|
44
|
+
label: ""
|
|
45
|
+
}),
|
|
46
|
+
...rest
|
|
47
|
+
}, ref) => /*#__PURE__*/React.createElement(LinkIconButton, _extends({
|
|
48
|
+
ref: ref,
|
|
49
|
+
icon: icon,
|
|
50
|
+
href: href
|
|
51
|
+
}, rest), children));
|
|
11
52
|
export const variants = [{
|
|
12
53
|
name: 'Button',
|
|
13
54
|
Component: Button,
|
|
@@ -16,5 +57,27 @@ export const variants = [{
|
|
|
16
57
|
name: 'LinkButton',
|
|
17
58
|
Component: LinkButtonRender,
|
|
18
59
|
elementType: HTMLAnchorElement
|
|
19
|
-
}
|
|
20
|
-
|
|
60
|
+
}
|
|
61
|
+
// TODO: Enable icon buttons in tests once it's ready
|
|
62
|
+
// {
|
|
63
|
+
// name: 'IconButton',
|
|
64
|
+
// Component: IconButtonRender,
|
|
65
|
+
// elementType: HTMLButtonElement,
|
|
66
|
+
// },
|
|
67
|
+
// {
|
|
68
|
+
// name: 'LinkIconButton',
|
|
69
|
+
// Component: LinkIconButtonRender,
|
|
70
|
+
// elementType: HTMLAnchorElement,
|
|
71
|
+
// },
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
export default variants;
|
|
75
|
+
export const linkButtonVariants = [{
|
|
76
|
+
name: 'LinkButton',
|
|
77
|
+
Component: LinkButtonRender,
|
|
78
|
+
elementType: HTMLAnchorElement
|
|
79
|
+
}, {
|
|
80
|
+
name: 'LinkIconButton',
|
|
81
|
+
Component: LinkIconButtonRender,
|
|
82
|
+
elementType: HTMLAnchorElement
|
|
83
|
+
}];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default } from '../new-button/variants/default/button';
|
|
2
2
|
export { default as LinkButton } from '../new-button/variants/default/link';
|
|
3
3
|
export { default as IconButton } from '../new-button/variants/icon/button';
|
|
4
|
-
export { default as LinkIconButton } from '../new-button/variants/icon/link';
|
|
4
|
+
export { default as LinkIconButton } from '../new-button/variants/icon/link';
|
|
5
|
+
export { SplitButton } from '../new-button/containers/split-button';
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
export { default as UNSAFE_BUTTON } from '../new-button/variants/default/button';
|
|
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,31 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* TODO: Add jsdoc
|
|
4
|
+
*/
|
|
5
|
+
export var SplitButtonContext = /*#__PURE__*/createContext(undefined);
|
|
6
|
+
export var useSplitButtonContext = function useSplitButtonContext() {
|
|
7
|
+
var context = useContext(SplitButtonContext);
|
|
8
|
+
if (!context) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
if (context.appearance === 'navigation') {
|
|
12
|
+
var newContext = {
|
|
13
|
+
spacing: 'default',
|
|
14
|
+
appearance: 'subtle',
|
|
15
|
+
isDisabled: false,
|
|
16
|
+
isActiveOverSelected: false,
|
|
17
|
+
isNavigationSplitButton: true,
|
|
18
|
+
isHighlighted: context.isHighlighted
|
|
19
|
+
};
|
|
20
|
+
return newContext;
|
|
21
|
+
}
|
|
22
|
+
var splitButtonContext = {
|
|
23
|
+
spacing: context.spacing,
|
|
24
|
+
appearance: context.appearance,
|
|
25
|
+
isDisabled: context.isDisabled,
|
|
26
|
+
isActiveOverSelected: true,
|
|
27
|
+
isNavigationSplitButton: false,
|
|
28
|
+
isHighlighted: false
|
|
29
|
+
};
|
|
30
|
+
return splitButtonContext;
|
|
31
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
|
|
3
|
+
import { css, jsx } from '@emotion/react';
|
|
4
|
+
import { fontSize as getFontSize } from '@atlaskit/theme/constants';
|
|
5
|
+
import { SplitButtonContext } from './split-button-context';
|
|
6
|
+
import { getActions } from './utils';
|
|
7
|
+
var fontSize = getFontSize();
|
|
8
|
+
var defaultDividerHeight = 20 / fontSize + 'em';
|
|
9
|
+
var defaultDividerStyles = css({
|
|
10
|
+
height: defaultDividerHeight,
|
|
11
|
+
margin: "var(--ds-space-075, 6px)".concat(" -0.5px")
|
|
12
|
+
});
|
|
13
|
+
var compactDividerHeight = 16 / fontSize + 'em';
|
|
14
|
+
var compactDividerStyles = css({
|
|
15
|
+
height: compactDividerHeight,
|
|
16
|
+
margin: "var(--ds-space-050, 4px)".concat(" -0.5px")
|
|
17
|
+
});
|
|
18
|
+
var baseDividerStyles = css({
|
|
19
|
+
display: 'inline-flex',
|
|
20
|
+
width: '1px',
|
|
21
|
+
position: 'relative',
|
|
22
|
+
zIndex: 2
|
|
23
|
+
});
|
|
24
|
+
var disabledStyles = css({
|
|
25
|
+
backgroundColor: "var(--ds-border, #091E4224)",
|
|
26
|
+
cursor: 'not-allowed'
|
|
27
|
+
});
|
|
28
|
+
var navigationDividerStyles = css({
|
|
29
|
+
height: compactDividerHeight,
|
|
30
|
+
margin: "var(--ds-space-100, 8px)".concat(" -0.5px"),
|
|
31
|
+
backgroundColor: "var(--ds-border, #0052cc)"
|
|
32
|
+
});
|
|
33
|
+
var dividerAppearance = {
|
|
34
|
+
default: css({
|
|
35
|
+
backgroundColor: "var(--ds-text, #172B4D)"
|
|
36
|
+
}),
|
|
37
|
+
primary: css({
|
|
38
|
+
backgroundColor: "var(--ds-text-inverse, #FFF)"
|
|
39
|
+
}),
|
|
40
|
+
danger: css({
|
|
41
|
+
backgroundColor: "var(--ds-text-inverse, #FFF)"
|
|
42
|
+
}),
|
|
43
|
+
warning: css({
|
|
44
|
+
backgroundColor: "var(--ds-text-warning-inverse, #172B4D)"
|
|
45
|
+
}),
|
|
46
|
+
navigation: navigationDividerStyles
|
|
47
|
+
};
|
|
48
|
+
var dividerHeight = {
|
|
49
|
+
default: defaultDividerStyles,
|
|
50
|
+
compact: compactDividerStyles
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* TODO: Add JSDoc
|
|
54
|
+
*/
|
|
55
|
+
export var Divider = function Divider(_ref) {
|
|
56
|
+
var appearance = _ref.appearance,
|
|
57
|
+
spacing = _ref.spacing,
|
|
58
|
+
_ref$isDisabled = _ref.isDisabled,
|
|
59
|
+
isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled;
|
|
60
|
+
return (
|
|
61
|
+
// I find it funny to provide a div for Divider
|
|
62
|
+
jsx("div", {
|
|
63
|
+
css: [baseDividerStyles, dividerAppearance[appearance], dividerHeight[spacing], isDisabled ? disabledStyles : undefined]
|
|
64
|
+
})
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
var splitButtonStyles = css({
|
|
68
|
+
display: 'inline-flex',
|
|
69
|
+
position: 'relative',
|
|
70
|
+
whiteSpace: 'nowrap'
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* TODO: Add JSdoc
|
|
75
|
+
*/
|
|
76
|
+
export var SplitButtonContainer = function SplitButtonContainer(_ref2) {
|
|
77
|
+
var children = _ref2.children;
|
|
78
|
+
return jsx("div", {
|
|
79
|
+
css: splitButtonStyles
|
|
80
|
+
}, children);
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* TODO: Add description when adding docs
|
|
84
|
+
*/
|
|
85
|
+
export var SplitButton = function SplitButton(_ref3) {
|
|
86
|
+
var children = _ref3.children,
|
|
87
|
+
_ref3$appearance = _ref3.appearance,
|
|
88
|
+
appearance = _ref3$appearance === void 0 ? 'default' : _ref3$appearance,
|
|
89
|
+
_ref3$spacing = _ref3.spacing,
|
|
90
|
+
spacing = _ref3$spacing === void 0 ? 'default' : _ref3$spacing,
|
|
91
|
+
_ref3$isDisabled = _ref3.isDisabled,
|
|
92
|
+
isDisabled = _ref3$isDisabled === void 0 ? false : _ref3$isDisabled;
|
|
93
|
+
var _getActions = getActions(children),
|
|
94
|
+
PrimaryAction = _getActions.PrimaryAction,
|
|
95
|
+
SecondaryAction = _getActions.SecondaryAction;
|
|
96
|
+
return jsx(SplitButtonContainer, null, jsx(SplitButtonContext.Provider, {
|
|
97
|
+
value: {
|
|
98
|
+
appearance: appearance,
|
|
99
|
+
spacing: spacing,
|
|
100
|
+
isDisabled: isDisabled
|
|
101
|
+
}
|
|
102
|
+
}, PrimaryAction, jsx(Divider, {
|
|
103
|
+
appearance: appearance,
|
|
104
|
+
spacing: spacing,
|
|
105
|
+
isDisabled: isDisabled
|
|
106
|
+
}), SecondaryAction));
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* TODO: Decide on API
|
|
110
|
+
*/
|
|
111
|
+
export var SplitButtonWithSlots = function SplitButtonWithSlots(_ref4) {
|
|
112
|
+
var primaryAction = _ref4.primaryAction,
|
|
113
|
+
secondaryAction = _ref4.secondaryAction,
|
|
114
|
+
_ref4$appearance = _ref4.appearance,
|
|
115
|
+
appearance = _ref4$appearance === void 0 ? 'default' : _ref4$appearance,
|
|
116
|
+
_ref4$spacing = _ref4.spacing,
|
|
117
|
+
spacing = _ref4$spacing === void 0 ? 'default' : _ref4$spacing,
|
|
118
|
+
_ref4$isDisabled = _ref4.isDisabled,
|
|
119
|
+
isDisabled = _ref4$isDisabled === void 0 ? false : _ref4$isDisabled;
|
|
120
|
+
return jsx(SplitButtonContainer, null, jsx(SplitButtonContext.Provider, {
|
|
121
|
+
value: {
|
|
122
|
+
appearance: appearance,
|
|
123
|
+
spacing: spacing,
|
|
124
|
+
isDisabled: isDisabled
|
|
125
|
+
}
|
|
126
|
+
}, primaryAction, jsx(Divider, {
|
|
127
|
+
appearance: appearance,
|
|
128
|
+
spacing: spacing,
|
|
129
|
+
isDisabled: isDisabled
|
|
130
|
+
}), secondaryAction));
|
|
131
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import { Children } from 'react';
|
|
3
|
+
export var getActions = function getActions(children) {
|
|
4
|
+
var _Children$toArray = Children.toArray(children),
|
|
5
|
+
_Children$toArray2 = _slicedToArray(_Children$toArray, 2),
|
|
6
|
+
PrimaryAction = _Children$toArray2[0],
|
|
7
|
+
SecondaryAction = _Children$toArray2[1];
|
|
8
|
+
if (typeof process !== 'undefined' && process.env.NODE_ENV === 'development' && (!PrimaryAction || !SecondaryAction)) {
|
|
9
|
+
// TODO: i18n?
|
|
10
|
+
throw new SyntaxError('SplitButton requires two children to be provided');
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
PrimaryAction: PrimaryAction,
|
|
14
|
+
SecondaryAction: SecondaryAction
|
|
15
|
+
};
|
|
16
|
+
};
|