@atlaskit/smart-card 20.1.2 → 21.0.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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 21.0.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 20.1.4
10
+
11
+ ### Patch Changes
12
+
13
+ - [`8df009f4313`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8df009f4313) - fix metadata status for prefetching
14
+
15
+ ## 20.1.3
16
+
17
+ ### Patch Changes
18
+
19
+ - [`7c0644e5daf`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7c0644e5daf) - fix on mouse hover functionality for hover cards
20
+
3
21
  ## 20.1.2
4
22
 
5
23
  ### Patch Changes
@@ -15,6 +15,8 @@ var _react = require("react");
15
15
 
16
16
  var _linkProvider = require("@atlaskit/link-provider");
17
17
 
18
+ var _linkingCommon = require("@atlaskit/linking-common");
19
+
18
20
  function usePrefetch(url) {
19
21
  var _useSmartLinkContext = (0, _linkProvider.useSmartLinkContext)(),
20
22
  store = _useSmartLinkContext.store,
@@ -70,7 +72,12 @@ function usePrefetch(url) {
70
72
  type: 'resolved',
71
73
  url: url,
72
74
  payload: response
73
- });
75
+ }); // Put the metadata in resolved state, theres no need for a pending or errored state as
76
+ // we are following the same render flow as described by the comments above and below.
77
+
78
+ dispatch((0, _linkingCommon.cardAction)(_linkingCommon.ACTION_UPDATE_METADATA_STATUS, {
79
+ url: url
80
+ }, undefined, undefined, 'resolved'));
74
81
  }
75
82
 
76
83
  _context.next = 14;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "20.1.2",
3
+ "version": "21.0.0",
4
4
  "sideEffects": false
5
5
  }
@@ -58,6 +58,8 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
58
58
  x: 0,
59
59
  y: 0
60
60
  });
61
+ var popupOffset = (0, _react.useRef)();
62
+ var parentSpan = (0, _react.useRef)(null);
61
63
  var renderers = (0, _renderers.useSmartLinkRenderers)();
62
64
  var linkState = (0, _store.useSmartCardState)(url);
63
65
  var hoverDisplay = 'card';
@@ -92,6 +94,14 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
92
94
  analytics.ui.hoverCardViewedEvent(hoverDisplay, invokeMethod);
93
95
  }
94
96
 
97
+ if (parentSpan.current) {
98
+ var _parentSpan$current$g = parentSpan.current.getBoundingClientRect(),
99
+ bottom = _parentSpan$current$g.bottom,
100
+ left = _parentSpan$current$g.left;
101
+
102
+ popupOffset.current = [mousePos.current.x - left, mousePos.current.y - bottom + _styled.CARD_GAP_PX];
103
+ }
104
+
95
105
  setIsOpen(true);
96
106
  }, delay);
97
107
  }, [delay, isOpen, analytics.ui]);
@@ -124,6 +134,7 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
124
134
  isOpen: isOpen,
125
135
  onClose: hideCard,
126
136
  placement: "bottom-start",
137
+ offset: popupOffset.current,
127
138
  content: function content(_ref2) {
128
139
  var update = _ref2.update;
129
140
  return (0, _core.jsx)("div", {
@@ -145,18 +156,12 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
145
156
  },
146
157
  trigger: function trigger(triggerProps) {
147
158
  return (0, _core.jsx)("span", {
159
+ ref: parentSpan
160
+ }, (0, _core.jsx)("span", (0, _extends2.default)({}, triggerProps, {
148
161
  onMouseEnter: initShowCard,
149
162
  onMouseLeave: initHideCard,
150
163
  onMouseMove: setMousePosition
151
- }, (0, _core.jsx)("span", (0, _extends2.default)({}, triggerProps, {
152
- css: {
153
- position: 'sticky'
154
- },
155
- style: {
156
- left: mousePos.current.x,
157
- top: mousePos.current.y
158
- }
159
- })), children);
164
+ }), children));
160
165
  },
161
166
  zIndex: 511 // Temporary fix for Confluence inline comment on editor mod has z-index of 500, Jira issue view has z-index of 510
