@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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/button
|
|
2
2
|
|
|
3
|
+
## 16.11.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#41859](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41859) [`7c662f243b9`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7c662f243b9) - Expose more UNSAFE exports from UNSAFE entry point for internal work. PLEASE DO NO USE ANYTHING FROM "UNSAFE" ENTRY POINT WITH "UNSAFE" PREFIX.
|
|
8
|
+
|
|
3
9
|
## 16.10.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -22,6 +22,12 @@ Object.defineProperty(exports, "LinkIconButton", {
|
|
|
22
22
|
return _link2.default;
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
|
+
Object.defineProperty(exports, "SplitButton", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function get() {
|
|
28
|
+
return _splitButton.SplitButton;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
25
31
|
Object.defineProperty(exports, "default", {
|
|
26
32
|
enumerable: true,
|
|
27
33
|
get: function get() {
|
|
@@ -31,4 +37,5 @@ Object.defineProperty(exports, "default", {
|
|
|
31
37
|
var _button = _interopRequireDefault(require("../new-button/variants/default/button"));
|
|
32
38
|
var _link = _interopRequireDefault(require("../new-button/variants/default/link"));
|
|
33
39
|
var _button2 = _interopRequireDefault(require("../new-button/variants/icon/button"));
|
|
34
|
-
var _link2 = _interopRequireDefault(require("../new-button/variants/icon/link"));
|
|
40
|
+
var _link2 = _interopRequireDefault(require("../new-button/variants/icon/link"));
|
|
41
|
+
var _splitButton = require("../new-button/containers/split-button");
|
|
@@ -10,4 +10,43 @@ Object.defineProperty(exports, "UNSAFE_BUTTON", {
|
|
|
10
10
|
return _button.default;
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
|
-
|
|
13
|
+
Object.defineProperty(exports, "UNSAFE_DIVIDER", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function get() {
|
|
16
|
+
return _splitButton.Divider;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "UNSAFE_GET_ACTIONS", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function get() {
|
|
22
|
+
return _splitButton.getActions;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "UNSAFE_ICON_BUTTON", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function get() {
|
|
28
|
+
return _button2.default;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "UNSAFE_SPLIT_BUTTON", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function get() {
|
|
34
|
+
return _splitButton.SplitButton;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(exports, "UNSAFE_SPLIT_BUTTON_CONTAINER", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function get() {
|
|
40
|
+
return _splitButton.SplitButtonContainer;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(exports, "UNSAFE_SPLIT_BUTTON_CONTEXT", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function get() {
|
|
46
|
+
return _splitButtonContext.SplitButtonContext;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
var _button = _interopRequireDefault(require("../new-button/variants/default/button"));
|
|
50
|
+
var _button2 = _interopRequireDefault(require("../new-button/variants/icon/button"));
|
|
51
|
+
var _splitButton = require("../new-button/containers/split-button");
|
|
52
|
+
var _splitButtonContext = require("../new-button/containers/split-button/split-button-context");
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Divider", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _splitButton.Divider;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "SplitButton", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _splitButton.SplitButton;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "SplitButtonContainer", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _splitButton.SplitButtonContainer;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "SplitButtonContext", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _splitButtonContext.SplitButtonContext;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "SplitButtonWithSlots", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function get() {
|
|
33
|
+
return _splitButton.SplitButtonWithSlots;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "getActions", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function get() {
|
|
39
|
+
return _utils.getActions;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "useSplitButtonContext", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function get() {
|
|
45
|
+
return _splitButtonContext.useSplitButtonContext;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
var _splitButton = require("./split-button");
|
|
49
|
+
var _utils = require("./utils");
|
|
50
|
+
var _splitButtonContext = require("./split-button-context");
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useSplitButtonContext = exports.SplitButtonContext = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
/**
|
|
9
|
+
* TODO: Add jsdoc
|
|
10
|
+
*/
|
|
11
|
+
var SplitButtonContext = exports.SplitButtonContext = /*#__PURE__*/(0, _react.createContext)(undefined);
|
|
12
|
+
var useSplitButtonContext = exports.useSplitButtonContext = function useSplitButtonContext() {
|
|
13
|
+
var context = (0, _react.useContext)(SplitButtonContext);
|
|
14
|
+
if (!context) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
if (context.appearance === 'navigation') {
|
|
18
|
+
var newContext = {
|
|
19
|
+
spacing: 'default',
|
|
20
|
+
appearance: 'subtle',
|
|
21
|
+
isDisabled: false,
|
|
22
|
+
isActiveOverSelected: false,
|
|
23
|
+
isNavigationSplitButton: true,
|
|
24
|
+
isHighlighted: context.isHighlighted
|
|
25
|
+
};
|
|
26
|
+
return newContext;
|
|
27
|
+
}
|
|
28
|
+
var splitButtonContext = {
|
|
29
|
+
spacing: context.spacing,
|
|
30
|
+
appearance: context.appearance,
|
|
31
|
+
isDisabled: context.isDisabled,
|
|
32
|
+
isActiveOverSelected: true,
|
|
33
|
+
isNavigationSplitButton: false,
|
|
34
|
+
isHighlighted: false
|
|
35
|
+
};
|
|
36
|
+
return splitButtonContext;
|
|
37
|
+
};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SplitButtonWithSlots = exports.SplitButtonContainer = exports.SplitButton = exports.Divider = void 0;
|
|
7
|
+
var _react = require("@emotion/react");
|
|
8
|
+
var _constants = require("@atlaskit/theme/constants");
|
|
9
|
+
var _splitButtonContext = require("./split-button-context");
|
|
10
|
+
var _utils = require("./utils");
|
|
11
|
+
/** @jsx jsx */
|
|
12
|
+
|
|
13
|
+
var fontSize = (0, _constants.fontSize)();
|
|
14
|
+
var defaultDividerHeight = 20 / fontSize + 'em';
|
|
15
|
+
var defaultDividerStyles = (0, _react.css)({
|
|
16
|
+
height: defaultDividerHeight,
|
|
17
|
+
margin: "var(--ds-space-075, 6px)".concat(" -0.5px")
|
|
18
|
+
});
|
|
19
|
+
var compactDividerHeight = 16 / fontSize + 'em';
|
|
20
|
+
var compactDividerStyles = (0, _react.css)({
|
|
21
|
+
height: compactDividerHeight,
|
|
22
|
+
margin: "var(--ds-space-050, 4px)".concat(" -0.5px")
|
|
23
|
+
});
|
|
24
|
+
var baseDividerStyles = (0, _react.css)({
|
|
25
|
+
display: 'inline-flex',
|
|
26
|
+
width: '1px',
|
|
27
|
+
position: 'relative',
|
|
28
|
+
zIndex: 2
|
|
29
|
+
});
|
|
30
|
+
var disabledStyles = (0, _react.css)({
|
|
31
|
+
backgroundColor: "var(--ds-border, #091E4224)",
|
|
32
|
+
cursor: 'not-allowed'
|
|
33
|
+
});
|
|
34
|
+
var navigationDividerStyles = (0, _react.css)({
|
|
35
|
+
height: compactDividerHeight,
|
|
36
|
+
margin: "var(--ds-space-100, 8px)".concat(" -0.5px"),
|
|
37
|
+
backgroundColor: "var(--ds-border, #0052cc)"
|
|
38
|
+
});
|
|
39
|
+
var dividerAppearance = {
|
|
40
|
+
default: (0, _react.css)({
|
|
41
|
+
backgroundColor: "var(--ds-text, #172B4D)"
|
|
42
|
+
}),
|
|
43
|
+
primary: (0, _react.css)({
|
|
44
|
+
backgroundColor: "var(--ds-text-inverse, #FFF)"
|
|
45
|
+
}),
|
|
46
|
+
danger: (0, _react.css)({
|
|
47
|
+
backgroundColor: "var(--ds-text-inverse, #FFF)"
|
|
48
|
+
}),
|
|
49
|
+
warning: (0, _react.css)({
|
|
50
|
+
backgroundColor: "var(--ds-text-warning-inverse, #172B4D)"
|
|
51
|
+
}),
|
|
52
|
+
navigation: navigationDividerStyles
|
|
53
|
+
};
|
|
54
|
+
var dividerHeight = {
|
|
55
|
+
default: defaultDividerStyles,
|
|
56
|
+
compact: compactDividerStyles
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* TODO: Add JSDoc
|
|
60
|
+
*/
|
|
61
|
+
var Divider = exports.Divider = function Divider(_ref) {
|
|
62
|
+
var appearance = _ref.appearance,
|
|
63
|
+
spacing = _ref.spacing,
|
|
64
|
+
_ref$isDisabled = _ref.isDisabled,
|
|
65
|
+
isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled;
|
|
66
|
+
return (
|
|
67
|
+
// I find it funny to provide a div for Divider
|
|
68
|
+
(0, _react.jsx)("div", {
|
|
69
|
+
css: [baseDividerStyles, dividerAppearance[appearance], dividerHeight[spacing], isDisabled ? disabledStyles : undefined]
|
|
70
|
+
})
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
var splitButtonStyles = (0, _react.css)({
|
|
74
|
+
display: 'inline-flex',
|
|
75
|
+
position: 'relative',
|
|
76
|
+
whiteSpace: 'nowrap'
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* TODO: Add JSdoc
|
|
81
|
+
*/
|
|
82
|
+
var SplitButtonContainer = exports.SplitButtonContainer = function SplitButtonContainer(_ref2) {
|
|
83
|
+
var children = _ref2.children;
|
|
84
|
+
return (0, _react.jsx)("div", {
|
|
85
|
+
css: splitButtonStyles
|
|
86
|
+
}, children);
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* TODO: Add description when adding docs
|
|
90
|
+
*/
|
|
91
|
+
var SplitButton = exports.SplitButton = function SplitButton(_ref3) {
|
|
92
|
+
var children = _ref3.children,
|
|
93
|
+
_ref3$appearance = _ref3.appearance,
|
|
94
|
+
appearance = _ref3$appearance === void 0 ? 'default' : _ref3$appearance,
|
|
95
|
+
_ref3$spacing = _ref3.spacing,
|
|
96
|
+
spacing = _ref3$spacing === void 0 ? 'default' : _ref3$spacing,
|
|
97
|
+
_ref3$isDisabled = _ref3.isDisabled,
|
|
98
|
+
isDisabled = _ref3$isDisabled === void 0 ? false : _ref3$isDisabled;
|
|
99
|
+
var _getActions = (0, _utils.getActions)(children),
|
|
100
|
+
PrimaryAction = _getActions.PrimaryAction,
|
|
101
|
+
SecondaryAction = _getActions.SecondaryAction;
|
|
102
|
+
return (0, _react.jsx)(SplitButtonContainer, null, (0, _react.jsx)(_splitButtonContext.SplitButtonContext.Provider, {
|
|
103
|
+
value: {
|
|
104
|
+
appearance: appearance,
|
|
105
|
+
spacing: spacing,
|
|
106
|
+
isDisabled: isDisabled
|
|
107
|
+
}
|
|
108
|
+
}, PrimaryAction, (0, _react.jsx)(Divider, {
|
|
109
|
+
appearance: appearance,
|
|
110
|
+
spacing: spacing,
|
|
111
|
+
isDisabled: isDisabled
|
|
112
|
+
}), SecondaryAction));
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* TODO: Decide on API
|
|
116
|
+
*/
|
|
117
|
+
var SplitButtonWithSlots = exports.SplitButtonWithSlots = function SplitButtonWithSlots(_ref4) {
|
|
118
|
+
var primaryAction = _ref4.primaryAction,
|
|
119
|
+
secondaryAction = _ref4.secondaryAction,
|
|
120
|
+
_ref4$appearance = _ref4.appearance,
|
|
121
|
+
appearance = _ref4$appearance === void 0 ? 'default' : _ref4$appearance,
|
|
122
|
+
_ref4$spacing = _ref4.spacing,
|
|
123
|
+
spacing = _ref4$spacing === void 0 ? 'default' : _ref4$spacing,
|
|
124
|
+
_ref4$isDisabled = _ref4.isDisabled,
|
|
125
|
+
isDisabled = _ref4$isDisabled === void 0 ? false : _ref4$isDisabled;
|
|
126
|
+
return (0, _react.jsx)(SplitButtonContainer, null, (0, _react.jsx)(_splitButtonContext.SplitButtonContext.Provider, {
|
|
127
|
+
value: {
|
|
128
|
+
appearance: appearance,
|
|
129
|
+
spacing: spacing,
|
|
130
|
+
isDisabled: isDisabled
|
|
131
|
+
}
|
|
132
|
+
}, primaryAction, (0, _react.jsx)(Divider, {
|
|
133
|
+
appearance: appearance,
|
|
134
|
+
spacing: spacing,
|
|
135
|
+
isDisabled: isDisabled
|
|
136
|
+
}), secondaryAction));
|
|
137
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getActions = void 0;
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
var getActions = exports.getActions = function getActions(children) {
|
|
11
|
+
var _Children$toArray = _react.Children.toArray(children),
|
|
12
|
+
_Children$toArray2 = (0, _slicedToArray2.default)(_Children$toArray, 2),
|
|
13
|
+
PrimaryAction = _Children$toArray2[0],
|
|
14
|
+
SecondaryAction = _Children$toArray2[1];
|
|
15
|
+
if (typeof process !== 'undefined' && process.env.NODE_ENV === 'development' && (!PrimaryAction || !SecondaryAction)) {
|
|
16
|
+
// TODO: i18n?
|
|
17
|
+
throw new SyntaxError('SplitButton requires two children to be provided');
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
PrimaryAction: PrimaryAction,
|
|
21
|
+
SecondaryAction: SecondaryAction
|
|
22
|
+
};
|
|
23
|
+
};
|
|
@@ -13,6 +13,7 @@ var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
|
|
|
13
13
|
var _useAutoFocus = _interopRequireDefault(require("@atlaskit/ds-lib/use-auto-focus"));
|
|
14
14
|
var _interactionContext = _interopRequireDefault(require("@atlaskit/interaction-context"));
|
|
15
15
|
var _primitives = require("@atlaskit/primitives");
|
|
16
|
+
var _splitButtonContext = require("../../containers/split-button/split-button-context");
|
|
16
17
|
var _blockEvents = _interopRequireDefault(require("./block-events"));
|
|
17
18
|
var _xcss = require("./xcss");
|
|
18
19
|
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); }
|
|
@@ -48,13 +49,13 @@ var overlayStyles = (0, _primitives.xcss)({
|
|
|
48
49
|
var useButtonBase = function useButtonBase(_ref) {
|
|
49
50
|
var analyticsContext = _ref.analyticsContext,
|
|
50
51
|
_ref$appearance = _ref.appearance,
|
|
51
|
-
|
|
52
|
+
propAppearance = _ref$appearance === void 0 ? 'default' : _ref$appearance,
|
|
52
53
|
_ref$autoFocus = _ref.autoFocus,
|
|
53
54
|
autoFocus = _ref$autoFocus === void 0 ? false : _ref$autoFocus,
|
|
54
55
|
buttonType = _ref.buttonType,
|
|
55
56
|
interactionName = _ref.interactionName,
|
|
56
57
|
_ref$isDisabled = _ref.isDisabled,
|
|
57
|
-
|
|
58
|
+
propIsDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
|
|
58
59
|
_ref$isSelected = _ref.isSelected,
|
|
59
60
|
isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected,
|
|
60
61
|
_ref$isIconButton = _ref.isIconButton,
|
|
@@ -80,8 +81,16 @@ var useButtonBase = function useButtonBase(_ref) {
|
|
|
80
81
|
_ref$shouldFitContain = _ref.shouldFitContainer,
|
|
81
82
|
shouldFitContainer = _ref$shouldFitContain === void 0 ? false : _ref$shouldFitContain,
|
|
82
83
|
_ref$spacing = _ref.spacing,
|
|
83
|
-
|
|
84
|
+
propSpacing = _ref$spacing === void 0 ? 'default' : _ref$spacing;
|
|
84
85
|
var ourRef = (0, _react.useRef)();
|
|
86
|
+
var splitButtonContext = (0, _splitButtonContext.useSplitButtonContext)();
|
|
87
|
+
var isSplitButton = Boolean(splitButtonContext);
|
|
88
|
+
var isNavigationSplitButton = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.isNavigationSplitButton) || false;
|
|
89
|
+
var appearance = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.appearance) || propAppearance;
|
|
90
|
+
var spacing = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.spacing) || propSpacing;
|
|
91
|
+
var isDisabled = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.isDisabled) || propIsDisabled;
|
|
92
|
+
var isHighlighted = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.isHighlighted) || false;
|
|
93
|
+
var isActiveOverSelected = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.isActiveOverSelected) || false;
|
|
85
94
|
var setRef = (0, _react.useCallback)(function (node) {
|
|
86
95
|
ourRef.current = node;
|
|
87
96
|
if (ref === null) {
|
|
@@ -106,7 +115,7 @@ var useButtonBase = function useButtonBase(_ref) {
|
|
|
106
115
|
action: 'clicked',
|
|
107
116
|
componentName: 'button',
|
|
108
117
|
packageName: "@atlaskit/button",
|
|
109
|
-
packageVersion: "16.
|
|
118
|
+
packageVersion: "16.11.0",
|
|
110
119
|
analyticsData: analyticsContext,
|
|
111
120
|
actionSubject: buttonType
|
|
112
121
|
});
|
|
@@ -116,14 +125,18 @@ var useButtonBase = function useButtonBase(_ref) {
|
|
|
116
125
|
spacing: spacing,
|
|
117
126
|
isDisabled: isDisabled,
|
|
118
127
|
isSelected: isSelected,
|
|
128
|
+
isHighlighted: isHighlighted,
|
|
129
|
+
isActiveOverSelected: isActiveOverSelected,
|
|
119
130
|
shouldFitContainer: shouldFitContainer,
|
|
120
131
|
isIconButton: isIconButton,
|
|
121
132
|
hasOverlay: Boolean(overlay),
|
|
122
133
|
isLink: buttonType === 'link',
|
|
123
134
|
hasIconBefore: hasIconBefore,
|
|
124
|
-
hasIconAfter: hasIconAfter
|
|
135
|
+
hasIconAfter: hasIconAfter,
|
|
136
|
+
isSplit: isSplitButton,
|
|
137
|
+
isNavigationSplit: isNavigationSplitButton
|
|
125
138
|
});
|
|
126
|
-
}, [appearance, buttonType, spacing, isDisabled, isSelected, isIconButton, shouldFitContainer, overlay, hasIconBefore, hasIconAfter]);
|
|
139
|
+
}, [appearance, buttonType, spacing, isDisabled, isSelected, isHighlighted, isActiveOverSelected, isIconButton, shouldFitContainer, overlay, hasIconBefore, hasIconAfter, isSplitButton, isNavigationSplitButton]);
|
|
127
140
|
var isEffectivelyDisabled = isDisabled || Boolean(overlay);
|
|
128
141
|
return _objectSpread({
|
|
129
142
|
ref: setRef,
|
|
@@ -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.11.0",
|
|
122
122
|
analyticsData: analyticsContext
|
|
123
123
|
});
|
|
124
124
|
|
|
@@ -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
|
+
};
|