@atlaskit/smart-card 45.27.1 → 45.28.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 (45) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/analytics.spec.yaml +23 -0
  3. package/dist/cjs/__tests__/informational-vr-tests/__snapshots__/pre-auth-value-proposition-modal/text-only--light-mode.png +3 -0
  4. package/dist/cjs/__tests__/informational-vr-tests/__snapshots__/pre-auth-value-proposition-modal/with-image--light-mode.png +3 -0
  5. package/dist/cjs/common/analytics/generated/use-analytics-events.js +1 -1
  6. package/dist/cjs/entry-points/pre-auth-value-proposition-modal.js +12 -0
  7. package/dist/cjs/state/services/pre-auth-value-proposition-modal/index.js +122 -0
  8. package/dist/cjs/utils/analytics/analytics.js +1 -1
  9. package/dist/cjs/view/LinkUrl/index.js +1 -1
  10. package/dist/cjs/view/PreAuthValuePropositionModal/IllustrationPane.compiled.css +30 -0
  11. package/dist/cjs/view/PreAuthValuePropositionModal/IllustrationPane.js +58 -0
  12. package/dist/cjs/view/PreAuthValuePropositionModal/assets/graphics-with-grid-no-provider-icons-2x.png +0 -0
  13. package/dist/cjs/view/PreAuthValuePropositionModal/index.compiled.css +17 -0
  14. package/dist/cjs/view/PreAuthValuePropositionModal/index.js +304 -0
  15. package/dist/es2019/__tests__/informational-vr-tests/__snapshots__/pre-auth-value-proposition-modal/text-only--light-mode.png +3 -0
  16. package/dist/es2019/__tests__/informational-vr-tests/__snapshots__/pre-auth-value-proposition-modal/with-image--light-mode.png +3 -0
  17. package/dist/es2019/common/analytics/generated/use-analytics-events.js +1 -1
  18. package/dist/es2019/entry-points/pre-auth-value-proposition-modal.js +1 -0
  19. package/dist/es2019/state/services/pre-auth-value-proposition-modal/index.js +97 -0
  20. package/dist/es2019/utils/analytics/analytics.js +1 -1
  21. package/dist/es2019/view/LinkUrl/index.js +1 -1
  22. package/dist/es2019/view/PreAuthValuePropositionModal/IllustrationPane.compiled.css +30 -0
  23. package/dist/es2019/view/PreAuthValuePropositionModal/IllustrationPane.js +51 -0
  24. package/dist/es2019/view/PreAuthValuePropositionModal/assets/graphics-with-grid-no-provider-icons-2x.png +0 -0
  25. package/dist/es2019/view/PreAuthValuePropositionModal/index.compiled.css +17 -0
  26. package/dist/es2019/view/PreAuthValuePropositionModal/index.js +282 -0
  27. package/dist/esm/__tests__/informational-vr-tests/__snapshots__/pre-auth-value-proposition-modal/text-only--light-mode.png +3 -0
  28. package/dist/esm/__tests__/informational-vr-tests/__snapshots__/pre-auth-value-proposition-modal/with-image--light-mode.png +3 -0
  29. package/dist/esm/common/analytics/generated/use-analytics-events.js +1 -1
  30. package/dist/esm/entry-points/pre-auth-value-proposition-modal.js +1 -0
  31. package/dist/esm/state/services/pre-auth-value-proposition-modal/index.js +115 -0
  32. package/dist/esm/utils/analytics/analytics.js +1 -1
  33. package/dist/esm/view/LinkUrl/index.js +1 -1
  34. package/dist/esm/view/PreAuthValuePropositionModal/IllustrationPane.compiled.css +30 -0
  35. package/dist/esm/view/PreAuthValuePropositionModal/IllustrationPane.js +52 -0
  36. package/dist/esm/view/PreAuthValuePropositionModal/assets/graphics-with-grid-no-provider-icons-2x.png +0 -0
  37. package/dist/esm/view/PreAuthValuePropositionModal/index.compiled.css +17 -0
  38. package/dist/esm/view/PreAuthValuePropositionModal/index.js +293 -0
  39. package/dist/types/common/analytics/generated/analytics.types.d.ts +14 -1
  40. package/dist/types/entry-points/pre-auth-value-proposition-modal.d.ts +1 -0
  41. package/dist/types/state/services/pre-auth-value-proposition-modal/index.d.ts +11 -0
  42. package/dist/types/view/PreAuthValuePropositionModal/IllustrationPane.d.ts +10 -0
  43. package/dist/types/view/PreAuthValuePropositionModal/index.d.ts +5 -0
  44. package/package.json +1 -1
  45. package/pre-auth-value-proposition-modal/package.json +10 -0
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Generates Typescript types for analytics events from analytics.spec.yaml
5
5
  *