162
167
 
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.titleBlockCss = exports.skeletonContainer = exports.metadataBlockCss = exports.loadingViewContainer = exports.footerBlockCss = exports.flexibleUiOptions = exports.HoverCardContainer = exports.CARD_WIDTH_REM = void 0;
8
+ exports.titleBlockCss = exports.skeletonContainer = exports.metadataBlockCss = exports.loadingViewContainer = exports.footerBlockCss = exports.flexibleUiOptions = exports.HoverCardContainer = exports.CARD_WIDTH_REM = exports.CARD_GAP_PX = void 0;
9
9
 
10
10
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
11
11
 
@@ -25,8 +25,11 @@ var flexibleUiOptions = {
25
25
  hidePadding: true
26
26
  };
27
27
  exports.flexibleUiOptions = flexibleUiOptions;
28
- var CARD_WIDTH_REM = 24;
28
+ var CARD_WIDTH_REM = 24; // gap between mouse cursor and hover card
29
+
29
30
  exports.CARD_WIDTH_REM = CARD_WIDTH_REM;
31
+ var CARD_GAP_PX = 10;
32
+ exports.CARD_GAP_PX = CARD_GAP_PX;
30
33
  var blockGap = '0.5rem';
31
34
  var elementGap = '0.5rem';
32
35
  var separatorCss = (0, _core.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n [data-separator] + [data-separator]:before {\n margin-right: ", ";\n }\n"])), elementGap);
@@ -1,5 +1,6 @@
1
1
  import { useCallback } from 'react';
2
2
  import { useSmartLinkContext } from '@atlaskit/link-provider';
3
+ import { ACTION_UPDATE_METADATA_STATUS, cardAction } from '@atlaskit/linking-common';
3
4
  export function usePrefetch(url) {
4
5
  const {
5
6
  store,
@@ -45,7 +46,12 @@ export function usePrefetch(url) {
45
46
  type: 'resolved',
46
47
  url,
47
48
  payload: response
48
- });
49
+ }); // Put the metadata in resolved state, theres no need for a pending or errored state as
50
+ // we are following the same render flow as described by the comments above and below.
51
+
52
+ dispatch(cardAction(ACTION_UPDATE_METADATA_STATUS, {
53
+ url
54
+ }, undefined, undefined, 'resolved'));
49
55
  }
50
56
  } catch (_err) {// Do nothing, link will be retried under the hood with exponential backoff.
51
57
  // If it does not succeed even after those retries, the normal resolve flow
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "20.1.2",
3
+ "version": "21.0.0",
4
4
  "sideEffects": false
5
5
  }
@@ -8,7 +8,7 @@ import { useSmartLinkActions } from '../../../state/hooks-external/useSmartLinkA
8
8
  import { useSmartLinkRenderers } from '../../../state/renderers';
9
9
  import { useSmartCardState as useLinkState } from '../../../state/store';
10
10
  import HoverCardContent from '../components/HoverCardContent';
11
- import { HoverCardContainer } from '../styled';
11
+ import { HoverCardContainer, CARD_GAP_PX } from '../styled';
12
12
  import { SMART_CARD_ANALYTICS_DISPLAY } from '../utils';
13
13
  export const hoverCardClassName = 'smart-links-hover-preview';
14
14
  export const HoverCardComponent = ({
@@ -26,6 +26,8 @@ export const HoverCardComponent = ({
26
26
  x: 0,
27
27
  y: 0
28
28
  });
29
+ const popupOffset = useRef();
30
+ const parentSpan = useRef(null);
29
31
  const renderers = useSmartLinkRenderers();
30
32
  const linkState = useLinkState(url);
31
33
  const hoverDisplay = 'card';
@@ -58,6 +60,14 @@ export const HoverCardComponent = ({
58
60
  analytics.ui.hoverCardViewedEvent(hoverDisplay, invokeMethod);
59
61
  }
60
62
 
63
+ if (parentSpan.current) {
64
+ const {
65
+ bottom,
66
+ left
67
+ } = parentSpan.current.getBoundingClientRect();
68
+ popupOffset.current = [mousePos.current.x - left, mousePos.current.y - bottom + CARD_GAP_PX];
69
+ }
70
+
61
71
  setIsOpen(true);
62
72
  }, delay);
63
73
  }, [delay, isOpen, analytics.ui]);
