@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
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.getXCSS = getXCSS;
|
|
8
|
+
exports.heights = void 0;
|
|
8
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
10
|
var _primitives = require("@atlaskit/primitives");
|
|
10
11
|
var _constants = require("@atlaskit/theme/constants");
|
|
@@ -12,7 +13,7 @@ var _colors = _interopRequireDefault(require("./colors"));
|
|
|
12
13
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
14
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
15
|
var fontSize = (0, _constants.fontSize)();
|
|
15
|
-
var heights = {
|
|
16
|
+
var heights = exports.heights = {
|
|
16
17
|
default: "".concat(32 / fontSize, "em"),
|
|
17
18
|
compact: "".concat(24 / fontSize, "em"),
|
|
18
19
|
none: 'auto'
|
|
@@ -41,6 +42,19 @@ var verticalAlign = {
|
|
|
41
42
|
compact: 'middle',
|
|
42
43
|
none: 'baseline'
|
|
43
44
|
};
|
|
45
|
+
var splitBorderStyles = {
|
|
46
|
+
':first-of-type': {
|
|
47
|
+
borderTopRightRadius: 0,
|
|
48
|
+
borderBottomRightRadius: 0
|
|
49
|
+
},
|
|
50
|
+
':last-of-type': {
|
|
51
|
+
borderTopLeftRadius: 0,
|
|
52
|
+
borderBottomLeftRadius: 0
|
|
53
|
+
},
|
|
54
|
+
':focus-visible': {
|
|
55
|
+
zIndex: 1
|
|
56
|
+
}
|
|
57
|
+
};
|
|
44
58
|
function getColor(_ref) {
|
|
45
59
|
var group = _ref.group,
|
|
46
60
|
key = _ref.key;
|
|
@@ -52,11 +66,13 @@ function getColors(_ref2) {
|
|
|
52
66
|
interactionState = _ref2$interactionStat === void 0 ? 'default' : _ref2$interactionStat,
|
|
53
67
|
isDisabled = _ref2.isDisabled,
|
|
54
68
|
isSelected = _ref2.isSelected,
|
|
69
|
+
isHighlighted = _ref2.isHighlighted,
|
|
70
|
+
isActiveOverSelected = _ref2.isActiveOverSelected,
|
|
55
71
|
hasOverlay = _ref2.hasOverlay;
|
|
56
72
|
var key = interactionState;
|
|
57
73
|
// Overlay does not change color on interaction, revert to 'default' or resting state
|
|
58
74
|
key = hasOverlay ? 'default' : key;
|
|
59
|
-
key = isSelected ? 'selected' : key;
|
|
75
|
+
key = isSelected || isHighlighted ? isActiveOverSelected ? 'active' : 'selected' : key;
|
|
60
76
|
// Disabled colors overrule everything else
|
|
61
77
|
key = isDisabled ? 'disabled' : key;
|
|
62
78
|
return {
|
|
@@ -75,27 +91,51 @@ function getXCSS(_ref3) {
|
|
|
75
91
|
spacing = _ref3.spacing,
|
|
76
92
|
isDisabled = _ref3.isDisabled,
|
|
77
93
|
isSelected = _ref3.isSelected,
|
|
94
|
+
isHighlighted = _ref3.isHighlighted,
|
|
95
|
+
isActiveOverSelected = _ref3.isActiveOverSelected,
|
|
78
96
|
isIconButton = _ref3.isIconButton,
|
|
79
97
|
shouldFitContainer = _ref3.shouldFitContainer,
|
|
80
98
|
isLink = _ref3.isLink,
|
|
99
|
+
isSplit = _ref3.isSplit,
|
|
100
|
+
isNavigationSplit = _ref3.isNavigationSplit,
|
|
81
101
|
hasOverlay = _ref3.hasOverlay,
|
|
82
102
|
hasIconBefore = _ref3.hasIconBefore,
|
|
83
103
|
hasIconAfter = _ref3.hasIconAfter;
|
|
84
104
|
var baseColors = getColors({
|
|
85
105
|
appearance: appearance,
|
|
86
106
|
isSelected: isSelected,
|
|
107
|
+
isHighlighted: isHighlighted,
|
|
108
|
+
isActiveOverSelected: isActiveOverSelected,
|
|
87
109
|
isDisabled: isDisabled
|
|
88
110
|
});
|
|
89
111
|
var combinedBaseColorStyles = isLink ? _objectSpread(_objectSpread({}, baseColors), {}, {
|
|
90
112
|
textDecoration: 'none',
|
|
91
113
|
// Disabling visited styles (by re-declaring the base colors)
|
|
92
114
|
':visited': baseColors
|
|
115
|
+
}) : isNavigationSplit && !isSelected ? _objectSpread(_objectSpread({}, baseColors), {}, {
|
|
116
|
+
backgroundColor: 'color.background.neutral.subtle'
|
|
93
117
|
}) : baseColors;
|
|
94
118
|
var height = heights[spacing];
|
|
95
119
|
var width = shouldFitContainer ? '100%' : 'auto';
|
|
96
|
-
width = isIconButton ? height : width;
|
|
97
|
-
var
|
|
98
|
-
var
|
|
120
|
+
width = isIconButton ? isNavigationSplit ? '24px' : height : width;
|
|
121
|
+
var defaultPaddingInlineStart = paddingInline[spacing][hasIconBefore ? 'withIcon' : 'default'];
|
|
122
|
+
var defaultPaddingInlineEnd = paddingInline[spacing][hasIconAfter ? 'withIcon' : 'default'];
|
|
123
|
+
var splitButtonStyles = isSplit ? splitBorderStyles : {};
|
|
124
|
+
var getNavigationSplitButtonPaddings = function getNavigationSplitButtonPaddings() {
|
|
125
|
+
if (isNavigationSplit) {
|
|
126
|
+
return {
|
|
127
|
+
paddingInlineStart: 'space.075',
|
|
128
|
+
paddingInlineEnd: 'space.075'
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
paddingInlineStart: isIconButton ? 'space.0' : defaultPaddingInlineStart,
|
|
133
|
+
paddingInlineEnd: isIconButton ? 'space.0' : defaultPaddingInlineEnd
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
var _getNavigationSplitBu = getNavigationSplitButtonPaddings(),
|
|
137
|
+
paddingInlineStart = _getNavigationSplitBu.paddingInlineStart,
|
|
138
|
+
paddingInlineEnd = _getNavigationSplitBu.paddingInlineEnd;
|
|
99
139
|
return (0, _primitives.xcss)(_objectSpread(_objectSpread(_objectSpread({
|
|
100
140
|
alignItems: 'center',
|
|
101
141
|
borderWidth: 'border.width.0',
|
|
@@ -114,8 +154,8 @@ function getXCSS(_ref3) {
|
|
|
114
154
|
whiteSpace: 'nowrap',
|
|
115
155
|
height: height,
|
|
116
156
|
paddingBlock: 'space.0',
|
|
117
|
-
paddingInlineStart:
|
|
118
|
-
paddingInlineEnd:
|
|
157
|
+
paddingInlineStart: paddingInlineStart,
|
|
158
|
+
paddingInlineEnd: paddingInlineEnd,
|
|
119
159
|
columnGap: gap[spacing],
|
|
120
160
|
verticalAlign: verticalAlign[spacing],
|
|
121
161
|
width: width,
|
|
@@ -126,7 +166,8 @@ function getXCSS(_ref3) {
|
|
|
126
166
|
} : {}), {}, {
|
|
127
167
|
':hover': _objectSpread(_objectSpread({}, getColors({
|
|
128
168
|
appearance: appearance,
|
|
129
|
-
isSelected: isSelected,
|
|
169
|
+
isSelected: isNavigationSplit && !isSelected ? false : isSelected,
|
|
170
|
+
isActiveOverSelected: isActiveOverSelected,
|
|
130
171
|
isDisabled: isDisabled,
|
|
131
172
|
interactionState: 'hover',
|
|
132
173
|
hasOverlay: hasOverlay
|
|
@@ -137,7 +178,8 @@ function getXCSS(_ref3) {
|
|
|
137
178
|
}),
|
|
138
179
|
':active': _objectSpread(_objectSpread({}, getColors({
|
|
139
180
|
appearance: appearance,
|
|
140
|
-
isSelected: isSelected,
|
|
181
|
+
isSelected: isNavigationSplit && !isSelected ? false : isSelected,
|
|
182
|
+
isActiveOverSelected: isActiveOverSelected,
|
|
141
183
|
isDisabled: isDisabled,
|
|
142
184
|
interactionState: 'active',
|
|
143
185
|
hasOverlay: hasOverlay
|
|
@@ -145,5 +187,5 @@ function getXCSS(_ref3) {
|
|
|
145
187
|
// background, box-shadow
|
|
146
188
|
transitionDuration: '0s, 0s'
|
|
147
189
|
})
|
|
148
|
-
}));
|
|
190
|
+
}, splitButtonStyles));
|
|
149
191
|
}
|
|
@@ -118,7 +118,7 @@ var _default = exports.default = /*#__PURE__*/_react.default.forwardRef(function
|
|
|
118
118
|
action: 'clicked',
|
|
119
119
|
componentName: 'button',
|
|
120
120
|
packageName: "@atlaskit/button",
|
|
121
|
-
packageVersion: "16.
|
|
121
|
+
packageVersion: "16.12.0",
|
|
122
122
|
analyticsData: analyticsContext
|
|
123
123
|
});
|
|
124
124
|
|
|
@@ -5,21 +5,65 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.variants = exports.default = void 0;
|
|
8
|
+
exports.variants = exports.linkButtonVariants = exports.default = void 0;
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _add = _interopRequireDefault(require("@atlaskit/icon/glyph/add"));
|
|
11
13
|
var _button = _interopRequireDefault(require("../new-button/variants/default/button"));
|
|
12
14
|
var _link = _interopRequireDefault(require("../new-button/variants/default/link"));
|
|
15
|
+
var _link2 = _interopRequireDefault(require("../new-button/variants/icon/link"));
|
|
16
|
+
var _excluded = ["href", "children"],
|
|
17
|
+
_excluded2 = ["href", "children", "icon"]; // eslint-disable-next-line import/no-extraneous-dependencies
|
|
18
|
+
// import IconButton, {
|
|
19
|
+
// IconButtonProps,
|
|
20
|
+
// } from '../new-button/variants/icon/button';
|
|
13
21
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
22
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
-
/* eslint-disable @repo/internal/react/no-unsafe-spread-props */
|
|
16
|
-
|
|
17
23
|
// Add required default props to variants
|
|
18
|
-
var LinkButtonRender = /*#__PURE__*/(0, _react.forwardRef)(function (
|
|
24
|
+
var LinkButtonRender = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
25
|
+
var _ref$href = _ref.href,
|
|
26
|
+
href = _ref$href === void 0 ? 'home' : _ref$href,
|
|
27
|
+
children = _ref.children,
|
|
28
|
+
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
19
29
|
return /*#__PURE__*/_react.default.createElement(_link.default, (0, _extends2.default)({
|
|
20
30
|
ref: ref,
|
|
21
|
-
href:
|
|
22
|
-
},
|
|
31
|
+
href: href
|
|
32
|
+
}, rest), children);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// TODO: Enable icon button in tests once it's ready
|
|
36
|
+
// const IconButtonRender = forwardRef(
|
|
37
|
+
// (
|
|
38
|
+
// {
|
|
39
|
+
// children,
|
|
40
|
+
// icon = <AddIcon label="" />,
|
|
41
|
+
// ...rest
|
|
42
|
+
// }: Omit<IconButtonProps, 'icon'> & {
|
|
43
|
+
// icon?: IconButtonProps['icon'];
|
|
44
|
+
// },
|
|
45
|
+
// ref: React.Ref<HTMLButtonElement>,
|
|
46
|
+
// ) => (
|
|
47
|
+
// <IconButton ref={ref} icon={icon} {...rest}>
|
|
48
|
+
// {children}
|
|
49
|
+
// </IconButton>
|
|
50
|
+
// ),
|
|
51
|
+
// );
|
|
52
|
+
|
|
53
|
+
var LinkIconButtonRender = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
54
|
+
var _ref2$href = _ref2.href,
|
|
55
|
+
href = _ref2$href === void 0 ? '/home' : _ref2$href,
|
|
56
|
+
children = _ref2.children,
|
|
57
|
+
_ref2$icon = _ref2.icon,
|
|
58
|
+
icon = _ref2$icon === void 0 ? /*#__PURE__*/_react.default.createElement(_add.default, {
|
|
59
|
+
label: ""
|
|
60
|
+
}) : _ref2$icon,
|
|
61
|
+
rest = (0, _objectWithoutProperties2.default)(_ref2, _excluded2);
|
|
62
|
+
return /*#__PURE__*/_react.default.createElement(_link2.default, (0, _extends2.default)({
|
|
63
|
+
ref: ref,
|
|
64
|
+
icon: icon,
|
|
65
|
+
href: href
|
|
66
|
+
}, rest), children);
|
|
23
67
|
});
|
|
24
68
|
var variants = exports.variants = [{
|
|
25
69
|
name: 'Button',
|
|
@@ -29,5 +73,26 @@ var variants = exports.variants = [{
|
|
|
29
73
|
name: 'LinkButton',
|
|
30
74
|
Component: LinkButtonRender,
|
|
31
75
|
elementType: HTMLAnchorElement
|
|
32
|
-
}
|
|
33
|
-
|
|
76
|
+
}
|
|
77
|
+
// TODO: Enable icon buttons in tests once it's ready
|
|
78
|
+
// {
|
|
79
|
+
// name: 'IconButton',
|
|
80
|
+
// Component: IconButtonRender,
|
|
81
|
+
// elementType: HTMLButtonElement,
|
|
82
|
+
// },
|
|
83
|
+
// {
|
|
84
|
+
// name: 'LinkIconButton',
|
|
85
|
+
// Component: LinkIconButtonRender,
|
|
86
|
+
// elementType: HTMLAnchorElement,
|
|
87
|
+
// },
|
|
88
|
+
];
|
|
89
|
+
var _default = exports.default = variants;
|
|
90
|
+
var linkButtonVariants = exports.linkButtonVariants = [{
|
|
91
|
+
name: 'LinkButton',
|
|
92
|
+
Component: LinkButtonRender,
|
|
93
|
+
elementType: HTMLAnchorElement
|
|
94
|
+
}, {
|
|
95
|
+
name: 'LinkIconButton',
|
|
96
|
+
Component: LinkIconButtonRender,
|
|
97
|
+
elementType: HTMLAnchorElement
|
|
98
|
+
}];
|
|
@@ -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 const SplitButtonContext = /*#__PURE__*/createContext(undefined);
|
|
6
|
+
export const useSplitButtonContext = () => {
|
|
7
|
+
const context = useContext(SplitButtonContext);
|
|
8
|
+
if (!context) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
if (context.appearance === 'navigation') {
|
|
12
|
+
const 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
|
+
const 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,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
|
+
};
|
|
@@ -14,7 +14,6 @@ import useDefaultButton from './use-default-button';
|
|
|
14
14
|
* - [Usage](https://atlassian.design/components/button/usage)
|
|
15
15
|
*/
|
|
16
16
|
const Button = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function Button({
|
|
17
|
-
// Button base
|
|
18
17
|
analyticsContext,
|
|
19
18
|
autoFocus,
|
|
20
19
|
appearance,
|
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import
|
|
2
|
+
import React, { forwardRef, memo } from 'react';
|
|
3
|
+
import UNSAFE_LINK from '@atlaskit/primitives/link';
|
|
4
4
|
import useDefaultButton from './use-default-button';
|
|
5
|
-
|
|
6
|
-
* __Link Button__
|
|
7
|
-
*
|
|
8
|
-
* A link button renders a link in the style of a button.
|
|
9
|
-
*
|
|
10
|
-
* - [Examples](https://atlassian.design/components/button/examples)
|
|
11
|
-
* - [Code](https://atlassian.design/components/button/code)
|
|
12
|
-
* - [Usage](https://atlassian.design/components/button/usage)
|
|
13
|
-
*/
|
|
14
|
-
const LinkButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function LinkButton({
|
|
15
|
-
// Button base
|
|
5
|
+
const LinkButtonBase = ({
|
|
16
6
|
analyticsContext,
|
|
17
7
|
autoFocus,
|
|
18
8
|
appearance,
|
|
@@ -38,7 +28,7 @@ const LinkButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(functi
|
|
|
38
28
|
testId,
|
|
39
29
|
href,
|
|
40
30
|
...rest
|
|
41
|
-
}, ref) {
|
|
31
|
+
}, ref) => {
|
|
42
32
|
const baseProps = useDefaultButton({
|
|
43
33
|
analyticsContext,
|
|
44
34
|
appearance,
|
|
@@ -65,34 +55,45 @@ const LinkButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(functi
|
|
|
65
55
|
shouldFitContainer,
|
|
66
56
|
spacing
|
|
67
57
|
});
|
|
68
|
-
return (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
58
|
+
return /*#__PURE__*/React.createElement(UNSAFE_LINK
|
|
59
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
60
|
+
, _extends({}, rest, {
|
|
61
|
+
ref: baseProps.ref,
|
|
62
|
+
xcss: baseProps.xcss,
|
|
63
|
+
onClick: baseProps.onClick,
|
|
64
|
+
onMouseDownCapture: baseProps.onMouseDownCapture,
|
|
65
|
+
onMouseUpCapture: baseProps.onMouseUpCapture,
|
|
66
|
+
onKeyDownCapture: baseProps.onKeyDownCapture,
|
|
67
|
+
onKeyUpCapture: baseProps.onKeyUpCapture,
|
|
68
|
+
onTouchStartCapture: baseProps.onTouchStartCapture,
|
|
69
|
+
onTouchEndCapture: baseProps.onTouchEndCapture,
|
|
70
|
+
onPointerDownCapture: baseProps.onPointerDownCapture,
|
|
71
|
+
onPointerUpCapture: baseProps.onPointerUpCapture,
|
|
72
|
+
onClickCapture: baseProps.onClickCapture,
|
|
73
|
+
testId: testId
|
|
74
|
+
/**
|
|
75
|
+
* Disable link in an accessible way using `href`, `role`, and `aria-disabled`.
|
|
76
|
+
* @see https://a11y-guidelines.orange.com/en/articles/disable-elements/#disable-a-link
|
|
77
|
+
*/
|
|
78
|
+
// @ts-expect-error (`href` is required, we could make it optional but don't want to encourage this pattern elsewhere)
|
|
79
|
+
,
|
|
80
|
+
href: baseProps.isDisabled ? undefined : href,
|
|
81
|
+
role: baseProps.isDisabled ? 'link' : undefined,
|
|
82
|
+
"aria-disabled": baseProps.isDisabled === true ? true : undefined
|
|
83
|
+
}), baseProps.children);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// Workarounds to support generic types with forwardRef + memo
|
|
87
|
+
const WithRef = /*#__PURE__*/forwardRef(LinkButtonBase);
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* __Link Button__
|
|
91
|
+
*
|
|
92
|
+
* Renders a link in the style of a button.
|
|
93
|
+
*
|
|
94
|
+
* - [Examples](https://atlassian.design/components/button/examples)
|
|
95
|
+
* - [Code](https://atlassian.design/components/button/code)
|
|
96
|
+
* - [Usage](https://atlassian.design/components/button/usage)
|
|
97
|
+
*/
|
|
98
|
+
const LinkButton = /*#__PURE__*/memo(WithRef);
|
|
98
99
|
export default LinkButton;
|
|
@@ -12,7 +12,6 @@ import useIconButton from './use-icon-button';
|
|
|
12
12
|
* - [Usage](https://atlassian.design/components/button/usage)
|
|
13
13
|
*/
|
|
14
14
|
const IconButton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function Button({
|
|
15
|
-
// Button base
|
|
16
15
|
analyticsContext,
|
|
17
16
|
autoFocus,
|
|
18
17
|
appearance,
|