@atlaskit/smart-card 40.14.1 → 40.15.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 +8 -0
- package/dist/cjs/utils/analytics/analytics.js +1 -1
- package/dist/cjs/view/CardWithUrl/component.js +2 -1
- package/dist/cjs/view/EmbedCard/components/ImageIcon.js +42 -10
- package/dist/cjs/view/EmbedCard/index.js +4 -2
- package/dist/cjs/view/EmbedCard/views/ResolvedView.js +5 -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.js +2 -1
- package/dist/es2019/view/EmbedCard/components/ImageIcon.js +36 -10
- package/dist/es2019/view/EmbedCard/index.js +4 -2
- package/dist/es2019/view/EmbedCard/views/ResolvedView.js +5 -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.js +2 -1
- package/dist/esm/view/EmbedCard/components/ImageIcon.js +40 -10
- package/dist/esm/view/EmbedCard/index.js +4 -2
- package/dist/esm/view/EmbedCard/views/ResolvedView.js +5 -3
- package/dist/esm/view/LinkUrl/index.js +1 -1
- package/dist/types/view/EmbedCard/components/ImageIcon.d.ts +2 -1
- package/dist/types/view/EmbedCard/types.d.ts +1 -0
- package/dist/types/view/EmbedCard/views/ResolvedView.d.ts +2 -0
- package/dist/types-ts4.5/view/EmbedCard/components/ImageIcon.d.ts +2 -1
- package/dist/types-ts4.5/view/EmbedCard/types.d.ts +1 -0
- package/dist/types-ts4.5/view/EmbedCard/views/ResolvedView.d.ts +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/smart-card
|
|
2
2
|
|
|
3
|
+
## 40.15.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`3d884c026efef`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3d884c026efef) -
|
|
8
|
+
The `EmbedCard` starts `hideIconLoadingSkeleton` prop supporting, that allows not rendering the
|
|
9
|
+
loading placeholder in SSR
|
|
10
|
+
|
|
3
11
|
## 40.14.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -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: "40.14.
|
|
14
|
+
packageVersion: "40.14.1"
|
|
15
15
|
};
|
|
16
16
|
var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
17
17
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -327,7 +327,8 @@ function Component(_ref) {
|
|
|
327
327
|
ref: embedIframeRef,
|
|
328
328
|
onIframeDwell: onIframeDwell,
|
|
329
329
|
onIframeFocus: onIframeFocus,
|
|
330
|
-
CompetitorPrompt: CompetitorPrompt
|
|
330
|
+
CompetitorPrompt: CompetitorPrompt,
|
|
331
|
+
hideIconLoadingSkeleton: hideIconLoadingSkeleton
|
|
331
332
|
});
|
|
332
333
|
}
|
|
333
334
|
}
|
|
@@ -2,15 +2,20 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
6
|
Object.defineProperty(exports, "__esModule", {
|
|
6
7
|
value: true
|
|
7
8
|
});
|
|
8
9
|
exports.ImageIcon = void 0;
|
|
9
10
|
require("./ImageIcon.compiled.css");
|
|
10
11
|
var _runtime = require("@compiled/react/runtime");
|
|
11
|
-
var
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
12
15
|
var _reactRenderImage = _interopRequireDefault(require("react-render-image"));
|
|
16
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
13
17
|
var _styled = require("./styled");
|
|
18
|
+
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); }
|
|
14
19
|
var styles = {
|
|
15
20
|
roundedImage: "_2rko1twn"
|
|
16
21
|
};
|
|
@@ -23,24 +28,51 @@ var ImageIcon = exports.ImageIcon = function ImageIcon(_ref) {
|
|
|
23
28
|
title = _ref.title,
|
|
24
29
|
defaultIcon = _ref.default,
|
|
25
30
|
_ref$appearance = _ref.appearance,
|
|
26
|
-
appearance = _ref$appearance === void 0 ? 'square' : _ref$appearance
|
|
31
|
+
appearance = _ref$appearance === void 0 ? 'square' : _ref$appearance,
|
|
32
|
+
hideLoadingSkeleton = _ref.hideLoadingSkeleton;
|
|
33
|
+
var _useState = (0, _react.useState)(false),
|
|
34
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
35
|
+
hasImageErrored = _useState2[0],
|
|
36
|
+
setHasImageErrored = _useState2[1];
|
|
37
|
+
|
|
38
|
+
// If url changes, reset state
|
|
39
|
+
(0, _react.useEffect)(function () {
|
|
40
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true)) {
|
|
41
|
+
setHasImageErrored(false);
|
|
42
|
+
}
|
|
43
|
+
}, [src]);
|
|
44
|
+
var handleError = (0, _react.useCallback)(function () {
|
|
45
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true)) {
|
|
46
|
+
setHasImageErrored(true);
|
|
47
|
+
}
|
|
48
|
+
}, []);
|
|
49
|
+
|
|
27
50
|
// TODO: do we need this?
|
|
28
51
|
if (!src) {
|
|
29
52
|
return defaultIcon || null;
|
|
30
53
|
}
|
|
54
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true) && hasImageErrored) {
|
|
55
|
+
return defaultIcon;
|
|
56
|
+
}
|
|
31
57
|
var LoadedImageComponent = /*#__PURE__*/_react.default.createElement(_styled.Image
|
|
32
58
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
33
|
-
, {
|
|
59
|
+
, (0, _extends2.default)({
|
|
34
60
|
className: (0, _runtime.ax)([appearance === 'round' && styles.roundedImage, "smart-link-icon"]),
|
|
35
61
|
src: src,
|
|
36
62
|
alt: alt,
|
|
37
63
|
size: size,
|
|
38
64
|
title: title
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
65
|
+
}, hideLoadingSkeleton && (0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true) ? {
|
|
66
|
+
onError: handleError
|
|
67
|
+
} : undefined));
|
|
68
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true) && hideLoadingSkeleton) {
|
|
69
|
+
return LoadedImageComponent;
|
|
70
|
+
} else {
|
|
71
|
+
return /*#__PURE__*/_react.default.createElement(_reactRenderImage.default, {
|
|
72
|
+
src: src,
|
|
73
|
+
loading: defaultIcon,
|
|
74
|
+
loaded: LoadedImageComponent,
|
|
75
|
+
errored: defaultIcon
|
|
76
|
+
});
|
|
77
|
+
}
|
|
46
78
|
};
|
|
@@ -52,7 +52,8 @@ var EmbedCard = exports.EmbedCard = /*#__PURE__*/_react.default.forwardRef(funct
|
|
|
52
52
|
iframeUrlType = _ref2.iframeUrlType,
|
|
53
53
|
actionOptions = _ref2.actionOptions,
|
|
54
54
|
renderers = _ref2.renderers,
|
|
55
|
-
CompetitorPrompt = _ref2.CompetitorPrompt
|
|
55
|
+
CompetitorPrompt = _ref2.CompetitorPrompt,
|
|
56
|
+
hideIconLoadingSkeleton = _ref2.hideIconLoadingSkeleton;
|
|
56
57
|
var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
|
|
57
58
|
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
58
59
|
var status = cardState.status,
|
|
@@ -110,7 +111,8 @@ var EmbedCard = exports.EmbedCard = /*#__PURE__*/_react.default.forwardRef(funct
|
|
|
110
111
|
onIframeDwell: onIframeDwell,
|
|
111
112
|
onIframeFocus: onIframeFocus,
|
|
112
113
|
testId: testId,
|
|
113
|
-
CompetitorPrompt: CompetitorPrompt
|
|
114
|
+
CompetitorPrompt: CompetitorPrompt,
|
|
115
|
+
hideIconLoadingSkeleton: hideIconLoadingSkeleton
|
|
114
116
|
}));
|
|
115
117
|
} else {
|
|
116
118
|
if (platform === 'mobile') {
|
|
@@ -30,7 +30,8 @@ var EmbedCardResolvedView = exports.EmbedCardResolvedView = /*#__PURE__*/_react.
|
|
|
30
30
|
onIframeFocus = _ref.onIframeFocus,
|
|
31
31
|
isSupportTheming = _ref.isSupportTheming,
|
|
32
32
|
type = _ref.type,
|
|
33
|
-
CompetitorPrompt = _ref.CompetitorPrompt
|
|
33
|
+
CompetitorPrompt = _ref.CompetitorPrompt,
|
|
34
|
+
hideIconLoadingSkeleton = _ref.hideIconLoadingSkeleton;
|
|
34
35
|
var iconFromContext = context === null || context === void 0 ? void 0 : context.icon;
|
|
35
36
|
var src = typeof iconFromContext === 'string' ? iconFromContext : undefined;
|
|
36
37
|
var text = title || (context === null || context === void 0 ? void 0 : context.text);
|
|
@@ -49,9 +50,10 @@ var EmbedCardResolvedView = exports.EmbedCardResolvedView = /*#__PURE__*/_react.
|
|
|
49
50
|
return /*#__PURE__*/_react.default.createElement(_ImageIcon.ImageIcon, {
|
|
50
51
|
src: src,
|
|
51
52
|
default: linkGlyph,
|
|
52
|
-
appearance: (0, _utils.isProfileType)(type) ? 'round' : 'square'
|
|
53
|
+
appearance: (0, _utils.isProfileType)(type) ? 'round' : 'square',
|
|
54
|
+
hideLoadingSkeleton: hideIconLoadingSkeleton
|
|
53
55
|
});
|
|
54
|
-
}, [iconFromContext, src, linkGlyph, type]);
|
|
56
|
+
}, [iconFromContext, src, linkGlyph, type, hideIconLoadingSkeleton]);
|
|
55
57
|
if ((0, _platformFeatureFlags.fg)('ptc-enable-embed-team-smart-links')) {
|
|
56
58
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
57
59
|
(0, _useEmbedResolvePostMessageListener.useEmbedResolvePostMessageListener)({
|
|
@@ -19,7 +19,7 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId", "isLink
|
|
|
19
19
|
_excluded2 = ["isLinkSafe", "showSafetyWarningModal"];
|
|
20
20
|
var PACKAGE_DATA = {
|
|
21
21
|
packageName: "@atlaskit/smart-card",
|
|
22
|
-
packageVersion: "40.14.
|
|
22
|
+
packageVersion: "40.14.1",
|
|
23
23
|
componentName: 'linkUrl'
|
|
24
24
|
};
|
|
25
25
|
var Anchor = (0, _click.withLinkClickedEvent)('a');
|
|
@@ -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: "40.14.
|
|
5
|
+
packageVersion: "40.14.1"
|
|
6
6
|
};
|
|
7
7
|
export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
8
8
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -316,7 +316,8 @@ function Component({
|
|
|
316
316
|
ref: embedIframeRef,
|
|
317
317
|
onIframeDwell: onIframeDwell,
|
|
318
318
|
onIframeFocus: onIframeFocus,
|
|
319
|
-
CompetitorPrompt: CompetitorPrompt
|
|
319
|
+
CompetitorPrompt: CompetitorPrompt,
|
|
320
|
+
hideIconLoadingSkeleton: hideIconLoadingSkeleton
|
|
320
321
|
});
|
|
321
322
|
}
|
|
322
323
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/* ImageIcon.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
3
|
import "./ImageIcon.compiled.css";
|
|
3
4
|
import { ax, ix } from "@compiled/react/runtime";
|
|
4
|
-
import React from 'react';
|
|
5
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
5
6
|
import ImageLoader from 'react-render-image';
|
|
7
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
6
8
|
import { Image } from './styled';
|
|
7
9
|
const styles = {
|
|
8
10
|
roundedImage: "_2rko1twn"
|
|
@@ -13,25 +15,49 @@ export const ImageIcon = ({
|
|
|
13
15
|
size = 16,
|
|
14
16
|
title,
|
|
15
17
|
default: defaultIcon,
|
|
16
|
-
appearance = 'square'
|
|
18
|
+
appearance = 'square',
|
|
19
|
+
hideLoadingSkeleton
|
|
17
20
|
}) => {
|
|
21
|
+
const [hasImageErrored, setHasImageErrored] = useState(false);
|
|
22
|
+
|
|
23
|
+
// If url changes, reset state
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (expValEquals('platform_editor_smart_card_otp', 'isEnabled', true)) {
|
|
26
|
+
setHasImageErrored(false);
|
|
27
|
+
}
|
|
28
|
+
}, [src]);
|
|
29
|
+
const handleError = useCallback(() => {
|
|
30
|
+
if (expValEquals('platform_editor_smart_card_otp', 'isEnabled', true)) {
|
|
31
|
+
setHasImageErrored(true);
|
|
32
|
+
}
|
|
33
|
+
}, []);
|
|
34
|
+
|
|
18
35
|
// TODO: do we need this?
|
|
19
36
|
if (!src) {
|
|
20
37
|
return defaultIcon || null;
|
|
21
38
|
}
|
|
39
|
+
if (expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) && hasImageErrored) {
|
|
40
|
+
return defaultIcon;
|
|
41
|
+
}
|
|
22
42
|
const LoadedImageComponent = /*#__PURE__*/React.createElement(Image
|
|
23
43
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
24
|
-
, {
|
|
44
|
+
, _extends({
|
|
25
45
|
className: ax([appearance === 'round' && styles.roundedImage, "smart-link-icon"]),
|
|
26
46
|
src: src,
|
|
27
47
|
alt: alt,
|
|
28
48
|
size: size,
|
|
29
49
|
title: title
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
50
|
+
}, hideLoadingSkeleton && expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) ? {
|
|
51
|
+
onError: handleError
|
|
52
|
+
} : undefined));
|
|
53
|
+
if (expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) && hideLoadingSkeleton) {
|
|
54
|
+
return LoadedImageComponent;
|
|
55
|
+
} else {
|
|
56
|
+
return /*#__PURE__*/React.createElement(ImageLoader, {
|
|
57
|
+
src: src,
|
|
58
|
+
loading: defaultIcon,
|
|
59
|
+
loaded: LoadedImageComponent,
|
|
60
|
+
errored: defaultIcon
|
|
61
|
+
});
|
|
62
|
+
}
|
|
37
63
|
};
|
|
@@ -44,7 +44,8 @@ export const EmbedCard = /*#__PURE__*/React.forwardRef(({
|
|
|
44
44
|
iframeUrlType,
|
|
45
45
|
actionOptions,
|
|
46
46
|
renderers,
|
|
47
|
-
CompetitorPrompt
|
|
47
|
+
CompetitorPrompt,
|
|
48
|
+
hideIconLoadingSkeleton
|
|
48
49
|
}, iframeRef) => {
|
|
49
50
|
var _details$meta, _forbiddenViewProps$c, _forbiddenViewProps$c2, _notFoundViewProps$co, _notFoundViewProps$co2;
|
|
50
51
|
const {
|
|
@@ -107,7 +108,8 @@ export const EmbedCard = /*#__PURE__*/React.forwardRef(({
|
|
|
107
108
|
onIframeDwell: onIframeDwell,
|
|
108
109
|
onIframeFocus: onIframeFocus,
|
|
109
110
|
testId: testId,
|
|
110
|
-
CompetitorPrompt: CompetitorPrompt
|
|
111
|
+
CompetitorPrompt: CompetitorPrompt,
|
|
112
|
+
hideIconLoadingSkeleton: hideIconLoadingSkeleton
|
|
111
113
|
}));
|
|
112
114
|
} else {
|
|
113
115
|
if (platform === 'mobile') {
|
|
@@ -22,7 +22,8 @@ export const EmbedCardResolvedView = /*#__PURE__*/React.forwardRef(({
|
|
|
22
22
|
onIframeFocus,
|
|
23
23
|
isSupportTheming,
|
|
24
24
|
type,
|
|
25
|
-
CompetitorPrompt
|
|
25
|
+
CompetitorPrompt,
|
|
26
|
+
hideIconLoadingSkeleton
|
|
26
27
|
}, embedIframeRef) => {
|
|
27
28
|
const iconFromContext = context === null || context === void 0 ? void 0 : context.icon;
|
|
28
29
|
const src = typeof iconFromContext === 'string' ? iconFromContext : undefined;
|
|
@@ -40,9 +41,10 @@ export const EmbedCardResolvedView = /*#__PURE__*/React.forwardRef(({
|
|
|
40
41
|
return /*#__PURE__*/React.createElement(ImageIcon, {
|
|
41
42
|
src: src,
|
|
42
43
|
default: linkGlyph,
|
|
43
|
-
appearance: isProfileType(type) ? 'round' : 'square'
|
|
44
|
+
appearance: isProfileType(type) ? 'round' : 'square',
|
|
45
|
+
hideLoadingSkeleton: hideIconLoadingSkeleton
|
|
44
46
|
});
|
|
45
|
-
}, [iconFromContext, src, linkGlyph, type]);
|
|
47
|
+
}, [iconFromContext, src, linkGlyph, type, hideIconLoadingSkeleton]);
|
|
46
48
|
if (fg('ptc-enable-embed-team-smart-links')) {
|
|
47
49
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
48
50
|
useEmbedResolvePostMessageListener({
|
|
@@ -9,7 +9,7 @@ import LinkWarningModal from './LinkWarningModal';
|
|
|
9
9
|
import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
|
|
10
10
|
const PACKAGE_DATA = {
|
|
11
11
|
packageName: "@atlaskit/smart-card",
|
|
12
|
-
packageVersion: "40.14.
|
|
12
|
+
packageVersion: "40.14.1",
|
|
13
13
|
componentName: 'linkUrl'
|
|
14
14
|
};
|
|
15
15
|
const Anchor = withLinkClickedEvent('a');
|
|
@@ -4,7 +4,7 @@ export var ANALYTICS_CHANNEL = 'media';
|
|
|
4
4
|
export var context = {
|
|
5
5
|
componentName: 'smart-cards',
|
|
6
6
|
packageName: "@atlaskit/smart-card",
|
|
7
|
-
packageVersion: "40.14.
|
|
7
|
+
packageVersion: "40.14.1"
|
|
8
8
|
};
|
|
9
9
|
export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
10
10
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -318,7 +318,8 @@ function Component(_ref) {
|
|
|
318
318
|
ref: embedIframeRef,
|
|
319
319
|
onIframeDwell: onIframeDwell,
|
|
320
320
|
onIframeFocus: onIframeFocus,
|
|
321
|
-
CompetitorPrompt: CompetitorPrompt
|
|
321
|
+
CompetitorPrompt: CompetitorPrompt,
|
|
322
|
+
hideIconLoadingSkeleton: hideIconLoadingSkeleton
|
|
322
323
|
});
|
|
323
324
|
}
|
|
324
325
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/* ImageIcon.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
4
|
import "./ImageIcon.compiled.css";
|
|
3
5
|
import { ax, ix } from "@compiled/react/runtime";
|
|
4
|
-
import React from 'react';
|
|
6
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
5
7
|
import ImageLoader from 'react-render-image';
|
|
8
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
6
9
|
import { Image } from './styled';
|
|
7
10
|
var styles = {
|
|
8
11
|
roundedImage: "_2rko1twn"
|
|
@@ -16,24 +19,51 @@ export var ImageIcon = function ImageIcon(_ref) {
|
|
|
16
19
|
title = _ref.title,
|
|
17
20
|
defaultIcon = _ref.default,
|
|
18
21
|
_ref$appearance = _ref.appearance,
|
|
19
|
-
appearance = _ref$appearance === void 0 ? 'square' : _ref$appearance
|
|
22
|
+
appearance = _ref$appearance === void 0 ? 'square' : _ref$appearance,
|
|
23
|
+
hideLoadingSkeleton = _ref.hideLoadingSkeleton;
|
|
24
|
+
var _useState = useState(false),
|
|
25
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
26
|
+
hasImageErrored = _useState2[0],
|
|
27
|
+
setHasImageErrored = _useState2[1];
|
|
28
|
+
|
|
29
|
+
// If url changes, reset state
|
|
30
|
+
useEffect(function () {
|
|
31
|
+
if (expValEquals('platform_editor_smart_card_otp', 'isEnabled', true)) {
|
|
32
|
+
setHasImageErrored(false);
|
|
33
|
+
}
|
|
34
|
+
}, [src]);
|
|
35
|
+
var handleError = useCallback(function () {
|
|
36
|
+
if (expValEquals('platform_editor_smart_card_otp', 'isEnabled', true)) {
|
|
37
|
+
setHasImageErrored(true);
|
|
38
|
+
}
|
|
39
|
+
}, []);
|
|
40
|
+
|
|
20
41
|
// TODO: do we need this?
|
|
21
42
|
if (!src) {
|
|
22
43
|
return defaultIcon || null;
|
|
23
44
|
}
|
|
45
|
+
if (expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) && hasImageErrored) {
|
|
46
|
+
return defaultIcon;
|
|
47
|
+
}
|
|
24
48
|
var LoadedImageComponent = /*#__PURE__*/React.createElement(Image
|
|
25
49
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
26
|
-
, {
|
|
50
|
+
, _extends({
|
|
27
51
|
className: ax([appearance === 'round' && styles.roundedImage, "smart-link-icon"]),
|
|
28
52
|
src: src,
|
|
29
53
|
alt: alt,
|
|
30
54
|
size: size,
|
|
31
55
|
title: title
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
56
|
+
}, hideLoadingSkeleton && expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) ? {
|
|
57
|
+
onError: handleError
|
|
58
|
+
} : undefined));
|
|
59
|
+
if (expValEquals('platform_editor_smart_card_otp', 'isEnabled', true) && hideLoadingSkeleton) {
|
|
60
|
+
return LoadedImageComponent;
|
|
61
|
+
} else {
|
|
62
|
+
return /*#__PURE__*/React.createElement(ImageLoader, {
|
|
63
|
+
src: src,
|
|
64
|
+
loading: defaultIcon,
|
|
65
|
+
loaded: LoadedImageComponent,
|
|
66
|
+
errored: defaultIcon
|
|
67
|
+
});
|
|
68
|
+
}
|
|
39
69
|
};
|
|
@@ -44,7 +44,8 @@ export var EmbedCard = /*#__PURE__*/React.forwardRef(function (_ref2, iframeRef)
|
|
|
44
44
|
iframeUrlType = _ref2.iframeUrlType,
|
|
45
45
|
actionOptions = _ref2.actionOptions,
|
|
46
46
|
renderers = _ref2.renderers,
|
|
47
|
-
CompetitorPrompt = _ref2.CompetitorPrompt
|
|
47
|
+
CompetitorPrompt = _ref2.CompetitorPrompt,
|
|
48
|
+
hideIconLoadingSkeleton = _ref2.hideIconLoadingSkeleton;
|
|
48
49
|
var _useAnalyticsEvents = useAnalyticsEvents(),
|
|
49
50
|
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
50
51
|
var status = cardState.status,
|
|
@@ -102,7 +103,8 @@ export var EmbedCard = /*#__PURE__*/React.forwardRef(function (_ref2, iframeRef)
|
|
|
102
103
|
onIframeDwell: onIframeDwell,
|
|
103
104
|
onIframeFocus: onIframeFocus,
|
|
104
105
|
testId: testId,
|
|
105
|
-
CompetitorPrompt: CompetitorPrompt
|
|
106
|
+
CompetitorPrompt: CompetitorPrompt,
|
|
107
|
+
hideIconLoadingSkeleton: hideIconLoadingSkeleton
|
|
106
108
|
}));
|
|
107
109
|
} else {
|
|
108
110
|
if (platform === 'mobile') {
|
|
@@ -23,7 +23,8 @@ export var EmbedCardResolvedView = /*#__PURE__*/React.forwardRef(function (_ref,
|
|
|
23
23
|
onIframeFocus = _ref.onIframeFocus,
|
|
24
24
|
isSupportTheming = _ref.isSupportTheming,
|
|
25
25
|
type = _ref.type,
|
|
26
|
-
CompetitorPrompt = _ref.CompetitorPrompt
|
|
26
|
+
CompetitorPrompt = _ref.CompetitorPrompt,
|
|
27
|
+
hideIconLoadingSkeleton = _ref.hideIconLoadingSkeleton;
|
|
27
28
|
var iconFromContext = context === null || context === void 0 ? void 0 : context.icon;
|
|
28
29
|
var src = typeof iconFromContext === 'string' ? iconFromContext : undefined;
|
|
29
30
|
var text = title || (context === null || context === void 0 ? void 0 : context.text);
|
|
@@ -42,9 +43,10 @@ export var EmbedCardResolvedView = /*#__PURE__*/React.forwardRef(function (_ref,
|
|
|
42
43
|
return /*#__PURE__*/React.createElement(ImageIcon, {
|
|
43
44
|
src: src,
|
|
44
45
|
default: linkGlyph,
|
|
45
|
-
appearance: isProfileType(type) ? 'round' : 'square'
|
|
46
|
+
appearance: isProfileType(type) ? 'round' : 'square',
|
|
47
|
+
hideLoadingSkeleton: hideIconLoadingSkeleton
|
|
46
48
|
});
|
|
47
|
-
}, [iconFromContext, src, linkGlyph, type]);
|
|
49
|
+
}, [iconFromContext, src, linkGlyph, type, hideIconLoadingSkeleton]);
|
|
48
50
|
if (fg('ptc-enable-embed-team-smart-links')) {
|
|
49
51
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
50
52
|
useEmbedResolvePostMessageListener({
|
|
@@ -12,7 +12,7 @@ import LinkWarningModal from './LinkWarningModal';
|
|
|
12
12
|
import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
|
|
13
13
|
var PACKAGE_DATA = {
|
|
14
14
|
packageName: "@atlaskit/smart-card",
|
|
15
|
-
packageVersion: "40.14.
|
|
15
|
+
packageVersion: "40.14.1",
|
|
16
16
|
componentName: 'linkUrl'
|
|
17
17
|
};
|
|
18
18
|
var Anchor = withLinkClickedEvent('a');
|
|
@@ -7,8 +7,9 @@ export interface ImageIconProps {
|
|
|
7
7
|
alt?: string;
|
|
8
8
|
appearance?: 'square' | 'round';
|
|
9
9
|
default?: React.ReactElement;
|
|
10
|
+
hideLoadingSkeleton?: boolean;
|
|
10
11
|
size?: number;
|
|
11
12
|
src?: string;
|
|
12
13
|
title?: string;
|
|
13
14
|
}
|
|
14
|
-
export declare const ImageIcon: ({ alt, src, size, title, default: defaultIcon, appearance, }: ImageIconProps) => JSX.Element | null;
|
|
15
|
+
export declare const ImageIcon: ({ alt, src, size, title, default: defaultIcon, appearance, hideLoadingSkeleton, }: ImageIconProps) => JSX.Element | null | undefined;
|
|
@@ -16,6 +16,7 @@ export type EmbedCardProps = {
|
|
|
16
16
|
handleErrorRetry: () => void;
|
|
17
17
|
handleFrameClick: React.EventHandler<React.MouseEvent | React.KeyboardEvent>;
|
|
18
18
|
handleInvoke: InvokeHandler;
|
|
19
|
+
hideIconLoadingSkeleton?: boolean;
|
|
19
20
|
id?: string;
|
|
20
21
|
iframeUrlType?: EmbedIframeUrlType;
|
|
21
22
|
inheritDimensions?: boolean;
|
|
@@ -10,6 +10,8 @@ export interface EmbedCardResolvedViewProps {
|
|
|
10
10
|
context?: ContextViewModel;
|
|
11
11
|
/** A prop that determines the style of a frame: whether to show it, hide it or only show it when a user hovers over embed */
|
|
12
12
|
frameStyle?: FrameStyle;
|
|
13
|
+
/** For image icons in the title, whether to hide the loading skeleton while the image is loading. */
|
|
14
|
+
hideIconLoadingSkeleton?: boolean;
|
|
13
15
|
inheritDimensions?: boolean;
|
|
14
16
|
/** A flag that determines whether the card is selected in edit mode. */
|
|
15
17
|
isSelected?: boolean;
|
|
@@ -7,8 +7,9 @@ export interface ImageIconProps {
|
|
|
7
7
|
alt?: string;
|
|
8
8
|
appearance?: 'square' | 'round';
|
|
9
9
|
default?: React.ReactElement;
|
|
10
|
+
hideLoadingSkeleton?: boolean;
|
|
10
11
|
size?: number;
|
|
11
12
|
src?: string;
|
|
12
13
|
title?: string;
|
|
13
14
|
}
|
|
14
|
-
export declare const ImageIcon: ({ alt, src, size, title, default: defaultIcon, appearance, }: ImageIconProps) => JSX.Element | null;
|
|
15
|
+
export declare const ImageIcon: ({ alt, src, size, title, default: defaultIcon, appearance, hideLoadingSkeleton, }: ImageIconProps) => JSX.Element | null | undefined;
|
|
@@ -16,6 +16,7 @@ export type EmbedCardProps = {
|
|
|
16
16
|
handleErrorRetry: () => void;
|
|
17
17
|
handleFrameClick: React.EventHandler<React.MouseEvent | React.KeyboardEvent>;
|
|
18
18
|
handleInvoke: InvokeHandler;
|
|
19
|
+
hideIconLoadingSkeleton?: boolean;
|
|
19
20
|
id?: string;
|
|
20
21
|
iframeUrlType?: EmbedIframeUrlType;
|
|
21
22
|
inheritDimensions?: boolean;
|
|
@@ -10,6 +10,8 @@ export interface EmbedCardResolvedViewProps {
|
|
|
10
10
|
context?: ContextViewModel;
|
|
11
11
|
/** A prop that determines the style of a frame: whether to show it, hide it or only show it when a user hovers over embed */
|
|
12
12
|
frameStyle?: FrameStyle;
|
|
13
|
+
/** For image icons in the title, whether to hide the loading skeleton while the image is loading. */
|
|
14
|
+
hideIconLoadingSkeleton?: boolean;
|
|
13
15
|
inheritDimensions?: boolean;
|
|
14
16
|
/** A flag that determines whether the card is selected in edit mode. */
|
|
15
17
|
isSelected?: boolean;
|