@@ -88,6 +98,7 @@ export const HoverCardComponent = ({
88
98
  isOpen: isOpen,
89
99
  onClose: hideCard,
90
100
  placement: "bottom-start",
101
+ offset: popupOffset.current,
91
102
  content: ({
92
103
  update
93
104
  }) => jsx("div", {
@@ -107,18 +118,12 @@ export const HoverCardComponent = ({
107
118
  url: url
108
119
  })),
109
120
  trigger: triggerProps => jsx("span", {
121
+ ref: parentSpan
122
+ }, jsx("span", _extends({}, triggerProps, {
110
123
  onMouseEnter: initShowCard,
111
124
  onMouseLeave: initHideCard,
112
125
  onMouseMove: setMousePosition
113
- }, jsx("span", _extends({}, triggerProps, {
114
- css: {
115
- position: 'sticky'
116
- },
117
- style: {
118
- left: mousePos.current.x,
119
- top: mousePos.current.y
120
- }
121
- })), children),
126
+ }), children)),
122
127
  zIndex: 511 // Temporary fix for Confluence inline comment on editor mod has z-index of 500, Jira issue view has z-index of 510
123
128
 
124
129
  });
@@ -8,7 +8,9 @@ export const flexibleUiOptions = {
8
8
  theme: SmartLinkTheme.Black,
9
9
  hidePadding: true
10
10
  };
11
- export const CARD_WIDTH_REM = 24;
11
+ export const CARD_WIDTH_REM = 24; // gap between mouse cursor and hover card
12
+
13
+ export const CARD_GAP_PX = 10;
12
14
  const blockGap = '0.5rem';
13
15
  const elementGap = '0.5rem';
