@atlaskit/smart-card 43.11.3 → 43.12.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 +15 -0
- package/analytics.spec.yaml +7 -1
- package/dist/cjs/utils/analytics/analytics.js +1 -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/cjs/view/EmbedCard/views/not-found-view/not-found-svg/index.js +5 -1
- 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 +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/es2019/view/EmbedCard/views/not-found-view/not-found-svg/index.js +5 -1
- 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 +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/esm/view/EmbedCard/views/not-found-view/not-found-svg/index.js +5 -1
- package/dist/esm/view/LinkUrl/index.js +1 -1
- 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 +8 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/smart-card
|
|
2
2
|
|
|
3
|
+
## 43.12.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`7ae944d7f3cd6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7ae944d7f3cd6) -
|
|
8
|
+
NAVX-2825 Fixing no-literal-string-in-jsx violations in linking platform
|
|
9
|
+
|
|
10
|
+
## 43.12.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- [`ad5cf8dbae112`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ad5cf8dbae112) -
|
|
15
|
+
[ux] Added analytics for mouse enter and leave using existing analytics and fixing issue with
|
|
16
|
+
sending embedCard dwell analytics
|
|
17
|
+
|
|
3
18
|
## 43.11.3
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/analytics.spec.yaml
CHANGED
|
@@ -343,6 +343,11 @@ events:
|
|
|
343
343
|
required: false
|
|
344
344
|
type: string
|
|
345
345
|
description: The definitionId of the Smart Link resolver invoked.
|
|
346
|
+
interactionType:
|
|
347
|
+
required: false
|
|
348
|
+
type: ['mouseenter', 'mouseleave', 'focus']
|
|
349
|
+
description:
|
|
350
|
+
The type of interaction that triggered this event - mouse enter, mouse leave, or focus.
|
|
346
351
|
- applicationAccount connected:
|
|
347
352
|
type: track
|
|
348
353
|
description: user connecting their account to view a Smart Link.
|
|
@@ -616,7 +621,8 @@ events:
|
|
|
616
621
|
description: Whether a modifier key was pressed when clicking the Smart Link.
|
|
617
622
|
- smartLink clicked (previewHoverCard):
|
|
618
623
|
type: ui
|
|
619
|
-
description:
|
|
624
|
+
description:
|
|
625
|
+
fires an event that represents when a user clicks on a Smart Link to open a preview panel.
|
|
620
626
|
attributes:
|
|
621
627
|
<<: [*PackageMetaDataContext, *CommonContext, *ResolvedContext]
|
|
622
628
|
id:
|
|
@@ -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: "
|
|
14
|
+
packageVersion: "43.12.0"
|
|
15
15
|
};
|
|
16
16
|
var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
17
17
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -10,9 +10,10 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
10
10
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
11
11
|
var _linkExtractors = require("@atlaskit/link-extractors");
|
|
12
12
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
|
+
var _platformFeatureFlagsReact = require("@atlaskit/platform-feature-flags-react");
|
|
13
14
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
14
15
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
15
|
-
var
|
|
16
|
+
var _useAnalyticsEvents3 = require("../../common/analytics/generated/use-analytics-events");
|
|
16
17
|
var _constants = require("../../constants");
|
|
17
18
|
var _state = require("../../state");
|
|
18
19
|
var _analytics = require("../../state/analytics");
|
|
@@ -31,6 +32,7 @@ var _InlineCard = require("../InlineCard");
|
|
|
31
32
|
var _useSmartLinkEvents = require("../SmartLinkEvents/useSmartLinkEvents");
|
|
32
33
|
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); }
|
|
33
34
|
var thirdPartyARIPrefix = 'ari:third-party';
|
|
35
|
+
var EmbedCardComponent = (0, _platformFeatureFlagsReact.componentWithFG)('rovo_chat_embed_card_dwell_and_hover_metrics', _EmbedCard.EmbedCardUpdated, _EmbedCard.EmbedCard);
|
|
34
36
|
function Component(_ref) {
|
|
35
37
|
var id = _ref.id,
|
|
36
38
|
url = _ref.url,
|
|
@@ -61,7 +63,7 @@ function Component(_ref) {
|
|
|
61
63
|
placeholderData = _ref.placeholderData;
|
|
62
64
|
var _useAnalyticsEventsNe = (0, _analyticsNext.useAnalyticsEvents)(),
|
|
63
65
|
createAnalyticsEvent = _useAnalyticsEventsNe.createAnalyticsEvent;
|
|
64
|
-
var _useAnalyticsEvents = (0,
|
|
66
|
+
var _useAnalyticsEvents = (0, _useAnalyticsEvents3.useAnalyticsEvents)(),
|
|
65
67
|
fireEvent = _useAnalyticsEvents.fireEvent;
|
|
66
68
|
var isFlexibleUi = (0, _react.useMemo)(function () {
|
|
67
69
|
return (0, _flexible.isFlexibleUiCard)(children, ui);
|
|
@@ -333,11 +335,333 @@ function Component(_ref) {
|
|
|
333
335
|
});
|
|
334
336
|
}
|
|
335
337
|
}
|
|
338
|
+
function ComponentUpdated(_ref2) {
|
|
339
|
+
var id = _ref2.id,
|
|
340
|
+
url = _ref2.url,
|
|
341
|
+
isSelected = _ref2.isSelected,
|
|
342
|
+
isHovered = _ref2.isHovered,
|
|
343
|
+
frameStyle = _ref2.frameStyle,
|
|
344
|
+
platform = _ref2.platform,
|
|
345
|
+
onClick = _ref2.onClick,
|
|
346
|
+
appearance = _ref2.appearance,
|
|
347
|
+
onResolve = _ref2.onResolve,
|
|
348
|
+
onError = _ref2.onError,
|
|
349
|
+
testId = _ref2.testId,
|
|
350
|
+
actionOptionsProp = _ref2.actionOptions,
|
|
351
|
+
inheritDimensions = _ref2.inheritDimensions,
|
|
352
|
+
embedIframeRef = _ref2.embedIframeRef,
|
|
353
|
+
embedIframeUrlType = _ref2.embedIframeUrlType,
|
|
354
|
+
inlinePreloaderStyle = _ref2.inlinePreloaderStyle,
|
|
355
|
+
ui = _ref2.ui,
|
|
356
|
+
children = _ref2.children,
|
|
357
|
+
showHoverPreview = _ref2.showHoverPreview,
|
|
358
|
+
hoverPreviewOptions = _ref2.hoverPreviewOptions,
|
|
359
|
+
removeTextHighlightingFromTitle = _ref2.removeTextHighlightingFromTitle,
|
|
360
|
+
resolvingPlaceholder = _ref2.resolvingPlaceholder,
|
|
361
|
+
truncateInline = _ref2.truncateInline,
|
|
362
|
+
CompetitorPrompt = _ref2.CompetitorPrompt,
|
|
363
|
+
hideIconLoadingSkeleton = _ref2.hideIconLoadingSkeleton,
|
|
364
|
+
disablePreviewPanel = _ref2.disablePreviewPanel,
|
|
365
|
+
placeholderData = _ref2.placeholderData;
|
|
366
|
+
var _useAnalyticsEventsNe2 = (0, _analyticsNext.useAnalyticsEvents)(),
|
|
367
|
+
createAnalyticsEvent = _useAnalyticsEventsNe2.createAnalyticsEvent;
|
|
368
|
+
var _useAnalyticsEvents2 = (0, _useAnalyticsEvents3.useAnalyticsEvents)(),
|
|
369
|
+
fireEvent = _useAnalyticsEvents2.fireEvent;
|
|
370
|
+
var isFlexibleUi = (0, _react.useMemo)(function () {
|
|
371
|
+
return (0, _flexible.isFlexibleUiCard)(children, ui);
|
|
372
|
+
}, [children, ui]);
|
|
373
|
+
|
|
374
|
+
// Get state, actions for this card.
|
|
375
|
+
var _useSmartLink2 = (0, _state.useSmartLink)(id, url),
|
|
376
|
+
state = _useSmartLink2.state,
|
|
377
|
+
actions = _useSmartLink2.actions,
|
|
378
|
+
config = _useSmartLink2.config,
|
|
379
|
+
renderers = _useSmartLink2.renderers,
|
|
380
|
+
error = _useSmartLink2.error,
|
|
381
|
+
isPreviewPanelAvailable = _useSmartLink2.isPreviewPanelAvailable,
|
|
382
|
+
openPreviewPanel = _useSmartLink2.openPreviewPanel;
|
|
383
|
+
var ari = (0, _helpers.getObjectAri)(state.details);
|
|
384
|
+
var name = (0, _helpers.getObjectName)(state.details);
|
|
385
|
+
var definitionId = (0, _helpers.getDefinitionId)(state.details);
|
|
386
|
+
var extensionKey = (0, _helpers.getExtensionKey)(state.details);
|
|
387
|
+
var resourceType = (0, _helpers.getResourceType)(state.details);
|
|
388
|
+
var services = (0, _helpers.getServices)(state.details);
|
|
389
|
+
var thirdPartyARI = (0, _helpers.getThirdPartyARI)(state.details);
|
|
390
|
+
var firstPartyIdentifier = (0, _helpers.getFirstPartyIdentifier)();
|
|
391
|
+
var actionOptions = (0, _combineActionOptions.combineActionOptions)({
|
|
392
|
+
actionOptions: actionOptionsProp,
|
|
393
|
+
platform: platform
|
|
394
|
+
});
|
|
395
|
+
var fire3PClickEvent = (0, _platformFeatureFlags.fg)('platform_smartlink_3pclick_analytics') ?
|
|
396
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
397
|
+
(0, _useSmartLinkEvents.useFire3PWorkflowsClickEvent)(firstPartyIdentifier, thirdPartyARI) : undefined;
|
|
398
|
+
|
|
399
|
+
// Setup UI handlers.
|
|
400
|
+
var handleClickWrapper = (0, _react.useCallback)(function (event) {
|
|
401
|
+
var isModifierKeyPressed = (0, _utils.isSpecialKey)(event) || (0, _utils.isSpecialClick)(event);
|
|
402
|
+
fireEvent('ui.smartLink.clicked', {
|
|
403
|
+
id: id,
|
|
404
|
+
display: isFlexibleUi ? _constants.CardDisplay.Flexible : appearance,
|
|
405
|
+
definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
|
|
406
|
+
isModifierKeyPressed: isModifierKeyPressed
|
|
407
|
+
});
|
|
408
|
+
if ((0, _platformFeatureFlags.fg)('platform_smartlink_3pclick_analytics')) {
|
|
409
|
+
if (thirdPartyARI && thirdPartyARI.startsWith(thirdPartyARIPrefix)) {
|
|
410
|
+
var clickURL = (0, _helpers.getClickUrl)(url, state.details);
|
|
411
|
+
if (clickURL === url && fire3PClickEvent) {
|
|
412
|
+
// For questions or concerns about this event,
|
|
413
|
+
// please reach out to the 3P Workflows Team via Slack in #help-3p-connector-workflow
|
|
414
|
+
fire3PClickEvent();
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
var isDisablePreviewPanel = disablePreviewPanel && (0, _experiments.editorExperiment)('platform_editor_preview_panel_linking_exp', true, {
|
|
419
|
+
exposure: true
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
// If preview panel is available and the user clicked on the link,
|
|
423
|
+
// delegate the click to the preview panel handler
|
|
424
|
+
if (!isModifierKeyPressed && ari && name && openPreviewPanel && isPreviewPanelAvailable !== null && isPreviewPanelAvailable !== void 0 && isPreviewPanelAvailable({
|
|
425
|
+
ari: ari
|
|
426
|
+
}) && !isDisablePreviewPanel) {
|
|
427
|
+
var _extractSmartLinkEmbe2;
|
|
428
|
+
event.preventDefault();
|
|
429
|
+
event.stopPropagation();
|
|
430
|
+
openPreviewPanel({
|
|
431
|
+
url: url,
|
|
432
|
+
ari: ari,
|
|
433
|
+
name: name,
|
|
434
|
+
iconUrl: (0, _helpers.getObjectIconUrl)(state.details),
|
|
435
|
+
panelData: {
|
|
436
|
+
embedUrl: (0, _expValEquals.expValEquals)('platform_hover_card_preview_panel', 'cohort', 'test') ? (_extractSmartLinkEmbe2 = (0, _linkExtractors.extractSmartLinkEmbed)(state.details)) === null || _extractSmartLinkEmbe2 === void 0 ? void 0 : _extractSmartLinkEmbe2.src : undefined
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
(0, _click.fireLinkClickedEvent)(createAnalyticsEvent)(event, {
|
|
440
|
+
attributes: {
|
|
441
|
+
clickOutcome: 'previewPanel'
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
return;
|
|
445
|
+
} else if (!onClick && !isFlexibleUi) {
|
|
446
|
+
var clickUrl = (0, _helpers.getClickUrl)(url, state.details);
|
|
447
|
+
|
|
448
|
+
// Ctrl+left click on mac typically doesn't trigger onClick
|
|
449
|
+
// The event could have potentially had `e.preventDefault()` called on it by now
|
|
450
|
+
// event by smart card internally
|
|
451
|
+
// If it has been called then only then can `isSpecialEvent` be true.
|
|
452
|
+
var target = (0, _utils.isSpecialEvent)(event) ? '_blank' : '_self';
|
|
453
|
+
window.open(clickUrl, target);
|
|
454
|
+
(0, _click.fireLinkClickedEvent)(createAnalyticsEvent)(event, {
|
|
455
|
+
attributes: {
|
|
456
|
+
clickOutcome: target === '_blank' ? 'clickThroughNewTabOrWindow' : 'clickThrough'
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
} else {
|
|
460
|
+
if (onClick) {
|
|
461
|
+
onClick(event);
|
|
462
|
+
}
|
|
463
|
+
(0, _click.fireLinkClickedEvent)(createAnalyticsEvent)(event);
|
|
464
|
+
}
|
|
465
|
+
}, [fireEvent, id, isFlexibleUi, appearance, definitionId, onClick, url, state.details, ari, name, fire3PClickEvent, isPreviewPanelAvailable, openPreviewPanel, createAnalyticsEvent, thirdPartyARI, disablePreviewPanel]);
|
|
466
|
+
var handleAuthorize = (0, _react.useCallback)(function () {
|
|
467
|
+
return actions.authorize(appearance);
|
|
468
|
+
}, [actions, appearance]);
|
|
469
|
+
var handleRetry = (0, _react.useCallback)(function () {
|
|
470
|
+
actions.reload();
|
|
471
|
+
}, [actions]);
|
|
472
|
+
var handleInvoke = (0, _react.useCallback)(function (opts) {
|
|
473
|
+
return actions.invoke(opts, appearance);
|
|
474
|
+
}, [actions, appearance]);
|
|
475
|
+
|
|
476
|
+
// NB: for each status change in a Smart Link, a performance mark is created.
|
|
477
|
+
// Measures are sent relative to the first mark, matching what a user sees.
|
|
478
|
+
(0, _react.useEffect)(function () {
|
|
479
|
+
measure.mark(id, state.status);
|
|
480
|
+
if (state.status !== 'pending' && state.status !== 'resolving') {
|
|
481
|
+
var _state$error3, _state$error4;
|
|
482
|
+
measure.create(id, state.status);
|
|
483
|
+
if (state.status === 'resolved') {
|
|
484
|
+
var _measure$getMeasure$d2, _measure$getMeasure2;
|
|
485
|
+
fireEvent('operational.smartLink.resolved', {
|
|
486
|
+
definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
|
|
487
|
+
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
|
|
488
|
+
});
|
|
489
|
+
} 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') {
|
|
490
|
+
fireEvent('operational.smartLink.unresolved', {
|
|
491
|
+
definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
|
|
492
|
+
reason: state.status,
|
|
493
|
+
error: state.error === undefined ? null : {
|
|
494
|
+
name: state.error.name,
|
|
495
|
+
kind: state.error.kind,
|
|
496
|
+
type: state.error.type
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}, [id, appearance, state.status, state.error, definitionId, extensionKey, resourceType, fireEvent]);
|
|
502
|
+
|
|
503
|
+
// NB: once the smart-card has rendered into an end state, we capture
|
|
504
|
+
// this as a successful render. These can be one of:
|
|
505
|
+
// - the resolved state: when metadata is shown;
|
|
506
|
+
// - the unresolved states: viz. forbidden, not_found, unauthorized, errored.
|
|
507
|
+
(0, _react.useEffect)(function () {
|
|
508
|
+
if ((0, _helpers.isFinalState)(state.status)) {
|
|
509
|
+
(0, _analytics.succeedUfoExperience)('smart-link-rendered', id || 'NULL', {
|
|
510
|
+
extensionKey: extensionKey,
|
|
511
|
+
display: isFlexibleUi ? 'flexible' : appearance
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
// UFO will disregard this if authentication experience has not yet been started
|
|
515
|
+
(0, _analytics.succeedUfoExperience)('smart-link-authenticated', id || 'NULL', {
|
|
516
|
+
display: isFlexibleUi ? 'flexible' : appearance
|
|
517
|
+
});
|
|
518
|
+
fireEvent('ui.smartLink.renderSuccess', {
|
|
519
|
+
display: isFlexibleUi ? 'flexible' : appearance
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
}, [appearance, extensionKey, fireEvent, id, isFlexibleUi, state.status]);
|
|
523
|
+
var onIframeDwell = (0, _react.useCallback)(function (dwellTime, dwellPercentVisible) {
|
|
524
|
+
fireEvent('ui.smartLinkIframe.dwelled', {
|
|
525
|
+
id: id,
|
|
526
|
+
definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
|
|
527
|
+
display: isFlexibleUi ? 'flexible' : appearance,
|
|
528
|
+
dwellPercentVisible: dwellPercentVisible,
|
|
529
|
+
dwellTime: dwellTime
|
|
530
|
+
});
|
|
531
|
+
}, [id, appearance, definitionId, isFlexibleUi, fireEvent]);
|
|
532
|
+
var onIframeFocus = (0, _react.useCallback)(function () {
|
|
533
|
+
fireEvent('ui.smartLinkIframe.focused', {
|
|
534
|
+
id: id,
|
|
535
|
+
definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
|
|
536
|
+
display: isFlexibleUi ? 'flexible' : appearance,
|
|
537
|
+
interactionType: 'focus'
|
|
538
|
+
});
|
|
539
|
+
}, [id, appearance, definitionId, isFlexibleUi, fireEvent]);
|
|
540
|
+
var onIframeMouseEnter = (0, _react.useCallback)(function () {
|
|
541
|
+
fireEvent('ui.smartLinkIframe.focused', {
|
|
542
|
+
id: id,
|
|
543
|
+
definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
|
|
544
|
+
display: isFlexibleUi ? 'flexible' : appearance,
|
|
545
|
+
interactionType: 'mouseenter'
|
|
546
|
+
});
|
|
547
|
+
}, [id, appearance, definitionId, isFlexibleUi, fireEvent]);
|
|
548
|
+
var onIframeMouseLeave = (0, _react.useCallback)(function () {
|
|
549
|
+
fireEvent('ui.smartLinkIframe.focused', {
|
|
550
|
+
id: id,
|
|
551
|
+
definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
|
|
552
|
+
display: isFlexibleUi ? 'flexible' : appearance,
|
|
553
|
+
interactionType: 'mouseleave'
|
|
554
|
+
});
|
|
555
|
+
}, [id, appearance, definitionId, isFlexibleUi, fireEvent]);
|
|
556
|
+
if (isFlexibleUi) {
|
|
557
|
+
var cardState = state;
|
|
558
|
+
if (error) {
|
|
559
|
+
if ((error === null || error === void 0 ? void 0 : error.name) === 'APIError') {
|
|
560
|
+
cardState = {
|
|
561
|
+
status: 'errored'
|
|
562
|
+
};
|
|
563
|
+
} else {
|
|
564
|
+
throw error;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
return /*#__PURE__*/_react.default.createElement(_FlexibleCard.default, {
|
|
568
|
+
id: id,
|
|
569
|
+
cardState: cardState,
|
|
570
|
+
placeholderData: (0, _platformFeatureFlags.fg)('platform_initial_data_for_smart_cards') ? placeholderData : undefined,
|
|
571
|
+
onAuthorize: services.length && handleAuthorize || undefined,
|
|
572
|
+
onClick: handleClickWrapper,
|
|
573
|
+
origin: "smartLinkCard",
|
|
574
|
+
renderers: renderers,
|
|
575
|
+
ui: ui,
|
|
576
|
+
showHoverPreview: showHoverPreview,
|
|
577
|
+
hoverPreviewOptions: hoverPreviewOptions,
|
|
578
|
+
actionOptions: actionOptions,
|
|
579
|
+
url: url,
|
|
580
|
+
testId: testId,
|
|
581
|
+
onResolve: onResolve,
|
|
582
|
+
onError: onError
|
|
583
|
+
}, children);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
// We have to keep this last to prevent hook order from being violated
|
|
587
|
+
if (error) {
|
|
588
|
+
throw error;
|
|
589
|
+
}
|
|
590
|
+
switch (appearance) {
|
|
591
|
+
case 'inline':
|
|
592
|
+
return /*#__PURE__*/_react.default.createElement(_InlineCard.InlineCard, {
|
|
593
|
+
id: id,
|
|
594
|
+
url: url,
|
|
595
|
+
renderers: renderers,
|
|
596
|
+
cardState: state,
|
|
597
|
+
handleAuthorize: services.length && handleAuthorize || undefined,
|
|
598
|
+
handleFrameClick: handleClickWrapper,
|
|
599
|
+
isSelected: isSelected,
|
|
600
|
+
isHovered: isHovered,
|
|
601
|
+
onResolve: onResolve,
|
|
602
|
+
onError: onError,
|
|
603
|
+
testId: testId,
|
|
604
|
+
inlinePreloaderStyle: inlinePreloaderStyle,
|
|
605
|
+
showHoverPreview: showHoverPreview,
|
|
606
|
+
hoverPreviewOptions: hoverPreviewOptions,
|
|
607
|
+
actionOptions: actionOptions,
|
|
608
|
+
removeTextHighlightingFromTitle: removeTextHighlightingFromTitle,
|
|
609
|
+
resolvingPlaceholder: resolvingPlaceholder,
|
|
610
|
+
truncateInline: truncateInline,
|
|
611
|
+
hideIconLoadingSkeleton: hideIconLoadingSkeleton
|
|
612
|
+
});
|
|
613
|
+
case 'block':
|
|
614
|
+
return /*#__PURE__*/_react.default.createElement(_BlockCard.BlockCard, {
|
|
615
|
+
id: id,
|
|
616
|
+
url: url,
|
|
617
|
+
renderers: renderers,
|
|
618
|
+
authFlow: config && config.authFlow,
|
|
619
|
+
cardState: state,
|
|
620
|
+
handleAuthorize: services.length && handleAuthorize || undefined,
|
|
621
|
+
handleFrameClick: handleClickWrapper,
|
|
622
|
+
isSelected: isSelected,
|
|
623
|
+
onResolve: onResolve,
|
|
624
|
+
onError: onError,
|
|
625
|
+
testId: testId,
|
|
626
|
+
actionOptions: actionOptions,
|
|
627
|
+
CompetitorPrompt: CompetitorPrompt,
|
|
628
|
+
hideIconLoadingSkeleton: hideIconLoadingSkeleton
|
|
629
|
+
});
|
|
630
|
+
case 'embed':
|
|
631
|
+
return /*#__PURE__*/_react.default.createElement(EmbedCardComponent, {
|
|
632
|
+
id: id,
|
|
633
|
+
url: url,
|
|
634
|
+
renderers: renderers,
|
|
635
|
+
cardState: state,
|
|
636
|
+
iframeUrlType: embedIframeUrlType,
|
|
637
|
+
handleAuthorize: services.length && handleAuthorize || undefined,
|
|
638
|
+
handleErrorRetry: handleRetry,
|
|
639
|
+
handleFrameClick: handleClickWrapper,
|
|
640
|
+
handleInvoke: handleInvoke,
|
|
641
|
+
isSelected: isSelected,
|
|
642
|
+
frameStyle: frameStyle,
|
|
643
|
+
platform: platform,
|
|
644
|
+
onResolve: onResolve,
|
|
645
|
+
onError: onError,
|
|
646
|
+
testId: testId,
|
|
647
|
+
inheritDimensions: inheritDimensions,
|
|
648
|
+
actionOptions: actionOptions,
|
|
649
|
+
ref: embedIframeRef,
|
|
650
|
+
onIframeDwell: onIframeDwell,
|
|
651
|
+
onIframeFocus: onIframeFocus,
|
|
652
|
+
onIframeMouseEnter: onIframeMouseEnter,
|
|
653
|
+
onIframeMouseLeave: onIframeMouseLeave,
|
|
654
|
+
CompetitorPrompt: CompetitorPrompt,
|
|
655
|
+
hideIconLoadingSkeleton: hideIconLoadingSkeleton
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
var CardWithUrlContentComponent = (0, _platformFeatureFlagsReact.componentWithFG)('rovo_chat_embed_card_dwell_and_hover_metrics', ComponentUpdated, Component);
|
|
336
660
|
var CardWithUrlContent = exports.CardWithUrlContent = function CardWithUrlContent(props) {
|
|
337
661
|
var display = (0, _flexible.isFlexibleUiCard)(props.children, props === null || props === void 0 ? void 0 : props.ui) ? _constants.CardDisplay.Flexible : props.appearance;
|
|
338
662
|
return /*#__PURE__*/_react.default.createElement(_modal.SmartLinkModalProvider, null, /*#__PURE__*/_react.default.createElement(_SmartLinkAnalyticsContext.SmartLinkAnalyticsContext, {
|
|
339
663
|
url: props.url,
|
|
340
664
|
id: props.id,
|
|
341
665
|
display: display
|
|
342
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
666
|
+
}, /*#__PURE__*/_react.default.createElement(CardWithUrlContentComponent, props)));
|
|
343
667
|
};
|
|
@@ -12,12 +12,14 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
12
12
|
var _runtime = require("@compiled/react/runtime");
|
|
13
13
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
14
14
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
|
+
var _platformFeatureFlagsReact = require("@atlaskit/platform-feature-flags-react");
|
|
15
16
|
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
16
17
|
var _useLinkClicked = require("../../../state/analytics/useLinkClicked");
|
|
17
18
|
var _utils = require("../../common/utils");
|
|
18
19
|
var _styled = require("./styled");
|
|
19
20
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
20
|
-
|
|
21
|
+
// eslint-disable-next-line no-unused-vars
|
|
22
|
+
var ExpandedFrame = function ExpandedFrame(_ref) {
|
|
21
23
|
var _ref$isPlaceholder = _ref.isPlaceholder,
|
|
22
24
|
isPlaceholder = _ref$isPlaceholder === void 0 ? false : _ref$isPlaceholder,
|
|
23
25
|
children = _ref.children,
|
|
@@ -113,4 +115,93 @@ var styles = {
|
|
|
113
115
|
contentStyle: "_19itdlqj _2rko12b0 _1reo15vq _18m915vq _v56414au _bfhkhp5a _16jlkb7n _4t3i1osq _1pbykb7n",
|
|
114
116
|
contentInteractiveActiveBorder: "_1jhm1tt7",
|
|
115
117
|
contentOverflowAuto: "_1reo1wug _18m91wug"
|
|
116
|
-
};
|
|
118
|
+
};
|
|
119
|
+
var ExpandedFrameUpdated = function ExpandedFrameUpdated(_ref2) {
|
|
120
|
+
var _ref2$isPlaceholder = _ref2.isPlaceholder,
|
|
121
|
+
isPlaceholder = _ref2$isPlaceholder === void 0 ? false : _ref2$isPlaceholder,
|
|
122
|
+
children = _ref2.children,
|
|
123
|
+
onClick = _ref2.onClick,
|
|
124
|
+
icon = _ref2.icon,
|
|
125
|
+
text = _ref2.text,
|
|
126
|
+
isSelected = _ref2.isSelected,
|
|
127
|
+
_ref2$frameStyle = _ref2.frameStyle,
|
|
128
|
+
frameStyle = _ref2$frameStyle === void 0 ? 'showOnHover' : _ref2$frameStyle,
|
|
129
|
+
href = _ref2.href,
|
|
130
|
+
minWidth = _ref2.minWidth,
|
|
131
|
+
maxWidth = _ref2.maxWidth,
|
|
132
|
+
_ref2$testId = _ref2.testId,
|
|
133
|
+
testId = _ref2$testId === void 0 ? 'expanded-frame' : _ref2$testId,
|
|
134
|
+
inheritDimensions = _ref2.inheritDimensions,
|
|
135
|
+
_ref2$allowScrollBar = _ref2.allowScrollBar,
|
|
136
|
+
allowScrollBar = _ref2$allowScrollBar === void 0 ? false : _ref2$allowScrollBar,
|
|
137
|
+
_ref2$setOverflow = _ref2.setOverflow,
|
|
138
|
+
setOverflow = _ref2$setOverflow === void 0 ? true : _ref2$setOverflow,
|
|
139
|
+
CompetitorPrompt = _ref2.CompetitorPrompt,
|
|
140
|
+
onContentMouseEnter = _ref2.onContentMouseEnter,
|
|
141
|
+
onContentMouseLeave = _ref2.onContentMouseLeave;
|
|
142
|
+
var isInteractive = function isInteractive() {
|
|
143
|
+
return !isPlaceholder && (Boolean(href) || Boolean(onClick));
|
|
144
|
+
};
|
|
145
|
+
var handleClick = function handleClick(event) {
|
|
146
|
+
return (0, _utils.handleClickCommon)(event, onClick);
|
|
147
|
+
};
|
|
148
|
+
var handleMouseDown = (0, _useLinkClicked.useMouseDownEvent)();
|
|
149
|
+
|
|
150
|
+
// Note: cleanup fg based on results of prompt_whiteboard_competitor_link experiment
|
|
151
|
+
var CompetitorPromptComponent = CompetitorPrompt && href && (0, _platformFeatureFlags.fg)('prompt_whiteboard_competitor_link_gate') ? /*#__PURE__*/React.createElement(CompetitorPrompt, {
|
|
152
|
+
sourceUrl: href,
|
|
153
|
+
linkType: "embed"
|
|
154
|
+
}) : null;
|
|
155
|
+
var renderHeader = function renderHeader() {
|
|
156
|
+
return frameStyle !== 'hide' && /*#__PURE__*/React.createElement("div", {
|
|
157
|
+
className: (0, _runtime.ax)([styles.header, "embed-header"])
|
|
158
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
159
|
+
className: (0, _runtime.ax)([styles.leftSection])
|
|
160
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
161
|
+
className: (0, _runtime.ax)([styles.headerIcon])
|
|
162
|
+
}, icon), /*#__PURE__*/React.createElement("div", {
|
|
163
|
+
className: (0, _runtime.ax)([styles.tooltipWrapper])
|
|
164
|
+
}, !isPlaceholder && /*#__PURE__*/React.createElement(_tooltip.default, {
|
|
165
|
+
content: text,
|
|
166
|
+
hideTooltipOnMouseDown: true
|
|
167
|
+
}, /*#__PURE__*/React.createElement("a", {
|
|
168
|
+
href: href,
|
|
169
|
+
onClick: handleClick,
|
|
170
|
+
onMouseDown: handleMouseDown,
|
|
171
|
+
className: (0, _runtime.ax)([styles.headerAnchor])
|
|
172
|
+
}, text)))), CompetitorPromptComponent);
|
|
173
|
+
};
|
|
174
|
+
var interactive = isInteractive();
|
|
175
|
+
var showBackgroundAlways = frameStyle === 'show' || isSelected && frameStyle !== 'hide';
|
|
176
|
+
var showBackgroundOnHover = interactive && frameStyle !== 'hide';
|
|
177
|
+
var renderContent = function renderContent() {
|
|
178
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
179
|
+
"data-testid": "embed-content-wrapper",
|
|
180
|
+
// This fixes an issue with input fields in cross domain iframes (ie. databases and jira fields from different domains)
|
|
181
|
+
// See: HOT-107830
|
|
182
|
+
contentEditable: false,
|
|
183
|
+
onMouseEnter: onContentMouseEnter,
|
|
184
|
+
onMouseLeave: onContentMouseLeave,
|
|
185
|
+
onFocus: onContentMouseEnter,
|
|
186
|
+
onBlur: onContentMouseLeave,
|
|
187
|
+
className: (0, _runtime.ax)([styles.contentStyle, setOverflow && allowScrollBar && styles.contentOverflowAuto, interactive && !showBackgroundAlways && !showBackgroundOnHover && styles.contentInteractiveActiveBorder])
|
|
188
|
+
}, children);
|
|
189
|
+
};
|
|
190
|
+
return /*#__PURE__*/React.createElement("div", (0, _extends2.default)({
|
|
191
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
192
|
+
className: (0, _runtime.ax)([styles.linkWrapper, inheritDimensions && styles.linkWrapperInheritDimensions, isSelected && frameStyle !== 'hide' && styles.linkWrapperSelected, showBackgroundAlways && styles.linkWrapperBorderAndBackground, showBackgroundOnHover && !showBackgroundAlways && styles.linkWrapperInteractiveNotHidden, _styled.className]),
|
|
193
|
+
style: {
|
|
194
|
+
minWidth: minWidth ? "".concat(minWidth, "px") : '',
|
|
195
|
+
maxWidth: maxWidth ? "".concat(maxWidth, "px") : ''
|
|
196
|
+
},
|
|
197
|
+
"data-testid": testId,
|
|
198
|
+
"data-trello-do-not-use-override": testId
|
|
199
|
+
// Due to limitations of testing library, we can't assert ::after
|
|
200
|
+
,
|
|
201
|
+
"data-is-selected": isSelected
|
|
202
|
+
}, (isPlaceholder || !href) && {
|
|
203
|
+
'data-wrapper-type': 'default',
|
|
204
|
+
'data-is-interactive': isInteractive()
|
|
205
|
+
}), renderHeader(), renderContent());
|
|
206
|
+
};
|
|
207
|
+
var ExpandedFrameWithFG = exports.ExpandedFrame = (0, _platformFeatureFlagsReact.componentWithFG)('rovo_chat_embed_card_dwell_and_hover_metrics', ExpandedFrameUpdated, ExpandedFrame);
|
|
@@ -6,7 +6,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", {
|
|
7
7
|
value: true
|
|
8
8
|
});
|
|
9
|
-
exports.Frame = void 0;
|
|
9
|
+
exports.FrameUpdated = exports.Frame = void 0;
|
|
10
10
|
require("./Frame.compiled.css");
|
|
11
11
|
var _runtime = require("@compiled/react/runtime");
|
|
12
12
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
@@ -16,6 +16,7 @@ var _utils = require("../../../utils");
|
|
|
16
16
|
var _IFrame = require("./IFrame");
|
|
17
17
|
var _IframeDwellTracker = require("./IframeDwellTracker");
|
|
18
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); }
|
|
19
|
+
// eslint-disable-next-line no-unused-vars
|
|
19
20
|
function mergeRefs(refs) {
|
|
20
21
|
return function (value) {
|
|
21
22
|
refs.forEach(function (ref) {
|
|
@@ -112,10 +113,127 @@ var Frame = exports.Frame = /*#__PURE__*/_react.default.forwardRef(function (_re
|
|
|
112
113
|
"data-testid": "".concat(testId, "-frame"),
|
|
113
114
|
"data-iframe-loaded": isIframeLoaded,
|
|
114
115
|
onMouseEnter: function onMouseEnter() {
|
|
115
|
-
|
|
116
|
+
setMouseOver(true);
|
|
116
117
|
},
|
|
117
118
|
onMouseLeave: function onMouseLeave() {
|
|
118
|
-
|
|
119
|
+
setMouseOver(false);
|
|
120
|
+
},
|
|
121
|
+
allowFullScreen: true,
|
|
122
|
+
scrolling: "yes",
|
|
123
|
+
allow: "autoplay; encrypted-media; clipboard-write",
|
|
124
|
+
onLoad: function onLoad() {
|
|
125
|
+
setIframeLoaded(true);
|
|
126
|
+
},
|
|
127
|
+
sandbox: (0, _utils.getIframeSandboxAttribute)(isTrusted),
|
|
128
|
+
title: title,
|
|
129
|
+
extensionKey: extensionKey,
|
|
130
|
+
className: (0, _runtime.ax)(["_19itidpf _1reo15vq _18m915vq _2rkofajl _154iidpf _1ltvidpf _1bsb1osq _4t3i1osq _kqswh2mm"])
|
|
131
|
+
}));
|
|
132
|
+
});
|
|
133
|
+
var FrameUpdated = exports.FrameUpdated = /*#__PURE__*/_react.default.forwardRef(function (_ref2, iframeRef) {
|
|
134
|
+
var url = _ref2.url,
|
|
135
|
+
_ref2$isTrusted = _ref2.isTrusted,
|
|
136
|
+
isTrusted = _ref2$isTrusted === void 0 ? false : _ref2$isTrusted,
|
|
137
|
+
testId = _ref2.testId,
|
|
138
|
+
onIframeDwell = _ref2.onIframeDwell,
|
|
139
|
+
onIframeFocus = _ref2.onIframeFocus,
|
|
140
|
+
onIframeMouseEnter = _ref2.onIframeMouseEnter,
|
|
141
|
+
onIframeMouseLeave = _ref2.onIframeMouseLeave,
|
|
142
|
+
isMouseOverProp = _ref2.isMouseOver,
|
|
143
|
+
title = _ref2.title,
|
|
144
|
+
extensionKey = _ref2.extensionKey;
|
|
145
|
+
var _useState1 = (0, _react.useState)(false),
|
|
146
|
+
_useState10 = (0, _slicedToArray2.default)(_useState1, 2),
|
|
147
|
+
isIframeLoaded = _useState10[0],
|
|
148
|
+
setIframeLoaded = _useState10[1];
|
|
149
|
+
var _useState11 = (0, _react.useState)(false),
|
|
150
|
+
_useState12 = (0, _slicedToArray2.default)(_useState11, 2),
|
|
151
|
+
isMouseOver = _useState12[0],
|
|
152
|
+
setMouseOver = _useState12[1];
|
|
153
|
+
var _useState13 = (0, _react.useState)(document.hasFocus()),
|
|
154
|
+
_useState14 = (0, _slicedToArray2.default)(_useState13, 2),
|
|
155
|
+
isWindowFocused = _useState14[0],
|
|
156
|
+
setWindowFocused = _useState14[1];
|
|
157
|
+
|
|
158
|
+
// Use prop if provided (from wrapper), otherwise use local state (for backward compatibility)
|
|
159
|
+
var effectiveMouseOver = isMouseOverProp !== undefined ? isMouseOverProp : isMouseOver;
|
|
160
|
+
var ref = (0, _react.useRef)();
|
|
161
|
+
var mergedRef = mergeRefs([iframeRef, ref]);
|
|
162
|
+
var _useState15 = (0, _react.useState)(0),
|
|
163
|
+
_useState16 = (0, _slicedToArray2.default)(_useState15, 2),
|
|
164
|
+
percentVisible = _useState16[0],
|
|
165
|
+
setPercentVisible = _useState16[1];
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* These are the 'percent visible' thresholds at which the intersectionObserver will
|
|
169
|
+
* trigger a state change. Eg. when the user scrolls and moves from 74% to 76%, or
|
|
170
|
+
* vice versa. It's in a state object so that its static for the useEffect
|
|
171
|
+
*/
|
|
172
|
+
var _useState17 = (0, _react.useState)([0.75, 0.8, 0.85, 0.9, 0.95, 1]),
|
|
173
|
+
_useState18 = (0, _slicedToArray2.default)(_useState17, 1),
|
|
174
|
+
threshold = _useState18[0];
|
|
175
|
+
(0, _react.useEffect)(function () {
|
|
176
|
+
if (!ref || !ref.current) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
var observer = new IntersectionObserver(function (entries) {
|
|
180
|
+
entries.forEach(function (entry) {
|
|
181
|
+
setPercentVisible(entry === null || entry === void 0 ? void 0 : entry.intersectionRatio);
|
|
182
|
+
});
|
|
183
|
+
}, {
|
|
184
|
+
threshold: threshold
|
|
185
|
+
});
|
|
186
|
+
observer.observe(ref.current);
|
|
187
|
+
return function () {
|
|
188
|
+
observer.disconnect();
|
|
189
|
+
};
|
|
190
|
+
}, [threshold, mergedRef]);
|
|
191
|
+
(0, _react.useEffect)(function () {
|
|
192
|
+
// Initialize with current focus state
|
|
193
|
+
setWindowFocused(document.hasFocus());
|
|
194
|
+
var onBlur = function onBlur() {
|
|
195
|
+
setWindowFocused(false);
|
|
196
|
+
if (document.activeElement === ref.current) {
|
|
197
|
+
onIframeFocus && onIframeFocus();
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
var onFocus = function onFocus() {
|
|
201
|
+
setWindowFocused(true);
|
|
202
|
+
};
|
|
203
|
+
window.addEventListener('blur', onBlur);
|
|
204
|
+
window.addEventListener('focus', onFocus);
|
|
205
|
+
return function () {
|
|
206
|
+
window.removeEventListener('blur', onBlur);
|
|
207
|
+
window.removeEventListener('focus', onFocus);
|
|
208
|
+
};
|
|
209
|
+
}, [ref, onIframeFocus]);
|
|
210
|
+
if (!url) {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_IframeDwellTracker.IframeDwellTracker, {
|
|
214
|
+
isIframeLoaded: isIframeLoaded,
|
|
215
|
+
isMouseOver: effectiveMouseOver,
|
|
216
|
+
isWindowFocused: isWindowFocused,
|
|
217
|
+
iframePercentVisible: percentVisible,
|
|
218
|
+
onIframeDwell: onIframeDwell
|
|
219
|
+
}), /*#__PURE__*/_react.default.createElement(_IFrame.IFrame, {
|
|
220
|
+
childRef: mergedRef,
|
|
221
|
+
src: url,
|
|
222
|
+
"data-testid": "".concat(testId, "-frame"),
|
|
223
|
+
"data-iframe-loaded": isIframeLoaded,
|
|
224
|
+
onMouseEnter: function onMouseEnter() {
|
|
225
|
+
onIframeMouseEnter === null || onIframeMouseEnter === void 0 || onIframeMouseEnter();
|
|
226
|
+
// Use local state if prop not provided, otherwise prop takes precedence
|
|
227
|
+
if (isMouseOverProp === undefined) {
|
|
228
|
+
setMouseOver(true);
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
onMouseLeave: function onMouseLeave() {
|
|
232
|
+
onIframeMouseLeave === null || onIframeMouseLeave === void 0 || onIframeMouseLeave();
|
|
233
|
+
// Use local state if prop not provided, otherwise prop takes precedence
|
|
234
|
+
if (isMouseOverProp === undefined) {
|
|
235
|
+
setMouseOver(false);
|
|
236
|
+
}
|
|
119
237
|
},
|
|
120
238
|
allowFullScreen: true,
|
|
121
239
|
scrolling: "yes",
|