@atlaskit/button 16.10.2 → 16.11.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 +6 -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/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/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/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/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/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/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/shared/use-button-base.d.ts +1 -1
- package/dist/types/new-button/variants/shared/xcss.d.ts +14 -1
- package/dist/types/old-button/types.d.ts +2 -2
- 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 +19 -0
- package/dist/types-ts4.5/new-button/variants/default/link.d.ts +17 -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 +17 -0
- package/dist/types-ts4.5/new-button/variants/icon/link.d.ts +17 -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 +69 -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 +15 -0
- package/package.json +2 -2
- package/tmp/api-report-tmp.d.ts +133 -0
|
@@ -0,0 +1,129 @@
|
|
|
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
|
+
const fontSize = getFontSize();
|
|
8
|
+
const defaultDividerHeight = 20 / fontSize + 'em';
|
|
9
|
+
const defaultDividerStyles = css({
|
|
10
|
+
height: defaultDividerHeight,
|
|
11
|
+
margin: `${"var(--ds-space-075, 6px)"} -0.5px`
|
|
12
|
+
});
|
|
13
|
+
const compactDividerHeight = 16 / fontSize + 'em';
|
|
14
|
+
const compactDividerStyles = css({
|
|
15
|
+
height: compactDividerHeight,
|
|
16
|
+
margin: `${"var(--ds-space-050, 4px)"} -0.5px`
|
|
17
|
+
});
|
|
18
|
+
const baseDividerStyles = css({
|
|
19
|
+
display: 'inline-flex',
|
|
20
|
+
width: '1px',
|
|
21
|
+
position: 'relative',
|
|
22
|
+
zIndex: 2
|
|
23
|
+
});
|
|
24
|
+
const disabledStyles = css({
|
|
25
|
+
backgroundColor: "var(--ds-border, #091E4224)",
|
|
26
|
+
cursor: 'not-allowed'
|
|
27
|
+
});
|
|
28
|
+
const navigationDividerStyles = css({
|
|
29
|
+
height: compactDividerHeight,
|
|
30
|
+
margin: `${"var(--ds-space-100, 8px)"} -0.5px`,
|
|
31
|
+
backgroundColor: "var(--ds-border, #0052cc)"
|
|
32
|
+
});
|
|
33
|
+
const 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
|
+
const dividerHeight = {
|
|
49
|
+
default: defaultDividerStyles,
|
|
50
|
+
compact: compactDividerStyles
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* TODO: Add JSDoc
|
|
54
|
+
*/
|
|
55
|
+
export const Divider = ({
|
|
56
|
+
appearance,
|
|
57
|
+
spacing,
|
|
58
|
+
isDisabled = false
|
|
59
|
+
}) => {
|
|
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
|
+
const splitButtonStyles = css({
|
|
68
|
+
display: 'inline-flex',
|
|
69
|
+
position: 'relative',
|
|
70
|
+
whiteSpace: 'nowrap'
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* TODO: Add JSdoc
|
|
75
|
+
*/
|
|
76
|
+
export const SplitButtonContainer = ({
|
|
77
|
+
children
|
|
78
|
+
}) => {
|
|
79
|
+
return jsx("div", {
|
|
80
|
+
css: splitButtonStyles
|
|
81
|
+
}, children);
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* TODO: Add description when adding docs
|
|
85
|
+
*/
|
|
86
|
+
export const SplitButton = ({
|
|
87
|
+
children,
|
|
88
|
+
appearance = 'default',
|
|
89
|
+
spacing = 'default',
|
|
90
|
+
isDisabled = false
|
|
91
|
+
}) => {
|
|
92
|
+
const {
|
|
93
|
+
PrimaryAction,
|
|
94
|
+
SecondaryAction
|
|
95
|
+
} = getActions(children);
|
|
96
|
+
return jsx(SplitButtonContainer, null, jsx(SplitButtonContext.Provider, {
|
|
97
|
+
value: {
|
|
98
|
+
appearance,
|
|
99
|
+
spacing,
|
|
100
|
+
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 const SplitButtonWithSlots = ({
|
|
112
|
+
primaryAction,
|
|
113
|
+
secondaryAction,
|
|
114
|
+
appearance = 'default',
|
|
115
|
+
spacing = 'default',
|
|
116
|
+
isDisabled = false
|
|
117
|
+
}) => {
|
|
118
|
+
return jsx(SplitButtonContainer, null, jsx(SplitButtonContext.Provider, {
|
|
119
|
+
value: {
|
|
120
|
+
appearance,
|
|
121
|
+
spacing,
|
|
122
|
+
isDisabled
|
|
123
|
+
}
|
|
124
|
+
}, primaryAction, jsx(Divider, {
|
|
125
|
+
appearance: appearance,
|
|
126
|
+
spacing: spacing,
|
|
127
|
+
isDisabled: isDisabled
|
|
128
|
+
}), secondaryAction));
|
|
129
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Children } from 'react';
|
|
2
|
+
export const getActions = children => {
|
|
3
|
+
const [PrimaryAction, SecondaryAction] = Children.toArray(children);
|
|
4
|
+
if (typeof process !== 'undefined' && process.env.NODE_ENV === 'development' && (!PrimaryAction || !SecondaryAction)) {
|
|
5
|
+
// TODO: i18n?
|
|
6
|
+
throw new SyntaxError('SplitButton requires two children to be provided');
|
|
7
|
+
}
|
|
8
|
+
return {
|
|
9
|
+
PrimaryAction,
|
|
10
|
+
SecondaryAction
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -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.11.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.11.0",
|
|
107
107
|
analyticsData: analyticsContext
|
|
108
108
|
});
|
|
109
109
|
|
|
@@ -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
|
+
};
|
|
@@ -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.11.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,
|