6
- * @codegen <<SignedSource::ac0d75fa9e8d43c947e88f47ba1267aa>>
6
+ * @codegen <<SignedSource::4715d46f4a378244afd94dadfd9e5f51>>
7
7
  * @codegenCommand yarn workspace @atlassian/analytics-tooling run analytics:codegen smart-card
8
8
  */
9
9
  import { useCallback } from 'react';
@@ -0,0 +1 @@
1
+ export { PreAuthValuePropositionModal } from '../view/PreAuthValuePropositionModal';
@@ -0,0 +1,97 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import { StorageClient } from '@atlaskit/frontend-utilities/StorageClient';
3
+ const SMART_CARD_STORAGE_SCOPE = '@atlaskit/smart-card';
4
+ export const PRE_AUTH_VALUE_PROPOSITION_MODAL_STORAGE_ITEM_KEY = 'pre-auth-value-proposition-modal-shown-providers:v3';
5
+ const weekInMs = 7 * 24 * 60 * 60 * 1000;
6
+ export const PRE_AUTH_VALUE_PROPOSITION_MODAL_COOLDOWN_MS = weekInMs;
7
+ let smartCardStorage;
8
+ const getSmartCardStorage = () => {
9
+ if (typeof window === 'undefined') {
10
+ return null;
11
+ }
12
+ if (smartCardStorage !== undefined) {
13
+ return smartCardStorage;
14
+ }
15
+ try {
16
+ smartCardStorage = new StorageClient(SMART_CARD_STORAGE_SCOPE);
17
+ } catch {
18
+ smartCardStorage = null;
19
+ }
20
+ return smartCardStorage;
21
+ };
22
+ const isShownExtensionKeys = value => Array.isArray(value) && value.every(extensionKey => typeof extensionKey === 'string');
23
+ const isStoredShowState = value => {
24
+ if (typeof value !== 'object' || value === null) {
25
+ return false;
26
+ }
27
+ const storedShowState = value;
28
+ return typeof storedShowState.lastShownAt === 'number' && Number.isFinite(storedShowState.lastShownAt) && isShownExtensionKeys(storedShowState.shownExtensionKeys);
29
+ };
30
+ const EMPTY_STORED_SHOW_STATE = {
31
+ lastShownAt: 0,
32
+ shownExtensionKeys: []
33
+ };
34
+ export class PreAuthValuePropositionModalService {
35
+ constructor() {
36
+ _defineProperty(this, "storedShowState", null);
37
+ }
38
+ hasReachedShowLimit(extensionKey) {
39
+ const {
40
+ lastShownAt,
41
+ shownExtensionKeys
42
+ } = this.getStoredShowState();
43
+ if (shownExtensionKeys.includes(extensionKey)) {
44
+ return true;
45
+ }
46
+ return lastShownAt > 0 && Date.now() - lastShownAt < PRE_AUTH_VALUE_PROPOSITION_MODAL_COOLDOWN_MS;
47
+ }
48
+ recordShow(extensionKey) {
49
+ if (this.hasReachedShowLimit(extensionKey)) {
50
+ return;
51
+ }
52
+ const {
53
+ shownExtensionKeys
54
+ } = this.getStoredShowState();
55
+ const nextStoredShowState = {
56
+ lastShownAt: Date.now(),
57
+ shownExtensionKeys: [...shownExtensionKeys, extensionKey]
58
+ };
59
+ this.storedShowState = nextStoredShowState;
60
+ try {
61
+ var _getSmartCardStorage;
62
+ (_getSmartCardStorage = getSmartCardStorage()) === null || _getSmartCardStorage === void 0 ? void 0 : _getSmartCardStorage.setItemWithExpiry(PRE_AUTH_VALUE_PROPOSITION_MODAL_STORAGE_ITEM_KEY, nextStoredShowState);
63
+ } catch {
64
+ // Browser Storage Controls, quota, private mode, and SSR must not break the editor.
65
+ }
66
+ }
67
+ reset() {
68
+ this.storedShowState = null;
69
+ try {
70
+ var _getSmartCardStorage2;
71
+ (_getSmartCardStorage2 = getSmartCardStorage()) === null || _getSmartCardStorage2 === void 0 ? void 0 : _getSmartCardStorage2.removeItem(PRE_AUTH_VALUE_PROPOSITION_MODAL_STORAGE_ITEM_KEY);
72
+ } catch {
73
+ // Browser Storage Controls, quota, private mode, and SSR must not break the editor.
74
+ }
75
+ }
76
+ getStoredShowState() {
77
+ if (this.storedShowState !== null) {
78
+ return this.storedShowState;
79
+ }
80
+ const storedShowState = this.readStoredShowState();
81
+ this.storedShowState = storedShowState;
82
+ return storedShowState;
83
+ }
84
+ readStoredShowState() {
85
+ try {
86
+ var _getSmartCardStorage3;
87
+ const storedShowState = (_getSmartCardStorage3 = getSmartCardStorage()) === null || _getSmartCardStorage3 === void 0 ? void 0 : _getSmartCardStorage3.getItem(PRE_AUTH_VALUE_PROPOSITION_MODAL_STORAGE_ITEM_KEY);
88
+ if (!isStoredShowState(storedShowState)) {
89
+ return EMPTY_STORED_SHOW_STATE;
90
+ }
91
+ return storedShowState;
92
+ } catch {
93
+ return EMPTY_STORED_SHOW_STATE;
94
+ }
95
+ }
96
+ }
97
+ export const preAuthValuePropositionModalService = new PreAuthValuePropositionModalService();
@@ -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: "45.27.0" || ''
7
+ packageVersion: "45.27.1" || ''
8
8
  };
