@atlaskit/smart-card 26.9.7 → 26.9.8
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 +8 -0
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +1 -0
- package/dist/cjs/view/HoverCard/components/HoverCardContent.js +21 -1
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +1 -0
- package/dist/es2019/view/HoverCard/components/HoverCardContent.js +21 -1
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/HoverCard/components/HoverCardComponent.js +1 -0
- package/dist/esm/view/HoverCard/components/HoverCardContent.js +21 -1
- package/dist/types/view/HoverCard/types.d.ts +2 -1
- package/dist/types-ts4.5/view/HoverCard/types.d.ts +2 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/smart-card
|
|
2
2
|
|
|
3
|
+
## 26.9.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`4d66cb26fcb`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4d66cb26fcb) - Bump jsdom to ^17.0.0
|
|
8
|
+
- [`2a6ebbbfdf1`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2a6ebbbfdf1) - [ux] Hover Preview: Hide hover preview on scrolling (wheel event)
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 26.9.7
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/dist/cjs/version.json
CHANGED
|
@@ -185,6 +185,7 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
185
185
|
var hoverCardContentProps = {
|
|
186
186
|
onMouseEnter: initShowCard,
|
|
187
187
|
onMouseLeave: initHideCard,
|
|
188
|
+
onWheel: initHideCard,
|
|
188
189
|
cardActions: filteredActions,
|
|
189
190
|
cardState: linkState,
|
|
190
191
|
onActionClick: onActionClick,
|
|
@@ -103,6 +103,7 @@ var HoverCardContent = function HoverCardContent(_ref) {
|
|
|
103
103
|
url = _ref.url,
|
|
104
104
|
onMouseEnter = _ref.onMouseEnter,
|
|
105
105
|
onMouseLeave = _ref.onMouseLeave,
|
|
106
|
+
onWheel = _ref.onWheel,
|
|
106
107
|
showServerActions = _ref.showServerActions;
|
|
107
108
|
var useLozengeAction = (0, _linkProvider.useFeatureFlag)('useLozengeAction');
|
|
108
109
|
var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
|
|
@@ -116,6 +117,7 @@ var HoverCardContent = function HoverCardContent(_ref) {
|
|
|
116
117
|
var linkStatus = (_linkState$status = linkState.status) !== null && _linkState$status !== void 0 ? _linkState$status : 'pending';
|
|
117
118
|
var statusRef = (0, _react2.useRef)(linkStatus);
|
|
118
119
|
var analyticsRef = (0, _react2.useRef)(analytics);
|
|
120
|
+
var wrapperRef = (0, _react2.useRef)(null);
|
|
119
121
|
(0, _react2.useEffect)(function () {
|
|
120
122
|
/**
|
|
121
123
|
* Must access current analytics object value via ref because its not stable
|
|
@@ -147,6 +149,22 @@ var HoverCardContent = function HoverCardContent(_ref) {
|
|
|
147
149
|
});
|
|
148
150
|
};
|
|
149
151
|
}, []);
|
|
152
|
+
(0, _react2.useEffect)(function () {
|
|
153
|
+
var wrapperRefValue = null;
|
|
154
|
+
if (wrapperRef.current && onWheel) {
|
|
155
|
+
// Detect wheel even on hover card content to close hover card
|
|
156
|
+
// Add event listener through ref because we want it to execute only once.
|
|
157
|
+
wrapperRef.current.addEventListener('wheel', onWheel, {
|
|
158
|
+
once: true
|
|
159
|
+
});
|
|
160
|
+
wrapperRefValue = wrapperRef.current;
|
|
161
|
+
}
|
|
162
|
+
return function () {
|
|
163
|
+
if (wrapperRefValue && onWheel) {
|
|
164
|
+
wrapperRefValue.removeEventListener('wheel', onWheel);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
}, [onWheel]);
|
|
150
168
|
var onClick = (0, _react2.useCallback)(function (event) {
|
|
151
169
|
var isModifierKeyPressed = (0, _utils.isSpecialEvent)(event);
|
|
152
170
|
analytics.ui.cardClickedEvent({
|
|
@@ -222,11 +240,13 @@ var HoverCardContent = function HoverCardContent(_ref) {
|
|
|
222
240
|
};
|
|
223
241
|
var cardView = getCardView(cardState);
|
|
224
242
|
return cardView ? (0, _react.jsx)("div", {
|
|
243
|
+
"data-testid": "hover-card-content",
|
|
225
244
|
onMouseEnter: onMouseEnter,
|
|
226
245
|
onMouseLeave: onMouseLeave,
|
|
227
246
|
onClick: onClickStopPropagation,
|
|
228
247
|
className: hoverCardClassName,
|
|
229
|
-
css: _styled.HoverCardContainer
|
|
248
|
+
css: _styled.HoverCardContainer,
|
|
249
|
+
ref: wrapperRef
|
|
230
250
|
}, cardView) : null;
|
|
231
251
|
};
|
|
232
252
|
var _default = HoverCardContent;
|
package/dist/es2019/version.json
CHANGED
|
@@ -61,6 +61,7 @@ const HoverCardContent = ({
|
|
|
61
61
|
url,
|
|
62
62
|
onMouseEnter,
|
|
63
63
|
onMouseLeave,
|
|
64
|
+
onWheel,
|
|
64
65
|
showServerActions
|
|
65
66
|
}) => {
|
|
66
67
|
var _linkState$status, _cardState$details;
|
|
@@ -75,6 +76,7 @@ const HoverCardContent = ({
|
|
|
75
76
|
const linkStatus = (_linkState$status = linkState.status) !== null && _linkState$status !== void 0 ? _linkState$status : 'pending';
|
|
76
77
|
const statusRef = useRef(linkStatus);
|
|
77
78
|
const analyticsRef = useRef(analytics);
|
|
79
|
+
const wrapperRef = useRef(null);
|
|
78
80
|
useEffect(() => {
|
|
79
81
|
/**
|
|
80
82
|
* Must access current analytics object value via ref because its not stable
|
|
@@ -106,6 +108,22 @@ const HoverCardContent = ({
|
|
|
106
108
|
});
|
|
107
109
|
};
|
|
108
110
|
}, []);
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
let wrapperRefValue = null;
|
|
113
|
+
if (wrapperRef.current && onWheel) {
|
|
114
|
+
// Detect wheel even on hover card content to close hover card
|
|
115
|
+
// Add event listener through ref because we want it to execute only once.
|
|
116
|
+
wrapperRef.current.addEventListener('wheel', onWheel, {
|
|
117
|
+
once: true
|
|
118
|
+
});
|
|
119
|
+
wrapperRefValue = wrapperRef.current;
|
|
120
|
+
}
|
|
121
|
+
return () => {
|
|
122
|
+
if (wrapperRefValue && onWheel) {
|
|
123
|
+
wrapperRefValue.removeEventListener('wheel', onWheel);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}, [onWheel]);
|
|
109
127
|
const onClick = useCallback(event => {
|
|
110
128
|
const isModifierKeyPressed = isSpecialEvent(event);
|
|
111
129
|
analytics.ui.cardClickedEvent({
|
|
@@ -178,11 +196,13 @@ const HoverCardContent = ({
|
|
|
178
196
|
};
|
|
179
197
|
const cardView = getCardView(cardState);
|
|
180
198
|
return cardView ? jsx("div", {
|
|
199
|
+
"data-testid": "hover-card-content",
|
|
181
200
|
onMouseEnter: onMouseEnter,
|
|
182
201
|
onMouseLeave: onMouseLeave,
|
|
183
202
|
onClick: onClickStopPropagation,
|
|
184
203
|
className: hoverCardClassName,
|
|
185
|
-
css: HoverCardContainer
|
|
204
|
+
css: HoverCardContainer,
|
|
205
|
+
ref: wrapperRef
|
|
186
206
|
}, cardView) : null;
|
|
187
207
|
};
|
|
188
208
|
export default HoverCardContent;
|
package/dist/esm/version.json
CHANGED
|
@@ -174,6 +174,7 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
174
174
|
var hoverCardContentProps = {
|
|
175
175
|
onMouseEnter: initShowCard,
|
|
176
176
|
onMouseLeave: initHideCard,
|
|
177
|
+
onWheel: initHideCard,
|
|
177
178
|
cardActions: filteredActions,
|
|
178
179
|
cardState: linkState,
|
|
179
180
|
onActionClick: onActionClick,
|
|
@@ -89,6 +89,7 @@ var HoverCardContent = function HoverCardContent(_ref) {
|
|
|
89
89
|
url = _ref.url,
|
|
90
90
|
onMouseEnter = _ref.onMouseEnter,
|
|
91
91
|
onMouseLeave = _ref.onMouseLeave,
|
|
92
|
+
onWheel = _ref.onWheel,
|
|
92
93
|
showServerActions = _ref.showServerActions;
|
|
93
94
|
var useLozengeAction = useFeatureFlag('useLozengeAction');
|
|
94
95
|
var _useAnalyticsEvents = useAnalyticsEvents(),
|
|
@@ -102,6 +103,7 @@ var HoverCardContent = function HoverCardContent(_ref) {
|
|
|
102
103
|
var linkStatus = (_linkState$status = linkState.status) !== null && _linkState$status !== void 0 ? _linkState$status : 'pending';
|
|
103
104
|
var statusRef = useRef(linkStatus);
|
|
104
105
|
var analyticsRef = useRef(analytics);
|
|
106
|
+
var wrapperRef = useRef(null);
|
|
105
107
|
useEffect(function () {
|
|
106
108
|
/**
|
|
107
109
|
* Must access current analytics object value via ref because its not stable
|
|
@@ -133,6 +135,22 @@ var HoverCardContent = function HoverCardContent(_ref) {
|
|
|
133
135
|
});
|
|
134
136
|
};
|
|
135
137
|
}, []);
|
|
138
|
+
useEffect(function () {
|
|
139
|
+
var wrapperRefValue = null;
|
|
140
|
+
if (wrapperRef.current && onWheel) {
|
|
141
|
+
// Detect wheel even on hover card content to close hover card
|
|
142
|
+
// Add event listener through ref because we want it to execute only once.
|
|
143
|
+
wrapperRef.current.addEventListener('wheel', onWheel, {
|
|
144
|
+
once: true
|
|
145
|
+
});
|
|
146
|
+
wrapperRefValue = wrapperRef.current;
|
|
147
|
+
}
|
|
148
|
+
return function () {
|
|
149
|
+
if (wrapperRefValue && onWheel) {
|
|
150
|
+
wrapperRefValue.removeEventListener('wheel', onWheel);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
}, [onWheel]);
|
|
136
154
|
var onClick = useCallback(function (event) {
|
|
137
155
|
var isModifierKeyPressed = isSpecialEvent(event);
|
|
138
156
|
analytics.ui.cardClickedEvent({
|
|
@@ -208,11 +226,13 @@ var HoverCardContent = function HoverCardContent(_ref) {
|
|
|
208
226
|
};
|
|
209
227
|
var cardView = getCardView(cardState);
|
|
210
228
|
return cardView ? jsx("div", {
|
|
229
|
+
"data-testid": "hover-card-content",
|
|
211
230
|
onMouseEnter: onMouseEnter,
|
|
212
231
|
onMouseLeave: onMouseLeave,
|
|
213
232
|
onClick: onClickStopPropagation,
|
|
214
233
|
className: hoverCardClassName,
|
|
215
|
-
css: HoverCardContainer
|
|
234
|
+
css: HoverCardContainer,
|
|
235
|
+
ref: wrapperRef
|
|
216
236
|
}, cardView) : null;
|
|
217
237
|
};
|
|
218
238
|
export default HoverCardContent;
|
|
@@ -5,7 +5,7 @@ import { LinkAction } from '../../state/hooks-external/useSmartLinkActions';
|
|
|
5
5
|
import { CardState } from '@atlaskit/linking-common';
|
|
6
6
|
import { AnalyticsHandler } from '../../utils/types';
|
|
7
7
|
import { CardProviderRenderers } from '@atlaskit/link-provider';
|
|
8
|
-
import {
|
|
8
|
+
import { MouseEventHandler, ReactElement } from 'react';
|
|
9
9
|
import { JsonLd } from 'json-ld-types';
|
|
10
10
|
export interface HoverCardProps extends WithAnalyticsEventsProps {
|
|
11
11
|
/**
|
|
@@ -80,6 +80,7 @@ export type HoverCardContentProps = {
|
|
|
80
80
|
url: string;
|
|
81
81
|
onMouseEnter?: MouseEventHandler;
|
|
82
82
|
onMouseLeave?: MouseEventHandler;
|
|
83
|
+
onWheel?: EventListenerOrEventListenerObject;
|
|
83
84
|
showServerActions?: boolean;
|
|
84
85
|
};
|
|
85
86
|
export type SnippetOrPreviewProps = {
|
|
@@ -5,7 +5,7 @@ import { LinkAction } from '../../state/hooks-external/useSmartLinkActions';
|
|
|
5
5
|
import { CardState } from '@atlaskit/linking-common';
|
|
6
6
|
import { AnalyticsHandler } from '../../utils/types';
|
|
7
7
|
import { CardProviderRenderers } from '@atlaskit/link-provider';
|
|
8
|
-
import {
|
|
8
|
+
import { MouseEventHandler, ReactElement } from 'react';
|
|
9
9
|
import { JsonLd } from 'json-ld-types';
|
|
10
10
|
export interface HoverCardProps extends WithAnalyticsEventsProps {
|
|
11
11
|
/**
|
|
@@ -80,6 +80,7 @@ export type HoverCardContentProps = {
|
|
|
80
80
|
url: string;
|
|
81
81
|
onMouseEnter?: MouseEventHandler;
|
|
82
82
|
onMouseLeave?: MouseEventHandler;
|
|
83
|
+
onWheel?: EventListenerOrEventListenerObject;
|
|
83
84
|
showServerActions?: boolean;
|
|
84
85
|
};
|
|
85
86
|
export type SnippetOrPreviewProps = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/smart-card",
|
|
3
|
-
"version": "26.9.
|
|
3
|
+
"version": "26.9.8",
|
|
4
4
|
"description": "Smart card component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@atlaskit/popup": "^1.8.0",
|
|
49
49
|
"@atlaskit/spinner": "^15.5.0",
|
|
50
50
|
"@atlaskit/theme": "^12.5.0",
|
|
51
|
-
"@atlaskit/tokens": "^1.
|
|
51
|
+
"@atlaskit/tokens": "^1.12.0",
|
|
52
52
|
"@atlaskit/tooltip": "^17.8.0",
|
|
53
53
|
"@atlaskit/ufo": "^0.2.0",
|
|
54
54
|
"@babel/runtime": "^7.0.0",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"fetch-mock": "^8.0.0",
|
|
96
96
|
"jest-emotion": "^10.0.32",
|
|
97
97
|
"jest-extended": "^0.11.2",
|
|
98
|
-
"jsdom": "^
|
|
98
|
+
"jsdom": "^17.0.0",
|
|
99
99
|
"lorem-ipsum": "^1.0.6",
|
|
100
100
|
"react": "^16.8.0",
|
|
101
101
|
"react-ace": "^6.1.0",
|