@atlaskit/smart-card 46.14.6 → 46.16.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/analytics.spec.yaml +2 -2
  3. package/dist/cjs/__tests__/vr-tests/bitbucket-favicon.svg +1 -0
  4. package/dist/cjs/utils/analytics/analytics.js +1 -1
  5. package/dist/cjs/utils/get-icon-for-file-type.js +6 -25
  6. package/dist/cjs/view/EmbedCard/views/ResolvedView.js +1 -20
  7. package/dist/cjs/view/FlexibleCard/components/actions/follow-action/index.js +5 -41
  8. package/dist/cjs/view/FlexibleCard/components/common/atlaskit-icon/index.js +3 -35
  9. package/dist/cjs/view/LinkUrl/index.js +1 -1
  10. package/dist/cjs/view/PreAuthValuePropositionModal/index.js +56 -110
  11. package/dist/cjs/view/PreAuthValuePropositionModal/use-pre-auth-value-proposition-modal.js +175 -0
  12. package/dist/es2019/__tests__/vr-tests/bitbucket-favicon.svg +1 -0
  13. package/dist/es2019/utils/analytics/analytics.js +1 -1
  14. package/dist/es2019/utils/get-icon-for-file-type.js +6 -19
  15. package/dist/es2019/view/EmbedCard/views/ResolvedView.js +1 -11
  16. package/dist/es2019/view/FlexibleCard/components/actions/follow-action/index.js +1 -26
  17. package/dist/es2019/view/FlexibleCard/components/common/atlaskit-icon/index.js +3 -29
  18. package/dist/es2019/view/LinkUrl/index.js +1 -1
  19. package/dist/es2019/view/PreAuthValuePropositionModal/index.js +54 -102
  20. package/dist/es2019/view/PreAuthValuePropositionModal/use-pre-auth-value-proposition-modal.js +160 -0
  21. package/dist/esm/__tests__/vr-tests/bitbucket-favicon.svg +1 -0
  22. package/dist/esm/utils/analytics/analytics.js +1 -1
  23. package/dist/esm/utils/get-icon-for-file-type.js +6 -25
  24. package/dist/esm/view/EmbedCard/views/ResolvedView.js +1 -17
  25. package/dist/esm/view/FlexibleCard/components/actions/follow-action/index.js +5 -36
  26. package/dist/esm/view/FlexibleCard/components/common/atlaskit-icon/index.js +3 -35
  27. package/dist/esm/view/LinkUrl/index.js +1 -1
  28. package/dist/esm/view/PreAuthValuePropositionModal/index.js +56 -110
  29. package/dist/esm/view/PreAuthValuePropositionModal/use-pre-auth-value-proposition-modal.js +167 -0
  30. package/dist/types/common/analytics/generated/analytics.types.d.ts +2 -2
  31. package/dist/types/view/PreAuthValuePropositionModal/index.d.ts +1 -1
  32. package/dist/types/view/PreAuthValuePropositionModal/use-pre-auth-value-proposition-modal.d.ts +31 -0
  33. package/package.json +7 -7
  34. package/dist/cjs/view/FlexibleCard/components/importIcon.js +0 -20
  35. package/dist/es2019/view/FlexibleCard/components/importIcon.js +0 -7
  36. package/dist/esm/view/FlexibleCard/components/importIcon.js +0 -13
  37. package/dist/types/view/FlexibleCard/components/importIcon.d.ts +0 -1
