@atlaskit/smart-card 43.11.3 → 43.12.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/analytics.spec.yaml +7 -1
- package/dist/cjs/view/CardWithUrl/component.js +327 -3
- package/dist/cjs/view/EmbedCard/components/ExpandedFrame.js +93 -2
- package/dist/cjs/view/EmbedCard/components/Frame.js +121 -3
- package/dist/cjs/view/EmbedCard/components/IframeDwellTracker.js +25 -4
- package/dist/cjs/view/EmbedCard/index.js +204 -1
- package/dist/cjs/view/EmbedCard/views/ResolvedView.js +95 -2
- package/dist/es2019/view/CardWithUrl/component.js +324 -2
- package/dist/es2019/view/EmbedCard/components/ExpandedFrame.js +87 -2
- package/dist/es2019/view/EmbedCard/components/Frame.js +112 -2
- package/dist/es2019/view/EmbedCard/components/IframeDwellTracker.js +25 -4
- package/dist/es2019/view/EmbedCard/index.js +208 -0
- package/dist/es2019/view/EmbedCard/views/ResolvedView.js +91 -3
- package/dist/esm/view/CardWithUrl/component.js +326 -2
- package/dist/esm/view/EmbedCard/components/ExpandedFrame.js +95 -2
- package/dist/esm/view/EmbedCard/components/Frame.js +122 -2
- package/dist/esm/view/EmbedCard/components/IframeDwellTracker.js +25 -4
- package/dist/esm/view/EmbedCard/index.js +203 -0
- package/dist/esm/view/EmbedCard/views/ResolvedView.js +97 -3
- package/dist/types/common/analytics/generated/analytics.types.d.ts +1 -0
- package/dist/types/view/EmbedCard/components/ExpandedFrame.d.ts +8 -1
- package/dist/types/view/EmbedCard/components/Frame.d.ts +6 -0
- package/dist/types/view/EmbedCard/index.d.ts +4 -0
- package/dist/types/view/EmbedCard/types.d.ts +4 -0
- package/dist/types/view/EmbedCard/views/ResolvedView.d.ts +6 -1
- package/dist/types-ts4.5/common/analytics/generated/analytics.types.d.ts +1 -0
- package/dist/types-ts4.5/view/EmbedCard/components/ExpandedFrame.d.ts +8 -1
- package/dist/types-ts4.5/view/EmbedCard/components/Frame.d.ts +6 -0
- package/dist/types-ts4.5/view/EmbedCard/index.d.ts +4 -0
- package/dist/types-ts4.5/view/EmbedCard/types.d.ts +4 -0
- package/dist/types-ts4.5/view/EmbedCard/views/ResolvedView.d.ts +6 -1
- package/package.json +5 -1
|
@@ -227,4 +227,212 @@ export const EmbedCard = /*#__PURE__*/React.forwardRef(({
|
|
|
227
227
|
isSelected: isSelected
|
|
228
228
|
});
|
|
229
229
|
}
|
|
230
|
+
});
|
|
231
|
+
export const EmbedCardUpdated = /*#__PURE__*/React.forwardRef(({
|
|
232
|
+
url,
|
|
233
|
+
cardState,
|
|
234
|
+
handleAuthorize,
|
|
235
|
+
handleErrorRetry,
|
|
236
|
+
handleFrameClick,
|
|
237
|
+
isSelected,
|
|
238
|
+
frameStyle,
|
|
239
|
+
platform,
|
|
240
|
+
onResolve,
|
|
241
|
+
onError,
|
|
242
|
+
testId,
|
|
243
|
+
inheritDimensions,
|
|
244
|
+
onIframeDwell,
|
|
245
|
+
onIframeFocus,
|
|
246
|
+
onIframeMouseEnter,
|
|
247
|
+
onIframeMouseLeave,
|
|
248
|
+
iframeUrlType,
|
|
249
|
+
actionOptions,
|
|
250
|
+
renderers,
|
|
251
|
+
CompetitorPrompt,
|
|
252
|
+
hideIconLoadingSkeleton
|
|
253
|
+
}, iframeRef) => {
|
|
254
|
+
var _details$meta4, _forbiddenViewProps$c3, _forbiddenViewProps$c4, _notFoundViewProps$co3, _notFoundViewProps$co4;
|
|
255
|
+
const {
|
|
256
|
+
createAnalyticsEvent
|
|
257
|
+
} = useAnalyticsEvents();
|
|
258
|
+
const {
|
|
259
|
+
status,
|
|
260
|
+
details
|
|
261
|
+
} = cardState;
|
|
262
|
+
const extensionKey = getExtensionKey(details);
|
|
263
|
+
const isProductIntegrationSupported = hasAuthScopeOverrides(details);
|
|
264
|
+
const {
|
|
265
|
+
shouldControlDataExport = false
|
|
266
|
+
} = useControlDataExportConfig();
|
|
267
|
+
switch (status) {
|
|
268
|
+
case 'pending':
|
|
269
|
+
case 'resolving':
|
|
270
|
+
return /*#__PURE__*/React.createElement(UFOLoadHoldWrapper, null, /*#__PURE__*/React.createElement(BlockCardResolvedView, {
|
|
271
|
+
url: url,
|
|
272
|
+
cardState: cardState,
|
|
273
|
+
onClick: handleFrameClick,
|
|
274
|
+
onError: onError,
|
|
275
|
+
onResolve: onResolve,
|
|
276
|
+
renderers: renderers,
|
|
277
|
+
actionOptions: actionOptions,
|
|
278
|
+
testId: testId ? `${testId}-resolving-view` : 'embed-card-resolving-view'
|
|
279
|
+
}));
|
|
280
|
+
case 'resolved':
|
|
281
|
+
const resolvedViewProps = extractEmbedProps(details, platform, iframeUrlType);
|
|
282
|
+
if (onResolve) {
|
|
283
|
+
var _resolvedViewProps$pr2, _details$meta3;
|
|
284
|
+
onResolve({
|
|
285
|
+
title: resolvedViewProps.title,
|
|
286
|
+
url,
|
|
287
|
+
aspectRatio: (_resolvedViewProps$pr2 = resolvedViewProps.preview) === null || _resolvedViewProps$pr2 === void 0 ? void 0 : _resolvedViewProps$pr2.aspectRatio,
|
|
288
|
+
...(fg('expose-product-details-from-smart-card') && {
|
|
289
|
+
extensionKey: details === null || details === void 0 ? void 0 : (_details$meta3 = details.meta) === null || _details$meta3 === void 0 ? void 0 : _details$meta3.key
|
|
290
|
+
})
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
if (getIsDataExportEnabled(shouldControlDataExport, cardState.details)) {
|
|
294
|
+
const unauthViewProps = extractEmbedProps(details, platform);
|
|
295
|
+
return /*#__PURE__*/React.createElement(UnauthorizedView, {
|
|
296
|
+
context: unauthViewProps.context,
|
|
297
|
+
extensionKey: extensionKey,
|
|
298
|
+
frameStyle: frameStyle,
|
|
299
|
+
isProductIntegrationSupported: isProductIntegrationSupported,
|
|
300
|
+
inheritDimensions: inheritDimensions,
|
|
301
|
+
isSelected: isSelected,
|
|
302
|
+
onAuthorize: handleAuthorize,
|
|
303
|
+
onClick: handleFrameClick,
|
|
304
|
+
testId: testId,
|
|
305
|
+
url: unauthViewProps.link
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
if (resolvedViewProps.preview) {
|
|
309
|
+
return /*#__PURE__*/React.createElement(EmbedCardResolvedView, _extends({}, resolvedViewProps, {
|
|
310
|
+
isSelected: isSelected,
|
|
311
|
+
frameStyle: frameStyle,
|
|
312
|
+
inheritDimensions: inheritDimensions,
|
|
313
|
+
onClick: handleFrameClick,
|
|
314
|
+
ref: iframeRef,
|
|
315
|
+
onIframeDwell: onIframeDwell,
|
|
316
|
+
onIframeFocus: onIframeFocus,
|
|
317
|
+
onIframeMouseEnter: onIframeMouseEnter,
|
|
318
|
+
onIframeMouseLeave: onIframeMouseLeave,
|
|
319
|
+
testId: testId,
|
|
320
|
+
CompetitorPrompt: CompetitorPrompt,
|
|
321
|
+
hideIconLoadingSkeleton: hideIconLoadingSkeleton,
|
|
322
|
+
extensionKey: extensionKey
|
|
323
|
+
}));
|
|
324
|
+
} else {
|
|
325
|
+
if (platform === 'mobile') {
|
|
326
|
+
const resolvedInlineViewProps = extractInlineProps(details);
|
|
327
|
+
return /*#__PURE__*/React.createElement(InlineCardResolvedView, _extends({}, resolvedInlineViewProps, {
|
|
328
|
+
isSelected: isSelected,
|
|
329
|
+
testId: testId,
|
|
330
|
+
onClick: handleFrameClick
|
|
331
|
+
}));
|
|
332
|
+
}
|
|
333
|
+
return /*#__PURE__*/React.createElement(BlockCardResolvedView, {
|
|
334
|
+
url: url,
|
|
335
|
+
cardState: cardState,
|
|
336
|
+
onClick: handleFrameClick,
|
|
337
|
+
onError: onError,
|
|
338
|
+
onResolve: onResolve,
|
|
339
|
+
renderers: renderers,
|
|
340
|
+
actionOptions: actionOptions,
|
|
341
|
+
testId: testId
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
case 'unauthorized':
|
|
345
|
+
if (onError) {
|
|
346
|
+
onError({
|
|
347
|
+
url,
|
|
348
|
+
status
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
const unauthorisedViewProps = extractEmbedProps(details, platform);
|
|
352
|
+
return /*#__PURE__*/React.createElement(UnauthorizedView, {
|
|
353
|
+
context: unauthorisedViewProps.context,
|
|
354
|
+
extensionKey: extensionKey,
|
|
355
|
+
frameStyle: frameStyle,
|
|
356
|
+
isProductIntegrationSupported: isProductIntegrationSupported,
|
|
357
|
+
inheritDimensions: inheritDimensions,
|
|
358
|
+
isSelected: isSelected,
|
|
359
|
+
onAuthorize: handleAuthorize,
|
|
360
|
+
onClick: handleFrameClick,
|
|
361
|
+
testId: testId,
|
|
362
|
+
url: unauthorisedViewProps.link
|
|
363
|
+
});
|
|
364
|
+
case 'forbidden':
|
|
365
|
+
if (onError) {
|
|
366
|
+
onError({
|
|
367
|
+
url,
|
|
368
|
+
status
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
const forbiddenViewProps = extractEmbedProps(details, platform);
|
|
372
|
+
const cardMetadata = (_details$meta4 = details === null || details === void 0 ? void 0 : details.meta) !== null && _details$meta4 !== void 0 ? _details$meta4 : getForbiddenJsonLd().meta;
|
|
373
|
+
if (forbiddenViewProps.preview) {
|
|
374
|
+
return /*#__PURE__*/React.createElement(EmbedCardResolvedView, _extends({}, forbiddenViewProps, {
|
|
375
|
+
title: forbiddenViewProps.link,
|
|
376
|
+
frameStyle: frameStyle,
|
|
377
|
+
isSelected: isSelected,
|
|
378
|
+
inheritDimensions: inheritDimensions,
|
|
379
|
+
onClick: handleFrameClick,
|
|
380
|
+
ref: iframeRef,
|
|
381
|
+
extensionKey: extensionKey
|
|
382
|
+
}));
|
|
383
|
+
}
|
|
384
|
+
const forbiddenAccessContext = extractRequestAccessContextImproved({
|
|
385
|
+
jsonLd: cardMetadata,
|
|
386
|
+
url,
|
|
387
|
+
product: (_forbiddenViewProps$c3 = (_forbiddenViewProps$c4 = forbiddenViewProps.context) === null || _forbiddenViewProps$c4 === void 0 ? void 0 : _forbiddenViewProps$c4.text) !== null && _forbiddenViewProps$c3 !== void 0 ? _forbiddenViewProps$c3 : '',
|
|
388
|
+
createAnalyticsEvent
|
|
389
|
+
});
|
|
390
|
+
return /*#__PURE__*/React.createElement(ForbiddenView, {
|
|
391
|
+
context: forbiddenViewProps.context,
|
|
392
|
+
frameStyle: frameStyle,
|
|
393
|
+
inheritDimensions: inheritDimensions,
|
|
394
|
+
isSelected: isSelected,
|
|
395
|
+
onAuthorize: handleAuthorize,
|
|
396
|
+
onClick: handleFrameClick,
|
|
397
|
+
accessContext: forbiddenAccessContext,
|
|
398
|
+
url: forbiddenViewProps.link
|
|
399
|
+
});
|
|
400
|
+
case 'not_found':
|
|
401
|
+
if (onError) {
|
|
402
|
+
onError({
|
|
403
|
+
url,
|
|
404
|
+
status
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
const notFoundViewProps = extractEmbedProps(details, platform);
|
|
408
|
+
const notFoundAccessContext = details !== null && details !== void 0 && details.meta ? extractRequestAccessContextImproved({
|
|
409
|
+
jsonLd: details === null || details === void 0 ? void 0 : details.meta,
|
|
410
|
+
url,
|
|
411
|
+
product: (_notFoundViewProps$co3 = (_notFoundViewProps$co4 = notFoundViewProps.context) === null || _notFoundViewProps$co4 === void 0 ? void 0 : _notFoundViewProps$co4.text) !== null && _notFoundViewProps$co3 !== void 0 ? _notFoundViewProps$co3 : '',
|
|
412
|
+
createAnalyticsEvent
|
|
413
|
+
}) : undefined;
|
|
414
|
+
return /*#__PURE__*/React.createElement(NotFoundView, {
|
|
415
|
+
context: notFoundViewProps.context,
|
|
416
|
+
frameStyle: frameStyle,
|
|
417
|
+
inheritDimensions: inheritDimensions,
|
|
418
|
+
isSelected: isSelected,
|
|
419
|
+
onClick: handleFrameClick,
|
|
420
|
+
accessContext: notFoundAccessContext,
|
|
421
|
+
url: notFoundViewProps.link
|
|
422
|
+
});
|
|
423
|
+
case 'fallback':
|
|
424
|
+
case 'errored':
|
|
425
|
+
default:
|
|
426
|
+
if (onError) {
|
|
427
|
+
onError({
|
|
428
|
+
url,
|
|
429
|
+
status
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
return /*#__PURE__*/React.createElement(EmbedCardErroredView, {
|
|
433
|
+
onRetry: handleErrorRetry,
|
|
434
|
+
inheritDimensions: inheritDimensions,
|
|
435
|
+
isSelected: isSelected
|
|
436
|
+
});
|
|
437
|
+
}
|
|
230
438
|
});
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import LinkGlyph from '@atlaskit/icon/core/migration/link';
|
|
3
|
+
import { componentWithFG } from '@atlaskit/platform-feature-flags-react';
|
|
3
4
|
import { useThemeObserver } from '@atlaskit/tokens';
|
|
4
5
|
import { getPreviewUrlWithTheme, isProfileType } from '../../../utils';
|
|
5
6
|
import { ExpandedFrame } from '../components/ExpandedFrame';
|
|
6
|
-
import { Frame } from '../components/Frame';
|
|
7
|
+
import { Frame, FrameUpdated } from '../components/Frame';
|
|
7
8
|
import { ImageIcon } from '../components/ImageIcon';
|
|
8
9
|
import { useEmbedResolvePostMessageListener } from '../useEmbedResolvePostMessageListener';
|
|
9
|
-
|
|
10
|
+
const FrameComponent = componentWithFG('rovo_chat_embed_card_dwell_and_hover_metrics', FrameUpdated, Frame);
|
|
11
|
+
const EmbedCardResolvedViewOld = /*#__PURE__*/React.forwardRef(({
|
|
10
12
|
link,
|
|
11
13
|
context,
|
|
12
14
|
onClick,
|
|
@@ -75,4 +77,90 @@ export const EmbedCardResolvedView = /*#__PURE__*/React.forwardRef(({
|
|
|
75
77
|
title: text,
|
|
76
78
|
extensionKey: extensionKey
|
|
77
79
|
}));
|
|
78
|
-
});
|
|
80
|
+
});
|
|
81
|
+
const EmbedCardResolvedViewUpdated = /*#__PURE__*/React.forwardRef(({
|
|
82
|
+
link,
|
|
83
|
+
context,
|
|
84
|
+
onClick,
|
|
85
|
+
isSelected,
|
|
86
|
+
frameStyle,
|
|
87
|
+
preview,
|
|
88
|
+
title,
|
|
89
|
+
isTrusted,
|
|
90
|
+
testId = 'embed-card-resolved-view',
|
|
91
|
+
inheritDimensions,
|
|
92
|
+
onIframeDwell,
|
|
93
|
+
onIframeFocus,
|
|
94
|
+
onIframeMouseEnter,
|
|
95
|
+
onIframeMouseLeave,
|
|
96
|
+
isSupportTheming,
|
|
97
|
+
type,
|
|
98
|
+
CompetitorPrompt,
|
|
99
|
+
hideIconLoadingSkeleton,
|
|
100
|
+
extensionKey
|
|
101
|
+
}, embedIframeRef) => {
|
|
102
|
+
const iconFromContext = context === null || context === void 0 ? void 0 : context.icon;
|
|
103
|
+
const src = typeof iconFromContext === 'string' ? iconFromContext : undefined;
|
|
104
|
+
const text = title || (context === null || context === void 0 ? void 0 : context.text);
|
|
105
|
+
const linkGlyph = React.useMemo(() => /*#__PURE__*/React.createElement(LinkGlyph, {
|
|
106
|
+
label: "icon",
|
|
107
|
+
LEGACY_size: "small",
|
|
108
|
+
testId: "embed-card-fallback-icon",
|
|
109
|
+
color: "currentColor"
|
|
110
|
+
}), []);
|
|
111
|
+
let icon = React.useMemo(() => {
|
|
112
|
+
if ( /*#__PURE__*/React.isValidElement(iconFromContext)) {
|
|
113
|
+
return iconFromContext;
|
|
114
|
+
}
|
|
115
|
+
return /*#__PURE__*/React.createElement(ImageIcon, {
|
|
116
|
+
src: src,
|
|
117
|
+
default: linkGlyph,
|
|
118
|
+
appearance: isProfileType(type) ? 'round' : 'square',
|
|
119
|
+
hideLoadingSkeleton: hideIconLoadingSkeleton
|
|
120
|
+
});
|
|
121
|
+
}, [iconFromContext, src, linkGlyph, type, hideIconLoadingSkeleton]);
|
|
122
|
+
useEmbedResolvePostMessageListener({
|
|
123
|
+
url: link,
|
|
124
|
+
embedIframeRef
|
|
125
|
+
});
|
|
126
|
+
const themeState = useThemeObserver();
|
|
127
|
+
let previewUrl = preview === null || preview === void 0 ? void 0 : preview.src;
|
|
128
|
+
if (previewUrl && isSupportTheming) {
|
|
129
|
+
previewUrl = getPreviewUrlWithTheme(previewUrl, themeState);
|
|
130
|
+
}
|
|
131
|
+
const [isMouseOver, setMouseOver] = React.useState(false);
|
|
132
|
+
return /*#__PURE__*/React.createElement(ExpandedFrame, {
|
|
133
|
+
isSelected: isSelected,
|
|
134
|
+
frameStyle: frameStyle,
|
|
135
|
+
href: link,
|
|
136
|
+
testId: testId,
|
|
137
|
+
icon: icon,
|
|
138
|
+
text: text,
|
|
139
|
+
onClick: onClick,
|
|
140
|
+
inheritDimensions: inheritDimensions,
|
|
141
|
+
setOverflow: false,
|
|
142
|
+
CompetitorPrompt: CompetitorPrompt,
|
|
143
|
+
onContentMouseEnter: () => {
|
|
144
|
+
setMouseOver(true);
|
|
145
|
+
onIframeMouseEnter === null || onIframeMouseEnter === void 0 ? void 0 : onIframeMouseEnter();
|
|
146
|
+
},
|
|
147
|
+
onContentMouseLeave: () => {
|
|
148
|
+
setMouseOver(false);
|
|
149
|
+
onIframeMouseLeave === null || onIframeMouseLeave === void 0 ? void 0 : onIframeMouseLeave();
|
|
150
|
+
}
|
|
151
|
+
}, /*#__PURE__*/React.createElement(FrameComponent, {
|
|
152
|
+
url: previewUrl,
|
|
153
|
+
isTrusted: isTrusted,
|
|
154
|
+
testId: testId,
|
|
155
|
+
ref: embedIframeRef,
|
|
156
|
+
onIframeDwell: onIframeDwell,
|
|
157
|
+
onIframeFocus: onIframeFocus,
|
|
158
|
+
onIframeMouseEnter: onIframeMouseEnter,
|
|
159
|
+
onIframeMouseLeave: onIframeMouseLeave,
|
|
160
|
+
isMouseOver: isMouseOver,
|
|
161
|
+
title: text,
|
|
162
|
+
extensionKey: extensionKey
|
|
163
|
+
}));
|
|
164
|
+
});
|
|
165
|
+
const EmbedCardResolvedViewWithFG = componentWithFG('rovo_chat_embed_card_dwell_and_hover_metrics', EmbedCardResolvedViewUpdated, EmbedCardResolvedViewOld);
|
|
166
|
+
export { EmbedCardResolvedViewWithFG as EmbedCardResolvedView };
|
|
@@ -2,6 +2,7 @@ import React, { useCallback, useEffect, useMemo } from 'react';
|
|
|
2
2
|
import { useAnalyticsEvents as useAnalyticsEventsNext } from '@atlaskit/analytics-next';
|
|
3
3
|
import { extractSmartLinkEmbed } from '@atlaskit/link-extractors';
|
|
4
4
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
|
+
import { componentWithFG } from '@atlaskit/platform-feature-flags-react';
|
|
5
6
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
6
7
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
8
|
import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
|
|
@@ -17,11 +18,12 @@ import { SmartLinkAnalyticsContext } from '../../utils/analytics/SmartLinkAnalyt
|
|
|
17
18
|
import { isFlexibleUiCard } from '../../utils/flexible';
|
|
18
19
|
import * as measure from '../../utils/performance';
|
|
19
20
|
import { BlockCard } from '../BlockCard';
|
|
20
|
-
import { EmbedCard } from '../EmbedCard';
|
|
21
|
+
import { EmbedCard, EmbedCardUpdated } from '../EmbedCard';
|
|
21
22
|
import FlexibleCard from '../FlexibleCard';
|
|
22
23
|
import { InlineCard } from '../InlineCard';
|
|
23
24
|
import { useFire3PWorkflowsClickEvent } from '../SmartLinkEvents/useSmartLinkEvents';
|
|
24
25
|
var thirdPartyARIPrefix = 'ari:third-party';
|
|
26
|
+
var EmbedCardComponent = componentWithFG('rovo_chat_embed_card_dwell_and_hover_metrics', EmbedCardUpdated, EmbedCard);
|
|
25
27
|
function Component(_ref) {
|
|
26
28
|
var id = _ref.id,
|
|
27
29
|
url = _ref.url,
|
|
@@ -324,11 +326,333 @@ function Component(_ref) {
|
|
|
324
326
|
});
|
|
325
327
|
}
|
|
326
328
|
}
|
|
329
|
+
function ComponentUpdated(_ref2) {
|
|
330
|
+
var id = _ref2.id,
|
|
331
|
+
url = _ref2.url,
|
|
332
|
+
isSelected = _ref2.isSelected,
|
|
333
|
+
isHovered = _ref2.isHovered,
|
|
334
|
+
frameStyle = _ref2.frameStyle,
|
|
335
|
+
platform = _ref2.platform,
|
|
336
|
+
onClick = _ref2.onClick,
|
|
337
|
+
appearance = _ref2.appearance,
|
|
338
|
+
onResolve = _ref2.onResolve,
|
|
339
|
+
onError = _ref2.onError,
|
|
340
|
+
testId = _ref2.testId,
|
|
341
|
+
actionOptionsProp = _ref2.actionOptions,
|
|
342
|
+
inheritDimensions = _ref2.inheritDimensions,
|
|
343
|
+
embedIframeRef = _ref2.embedIframeRef,
|
|
344
|
+
embedIframeUrlType = _ref2.embedIframeUrlType,
|
|
345
|
+
inlinePreloaderStyle = _ref2.inlinePreloaderStyle,
|
|
346
|
+
ui = _ref2.ui,
|
|
347
|
+
children = _ref2.children,
|
|
348
|
+
showHoverPreview = _ref2.showHoverPreview,
|
|
349
|
+
hoverPreviewOptions = _ref2.hoverPreviewOptions,
|
|
350
|
+
removeTextHighlightingFromTitle = _ref2.removeTextHighlightingFromTitle,
|
|
351
|
+
resolvingPlaceholder = _ref2.resolvingPlaceholder,
|
|
352
|
+
truncateInline = _ref2.truncateInline,
|
|
353
|
+
CompetitorPrompt = _ref2.CompetitorPrompt,
|
|
354
|
+
hideIconLoadingSkeleton = _ref2.hideIconLoadingSkeleton,
|
|
355
|
+
disablePreviewPanel = _ref2.disablePreviewPanel,
|
|
356
|
+
placeholderData = _ref2.placeholderData;
|
|
357
|
+
var _useAnalyticsEventsNe2 = useAnalyticsEventsNext(),
|
|
358
|
+
createAnalyticsEvent = _useAnalyticsEventsNe2.createAnalyticsEvent;
|
|
359
|
+
var _useAnalyticsEvents2 = useAnalyticsEvents(),
|
|
360
|
+
fireEvent = _useAnalyticsEvents2.fireEvent;
|
|
361
|
+
var isFlexibleUi = useMemo(function () {
|
|
362
|
+
return isFlexibleUiCard(children, ui);
|
|
363
|
+
}, [children, ui]);
|
|
364
|
+
|
|
365
|
+
// Get state, actions for this card.
|
|
366
|
+
var _useSmartLink2 = useSmartLink(id, url),
|
|
367
|
+
state = _useSmartLink2.state,
|
|
368
|
+
actions = _useSmartLink2.actions,
|
|
369
|
+
config = _useSmartLink2.config,
|
|
370
|
+
renderers = _useSmartLink2.renderers,
|
|
371
|
+
error = _useSmartLink2.error,
|
|
372
|
+
isPreviewPanelAvailable = _useSmartLink2.isPreviewPanelAvailable,
|
|
373
|
+
openPreviewPanel = _useSmartLink2.openPreviewPanel;
|
|
374
|
+
var ari = getObjectAri(state.details);
|
|
375
|
+
var name = getObjectName(state.details);
|
|
376
|
+
var definitionId = getDefinitionId(state.details);
|
|
377
|
+
var extensionKey = getExtensionKey(state.details);
|
|
378
|
+
var resourceType = getResourceType(state.details);
|
|
379
|
+
var services = getServices(state.details);
|
|
380
|
+
var thirdPartyARI = getThirdPartyARI(state.details);
|
|
381
|
+
var firstPartyIdentifier = getFirstPartyIdentifier();
|
|
382
|
+
var actionOptions = combineActionOptions({
|
|
383
|
+
actionOptions: actionOptionsProp,
|
|
384
|
+
platform: platform
|
|
385
|
+
});
|
|
386
|
+
var fire3PClickEvent = fg('platform_smartlink_3pclick_analytics') ?
|
|
387
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
388
|
+
useFire3PWorkflowsClickEvent(firstPartyIdentifier, thirdPartyARI) : undefined;
|
|
389
|
+
|
|
390
|
+
// Setup UI handlers.
|
|
391
|
+
var handleClickWrapper = useCallback(function (event) {
|
|
392
|
+
var isModifierKeyPressed = isSpecialKey(event) || isSpecialClick(event);
|
|
393
|
+
fireEvent('ui.smartLink.clicked', {
|
|
394
|
+
id: id,
|
|
395
|
+
display: isFlexibleUi ? CardDisplay.Flexible : appearance,
|
|
396
|
+
definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
|
|
397
|
+
isModifierKeyPressed: isModifierKeyPressed
|
|
398
|
+
});
|
|
399
|
+
if (fg('platform_smartlink_3pclick_analytics')) {
|
|
400
|
+
if (thirdPartyARI && thirdPartyARI.startsWith(thirdPartyARIPrefix)) {
|
|
401
|
+
var clickURL = getClickUrl(url, state.details);
|
|
402
|
+
if (clickURL === url && fire3PClickEvent) {
|
|
403
|
+
// For questions or concerns about this event,
|
|
404
|
+
// please reach out to the 3P Workflows Team via Slack in #help-3p-connector-workflow
|
|
405
|
+
fire3PClickEvent();
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
var isDisablePreviewPanel = disablePreviewPanel && editorExperiment('platform_editor_preview_panel_linking_exp', true, {
|
|
410
|
+
exposure: true
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
// If preview panel is available and the user clicked on the link,
|
|
414
|
+
// delegate the click to the preview panel handler
|
|
415
|
+
if (!isModifierKeyPressed && ari && name && openPreviewPanel && isPreviewPanelAvailable !== null && isPreviewPanelAvailable !== void 0 && isPreviewPanelAvailable({
|
|
416
|
+
ari: ari
|
|
417
|
+
}) && !isDisablePreviewPanel) {
|
|
418
|
+
var _extractSmartLinkEmbe2;
|
|
419
|
+
event.preventDefault();
|
|
420
|
+
event.stopPropagation();
|
|
421
|
+
openPreviewPanel({
|
|
422
|
+
url: url,
|
|
423
|
+
ari: ari,
|
|
424
|
+
name: name,
|
|
425
|
+
iconUrl: getObjectIconUrl(state.details),
|
|
426
|
+
panelData: {
|
|
427
|
+
embedUrl: expValEquals('platform_hover_card_preview_panel', 'cohort', 'test') ? (_extractSmartLinkEmbe2 = extractSmartLinkEmbed(state.details)) === null || _extractSmartLinkEmbe2 === void 0 ? void 0 : _extractSmartLinkEmbe2.src : undefined
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
fireLinkClickedEvent(createAnalyticsEvent)(event, {
|
|
431
|
+
attributes: {
|
|
432
|
+
clickOutcome: 'previewPanel'
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
return;
|
|
436
|
+
} else if (!onClick && !isFlexibleUi) {
|
|
437
|
+
var clickUrl = getClickUrl(url, state.details);
|
|
438
|
+
|
|
439
|
+
// Ctrl+left click on mac typically doesn't trigger onClick
|
|
440
|
+
// The event could have potentially had `e.preventDefault()` called on it by now
|
|
441
|
+
// event by smart card internally
|
|
442
|
+
// If it has been called then only then can `isSpecialEvent` be true.
|
|
443
|
+
var target = isSpecialEvent(event) ? '_blank' : '_self';
|
|
444
|
+
window.open(clickUrl, target);
|
|
445
|
+
fireLinkClickedEvent(createAnalyticsEvent)(event, {
|
|
446
|
+
attributes: {
|
|
447
|
+
clickOutcome: target === '_blank' ? 'clickThroughNewTabOrWindow' : 'clickThrough'
|
|
448
|
+
}
|
|
449
|
+
});
|
|
450
|
+
} else {
|
|
451
|
+
if (onClick) {
|
|
452
|
+
onClick(event);
|
|
453
|
+
}
|
|
454
|
+
fireLinkClickedEvent(createAnalyticsEvent)(event);
|
|
455
|
+
}
|
|
456
|
+
}, [fireEvent, id, isFlexibleUi, appearance, definitionId, onClick, url, state.details, ari, name, fire3PClickEvent, isPreviewPanelAvailable, openPreviewPanel, createAnalyticsEvent, thirdPartyARI, disablePreviewPanel]);
|
|
457
|
+
var handleAuthorize = useCallback(function () {
|
|
458
|
+
return actions.authorize(appearance);
|
|
459
|
+
}, [actions, appearance]);
|
|
460
|
+
var handleRetry = useCallback(function () {
|
|
461
|
+
actions.reload();
|
|
462
|
+
}, [actions]);
|
|
463
|
+
var handleInvoke = useCallback(function (opts) {
|
|
464
|
+
return actions.invoke(opts, appearance);
|
|
465
|
+
}, [actions, appearance]);
|
|
466
|
+
|
|
467
|
+
// NB: for each status change in a Smart Link, a performance mark is created.
|
|
468
|
+
// Measures are sent relative to the first mark, matching what a user sees.
|
|
469
|
+
useEffect(function () {
|
|
470
|
+
measure.mark(id, state.status);
|
|
471
|
+
if (state.status !== 'pending' && state.status !== 'resolving') {
|
|
472
|
+
var _state$error3, _state$error4;
|
|
473
|
+
measure.create(id, state.status);
|
|
474
|
+
if (state.status === 'resolved') {
|
|
475
|
+
var _measure$getMeasure$d2, _measure$getMeasure2;
|
|
476
|
+
fireEvent('operational.smartLink.resolved', {
|
|
477
|
+
definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
|
|
478
|
+
duration: (_measure$getMeasure$d2 = (_measure$getMeasure2 = measure.getMeasure(id, state.status)) === null || _measure$getMeasure2 === void 0 ? void 0 : _measure$getMeasure2.duration) !== null && _measure$getMeasure$d2 !== void 0 ? _measure$getMeasure$d2 : null
|
|
479
|
+
});
|
|
480
|
+
} else if (((_state$error3 = state.error) === null || _state$error3 === void 0 ? void 0 : _state$error3.type) !== 'ResolveUnsupportedError' && ((_state$error4 = state.error) === null || _state$error4 === void 0 ? void 0 : _state$error4.type) !== 'UnsupportedError') {
|
|
481
|
+
fireEvent('operational.smartLink.unresolved', {
|
|
482
|
+
definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
|
|
483
|
+
reason: state.status,
|
|
484
|
+
error: state.error === undefined ? null : {
|
|
485
|
+
name: state.error.name,
|
|
486
|
+
kind: state.error.kind,
|
|
487
|
+
type: state.error.type
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}, [id, appearance, state.status, state.error, definitionId, extensionKey, resourceType, fireEvent]);
|
|
493
|
+
|
|
494
|
+
// NB: once the smart-card has rendered into an end state, we capture
|
|
495
|
+
// this as a successful render. These can be one of:
|
|
496
|
+
// - the resolved state: when metadata is shown;
|
|
497
|
+
// - the unresolved states: viz. forbidden, not_found, unauthorized, errored.
|
|
498
|
+
useEffect(function () {
|
|
499
|
+
if (isFinalState(state.status)) {
|
|
500
|
+
succeedUfoExperience('smart-link-rendered', id || 'NULL', {
|
|
501
|
+
extensionKey: extensionKey,
|
|
502
|
+
display: isFlexibleUi ? 'flexible' : appearance
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
// UFO will disregard this if authentication experience has not yet been started
|
|
506
|
+
succeedUfoExperience('smart-link-authenticated', id || 'NULL', {
|
|
507
|
+
display: isFlexibleUi ? 'flexible' : appearance
|
|
508
|
+
});
|
|
509
|
+
fireEvent('ui.smartLink.renderSuccess', {
|
|
510
|
+
display: isFlexibleUi ? 'flexible' : appearance
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
}, [appearance, extensionKey, fireEvent, id, isFlexibleUi, state.status]);
|
|
514
|
+
var onIframeDwell = useCallback(function (dwellTime, dwellPercentVisible) {
|
|
515
|
+
fireEvent('ui.smartLinkIframe.dwelled', {
|
|
516
|
+
id: id,
|
|
517
|
+
definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
|
|
518
|
+
display: isFlexibleUi ? 'flexible' : appearance,
|
|
519
|
+
dwellPercentVisible: dwellPercentVisible,
|
|
520
|
+
dwellTime: dwellTime
|
|
521
|
+
});
|
|
522
|
+
}, [id, appearance, definitionId, isFlexibleUi, fireEvent]);
|
|
523
|
+
var onIframeFocus = useCallback(function () {
|
|
524
|
+
fireEvent('ui.smartLinkIframe.focused', {
|
|
525
|
+
id: id,
|
|
526
|
+
definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
|
|
527
|
+
display: isFlexibleUi ? 'flexible' : appearance,
|
|
528
|
+
interactionType: 'focus'
|
|
529
|
+
});
|
|
530
|
+
}, [id, appearance, definitionId, isFlexibleUi, fireEvent]);
|
|
531
|
+
var onIframeMouseEnter = useCallback(function () {
|
|
532
|
+
fireEvent('ui.smartLinkIframe.focused', {
|
|
533
|
+
id: id,
|
|
534
|
+
definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
|
|
535
|
+
display: isFlexibleUi ? 'flexible' : appearance,
|
|
536
|
+
interactionType: 'mouseenter'
|
|
537
|
+
});
|
|
538
|
+
}, [id, appearance, definitionId, isFlexibleUi, fireEvent]);
|
|
539
|
+
var onIframeMouseLeave = useCallback(function () {
|
|
540
|
+
fireEvent('ui.smartLinkIframe.focused', {
|
|
541
|
+
id: id,
|
|
542
|
+
definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
|
|
543
|
+
display: isFlexibleUi ? 'flexible' : appearance,
|
|
544
|
+
interactionType: 'mouseleave'
|
|
545
|
+
});
|
|
546
|
+
}, [id, appearance, definitionId, isFlexibleUi, fireEvent]);
|
|
547
|
+
if (isFlexibleUi) {
|
|
548
|
+
var cardState = state;
|
|
549
|
+
if (error) {
|
|
550
|
+
if ((error === null || error === void 0 ? void 0 : error.name) === 'APIError') {
|
|
551
|
+
cardState = {
|
|
552
|
+
status: 'errored'
|
|
553
|
+
};
|
|
554
|
+
} else {
|
|
555
|
+
throw error;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
return /*#__PURE__*/React.createElement(FlexibleCard, {
|
|
559
|
+
id: id,
|
|
560
|
+
cardState: cardState,
|
|
561
|
+
placeholderData: fg('platform_initial_data_for_smart_cards') ? placeholderData : undefined,
|
|
562
|
+
onAuthorize: services.length && handleAuthorize || undefined,
|
|
563
|
+
onClick: handleClickWrapper,
|
|
564
|
+
origin: "smartLinkCard",
|
|
565
|
+
renderers: renderers,
|
|
566
|
+
ui: ui,
|
|
567
|
+
showHoverPreview: showHoverPreview,
|
|
568
|
+
hoverPreviewOptions: hoverPreviewOptions,
|
|
569
|
+
actionOptions: actionOptions,
|
|
570
|
+
url: url,
|
|
571
|
+
testId: testId,
|
|
572
|
+
onResolve: onResolve,
|
|
573
|
+
onError: onError
|
|
574
|
+
}, children);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
// We have to keep this last to prevent hook order from being violated
|
|
578
|
+
if (error) {
|
|
579
|
+
throw error;
|
|
580
|
+
}
|
|
581
|
+
switch (appearance) {
|
|
582
|
+
case 'inline':
|
|
583
|
+
return /*#__PURE__*/React.createElement(InlineCard, {
|
|
584
|
+
id: id,
|
|
585
|
+
url: url,
|
|
586
|
+
renderers: renderers,
|
|
587
|
+
cardState: state,
|
|
588
|
+
handleAuthorize: services.length && handleAuthorize || undefined,
|
|
589
|
+
handleFrameClick: handleClickWrapper,
|
|
590
|
+
isSelected: isSelected,
|
|
591
|
+
isHovered: isHovered,
|
|
592
|
+
onResolve: onResolve,
|
|
593
|
+
onError: onError,
|
|
594
|
+
testId: testId,
|
|
595
|
+
inlinePreloaderStyle: inlinePreloaderStyle,
|
|
596
|
+
showHoverPreview: showHoverPreview,
|
|
597
|
+
hoverPreviewOptions: hoverPreviewOptions,
|
|
598
|
+
actionOptions: actionOptions,
|
|
599
|
+
removeTextHighlightingFromTitle: removeTextHighlightingFromTitle,
|
|
600
|
+
resolvingPlaceholder: resolvingPlaceholder,
|
|
601
|
+
truncateInline: truncateInline,
|
|
602
|
+
hideIconLoadingSkeleton: hideIconLoadingSkeleton
|
|
603
|
+
});
|
|
604
|
+
case 'block':
|
|
605
|
+
return /*#__PURE__*/React.createElement(BlockCard, {
|
|
606
|
+
id: id,
|
|
607
|
+
url: url,
|
|
608
|
+
renderers: renderers,
|
|
609
|
+
authFlow: config && config.authFlow,
|
|
610
|
+
cardState: state,
|
|
611
|
+
handleAuthorize: services.length && handleAuthorize || undefined,
|
|
612
|
+
handleFrameClick: handleClickWrapper,
|
|
613
|
+
isSelected: isSelected,
|
|
614
|
+
onResolve: onResolve,
|
|
615
|
+
onError: onError,
|
|
616
|
+
testId: testId,
|
|
617
|
+
actionOptions: actionOptions,
|
|
618
|
+
CompetitorPrompt: CompetitorPrompt,
|
|
619
|
+
hideIconLoadingSkeleton: hideIconLoadingSkeleton
|
|
620
|
+
});
|
|
621
|
+
case 'embed':
|
|
622
|
+
return /*#__PURE__*/React.createElement(EmbedCardComponent, {
|
|
623
|
+
id: id,
|
|
624
|
+
url: url,
|
|
625
|
+
renderers: renderers,
|
|
626
|
+
cardState: state,
|
|
627
|
+
iframeUrlType: embedIframeUrlType,
|
|
628
|
+
handleAuthorize: services.length && handleAuthorize || undefined,
|
|
629
|
+
handleErrorRetry: handleRetry,
|
|
630
|
+
handleFrameClick: handleClickWrapper,
|
|
631
|
+
handleInvoke: handleInvoke,
|
|
632
|
+
isSelected: isSelected,
|
|
633
|
+
frameStyle: frameStyle,
|
|
634
|
+
platform: platform,
|
|
635
|
+
onResolve: onResolve,
|
|
636
|
+
onError: onError,
|
|
637
|
+
testId: testId,
|
|
638
|
+
inheritDimensions: inheritDimensions,
|
|
639
|
+
actionOptions: actionOptions,
|
|
640
|
+
ref: embedIframeRef,
|
|
641
|
+
onIframeDwell: onIframeDwell,
|
|
642
|
+
onIframeFocus: onIframeFocus,
|
|
643
|
+
onIframeMouseEnter: onIframeMouseEnter,
|
|
644
|
+
onIframeMouseLeave: onIframeMouseLeave,
|
|
645
|
+
CompetitorPrompt: CompetitorPrompt,
|
|
646
|
+
hideIconLoadingSkeleton: hideIconLoadingSkeleton
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
var CardWithUrlContentComponent = componentWithFG('rovo_chat_embed_card_dwell_and_hover_metrics', ComponentUpdated, Component);
|
|
327
651
|
export var CardWithUrlContent = function CardWithUrlContent(props) {
|
|
328
652
|
var display = isFlexibleUiCard(props.children, props === null || props === void 0 ? void 0 : props.ui) ? CardDisplay.Flexible : props.appearance;
|
|
329
653
|
return /*#__PURE__*/React.createElement(SmartLinkModalProvider, null, /*#__PURE__*/React.createElement(SmartLinkAnalyticsContext, {
|
|
330
654
|
url: props.url,
|
|
331
655
|
id: props.id,
|
|
332
656
|
display: display
|
|
333
|
-
}, /*#__PURE__*/React.createElement(
|
|
657
|
+
}, /*#__PURE__*/React.createElement(CardWithUrlContentComponent, props)));
|
|
334
658
|
};
|