@atlaskit/smart-card 21.0.1 → 21.0.4
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 +18 -0
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/FlexibleCard/components/actions/action/action-button/index.js +87 -0
- package/dist/cjs/view/FlexibleCard/components/actions/action/action-button/types.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/actions/action/action-dropdown-item/index.js +31 -0
- package/dist/cjs/view/FlexibleCard/components/actions/action/action-dropdown-item/types.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/actions/action/action-icon/index.js +52 -0
- package/dist/cjs/view/FlexibleCard/components/actions/action/action-icon/types.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/actions/action/index.js +42 -104
- package/dist/cjs/view/FlexibleCard/components/blocks/action-group/index.js +44 -15
- package/dist/cjs/view/FlexibleCard/components/blocks/block/index.js +1 -1
- package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +16 -3
- package/dist/cjs/view/FlexibleCard/components/utils.js +7 -2
- package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +20 -20
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/FlexibleCard/components/actions/action/action-button/index.js +88 -0
- package/dist/es2019/view/FlexibleCard/components/actions/action/action-button/types.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/actions/action/action-dropdown-item/index.js +18 -0
- package/dist/es2019/view/FlexibleCard/components/actions/action/action-dropdown-item/types.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/actions/action/action-icon/index.js +35 -0
- package/dist/es2019/view/FlexibleCard/components/actions/action/action-icon/types.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/actions/action/index.js +26 -110
- package/dist/es2019/view/FlexibleCard/components/blocks/action-group/index.js +31 -12
- package/dist/es2019/view/FlexibleCard/components/blocks/block/index.js +2 -1
- package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +23 -2
- package/dist/es2019/view/FlexibleCard/components/utils.js +6 -0
- package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +20 -20
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/FlexibleCard/components/actions/action/action-button/index.js +67 -0
- package/dist/esm/view/FlexibleCard/components/actions/action/action-button/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/actions/action/action-dropdown-item/index.js +19 -0
- package/dist/esm/view/FlexibleCard/components/actions/action/action-dropdown-item/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/actions/action/action-icon/index.js +39 -0
- package/dist/esm/view/FlexibleCard/components/actions/action/action-icon/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/actions/action/index.js +41 -99
- package/dist/esm/view/FlexibleCard/components/blocks/action-group/index.js +44 -16
- package/dist/esm/view/FlexibleCard/components/blocks/block/index.js +2 -2
- package/dist/esm/view/FlexibleCard/components/blocks/utils.js +14 -2
- package/dist/esm/view/FlexibleCard/components/utils.js +3 -1
- package/dist/esm/view/HoverCard/components/HoverCardComponent.js +20 -20
- package/dist/types/view/FlexibleCard/components/actions/action/action-button/index.d.ts +5 -0
- package/dist/types/view/FlexibleCard/components/actions/action/action-button/types.d.ts +8 -0
- package/dist/types/view/FlexibleCard/components/actions/action/action-dropdown-item/index.d.ts +4 -0
- package/dist/types/view/FlexibleCard/components/actions/action/action-dropdown-item/types.d.ts +8 -0
- package/dist/types/view/FlexibleCard/components/actions/action/action-icon/index.d.ts +5 -0
- package/dist/types/view/FlexibleCard/components/actions/action/action-icon/types.d.ts +7 -0
- package/dist/types/view/FlexibleCard/components/actions/action/index.d.ts +0 -3
- package/dist/types/view/FlexibleCard/components/actions/action/types.d.ts +0 -16
- package/dist/types/view/FlexibleCard/components/blocks/utils.d.ts +2 -1
- package/dist/types/view/FlexibleCard/components/utils.d.ts +2 -0
- package/package.json +8 -5
- package/report.api.md +32 -2
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
|
|
3
|
+
var _templateObject, _templateObject2;
|
|
4
|
+
|
|
5
|
+
/** @jsx jsx */
|
|
6
|
+
import React, { useCallback } from 'react';
|
|
7
|
+
import { css, jsx } from '@emotion/core';
|
|
8
|
+
import Button from '@atlaskit/button/custom-theme-button';
|
|
9
|
+
import Tooltip from '@atlaskit/tooltip';
|
|
10
|
+
import { SmartLinkSize } from '../../../../../../constants';
|
|
11
|
+
import { sizeToButtonSpacing } from '../../../utils';
|
|
12
|
+
|
|
13
|
+
var getButtonStyle = function getButtonStyle(size, iconOnly) {
|
|
14
|
+
switch (size) {
|
|
15
|
+
case SmartLinkSize.Large:
|
|
16
|
+
return iconOnly ? css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n button,\n button:hover,\n button:focus,\n button:active {\n padding: 0;\n > span {\n margin: 0;\n }\n }\n "]))) : '';
|
|
17
|
+
|
|
18
|
+
case SmartLinkSize.Small:
|
|
19
|
+
return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n font-size: 0.75rem;\n font-weight: 500;\n line-height: 1rem;\n button,\n button:hover,\n button:focus,\n button:active {\n line-height: 1rem;\n ", "\n }\n "])), iconOnly ? "\n padding: 0.125rem;\n " : "\n padding-left: 0.25rem;\n padding-right: 0.25rem;\n ");
|
|
20
|
+
|
|
21
|
+
case SmartLinkSize.XLarge:
|
|
22
|
+
case SmartLinkSize.Medium:
|
|
23
|
+
default:
|
|
24
|
+
return '';
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var ActionButton = function ActionButton(_ref) {
|
|
29
|
+
var appearance = _ref.appearance,
|
|
30
|
+
content = _ref.content,
|
|
31
|
+
iconAfter = _ref.iconAfter,
|
|
32
|
+
iconBefore = _ref.iconBefore,
|
|
33
|
+
onClick = _ref.onClick,
|
|
34
|
+
overrideCss = _ref.overrideCss,
|
|
35
|
+
size = _ref.size,
|
|
36
|
+
testId = _ref.testId,
|
|
37
|
+
tooltipMessage = _ref.tooltipMessage;
|
|
38
|
+
var iconOnly = !content;
|
|
39
|
+
var onButtonClick = useCallback(function (handler) {
|
|
40
|
+
return function (e) {
|
|
41
|
+
e.preventDefault();
|
|
42
|
+
handler();
|
|
43
|
+
};
|
|
44
|
+
}, []);
|
|
45
|
+
var onContainerClick = useCallback(function (e) {
|
|
46
|
+
// Stop button on click event from propagate into parent container.
|
|
47
|
+
e.stopPropagation();
|
|
48
|
+
}, []);
|
|
49
|
+
return jsx("div", {
|
|
50
|
+
css: [getButtonStyle(size, iconOnly), overrideCss],
|
|
51
|
+
"data-testid": "".concat(testId, "-button-wrapper"),
|
|
52
|
+
onClick: onContainerClick
|
|
53
|
+
}, jsx(Tooltip, {
|
|
54
|
+
content: tooltipMessage,
|
|
55
|
+
hideTooltipOnClick: true,
|
|
56
|
+
testId: "".concat(testId, "-tooltip")
|
|
57
|
+
}, jsx(Button, {
|
|
58
|
+
appearance: appearance,
|
|
59
|
+
iconAfter: iconAfter,
|
|
60
|
+
iconBefore: iconBefore,
|
|
61
|
+
onClick: onButtonClick(onClick),
|
|
62
|
+
spacing: sizeToButtonSpacing[size],
|
|
63
|
+
testId: testId
|
|
64
|
+
}, content)));
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export default ActionButton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DropdownItem } from '@atlaskit/dropdown-menu';
|
|
3
|
+
import { handleOnClick } from '../../../../../../utils';
|
|
4
|
+
|
|
5
|
+
var ActionDropdownItem = function ActionDropdownItem(_ref) {
|
|
6
|
+
var content = _ref.content,
|
|
7
|
+
iconAfter = _ref.iconAfter,
|
|
8
|
+
iconBefore = _ref.iconBefore,
|
|
9
|
+
onClick = _ref.onClick,
|
|
10
|
+
testId = _ref.testId;
|
|
11
|
+
return /*#__PURE__*/React.createElement(DropdownItem, {
|
|
12
|
+
elemAfter: iconAfter,
|
|
13
|
+
elemBefore: iconBefore,
|
|
14
|
+
onClick: handleOnClick(onClick),
|
|
15
|
+
testId: testId
|
|
16
|
+
}, content);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default ActionDropdownItem;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
|
|
3
|
+
var _templateObject;
|
|
4
|
+
|
|
5
|
+
/** @jsx jsx */
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { css, jsx } from '@emotion/core';
|
|
8
|
+
import { SmartLinkSize } from '../../../../../../constants';
|
|
9
|
+
import { tokens } from '../../../../../../utils/token';
|
|
10
|
+
import { getIconSizeStyles } from '../../../utils';
|
|
11
|
+
|
|
12
|
+
var getIconWidth = function getIconWidth(size) {
|
|
13
|
+
switch (size) {
|
|
14
|
+
case SmartLinkSize.XLarge:
|
|
15
|
+
case SmartLinkSize.Large:
|
|
16
|
+
return '1.5rem';
|
|
17
|
+
|
|
18
|
+
case SmartLinkSize.Medium:
|
|
19
|
+
case SmartLinkSize.Small:
|
|
20
|
+
default:
|
|
21
|
+
return '1rem';
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
var getIconStyles = function getIconStyles(size) {
|
|
26
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n ", ";\n"])), tokens.actionIcon, getIconSizeStyles(getIconWidth(size)));
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
var ActionIcon = function ActionIcon(_ref) {
|
|
30
|
+
var size = _ref.size,
|
|
31
|
+
testId = _ref.testId,
|
|
32
|
+
icon = _ref.icon;
|
|
33
|
+
return jsx("span", {
|
|
34
|
+
css: getIconStyles(size),
|
|
35
|
+
"data-testid": "".concat(testId, "-icon")
|
|
36
|
+
}, icon);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default ActionIcon;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,62 +1,10 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
3
|
-
|
|
4
|
-
var _templateObject, _templateObject2, _templateObject3, _sizeToSpacing;
|
|
5
|
-
|
|
6
1
|
/** @jsx jsx */
|
|
7
2
|
import React from 'react';
|
|
8
|
-
import {
|
|
9
|
-
import Button from '@atlaskit/button/custom-theme-button';
|
|
3
|
+
import { jsx } from '@emotion/core';
|
|
10
4
|
import { SmartLinkSize } from '../../../../../constants';
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import { tokens } from '../../../../../utils/token';
|
|
15
|
-
import { handleOnClick } from '../../../../../utils';
|
|
16
|
-
|
|
17
|
-
var getIconWidth = function getIconWidth(size) {
|
|
18
|
-
switch (size) {
|
|
19
|
-
case SmartLinkSize.XLarge:
|
|
20
|
-
case SmartLinkSize.Large:
|
|
21
|
-
return '1.5rem';
|
|
22
|
-
|
|
23
|
-
case SmartLinkSize.Medium:
|
|
24
|
-
case SmartLinkSize.Small:
|
|
25
|
-
default:
|
|
26
|
-
return '1rem';
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
var getIconStyles = function getIconStyles(size) {
|
|
31
|
-
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n ", ";\n"])), tokens.actionIcon, getIconSizeStyles(getIconWidth(size)));
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
var getButtonStyle = function getButtonStyle(size, iconOnly) {
|
|
35
|
-
switch (size) {
|
|
36
|
-
case SmartLinkSize.Large:
|
|
37
|
-
return iconOnly ? css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n button,\n button:hover,\n button:focus,\n button:active {\n padding: 0;\n > span {\n margin: 0;\n }\n }\n "]))) : '';
|
|
38
|
-
|
|
39
|
-
case SmartLinkSize.Small:
|
|
40
|
-
return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n font-size: 0.75rem;\n font-weight: 500;\n line-height: 1rem;\n button,\n button:hover,\n button:focus,\n button:active {\n line-height: 1rem;\n ", "\n }\n "])), iconOnly ? "\n padding: 0.125rem;\n " : "\n padding-left: 0.25rem;\n padding-right: 0.25rem;\n ");
|
|
41
|
-
|
|
42
|
-
case SmartLinkSize.XLarge:
|
|
43
|
-
case SmartLinkSize.Medium:
|
|
44
|
-
default:
|
|
45
|
-
return '';
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
var ActionIcon = function ActionIcon(_ref) {
|
|
50
|
-
var size = _ref.size,
|
|
51
|
-
testId = _ref.testId,
|
|
52
|
-
icon = _ref.icon;
|
|
53
|
-
return jsx("span", {
|
|
54
|
-
css: getIconStyles(size),
|
|
55
|
-
"data-testid": "".concat(testId, "-icon")
|
|
56
|
-
}, icon);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export var sizeToSpacing = (_sizeToSpacing = {}, _defineProperty(_sizeToSpacing, SmartLinkSize.Small, 'none'), _defineProperty(_sizeToSpacing, SmartLinkSize.Medium, 'compact'), _defineProperty(_sizeToSpacing, SmartLinkSize.Large, 'compact'), _defineProperty(_sizeToSpacing, SmartLinkSize.XLarge, 'default'), _sizeToSpacing);
|
|
5
|
+
import ActionButton from './action-button';
|
|
6
|
+
import ActionDropdownItem from './action-dropdown-item';
|
|
7
|
+
import ActionIcon from './action-icon';
|
|
60
8
|
/**
|
|
61
9
|
* A base action that can be triggered with an on click.
|
|
62
10
|
* @internal
|
|
@@ -66,60 +14,54 @@ export var sizeToSpacing = (_sizeToSpacing = {}, _defineProperty(_sizeToSpacing,
|
|
|
66
14
|
* @see CustomAction
|
|
67
15
|
*/
|
|
68
16
|
|
|
69
|
-
var Action = function Action(
|
|
70
|
-
var
|
|
71
|
-
appearance =
|
|
72
|
-
content =
|
|
73
|
-
onClick =
|
|
74
|
-
|
|
75
|
-
size =
|
|
76
|
-
|
|
77
|
-
testId =
|
|
78
|
-
icon =
|
|
79
|
-
|
|
80
|
-
iconPosition =
|
|
81
|
-
tooltipMessage =
|
|
82
|
-
asDropDownItem =
|
|
83
|
-
overrideCss =
|
|
17
|
+
var Action = function Action(_ref) {
|
|
18
|
+
var _ref$appearance = _ref.appearance,
|
|
19
|
+
appearance = _ref$appearance === void 0 ? 'subtle' : _ref$appearance,
|
|
20
|
+
content = _ref.content,
|
|
21
|
+
onClick = _ref.onClick,
|
|
22
|
+
_ref$size = _ref.size,
|
|
23
|
+
size = _ref$size === void 0 ? SmartLinkSize.Medium : _ref$size,
|
|
24
|
+
_ref$testId = _ref.testId,
|
|
25
|
+
testId = _ref$testId === void 0 ? 'smart-action' : _ref$testId,
|
|
26
|
+
icon = _ref.icon,
|
|
27
|
+
_ref$iconPosition = _ref.iconPosition,
|
|
28
|
+
iconPosition = _ref$iconPosition === void 0 ? 'before' : _ref$iconPosition,
|
|
29
|
+
tooltipMessage = _ref.tooltipMessage,
|
|
30
|
+
asDropDownItem = _ref.asDropDownItem,
|
|
31
|
+
overrideCss = _ref.overrideCss;
|
|
84
32
|
|
|
85
33
|
if (!onClick) {
|
|
86
34
|
return null;
|
|
87
35
|
}
|
|
88
36
|
|
|
89
|
-
var
|
|
37
|
+
var actionIcon = icon && jsx(ActionIcon, {
|
|
38
|
+
icon: icon,
|
|
90
39
|
size: size,
|
|
91
|
-
testId: testId
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
var iconAfter = icon && iconPosition === 'after' ?
|
|
95
|
-
size: size,
|
|
96
|
-
testId: testId,
|
|
97
|
-
icon: icon
|
|
98
|
-
}) : undefined;
|
|
99
|
-
var iconOnly = !content;
|
|
40
|
+
testId: testId
|
|
41
|
+
});
|
|
42
|
+
var iconBefore = icon && iconPosition === 'before' ? actionIcon : undefined;
|
|
43
|
+
var iconAfter = icon && iconPosition === 'after' ? actionIcon : undefined;
|
|
100
44
|
|
|
101
45
|
if (asDropDownItem) {
|
|
102
|
-
return jsx(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
onClick:
|
|
107
|
-
|
|
46
|
+
return jsx(ActionDropdownItem, {
|
|
47
|
+
content: content,
|
|
48
|
+
iconAfter: iconAfter,
|
|
49
|
+
iconBefore: iconBefore,
|
|
50
|
+
onClick: onClick,
|
|
51
|
+
testId: testId
|
|
52
|
+
});
|
|
108
53
|
} else {
|
|
109
|
-
return jsx(
|
|
110
|
-
content: tooltipMessage,
|
|
111
|
-
testId: "".concat(testId, "-tooltip")
|
|
112
|
-
}, jsx("div", {
|
|
113
|
-
css: [getButtonStyle(size, iconOnly), overrideCss],
|
|
114
|
-
"data-testid": "".concat(testId, "-button-wrapper")
|
|
115
|
-
}, jsx(Button, {
|
|
116
|
-
spacing: sizeToSpacing[size],
|
|
54
|
+
return jsx(ActionButton, {
|
|
117
55
|
appearance: appearance,
|
|
118
|
-
|
|
119
|
-
|
|
56
|
+
content: content,
|
|
57
|
+
iconAfter: iconAfter,
|
|
120
58
|
iconBefore: iconBefore,
|
|
121
|
-
|
|
122
|
-
|
|
59
|
+
onClick: onClick,
|
|
60
|
+
overrideCss: overrideCss,
|
|
61
|
+
size: size,
|
|
62
|
+
testId: testId,
|
|
63
|
+
tooltipMessage: tooltipMessage
|
|
64
|
+
});
|
|
123
65
|
}
|
|
124
66
|
};
|
|
125
67
|
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
4
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
4
5
|
var _excluded = ["triggerRef"];
|
|
5
6
|
|
|
6
7
|
var _templateObject;
|
|
7
8
|
|
|
8
9
|
/** @jsx jsx */
|
|
9
|
-
import { useCallback } from 'react';
|
|
10
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
10
11
|
import { FormattedMessage } from 'react-intl-next';
|
|
11
12
|
import { css, jsx } from '@emotion/core';
|
|
12
13
|
import ButtonGroup from '@atlaskit/button/button-group';
|
|
@@ -16,7 +17,7 @@ import DropdownMenu from '@atlaskit/dropdown-menu';
|
|
|
16
17
|
import { SmartLinkSize } from '../../../../../constants';
|
|
17
18
|
import Button from '@atlaskit/button/standard-button';
|
|
18
19
|
import MoreIcon from '@atlaskit/icon/glyph/more';
|
|
19
|
-
import {
|
|
20
|
+
import { sizeToButtonSpacing } from '../../utils';
|
|
20
21
|
import { tokens } from '../../../../../utils/token';
|
|
21
22
|
import { messages } from '../../../../../messages';
|
|
22
23
|
var styles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline-flex;\n line-height: 1rem;\n > div {\n align-items: center;\n button:focus {\n // AK button removes the default browser outline on focus and apply\n // box-shadow styling to create the outline appearance.\n // Due to our container elements (Container/Block/ElementGroup) has\n // overflow hidden to prevent the metadata element from leaking outside\n // of its container, the box-shadow doesn't show properly.\n // Invert the AK box-shadow styling.\n box-shadow: inset 0 0 0 2px ", ";\n }\n }\n"])), tokens.focus);
|
|
@@ -38,40 +39,67 @@ var ActionGroup = function ActionGroup(_ref) {
|
|
|
38
39
|
visibleButtonsNum = _ref$visibleButtonsNu === void 0 ? 2 : _ref$visibleButtonsNu,
|
|
39
40
|
onDropdownOpenChange = _ref.onDropdownOpenChange,
|
|
40
41
|
testId = _ref.testId;
|
|
41
|
-
|
|
42
|
-
var
|
|
43
|
-
|
|
42
|
+
|
|
43
|
+
var _useState = useState(false),
|
|
44
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
45
|
+
isOpen = _useState2[0],
|
|
46
|
+
setIsOpen = _useState2[1];
|
|
47
|
+
|
|
48
|
+
var _useMemo = useMemo(function () {
|
|
49
|
+
var isMoreThenTwoItems = items.length > visibleButtonsNum;
|
|
50
|
+
var buttons = isMoreThenTwoItems ? items.slice(0, visibleButtonsNum - 1) : items;
|
|
51
|
+
var dropdownItems = isMoreThenTwoItems ? items.slice(visibleButtonsNum - 1) : [];
|
|
52
|
+
return [buttons, dropdownItems];
|
|
53
|
+
}, [items, visibleButtonsNum]),
|
|
54
|
+
_useMemo2 = _slicedToArray(_useMemo, 2),
|
|
55
|
+
buttonActions = _useMemo2[0],
|
|
56
|
+
dropdownItemActions = _useMemo2[1]; // Stop AK dropdown menu to propagate event on click.
|
|
57
|
+
|
|
44
58
|
|
|
45
59
|
var onClick = useCallback(function (e) {
|
|
46
60
|
return e.stopPropagation();
|
|
47
61
|
}, []);
|
|
62
|
+
var onOpenChange = useCallback(function (attrs) {
|
|
63
|
+
setIsOpen(attrs.isOpen);
|
|
64
|
+
|
|
65
|
+
if (onDropdownOpenChange) {
|
|
66
|
+
onDropdownOpenChange(attrs.isOpen);
|
|
67
|
+
}
|
|
68
|
+
}, [onDropdownOpenChange]);
|
|
69
|
+
var onActionClick = useCallback(function () {
|
|
70
|
+
if (isOpen) {
|
|
71
|
+
onOpenChange({
|
|
72
|
+
isOpen: false
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}, [isOpen, onOpenChange]);
|
|
48
76
|
return jsx("div", {
|
|
49
77
|
css: styles,
|
|
50
78
|
className: "actions-button-group",
|
|
51
79
|
onClick: onClick
|
|
52
|
-
}, jsx(ButtonGroup, null, renderActionItems(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
var triggerRef = _ref3.triggerRef,
|
|
59
|
-
props = _objectWithoutProperties(_ref3, _excluded);
|
|
80
|
+
}, jsx(ButtonGroup, null, renderActionItems(buttonActions, size, appearance, false, onActionClick), dropdownItemActions.length > 0 ? jsx(DropdownMenu, {
|
|
81
|
+
isOpen: isOpen,
|
|
82
|
+
onOpenChange: onOpenChange,
|
|
83
|
+
trigger: function trigger(_ref2) {
|
|
84
|
+
var triggerRef = _ref2.triggerRef,
|
|
85
|
+
props = _objectWithoutProperties(_ref2, _excluded);
|
|
60
86
|
|
|
61
87
|
return jsx(Tooltip, {
|
|
62
88
|
content: jsx(FormattedMessage, messages.more_actions),
|
|
89
|
+
hideTooltipOnClick: true,
|
|
63
90
|
testId: "action-group-more-button-tooltip",
|
|
64
91
|
tag: "span"
|
|
65
92
|
}, jsx(Button, _extends({}, props, {
|
|
66
|
-
spacing:
|
|
93
|
+
spacing: sizeToButtonSpacing[size],
|
|
67
94
|
testId: "action-group-more-button",
|
|
68
95
|
iconBefore: jsx(MoreIcon, {
|
|
69
96
|
label: "more"
|
|
70
97
|
}),
|
|
71
98
|
ref: triggerRef
|
|
72
99
|
})));
|
|
73
|
-
}
|
|
74
|
-
|
|
100
|
+
},
|
|
101
|
+
testId: "action-group-dropdown"
|
|
102
|
+
}, renderActionItems(dropdownItemActions, size, appearance, true, onActionClick)) : null));
|
|
75
103
|
};
|
|
76
104
|
|
|
77
105
|
export default ActionGroup;
|
|
@@ -6,10 +6,10 @@ var _templateObject;
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { css, jsx } from '@emotion/core';
|
|
8
8
|
import { ElementName, SmartLinkDirection, SmartLinkSize } from '../../../../../constants';
|
|
9
|
-
import { getBaseStyles, getGapSize, renderChildren } from '../utils';
|
|
9
|
+
import { getBaseStyles, getGapSize, highlightRemoveStyles, renderChildren } from '../utils';
|
|
10
10
|
|
|
11
11
|
var getBlockStyles = function getBlockStyles(direction, size) {
|
|
12
|
-
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", "\n justify-content: flex-start;\n [data-separator] + [data-separator]:before {\n content: '\u2022';\n margin-right: ", "rem;\n }\n // Pull request elements: source branch \u2192 target branch\n [data-smart-element='", "']\n + [data-smart-element='", "']:before {\n content: '\u2192';\n }\n // Pull request elements: target branch \u2190 source branch\n [data-smart-element='", "']\n + [data-smart-element='", "']:before {\n content: '\u2190';\n }\n"])), getBaseStyles(direction, size), getGapSize(size), ElementName.SourceBranch, ElementName.TargetBranch, ElementName.TargetBranch, ElementName.SourceBranch);
|
|
12
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", "\n ", "\n justify-content: flex-start;\n [data-separator] + [data-separator]:before {\n content: '\u2022';\n margin-right: ", "rem;\n }\n // Pull request elements: source branch \u2192 target branch\n [data-smart-element='", "']\n + [data-smart-element='", "']:before {\n content: '\u2192';\n }\n // Pull request elements: target branch \u2190 source branch\n [data-smart-element='", "']\n + [data-smart-element='", "']:before {\n content: '\u2190';\n }\n"])), getBaseStyles(direction, size), highlightRemoveStyles, getGapSize(size), ElementName.SourceBranch, ElementName.TargetBranch, ElementName.TargetBranch, ElementName.SourceBranch);
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
15
|
* A block represents a collection of elements and actions that are arranged
|
|
@@ -6,7 +6,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
6
6
|
var _excluded = ["name"],
|
|
7
7
|
_excluded2 = ["name", "hideContent", "hideIcon", "onClick"];
|
|
8
8
|
|
|
9
|
-
var _ElementDisplaySchema, _templateObject, _templateObject2, _templateObject3;
|
|
9
|
+
var _ElementDisplaySchema, _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
10
10
|
|
|
11
11
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
12
12
|
|
|
@@ -52,6 +52,7 @@ export var getGapSize = function getGapSize(size) {
|
|
|
52
52
|
export var getBaseStyles = function getBaseStyles(direction, size) {
|
|
53
53
|
return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n align-items: center;\n display: flex;\n gap: ", "rem;\n line-height: 1rem;\n min-width: 0;\n overflow: hidden;\n ", ";\n &:empty {\n display: none;\n }\n & > * {\n min-width: 0;\n }\n & > [data-fit-to-content] {\n min-width: fit-content;\n }\n"])), getGapSize(size), getDirectionStyles(direction));
|
|
54
54
|
};
|
|
55
|
+
export var highlightRemoveStyles = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n outline: none !important;\n outline-color: inherit;\n color: inherit;\n -webkit-tap-highlight-color: transparent;\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n"])));
|
|
55
56
|
|
|
56
57
|
var isActionGroup = function isActionGroup(node) {
|
|
57
58
|
return /*#__PURE__*/React.isValidElement(node) && node.type === ActionGroup;
|
|
@@ -116,6 +117,7 @@ export var renderActionItems = function renderActionItems() {
|
|
|
116
117
|
var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : SmartLinkSize.Medium;
|
|
117
118
|
var appearance = arguments.length > 2 ? arguments[2] : undefined;
|
|
118
119
|
var asDropDownItems = arguments.length > 3 ? arguments[3] : undefined;
|
|
120
|
+
var onActionItemClick = arguments.length > 4 ? arguments[4] : undefined;
|
|
119
121
|
var actions = items.reduce(function (acc, curr, idx) {
|
|
120
122
|
var name = curr.name,
|
|
121
123
|
hideContent = curr.hideContent,
|
|
@@ -136,12 +138,22 @@ export var renderActionItems = function renderActionItems() {
|
|
|
136
138
|
}
|
|
137
139
|
|
|
138
140
|
if (Action) {
|
|
141
|
+
var handleOnClick = function handleOnClick() {
|
|
142
|
+
if (onActionItemClick) {
|
|
143
|
+
onActionItemClick();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (onClick) {
|
|
147
|
+
onClick();
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
|
|
139
151
|
return [].concat(_toConsumableArray(acc), [/*#__PURE__*/React.createElement(Action, _extends({
|
|
140
152
|
asDropDownItem: asDropDownItems,
|
|
141
153
|
size: size,
|
|
142
154
|
key: idx,
|
|
143
155
|
appearance: appearance,
|
|
144
|
-
onClick:
|
|
156
|
+
onClick: handleOnClick
|
|
145
157
|
}, actionProps))]);
|
|
146
158
|
}
|
|
147
159
|
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
4
|
|
|
4
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
5
|
+
var _sizeToButtonSpacing, _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
5
6
|
|
|
6
7
|
import React from 'react';
|
|
7
8
|
import { css } from '@emotion/core';
|
|
8
9
|
import { FormattedMessage } from 'react-intl-next';
|
|
9
10
|
import { SmartLinkSize } from '../../../constants';
|
|
11
|
+
export var sizeToButtonSpacing = (_sizeToButtonSpacing = {}, _defineProperty(_sizeToButtonSpacing, SmartLinkSize.Small, 'none'), _defineProperty(_sizeToButtonSpacing, SmartLinkSize.Medium, 'compact'), _defineProperty(_sizeToButtonSpacing, SmartLinkSize.Large, 'compact'), _defineProperty(_sizeToButtonSpacing, SmartLinkSize.XLarge, 'default'), _sizeToButtonSpacing);
|
|
10
12
|
export var getFormattedMessage = function getFormattedMessage(message) {
|
|
11
13
|
if (message) {
|
|
12
14
|
var descriptor = message.descriptor,
|
|
@@ -27,16 +27,23 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
27
27
|
var fadeOutTimeoutId = useRef();
|
|
28
28
|
var fadeInTimeoutId = useRef();
|
|
29
29
|
var cardOpenTime = useRef();
|
|
30
|
-
var mousePos = useRef(
|
|
31
|
-
x: 0,
|
|
32
|
-
y: 0
|
|
33
|
-
});
|
|
30
|
+
var mousePos = useRef();
|
|
34
31
|
var popupOffset = useRef();
|
|
35
32
|
var parentSpan = useRef(null);
|
|
36
33
|
var renderers = useSmartLinkRenderers();
|
|
37
34
|
var linkState = useLinkState(url);
|
|
38
35
|
var hoverDisplay = 'card';
|
|
39
36
|
var invokeMethod = 'mouse_hover';
|
|
37
|
+
var setMousePosition = useCallback(function (event) {
|
|
38
|
+
if (isOpen) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
mousePos.current = {
|
|
43
|
+
x: event.clientX,
|
|
44
|
+
y: event.clientY
|
|
45
|
+
};
|
|
46
|
+
}, [isOpen]);
|
|
40
47
|
var hideCard = useCallback(function () {
|
|
41
48
|
//Check its previously open to avoid firing events when moving between the child and hover card components
|
|
42
49
|
if (isOpen === true && cardOpenTime.current) {
|
|
@@ -55,19 +62,22 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
55
62
|
return hideCard();
|
|
56
63
|
}, delay);
|
|
57
64
|
}, [hideCard]);
|
|
58
|
-
var initShowCard = useCallback(function () {
|
|
65
|
+
var initShowCard = useCallback(function (event) {
|
|
59
66
|
if (fadeOutTimeoutId.current) {
|
|
60
67
|
clearTimeout(fadeOutTimeoutId.current);
|
|
61
|
-
}
|
|
68
|
+
} //Set mouse position in the case it's not already set by onMouseMove, as in the case of scrolling
|
|
69
|
+
|
|
62
70
|
|
|
71
|
+
setMousePosition(event);
|
|
63
72
|
fadeInTimeoutId.current = setTimeout(function () {
|
|
64
73
|
//Check if its previously closed to avoid firing events when moving between the child and hover card components
|
|
65
74
|
if (isOpen === false) {
|
|
66
75
|
cardOpenTime.current = Date.now();
|
|
67
76
|
analytics.ui.hoverCardViewedEvent(hoverDisplay, invokeMethod);
|
|
68
|
-
}
|
|
77
|
+
} //If these are undefined then popupOffset is undefined and we fallback to default bottom-start placement
|
|
78
|
+
|
|
69
79
|
|
|
70
|
-
if (parentSpan.current) {
|
|
80
|
+
if (parentSpan.current && mousePos.current) {
|
|
71
81
|
var _parentSpan$current$g = parentSpan.current.getBoundingClientRect(),
|
|
72
82
|
bottom = _parentSpan$current$g.bottom,
|
|
73
83
|
left = _parentSpan$current$g.left;
|
|
@@ -77,7 +87,7 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
77
87
|
|
|
78
88
|
setIsOpen(true);
|
|
79
89
|
}, delay);
|
|
80
|
-
}, [
|
|
90
|
+
}, [isOpen, setMousePosition, analytics.ui]);
|
|
81
91
|
var linkActions = useSmartLinkActions({
|
|
82
92
|
url: url,
|
|
83
93
|
appearance: SMART_CARD_ANALYTICS_DISPLAY,
|
|
@@ -87,17 +97,7 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
87
97
|
if (actionId === 'preview-content') {
|
|
88
98
|
hideCard();
|
|
89
99
|
}
|
|
90
|
-
}, [hideCard]);
|
|
91
|
-
var setMousePosition = useCallback(function (event) {
|
|
92
|
-
if (isOpen) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
mousePos.current = {
|
|
97
|
-
x: event.clientX,
|
|
98
|
-
y: event.clientY
|
|
99
|
-
};
|
|
100
|
-
}, [isOpen]); // Stop hover preview content to propagate event to parent.
|
|
100
|
+
}, [hideCard]); // Stop hover preview content to propagate event to parent.
|
|
101
101
|
|
|
102
102
|
var onClick = useCallback(function (e) {
|
|
103
103
|
return e.stopPropagation();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { SmartLinkSize } from '../../../../../../constants';
|
|
3
|
+
import { ActionProps } from '../types';
|
|
4
|
+
export declare type ActionButtonProps = ActionProps & {
|
|
5
|
+
iconAfter?: React.ReactChild;
|
|
6
|
+
iconBefore?: React.ReactChild;
|
|
7
|
+
size: SmartLinkSize;
|
|
8
|
+
};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { Spacing } from '@atlaskit/button';
|
|
4
|
-
import { SmartLinkSize } from '../../../../../constants';
|
|
5
3
|
import { ActionProps } from './types';
|
|
6
|
-
export declare const sizeToSpacing: Record<SmartLinkSize, Spacing>;
|
|
7
4
|
/**
|
|
8
5
|
* A base action that can be triggered with an on click.
|
|
9
6
|
* @internal
|
|
@@ -46,19 +46,3 @@ export declare type ActionProps = {
|
|
|
46
46
|
*/
|
|
47
47
|
testId?: string;
|
|
48
48
|
};
|
|
49
|
-
export declare type ActionIconProps = {
|
|
50
|
-
/**
|
|
51
|
-
* Determines the size of the Icon within the Action.
|
|
52
|
-
*/
|
|
53
|
-
size?: SmartLinkSize;
|
|
54
|
-
/**
|
|
55
|
-
* Determines the icon within the Action.
|
|
56
|
-
*/
|
|
57
|
-
icon?: ReactChild;
|
|
58
|
-
/**
|
|
59
|
-
* A `testId` prop is provided for specified elements, which is a unique
|
|
60
|
-
* string that appears as a data attribute `data-testid` in the rendered code,
|
|
61
|
-
* serving as a hook for automated tests
|
|
62
|
-
*/
|
|
63
|
-
testId?: string;
|
|
64
|
-
};
|