@@ -0,0 +1,175 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.SMART_LINK_MODAL_ID = void 0;
8
+ exports.usePreAuthValuePropositionModal = usePreAuthValuePropositionModal;
9
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
+ var _react = require("react");
11
+ var _extractSmartLinkProvider = require("@atlaskit/link-extractors/extract-smart-link-provider");
12
+ var _expVal = require("@atlaskit/platform-feature-experiments/exp-val");
13
+ var _useAnalyticsEvents2 = require("../../common/analytics/generated/use-analytics-events");
14
+ var _helpers = require("../../state/helpers");
15
+ var _useSocialProof2 = _interopRequireDefault(require("../../state/hooks/use-social-proof"));
16
+ var _useSmartLink2 = require("../../state/hooks/useSmartLink");
17
+ var _preAuthValuePropositionModal = require("../../state/services/pre-auth-value-proposition-modal");
18
+ var SMART_LINK_MODAL_ID = exports.SMART_LINK_MODAL_ID = 'pre-auth-value-proposition-modal';
19
+ var getModalCloseMethod = function getModalCloseMethod(event) {
20
+ return 'key' in event && event.key === 'Escape' ? 'escape' : 'overlay';
21
+ };
22
+
23
+ /**
24
+ * Eligibility, assignment and modal actions for one URL attempt.
25
+ * The existing choreographer adapter owns display permission and cleanup.
26
+ */
27
+ function usePreAuthValuePropositionModal(_ref) {
28
+ var url = _ref.url,
29
+ onFinished = _ref.onFinished;
30
+ var _useSmartLink = (0, _useSmartLink2.useSmartLink)(SMART_LINK_MODAL_ID, url, 'inline'),
31
+ actions = _useSmartLink.actions,
32
+ config = _useSmartLink.config,
33
+ state = _useSmartLink.state;
34
+ var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(),
35
+ fireEvent = _useAnalyticsEvents.fireEvent;
36
+ var _useState = (0, _react.useState)(false),
37
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
38
+ isRequested = _useState2[0],
39
+ setIsRequested = _useState2[1];
40
+ var finished = (0, _react.useRef)(false);
41
+ var hasOpened = (0, _react.useRef)(false);
42
+ var hasRecordedShow = (0, _react.useRef)(false);
43
+ var _useState3 = (0, _react.useState)('modal_text_only'),
44
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
45
+ visibleVariant = _useState4[0],
46
+ setVisibleVariant = _useState4[1];
47
+ var modalOpenTimeRef = (0, _react.useRef)(Date.now());
48
+ var provider = (0, _react.useMemo)(function () {
49
+ return (0, _extractSmartLinkProvider.extractSmartLinkProvider)(state.details);
50
+ }, [state.details]);
51
+ var providerName = provider === null || provider === void 0 ? void 0 : provider.text;
52
+ var services = (0, _helpers.getServices)(state.details);
53
+ var extensionKey = (0, _helpers.getExtensionKey)(state.details);
54
+ var _useSocialProof = (0, _useSocialProof2.default)(extensionKey, true),
55
+ connectedPct = _useSocialProof.connectedPct,
56
+ isSocialProofAvailable = _useSocialProof.isEnabled;
57
+ var hasSupportedAuthorization = (config === null || config === void 0 ? void 0 : config.authFlow) !== 'disabled' && services.length > 0;
58
+ var isBaseEligible = state.status === 'unauthorized' && Boolean(providerName) && Boolean(extensionKey) && hasSupportedAuthorization;
59
+ var finishCoordinatedAttempt = (0, _react.useCallback)(function () {
60
+ if (finished.current) {
61
+ return;
62
+ }
63
+ finished.current = true;
64
+ setIsRequested(false);
65
+ onFinished();
66
+ }, [onFinished]);
67
+ var handleUnavailable = (0, _react.useCallback)(function () {
68
+ if (finished.current) {
69
+ return;
70
+ }
71
+ if (hasOpened.current) {
72
+ fireEvent('ui.modal.closed.preAuthValueProposition', {
73
+ closeMethod: 'coordinator',
74
+ dwellTime: Date.now() - modalOpenTimeRef.current
75
+ });
76
+ }
77
+ finishCoordinatedAttempt();
78
+ }, [fireEvent, finishCoordinatedAttempt]);
79
+ var shouldClaim = (0, _react.useCallback)(function () {
80
+ // Recheck at offer time: another attempt may have consumed the cap while we waited.
81
+ if (finished.current || !isBaseEligible || !extensionKey || _preAuthValuePropositionModal.preAuthValuePropositionModalService.hasReachedShowLimit(extensionKey)) {
82
+ return false;
83
+ }
84
+ var variant = (0, _expVal.expVal)('platform_sl_3p_preauth_value_modal', 'variant', 'control');
85
+ if (variant !== 'modal_text_only' && variant !== 'modal_with_image') {
86
+ return false;
87
+ }
88
+ setVisibleVariant(variant);
89
+ return true;
90
+ }, [extensionKey, isBaseEligible]);
91
+
92
+ // The editor mounts this flow only when platform_sl_3p_preauth_value_modal_killswitch is on.
93
+ (0, _react.useEffect)(function () {
94
+ if (finished.current) {
95
+ return;
96
+ }
97
+ if (state.status === 'pending' || state.status === 'resolving') {
98
+ // A previously eligible link that starts resolving again must release its slot.
99
+ if (isRequested) {
100
+ handleUnavailable();
101
+ }
102
+ return;
103
+ }
104
+ if (!isBaseEligible || !extensionKey) {
105
+ handleUnavailable();
106
+ return;
107
+ }
108
+ if (!isRequested) {
109
+ if (_preAuthValuePropositionModal.preAuthValuePropositionModalService.hasReachedShowLimit(extensionKey)) {
110
+ finishCoordinatedAttempt();
111
+ } else {
112
+ setIsRequested(true);
113
+ }
114
+ }
115
+ }, [extensionKey, isBaseEligible, state.status, isRequested, handleUnavailable, finishCoordinatedAttempt]);
116
+ var recordShowOnce = (0, _react.useCallback)(function () {
117
+ if (hasRecordedShow.current || !extensionKey) {
118
+ return;
119
+ }
120
+ hasRecordedShow.current = true;
121
+ _preAuthValuePropositionModal.preAuthValuePropositionModalService.recordShow(extensionKey);
122
+ }, [extensionKey]);
123
+ var dismissModal = (0, _react.useCallback)(function (closeMethod) {
124
+ if (finished.current) {
125
+ return;
126
+ }
127
+ // A user can dismiss the visible modal before its entrance animation completes.
128
+ recordShowOnce();
129
+ fireEvent('ui.modal.closed.preAuthValueProposition', {
130
+ closeMethod: closeMethod,
131
+ dwellTime: Date.now() - modalOpenTimeRef.current
132
+ });
133
+ finishCoordinatedAttempt();
134
+ }, [fireEvent, finishCoordinatedAttempt, recordShowOnce]);
135
+ var handleCloseButton = (0, _react.useCallback)(function () {
136
+ dismissModal('button');
137
+ }, [dismissModal]);
138
+ var handleModalClose = (0, _react.useCallback)(function (event) {
139
+ dismissModal(getModalCloseMethod(event));
140
+ }, [dismissModal]);
141
+ var handleOpenComplete = (0, _react.useCallback)(function () {
142
+ if (finished.current || hasOpened.current || !extensionKey) {
143
+ return;
144
+ }
145
+ hasOpened.current = true;
146
+ recordShowOnce();
147
+ modalOpenTimeRef.current = Date.now();
148
+ fireEvent('ui.modal.opened.preAuthValueProposition', {});
149
+ }, [fireEvent, extensionKey, recordShowOnce]);
150
+ var connectAccount = (0, _react.useCallback)(function () {
151
+ if (finished.current) {
152
+ return;
153
+ }
154
+ recordShowOnce();
155
+ fireEvent('track.applicationAccount.authStarted', {});
156
+ finishCoordinatedAttempt();
157
+ actions.authorize('inline');
158
+ }, [actions, fireEvent, finishCoordinatedAttempt, recordShowOnce]);
159
+ return {
160
+ isActive: isRequested,
161
+ isEligible: isBaseEligible,
162
+ onUnavailable: handleUnavailable,
163
+ shouldClaim: shouldClaim,
164
+ modal: {
165
+ provider: provider,
166
+ variant: visibleVariant,
167
+ connectedPct: connectedPct,
168
+ isSocialProofAvailable: isSocialProofAvailable,
169
+ onClose: handleModalClose,
170
+ onCloseButton: handleCloseButton,
171
+ onConnect: connectAccount,
172
+ onOpenComplete: handleOpenComplete
173
+ }
174
+ };
175
+ }
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="192" height="192" viewBox="0 0 32 32"><image href="data:image/png;base64,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" width="32" height="32" /></svg>
@@ -4,7 +4,7 @@ export const ANALYTICS_CHANNEL = 'media';
4
4
  export const context = {
5
5
  componentName: 'smart-cards',
6
6
  packageName: "@atlaskit/smart-card" || '',
7
- packageVersion: "46.14.5" || ''
7
+ packageVersion: "46.15.0" || ''
8
8
  };
