@atlaskit/smart-card 21.0.2 → 21.1.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 +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/title-block/index.js +13 -4
- package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +16 -3
- package/dist/cjs/view/FlexibleCard/components/utils.js +7 -2
- 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/title-block/index.js +12 -2
- package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +23 -2
- package/dist/es2019/view/FlexibleCard/components/utils.js +6 -0
- 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/title-block/index.js +13 -5
- package/dist/esm/view/FlexibleCard/components/blocks/utils.js +14 -2
- package/dist/esm/view/FlexibleCard/components/utils.js +3 -1
- package/dist/types/index.d.ts +1 -1
- 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/title-block/types.d.ts +6 -1
- package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +3 -0
- 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 +41 -2
|
@@ -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
|
|
@@ -2,11 +2,11 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
4
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
5
|
-
var _excluded = ["actions", "anchorTarget", "hideTitleTooltip", "maxLines", "onClick", "overrideCss", "status", "showActionOnHover", "testId", "text", "theme"];
|
|
5
|
+
var _excluded = ["actions", "anchorTarget", "hideTitleTooltip", "maxLines", "onActionMenuOpenChange", "onClick", "overrideCss", "status", "showActionOnHover", "testId", "text", "theme"];
|
|
6
6
|
|
|
7
7
|
var _templateObject, _templateObject2;
|
|
8
8
|
|
|
9
|
-
import React, { useState } from 'react';
|
|
9
|
+
import React, { useCallback, useState } from 'react';
|
|
10
10
|
import { css } from '@emotion/core';
|
|
11
11
|
import { SmartLinkStatus } from '../../../../../constants';
|
|
12
12
|
import TitleBlockResolvedView from './resolved';
|
|
@@ -59,6 +59,7 @@ var TitleBlock = function TitleBlock(_ref) {
|
|
|
59
59
|
anchorTarget = _ref.anchorTarget,
|
|
60
60
|
hideTitleTooltip = _ref.hideTitleTooltip,
|
|
61
61
|
maxLines = _ref.maxLines,
|
|
62
|
+
onActionMenuOpenChange = _ref.onActionMenuOpenChange,
|
|
62
63
|
onClick = _ref.onClick,
|
|
63
64
|
overrideCss = _ref.overrideCss,
|
|
64
65
|
_ref$status = _ref.status,
|
|
@@ -75,12 +76,19 @@ var TitleBlock = function TitleBlock(_ref) {
|
|
|
75
76
|
actionDropdownOpen = _useState2[0],
|
|
76
77
|
setActionDropdownOpen = _useState2[1];
|
|
77
78
|
|
|
79
|
+
var onDropdownOpenChange = useCallback(function (isOpen) {
|
|
80
|
+
setActionDropdownOpen(isOpen);
|
|
81
|
+
|
|
82
|
+
if (onActionMenuOpenChange) {
|
|
83
|
+
onActionMenuOpenChange({
|
|
84
|
+
isOpen: isOpen
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}, [onActionMenuOpenChange]);
|
|
78
88
|
var actionGroup = actions.length > 0 && /*#__PURE__*/React.createElement(ActionGroup, {
|
|
79
89
|
items: actions,
|
|
80
90
|
visibleButtonsNum: showActionOnHover ? 1 : 2,
|
|
81
|
-
onDropdownOpenChange:
|
|
82
|
-
return setActionDropdownOpen(isOpen);
|
|
83
|
-
}
|
|
91
|
+
onDropdownOpenChange: onDropdownOpenChange
|
|
84
92
|
});
|
|
85
93
|
var actionStyles = getActionStyles(showActionOnHover, actionDropdownOpen);
|
|
86
94
|
var combinedCss = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", " ", "\n "])), actionStyles, overrideCss);
|
|
@@ -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,
|
package/dist/types/index.d.ts
CHANGED
|
@@ -18,5 +18,5 @@ export { contentFooterClassName, metadataListClassName, blockCardResolvingViewCl
|
|
|
18
18
|
export { loadingPlaceholderClassName } from './view/CardWithUrl/component-lazy/LazyFallback';
|
|
19
19
|
export { ActionName, ElementName, SmartLinkDirection, SmartLinkPosition, SmartLinkSize, SmartLinkTheme, } from './constants';
|
|
20
20
|
export { MetadataBlock, PreviewBlock, SnippetBlock, TitleBlock, FooterBlock, } from './view/FlexibleCard/components/blocks';
|
|
21
|
-
export type { ActionItem, ElementItem, } from './view/FlexibleCard/components/blocks/types';
|
|
21
|
+
export type { ActionItem, ElementItem, OnActionMenuOpenChangeOptions, } from './view/FlexibleCard/components/blocks/types';
|
|
22
22
|
export type { AnalyticsAction, AnalyticsActionSubject, AnalyticsPayload, AnalyticsHandler, } from './utils/types';
|
|
@@ -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
|
-
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ActionItem, BlockProps, ElementItem } from '../types';
|
|
2
|
+
import { ActionItem, BlockProps, ElementItem, OnActionMenuOpenChangeOptions } from '../types';
|
|
3
3
|
import { SmartLinkPosition, SmartLinkTheme } from '../../../../../constants';
|
|
4
4
|
import { RetryOptions } from '../../../types';
|
|
5
5
|
import { AnchorTarget } from '../../types';
|
|
@@ -34,6 +34,11 @@ export declare type TitleBlockProps = {
|
|
|
34
34
|
* @see ElementItem
|
|
35
35
|
*/
|
|
36
36
|
metadata?: ElementItem[];
|
|
37
|
+
/**
|
|
38
|
+
* Called when the action dropdown menu (if present) is open/closed.
|
|
39
|
+
* Receives an object with `isOpen` state.
|
|
40
|
+
*/
|
|
41
|
+
onActionMenuOpenChange?: (options: OnActionMenuOpenChangeOptions) => void;
|
|
37
42
|
/**
|
|
38
43
|
* Determines the position of the link icon in relative to the vertical
|
|
39
44
|
* height of the TitleBlock. It can either be centred or placed on “top”.
|
|
@@ -100,6 +100,9 @@ export declare type CustomActionItem = BaseActionItem & {
|
|
|
100
100
|
name: ActionName.CustomAction;
|
|
101
101
|
} & ((Required<Pick<ActionProps, 'icon' | 'iconPosition'>> & Pick<ActionProps, 'content'>) | ((Required<Pick<ActionProps, 'content'>> & Pick<ActionProps, 'icon' | 'iconPosition'>) & Pick<ActionProps, 'tooltipMessage'>));
|
|
102
102
|
export declare type ActionItem = NamedActionItem | CustomActionItem;
|
|
103
|
+
export declare type OnActionMenuOpenChangeOptions = {
|
|
104
|
+
isOpen: boolean;
|
|
105
|
+
};
|
|
103
106
|
/**
|
|
104
107
|
* A type that contains all the possible combinations of elements with their corresponding props.
|
|
105
108
|
*/
|
|
@@ -7,6 +7,7 @@ export declare type ElementDisplaySchemaType = 'inline' | 'block';
|
|
|
7
7
|
export declare const ElementDisplaySchema: Record<ElementName, ElementDisplaySchemaType[]>;
|
|
8
8
|
export declare const getGapSize: (size: SmartLinkSize) => number;
|
|
9
9
|
export declare const getBaseStyles: (direction: SmartLinkDirection, size: SmartLinkSize) => SerializedStyles;
|
|
10
|
+
export declare const highlightRemoveStyles: SerializedStyles;
|
|
10
11
|
export declare const renderChildren: (children: React.ReactNode, size: SmartLinkSize) => React.ReactNode;
|
|
11
12
|
export declare const renderElementItems: (items?: ElementItem[], display?: ElementDisplaySchemaType) => React.ReactNode | undefined;
|
|
12
|
-
export declare const renderActionItems: (items?: ActionItem[], size?: SmartLinkSize, appearance?: Appearance | undefined, asDropDownItems?: boolean | undefined) => React.ReactNode | undefined;
|
|
13
|
+
export declare const renderActionItems: (items?: ActionItem[], size?: SmartLinkSize, appearance?: Appearance | undefined, asDropDownItems?: boolean | undefined, onActionItemClick?: (() => void) | undefined) => React.ReactNode | undefined;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { SerializedStyles } from '@emotion/core';
|
|
3
|
+
import { Spacing } from '@atlaskit/button';
|
|
3
4
|
import { SmartLinkSize } from '../../../constants';
|
|
4
5
|
import { MessageProps } from './types';
|
|
6
|
+
export declare const sizeToButtonSpacing: Record<SmartLinkSize, Spacing>;
|
|
5
7
|
export declare const getFormattedMessage: (message?: MessageProps | undefined) => JSX.Element | undefined;
|
|
6
8
|
export declare const getIconSizeStyles: (width: string) => SerializedStyles;
|
|
7
9
|
export declare const getIconWidth: (size?: SmartLinkSize | undefined) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/smart-card",
|
|
3
|
-
"version": "21.0
|
|
3
|
+
"version": "21.1.0",
|
|
4
4
|
"description": "Smart card component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@atlaskit/avatar": "^21.0.0",
|
|
28
28
|
"@atlaskit/avatar-group": "^9.0.0",
|
|
29
29
|
"@atlaskit/button": "^16.3.0",
|
|
30
|
-
"@atlaskit/dropdown-menu": "^11.
|
|
30
|
+
"@atlaskit/dropdown-menu": "^11.3.0",
|
|
31
31
|
"@atlaskit/icon": "^21.10.0",
|
|
32
32
|
"@atlaskit/icon-file-type": "^6.3.0",
|
|
33
33
|
"@atlaskit/icon-object": "^6.2.0",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"@atlaskit/linking-common": "^1.5.0",
|
|
37
37
|
"@atlaskit/logo": "^13.8.0",
|
|
38
38
|
"@atlaskit/lozenge": "^11.1.0",
|
|
39
|
-
"@atlaskit/media-common": "^2.
|
|
39
|
+
"@atlaskit/media-common": "^2.16.0",
|
|
40
40
|
"@atlaskit/modal-dialog": "^12.2.0",
|
|
41
41
|
"@atlaskit/outbound-auth-flow-client": "^3.3.0",
|
|
42
|
-
"@atlaskit/popup": "^1.
|
|
42
|
+
"@atlaskit/popup": "^1.4.0",
|
|
43
43
|
"@atlaskit/spinner": "^15.1.0",
|
|
44
44
|
"@atlaskit/theme": "^12.1.0",
|
|
45
45
|
"@atlaskit/tokens": "^0.10.0",
|
|
@@ -66,6 +66,7 @@
|
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@atlaskit/avatar": "^21.0.0",
|
|
68
68
|
"@atlaskit/checkbox": "^12.3.0",
|
|
69
|
+
"@atlaskit/code": "^14.3.0",
|
|
69
70
|
"@atlaskit/css-reset": "^6.3.0",
|
|
70
71
|
"@atlaskit/docs": "*",
|
|
71
72
|
"@atlaskit/field-base": "^15.0.6",
|
|
@@ -78,11 +79,12 @@
|
|
|
78
79
|
"@atlaskit/radio": "^5.3.0",
|
|
79
80
|
"@atlaskit/range": "^6.0.0",
|
|
80
81
|
"@atlaskit/section-message": "^6.1.5",
|
|
81
|
-
"@atlaskit/select": "^15.
|
|
82
|
+
"@atlaskit/select": "^15.6.0",
|
|
82
83
|
"@atlaskit/table-tree": "^9.1.0",
|
|
83
84
|
"@atlaskit/tabs": "^13.2.10",
|
|
84
85
|
"@atlaskit/textarea": "^4.3.0",
|
|
85
86
|
"@atlaskit/textfield": "^5.1.0",
|
|
87
|
+
"@atlaskit/toggle": "^12.4.0",
|
|
86
88
|
"@atlaskit/visual-regression": "*",
|
|
87
89
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
88
90
|
"@testing-library/jest-dom": "^4.1.0",
|
|
@@ -103,6 +105,7 @@
|
|
|
103
105
|
"mockdate": "^3.0.2",
|
|
104
106
|
"react": "^16.8.0",
|
|
105
107
|
"react-ace": "^6.1.0",
|
|
108
|
+
"react-beautiful-dnd": "^12.1.1",
|
|
106
109
|
"react-dom": "^16.8.0",
|
|
107
110
|
"react-intl-next": "npm:react-intl@^5.18.1",
|
|
108
111
|
"react-test-renderer": "^16.8.0",
|