@atlaskit/smart-card 26.9.0 → 26.9.1
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 +7 -0
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +11 -11
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +12 -12
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/HoverCard/components/HoverCardComponent.js +11 -11
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/smart-card
|
|
2
2
|
|
|
3
|
+
## 26.9.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`88cc5a0088c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/88cc5a0088c) - [ux] Flexible Smart Links: Hover preview to follow mouse position
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
3
10
|
## 26.9.0
|
|
4
11
|
|
|
5
12
|
### Minor Changes
|
package/dist/cjs/version.json
CHANGED
|
@@ -58,14 +58,14 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
58
58
|
var _useSmartCardActions = (0, _actions.useSmartCardActions)(id, url, analytics),
|
|
59
59
|
loadMetadata = _useSmartCardActions.loadMetadata;
|
|
60
60
|
var setMousePosition = (0, _react2.useCallback)(function (event) {
|
|
61
|
-
if (isOpen) {
|
|
61
|
+
if (isOpen && canOpen) {
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
64
|
mousePos.current = {
|
|
65
65
|
x: event.clientX,
|
|
66
66
|
y: event.clientY
|
|
67
67
|
};
|
|
68
|
-
}, [isOpen]);
|
|
68
|
+
}, [canOpen, isOpen]);
|
|
69
69
|
var hideCard = (0, _react2.useCallback)(function () {
|
|
70
70
|
setIsOpen(false);
|
|
71
71
|
}, []);
|
|
@@ -131,20 +131,21 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
131
131
|
|
|
132
132
|
//Set mouse position in the case it's not already set by onMouseMove, as in the case of scrolling
|
|
133
133
|
setMousePosition(event);
|
|
134
|
+
|
|
135
|
+
//If these are undefined then popupOffset is undefined and we fallback to default bottom-start placement
|
|
136
|
+
if ((!isOpen || !canOpen) && parentSpan.current && mousePos.current) {
|
|
137
|
+
var _parentSpan$current$g = parentSpan.current.getBoundingClientRect(),
|
|
138
|
+
bottom = _parentSpan$current$g.bottom,
|
|
139
|
+
left = _parentSpan$current$g.left;
|
|
140
|
+
popupOffset.current = [mousePos.current.x - left, mousePos.current.y - bottom + _styled.CARD_GAP_PX];
|
|
141
|
+
}
|
|
134
142
|
if (!isOpen && !fadeInTimeoutId.current) {
|
|
135
143
|
// setting a timeout to show a Hover Card after delay runs out
|
|
136
144
|
fadeInTimeoutId.current = setTimeout(function () {
|
|
137
|
-
//If these are undefined then popupOffset is undefined and we fallback to default bottom-start placement
|
|
138
|
-
if (parentSpan.current && mousePos.current) {
|
|
139
|
-
var _parentSpan$current$g = parentSpan.current.getBoundingClientRect(),
|
|
140
|
-
bottom = _parentSpan$current$g.bottom,
|
|
141
|
-
left = _parentSpan$current$g.left;
|
|
142
|
-
popupOffset.current = [mousePos.current.x - left, mousePos.current.y - bottom + _styled.CARD_GAP_PX];
|
|
143
|
-
}
|
|
144
145
|
setIsOpen(true);
|
|
145
146
|
}, FADE_IN_DELAY);
|
|
146
147
|
}
|
|
147
|
-
}, [initResolve, isOpen, setMousePosition]);
|
|
148
|
+
}, [canOpen, initResolve, isOpen, setMousePosition]);
|
|
148
149
|
var linkActions = (0, _useSmartLinkActions.useSmartLinkActions)({
|
|
149
150
|
url: url,
|
|
150
151
|
appearance: _constants.CardDisplay.HoverCardPreview,
|
|
@@ -163,7 +164,6 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
163
164
|
}, [hideCard]);
|
|
164
165
|
|
|
165
166
|
// Stop hover preview content to propagate event to parent.
|
|
166
|
-
|
|
167
167
|
var onChildClick = (0, _react2.useCallback)(function (e) {
|
|
168
168
|
e.stopPropagation();
|
|
169
169
|
if (closeOnChildClick) {
|
package/dist/es2019/version.json
CHANGED
|
@@ -40,14 +40,14 @@ export const HoverCardComponent = ({
|
|
|
40
40
|
loadMetadata
|
|
41
41
|
} = useSmartCardActions(id, url, analytics);
|
|
42
42
|
const setMousePosition = useCallback(event => {
|
|
43
|
-
if (isOpen) {
|
|
43
|
+
if (isOpen && canOpen) {
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
46
|
mousePos.current = {
|
|
47
47
|
x: event.clientX,
|
|
48
48
|
y: event.clientY
|
|
49
49
|
};
|
|
50
|
-
}, [isOpen]);
|
|
50
|
+
}, [canOpen, isOpen]);
|
|
51
51
|
const hideCard = useCallback(() => {
|
|
52
52
|
setIsOpen(false);
|
|
53
53
|
}, []);
|
|
@@ -111,21 +111,22 @@ export const HoverCardComponent = ({
|
|
|
111
111
|
|
|
112
112
|
//Set mouse position in the case it's not already set by onMouseMove, as in the case of scrolling
|
|
113
113
|
setMousePosition(event);
|
|
114
|
+
|
|
115
|
+
//If these are undefined then popupOffset is undefined and we fallback to default bottom-start placement
|
|
116
|
+
if ((!isOpen || !canOpen) && parentSpan.current && mousePos.current) {
|
|
117
|
+
const {
|
|
118
|
+
bottom,
|
|
119
|
+
left
|
|
120
|
+
} = parentSpan.current.getBoundingClientRect();
|
|
121
|
+
popupOffset.current = [mousePos.current.x - left, mousePos.current.y - bottom + CARD_GAP_PX];
|
|
122
|
+
}
|
|
114
123
|
if (!isOpen && !fadeInTimeoutId.current) {
|
|
115
124
|
// setting a timeout to show a Hover Card after delay runs out
|
|
116
125
|
fadeInTimeoutId.current = setTimeout(() => {
|
|
117
|
-
//If these are undefined then popupOffset is undefined and we fallback to default bottom-start placement
|
|
118
|
-
if (parentSpan.current && mousePos.current) {
|
|
119
|
-
const {
|
|
120
|
-
bottom,
|
|
121
|
-
left
|
|
122
|
-
} = parentSpan.current.getBoundingClientRect();
|
|
123
|
-
popupOffset.current = [mousePos.current.x - left, mousePos.current.y - bottom + CARD_GAP_PX];
|
|
124
|
-
}
|
|
125
126
|
setIsOpen(true);
|
|
126
127
|
}, FADE_IN_DELAY);
|
|
127
128
|
}
|
|
128
|
-
}, [initResolve, isOpen, setMousePosition]);
|
|
129
|
+
}, [canOpen, initResolve, isOpen, setMousePosition]);
|
|
129
130
|
const linkActions = useSmartLinkActions({
|
|
130
131
|
url,
|
|
131
132
|
appearance: CardDisplay.HoverCardPreview,
|
|
@@ -142,7 +143,6 @@ export const HoverCardComponent = ({
|
|
|
142
143
|
}, [hideCard]);
|
|
143
144
|
|
|
144
145
|
// Stop hover preview content to propagate event to parent.
|
|
145
|
-
|
|
146
146
|
const onChildClick = useCallback(e => {
|
|
147
147
|
e.stopPropagation();
|
|
148
148
|
if (closeOnChildClick) {
|
package/dist/esm/version.json
CHANGED
|
@@ -47,14 +47,14 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
47
47
|
var _useSmartCardActions = useSmartCardActions(id, url, analytics),
|
|
48
48
|
loadMetadata = _useSmartCardActions.loadMetadata;
|
|
49
49
|
var setMousePosition = useCallback(function (event) {
|
|
50
|
-
if (isOpen) {
|
|
50
|
+
if (isOpen && canOpen) {
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
53
|
mousePos.current = {
|
|
54
54
|
x: event.clientX,
|
|
55
55
|
y: event.clientY
|
|
56
56
|
};
|
|
57
|
-
}, [isOpen]);
|
|
57
|
+
}, [canOpen, isOpen]);
|
|
58
58
|
var hideCard = useCallback(function () {
|
|
59
59
|
setIsOpen(false);
|
|
60
60
|
}, []);
|
|
@@ -120,20 +120,21 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
120
120
|
|
|
121
121
|
//Set mouse position in the case it's not already set by onMouseMove, as in the case of scrolling
|
|
122
122
|
setMousePosition(event);
|
|
123
|
+
|
|
124
|
+
//If these are undefined then popupOffset is undefined and we fallback to default bottom-start placement
|
|
125
|
+
if ((!isOpen || !canOpen) && parentSpan.current && mousePos.current) {
|
|
126
|
+
var _parentSpan$current$g = parentSpan.current.getBoundingClientRect(),
|
|
127
|
+
bottom = _parentSpan$current$g.bottom,
|
|
128
|
+
left = _parentSpan$current$g.left;
|
|
129
|
+
popupOffset.current = [mousePos.current.x - left, mousePos.current.y - bottom + CARD_GAP_PX];
|
|
130
|
+
}
|
|
123
131
|
if (!isOpen && !fadeInTimeoutId.current) {
|
|
124
132
|
// setting a timeout to show a Hover Card after delay runs out
|
|
125
133
|
fadeInTimeoutId.current = setTimeout(function () {
|
|
126
|
-
//If these are undefined then popupOffset is undefined and we fallback to default bottom-start placement
|
|
127
|
-
if (parentSpan.current && mousePos.current) {
|
|
128
|
-
var _parentSpan$current$g = parentSpan.current.getBoundingClientRect(),
|
|
129
|
-
bottom = _parentSpan$current$g.bottom,
|
|
130
|
-
left = _parentSpan$current$g.left;
|
|
131
|
-
popupOffset.current = [mousePos.current.x - left, mousePos.current.y - bottom + CARD_GAP_PX];
|
|
132
|
-
}
|
|
133
134
|
setIsOpen(true);
|
|
134
135
|
}, FADE_IN_DELAY);
|
|
135
136
|
}
|
|
136
|
-
}, [initResolve, isOpen, setMousePosition]);
|
|
137
|
+
}, [canOpen, initResolve, isOpen, setMousePosition]);
|
|
137
138
|
var linkActions = useSmartLinkActions({
|
|
138
139
|
url: url,
|
|
139
140
|
appearance: CardDisplay.HoverCardPreview,
|
|
@@ -152,7 +153,6 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
152
153
|
}, [hideCard]);
|
|
153
154
|
|
|
154
155
|
// Stop hover preview content to propagate event to parent.
|
|
155
|
-
|
|
156
156
|
var onChildClick = useCallback(function (e) {
|
|
157
157
|
e.stopPropagation();
|
|
158
158
|
if (closeOnChildClick) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/smart-card",
|
|
3
|
-
"version": "26.9.
|
|
3
|
+
"version": "26.9.1",
|
|
4
4
|
"description": "Smart card component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"@atlaskit/icon-object": "^6.3.0",
|
|
43
43
|
"@atlaskit/icon-priority": "^6.3.0",
|
|
44
44
|
"@atlaskit/in-product-testing": "^0.2.0",
|
|
45
|
-
"@atlaskit/link-analytics": "^8.
|
|
45
|
+
"@atlaskit/link-analytics": "^8.2.0",
|
|
46
46
|
"@atlaskit/link-client-extension": "^1.5.0",
|
|
47
|
-
"@atlaskit/linking-common": "^3.
|
|
47
|
+
"@atlaskit/linking-common": "^3.2.0",
|
|
48
48
|
"@atlaskit/linking-types": "^8.1.0",
|
|
49
49
|
"@atlaskit/logo": "^13.14.0",
|
|
50
50
|
"@atlaskit/lozenge": "^11.4.0",
|