@atlaskit/smart-card 26.48.0 → 26.48.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 +12 -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/FlexibleCard/components/blocks/action-group/index.js +10 -3
- package/dist/cjs/view/FlexibleCard/components/blocks/title-block/index.js +9 -4
- 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/FlexibleCard/components/blocks/action-group/index.js +8 -14
- package/dist/es2019/view/FlexibleCard/components/blocks/title-block/index.js +8 -12
- 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/FlexibleCard/components/blocks/action-group/index.js +10 -3
- package/dist/esm/view/FlexibleCard/components/blocks/title-block/index.js +9 -4
- package/dist/esm/view/LinkUrl/index.js +1 -1
- package/dist/types/state/hooks/use-related-urls/index.d.ts +1 -1
- package/dist/types/view/CardWithUrl/component-lazy/LazyIntersectionObserverCard.d.ts +4 -1
- package/dist/types-ts4.5/state/hooks/use-related-urls/index.d.ts +1 -1
- package/dist/types-ts4.5/view/CardWithUrl/component-lazy/LazyIntersectionObserverCard.d.ts +4 -1
- package/package.json +8 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/smart-card
|
|
2
2
|
|
|
3
|
+
## 26.48.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 26.48.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#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
|
|
14
|
+
|
|
3
15
|
## 26.48.0
|
|
4
16
|
|
|
5
17
|
### 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.2"
|
|
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
|
+
};
|
|
@@ -8,7 +8,6 @@ exports.default = void 0;
|
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
-
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
12
11
|
var _react = require("react");
|
|
13
12
|
var _reactIntlNext = require("react-intl-next");
|
|
14
13
|
var _react2 = require("@emotion/react");
|
|
@@ -25,9 +24,17 @@ var _actionGroupItem = _interopRequireDefault(require("./action-group-item"));
|
|
|
25
24
|
var _utils2 = require("../utils");
|
|
26
25
|
var _reactMagneticDi = require("react-magnetic-di");
|
|
27
26
|
var _excluded = ["triggerRef"];
|
|
28
|
-
var _templateObject;
|
|
29
27
|
/** @jsx jsx */
|
|
30
|
-
var styles = (0, _react2.css)(
|
|
28
|
+
var styles = (0, _react2.css)({
|
|
29
|
+
display: 'inline-flex',
|
|
30
|
+
lineHeight: '1rem',
|
|
31
|
+
'> div': {
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
'button:focus-visible': {
|
|
34
|
+
outlineOffset: '-2px'
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
});
|
|
31
38
|
var renderActionItems = function renderActionItems() {
|
|
32
39
|
var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
33
40
|
var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _constants.SmartLinkSize.Medium;
|
|
@@ -9,7 +9,6 @@ exports.default = void 0;
|
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
11
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
12
|
-
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
13
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
14
13
|
var _react2 = require("@emotion/react");
|
|
15
14
|
var _useLinkClicked = require("../../../../../state/analytics/useLinkClicked");
|
|
@@ -20,12 +19,18 @@ var _resolving = _interopRequireDefault(require("./resolving"));
|
|
|
20
19
|
var _actionGroup = _interopRequireDefault(require("../action-group"));
|
|
21
20
|
var _elements = require("../../elements");
|
|
22
21
|
var _excluded = ["actions", "anchorTarget", "hideTitleTooltip", "maxLines", "onActionMenuOpenChange", "onClick", "overrideCss", "status", "showActionOnHover", "testId", "text", "theme", "hideRetry", "metadataPosition", "hideIcon"];
|
|
23
|
-
var _templateObject, _templateObject2;
|
|
24
22
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
23
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
26
24
|
var getActionStyles = function getActionStyles(showOnHover, isOpen) {
|
|
27
25
|
if (showOnHover && !isOpen) {
|
|
28
|
-
return (0, _react2.css)(
|
|
26
|
+
return (0, _react2.css)({
|
|
27
|
+
'.actions-button-group': {
|
|
28
|
+
opacity: 0
|
|
29
|
+
},
|
|
30
|
+
'&:hover .actions-button-group, .actions-button-group:focus-within': {
|
|
31
|
+
opacity: 1
|
|
32
|
+
}
|
|
33
|
+
});
|
|
29
34
|
}
|
|
30
35
|
};
|
|
31
36
|
var getTitleBlockViewComponent = function getTitleBlockViewComponent(status) {
|
|
@@ -99,7 +104,7 @@ var TitleBlock = function TitleBlock(_ref) {
|
|
|
99
104
|
onDropdownOpenChange: onDropdownOpenChange
|
|
100
105
|
});
|
|
101
106
|
var actionStyles = getActionStyles(showActionOnHover, actionDropdownOpen);
|
|
102
|
-
var combinedCss = (0, _react2.css)(
|
|
107
|
+
var combinedCss = (0, _react2.css)(actionStyles, overrideCss);
|
|
103
108
|
var overrideText = !!text ? {
|
|
104
109
|
text: text
|
|
105
110
|
} : {};
|
|
@@ -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.2",
|
|
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.2"
|
|
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
|
+
};
|
|
@@ -15,22 +15,16 @@ import { useFlexibleUiContext, useFlexibleUiOptionContext } from '../../../../..
|
|
|
15
15
|
import ActionGroupItem from './action-group-item';
|
|
16
16
|
import { filterActionItems } from '../utils';
|
|
17
17
|
import { di } from 'react-magnetic-di';
|
|
18
|
-
const styles = css
|
|
19
|
-
display: inline-flex
|
|
20
|
-
|
|
21
|
-
> div {
|
|
22
|
-
|
|
23
|
-
button:focus-visible {
|
|
24
|
-
|
|
25
|
-
// box-shadow styling to create the outline appearance.
|
|
26
|
-
// Due to our container elements (Container/Block/ElementGroup) has
|
|
27
|
-
// overflow hidden to prevent the metadata element from leaking outside
|
|
28
|
-
// of its container, the box-shadow doesn't show properly.
|
|
29
|
-
// Invert the AK box-shadow styling.
|
|
30
|
-
outline-offset: -2px;
|
|
18
|
+
const styles = css({
|
|
19
|
+
display: 'inline-flex',
|
|
20
|
+
lineHeight: '1rem',
|
|
21
|
+
'> div': {
|
|
22
|
+
alignItems: 'center',
|
|
23
|
+
'button:focus-visible': {
|
|
24
|
+
outlineOffset: '-2px'
|
|
31
25
|
}
|
|
32
26
|
}
|
|
33
|
-
|
|
27
|
+
});
|
|
34
28
|
const renderActionItems = (items = [], size = SmartLinkSize.Medium, appearance, asDropDownItems, onActionItemClick) => items.map((item, idx) => jsx(ActionGroupItem, {
|
|
35
29
|
item: item,
|
|
36
30
|
key: idx,
|
|
@@ -10,16 +10,14 @@ import ActionGroup from '../action-group';
|
|
|
10
10
|
import { Title } from '../../elements';
|
|
11
11
|
const getActionStyles = (showOnHover, isOpen) => {
|
|
12
12
|
if (showOnHover && !isOpen) {
|
|
13
|
-
return css
|
|
14
|
-
.actions-button-group {
|
|
15
|
-
opacity: 0
|
|
13
|
+
return css({
|
|
14
|
+
'.actions-button-group': {
|
|
15
|
+
opacity: 0
|
|
16
|
+
},
|
|
17
|
+
'&:hover .actions-button-group, .actions-button-group:focus-within': {
|
|
18
|
+
opacity: 1
|
|
16
19
|
}
|
|
17
|
-
|
|
18
|
-
&:hover .actions-button-group,
|
|
19
|
-
.actions-button-group:focus-within {
|
|
20
|
-
opacity: 1;
|
|
21
|
-
}
|
|
22
|
-
`;
|
|
20
|
+
});
|
|
23
21
|
}
|
|
24
22
|
};
|
|
25
23
|
const getTitleBlockViewComponent = status => {
|
|
@@ -87,9 +85,7 @@ const TitleBlock = ({
|
|
|
87
85
|
onDropdownOpenChange: onDropdownOpenChange
|
|
88
86
|
});
|
|
89
87
|
const actionStyles = getActionStyles(showActionOnHover, actionDropdownOpen);
|
|
90
|
-
const combinedCss = css
|
|
91
|
-
${actionStyles} ${overrideCss}
|
|
92
|
-
`;
|
|
88
|
+
const combinedCss = css(actionStyles, overrideCss);
|
|
93
89
|
const overrideText = !!text ? {
|
|
94
90
|
text
|
|
95
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.2",
|
|
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.2"
|
|
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
|
+
};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
-
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
5
4
|
var _excluded = ["triggerRef"];
|
|
6
|
-
var _templateObject;
|
|
7
5
|
/** @jsx jsx */
|
|
8
6
|
import { useCallback, useMemo, useState } from 'react';
|
|
9
7
|
import { FormattedMessage } from 'react-intl-next';
|
|
@@ -20,7 +18,16 @@ import { useFlexibleUiContext, useFlexibleUiOptionContext } from '../../../../..
|
|
|
20
18
|
import ActionGroupItem from './action-group-item';
|
|
21
19
|
import { filterActionItems } from '../utils';
|
|
22
20
|
import { di } from 'react-magnetic-di';
|
|
23
|
-
var styles = css(
|
|
21
|
+
var styles = css({
|
|
22
|
+
display: 'inline-flex',
|
|
23
|
+
lineHeight: '1rem',
|
|
24
|
+
'> div': {
|
|
25
|
+
alignItems: 'center',
|
|
26
|
+
'button:focus-visible': {
|
|
27
|
+
outlineOffset: '-2px'
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
24
31
|
var renderActionItems = function renderActionItems() {
|
|
25
32
|
var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
26
33
|
var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : SmartLinkSize.Medium;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
5
4
|
var _excluded = ["actions", "anchorTarget", "hideTitleTooltip", "maxLines", "onActionMenuOpenChange", "onClick", "overrideCss", "status", "showActionOnHover", "testId", "text", "theme", "hideRetry", "metadataPosition", "hideIcon"];
|
|
6
|
-
var _templateObject, _templateObject2;
|
|
7
5
|
import React, { useCallback, useState } from 'react';
|
|
8
6
|
import { css } from '@emotion/react';
|
|
9
7
|
import { useMouseDownEvent } from '../../../../../state/analytics/useLinkClicked';
|
|
@@ -15,7 +13,14 @@ import ActionGroup from '../action-group';
|
|
|
15
13
|
import { Title } from '../../elements';
|
|
16
14
|
var getActionStyles = function getActionStyles(showOnHover, isOpen) {
|
|
17
15
|
if (showOnHover && !isOpen) {
|
|
18
|
-
return css(
|
|
16
|
+
return css({
|
|
17
|
+
'.actions-button-group': {
|
|
18
|
+
opacity: 0
|
|
19
|
+
},
|
|
20
|
+
'&:hover .actions-button-group, .actions-button-group:focus-within': {
|
|
21
|
+
opacity: 1
|
|
22
|
+
}
|
|
23
|
+
});
|
|
19
24
|
}
|
|
20
25
|
};
|
|
21
26
|
var getTitleBlockViewComponent = function getTitleBlockViewComponent(status) {
|
|
@@ -89,7 +94,7 @@ var TitleBlock = function TitleBlock(_ref) {
|
|
|
89
94
|
onDropdownOpenChange: onDropdownOpenChange
|
|
90
95
|
});
|
|
91
96
|
var actionStyles = getActionStyles(showActionOnHover, actionDropdownOpen);
|
|
92
|
-
var combinedCss = css(
|
|
97
|
+
var combinedCss = css(actionStyles, overrideCss);
|
|
93
98
|
var overrideText = !!text ? {
|
|
94
99
|
text: text
|
|
95
100
|
} : {};
|
|
@@ -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.2",
|
|
14
14
|
componentName: 'linkUrl'
|
|
15
15
|
};
|
|
16
16
|
var Link = withLinkClickedEvent('a');
|
|
@@ -2,5 +2,5 @@ import { JsonLd } from 'json-ld-types';
|
|
|
2
2
|
export type RelatedUrlsResponse = {
|
|
3
3
|
resolvedResults?: JsonLd.Response[];
|
|
4
4
|
};
|
|
5
|
-
declare const useRelatedUrls: () => (url:
|
|
5
|
+
declare const useRelatedUrls: () => (url: string) => Promise<RelatedUrlsResponse>;
|
|
6
6
|
export default useRelatedUrls;
|
|
@@ -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 {};
|
|
@@ -2,5 +2,5 @@ import { JsonLd } from 'json-ld-types';
|
|
|
2
2
|
export type RelatedUrlsResponse = {
|
|
3
3
|
resolvedResults?: JsonLd.Response[];
|
|
4
4
|
};
|
|
5
|
-
declare const useRelatedUrls: () => (url:
|
|
5
|
+
declare const useRelatedUrls: () => (url: string) => Promise<RelatedUrlsResponse>;
|
|
6
6
|
export default useRelatedUrls;
|
|
@@ -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.2",
|
|
4
4
|
"description": "Smart card component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@atlaskit/avatar": "^21.5.0",
|
|
31
31
|
"@atlaskit/avatar-group": "^9.5.0",
|
|
32
32
|
"@atlaskit/badge": "^15.2.0",
|
|
33
|
-
"@atlaskit/button": "^17.
|
|
33
|
+
"@atlaskit/button": "^17.6.0",
|
|
34
34
|
"@atlaskit/dropdown-menu": "^12.5.0",
|
|
35
35
|
"@atlaskit/icon": "^22.1.0",
|
|
36
36
|
"@atlaskit/icon-file-type": "^6.4.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@atlaskit/outbound-auth-flow-client": "^3.4.0",
|
|
49
49
|
"@atlaskit/platform-feature-flags": "^0.2.1",
|
|
50
50
|
"@atlaskit/popup": "^1.12.0",
|
|
51
|
-
"@atlaskit/primitives": "^
|
|
51
|
+
"@atlaskit/primitives": "^3.0.0",
|
|
52
52
|
"@atlaskit/spinner": "^16.0.0",
|
|
53
53
|
"@atlaskit/theme": "^12.6.0",
|
|
54
54
|
"@atlaskit/tokens": "^1.38.0",
|
|
@@ -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"
|