9
9
  export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -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: "45.27.0",
12
+ packageVersion: "45.27.1",
13
13
  componentName: 'linkUrl'
14
14
  };
15
15
  const LinkUrl = ({
@@ -0,0 +1,30 @@
1
+ ._154i18e8{top:53px}
2
+ ._154i1rp4{top:215px}
3
+ ._154intd2{top:184px}
4
+ ._154invl5{top:355px}
5
+ ._18m915vq{overflow-y:hidden}
6
+ ._1bah1h6o{justify-content:center}
7
+ ._1bsb1kdj{width:25pc}
8
+ ._1bsb1ylp{width:40px}
9
+ ._1bsbl52n{width:17px}
10
+ ._1bsbo7ao{width:15px}
11
+ ._1e0c1txw{display:flex}
12
+ ._1e0c1ule{display:block}
13
+ ._1ein1kw7{border-end-end-radius:inherit}
14
+ ._1ltv1uvc{left:107px}
15
+ ._1ltv5rga{left:123px}
16
+ ._1ltvs0l4{left:121px}
17
+ ._1ltvvbgk{left:4pc}
18
+ ._1o9zidpf{flex-shrink:0}
19
+ ._1reo15vq{overflow-x:hidden}
20
+ ._4cvr1h6o{align-items:center}
21
+ ._4t3i1osq{height:100%}
22
+ ._4t3i1ylp{height:40px}
23
+ ._4t3ikbql{height:450px}
24
+ ._4t3il52n{height:17px}
25
+ ._4t3io7ao{height:15px}
26
+ ._5fbc1kw7{border-start-end-radius:inherit}
27
+ ._kqswh2mm{position:relative}
28
+ ._kqswstnw{position:absolute}
29
+ ._t9ec1b7d{transform:rotate(-3.18deg)}
30
+ ._t9ec751h{transform:rotate(3.37deg)}
@@ -0,0 +1,51 @@
1
+ /* IllustrationPane.tsx generated by @compiled/babel-plugin v3.0.2 */
2
+ import "./IllustrationPane.compiled.css";
3
+ import { ax, ix } from "@compiled/react/runtime";
4
+ import React from 'react';
5
+ import { Box } from '@atlaskit/primitives/compiled/box';
6
+
7
+ // Asset imports require an explicit extension for TypeScript and ESLint resolution.
8
+ // oxlint-disable-next-line import/extensions
9
+ import illustrationWithoutProviderIcons from './assets/graphics-with-grid-no-provider-icons-2x.png';
10
+ const styles = {
11
+ illustration: "_1e0c1ule _4t3ikbql _1bsb1kdj",
12
+ illustrationLayer: "_1reo15vq _18m915vq _1ein1kw7 _5fbc1kw7 _4t3ikbql _kqswh2mm _1bsb1kdj",
13
+ rightPane: "_1reo15vq _18m915vq _4cvr1h6o _1ein1kw7 _5fbc1kw7 _1e0c1txw _1o9zidpf _4t3i1osq _1bah1h6o _1bsb1kdj"
14
+ };
15
+
16
+ // Pixel offsets and rotations are from the Figma illustration, not space tokens.
17
+ const illustrationIconStyles = {
18
+ footer: "_4t3io7ao _1ltv1uvc _kqswstnw _154invl5 _t9ec1b7d _1bsbo7ao",
19
+ searchFirst: "_4t3il52n _1ltv5rga _kqswstnw _154intd2 _t9ec751h _1bsbl52n",
20
+ searchSecond: "_4t3il52n _1ltvs0l4 _kqswstnw _154i1rp4 _t9ec751h _1bsbl52n",
21
+ top: "_1reo15vq _18m915vq _4t3i1ylp _1ltvvbgk _kqswstnw _154i18e8 _1bsb1ylp"
22
+ };
23
+ const IllustrationPane = ({
24
+ renderProviderIcon
25
+ }) => /*#__PURE__*/React.createElement(Box, {
26
+ xcss: styles.rightPane
27
+ }, /*#__PURE__*/React.createElement(Box, {
28
+ xcss: styles.illustrationLayer
29
+ }, /*#__PURE__*/React.createElement("img", {
30
+ alt: "",
31
+ "aria-hidden": "true",
32
+ "data-testid": "pre-auth-value-proposition-modal-illustration",
33
+ height: 450,
34
+ src: illustrationWithoutProviderIcons,
35
+ srcSet: `${illustrationWithoutProviderIcons} 2x`,
36
+ width: 400,
37
+ className: ax([styles.illustration])
38
+ }), /*#__PURE__*/React.createElement("div", {
39
+ "aria-hidden": "true",
40
+ className: ax([illustrationIconStyles.top])
41
+ }, renderProviderIcon(40, 'pre-auth-value-proposition-modal-illustration-icon')), /*#__PURE__*/React.createElement("div", {
42
+ "aria-hidden": "true",
43
+ className: ax([illustrationIconStyles.searchFirst])
44
+ }, renderProviderIcon(17, 'pre-auth-value-proposition-modal-illustration-icon')), /*#__PURE__*/React.createElement("div", {
45
+ "aria-hidden": "true",
46
+ className: ax([illustrationIconStyles.searchSecond])
47
+ }, renderProviderIcon(17, 'pre-auth-value-proposition-modal-illustration-icon')), /*#__PURE__*/React.createElement("div", {
48
+ "aria-hidden": "true",
49
+ className: ax([illustrationIconStyles.footer])
50
+ }, renderProviderIcon(15, 'pre-auth-value-proposition-modal-illustration-icon'))));
51
+ export default IllustrationPane;
@@ -0,0 +1,17 @@
1
+ ._2rko1kw7{border-radius:inherit}
2
+ ._zulp1ejb{gap:var(--ds-space-300,24px)}
3
+ ._zulppxbi{gap:var(--ds-space-200,1pc)}._16jlkb7n{flex-grow:1}
4
+ ._18m915vq{overflow-y:hidden}
5
+ ._19bv1jfw{padding-left:var(--ds-space-500,40px)}
6
+ ._1bsb1kdj{width:25pc}
7
+ ._1bsbnklw{width:20pc}
8
+ ._1e0c1txw{display:flex}
9
+ ._1o9zidpf{flex-shrink:0}
10
+ ._1reo15vq{overflow-x:hidden}
11
+ ._2lx21bp4{flex-direction:column}
12
+ ._4cvr1fhb{align-items:stretch}
13
+ ._4cvr1h6o{align-items:center}
14
+ ._4t3i1osq{height:100%}
15
+ ._ca0q1jfw{padding-top:var(--ds-space-500,40px)}
16
+ ._n3td1jfw{padding-bottom:var(--ds-space-500,40px)}
17
+ ._u5f31jfw{padding-right:var(--ds-space-500,40px)}
@@ -0,0 +1,282 @@
1
+ /* index.tsx generated by @compiled/babel-plugin v3.0.2 */
2
+ import _extends from "@babel/runtime/helpers/extends";
3
+ import "./index.compiled.css";
4
+ import { ax, ix } from "@compiled/react/runtime";
5
+ import React, { lazy, Suspense, useCallback, useEffect, useMemo, useRef, useState } from 'react';
6
+ import { defineMessages, FormattedMessage } from 'react-intl';
7
+ import Button from '@atlaskit/button/default/button';
8
+ import Heading from '@atlaskit/heading/heading';
9
+ import { extractSmartLinkProvider } from '@atlaskit/link-extractors/extract-smart-link-provider';
10
+ import ModalBody from '@atlaskit/modal-dialog/modal-body';
11
+ import Modal from '@atlaskit/modal-dialog/modal-dialog';
12
+ import ModalTitle from '@atlaskit/modal-dialog/modal-title';
13
+ import ModalTransition from '@atlaskit/modal-dialog/modal-transition';
14
+ import { expVal } from '@atlaskit/platform-feature-experiments/exp-val';
15
+ import { Box } from '@atlaskit/primitives/compiled/box';
16
+ import { Flex } from '@atlaskit/primitives/compiled/flex';
17
+ import { Stack } from '@atlaskit/primitives/compiled/stack';
18
+ import { Text } from '@atlaskit/primitives/compiled/text';
19
+ import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
20
+ 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
+ import { SmartLinkAnalyticsContext } from '../../utils/analytics/SmartLinkAnalyticsContext';
26
+ import ImageIcon from '../common/image-icon';
27
+ const IllustrationPane = /*#__PURE__*/lazy(() => import( /* webpackChunkName: "@atlaskit-internal_smart-card-pre-auth-value-proposition-illustration" */'./IllustrationPane'));
28
+ const SOCIAL_PROOF_TEAM_PREVIEW_THRESHOLD = 30;
29
+ const SMART_LINK_MODAL_ID = 'pre-auth-value-proposition-modal';
30
+ const messages = defineMessages({
31
+ close: {
32
+ id: 'smart-card.view.PreAuthValuePropositionModal.close',
33
+ defaultMessage: 'Close',
34
+ description: 'Closes the pre-auth value proposition modal.'
35
+ },
36
+ connect: {
37
+ id: 'smart-card.view.PreAuthValuePropositionModal.connect',
38
+ defaultMessage: 'Connect {providerName}',
39
+ description: 'Connect button in the pre-auth value proposition modal. providerName is supplied by the Smart Link response.'
40
+ },
41
+ embedBenefit: {
42
+ id: 'smart-card.view.PreAuthValuePropositionModal.embedBenefit',
43
+ defaultMessage: '<b>Embed</b> richer link previews without leaving your workflow',
44
+ description: 'Explains the benefit of embedding richer Smart Link previews without leaving the current workflow.'
45
+ },
46
+ searchBenefit: {
47
+ id: 'smart-card.view.PreAuthValuePropositionModal.searchBenefit',
48
+ defaultMessage: '<b>Search</b> across {providerName} and Atlassian content in one place',
49
+ description: 'Explains the cross-product search benefit. providerName is supplied by the Smart Link response.'
50
+ },
51
+ seeBenefit: {
52
+ id: 'smart-card.view.PreAuthValuePropositionModal.seeBenefit',
53
+ defaultMessage: '<b>See</b> Rovo answers grounded in your {providerName} content',
54
+ description: 'Explains the Rovo benefit. providerName is supplied by the Smart Link response.'
55
+ },
56
+ title: {
57
+ id: 'smart-card.view.PreAuthValuePropositionModal.title',
58
+ defaultMessage: 'Connect {providerName}',
59
+ description: 'Title for the pre-auth value proposition modal. providerName is supplied by the Smart Link response.'
60
+ }
61
+ });
62
+ const styles = {
63
+ bodyCopy: "_1bsbnklw",
64
+ content: "_zulp1ejb _1e0c1txw _2lx21bp4 _4t3i1osq _n3td1jfw _19bv1jfw _u5f31jfw _ca0q1jfw",
65
+ copyColumn: "_zulppxbi _1e0c1txw _2lx21bp4 _16jlkb7n",
66
+ leftPane: "_1e0c1txw _2lx21bp4 _1o9zidpf _4t3i1osq _1bsb1kdj",
67
+ providerIcon: "_4cvr1h6o _1e0c1txw _1o9zidpf",
68
+ splitLayout: "_2rko1kw7 _1reo15vq _18m915vq _4cvr1fhb _1e0c1txw _4t3i1osq"
69
+ };
70
+ const bold = chunks => /*#__PURE__*/React.createElement(Text, {
71
+ as: "strong"
72
+ }, chunks);
73
+ const getModalCloseMethod = event => 'key' in event && event.key === 'Escape' ? 'escape' : 'overlay';
74
+ const ModalCopy = ({
75
+ connectedPct,
76
+ isSocialProofAvailable,
77
+ onClose,
78
+ onConnect,
79
+ providerIcon,
80
+ providerName
81
+ }) => {
82
+ const messageValues = {
83
+ b: bold,
84
+ providerName
85
+ };
86
+ const isSocialProofUsageHighEnough = connectedPct !== undefined && connectedPct >= SOCIAL_PROOF_TEAM_PREVIEW_THRESHOLD;
87
+ return /*#__PURE__*/React.createElement(ModalBody, {
88
+ hasInlinePadding: false
89
+ }, /*#__PURE__*/React.createElement(Box, {
90
+ xcss: styles.content
91
+ }, /*#__PURE__*/React.createElement(Box, {
92
+ xcss: styles.copyColumn
93
+ }, /*#__PURE__*/React.createElement(Stack, {
94
+ space: "space.250"
95
+ }, providerIcon && /*#__PURE__*/React.createElement(Box, {
96
+ xcss: styles.providerIcon
97
+ }, providerIcon), /*#__PURE__*/React.createElement(ModalTitle, {
98
+ isMultiline: false
99
+ }, /*#__PURE__*/React.createElement(Heading, {
100
+ as: "span",
101
+ color: "color.text",
102
+ size: "large"
103
+ }, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.title, {
104
+ values: {
105
+ providerName
106
+ }
107
+ }))))), /*#__PURE__*/React.createElement(Box, {
108
+ xcss: styles.bodyCopy
109
+ }, /*#__PURE__*/React.createElement(Stack, {
110
+ space: "space.200"
111
+ }, /*#__PURE__*/React.createElement(Text, {
112
+ as: "p",
113
+ color: "color.text",
114
+ size: "large"
115
+ }, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.seeBenefit, {
116
+ values: messageValues
117
+ }))), /*#__PURE__*/React.createElement(Text, {
118
+ as: "p",
119
+ color: "color.text",
120
+ size: "large"
121
+ }, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.searchBenefit, {
122
+ values: messageValues
123
+ }))), /*#__PURE__*/React.createElement(Text, {
124
+ as: "p",
125
+ color: "color.text",
126
+ size: "large"
127
+ }, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.embedBenefit, {
128
+ values: messageValues
129
+ })))))), isSocialProofAvailable && /*#__PURE__*/React.createElement(Text, {
130
+ as: "p",
131
+ color: "color.text.subtlest",
132
+ size: "small",
133
+ testId: "pre-auth-value-proposition-modal-social-proof"
134
+ }, isSocialProofUsageHighEnough ? /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, smartCardMessages.social_proof_inline_cta_tag_high_with_context, {
135
+ values: {
136
+ connectedPct,
137
+ context: providerName,
138
+ b: bold
139
+ }
140
+ })) : /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, smartCardMessages.social_proof_inline_cta_tag_low_with_context, {
141
+ values: {
142
+ context: providerName
143
+ }
144
+ }))), /*#__PURE__*/React.createElement(Flex, {
145
+ gap: "space.075",
146
+ justifyContent: "start"
147
+ }, /*#__PURE__*/React.createElement(Button, {
148
+ appearance: "primary",
149
+ onClick: onConnect,
150
+ autoFocus: true,
151
+ spacing: "default"
152
+ }, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.connect, {
153
+ values: {
154
+ providerName
155
+ }
156
+ }))), /*#__PURE__*/React.createElement(Button, {
157
+ appearance: "subtle",
158
+ onClick: onClose
159
+ }, /*#__PURE__*/React.createElement(FormattedMessage, messages.close)))));
160
+ };
161
+ const PreAuthValuePropositionModalContent = ({
162
+ onFinished,
163
+ url
164
+ }) => {
165
+ var _provider$iconLabel;
166
+ const {
167
+ actions,
168
+ config,
169
+ state
170
+ } = useSmartLink(SMART_LINK_MODAL_ID, url, 'inline');
171
+ const {
172
+ fireEvent
173
+ } = useAnalyticsEvents();
174
+ const [isOpen, setIsOpen] = useState(false);
175
+ const [visibleVariant, setVisibleVariant] = useState('modal_text_only');
176
+ const modalOpenTimeRef = useRef(Date.now());
177
+ const provider = useMemo(() => extractSmartLinkProvider(state.details), [state.details]);
178
+ const providerName = provider === null || provider === void 0 ? void 0 : provider.text;
179
+ const providerIconUrl = typeof (provider === null || provider === void 0 ? void 0 : provider.icon) === 'string' ? provider.icon : undefined;
180
+ const renderProviderIcon = (size, testId, label) => {
181
+ if (providerIconUrl) {
182
+ const sizePx = `${size}px`;
183
+ return /*#__PURE__*/React.createElement(ImageIcon, {
184
+ height: sizePx,
185
+ hideLoadingSkeleton: true,
186
+ label: label !== null && label !== void 0 ? label : '',
187
+ testId: testId,
188
+ url: providerIconUrl,
189
+ width: sizePx
190
+ });
191
+ }
192
+ return provider === null || provider === void 0 ? void 0 : provider.icon;
193
+ };
194
+ 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);
195
+ const services = getServices(state.details);
196
+ const extensionKey = getExtensionKey(state.details);
197
+ const {
198
+ connectedPct,
199
+ isEnabled: isSocialProofAvailable
200
+ } = useSocialProof(extensionKey, true);
201
+ const hasSupportedAuthorization = (config === null || config === void 0 ? void 0 : config.authFlow) !== 'disabled' && services.length > 0;
202
+ const isBaseEligible = state.status === 'unauthorized' && Boolean(providerName) && Boolean(extensionKey) && hasSupportedAuthorization;
203
+ useEffect(() => {
204
+ if (state.status === 'pending' || state.status === 'resolving') {
205
+ return;
206
+ }
207
+ if (!isBaseEligible || !extensionKey || preAuthValuePropositionModalService.hasReachedShowLimit(extensionKey)) {
208
+ onFinished();
209
+ return;
210
+ }
211
+ const experimentVariant = expVal('platform_sl_3p_preauth_value_modal', 'variant', 'control');
212
+ if (experimentVariant === 'modal_text_only' || experimentVariant === 'modal_with_image') {
213
+ preAuthValuePropositionModalService.recordShow(extensionKey);
214
+ setVisibleVariant(experimentVariant);
215
+ setIsOpen(true);
216
+ return;
217
+ }
218
+ onFinished();
219
+ }, [extensionKey, isBaseEligible, onFinished, state.status]);
220
+ const dismissModal = useCallback(closeMethod => {
221
+ fireEvent('ui.modal.closed.preAuthValueProposition', {
222
+ closeMethod,
223
+ dwellTime: Date.now() - modalOpenTimeRef.current
224
+ });
225
+ setIsOpen(false);
226
+ onFinished();
227
+ }, [fireEvent, onFinished]);
228
+ const handleCloseButton = useCallback(() => {
229
+ dismissModal('button');
230
+ }, [dismissModal]);
231
+ const handleModalClose = useCallback(event => {
232
+ dismissModal(getModalCloseMethod(event));
233
+ }, [dismissModal]);
234
+ const handleOpenComplete = useCallback(() => {
235
+ modalOpenTimeRef.current = Date.now();
236
+ fireEvent('ui.modal.opened.preAuthValueProposition', {});
237
+ }, [fireEvent]);
238
+ const connectAccount = useCallback(() => {
239
+ fireEvent('track.applicationAccount.authStarted', {});
240
+ setIsOpen(false);
241
+ actions.authorize('inline');
242
+ onFinished();
243
+ }, [actions, fireEvent, onFinished]);
244
+ if (!isOpen || !providerName) {
245
+ return null;
246
+ }
247
+ const modalCopy = /*#__PURE__*/React.createElement(ModalCopy, {
248
+ connectedPct: connectedPct,
249
+ isSocialProofAvailable: isSocialProofAvailable,
250
+ onClose: handleCloseButton,
251
+ onConnect: connectAccount,
252
+ providerIcon: providerIcon,
253
+ providerName: providerName
254
+ });
255
+ const showIllustration = visibleVariant === 'modal_with_image';
256
+ return /*#__PURE__*/React.createElement(ModalTransition, null, /*#__PURE__*/React.createElement(Modal, {
257
+ onClose: handleModalClose,
258
+ onOpenComplete: handleOpenComplete,
259
+ testId: "pre-auth-value-proposition-modal",
260
+ width: showIllustration ? 800 : 400
261
+ }, showIllustration ? /*#__PURE__*/React.createElement(Box, {
262
+ xcss: styles.splitLayout
263
+ }, /*#__PURE__*/React.createElement(Box, {
264
+ xcss: styles.leftPane
265
+ }, modalCopy), /*#__PURE__*/React.createElement(Suspense, {
266
+ fallback: null
267
+ }, /*#__PURE__*/React.createElement(IllustrationPane, {
268
+ renderProviderIcon: renderProviderIcon
269
+ }))) : modalCopy));
270
+ };
271
+ export const PreAuthValuePropositionModal = ({
272
+ onFinished,
273
+ url
274
+ }) => /*#__PURE__*/React.createElement(SmartLinkAnalyticsContext, {
275
+ display: "inline",
276
+ id: SMART_LINK_MODAL_ID,
277
+ source: "preAuthValuePropositionModal",
278
+ url: url
279
+ }, /*#__PURE__*/React.createElement(PreAuthValuePropositionModalContent, {
280
+ onFinished: onFinished,
281
+ url: url
282
+ }));
@@ -0,0 +1,3 @@
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:518c13af727406b6945913719c3ac167a691d4cf00a9535024a36307f71ec6ca
3
+ size 38742
@@ -0,0 +1,3 @@
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ded63043b0e672f2cd8a3f3c005736b62312f9afce2973d8876e281f39e70e7b
3
+ size 62949
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Generates Typescript types for analytics events from analytics.spec.yaml
5
5
  *
