@atlaskit/smart-card 26.6.0 → 26.6.2
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 +13 -0
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/FlexibleCard/components/blocks/action-group/index.js +2 -1
- package/dist/cjs/view/FlexibleCard/components/container/index.js +27 -15
- package/dist/cjs/view/FlexibleCard/components/elements/lozenge/lozenge-action/index.js +2 -1
- package/dist/cjs/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-trigger/index.js +3 -1
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/FlexibleCard/components/blocks/action-group/index.js +2 -1
- package/dist/es2019/view/FlexibleCard/components/container/index.js +29 -15
- package/dist/es2019/view/FlexibleCard/components/elements/lozenge/lozenge-action/index.js +2 -1
- package/dist/es2019/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-trigger/index.js +2 -0
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/FlexibleCard/components/blocks/action-group/index.js +2 -1
- package/dist/esm/view/FlexibleCard/components/container/index.js +29 -17
- package/dist/esm/view/FlexibleCard/components/elements/lozenge/lozenge-action/index.js +2 -1
- package/dist/esm/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-trigger/index.js +3 -1
- package/dist/types/view/FlexibleCard/components/container/index.d.ts +1 -1
- package/dist/types/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-trigger/type.d.ts +1 -0
- package/dist/types-ts4.5/view/FlexibleCard/components/container/index.d.ts +1 -1
- package/dist/types-ts4.5/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-trigger/type.d.ts +1 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/smart-card
|
|
2
2
|
|
|
3
|
+
## 26.6.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 26.6.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`ebb6750a97d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ebb6750a97d) - [ux] Flexible Smart Links: Change hover preview show/hide behavior. Hover preview should not show when hovering over metadata elements and actions.
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
3
16
|
## 26.6.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
package/dist/cjs/version.json
CHANGED
|
@@ -140,7 +140,8 @@ var ActionGroup = function ActionGroup(_ref) {
|
|
|
140
140
|
}, [appearance, isMoreThenTwoItems, isOpen, onActionItemClick, onOpenChange, renderableActionItems, size, ui === null || ui === void 0 ? void 0 : ui.zIndex, visibleButtonsNum]);
|
|
141
141
|
return renderableActionItems.length > 0 ? (0, _react2.jsx)("div", {
|
|
142
142
|
css: styles,
|
|
143
|
-
className: "actions-button-group"
|
|
143
|
+
className: "actions-button-group",
|
|
144
|
+
"data-action-open": isOpen
|
|
144
145
|
}, (0, _react2.jsx)(_buttonGroup.default, null, actionButtons, moreActionDropdown)) : null;
|
|
145
146
|
};
|
|
146
147
|
var _default = ActionGroup;
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.getContainerStyles = exports.default = void 0;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
11
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
11
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
@@ -80,7 +81,7 @@ var getContainerStyles = function getContainerStyles(size, hideBackground, hideE
|
|
|
80
81
|
return (0, _react2.css)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n gap: ", " 0;\n flex-direction: column;\n min-width: 0;\n overflow-x: hidden;\n position: relative;\n ", "\n ", "\n ", "\n ", "\n &:hover ~ .actions-button-group {\n opacity: 1;\n }\n a:focus,\n .has-action:focus {\n outline-offset: -2px;\n }\n "])), getGap(size), hideBackground ? '' : "background-color: ".concat(_token.tokens.background, ";"), paddingCss, hideElevation ? '' : elevationStyles, clickableContainer ? clickableContainerStyles : '');
|
|
81
82
|
};
|
|
82
83
|
exports.getContainerStyles = getContainerStyles;
|
|
83
|
-
var renderChildren = function renderChildren(children, containerSize, containerTheme, status, retry, onClick
|
|
84
|
+
var renderChildren = function renderChildren(children, containerSize, containerTheme, status, retry, onClick) {
|
|
84
85
|
return _react.default.Children.map(children, function (child) {
|
|
85
86
|
// TODO: EDM-6468: Use useFlexibleUiOptionContext for rendering options inside block/element instead
|
|
86
87
|
if ( /*#__PURE__*/_react.default.isValidElement(child) && (0, _flexible.isFlexibleUiBlock)(child)) {
|
|
@@ -95,13 +96,6 @@ var renderChildren = function renderChildren(children, containerSize, containerT
|
|
|
95
96
|
status: status,
|
|
96
97
|
theme: containerTheme
|
|
97
98
|
});
|
|
98
|
-
} else if (onActionMenuOpenChange && (0, _flexible.isFlexibleUiFooterBlock)(child)) {
|
|
99
|
-
return /*#__PURE__*/_react.default.cloneElement(child, {
|
|
100
|
-
// @ts-expect-error
|
|
101
|
-
size: size,
|
|
102
|
-
status: status,
|
|
103
|
-
onActionMenuOpenChange: onActionMenuOpenChange
|
|
104
|
-
});
|
|
105
99
|
}
|
|
106
100
|
// @ts-expect-error
|
|
107
101
|
return /*#__PURE__*/_react.default.cloneElement(child, {
|
|
@@ -138,7 +132,7 @@ var getLayeredLink = function getLayeredLink(testId, context, children, onClick)
|
|
|
138
132
|
|
|
139
133
|
/**
|
|
140
134
|
* A container is a hidden component that build the Flexible Smart Link.
|
|
141
|
-
* All
|
|
135
|
+
* All the Flexible UI components are wrapped inside the container.
|
|
142
136
|
* It inherits the ui props from Card component and applies the custom styling
|
|
143
137
|
* accordingly.
|
|
144
138
|
* @internal
|
|
@@ -177,15 +171,33 @@ var Container = function Container(_ref3) {
|
|
|
177
171
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
178
172
|
hoverCardCanOpen = _useState2[0],
|
|
179
173
|
setHoverCardCanOpen = _useState2[1];
|
|
180
|
-
var
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
174
|
+
var canShowHoverPreview = showHoverPreview && status === 'resolved';
|
|
175
|
+
var canShowAuthTooltip = showAuthTooltip && status === 'unauthorized';
|
|
176
|
+
var onMouseOver = (0, _react.useCallback)(function (e) {
|
|
177
|
+
var _e$target$closest;
|
|
178
|
+
// Never show hover card on action or when action dropdown opens.
|
|
179
|
+
// The code below can be simplified by using :is() and :has()
|
|
180
|
+
// but the pseudo-class isn't support by Firefox yet.
|
|
181
|
+
var action =
|
|
182
|
+
// Any action button group (title/footer block)
|
|
183
|
+
e.target.closest('.actions-button-group') || ( // When action dropdown list is opened on action button group or lozenge action
|
|
184
|
+
(_e$target$closest = e.target.closest('[data-smart-link-container]')) === null || _e$target$closest === void 0 ? void 0 : _e$target$closest.querySelector('[data-action-open="true"]'));
|
|
185
|
+
var canOpen = canShowAuthTooltip && !action ||
|
|
186
|
+
// EDM-7060: For hover preview, also hide hover card on all elements
|
|
187
|
+
// except title element (link title)
|
|
188
|
+
canShowHoverPreview && !action && !e.target.closest("[data-smart-element]:not([data-smart-element=\"".concat(_constants.ElementName.Title, "\"])"));
|
|
189
|
+
if (hoverCardCanOpen !== canOpen) {
|
|
190
|
+
setHoverCardCanOpen(canOpen);
|
|
191
|
+
}
|
|
192
|
+
}, [canShowAuthTooltip, canShowHoverPreview, hoverCardCanOpen]);
|
|
193
|
+
var containerContent = (0, _react2.jsx)("div", (0, _extends2.default)({
|
|
184
194
|
css: getContainerStyles(size, hideBackground, hideElevation, hidePadding, clickableContainer, childrenOptions),
|
|
185
195
|
"data-smart-link-container": true,
|
|
186
196
|
"data-testid": testId
|
|
187
|
-
},
|
|
188
|
-
|
|
197
|
+
}, canShowHoverPreview || canShowAuthTooltip ? {
|
|
198
|
+
onMouseOver: onMouseOver
|
|
199
|
+
} : undefined), clickableContainer ? getLayeredLink(testId, context, children, onClick) : null, renderChildren(children, size, theme, status, retry, onClick));
|
|
200
|
+
if (context !== null && context !== void 0 && context.url && (canShowHoverPreview || canShowAuthTooltip)) {
|
|
189
201
|
return (0, _react2.jsx)(_HoverCard.HoverCard, {
|
|
190
202
|
url: context === null || context === void 0 ? void 0 : context.url,
|
|
191
203
|
canOpen: hoverCardCanOpen,
|
|
@@ -151,11 +151,12 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
151
151
|
var trigger = (0, _react2.useCallback)(function (props) {
|
|
152
152
|
return (0, _react.jsx)(_lozengeActionTrigger.default, (0, _extends2.default)({}, props, {
|
|
153
153
|
appearance: selected.appearance,
|
|
154
|
+
isOpen: isOpen,
|
|
154
155
|
showFeatureDiscovery: action === null || action === void 0 ? void 0 : action.showFeatureDiscovery,
|
|
155
156
|
testId: testId,
|
|
156
157
|
text: selected.text
|
|
157
158
|
}));
|
|
158
|
-
}, [selected.appearance, selected.text, action === null || action === void 0 ? void 0 : action.showFeatureDiscovery, testId]);
|
|
159
|
+
}, [selected.appearance, selected.text, isOpen, action === null || action === void 0 ? void 0 : action.showFeatureDiscovery, testId]);
|
|
159
160
|
var handleItemClick = (0, _react2.useCallback)( /*#__PURE__*/function () {
|
|
160
161
|
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(id, text, appearance) {
|
|
161
162
|
var updateAction, request;
|
|
@@ -14,10 +14,11 @@ var _lozenge = _interopRequireDefault(require("@atlaskit/lozenge"));
|
|
|
14
14
|
var _chevronDown = _interopRequireDefault(require("@atlaskit/icon/glyph/chevron-down"));
|
|
15
15
|
var _styled = require("../styled");
|
|
16
16
|
var _featureDiscovery = _interopRequireDefault(require("../feature-discovery"));
|
|
17
|
-
var _excluded = ["appearance", "showFeatureDiscovery", "testId", "text", "triggerRef"];
|
|
17
|
+
var _excluded = ["appearance", "isOpen", "showFeatureDiscovery", "testId", "text", "triggerRef"];
|
|
18
18
|
/** @jsx jsx */
|
|
19
19
|
var LozengeActionTrigger = function LozengeActionTrigger(_ref) {
|
|
20
20
|
var appearance = _ref.appearance,
|
|
21
|
+
isOpen = _ref.isOpen,
|
|
21
22
|
showFeatureDiscovery = _ref.showFeatureDiscovery,
|
|
22
23
|
testId = _ref.testId,
|
|
23
24
|
text = _ref.text,
|
|
@@ -48,6 +49,7 @@ var LozengeActionTrigger = function LozengeActionTrigger(_ref) {
|
|
|
48
49
|
type: "button"
|
|
49
50
|
}, props, {
|
|
50
51
|
css: _styled.triggerButtonStyles,
|
|
52
|
+
"data-action-open": isOpen,
|
|
51
53
|
"data-testid": "".concat(testId, "--trigger"),
|
|
52
54
|
onMouseEnter: onMouseEnter,
|
|
53
55
|
onMouseLeave: onMouseLeave,
|
package/dist/es2019/version.json
CHANGED
|
@@ -124,7 +124,8 @@ const ActionGroup = ({
|
|
|
124
124
|
}, [appearance, isMoreThenTwoItems, isOpen, onActionItemClick, onOpenChange, renderableActionItems, size, ui === null || ui === void 0 ? void 0 : ui.zIndex, visibleButtonsNum]);
|
|
125
125
|
return renderableActionItems.length > 0 ? jsx("div", {
|
|
126
126
|
css: styles,
|
|
127
|
-
className: "actions-button-group"
|
|
127
|
+
className: "actions-button-group",
|
|
128
|
+
"data-action-open": isOpen
|
|
128
129
|
}, jsx(ButtonGroup, null, actionButtons, moreActionDropdown)) : null;
|
|
129
130
|
};
|
|
130
131
|
export default ActionGroup;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
/** @jsx jsx */
|
|
2
3
|
import React, { useContext, useState, useCallback } from 'react';
|
|
3
4
|
import { css, jsx } from '@emotion/react';
|
|
4
|
-
import { MediaPlacement, SmartLinkSize, SmartLinkTheme } from '../../../../constants';
|
|
5
|
-
import { isFlexibleUiBlock, isFlexibleUiPreviewBlock, isFlexibleUiTitleBlock
|
|
5
|
+
import { ElementName, MediaPlacement, SmartLinkSize, SmartLinkTheme } from '../../../../constants';
|
|
6
|
+
import { isFlexibleUiBlock, isFlexibleUiPreviewBlock, isFlexibleUiTitleBlock } from '../../../../utils/flexible';
|
|
6
7
|
import { tokens } from '../../../../utils/token';
|
|
7
8
|
import { FlexibleUiContext } from '../../../../state/flexible-ui-context';
|
|
8
9
|
import LayeredLink from './layered-link';
|
|
@@ -111,7 +112,7 @@ export const getContainerStyles = (size, hideBackground, hideElevation, hidePadd
|
|
|
111
112
|
}
|
|
112
113
|
`;
|
|
113
114
|
};
|
|
114
|
-
const renderChildren = (children, containerSize, containerTheme, status, retry, onClick
|
|
115
|
+
const renderChildren = (children, containerSize, containerTheme, status, retry, onClick) => React.Children.map(children, child => {
|
|
115
116
|
// TODO: EDM-6468: Use useFlexibleUiOptionContext for rendering options inside block/element instead
|
|
116
117
|
if ( /*#__PURE__*/React.isValidElement(child) && isFlexibleUiBlock(child)) {
|
|
117
118
|
const {
|
|
@@ -127,13 +128,6 @@ const renderChildren = (children, containerSize, containerTheme, status, retry,
|
|
|
127
128
|
status,
|
|
128
129
|
theme: containerTheme
|
|
129
130
|
});
|
|
130
|
-
} else if (onActionMenuOpenChange && isFlexibleUiFooterBlock(child)) {
|
|
131
|
-
return /*#__PURE__*/React.cloneElement(child, {
|
|
132
|
-
// @ts-expect-error
|
|
133
|
-
size,
|
|
134
|
-
status,
|
|
135
|
-
onActionMenuOpenChange
|
|
136
|
-
});
|
|
137
131
|
}
|
|
138
132
|
// @ts-expect-error
|
|
139
133
|
return /*#__PURE__*/React.cloneElement(child, {
|
|
@@ -168,7 +162,7 @@ const getLayeredLink = (testId, context, children, onClick) => {
|
|
|
168
162
|
|
|
169
163
|
/**
|
|
170
164
|
* A container is a hidden component that build the Flexible Smart Link.
|
|
171
|
-
* All
|
|
165
|
+
* All the Flexible UI components are wrapped inside the container.
|
|
172
166
|
* It inherits the ui props from Card component and applies the custom styling
|
|
173
167
|
* accordingly.
|
|
174
168
|
* @internal
|
|
@@ -194,13 +188,33 @@ const Container = ({
|
|
|
194
188
|
const context = useContext(FlexibleUiContext);
|
|
195
189
|
const childrenOptions = getChildrenOptions(children, context);
|
|
196
190
|
const [hoverCardCanOpen, setHoverCardCanOpen] = useState(true);
|
|
197
|
-
const
|
|
198
|
-
const
|
|
191
|
+
const canShowHoverPreview = showHoverPreview && status === 'resolved';
|
|
192
|
+
const canShowAuthTooltip = showAuthTooltip && status === 'unauthorized';
|
|
193
|
+
const onMouseOver = useCallback(e => {
|
|
194
|
+
var _e$target$closest;
|
|
195
|
+
// Never show hover card on action or when action dropdown opens.
|
|
196
|
+
// The code below can be simplified by using :is() and :has()
|
|
197
|
+
// but the pseudo-class isn't support by Firefox yet.
|
|
198
|
+
const action =
|
|
199
|
+
// Any action button group (title/footer block)
|
|
200
|
+
e.target.closest('.actions-button-group') || ( // When action dropdown list is opened on action button group or lozenge action
|
|
201
|
+
(_e$target$closest = e.target.closest('[data-smart-link-container]')) === null || _e$target$closest === void 0 ? void 0 : _e$target$closest.querySelector('[data-action-open="true"]'));
|
|
202
|
+
const canOpen = canShowAuthTooltip && !action ||
|
|
203
|
+
// EDM-7060: For hover preview, also hide hover card on all elements
|
|
204
|
+
// except title element (link title)
|
|
205
|
+
canShowHoverPreview && !action && !e.target.closest(`[data-smart-element]:not([data-smart-element="${ElementName.Title}"])`);
|
|
206
|
+
if (hoverCardCanOpen !== canOpen) {
|
|
207
|
+
setHoverCardCanOpen(canOpen);
|
|
208
|
+
}
|
|
209
|
+
}, [canShowAuthTooltip, canShowHoverPreview, hoverCardCanOpen]);
|
|
210
|
+
const containerContent = jsx("div", _extends({
|
|
199
211
|
css: getContainerStyles(size, hideBackground, hideElevation, hidePadding, clickableContainer, childrenOptions),
|
|
200
212
|
"data-smart-link-container": true,
|
|
201
213
|
"data-testid": testId
|
|
202
|
-
},
|
|
203
|
-
|
|
214
|
+
}, canShowHoverPreview || canShowAuthTooltip ? {
|
|
215
|
+
onMouseOver
|
|
216
|
+
} : undefined), clickableContainer ? getLayeredLink(testId, context, children, onClick) : null, renderChildren(children, size, theme, status, retry, onClick));
|
|
217
|
+
if (context !== null && context !== void 0 && context.url && (canShowHoverPreview || canShowAuthTooltip)) {
|
|
204
218
|
return jsx(HoverCard, {
|
|
205
219
|
url: context === null || context === void 0 ? void 0 : context.url,
|
|
206
220
|
canOpen: hoverCardCanOpen,
|
|
@@ -86,10 +86,11 @@ const LozengeAction = ({
|
|
|
86
86
|
}, [action.read, analytics, invoke, isLoaded, text]);
|
|
87
87
|
const trigger = useCallback(props => jsx(LozengeActionTrigger, _extends({}, props, {
|
|
88
88
|
appearance: selected.appearance,
|
|
89
|
+
isOpen: isOpen,
|
|
89
90
|
showFeatureDiscovery: action === null || action === void 0 ? void 0 : action.showFeatureDiscovery,
|
|
90
91
|
testId: testId,
|
|
91
92
|
text: selected.text
|
|
92
|
-
})), [selected.appearance, selected.text, action === null || action === void 0 ? void 0 : action.showFeatureDiscovery, testId]);
|
|
93
|
+
})), [selected.appearance, selected.text, isOpen, action === null || action === void 0 ? void 0 : action.showFeatureDiscovery, testId]);
|
|
93
94
|
const handleItemClick = useCallback(async (id, text, appearance) => {
|
|
94
95
|
try {
|
|
95
96
|
analytics === null || analytics === void 0 ? void 0 : analytics.ui.smartLinkLozengeActionListItemClickedEvent();
|
|
@@ -8,6 +8,7 @@ import { triggerButtonStyles, triggerLozengeStyles } from '../styled';
|
|
|
8
8
|
import FeatureDiscovery from '../feature-discovery';
|
|
9
9
|
const LozengeActionTrigger = ({
|
|
10
10
|
appearance,
|
|
11
|
+
isOpen,
|
|
11
12
|
showFeatureDiscovery,
|
|
12
13
|
testId,
|
|
13
14
|
text,
|
|
@@ -30,6 +31,7 @@ const LozengeActionTrigger = ({
|
|
|
30
31
|
type: "button"
|
|
31
32
|
}, props, {
|
|
32
33
|
css: triggerButtonStyles,
|
|
34
|
+
"data-action-open": isOpen,
|
|
33
35
|
"data-testid": `${testId}--trigger`,
|
|
34
36
|
onMouseEnter: onMouseEnter,
|
|
35
37
|
onMouseLeave: onMouseLeave,
|
package/dist/esm/version.json
CHANGED
|
@@ -133,7 +133,8 @@ var ActionGroup = function ActionGroup(_ref) {
|
|
|
133
133
|
}, [appearance, isMoreThenTwoItems, isOpen, onActionItemClick, onOpenChange, renderableActionItems, size, ui === null || ui === void 0 ? void 0 : ui.zIndex, visibleButtonsNum]);
|
|
134
134
|
return renderableActionItems.length > 0 ? jsx("div", {
|
|
135
135
|
css: styles,
|
|
136
|
-
className: "actions-button-group"
|
|
136
|
+
className: "actions-button-group",
|
|
137
|
+
"data-action-open": isOpen
|
|
137
138
|
}, jsx(ButtonGroup, null, actionButtons, moreActionDropdown)) : null;
|
|
138
139
|
};
|
|
139
140
|
export default ActionGroup;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
3
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
3
4
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
4
5
|
/** @jsx jsx */
|
|
5
6
|
import React, { useContext, useState, useCallback } from 'react';
|
|
6
7
|
import { css, jsx } from '@emotion/react';
|
|
7
|
-
import { MediaPlacement, SmartLinkSize, SmartLinkTheme } from '../../../../constants';
|
|
8
|
-
import { isFlexibleUiBlock, isFlexibleUiPreviewBlock, isFlexibleUiTitleBlock
|
|
8
|
+
import { ElementName, MediaPlacement, SmartLinkSize, SmartLinkTheme } from '../../../../constants';
|
|
9
|
+
import { isFlexibleUiBlock, isFlexibleUiPreviewBlock, isFlexibleUiTitleBlock } from '../../../../utils/flexible';
|
|
9
10
|
import { tokens } from '../../../../utils/token';
|
|
10
11
|
import { FlexibleUiContext } from '../../../../state/flexible-ui-context';
|
|
11
12
|
import LayeredLink from './layered-link';
|
|
@@ -69,7 +70,7 @@ export var getContainerStyles = function getContainerStyles(size, hideBackground
|
|
|
69
70
|
var paddingCss = getContainerPaddingStyles(size, hidePadding, childrenOptions);
|
|
70
71
|
return css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n display: flex;\n gap: ", " 0;\n flex-direction: column;\n min-width: 0;\n overflow-x: hidden;\n position: relative;\n ", "\n ", "\n ", "\n ", "\n &:hover ~ .actions-button-group {\n opacity: 1;\n }\n a:focus,\n .has-action:focus {\n outline-offset: -2px;\n }\n "])), getGap(size), hideBackground ? '' : "background-color: ".concat(tokens.background, ";"), paddingCss, hideElevation ? '' : elevationStyles, clickableContainer ? clickableContainerStyles : '');
|
|
71
72
|
};
|
|
72
|
-
var renderChildren = function renderChildren(children, containerSize, containerTheme, status, retry, onClick
|
|
73
|
+
var renderChildren = function renderChildren(children, containerSize, containerTheme, status, retry, onClick) {
|
|
73
74
|
return React.Children.map(children, function (child) {
|
|
74
75
|
// TODO: EDM-6468: Use useFlexibleUiOptionContext for rendering options inside block/element instead
|
|
75
76
|
if ( /*#__PURE__*/React.isValidElement(child) && isFlexibleUiBlock(child)) {
|
|
@@ -84,13 +85,6 @@ var renderChildren = function renderChildren(children, containerSize, containerT
|
|
|
84
85
|
status: status,
|
|
85
86
|
theme: containerTheme
|
|
86
87
|
});
|
|
87
|
-
} else if (onActionMenuOpenChange && isFlexibleUiFooterBlock(child)) {
|
|
88
|
-
return /*#__PURE__*/React.cloneElement(child, {
|
|
89
|
-
// @ts-expect-error
|
|
90
|
-
size: size,
|
|
91
|
-
status: status,
|
|
92
|
-
onActionMenuOpenChange: onActionMenuOpenChange
|
|
93
|
-
});
|
|
94
88
|
}
|
|
95
89
|
// @ts-expect-error
|
|
96
90
|
return /*#__PURE__*/React.cloneElement(child, {
|
|
@@ -127,7 +121,7 @@ var getLayeredLink = function getLayeredLink(testId, context, children, onClick)
|
|
|
127
121
|
|
|
128
122
|
/**
|
|
129
123
|
* A container is a hidden component that build the Flexible Smart Link.
|
|
130
|
-
* All
|
|
124
|
+
* All the Flexible UI components are wrapped inside the container.
|
|
131
125
|
* It inherits the ui props from Card component and applies the custom styling
|
|
132
126
|
* accordingly.
|
|
133
127
|
* @internal
|
|
@@ -166,15 +160,33 @@ var Container = function Container(_ref3) {
|
|
|
166
160
|
_useState2 = _slicedToArray(_useState, 2),
|
|
167
161
|
hoverCardCanOpen = _useState2[0],
|
|
168
162
|
setHoverCardCanOpen = _useState2[1];
|
|
169
|
-
var
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
163
|
+
var canShowHoverPreview = showHoverPreview && status === 'resolved';
|
|
164
|
+
var canShowAuthTooltip = showAuthTooltip && status === 'unauthorized';
|
|
165
|
+
var onMouseOver = useCallback(function (e) {
|
|
166
|
+
var _e$target$closest;
|
|
167
|
+
// Never show hover card on action or when action dropdown opens.
|
|
168
|
+
// The code below can be simplified by using :is() and :has()
|
|
169
|
+
// but the pseudo-class isn't support by Firefox yet.
|
|
170
|
+
var action =
|
|
171
|
+
// Any action button group (title/footer block)
|
|
172
|
+
e.target.closest('.actions-button-group') || ( // When action dropdown list is opened on action button group or lozenge action
|
|
173
|
+
(_e$target$closest = e.target.closest('[data-smart-link-container]')) === null || _e$target$closest === void 0 ? void 0 : _e$target$closest.querySelector('[data-action-open="true"]'));
|
|
174
|
+
var canOpen = canShowAuthTooltip && !action ||
|
|
175
|
+
// EDM-7060: For hover preview, also hide hover card on all elements
|
|
176
|
+
// except title element (link title)
|
|
177
|
+
canShowHoverPreview && !action && !e.target.closest("[data-smart-element]:not([data-smart-element=\"".concat(ElementName.Title, "\"])"));
|
|
178
|
+
if (hoverCardCanOpen !== canOpen) {
|
|
179
|
+
setHoverCardCanOpen(canOpen);
|
|
180
|
+
}
|
|
181
|
+
}, [canShowAuthTooltip, canShowHoverPreview, hoverCardCanOpen]);
|
|
182
|
+
var containerContent = jsx("div", _extends({
|
|
173
183
|
css: getContainerStyles(size, hideBackground, hideElevation, hidePadding, clickableContainer, childrenOptions),
|
|
174
184
|
"data-smart-link-container": true,
|
|
175
185
|
"data-testid": testId
|
|
176
|
-
},
|
|
177
|
-
|
|
186
|
+
}, canShowHoverPreview || canShowAuthTooltip ? {
|
|
187
|
+
onMouseOver: onMouseOver
|
|
188
|
+
} : undefined), clickableContainer ? getLayeredLink(testId, context, children, onClick) : null, renderChildren(children, size, theme, status, retry, onClick));
|
|
189
|
+
if (context !== null && context !== void 0 && context.url && (canShowHoverPreview || canShowAuthTooltip)) {
|
|
178
190
|
return jsx(HoverCard, {
|
|
179
191
|
url: context === null || context === void 0 ? void 0 : context.url,
|
|
180
192
|
canOpen: hoverCardCanOpen,
|
|
@@ -140,11 +140,12 @@ var LozengeAction = function LozengeAction(_ref) {
|
|
|
140
140
|
var trigger = useCallback(function (props) {
|
|
141
141
|
return jsx(LozengeActionTrigger, _extends({}, props, {
|
|
142
142
|
appearance: selected.appearance,
|
|
143
|
+
isOpen: isOpen,
|
|
143
144
|
showFeatureDiscovery: action === null || action === void 0 ? void 0 : action.showFeatureDiscovery,
|
|
144
145
|
testId: testId,
|
|
145
146
|
text: selected.text
|
|
146
147
|
}));
|
|
147
|
-
}, [selected.appearance, selected.text, action === null || action === void 0 ? void 0 : action.showFeatureDiscovery, testId]);
|
|
148
|
+
}, [selected.appearance, selected.text, isOpen, action === null || action === void 0 ? void 0 : action.showFeatureDiscovery, testId]);
|
|
148
149
|
var handleItemClick = useCallback( /*#__PURE__*/function () {
|
|
149
150
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(id, text, appearance) {
|
|
150
151
|
var updateAction, request;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
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
|
-
var _excluded = ["appearance", "showFeatureDiscovery", "testId", "text", "triggerRef"];
|
|
4
|
+
var _excluded = ["appearance", "isOpen", "showFeatureDiscovery", "testId", "text", "triggerRef"];
|
|
5
5
|
/** @jsx jsx */
|
|
6
6
|
import { jsx } from '@emotion/react';
|
|
7
7
|
import { useCallback, useMemo, useState } from 'react';
|
|
@@ -11,6 +11,7 @@ import { triggerButtonStyles, triggerLozengeStyles } from '../styled';
|
|
|
11
11
|
import FeatureDiscovery from '../feature-discovery';
|
|
12
12
|
var LozengeActionTrigger = function LozengeActionTrigger(_ref) {
|
|
13
13
|
var appearance = _ref.appearance,
|
|
14
|
+
isOpen = _ref.isOpen,
|
|
14
15
|
showFeatureDiscovery = _ref.showFeatureDiscovery,
|
|
15
16
|
testId = _ref.testId,
|
|
16
17
|
text = _ref.text,
|
|
@@ -41,6 +42,7 @@ var LozengeActionTrigger = function LozengeActionTrigger(_ref) {
|
|
|
41
42
|
type: "button"
|
|
42
43
|
}, props, {
|
|
43
44
|
css: triggerButtonStyles,
|
|
45
|
+
"data-action-open": isOpen,
|
|
44
46
|
"data-testid": "".concat(testId, "--trigger"),
|
|
45
47
|
onMouseEnter: onMouseEnter,
|
|
46
48
|
onMouseLeave: onMouseLeave,
|
|
@@ -6,7 +6,7 @@ import { ChildrenOptions, ContainerProps } from './types';
|
|
|
6
6
|
export declare const getContainerStyles: (size: SmartLinkSize, hideBackground: boolean, hideElevation: boolean, hidePadding: boolean, clickableContainer: boolean, childrenOptions: ChildrenOptions) => SerializedStyles;
|
|
7
7
|
/**
|
|
8
8
|
* A container is a hidden component that build the Flexible Smart Link.
|
|
9
|
-
* All
|
|
9
|
+
* All the Flexible UI components are wrapped inside the container.
|
|
10
10
|
* It inherits the ui props from Card component and applies the custom styling
|
|
11
11
|
* accordingly.
|
|
12
12
|
* @internal
|
|
@@ -3,6 +3,7 @@ import type { ThemeAppearance } from '@atlaskit/lozenge';
|
|
|
3
3
|
import type { CustomTriggerProps } from '@atlaskit/dropdown-menu';
|
|
4
4
|
export type LozengeActionTriggerProps = {
|
|
5
5
|
appearance?: ThemeAppearance;
|
|
6
|
+
isOpen?: boolean;
|
|
6
7
|
showFeatureDiscovery?: boolean;
|
|
7
8
|
testId?: string;
|
|
8
9
|
text: string | React.ReactNode;
|
|
@@ -6,7 +6,7 @@ import { ChildrenOptions, ContainerProps } from './types';
|
|
|
6
6
|
export declare const getContainerStyles: (size: SmartLinkSize, hideBackground: boolean, hideElevation: boolean, hidePadding: boolean, clickableContainer: boolean, childrenOptions: ChildrenOptions) => SerializedStyles;
|
|
7
7
|
/**
|
|
8
8
|
* A container is a hidden component that build the Flexible Smart Link.
|
|
9
|
-
* All
|
|
9
|
+
* All the Flexible UI components are wrapped inside the container.
|
|
10
10
|
* It inherits the ui props from Card component and applies the custom styling
|
|
11
11
|
* accordingly.
|
|
12
12
|
* @internal
|
|
@@ -3,6 +3,7 @@ import type { ThemeAppearance } from '@atlaskit/lozenge';
|
|
|
3
3
|
import type { CustomTriggerProps } from '@atlaskit/dropdown-menu';
|
|
4
4
|
export type LozengeActionTriggerProps = {
|
|
5
5
|
appearance?: ThemeAppearance;
|
|
6
|
+
isOpen?: boolean;
|
|
6
7
|
showFeatureDiscovery?: boolean;
|
|
7
8
|
testId?: string;
|
|
8
9
|
text: string | React.ReactNode;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/smart-card",
|
|
3
|
-
"version": "26.6.
|
|
3
|
+
"version": "26.6.2",
|
|
4
4
|
"description": "Smart card component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -43,19 +43,19 @@
|
|
|
43
43
|
"@atlaskit/icon-priority": "^6.3.0",
|
|
44
44
|
"@atlaskit/in-product-testing": "^0.2.0",
|
|
45
45
|
"@atlaskit/link-analytics": "^8.0.2",
|
|
46
|
-
"@atlaskit/link-client-extension": "^1.
|
|
46
|
+
"@atlaskit/link-client-extension": "^1.5.0",
|
|
47
47
|
"@atlaskit/linking-common": "^3.1.0",
|
|
48
|
-
"@atlaskit/linking-types": "^
|
|
48
|
+
"@atlaskit/linking-types": "^8.0.0",
|
|
49
49
|
"@atlaskit/logo": "^13.14.0",
|
|
50
50
|
"@atlaskit/lozenge": "^11.4.0",
|
|
51
|
-
"@atlaskit/media-common": "^7.
|
|
51
|
+
"@atlaskit/media-common": "^7.1.0",
|
|
52
52
|
"@atlaskit/modal-dialog": "^12.6.0",
|
|
53
53
|
"@atlaskit/outbound-auth-flow-client": "^3.4.0",
|
|
54
54
|
"@atlaskit/platform-feature-flags": "^0.2.1",
|
|
55
55
|
"@atlaskit/popup": "^1.8.0",
|
|
56
56
|
"@atlaskit/spinner": "^15.5.0",
|
|
57
57
|
"@atlaskit/theme": "^12.5.0",
|
|
58
|
-
"@atlaskit/tokens": "^1.
|
|
58
|
+
"@atlaskit/tokens": "^1.10.0",
|
|
59
59
|
"@atlaskit/tooltip": "^17.8.0",
|
|
60
60
|
"@atlaskit/ufo": "^0.2.0",
|
|
61
61
|
"@babel/runtime": "^7.0.0",
|