@atlaskit/smart-card 26.48.0 → 26.48.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 +6 -0
- package/dist/cjs/utils/analytics/analytics.js +1 -1
- package/dist/cjs/view/CardWithUrl/component-lazy/LazyIntersectionObserverCard.js +51 -3
- package/dist/cjs/view/LinkUrl/index.js +1 -1
- package/dist/es2019/utils/analytics/analytics.js +1 -1
- package/dist/es2019/view/CardWithUrl/component-lazy/LazyIntersectionObserverCard.js +46 -3
- package/dist/es2019/view/LinkUrl/index.js +1 -1
- package/dist/esm/utils/analytics/analytics.js +1 -1
- package/dist/esm/view/CardWithUrl/component-lazy/LazyIntersectionObserverCard.js +51 -3
- package/dist/esm/view/LinkUrl/index.js +1 -1
- package/dist/types/view/CardWithUrl/component-lazy/LazyIntersectionObserverCard.d.ts +4 -1
- package/dist/types-ts4.5/view/CardWithUrl/component-lazy/LazyIntersectionObserverCard.d.ts +4 -1
- package/package.json +6 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/smart-card
|
|
2
2
|
|
|
3
|
+
## 26.48.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#75710](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/75710) [`48a473f02139`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/48a473f02139) - Fixes intersection observer not being disconnected when component not intersecting, behind ff platform.linking-platform.smart-card.fix-intersection-observer
|
|
8
|
+
|
|
3
9
|
## 26.48.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -22,7 +22,7 @@ var ANALYTICS_CHANNEL = exports.ANALYTICS_CHANNEL = 'media';
|
|
|
22
22
|
var context = exports.context = {
|
|
23
23
|
componentName: 'smart-cards',
|
|
24
24
|
packageName: "@atlaskit/smart-card",
|
|
25
|
-
packageVersion: "26.48.
|
|
25
|
+
packageVersion: "26.48.1"
|
|
26
26
|
};
|
|
27
27
|
var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
28
28
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -5,9 +5,10 @@ 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
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
12
|
var _state = require("../../../state");
|
|
12
13
|
var _component = require("../component");
|
|
13
14
|
var _LoadingCardLink = require("./LoadingCardLink");
|
|
@@ -19,7 +20,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
19
20
|
// being compared to. Since the default container is the `document`, we set this
|
|
20
21
|
// up to check once a Smart Link is within `X` px from the bottom of the viewport.
|
|
21
22
|
var ROOT_MARGIN_VERTICAL = '360px';
|
|
22
|
-
function
|
|
23
|
+
function LazyIntersectionObserverCardLegacy(props) {
|
|
23
24
|
var _useState = (0, _react.useState)(false),
|
|
24
25
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
25
26
|
isIntersecting = _useState2[0],
|
|
@@ -60,4 +61,51 @@ function LazyIntersectionObserverCard(props) {
|
|
|
60
61
|
return /*#__PURE__*/_react.default.createElement(Component, {
|
|
61
62
|
className: "loader-wrapper"
|
|
62
63
|
}, content);
|
|
63
|
-
}
|
|
64
|
+
}
|
|
65
|
+
function LazyIntersectionObserverCardNext(props) {
|
|
66
|
+
var ref = (0, _react.useRef)(null);
|
|
67
|
+
var _useState3 = (0, _react.useState)(false),
|
|
68
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
69
|
+
isIntersecting = _useState4[0],
|
|
70
|
+
setIsIntersecting = _useState4[1];
|
|
71
|
+
var appearance = props.appearance,
|
|
72
|
+
url = props.url,
|
|
73
|
+
id = props.id;
|
|
74
|
+
var prefetch = (0, _state.usePrefetch)(url);
|
|
75
|
+
var Component = appearance === 'inline' ? 'span' : 'div';
|
|
76
|
+
var ComponentObserver = Component;
|
|
77
|
+
var onIntersection = (0, _react.useCallback)(function (entries, observer) {
|
|
78
|
+
var isVisible = entries.some(function (entry) {
|
|
79
|
+
return entry.isIntersecting;
|
|
80
|
+
});
|
|
81
|
+
if (isVisible) {
|
|
82
|
+
(0, _ufoExperiences.startUfoExperience)('smart-link-rendered', id);
|
|
83
|
+
setIsIntersecting(true);
|
|
84
|
+
observer.disconnect();
|
|
85
|
+
} else {
|
|
86
|
+
prefetch();
|
|
87
|
+
}
|
|
88
|
+
}, [prefetch, id]);
|
|
89
|
+
(0, _react.useEffect)(function () {
|
|
90
|
+
if (!ref.current) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
var intersectionObserver = new IntersectionObserver(onIntersection, {
|
|
94
|
+
rootMargin: "".concat(ROOT_MARGIN_VERTICAL, " 0px ").concat(ROOT_MARGIN_VERTICAL, " 0px")
|
|
95
|
+
});
|
|
96
|
+
intersectionObserver.observe(ref.current);
|
|
97
|
+
return function () {
|
|
98
|
+
return intersectionObserver.disconnect();
|
|
99
|
+
};
|
|
100
|
+
}, [ref, onIntersection]);
|
|
101
|
+
var content = isIntersecting ? /*#__PURE__*/_react.default.createElement(_component.CardWithUrlContent, props) : /*#__PURE__*/_react.default.createElement(ComponentObserver, {
|
|
102
|
+
ref: ref
|
|
103
|
+
}, /*#__PURE__*/_react.default.createElement(_LoadingCardLink.LoadingCardLink, props));
|
|
104
|
+
return /*#__PURE__*/_react.default.createElement(Component, {
|
|
105
|
+
className: "loader-wrapper"
|
|
106
|
+
}, content);
|
|
107
|
+
}
|
|
108
|
+
var LazyIntersectionObserverCard = exports.LazyIntersectionObserverCard = function LazyIntersectionObserverCard(props) {
|
|
109
|
+
var Component = (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.fix-intersection-observer') ? LazyIntersectionObserverCardNext : LazyIntersectionObserverCardLegacy;
|
|
110
|
+
return /*#__PURE__*/_react.default.createElement(Component, props);
|
|
111
|
+
};
|
|
@@ -17,7 +17,7 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId"],
|
|
|
17
17
|
_excluded2 = ["isLinkSafe", "showSafetyWarningModal"];
|
|
18
18
|
var PACKAGE_DATA = {
|
|
19
19
|
packageName: "@atlaskit/smart-card",
|
|
20
|
-
packageVersion: "26.48.
|
|
20
|
+
packageVersion: "26.48.1",
|
|
21
21
|
componentName: 'linkUrl'
|
|
22
22
|
};
|
|
23
23
|
var Link = (0, _click.withLinkClickedEvent)('a');
|
|
@@ -4,7 +4,7 @@ export const ANALYTICS_CHANNEL = 'media';
|
|
|
4
4
|
export const context = {
|
|
5
5
|
componentName: 'smart-cards',
|
|
6
6
|
packageName: "@atlaskit/smart-card",
|
|
7
|
-
packageVersion: "26.48.
|
|
7
|
+
packageVersion: "26.48.1"
|
|
8
8
|
};
|
|
9
9
|
export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
10
10
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import React, { useCallback, useState } from 'react';
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
import { usePrefetch } from '../../../state';
|
|
3
4
|
import { CardWithUrlContent } from '../component';
|
|
4
5
|
import { LoadingCardLink } from './LoadingCardLink';
|
|
@@ -9,7 +10,7 @@ import { startUfoExperience } from '../../../state/analytics/ufoExperiences';
|
|
|
9
10
|
// being compared to. Since the default container is the `document`, we set this
|
|
10
11
|
// up to check once a Smart Link is within `X` px from the bottom of the viewport.
|
|
11
12
|
const ROOT_MARGIN_VERTICAL = '360px';
|
|
12
|
-
|
|
13
|
+
function LazyIntersectionObserverCardLegacy(props) {
|
|
13
14
|
const [isIntersecting, setIsIntersecting] = useState(false);
|
|
14
15
|
const {
|
|
15
16
|
appearance,
|
|
@@ -45,4 +46,46 @@ export function LazyIntersectionObserverCard(props) {
|
|
|
45
46
|
return /*#__PURE__*/React.createElement(Component, {
|
|
46
47
|
className: "loader-wrapper"
|
|
47
48
|
}, content);
|
|
48
|
-
}
|
|
49
|
+
}
|
|
50
|
+
function LazyIntersectionObserverCardNext(props) {
|
|
51
|
+
const ref = useRef(null);
|
|
52
|
+
const [isIntersecting, setIsIntersecting] = useState(false);
|
|
53
|
+
const {
|
|
54
|
+
appearance,
|
|
55
|
+
url,
|
|
56
|
+
id
|
|
57
|
+
} = props;
|
|
58
|
+
const prefetch = usePrefetch(url);
|
|
59
|
+
const Component = appearance === 'inline' ? 'span' : 'div';
|
|
60
|
+
const ComponentObserver = Component;
|
|
61
|
+
const onIntersection = useCallback((entries, observer) => {
|
|
62
|
+
const isVisible = entries.some(entry => entry.isIntersecting);
|
|
63
|
+
if (isVisible) {
|
|
64
|
+
startUfoExperience('smart-link-rendered', id);
|
|
65
|
+
setIsIntersecting(true);
|
|
66
|
+
observer.disconnect();
|
|
67
|
+
} else {
|
|
68
|
+
prefetch();
|
|
69
|
+
}
|
|
70
|
+
}, [prefetch, id]);
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (!ref.current) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const intersectionObserver = new IntersectionObserver(onIntersection, {
|
|
76
|
+
rootMargin: `${ROOT_MARGIN_VERTICAL} 0px ${ROOT_MARGIN_VERTICAL} 0px`
|
|
77
|
+
});
|
|
78
|
+
intersectionObserver.observe(ref.current);
|
|
79
|
+
return () => intersectionObserver.disconnect();
|
|
80
|
+
}, [ref, onIntersection]);
|
|
81
|
+
const content = isIntersecting ? /*#__PURE__*/React.createElement(CardWithUrlContent, props) : /*#__PURE__*/React.createElement(ComponentObserver, {
|
|
82
|
+
ref: ref
|
|
83
|
+
}, /*#__PURE__*/React.createElement(LoadingCardLink, props));
|
|
84
|
+
return /*#__PURE__*/React.createElement(Component, {
|
|
85
|
+
className: "loader-wrapper"
|
|
86
|
+
}, content);
|
|
87
|
+
}
|
|
88
|
+
export const LazyIntersectionObserverCard = props => {
|
|
89
|
+
const Component = getBooleanFF('platform.linking-platform.smart-card.fix-intersection-observer') ? LazyIntersectionObserverCardNext : LazyIntersectionObserverCardLegacy;
|
|
90
|
+
return /*#__PURE__*/React.createElement(Component, props);
|
|
91
|
+
};
|
|
@@ -7,7 +7,7 @@ import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-m
|
|
|
7
7
|
import LinkWarningModal from './LinkWarningModal';
|
|
8
8
|
const PACKAGE_DATA = {
|
|
9
9
|
packageName: "@atlaskit/smart-card",
|
|
10
|
-
packageVersion: "26.48.
|
|
10
|
+
packageVersion: "26.48.1",
|
|
11
11
|
componentName: 'linkUrl'
|
|
12
12
|
};
|
|
13
13
|
const Link = withLinkClickedEvent('a');
|
|
@@ -15,7 +15,7 @@ export var ANALYTICS_CHANNEL = 'media';
|
|
|
15
15
|
export var context = {
|
|
16
16
|
componentName: 'smart-cards',
|
|
17
17
|
packageName: "@atlaskit/smart-card",
|
|
18
|
-
packageVersion: "26.48.
|
|
18
|
+
packageVersion: "26.48.1"
|
|
19
19
|
};
|
|
20
20
|
export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
21
21
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import React, { useCallback, useState } from 'react';
|
|
2
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
3
4
|
import { usePrefetch } from '../../../state';
|
|
4
5
|
import { CardWithUrlContent } from '../component';
|
|
5
6
|
import { LoadingCardLink } from './LoadingCardLink';
|
|
@@ -10,7 +11,7 @@ import { startUfoExperience } from '../../../state/analytics/ufoExperiences';
|
|
|
10
11
|
// being compared to. Since the default container is the `document`, we set this
|
|
11
12
|
// up to check once a Smart Link is within `X` px from the bottom of the viewport.
|
|
12
13
|
var ROOT_MARGIN_VERTICAL = '360px';
|
|
13
|
-
|
|
14
|
+
function LazyIntersectionObserverCardLegacy(props) {
|
|
14
15
|
var _useState = useState(false),
|
|
15
16
|
_useState2 = _slicedToArray(_useState, 2),
|
|
16
17
|
isIntersecting = _useState2[0],
|
|
@@ -51,4 +52,51 @@ export function LazyIntersectionObserverCard(props) {
|
|
|
51
52
|
return /*#__PURE__*/React.createElement(Component, {
|
|
52
53
|
className: "loader-wrapper"
|
|
53
54
|
}, content);
|
|
54
|
-
}
|
|
55
|
+
}
|
|
56
|
+
function LazyIntersectionObserverCardNext(props) {
|
|
57
|
+
var ref = useRef(null);
|
|
58
|
+
var _useState3 = useState(false),
|
|
59
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
60
|
+
isIntersecting = _useState4[0],
|
|
61
|
+
setIsIntersecting = _useState4[1];
|
|
62
|
+
var appearance = props.appearance,
|
|
63
|
+
url = props.url,
|
|
64
|
+
id = props.id;
|
|
65
|
+
var prefetch = usePrefetch(url);
|
|
66
|
+
var Component = appearance === 'inline' ? 'span' : 'div';
|
|
67
|
+
var ComponentObserver = Component;
|
|
68
|
+
var onIntersection = useCallback(function (entries, observer) {
|
|
69
|
+
var isVisible = entries.some(function (entry) {
|
|
70
|
+
return entry.isIntersecting;
|
|
71
|
+
});
|
|
72
|
+
if (isVisible) {
|
|
73
|
+
startUfoExperience('smart-link-rendered', id);
|
|
74
|
+
setIsIntersecting(true);
|
|
75
|
+
observer.disconnect();
|
|
76
|
+
} else {
|
|
77
|
+
prefetch();
|
|
78
|
+
}
|
|
79
|
+
}, [prefetch, id]);
|
|
80
|
+
useEffect(function () {
|
|
81
|
+
if (!ref.current) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
var intersectionObserver = new IntersectionObserver(onIntersection, {
|
|
85
|
+
rootMargin: "".concat(ROOT_MARGIN_VERTICAL, " 0px ").concat(ROOT_MARGIN_VERTICAL, " 0px")
|
|
86
|
+
});
|
|
87
|
+
intersectionObserver.observe(ref.current);
|
|
88
|
+
return function () {
|
|
89
|
+
return intersectionObserver.disconnect();
|
|
90
|
+
};
|
|
91
|
+
}, [ref, onIntersection]);
|
|
92
|
+
var content = isIntersecting ? /*#__PURE__*/React.createElement(CardWithUrlContent, props) : /*#__PURE__*/React.createElement(ComponentObserver, {
|
|
93
|
+
ref: ref
|
|
94
|
+
}, /*#__PURE__*/React.createElement(LoadingCardLink, props));
|
|
95
|
+
return /*#__PURE__*/React.createElement(Component, {
|
|
96
|
+
className: "loader-wrapper"
|
|
97
|
+
}, content);
|
|
98
|
+
}
|
|
99
|
+
export var LazyIntersectionObserverCard = function LazyIntersectionObserverCard(props) {
|
|
100
|
+
var Component = getBooleanFF('platform.linking-platform.smart-card.fix-intersection-observer') ? LazyIntersectionObserverCardNext : LazyIntersectionObserverCardLegacy;
|
|
101
|
+
return /*#__PURE__*/React.createElement(Component, props);
|
|
102
|
+
};
|
|
@@ -10,7 +10,7 @@ import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-m
|
|
|
10
10
|
import LinkWarningModal from './LinkWarningModal';
|
|
11
11
|
var PACKAGE_DATA = {
|
|
12
12
|
packageName: "@atlaskit/smart-card",
|
|
13
|
-
packageVersion: "26.48.
|
|
13
|
+
packageVersion: "26.48.1",
|
|
14
14
|
componentName: 'linkUrl'
|
|
15
15
|
};
|
|
16
16
|
var Link = withLinkClickedEvent('a');
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CardWithUrlContentProps } from '../types';
|
|
3
|
-
|
|
3
|
+
declare function LazyIntersectionObserverCardLegacy(props: CardWithUrlContentProps): JSX.Element;
|
|
4
|
+
declare function LazyIntersectionObserverCardNext(props: CardWithUrlContentProps): JSX.Element;
|
|
5
|
+
export declare const LazyIntersectionObserverCard: typeof LazyIntersectionObserverCardNext | typeof LazyIntersectionObserverCardLegacy;
|
|
6
|
+
export {};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CardWithUrlContentProps } from '../types';
|
|
3
|
-
|
|
3
|
+
declare function LazyIntersectionObserverCardLegacy(props: CardWithUrlContentProps): JSX.Element;
|
|
4
|
+
declare function LazyIntersectionObserverCardNext(props: CardWithUrlContentProps): JSX.Element;
|
|
5
|
+
export declare const LazyIntersectionObserverCard: typeof LazyIntersectionObserverCardNext | typeof LazyIntersectionObserverCardLegacy;
|
|
6
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/smart-card",
|
|
3
|
-
"version": "26.48.
|
|
3
|
+
"version": "26.48.1",
|
|
4
4
|
"description": "Smart card component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -77,11 +77,13 @@
|
|
|
77
77
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
|
+
"@af/integration-testing": "*",
|
|
80
81
|
"@af/visual-regression": "*",
|
|
81
82
|
"@atlaskit/analytics-listeners": "^8.9.0",
|
|
82
83
|
"@atlaskit/css-reset": "^6.6.0",
|
|
83
84
|
"@atlaskit/link-test-helpers": "^6.2.0",
|
|
84
85
|
"@atlaskit/media-test-helpers": "^33.0.0",
|
|
86
|
+
"@atlaskit/ssr": "*",
|
|
85
87
|
"@atlaskit/visual-regression": "*",
|
|
86
88
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
87
89
|
"@atlassian/feature-flags-test-utils": "^0.2.0",
|
|
@@ -153,6 +155,9 @@
|
|
|
153
155
|
},
|
|
154
156
|
"platform.linking-platform.smart-card.hover-card-ai-summaries": {
|
|
155
157
|
"type": "boolean"
|
|
158
|
+
},
|
|
159
|
+
"platform.linking-platform.smart-card.fix-intersection-observer": {
|
|
160
|
+
"type": "boolean"
|
|
156
161
|
}
|
|
157
162
|
},
|
|
158
163
|
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
|