14
16
  const separatorCss = css`
@@ -2,6 +2,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  import { useCallback } from 'react';
4
4
  import { useSmartLinkContext } from '@atlaskit/link-provider';
5
+ import { ACTION_UPDATE_METADATA_STATUS, cardAction } from '@atlaskit/linking-common';
5
6
  export function usePrefetch(url) {
6
7
  var _useSmartLinkContext = useSmartLinkContext(),
7
8
  store = _useSmartLinkContext.store,
@@ -57,7 +58,12 @@ export function usePrefetch(url) {
57
58
  type: 'resolved',
58
59
  url: url,
59
60
  payload: response
60
- });
61
+ }); // Put the metadata in resolved state, theres no need for a pending or errored state as
62
+ // we are following the same render flow as described by the comments above and below.
63
+
64
+ dispatch(cardAction(ACTION_UPDATE_METADATA_STATUS, {
65
+ url: url
66
+ }, undefined, undefined, 'resolved'));
61
67
  }
62
68
 
63
69
  _context.next = 14;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "20.1.2",
3
+ "version": "21.0.0",
4
4
  "sideEffects": false
5
5
  }
@@ -9,7 +9,7 @@ import { useSmartLinkActions } from '../../../state/hooks-external/useSmartLinkA
9
9
  import { useSmartLinkRenderers } from '../../../state/renderers';
10
10
  import { useSmartCardState as useLinkState } from '../../../state/store';
11
11
  import HoverCardContent from '../components/HoverCardContent';
12
- import { HoverCardContainer } from '../styled';
12
+ import { HoverCardContainer, CARD_GAP_PX } from '../styled';
13
13
  import { SMART_CARD_ANALYTICS_DISPLAY } from '../utils';
14
14
  export var hoverCardClassName = 'smart-links-hover-preview';
15
15
  export var HoverCardComponent = function HoverCardComponent(_ref) {
@@ -31,6 +31,8 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
31
31
  x: 0,
32
32
  y: 0
33
33
  });
34
+ var popupOffset = useRef();
35
+ var parentSpan = useRef(null);
34
36
  var renderers = useSmartLinkRenderers();
35
37
  var linkState = useLinkState(url);
36
38
  var hoverDisplay = 'card';
@@ -65,6 +67,14 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
65
67
  analytics.ui.hoverCardViewedEvent(hoverDisplay, invokeMethod);
66
68
  }
67
69
 
70
+ if (parentSpan.current) {
71
+ var _parentSpan$current$g = parentSpan.current.getBoundingClientRect(),
72
+ bottom = _parentSpan$current$g.bottom,
73
+ left = _parentSpan$current$g.left;
74
+
75
+ popupOffset.current = [mousePos.current.x - left, mousePos.current.y - bottom + CARD_GAP_PX];
76
+ }
77
+
68
78
  setIsOpen(true);
69
79
  }, delay);
70
80
  }, [delay, isOpen, analytics.ui]);
@@ -97,6 +107,7 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
97
107
  isOpen: isOpen,
98
108
  onClose: hideCard,
99
109
  placement: "bottom-start",
110
+ offset: popupOffset.current,
100
111
  content: function content(_ref2) {
101
112
  var update = _ref2.update;
102
113
  return jsx("div", {
@@ -118,18 +129,12 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
118
129
  },
119
130
  trigger: function trigger(triggerProps) {
120
131
  return jsx("span", {
132
+ ref: parentSpan
133
+ }, jsx("span", _extends({}, triggerProps, {
121
134
  onMouseEnter: initShowCard,
122
135
  onMouseLeave: initHideCard,
123
136
  onMouseMove: setMousePosition
124
- }, jsx("span", _extends({}, triggerProps, {
125
- css: {
126
- position: 'sticky'
127
- },
128
- style: {
129
- left: mousePos.current.x,
130
- top: mousePos.current.y
131
- }
132
- })), children);
137
+ }), children));
133
138
  },
134
139
  zIndex: 511 // Temporary fix for Confluence inline comment on editor mod has z-index of 500, Jira issue view has z-index of 510
135
140
 
@@ -12,7 +12,9 @@ export var flexibleUiOptions = {
12
12
  theme: SmartLinkTheme.Black,
13
13
  hidePadding: true
14
14
  };
15
- export var CARD_WIDTH_REM = 24;
15
+ export var CARD_WIDTH_REM = 24; // gap between mouse cursor and hover card
16
+
17
+ export var CARD_GAP_PX = 10;
16
18
  var blockGap = '0.5rem';
17
19
  var elementGap = '0.5rem';
18
20
  var separatorCss = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n [data-separator] + [data-separator]:before {\n margin-right: ", ";\n }\n"])), elementGap);
@@ -1,6 +1,7 @@
1
1
  import { FlexibleUiOptions } from '../FlexibleCard/types';
2
2
  export declare const flexibleUiOptions: FlexibleUiOptions;
3
3
  export declare const CARD_WIDTH_REM = 24;
4
+ export declare const CARD_GAP_PX = 10;
4
5
  export declare const HoverCardContainer: import("@emotion/utils").SerializedStyles;
5
6
  export declare const titleBlockCss: import("@emotion/utils").SerializedStyles;
6
7
  export declare const metadataBlockCss: import("@emotion/utils").SerializedStyles;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "20.1.2",
3
+ "version": "21.0.0",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -33,7 +33,7 @@
33
33
  "@atlaskit/icon-object": "^6.2.0",
34
34
  "@atlaskit/icon-priority": "^6.3.0",
35
35
  "@atlaskit/in-product-testing": "^0.1.0",
36
- "@atlaskit/linking-common": "^1.4.0",
36
+ "@atlaskit/linking-common": "^1.5.0",
37
37
  "@atlaskit/logo": "^13.8.0",
38
38
  "@atlaskit/lozenge": "^11.1.0",
39
39
  "@atlaskit/media-common": "^2.15.0",
@@ -58,7 +58,7 @@
58
58
  "uuid": "^3.1.0"
59
59
  },
60
60
  "peerDependencies": {
61
- "@atlaskit/link-provider": "^1.1.5",
61
+ "@atlaskit/link-provider": "^1.2.0",
62
62
  "react": "^16.8.0",
63
63
  "react-dom": "^16.8.0",
64
64
  "react-intl-next": "npm:react-intl@^5.18.1"
@@ -70,7 +70,7 @@
70
70
  "@atlaskit/docs": "*",
71
71
  "@atlaskit/field-base": "^15.0.6",
72
72
  "@atlaskit/form": "^8.5.0",
73
- "@atlaskit/inline-message": "^11.2.0",
73
+ "@atlaskit/inline-message": "^11.3.0",
74
74
  "@atlaskit/lozenge": "^11.1.0",
75
75
  "@atlaskit/media-integration-test-helpers": "^2.6.0",
76
76
  "@atlaskit/media-test-helpers": "^30.0.0",