6
- * @codegen <<SignedSource::ac0d75fa9e8d43c947e88f47ba1267aa>>
6
+ * @codegen <<SignedSource::4715d46f4a378244afd94dadfd9e5f51>>
7
7
  * @codegenCommand yarn workspace @atlassian/analytics-tooling run analytics:codegen smart-card
8
8
  */
9
9
  import { useCallback } from 'react';
@@ -0,0 +1 @@
1
+ export { PreAuthValuePropositionModal } from '../view/PreAuthValuePropositionModal';
@@ -0,0 +1,115 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
+ import _createClass from "@babel/runtime/helpers/createClass";
4
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
+ import _typeof from "@babel/runtime/helpers/typeof";
6
+ import { StorageClient } from '@atlaskit/frontend-utilities/StorageClient';
7
+ var SMART_CARD_STORAGE_SCOPE = '@atlaskit/smart-card';
8
+ export var PRE_AUTH_VALUE_PROPOSITION_MODAL_STORAGE_ITEM_KEY = 'pre-auth-value-proposition-modal-shown-providers:v3';
9
+ var weekInMs = 7 * 24 * 60 * 60 * 1000;
10
+ export var PRE_AUTH_VALUE_PROPOSITION_MODAL_COOLDOWN_MS = weekInMs;
11
+ var smartCardStorage;
12
+ var getSmartCardStorage = function getSmartCardStorage() {
13
+ if (typeof window === 'undefined') {
14
+ return null;
15
+ }
16
+ if (smartCardStorage !== undefined) {
17
+ return smartCardStorage;
18
+ }
19
+ try {
20
+ smartCardStorage = new StorageClient(SMART_CARD_STORAGE_SCOPE);
21
+ } catch (_unused) {
22
+ smartCardStorage = null;
23
+ }
24
+ return smartCardStorage;
25
+ };
26
+ var isShownExtensionKeys = function isShownExtensionKeys(value) {
27
+ return Array.isArray(value) && value.every(function (extensionKey) {
28
+ return typeof extensionKey === 'string';
29
+ });
30
+ };
31
+ var isStoredShowState = function isStoredShowState(value) {
32
+ if (_typeof(value) !== 'object' || value === null) {
33
+ return false;
34
+ }
35
+ var storedShowState = value;
36
+ return typeof storedShowState.lastShownAt === 'number' && Number.isFinite(storedShowState.lastShownAt) && isShownExtensionKeys(storedShowState.shownExtensionKeys);
37
+ };
38
+ var EMPTY_STORED_SHOW_STATE = {
39
+ lastShownAt: 0,
40
+ shownExtensionKeys: []
41
+ };
42
+ export var PreAuthValuePropositionModalService = /*#__PURE__*/function () {
43
+ function PreAuthValuePropositionModalService() {
44
+ _classCallCheck(this, PreAuthValuePropositionModalService);
45
+ _defineProperty(this, "storedShowState", null);
46
+ }
47
+ return _createClass(PreAuthValuePropositionModalService, [{
48
+ key: "hasReachedShowLimit",
49
+ value: function hasReachedShowLimit(extensionKey) {
50
+ var _this$getStoredShowSt = this.getStoredShowState(),
51
+ lastShownAt = _this$getStoredShowSt.lastShownAt,
52
+ shownExtensionKeys = _this$getStoredShowSt.shownExtensionKeys;
53
+ if (shownExtensionKeys.includes(extensionKey)) {
54
+ return true;
55
+ }
56
+ return lastShownAt > 0 && Date.now() - lastShownAt < PRE_AUTH_VALUE_PROPOSITION_MODAL_COOLDOWN_MS;
57
+ }
58
+ }, {
59
+ key: "recordShow",
60
+ value: function recordShow(extensionKey) {
61
+ if (this.hasReachedShowLimit(extensionKey)) {
62
+ return;
63
+ }
64
+ var _this$getStoredShowSt2 = this.getStoredShowState(),
65
+ shownExtensionKeys = _this$getStoredShowSt2.shownExtensionKeys;
66
+ var nextStoredShowState = {
67
+ lastShownAt: Date.now(),
68
+ shownExtensionKeys: [].concat(_toConsumableArray(shownExtensionKeys), [extensionKey])
69
+ };
70
+ this.storedShowState = nextStoredShowState;
71
+ try {
72
+ var _getSmartCardStorage;
73
+ (_getSmartCardStorage = getSmartCardStorage()) === null || _getSmartCardStorage === void 0 || _getSmartCardStorage.setItemWithExpiry(PRE_AUTH_VALUE_PROPOSITION_MODAL_STORAGE_ITEM_KEY, nextStoredShowState);
74
+ } catch (_unused2) {
75
+ // Browser Storage Controls, quota, private mode, and SSR must not break the editor.
76
+ }
77
+ }
78
+ }, {
79
+ key: "reset",
80
+ value: function reset() {
81
+ this.storedShowState = null;
82
+ try {
83
+ var _getSmartCardStorage2;
84
+ (_getSmartCardStorage2 = getSmartCardStorage()) === null || _getSmartCardStorage2 === void 0 || _getSmartCardStorage2.removeItem(PRE_AUTH_VALUE_PROPOSITION_MODAL_STORAGE_ITEM_KEY);
85
+ } catch (_unused3) {
86
+ // Browser Storage Controls, quota, private mode, and SSR must not break the editor.
87
+ }
88
+ }
89
+ }, {
90
+ key: "getStoredShowState",
91
+ value: function getStoredShowState() {
92
+ if (this.storedShowState !== null) {
93
+ return this.storedShowState;
94
+ }
95
+ var storedShowState = this.readStoredShowState();
96
+ this.storedShowState = storedShowState;
97
+ return storedShowState;
98
+ }
99
+ }, {
100
+ key: "readStoredShowState",
101
+ value: function readStoredShowState() {
102
+ try {
103
+ var _getSmartCardStorage3;
104
+ var storedShowState = (_getSmartCardStorage3 = getSmartCardStorage()) === null || _getSmartCardStorage3 === void 0 ? void 0 : _getSmartCardStorage3.getItem(PRE_AUTH_VALUE_PROPOSITION_MODAL_STORAGE_ITEM_KEY);
105
+ if (!isStoredShowState(storedShowState)) {
106
+ return EMPTY_STORED_SHOW_STATE;
107
+ }
108
+ return storedShowState;
109
+ } catch (_unused4) {
110
+ return EMPTY_STORED_SHOW_STATE;
111
+ }
112
+ }
113
+ }]);
114
+ }();
115
+ export var preAuthValuePropositionModalService = new PreAuthValuePropositionModalService();
@@ -4,7 +4,7 @@ export var ANALYTICS_CHANNEL = 'media';
4
4
  export var context = {
5
5
  componentName: 'smart-cards',
6
6
  packageName: "@atlaskit/smart-card" || '',
7
- packageVersion: "45.27.0" || ''
7
+ packageVersion: "45.27.1" || ''
8
8
  };
9
9
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";