9
9
  export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -1,6 +1,4 @@
1
1
  import React from 'react';
2
- import Loadable from 'react-loadable';
3
- import { fg } from '@atlaskit/platform-feature-flags/fg';
4
2
  import extractFileFormatIcon from '../extractors/flexible/icon/extract-file-formatIcon';
5
3
  import { getLazyIcons } from './get-lazy-icons';
6
4
  import { getLazyIconComponent } from './lazy-component';
@@ -14,6 +12,7 @@ const getTypeToIconMap = fileFormat => {
14
12
  return [(_lazyIcons$iconDescri = lazyIcons[iconDescriptor.icon]) === null || _lazyIcons$iconDescri === void 0 ? void 0 : _lazyIcons$iconDescri.default, (_iconDescriptor$label = iconDescriptor.label) !== null && _iconDescriptor$label !== void 0 ? _iconDescriptor$label : ''];
15
13
  };
16
14
  export const getIconForFileType = (fileMimeType, showIconLabel) => {
15
+ var _extractFileFormatIco;
17
16
  if (!fileMimeType) {
18
17
  return;
19
18
  }
@@ -25,25 +24,13 @@ export const getIconForFileType = (fileMimeType, showIconLabel) => {
25
24
  if (!importCb) {
26
25
  return;
27
26
  }
28
- if (fg('platform_sl_replace_react_loadable')) {
29
- var _extractFileFormatIco;
30
- const iconType = (_extractFileFormatIco = extractFileFormatIcon(fileMimeType.toLowerCase())) === null || _extractFileFormatIco === void 0 ? void 0 : _extractFileFormatIco.icon;
31
- if (iconType) {
32
- const LazyIcon = getLazyIconComponent(`${iconType}:default`, importCb);
33
- const lazyLabel = (showIconLabel !== null && showIconLabel !== void 0 ? showIconLabel : true) ? icon[1] || '' : '';
34
- return /*#__PURE__*/React.createElement(LazyIcon, {
35
- testId: "document-file-format-icon",
36
- label: lazyLabel
37
- });
38
- }
27
+ const iconType = (_extractFileFormatIco = extractFileFormatIcon(fileMimeType.toLowerCase())) === null || _extractFileFormatIco === void 0 ? void 0 : _extractFileFormatIco.icon;
28
+ if (!iconType) {
29
+ return;
39
30
  }
40
- const Icon = Loadable({
41
- loader: () => importCb().then(module => module.default),
42
- loading: () => null
43
- }); // because we're using dynamic loading here, TS will not be able to infer the type
44
-
31
+ const LazyIcon = getLazyIconComponent(`${iconType}:default`, importCb);
45
32
  const label = (showIconLabel !== null && showIconLabel !== void 0 ? showIconLabel : true) ? icon[1] || '' : '';
46
- return /*#__PURE__*/React.createElement(Icon, {
33
+ return /*#__PURE__*/React.createElement(LazyIcon, {
47
34
  testId: "document-file-format-icon",
48
35
  label: label
49
36
  });
@@ -2,7 +2,6 @@
2
2
  import "./ResolvedView.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React, { lazy } from 'react';
5
- import Loadable from 'react-loadable';
6
5
  import LinkGlyph from '@atlaskit/icon/core/link';
7
6
  import { useSmartLinkContext } from '@atlaskit/link-provider/use-smart-link-context';
8
7
  import { fg } from '@atlaskit/platform-feature-flags/fg';
@@ -20,11 +19,6 @@ import { ExpandedFrame } from '../components/ExpandedFrame';
20
19
  import { Frame } from '../components/Frame';
21
20
  import { ImageIcon } from '../components/ImageIcon';
22
21
  import { useEmbedResolvePostMessageListener } from '../useEmbedResolvePostMessageListener';
23
- const EmbedRovoActionsFooter = Loadable({
24
- loader: () => import( /* webpackChunkName: "smart-card-embed-rovo-actions-footer" */'../components/rovo-actions-footer').then(module => module.default),
25
- loading: () => null
26
- });
27
- EmbedRovoActionsFooter.displayName = 'lazy(EmbedRovoActionsFooter)';
28
22
 
29
23
  // Inline module-scope lazy() so product SSR tooling can preload it before hydration.
30
24
  const LazyEmbedRovoActionsFooter = withSuspense( /*#__PURE__*/lazy(() => import( /* webpackChunkName: "smart-card-embed-rovo-actions-footer" */'../components/rovo-actions-footer').catch(renderNothingOnLoadError)), 'lazy(EmbedRovoActionsFooter)');
@@ -68,11 +62,7 @@ const EmbedFrameWithRovoFooter = ({
68
62
  response: details
69
63
  });
70
64
  }, [details, isEmbedRovoActionsFooterEnabled, product, rovoActionData]);
71
- const footer = React.useMemo(() => rovoActionData && prompts.length > 0 ? fg('platform_sl_replace_react_loadable') ? /*#__PURE__*/React.createElement(LazyEmbedRovoActionsFooter, {
72
- actionData: rovoActionData,
73
- prompts: prompts,
74
- testId: `${testId}-rovo-actions-footer`
75
- }) : /*#__PURE__*/React.createElement(EmbedRovoActionsFooter, {
65
+ const footer = React.useMemo(() => rovoActionData && prompts.length > 0 ? /*#__PURE__*/React.createElement(LazyEmbedRovoActionsFooter, {
76
66
  actionData: rovoActionData,
77
67
  prompts: prompts,
78
68
  testId: `${testId}-rovo-actions-footer`
@@ -2,26 +2,12 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { lazy } from 'react';
3
3
  import { FormattedMessage, useIntl } from 'react-intl';
4
4
  import FeatureGates from '@atlaskit/feature-gate-js-client/feature-gates';
5
- import { fg } from '@atlaskit/platform-feature-flags/fg';
6
5
  import { ActionName } from '../../../../../constants';
7
6
  import { messages } from '../../../../../messages';
8
7
  import { useFlexibleUiContext } from '../../../../../state/flexible-ui-context/useFlexibleUiContext';
9
8
  import { renderNothingOnLoadError, withSuspense } from '../../../../../utils/lazy-component';
10
- import { importIcon } from '../../importIcon';
11
9
  import ServerAction from '../action/server-action';
12
10
  import { getFollowActionErrorMessage } from './utils';
13
- const importIconMapper = {
14
- goal: () => import( /* webpackChunkName: "glyphGoal" */'./goal-icon').then(({
15
- GoalIcon
16
- }) => ({
17
- default: GoalIcon
18
- })),
19
- projects: () => import( /* webpackChunkName: "glyphProjects" */'./projects-icon').then(({
20
- ProjectsIcon
21
- }) => ({
22
- default: ProjectsIcon
23
- }))
24
- };
25
11
 
26
12
  // Inline module-scope lazy() calls so product SSR tooling can preload them before hydration.
27
13
  const lazyIconMapper = {
@@ -36,17 +22,6 @@ const lazyIconMapper = {
36
22
  default: ProjectsIcon
37
23
  })).catch(renderNothingOnLoadError)), 'lazy(ProjectsIcon)')
38
24
  };
39
- const getIcon = stackIconType => {
40
- if (fg('platform_sl_replace_react_loadable')) {
41
- var _lazyIconMapper$stack;
42
- return (_lazyIconMapper$stack = lazyIconMapper[stackIconType]) !== null && _lazyIconMapper$stack !== void 0 ? _lazyIconMapper$stack : null;
43
- }
44
- const importFn = importIconMapper[stackIconType];
45
- if (!importFn) {
46
- return null;
47
- }
48
- return importIcon(importFn);
49
- };
50
25
  const FollowAction = props => {
51
26
  var _context$actions;
52
27
  const context = useFlexibleUiContext();
@@ -71,7 +46,7 @@ const FollowAction = props => {
71
46
  const stackTooltipMessage = isProject ? projectTooltipMessage : goalTooltipMessage;
72
47
  const tooltipMessage = isStackItem ? stackTooltipMessage : message;
73
48
  const stackIconType = isProject ? 'projects' : 'goal';
74
- const ImportedIcon = getIcon(stackIconType);
49
+ const ImportedIcon = lazyIconMapper[stackIconType];
75
50
  const followIcon = /*#__PURE__*/React.createElement(ImportedIcon, {
76
51
  label: "",
77
52
  testId: `smart-action-follow-action-${stackIconType}-icon`
@@ -1,6 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React from 'react';
3
- import Loadable from 'react-loadable';
4
3
  import IconTile from '@atlaskit/icon/icon-tile';
5
4
  import { ConfluenceIcon } from '@atlaskit/logo/confluence-icon';
6
5
  import { JiraIcon } from '@atlaskit/logo/jira-icon';
@@ -10,16 +9,6 @@ import { IconType, SmartLinkSize } from '../../../../../constants';
10
9
  import { getLazyIcons } from '../../../../../utils/get-lazy-icons';
11
10
  import { isIconSizeLarge } from '../../../../../utils/is-icon-size-large';
12
11
  import { getLazyIconComponent } from '../../../../../utils/lazy-component';
13
- const getIconImportFn = (icon, size) => {
14
- const item = getLazyIcons()[icon];
15
- if (isIconSizeLarge(size) && item !== null && item !== void 0 && item.large) {
16
- return item.large;
17
- }
18
- return item === null || item === void 0 ? void 0 : item.default;
19
- };
20
-
21
- // Only used when platform_sl_replace_react_loadable is on. Kept separate from getIconImportFn so
22
- // the gate-off path is unchanged.
23
12
  const getLazyIcon = (icon, size) => {
24
13
  const item = getLazyIcons()[icon];
25
14
  if (isIconSizeLarge(size) && item !== null && item !== void 0 && item.large) {
@@ -27,12 +16,6 @@ const getLazyIcon = (icon, size) => {
27
16
  }
28
17
  return item !== null && item !== void 0 && item.default ? getLazyIconComponent(`${icon}:default`, item.default) : undefined;
29
18
  };
30
- const importIcon = importFn => {
31
- return Loadable({
32
- loader: () => importFn().then(module => module.default),
33
- loading: () => null
34
- }); // Because we're using dynamic loading here, TS will not be able to infer the type.
35
- };
36
19
  const getBlogIcon = () => require('../../../../../common/ui/icons/blog-icon').default;
37
20
  const getDocumentIcon = () => require('../../../../../common/ui/icons/page-icon').default;
38
21
  const getLiveDocumentIcon = () => require('../../../../../common/ui/icons/live-document-icon').default;
@@ -82,18 +65,9 @@ const AtlaskitIcon = ({
82
65
  });
83
66
  }
84
67
  }
85
- let ImportedIcon;
86
- if (fg('platform_sl_replace_react_loadable')) {
87
- ImportedIcon = getLazyIcon(icon, size);
88
- if (!ImportedIcon) {
89
- return null;
90
- }
91
- } else {
92
- const importFn = getIconImportFn(icon, size);
93
- if (!importFn) {
94
- return null;
95
- }
96
- ImportedIcon = importIcon(importFn);
68
+ const ImportedIcon = getLazyIcon(icon, size);
69
+ if (!ImportedIcon) {
70
+ return null;
97
71
  }
98
72
  if (isCoreIcon(icon)) {
99
73
  let color;
@@ -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: "46.14.5",
12
+ packageVersion: "46.15.0",
13
13
  componentName: 'linkUrl'
14
14
  };
15
15
  const LinkUrl = ({
@@ -2,31 +2,26 @@
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import "./index.compiled.css";
4
4
  import { ax, ix } from "@compiled/react/runtime";
5
- import React, { lazy, Suspense, useCallback, useEffect, useMemo, useRef, useState } from 'react';
5
+ import React, { lazy, Suspense, useEffect } from 'react';
6
+ import { ErrorBoundary } from 'react-error-boundary';
6
7
  import { defineMessages, FormattedMessage } from 'react-intl';
7
8
  import Button from '@atlaskit/button/default/button';
8
9
  import Heading from '@atlaskit/heading/heading';
9
- import { extractSmartLinkProvider } from '@atlaskit/link-extractors/extract-smart-link-provider';
10
+ import { ChoreographedContent } from '@atlaskit/link-provider/choreographed-content';
10
11
  import ModalBody from '@atlaskit/modal-dialog/modal-body';
11
12
  import Modal from '@atlaskit/modal-dialog/modal-dialog';
12
13
  import ModalTitle from '@atlaskit/modal-dialog/modal-title';
13
14
  import ModalTransition from '@atlaskit/modal-dialog/modal-transition';
14
- import { expVal } from '@atlaskit/platform-feature-experiments/exp-val';
15
15
  import { Box } from '@atlaskit/primitives/compiled/box';
16
16
  import { Flex } from '@atlaskit/primitives/compiled/flex';
17
17
  import { Stack } from '@atlaskit/primitives/compiled/stack';
18
18
  import { Text } from '@atlaskit/primitives/compiled/text';
19
- import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
20
19
  import { messages as smartCardMessages } from '../../messages';
21
- import { getExtensionKey, getServices } from '../../state/helpers';
22
- import useSocialProof from '../../state/hooks/use-social-proof';
23
- import { useSmartLink } from '../../state/hooks/useSmartLink';
24
- import { preAuthValuePropositionModalService } from '../../state/services/pre-auth-value-proposition-modal';
25
20
  import { SmartLinkAnalyticsContext } from '../../utils/analytics/SmartLinkAnalyticsContext';
26
21
  import ImageIcon from '../common/image-icon';
22
+ import { SMART_LINK_MODAL_ID, usePreAuthValuePropositionModal } from './use-pre-auth-value-proposition-modal';
27
23
  const IllustrationPane = /*#__PURE__*/lazy(() => import( /* webpackChunkName: "@atlaskit-internal_smart-card-pre-auth-value-proposition-illustration" */'./IllustrationPane'));
28
24
  const SOCIAL_PROOF_TEAM_PREVIEW_THRESHOLD = 30;
29
- const SMART_LINK_MODAL_ID = 'pre-auth-value-proposition-modal';
30
25
  const messages = defineMessages({
31
26
  close: {
32
27
  id: 'smart-card.view.PreAuthValuePropositionModal.close',
@@ -72,7 +67,6 @@ const styles = {
72
67
  const bold = chunks => /*#__PURE__*/React.createElement(Text, {
73
68
  as: "strong"
74
69
  }, chunks);
75
- const getModalCloseMethod = event => 'key' in event && event.key === 'Escape' ? 'escape' : 'overlay';
76
70
  const ModalCopy = ({
77
71
  connectedPct,
78
72
  isSocialProofAvailable,
@@ -165,33 +159,25 @@ const ModalCopy = ({
165
159
  onClick: onClose
166
160
  }, /*#__PURE__*/React.createElement(FormattedMessage, messages.close))))));
167
161
  };
168
- const PreAuthValuePropositionModalContent = ({
169
- onFinished,
170
- onOpenChange,
171
- url
162
+
163
+ /** Mounted only while the existing choreographer grants permission. */
164
+ const ModalContent = ({
165
+ provider,
166
+ variant,
167
+ connectedPct,
168
+ isSocialProofAvailable,
169
+ onClose,
170
+ onCloseButton,
171
+ onConnect,
172
+ onOpenComplete,
173
+ onOpenChange
172
174
  }) => {
173
175
  var _provider$iconLabel;
174
- const {
175
- actions,
176
- config,
177
- state
178
- } = useSmartLink(SMART_LINK_MODAL_ID, url, 'inline');
179
- const {
180
- fireEvent
181
- } = useAnalyticsEvents();
182
- const [isOpen, setIsOpen] = useState(false);
183
- const [visibleVariant, setVisibleVariant] = useState('modal_text_only');
184
- const modalOpenTimeRef = useRef(Date.now());
185
- const provider = useMemo(() => extractSmartLinkProvider(state.details), [state.details]);
186
- const providerName = provider === null || provider === void 0 ? void 0 : provider.text;
187
- const isVisible = isOpen && Boolean(providerName);
188
176
  useEffect(() => {
189
- if (!isVisible) {
190
- return;
191
- }
192
177
  onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(true);
193
178
  return () => onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(false);
194
- }, [isVisible, onOpenChange]);
179
+ }, [onOpenChange]);
180
+ const providerName = provider === null || provider === void 0 ? void 0 : provider.text;
195
181
  const providerIconUrl = typeof (provider === null || provider === void 0 ? void 0 : provider.icon) === 'string' ? provider.icon : undefined;
196
182
  const renderProviderIcon = (size, testId, label) => {
197
183
  if (providerIconUrl) {
@@ -208,70 +194,18 @@ const PreAuthValuePropositionModalContent = ({
208
194
  return provider === null || provider === void 0 ? void 0 : provider.icon;
209
195
  };
210
196
  const providerIcon = renderProviderIcon(24, 'pre-auth-value-proposition-modal-provider-icon', (_provider$iconLabel = provider === null || provider === void 0 ? void 0 : provider.iconLabel) !== null && _provider$iconLabel !== void 0 ? _provider$iconLabel : providerName);
211
- const services = getServices(state.details);
212
- const extensionKey = getExtensionKey(state.details);
213
- const {
214
- connectedPct,
215
- isEnabled: isSocialProofAvailable
216
- } = useSocialProof(extensionKey, true);
217
- const hasSupportedAuthorization = (config === null || config === void 0 ? void 0 : config.authFlow) !== 'disabled' && services.length > 0;
218
- const isBaseEligible = state.status === 'unauthorized' && Boolean(providerName) && Boolean(extensionKey) && hasSupportedAuthorization;
219
- useEffect(() => {
220
- if (state.status === 'pending' || state.status === 'resolving') {
221
- return;
222
- }
223
- if (!isBaseEligible || !extensionKey || preAuthValuePropositionModalService.hasReachedShowLimit(extensionKey)) {
224
- onFinished();
225
- return;
226
- }
227
- const experimentVariant = expVal('platform_sl_3p_preauth_value_modal', 'variant', 'control');
228
- if (experimentVariant === 'modal_text_only' || experimentVariant === 'modal_with_image') {
229
- preAuthValuePropositionModalService.recordShow(extensionKey);
230
- setVisibleVariant(experimentVariant);
231
- setIsOpen(true);
232
- return;
233
- }
234
- onFinished();
235
- }, [extensionKey, isBaseEligible, onFinished, state.status]);
236
- const dismissModal = useCallback(closeMethod => {
237
- fireEvent('ui.modal.closed.preAuthValueProposition', {
238
- closeMethod,
239
- dwellTime: Date.now() - modalOpenTimeRef.current
240
- });
241
- setIsOpen(false);
242
- onFinished();
243
- }, [fireEvent, onFinished]);
244
- const handleCloseButton = useCallback(() => {
245
- dismissModal('button');
246
- }, [dismissModal]);
247
- const handleModalClose = useCallback(event => {
248
- dismissModal(getModalCloseMethod(event));
249
- }, [dismissModal]);
250
- const handleOpenComplete = useCallback(() => {
251
- modalOpenTimeRef.current = Date.now();
252
- fireEvent('ui.modal.opened.preAuthValueProposition', {});
253
- }, [fireEvent]);
254
- const connectAccount = useCallback(() => {
255
- fireEvent('track.applicationAccount.authStarted', {});
256
- setIsOpen(false);
257
- actions.authorize('inline');
258
- onFinished();
259
- }, [actions, fireEvent, onFinished]);
260
- if (!isOpen || !providerName) {
261
- return null;
262
- }
263
197
  const modalCopy = /*#__PURE__*/React.createElement(ModalCopy, {
264
198
  connectedPct: connectedPct,
265
199
  isSocialProofAvailable: isSocialProofAvailable,
266
- onClose: handleCloseButton,
267
- onConnect: connectAccount,
200
+ onClose: onCloseButton,
201
+ onConnect: onConnect,
268
202
  providerIcon: providerIcon,
269
- providerName: providerName
203
+ providerName: providerName !== null && providerName !== void 0 ? providerName : ''
270
204
  });
271
- const showIllustration = visibleVariant === 'modal_with_image';
272
- return /*#__PURE__*/React.createElement(ModalTransition, null, /*#__PURE__*/React.createElement(Modal, {
273
- onClose: handleModalClose,
274
- onOpenComplete: handleOpenComplete,
205
+ const showIllustration = variant === 'modal_with_image';
206
+ const modal = providerName ? /*#__PURE__*/React.createElement(ModalTransition, null, /*#__PURE__*/React.createElement(Modal, {
207
+ onClose: onClose,
208
+ onOpenComplete: onOpenComplete,
275
209
  testId: "pre-auth-value-proposition-modal",
276
210
  width: showIllustration ? 800 : 400
277
211
  }, showIllustration ? /*#__PURE__*/React.createElement(Box, {
@@ -282,19 +216,37 @@ const PreAuthValuePropositionModalContent = ({
282
216
  fallback: null
283
217
  }, /*#__PURE__*/React.createElement(IllustrationPane, {
284
218
  renderProviderIcon: renderProviderIcon
285
- }))) : modalCopy));
219
+ }))) : modalCopy)) : null;
220
+ return modal;
286
221
  };
287
- export const PreAuthValuePropositionModal = ({
288
- onFinished,
222
+ const PreAuthValuePropositionModalContent = ({
289
223
  onOpenChange,
290
- url
291
- }) => /*#__PURE__*/React.createElement(SmartLinkAnalyticsContext, {
224
+ ...options
225
+ }) => {
226
+ const {
227
+ isActive,
228
+ isEligible,
229
+ onUnavailable,
230
+ shouldClaim,
231
+ modal
232
+ } = usePreAuthValuePropositionModal(options);
233
+ return /*#__PURE__*/React.createElement(ChoreographedContent, {
234
+ messageId: "smart-link-pre-auth-value-proposition-modal",
235
+ isActive: isActive,
236
+ onUnavailable: onUnavailable,
237
+ shouldClaim: shouldClaim
238
+ }, ({
239
+ hasPermission
240
+ }) => hasPermission && isEligible ? /*#__PURE__*/React.createElement(ErrorBoundary, {
241
+ fallback: null,
242
+ onError: onUnavailable
243
+ }, /*#__PURE__*/React.createElement(ModalContent, _extends({}, modal, {
244
+ onOpenChange: onOpenChange
245
+ }))) : null);
246
+ };
247
+ export const PreAuthValuePropositionModal = props => /*#__PURE__*/React.createElement(SmartLinkAnalyticsContext, {
292
248
  display: "inline",
293
249
  id: SMART_LINK_MODAL_ID,
294
250
  source: "preAuthValuePropositionModal",
295
- url: url
296
- }, /*#__PURE__*/React.createElement(PreAuthValuePropositionModalContent, {
297
- onFinished: onFinished,
298
- onOpenChange: onOpenChange,
299
- url: url
300
- }));
251
+ url: props.url
252
+ }, /*#__PURE__*/React.createElement(PreAuthValuePropositionModalContent, props));