@atlaskit/smart-card 44.3.0 → 44.3.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 +17 -0
- package/analytics.spec.yaml +9 -0
- package/dist/cjs/ssr.js +28 -1
- package/dist/cjs/state/hooks/use-incoming-outgoing-links/index.js +8 -14
- package/dist/cjs/state/hooks/use-intersection-observer/index.js +49 -0
- package/dist/cjs/utils/analytics/analytics.js +1 -1
- package/dist/cjs/view/CardWithUrl/card-error-boundary/index.js +28 -0
- package/dist/cjs/view/CardWithUrl/card-intersection-observer/index.js +46 -0
- package/dist/cjs/view/CardWithUrl/card-loader-wrapper/index.js +23 -0
- package/dist/cjs/view/CardWithUrl/component-lazy/LazyIntersectionObserverCard.js +43 -3
- package/dist/cjs/view/CardWithUrl/component.js +34 -2
- package/dist/cjs/view/LinkUrl/index.js +1 -1
- package/dist/es2019/ssr.js +28 -2
- package/dist/es2019/state/hooks/use-incoming-outgoing-links/index.js +8 -12
- package/dist/es2019/state/hooks/use-intersection-observer/index.js +41 -0
- package/dist/es2019/utils/analytics/analytics.js +1 -1
- package/dist/es2019/view/CardWithUrl/card-error-boundary/index.js +20 -0
- package/dist/es2019/view/CardWithUrl/card-intersection-observer/index.js +25 -0
- package/dist/es2019/view/CardWithUrl/card-loader-wrapper/index.js +16 -0
- package/dist/es2019/view/CardWithUrl/component-lazy/LazyIntersectionObserverCard.js +39 -2
- package/dist/es2019/view/CardWithUrl/component.js +34 -2
- package/dist/es2019/view/LinkUrl/index.js +1 -1
- package/dist/esm/ssr.js +29 -2
- package/dist/esm/state/hooks/use-incoming-outgoing-links/index.js +8 -14
- package/dist/esm/state/hooks/use-intersection-observer/index.js +44 -0
- package/dist/esm/utils/analytics/analytics.js +1 -1
- package/dist/esm/view/CardWithUrl/card-error-boundary/index.js +21 -0
- package/dist/esm/view/CardWithUrl/card-intersection-observer/index.js +37 -0
- package/dist/esm/view/CardWithUrl/card-loader-wrapper/index.js +15 -0
- package/dist/esm/view/CardWithUrl/component-lazy/LazyIntersectionObserverCard.js +42 -2
- package/dist/esm/view/CardWithUrl/component.js +34 -2
- package/dist/esm/view/LinkUrl/index.js +1 -1
- package/dist/types/common/analytics/generated/analytics.types.d.ts +7 -1
- package/dist/types/state/hooks/use-intersection-observer/index.d.ts +6 -0
- package/dist/types/view/CardWithUrl/card-error-boundary/index.d.ts +5 -0
- package/dist/types/view/CardWithUrl/card-intersection-observer/index.d.ts +7 -0
- package/dist/types/view/CardWithUrl/card-loader-wrapper/index.d.ts +7 -0
- package/dist/types/view/CardWithUrl/component-lazy/LazyIntersectionObserverCard.d.ts +1 -1
- package/dist/types/view/CardWithUrl/component.d.ts +1 -0
- package/dist/types/view/CardWithUrl/types.d.ts +1 -0
- package/dist/types-ts4.5/common/analytics/generated/analytics.types.d.ts +7 -1
- package/dist/types-ts4.5/state/hooks/use-intersection-observer/index.d.ts +6 -0
- package/dist/types-ts4.5/view/CardWithUrl/card-error-boundary/index.d.ts +5 -0
- package/dist/types-ts4.5/view/CardWithUrl/card-intersection-observer/index.d.ts +7 -0
- package/dist/types-ts4.5/view/CardWithUrl/card-loader-wrapper/index.d.ts +7 -0
- package/dist/types-ts4.5/view/CardWithUrl/component-lazy/LazyIntersectionObserverCard.d.ts +1 -1
- package/dist/types-ts4.5/view/CardWithUrl/component.d.ts +1 -0
- package/dist/types-ts4.5/view/CardWithUrl/types.d.ts +1 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/smart-card
|
|
2
2
|
|
|
3
|
+
## 44.3.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`dee5bdcb8345a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/dee5bdcb8345a) -
|
|
8
|
+
Fire analytics event when SL intesects into viewport
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 44.3.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`3c09c35ca21ce`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3c09c35ca21ce) -
|
|
16
|
+
NAVX-2971: Remove platform_navx_send_context_to_ugs_for_rel_links feature flag (cleanup state:
|
|
17
|
+
true) — always send X-Query-Context header
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 44.3.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
package/analytics.spec.yaml
CHANGED
|
@@ -851,6 +851,15 @@ events:
|
|
|
851
851
|
required: false
|
|
852
852
|
type: string
|
|
853
853
|
description: The unique ID for this Smart Link
|
|
854
|
+
- smartLink seen:
|
|
855
|
+
type: ui
|
|
856
|
+
description: fires an event that represents when a rendered Smart Link is visible in the viewport for the first time
|
|
857
|
+
attributes:
|
|
858
|
+
<<: [*PackageMetaDataContext, *CommonContext, *ResolvedContext]
|
|
859
|
+
display:
|
|
860
|
+
required: true
|
|
861
|
+
type: ['inline', 'block', 'embed', 'flexible']
|
|
862
|
+
description: Whether the card was an Inline, Block, Embed or Flexible UI
|
|
854
863
|
- smartLink clicked (smartlinkClickAnalyticsWorkflows):
|
|
855
864
|
type: ui
|
|
856
865
|
description:
|
package/dist/cjs/ssr.js
CHANGED
|
@@ -12,7 +12,9 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
12
12
|
var _reactErrorBoundary = require("react-error-boundary");
|
|
13
13
|
var _uuid = _interopRequireDefault(require("uuid"));
|
|
14
14
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
15
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
16
|
var _analytics = require("./utils/analytics/analytics");
|
|
17
|
+
var _cardErrorBoundary = _interopRequireDefault(require("./view/CardWithUrl/card-error-boundary"));
|
|
16
18
|
var _component = require("./view/CardWithUrl/component");
|
|
17
19
|
var _LoadingCardLink = require("./view/CardWithUrl/component-lazy/LoadingCardLink");
|
|
18
20
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
@@ -21,7 +23,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
21
23
|
// SSR friendly version of smart-card
|
|
22
24
|
// simplifies the logic around rendering and loading placeholders and
|
|
23
25
|
// only contains whats necessary to render the card on SSR mode
|
|
24
|
-
var
|
|
26
|
+
var CardSSROld = function CardSSROld(props) {
|
|
25
27
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
26
28
|
var _useState = (0, _react.useState)(function () {
|
|
27
29
|
var _props$id;
|
|
@@ -47,4 +49,29 @@ var CardSSR = exports.CardSSR = function CardSSR(props) {
|
|
|
47
49
|
}, /*#__PURE__*/_react.default.createElement(Component, {
|
|
48
50
|
className: "loader-wrapper"
|
|
49
51
|
}, /*#__PURE__*/_react.default.createElement(_component.CardWithUrlContent, cardProps))));
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// SSR friendly version of smart-card
|
|
55
|
+
// simplifies the logic around rendering and loading placeholders and
|
|
56
|
+
// only contains whats necessary to render the card on SSR mode
|
|
57
|
+
var CardSSRNew = function CardSSRNew(props) {
|
|
58
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
59
|
+
var _useState3 = (0, _react.useState)(function () {
|
|
60
|
+
var _props$id2;
|
|
61
|
+
return (_props$id2 = props.id) !== null && _props$id2 !== void 0 ? _props$id2 : (0, _uuid.default)();
|
|
62
|
+
}),
|
|
63
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 1),
|
|
64
|
+
id = _useState4[0];
|
|
65
|
+
var propsWithId = _objectSpread(_objectSpread({}, props), {}, {
|
|
66
|
+
id: id
|
|
67
|
+
});
|
|
68
|
+
return /*#__PURE__*/_react.default.createElement(_analyticsNext.AnalyticsContext, {
|
|
69
|
+
data: _analytics.context
|
|
70
|
+
}, /*#__PURE__*/_react.default.createElement(_cardErrorBoundary.default, propsWithId, /*#__PURE__*/_react.default.createElement(_component.CardWithUrl, propsWithId)));
|
|
71
|
+
};
|
|
72
|
+
var CardSSR = exports.CardSSR = function CardSSR(props) {
|
|
73
|
+
if ((0, _platformFeatureFlags.fg)('platform_sl_event_ui_seen')) {
|
|
74
|
+
return /*#__PURE__*/_react.default.createElement(CardSSRNew, props);
|
|
75
|
+
}
|
|
76
|
+
return /*#__PURE__*/_react.default.createElement(CardSSROld, props);
|
|
50
77
|
};
|
|
@@ -9,7 +9,6 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
|
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
10
|
var _react = require("react");
|
|
11
11
|
var _linkingCommon = require("@atlaskit/linking-common");
|
|
12
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
12
|
var _query = require("./query");
|
|
14
13
|
/**
|
|
15
14
|
* @param baseUriWithNoTrailingSlash base url which will then be appended with /gateway/api/graphql to make requests to AGG
|
|
@@ -107,8 +106,8 @@ var useIncomingOutgoingAri = function useIncomingOutgoingAri() {
|
|
|
107
106
|
var _response$data$graphS, _response$data, _response$data$graphS2, _response$data2;
|
|
108
107
|
var firstIncoming,
|
|
109
108
|
firstOutgoing,
|
|
110
|
-
headers,
|
|
111
109
|
siteId,
|
|
110
|
+
headers,
|
|
112
111
|
response,
|
|
113
112
|
incomingAris,
|
|
114
113
|
outgoingAris,
|
|
@@ -118,28 +117,23 @@ var useIncomingOutgoingAri = function useIncomingOutgoingAri() {
|
|
|
118
117
|
case 0:
|
|
119
118
|
firstIncoming = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : 50;
|
|
120
119
|
firstOutgoing = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : 50;
|
|
121
|
-
|
|
122
|
-
_context4.next = 9;
|
|
123
|
-
break;
|
|
124
|
-
}
|
|
125
|
-
_context4.next = 5;
|
|
120
|
+
_context4.next = 4;
|
|
126
121
|
return getSiteId(ari);
|
|
127
|
-
case
|
|
122
|
+
case 4:
|
|
128
123
|
siteId = _context4.sent;
|
|
129
124
|
if (siteId) {
|
|
130
|
-
_context4.next =
|
|
125
|
+
_context4.next = 7;
|
|
131
126
|
break;
|
|
132
127
|
}
|
|
133
128
|
return _context4.abrupt("return", {
|
|
134
129
|
incomingAris: [],
|
|
135
130
|
outgoingAris: []
|
|
136
131
|
});
|
|
137
|
-
case
|
|
132
|
+
case 7:
|
|
138
133
|
headers = {
|
|
139
134
|
'X-Query-Context': "ari:cloud:platform::site/".concat(siteId)
|
|
140
135
|
};
|
|
141
|
-
|
|
142
|
-
_context4.next = 11;
|
|
136
|
+
_context4.next = 10;
|
|
143
137
|
return aggRequestCall({
|
|
144
138
|
variables: {
|
|
145
139
|
id: ari,
|
|
@@ -148,7 +142,7 @@ var useIncomingOutgoingAri = function useIncomingOutgoingAri() {
|
|
|
148
142
|
},
|
|
149
143
|
query: _query.queryIncomingOutgoingLinks
|
|
150
144
|
}, headers);
|
|
151
|
-
case
|
|
145
|
+
case 10:
|
|
152
146
|
response = _context4.sent;
|
|
153
147
|
incomingAris = (_response$data$graphS = response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 || (_response$data = _response$data.graphStore) === null || _response$data === void 0 || (_response$data = _response$data.incoming) === null || _response$data === void 0 || (_response$data = _response$data.aris) === null || _response$data === void 0 || (_response$data = _response$data.map(function (node) {
|
|
154
148
|
return node === null || node === void 0 ? void 0 : node.id;
|
|
@@ -164,7 +158,7 @@ var useIncomingOutgoingAri = function useIncomingOutgoingAri() {
|
|
|
164
158
|
incomingAris: incomingAris,
|
|
165
159
|
outgoingAris: outgoingAris
|
|
166
160
|
});
|
|
167
|
-
case
|
|
161
|
+
case 14:
|
|
168
162
|
case "end":
|
|
169
163
|
return _context4.stop();
|
|
170
164
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
// This property enables the intersection observer to be run once the
|
|
9
|
+
// HTML element being observed is within `X` px of the target container it is
|
|
10
|
+
// being compared to. Since the default container is the `document`, we set this
|
|
11
|
+
// up to check once a Smart Link is within `X` px from the bottom of the viewport.
|
|
12
|
+
var ROOT_MARGIN_VERTICAL = '360px';
|
|
13
|
+
var useIntersectionObserver = function useIntersectionObserver(_ref) {
|
|
14
|
+
var onIntersectingCallback = _ref.onIntersecting,
|
|
15
|
+
onIntersectionCallback = _ref.onIntersection;
|
|
16
|
+
var ref = (0, _react.useRef)(null);
|
|
17
|
+
var onIntersectingCallbackRef = (0, _react.useRef)(onIntersectingCallback);
|
|
18
|
+
var onIntersectionCallbackRef = (0, _react.useRef)(onIntersectionCallback);
|
|
19
|
+
(0, _react.useEffect)(function () {
|
|
20
|
+
onIntersectingCallbackRef.current = onIntersectingCallback;
|
|
21
|
+
onIntersectionCallbackRef.current = onIntersectionCallback;
|
|
22
|
+
}, [onIntersectingCallback, onIntersectionCallback]);
|
|
23
|
+
var onIntersection = (0, _react.useCallback)(function (entries, observer) {
|
|
24
|
+
var _onIntersectionCallba;
|
|
25
|
+
var isIntersecting = entries.some(function (entry) {
|
|
26
|
+
return entry.isIntersecting;
|
|
27
|
+
});
|
|
28
|
+
(_onIntersectionCallba = onIntersectionCallbackRef.current) === null || _onIntersectionCallba === void 0 || _onIntersectionCallba.call(onIntersectionCallbackRef, isIntersecting);
|
|
29
|
+
if (isIntersecting) {
|
|
30
|
+
var _onIntersectingCallba;
|
|
31
|
+
(_onIntersectingCallba = onIntersectingCallbackRef.current) === null || _onIntersectingCallba === void 0 || _onIntersectingCallba.call(onIntersectingCallbackRef);
|
|
32
|
+
observer.disconnect();
|
|
33
|
+
}
|
|
34
|
+
}, []);
|
|
35
|
+
(0, _react.useEffect)(function () {
|
|
36
|
+
if (!ref.current) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
var intersectionObserver = new IntersectionObserver(onIntersection, {
|
|
40
|
+
rootMargin: "".concat(ROOT_MARGIN_VERTICAL, " 0px ").concat(ROOT_MARGIN_VERTICAL, " 0px")
|
|
41
|
+
});
|
|
42
|
+
intersectionObserver.observe(ref.current);
|
|
43
|
+
return function () {
|
|
44
|
+
return intersectionObserver.disconnect();
|
|
45
|
+
};
|
|
46
|
+
}, [ref, onIntersection]);
|
|
47
|
+
return ref;
|
|
48
|
+
};
|
|
49
|
+
var _default = exports.default = useIntersectionObserver;
|
|
@@ -11,7 +11,7 @@ var ANALYTICS_CHANNEL = exports.ANALYTICS_CHANNEL = 'media';
|
|
|
11
11
|
var context = exports.context = {
|
|
12
12
|
componentName: 'smart-cards',
|
|
13
13
|
packageName: "@atlaskit/smart-card",
|
|
14
|
-
packageVersion: "44.
|
|
14
|
+
packageVersion: "44.3.1"
|
|
15
15
|
};
|
|
16
16
|
var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
17
17
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _reactErrorBoundary = require("react-error-boundary");
|
|
11
|
+
var _LoadingCardLink = require("../component-lazy/LoadingCardLink");
|
|
12
|
+
var _excluded = ["children"];
|
|
13
|
+
var CardErrorBoundary = function CardErrorBoundary(_ref) {
|
|
14
|
+
var children = _ref.children,
|
|
15
|
+
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
16
|
+
// TODO: NAVX-4682: Add feature parity to CardWithURLRenderer
|
|
17
|
+
var ErrorFallbackComponent = props.fallbackComponent;
|
|
18
|
+
var errorBoundaryFallbackComponent = function errorBoundaryFallbackComponent() {
|
|
19
|
+
if (ErrorFallbackComponent) {
|
|
20
|
+
return /*#__PURE__*/_react.default.createElement(ErrorFallbackComponent, null);
|
|
21
|
+
}
|
|
22
|
+
return /*#__PURE__*/_react.default.createElement(_LoadingCardLink.LoadingCardLink, props);
|
|
23
|
+
};
|
|
24
|
+
return /*#__PURE__*/_react.default.createElement(_reactErrorBoundary.ErrorBoundary, {
|
|
25
|
+
FallbackComponent: errorBoundaryFallbackComponent
|
|
26
|
+
}, children);
|
|
27
|
+
};
|
|
28
|
+
var _default = exports.default = CardErrorBoundary;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _useIntersectionObserver = _interopRequireDefault(require("../../../state/hooks/use-intersection-observer"));
|
|
13
|
+
var _utils = require("../../../utils");
|
|
14
|
+
var _cardLoaderWrapper = _interopRequireDefault(require("../card-loader-wrapper"));
|
|
15
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
16
|
+
var withCardIntersectionObserver = function withCardIntersectionObserver(Component) {
|
|
17
|
+
return function (props) {
|
|
18
|
+
// TODO: NAVX-4682: Add feature parity to LazyIntersectionObserverCard for no lazy loading
|
|
19
|
+
var _useState = (0, _react.useState)(false),
|
|
20
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
21
|
+
isIntersected = _useState2[0],
|
|
22
|
+
setIsIntersected = _useState2[1];
|
|
23
|
+
var onIntersecting = (0, _react.useCallback)(function () {
|
|
24
|
+
setIsIntersected(true);
|
|
25
|
+
}, []);
|
|
26
|
+
var ref = (0, _useIntersectionObserver.default)({
|
|
27
|
+
onIntersecting: onIntersecting
|
|
28
|
+
});
|
|
29
|
+
return /*#__PURE__*/_react.default.createElement(_cardLoaderWrapper.default, {
|
|
30
|
+
appearance: props.appearance,
|
|
31
|
+
ref: ref
|
|
32
|
+
}, /*#__PURE__*/_react.default.createElement(Component, (0, _extends2.default)({}, props, {
|
|
33
|
+
isIntersected: isIntersected
|
|
34
|
+
})));
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
var withCardIntersectionObserverFallback = function withCardIntersectionObserverFallback(Component) {
|
|
38
|
+
return function (props) {
|
|
39
|
+
return /*#__PURE__*/_react.default.createElement(_cardLoaderWrapper.default, {
|
|
40
|
+
appearance: props.appearance
|
|
41
|
+
}, /*#__PURE__*/_react.default.createElement(Component, props));
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
var _default = exports.default = function _default(Component) {
|
|
45
|
+
return (0, _utils.isIntersectionObserverSupported)() ? withCardIntersectionObserver(Component) : withCardIntersectionObserverFallback(Component);
|
|
46
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
10
|
+
var CardLoaderWrapper = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
11
|
+
var appearance = _ref.appearance,
|
|
12
|
+
children = _ref.children;
|
|
13
|
+
var Component = appearance === 'inline' ? 'span' : 'div';
|
|
14
|
+
return (
|
|
15
|
+
/*#__PURE__*/
|
|
16
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
17
|
+
_react.default.createElement(Component, {
|
|
18
|
+
className: "loader-wrapper",
|
|
19
|
+
ref: ref
|
|
20
|
+
}, children)
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
var _default = exports.default = CardLoaderWrapper;
|
|
@@ -5,12 +5,16 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.LazyIntersectionObserverCard =
|
|
8
|
+
exports.LazyIntersectionObserverCard = void 0;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _platformFeatureFlagsReact = require("@atlaskit/platform-feature-flags-react");
|
|
11
13
|
var _state = require("../../../state");
|
|
12
14
|
var _ufoExperiences = require("../../../state/analytics/ufoExperiences");
|
|
15
|
+
var _useIntersectionObserver = _interopRequireDefault(require("../../../state/hooks/use-intersection-observer"));
|
|
13
16
|
var _shouldSample = require("../../../utils/shouldSample");
|
|
17
|
+
var _cardLoaderWrapper = _interopRequireDefault(require("../card-loader-wrapper"));
|
|
14
18
|
var _component = require("../component");
|
|
15
19
|
var _LoadingCardLink = require("./LoadingCardLink");
|
|
16
20
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
@@ -19,7 +23,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
19
23
|
// being compared to. Since the default container is the `document`, we set this
|
|
20
24
|
// up to check once a Smart Link is within `X` px from the bottom of the viewport.
|
|
21
25
|
var ROOT_MARGIN_VERTICAL = '360px';
|
|
22
|
-
function
|
|
26
|
+
function LazyIntersectionObserverCardOld(props) {
|
|
23
27
|
var ref = (0, _react.useRef)(null);
|
|
24
28
|
var _useState = (0, _react.useState)(false),
|
|
25
29
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -68,4 +72,40 @@ function LazyIntersectionObserverCard(props) {
|
|
|
68
72
|
return /*#__PURE__*/_react.default.createElement(Component, {
|
|
69
73
|
className: "loader-wrapper"
|
|
70
74
|
}, content);
|
|
71
|
-
}
|
|
75
|
+
}
|
|
76
|
+
var LazyIntersectionObserverCardNew = function LazyIntersectionObserverCardNew(props) {
|
|
77
|
+
var _useState5 = (0, _react.useState)(false),
|
|
78
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
79
|
+
isIntersected = _useState6[0],
|
|
80
|
+
setIsIntersected = _useState6[1];
|
|
81
|
+
var _useState7 = (0, _react.useState)((0, _shouldSample.shouldSample)()),
|
|
82
|
+
_useState8 = (0, _slicedToArray2.default)(_useState7, 1),
|
|
83
|
+
shouldSendRenderedUFOEvent = _useState8[0];
|
|
84
|
+
var appearance = props.appearance,
|
|
85
|
+
url = props.url,
|
|
86
|
+
id = props.id;
|
|
87
|
+
var prefetch = (0, _state.usePrefetch)(url);
|
|
88
|
+
var ComponentObserver = appearance === 'inline' ? 'span' : 'div';
|
|
89
|
+
var onIntersection = (0, _react.useCallback)(function (isIntersecting) {
|
|
90
|
+
if (isIntersecting) {
|
|
91
|
+
if (shouldSendRenderedUFOEvent) {
|
|
92
|
+
(0, _ufoExperiences.startUfoExperience)('smart-link-rendered', id);
|
|
93
|
+
}
|
|
94
|
+
setIsIntersected(true);
|
|
95
|
+
} else {
|
|
96
|
+
prefetch();
|
|
97
|
+
}
|
|
98
|
+
}, [id, prefetch, shouldSendRenderedUFOEvent]);
|
|
99
|
+
var ref = (0, _useIntersectionObserver.default)({
|
|
100
|
+
onIntersection: onIntersection
|
|
101
|
+
});
|
|
102
|
+
var content = isIntersected ? /*#__PURE__*/_react.default.createElement(_component.CardWithUrlContent, (0, _extends2.default)({}, props, {
|
|
103
|
+
isIntersected: true
|
|
104
|
+
})) : /*#__PURE__*/_react.default.createElement(ComponentObserver, {
|
|
105
|
+
ref: ref
|
|
106
|
+
}, /*#__PURE__*/_react.default.createElement(_LoadingCardLink.LoadingCardLink, props));
|
|
107
|
+
return /*#__PURE__*/_react.default.createElement(_cardLoaderWrapper.default, {
|
|
108
|
+
appearance: appearance
|
|
109
|
+
}, content);
|
|
110
|
+
};
|
|
111
|
+
var LazyIntersectionObserverCard = exports.LazyIntersectionObserverCard = (0, _platformFeatureFlagsReact.componentWithFG)('platform_sl_event_ui_seen', LazyIntersectionObserverCardNew, LazyIntersectionObserverCardOld);
|
|
@@ -5,7 +5,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.CardWithUrlContent = void 0;
|
|
8
|
+
exports.CardWithUrlContent = exports.CardWithUrl = void 0;
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
11
11
|
var _linkExtractors = require("@atlaskit/link-extractors");
|
|
@@ -30,6 +30,7 @@ var _EmbedCard = require("../EmbedCard");
|
|
|
30
30
|
var _FlexibleCard = _interopRequireDefault(require("../FlexibleCard"));
|
|
31
31
|
var _InlineCard = require("../InlineCard");
|
|
32
32
|
var _useSmartLinkEvents = require("../SmartLinkEvents/useSmartLinkEvents");
|
|
33
|
+
var _cardIntersectionObserver = _interopRequireDefault(require("./card-intersection-observer"));
|
|
33
34
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
34
35
|
var thirdPartyARIPrefix = 'ari:third-party';
|
|
35
36
|
var EmbedCardComponent = (0, _platformFeatureFlagsReact.componentWithFG)('rovo_chat_embed_card_dwell_and_hover_metrics', _EmbedCard.EmbedCardUpdated, _EmbedCard.EmbedCard);
|
|
@@ -38,6 +39,7 @@ function Component(_ref) {
|
|
|
38
39
|
url = _ref.url,
|
|
39
40
|
isSelected = _ref.isSelected,
|
|
40
41
|
isHovered = _ref.isHovered,
|
|
42
|
+
isIntersected = _ref.isIntersected,
|
|
41
43
|
frameStyle = _ref.frameStyle,
|
|
42
44
|
platform = _ref.platform,
|
|
43
45
|
onClick = _ref.onClick,
|
|
@@ -65,6 +67,7 @@ function Component(_ref) {
|
|
|
65
67
|
createAnalyticsEvent = _useAnalyticsEventsNe.createAnalyticsEvent;
|
|
66
68
|
var _useAnalyticsEvents = (0, _useAnalyticsEvents3.useAnalyticsEvents)(),
|
|
67
69
|
fireEvent = _useAnalyticsEvents.fireEvent;
|
|
70
|
+
var hasFiredSeenRef = (0, _react.useRef)(false);
|
|
68
71
|
var isFlexibleUi = (0, _react.useMemo)(function () {
|
|
69
72
|
return (0, _flexible.isFlexibleUiCard)(children, ui);
|
|
70
73
|
}, [children, ui]);
|
|
@@ -218,6 +221,19 @@ function Component(_ref) {
|
|
|
218
221
|
});
|
|
219
222
|
}
|
|
220
223
|
}, [appearance, extensionKey, fireEvent, id, isFlexibleUi, state.status]);
|
|
224
|
+
|
|
225
|
+
// Fire smartLink seen event once on a successful render card is in the viewport
|
|
226
|
+
(0, _react.useEffect)(function () {
|
|
227
|
+
if ((0, _platformFeatureFlags.fg)('platform_sl_event_ui_seen')) {
|
|
228
|
+
if (!(0, _helpers.isFinalState)(state.status)) return;
|
|
229
|
+
if (isIntersected && !hasFiredSeenRef.current) {
|
|
230
|
+
fireEvent('ui.smartLink.seen', {
|
|
231
|
+
display: appearance
|
|
232
|
+
});
|
|
233
|
+
hasFiredSeenRef.current = true;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}, [state.status, isIntersected, fireEvent, appearance]);
|
|
221
237
|
var onIframeDwell = (0, _react.useCallback)(function (dwellTime, dwellPercentVisible) {
|
|
222
238
|
fireEvent('ui.smartLinkIframe.dwelled', {
|
|
223
239
|
id: id,
|
|
@@ -340,6 +356,7 @@ function ComponentUpdated(_ref2) {
|
|
|
340
356
|
url = _ref2.url,
|
|
341
357
|
isSelected = _ref2.isSelected,
|
|
342
358
|
isHovered = _ref2.isHovered,
|
|
359
|
+
isIntersected = _ref2.isIntersected,
|
|
343
360
|
frameStyle = _ref2.frameStyle,
|
|
344
361
|
platform = _ref2.platform,
|
|
345
362
|
onClick = _ref2.onClick,
|
|
@@ -367,6 +384,7 @@ function ComponentUpdated(_ref2) {
|
|
|
367
384
|
createAnalyticsEvent = _useAnalyticsEventsNe2.createAnalyticsEvent;
|
|
368
385
|
var _useAnalyticsEvents2 = (0, _useAnalyticsEvents3.useAnalyticsEvents)(),
|
|
369
386
|
fireEvent = _useAnalyticsEvents2.fireEvent;
|
|
387
|
+
var hasFiredSeenRef = (0, _react.useRef)(false);
|
|
370
388
|
var isFlexibleUi = (0, _react.useMemo)(function () {
|
|
371
389
|
return (0, _flexible.isFlexibleUiCard)(children, ui);
|
|
372
390
|
}, [children, ui]);
|
|
@@ -520,6 +538,19 @@ function ComponentUpdated(_ref2) {
|
|
|
520
538
|
});
|
|
521
539
|
}
|
|
522
540
|
}, [appearance, extensionKey, fireEvent, id, isFlexibleUi, state.status]);
|
|
541
|
+
|
|
542
|
+
// Fire smartLink seen event once on a successful render card is in the viewport
|
|
543
|
+
(0, _react.useEffect)(function () {
|
|
544
|
+
if ((0, _platformFeatureFlags.fg)('platform_sl_event_ui_seen')) {
|
|
545
|
+
if (!(0, _helpers.isFinalState)(state.status)) return;
|
|
546
|
+
if (isIntersected && !hasFiredSeenRef.current) {
|
|
547
|
+
fireEvent('ui.smartLink.seen', {
|
|
548
|
+
display: appearance
|
|
549
|
+
});
|
|
550
|
+
hasFiredSeenRef.current = true;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}, [state.status, isIntersected, fireEvent, appearance]);
|
|
523
554
|
var onIframeDwell = (0, _react.useCallback)(function (dwellTime, dwellPercentVisible) {
|
|
524
555
|
fireEvent('ui.smartLinkIframe.dwelled', {
|
|
525
556
|
id: id,
|
|
@@ -664,4 +695,5 @@ var CardWithUrlContent = exports.CardWithUrlContent = function CardWithUrlConten
|
|
|
664
695
|
id: props.id,
|
|
665
696
|
display: display
|
|
666
697
|
}, /*#__PURE__*/_react.default.createElement(CardWithUrlContentComponent, props)));
|
|
667
|
-
};
|
|
698
|
+
};
|
|
699
|
+
var CardWithUrl = exports.CardWithUrl = (0, _cardIntersectionObserver.default)(CardWithUrlContent);
|
|
@@ -22,7 +22,7 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId", "isLink
|
|
|
22
22
|
_excluded2 = ["isLinkSafe", "showSafetyWarningModal"];
|
|
23
23
|
var PACKAGE_DATA = {
|
|
24
24
|
packageName: "@atlaskit/smart-card",
|
|
25
|
-
packageVersion: "44.
|
|
25
|
+
packageVersion: "44.3.1",
|
|
26
26
|
componentName: 'linkUrl'
|
|
27
27
|
};
|
|
28
28
|
var Anchor = (0, _click.withLinkClickedEvent)('a');
|
package/dist/es2019/ssr.js
CHANGED
|
@@ -3,13 +3,15 @@ import { ErrorBoundary } from 'react-error-boundary';
|
|
|
3
3
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
4
4
|
import uuid from 'uuid';
|
|
5
5
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
import { context } from './utils/analytics/analytics';
|
|
7
|
-
import
|
|
8
|
+
import CardErrorBoundary from './view/CardWithUrl/card-error-boundary';
|
|
9
|
+
import { CardWithUrl, CardWithUrlContent } from './view/CardWithUrl/component';
|
|
8
10
|
import { LoadingCardLink } from './view/CardWithUrl/component-lazy/LoadingCardLink';
|
|
9
11
|
// SSR friendly version of smart-card
|
|
10
12
|
// simplifies the logic around rendering and loading placeholders and
|
|
11
13
|
// only contains whats necessary to render the card on SSR mode
|
|
12
|
-
|
|
14
|
+
const CardSSROld = props => {
|
|
13
15
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
14
16
|
const [id] = useState(() => {
|
|
15
17
|
var _props$id;
|
|
@@ -34,4 +36,28 @@ export const CardSSR = props => {
|
|
|
34
36
|
}, /*#__PURE__*/React.createElement(Component, {
|
|
35
37
|
className: "loader-wrapper"
|
|
36
38
|
}, /*#__PURE__*/React.createElement(CardWithUrlContent, cardProps))));
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// SSR friendly version of smart-card
|
|
42
|
+
// simplifies the logic around rendering and loading placeholders and
|
|
43
|
+
// only contains whats necessary to render the card on SSR mode
|
|
44
|
+
const CardSSRNew = props => {
|
|
45
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
46
|
+
const [id] = useState(() => {
|
|
47
|
+
var _props$id2;
|
|
48
|
+
return (_props$id2 = props.id) !== null && _props$id2 !== void 0 ? _props$id2 : uuid();
|
|
49
|
+
});
|
|
50
|
+
const propsWithId = {
|
|
51
|
+
...props,
|
|
52
|
+
id
|
|
53
|
+
};
|
|
54
|
+
return /*#__PURE__*/React.createElement(AnalyticsContext, {
|
|
55
|
+
data: context
|
|
56
|
+
}, /*#__PURE__*/React.createElement(CardErrorBoundary, propsWithId, /*#__PURE__*/React.createElement(CardWithUrl, propsWithId)));
|
|
57
|
+
};
|
|
58
|
+
export const CardSSR = props => {
|
|
59
|
+
if (fg('platform_sl_event_ui_seen')) {
|
|
60
|
+
return /*#__PURE__*/React.createElement(CardSSRNew, props);
|
|
61
|
+
}
|
|
62
|
+
return /*#__PURE__*/React.createElement(CardSSROld, props);
|
|
37
63
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useCallback, useMemo } from 'react';
|
|
2
2
|
import { request } from '@atlaskit/linking-common';
|
|
3
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
import { queryIncomingOutgoingLinks as queryIncomingOutgoingAris } from './query';
|
|
5
4
|
/**
|
|
6
5
|
* @param baseUriWithNoTrailingSlash base url which will then be appended with /gateway/api/graphql to make requests to AGG
|
|
@@ -45,19 +44,16 @@ const useIncomingOutgoingAri = (baseUriWithNoTrailingSlash = '') => {
|
|
|
45
44
|
*/
|
|
46
45
|
async (ari, firstIncoming = 50, firstOutgoing = 50) => {
|
|
47
46
|
var _response$data$graphS, _response$data, _response$data$graphS2, _response$data$graphS3, _response$data$graphS4, _response$data$graphS5, _response$data$graphS6, _response$data2, _response$data2$graph, _response$data2$graph2, _response$data2$graph3, _response$data2$graph4;
|
|
48
|
-
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
incomingAris: [],
|
|
54
|
-
outgoingAris: []
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
headers = {
|
|
58
|
-
'X-Query-Context': `ari:cloud:platform::site/${siteId}`
|
|
47
|
+
const siteId = await getSiteId(ari);
|
|
48
|
+
if (!siteId) {
|
|
49
|
+
return {
|
|
50
|
+
incomingAris: [],
|
|
51
|
+
outgoingAris: []
|
|
59
52
|
};
|
|
60
53
|
}
|
|
54
|
+
const headers = {
|
|
55
|
+
'X-Query-Context': `ari:cloud:platform::site/${siteId}`
|
|
56
|
+
};
|
|
61
57
|
const response = await aggRequestCall({
|
|
62
58
|
variables: {
|
|
63
59
|
id: ari,
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
// This property enables the intersection observer to be run once the
|
|
4
|
+
// HTML element being observed is within `X` px of the target container it is
|
|
5
|
+
// being compared to. Since the default container is the `document`, we set this
|
|
6
|
+
// up to check once a Smart Link is within `X` px from the bottom of the viewport.
|
|
7
|
+
const ROOT_MARGIN_VERTICAL = '360px';
|
|
8
|
+
const useIntersectionObserver = ({
|
|
9
|
+
onIntersecting: onIntersectingCallback,
|
|
10
|
+
onIntersection: onIntersectionCallback
|
|
11
|
+
}) => {
|
|
12
|
+
const ref = useRef(null);
|
|
13
|
+
const onIntersectingCallbackRef = useRef(onIntersectingCallback);
|
|
14
|
+
const onIntersectionCallbackRef = useRef(onIntersectionCallback);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
onIntersectingCallbackRef.current = onIntersectingCallback;
|
|
17
|
+
onIntersectionCallbackRef.current = onIntersectionCallback;
|
|
18
|
+
}, [onIntersectingCallback, onIntersectionCallback]);
|
|
19
|
+
const onIntersection = useCallback((entries, observer) => {
|
|
20
|
+
var _onIntersectionCallba;
|
|
21
|
+
const isIntersecting = entries.some(entry => entry.isIntersecting);
|
|
22
|
+
(_onIntersectionCallba = onIntersectionCallbackRef.current) === null || _onIntersectionCallba === void 0 ? void 0 : _onIntersectionCallba.call(onIntersectionCallbackRef, isIntersecting);
|
|
23
|
+
if (isIntersecting) {
|
|
24
|
+
var _onIntersectingCallba;
|
|
25
|
+
(_onIntersectingCallba = onIntersectingCallbackRef.current) === null || _onIntersectingCallba === void 0 ? void 0 : _onIntersectingCallba.call(onIntersectingCallbackRef);
|
|
26
|
+
observer.disconnect();
|
|
27
|
+
}
|
|
28
|
+
}, []);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (!ref.current) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const intersectionObserver = new IntersectionObserver(onIntersection, {
|
|
34
|
+
rootMargin: `${ROOT_MARGIN_VERTICAL} 0px ${ROOT_MARGIN_VERTICAL} 0px`
|
|
35
|
+
});
|
|
36
|
+
intersectionObserver.observe(ref.current);
|
|
37
|
+
return () => intersectionObserver.disconnect();
|
|
38
|
+
}, [ref, onIntersection]);
|
|
39
|
+
return ref;
|
|
40
|
+
};
|
|
41
|
+
export default useIntersectionObserver;
|
|
@@ -2,7 +2,7 @@ export const ANALYTICS_CHANNEL = 'media';
|
|
|
2
2
|
export const context = {
|
|
3
3
|
componentName: 'smart-cards',
|
|
4
4
|
packageName: "@atlaskit/smart-card",
|
|
5
|
-
packageVersion: "44.
|
|
5
|
+
packageVersion: "44.3.1"
|
|
6
6
|
};
|
|
7
7
|
export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
8
8
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ErrorBoundary } from 'react-error-boundary';
|
|
3
|
+
import { LoadingCardLink } from '../component-lazy/LoadingCardLink';
|
|
4
|
+
const CardErrorBoundary = ({
|
|
5
|
+
children,
|
|
6
|
+
...props
|
|
7
|
+
}) => {
|
|
8
|
+
// TODO: NAVX-4682: Add feature parity to CardWithURLRenderer
|
|
9
|
+
const ErrorFallbackComponent = props.fallbackComponent;
|
|
10
|
+
const errorBoundaryFallbackComponent = () => {
|
|
11
|
+
if (ErrorFallbackComponent) {
|
|
12
|
+
return /*#__PURE__*/React.createElement(ErrorFallbackComponent, null);
|
|
13
|
+
}
|
|
14
|
+
return /*#__PURE__*/React.createElement(LoadingCardLink, props);
|
|
15
|
+
};
|
|
16
|
+
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
17
|
+
FallbackComponent: errorBoundaryFallbackComponent
|
|
18
|
+
}, children);
|
|
19
|
+
};
|
|
20
|
+
export default CardErrorBoundary;
|