@atlaskit/smart-card 46.15.0 → 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.
- package/CHANGELOG.md +17 -0
- package/analytics.spec.yaml +2 -2
- package/dist/cjs/utils/analytics/analytics.js +1 -1
- package/dist/cjs/view/LinkUrl/index.js +1 -1
- package/dist/cjs/view/PreAuthValuePropositionModal/index.js +56 -110
- package/dist/cjs/view/PreAuthValuePropositionModal/use-pre-auth-value-proposition-modal.js +175 -0
- package/dist/es2019/utils/analytics/analytics.js +1 -1
- package/dist/es2019/view/LinkUrl/index.js +1 -1
- package/dist/es2019/view/PreAuthValuePropositionModal/index.js +54 -102
- package/dist/es2019/view/PreAuthValuePropositionModal/use-pre-auth-value-proposition-modal.js +160 -0
- package/dist/esm/utils/analytics/analytics.js +1 -1
- package/dist/esm/view/LinkUrl/index.js +1 -1
- package/dist/esm/view/PreAuthValuePropositionModal/index.js +56 -110
- package/dist/esm/view/PreAuthValuePropositionModal/use-pre-auth-value-proposition-modal.js +167 -0
- package/dist/types/common/analytics/generated/analytics.types.d.ts +2 -2
- package/dist/types/view/PreAuthValuePropositionModal/index.d.ts +1 -1
- package/dist/types/view/PreAuthValuePropositionModal/use-pre-auth-value-proposition-modal.d.ts +31 -0
- package/package.json +6 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/smart-card
|
|
2
2
|
|
|
3
|
+
## 46.16.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`b246dad7a0032`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b246dad7a0032) -
|
|
8
|
+
Update i18n NPM package versions for linking-platform,smart-experiences (Group 15)
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- [`79bf848b02b91`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/79bf848b02b91) -
|
|
13
|
+
Use the existing Smart Card choreographer integration for the pre-auth value modal under
|
|
14
|
+
platform_sl_3p_preauth_value_modal_killswitch. Add an optional slot-offer predicate to recheck
|
|
15
|
+
eligibility, frequency caps and experiment assignment before claiming permission. Keep the
|
|
16
|
+
existing modal API and editor toolbar integration, and count early user interactions toward the
|
|
17
|
+
frequency cap.
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 46.15.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
package/analytics.spec.yaml
CHANGED
|
@@ -338,8 +338,8 @@ events:
|
|
|
338
338
|
<<: [*PackageMetaDataContext, *CommonContext]
|
|
339
339
|
closeMethod:
|
|
340
340
|
required: true
|
|
341
|
-
type: ['button', 'escape', 'overlay']
|
|
342
|
-
description: How the
|
|
341
|
+
type: ['button', 'escape', 'overlay', 'coordinator']
|
|
342
|
+
description: How the modal closed. Coordinator withdrawal is not a user dismissal.
|
|
343
343
|
dwellTime:
|
|
344
344
|
required: true
|
|
345
345
|
type: number
|
|
@@ -25,7 +25,7 @@ var ANALYTICS_CHANNEL = exports.ANALYTICS_CHANNEL = 'media';
|
|
|
25
25
|
var context = exports.context = {
|
|
26
26
|
componentName: 'smart-cards',
|
|
27
27
|
packageName: "@atlaskit/smart-card" || '',
|
|
28
|
-
packageVersion: "46.
|
|
28
|
+
packageVersion: "46.15.0" || ''
|
|
29
29
|
};
|
|
30
30
|
var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
31
31
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -19,7 +19,7 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId", "isLink
|
|
|
19
19
|
_excluded2 = ["isLinkSafe", "showSafetyWarningModal"];
|
|
20
20
|
var PACKAGE_DATA = {
|
|
21
21
|
packageName: "@atlaskit/smart-card",
|
|
22
|
-
packageVersion: "46.
|
|
22
|
+
packageVersion: "46.15.0",
|
|
23
23
|
componentName: 'linkUrl'
|
|
24
24
|
};
|
|
25
25
|
var LinkUrl = function LinkUrl(_ref) {
|
|
@@ -9,30 +9,27 @@ exports.PreAuthValuePropositionModal = void 0;
|
|
|
9
9
|
require("./index.compiled.css");
|
|
10
10
|
var _runtime = require("@compiled/react/runtime");
|
|
11
11
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
12
|
-
var
|
|
12
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
13
13
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
14
14
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
+
var _reactErrorBoundary = require("react-error-boundary");
|
|
15
16
|
var _reactIntl = require("react-intl");
|
|
16
17
|
var _button = _interopRequireDefault(require("@atlaskit/button/default/button"));
|
|
17
18
|
var _heading = _interopRequireDefault(require("@atlaskit/heading/heading"));
|
|
18
|
-
var
|
|
19
|
+
var _choreographedContent = require("@atlaskit/link-provider/choreographed-content");
|
|
19
20
|
var _modalBody = _interopRequireDefault(require("@atlaskit/modal-dialog/modal-body"));
|
|
20
21
|
var _modalDialog = _interopRequireDefault(require("@atlaskit/modal-dialog/modal-dialog"));
|
|
21
22
|
var _modalTitle = _interopRequireDefault(require("@atlaskit/modal-dialog/modal-title"));
|
|
22
23
|
var _modalTransition = _interopRequireDefault(require("@atlaskit/modal-dialog/modal-transition"));
|
|
23
|
-
var _expVal = require("@atlaskit/platform-feature-experiments/exp-val");
|
|
24
24
|
var _box = require("@atlaskit/primitives/compiled/box");
|
|
25
25
|
var _flex = require("@atlaskit/primitives/compiled/flex");
|
|
26
26
|
var _stack = require("@atlaskit/primitives/compiled/stack");
|
|
27
27
|
var _text = require("@atlaskit/primitives/compiled/text");
|
|
28
|
-
var _useAnalyticsEvents2 = require("../../common/analytics/generated/use-analytics-events");
|
|
29
28
|
var _messages = require("../../messages");
|
|
30
|
-
var _helpers = require("../../state/helpers");
|
|
31
|
-
var _useSocialProof2 = _interopRequireDefault(require("../../state/hooks/use-social-proof"));
|
|
32
|
-
var _useSmartLink2 = require("../../state/hooks/useSmartLink");
|
|
33
|
-
var _preAuthValuePropositionModal = require("../../state/services/pre-auth-value-proposition-modal");
|
|
34
29
|
var _SmartLinkAnalyticsContext = require("../../utils/analytics/SmartLinkAnalyticsContext");
|
|
35
30
|
var _imageIcon = _interopRequireDefault(require("../common/image-icon"));
|
|
31
|
+
var _usePreAuthValuePropositionModal = require("./use-pre-auth-value-proposition-modal");
|
|
32
|
+
var _excluded = ["onOpenChange"];
|
|
36
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" != (0, _typeof2.default)(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); }
|
|
37
34
|
var IllustrationPane = /*#__PURE__*/(0, _react.lazy)(function () {
|
|
38
35
|
return Promise.resolve().then(function () {
|
|
@@ -40,7 +37,6 @@ var IllustrationPane = /*#__PURE__*/(0, _react.lazy)(function () {
|
|
|
40
37
|
});
|
|
41
38
|
});
|
|
42
39
|
var SOCIAL_PROOF_TEAM_PREVIEW_THRESHOLD = 30;
|
|
43
|
-
var SMART_LINK_MODAL_ID = 'pre-auth-value-proposition-modal';
|
|
44
40
|
var messages = (0, _reactIntl.defineMessages)({
|
|
45
41
|
close: {
|
|
46
42
|
id: 'smart-card.view.PreAuthValuePropositionModal.close',
|
|
@@ -88,9 +84,6 @@ var bold = function bold(chunks) {
|
|
|
88
84
|
as: "strong"
|
|
89
85
|
}, chunks);
|
|
90
86
|
};
|
|
91
|
-
var getModalCloseMethod = function getModalCloseMethod(event) {
|
|
92
|
-
return 'key' in event && event.key === 'Escape' ? 'escape' : 'overlay';
|
|
93
|
-
};
|
|
94
87
|
var ModalCopy = function ModalCopy(_ref) {
|
|
95
88
|
var connectedPct = _ref.connectedPct,
|
|
96
89
|
isSocialProofAvailable = _ref.isSocialProofAvailable,
|
|
@@ -182,40 +175,26 @@ var ModalCopy = function ModalCopy(_ref) {
|
|
|
182
175
|
onClick: onClose
|
|
183
176
|
}, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, messages.close))))));
|
|
184
177
|
};
|
|
185
|
-
|
|
178
|
+
|
|
179
|
+
/** Mounted only while the existing choreographer grants permission. */
|
|
180
|
+
var ModalContent = function ModalContent(_ref2) {
|
|
186
181
|
var _provider$iconLabel;
|
|
187
|
-
var
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
var _useState = (0, _react.useState)(false),
|
|
197
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
198
|
-
isOpen = _useState2[0],
|
|
199
|
-
setIsOpen = _useState2[1];
|
|
200
|
-
var _useState3 = (0, _react.useState)('modal_text_only'),
|
|
201
|
-
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
202
|
-
visibleVariant = _useState4[0],
|
|
203
|
-
setVisibleVariant = _useState4[1];
|
|
204
|
-
var modalOpenTimeRef = (0, _react.useRef)(Date.now());
|
|
205
|
-
var provider = (0, _react.useMemo)(function () {
|
|
206
|
-
return (0, _extractSmartLinkProvider.extractSmartLinkProvider)(state.details);
|
|
207
|
-
}, [state.details]);
|
|
208
|
-
var providerName = provider === null || provider === void 0 ? void 0 : provider.text;
|
|
209
|
-
var isVisible = isOpen && Boolean(providerName);
|
|
182
|
+
var provider = _ref2.provider,
|
|
183
|
+
variant = _ref2.variant,
|
|
184
|
+
connectedPct = _ref2.connectedPct,
|
|
185
|
+
isSocialProofAvailable = _ref2.isSocialProofAvailable,
|
|
186
|
+
onClose = _ref2.onClose,
|
|
187
|
+
onCloseButton = _ref2.onCloseButton,
|
|
188
|
+
onConnect = _ref2.onConnect,
|
|
189
|
+
onOpenComplete = _ref2.onOpenComplete,
|
|
190
|
+
onOpenChange = _ref2.onOpenChange;
|
|
210
191
|
(0, _react.useEffect)(function () {
|
|
211
|
-
if (!isVisible) {
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
192
|
onOpenChange === null || onOpenChange === void 0 || onOpenChange(true);
|
|
215
193
|
return function () {
|
|
216
194
|
return onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(false);
|
|
217
195
|
};
|
|
218
|
-
}, [
|
|
196
|
+
}, [onOpenChange]);
|
|
197
|
+
var providerName = provider === null || provider === void 0 ? void 0 : provider.text;
|
|
219
198
|
var providerIconUrl = typeof (provider === null || provider === void 0 ? void 0 : provider.icon) === 'string' ? provider.icon : undefined;
|
|
220
199
|
var renderProviderIcon = function renderProviderIcon(size, testId, label) {
|
|
221
200
|
if (providerIconUrl) {
|
|
@@ -232,69 +211,18 @@ var PreAuthValuePropositionModalContent = function PreAuthValuePropositionModalC
|
|
|
232
211
|
return provider === null || provider === void 0 ? void 0 : provider.icon;
|
|
233
212
|
};
|
|
234
213
|
var 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);
|
|
235
|
-
var services = (0, _helpers.getServices)(state.details);
|
|
236
|
-
var extensionKey = (0, _helpers.getExtensionKey)(state.details);
|
|
237
|
-
var _useSocialProof = (0, _useSocialProof2.default)(extensionKey, true),
|
|
238
|
-
connectedPct = _useSocialProof.connectedPct,
|
|
239
|
-
isSocialProofAvailable = _useSocialProof.isEnabled;
|
|
240
|
-
var hasSupportedAuthorization = (config === null || config === void 0 ? void 0 : config.authFlow) !== 'disabled' && services.length > 0;
|
|
241
|
-
var isBaseEligible = state.status === 'unauthorized' && Boolean(providerName) && Boolean(extensionKey) && hasSupportedAuthorization;
|
|
242
|
-
(0, _react.useEffect)(function () {
|
|
243
|
-
if (state.status === 'pending' || state.status === 'resolving') {
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
if (!isBaseEligible || !extensionKey || _preAuthValuePropositionModal.preAuthValuePropositionModalService.hasReachedShowLimit(extensionKey)) {
|
|
247
|
-
onFinished();
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
var experimentVariant = (0, _expVal.expVal)('platform_sl_3p_preauth_value_modal', 'variant', 'control');
|
|
251
|
-
if (experimentVariant === 'modal_text_only' || experimentVariant === 'modal_with_image') {
|
|
252
|
-
_preAuthValuePropositionModal.preAuthValuePropositionModalService.recordShow(extensionKey);
|
|
253
|
-
setVisibleVariant(experimentVariant);
|
|
254
|
-
setIsOpen(true);
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
onFinished();
|
|
258
|
-
}, [extensionKey, isBaseEligible, onFinished, state.status]);
|
|
259
|
-
var dismissModal = (0, _react.useCallback)(function (closeMethod) {
|
|
260
|
-
fireEvent('ui.modal.closed.preAuthValueProposition', {
|
|
261
|
-
closeMethod: closeMethod,
|
|
262
|
-
dwellTime: Date.now() - modalOpenTimeRef.current
|
|
263
|
-
});
|
|
264
|
-
setIsOpen(false);
|
|
265
|
-
onFinished();
|
|
266
|
-
}, [fireEvent, onFinished]);
|
|
267
|
-
var handleCloseButton = (0, _react.useCallback)(function () {
|
|
268
|
-
dismissModal('button');
|
|
269
|
-
}, [dismissModal]);
|
|
270
|
-
var handleModalClose = (0, _react.useCallback)(function (event) {
|
|
271
|
-
dismissModal(getModalCloseMethod(event));
|
|
272
|
-
}, [dismissModal]);
|
|
273
|
-
var handleOpenComplete = (0, _react.useCallback)(function () {
|
|
274
|
-
modalOpenTimeRef.current = Date.now();
|
|
275
|
-
fireEvent('ui.modal.opened.preAuthValueProposition', {});
|
|
276
|
-
}, [fireEvent]);
|
|
277
|
-
var connectAccount = (0, _react.useCallback)(function () {
|
|
278
|
-
fireEvent('track.applicationAccount.authStarted', {});
|
|
279
|
-
setIsOpen(false);
|
|
280
|
-
actions.authorize('inline');
|
|
281
|
-
onFinished();
|
|
282
|
-
}, [actions, fireEvent, onFinished]);
|
|
283
|
-
if (!isOpen || !providerName) {
|
|
284
|
-
return null;
|
|
285
|
-
}
|
|
286
214
|
var modalCopy = /*#__PURE__*/_react.default.createElement(ModalCopy, {
|
|
287
215
|
connectedPct: connectedPct,
|
|
288
216
|
isSocialProofAvailable: isSocialProofAvailable,
|
|
289
|
-
onClose:
|
|
290
|
-
onConnect:
|
|
217
|
+
onClose: onCloseButton,
|
|
218
|
+
onConnect: onConnect,
|
|
291
219
|
providerIcon: providerIcon,
|
|
292
|
-
providerName: providerName
|
|
220
|
+
providerName: providerName !== null && providerName !== void 0 ? providerName : ''
|
|
293
221
|
});
|
|
294
|
-
var showIllustration =
|
|
295
|
-
|
|
296
|
-
onClose:
|
|
297
|
-
onOpenComplete:
|
|
222
|
+
var showIllustration = variant === 'modal_with_image';
|
|
223
|
+
var modal = providerName ? /*#__PURE__*/_react.default.createElement(_modalTransition.default, null, /*#__PURE__*/_react.default.createElement(_modalDialog.default, {
|
|
224
|
+
onClose: onClose,
|
|
225
|
+
onOpenComplete: onOpenComplete,
|
|
298
226
|
testId: "pre-auth-value-proposition-modal",
|
|
299
227
|
width: showIllustration ? 800 : 400
|
|
300
228
|
}, showIllustration ? /*#__PURE__*/_react.default.createElement(_box.Box, {
|
|
@@ -305,20 +233,38 @@ var PreAuthValuePropositionModalContent = function PreAuthValuePropositionModalC
|
|
|
305
233
|
fallback: null
|
|
306
234
|
}, /*#__PURE__*/_react.default.createElement(IllustrationPane, {
|
|
307
235
|
renderProviderIcon: renderProviderIcon
|
|
308
|
-
}))) : modalCopy));
|
|
236
|
+
}))) : modalCopy)) : null;
|
|
237
|
+
return modal;
|
|
238
|
+
};
|
|
239
|
+
var PreAuthValuePropositionModalContent = function PreAuthValuePropositionModalContent(_ref3) {
|
|
240
|
+
var onOpenChange = _ref3.onOpenChange,
|
|
241
|
+
options = (0, _objectWithoutProperties2.default)(_ref3, _excluded);
|
|
242
|
+
var _usePreAuthValuePropo = (0, _usePreAuthValuePropositionModal.usePreAuthValuePropositionModal)(options),
|
|
243
|
+
isActive = _usePreAuthValuePropo.isActive,
|
|
244
|
+
isEligible = _usePreAuthValuePropo.isEligible,
|
|
245
|
+
onUnavailable = _usePreAuthValuePropo.onUnavailable,
|
|
246
|
+
shouldClaim = _usePreAuthValuePropo.shouldClaim,
|
|
247
|
+
modal = _usePreAuthValuePropo.modal;
|
|
248
|
+
return /*#__PURE__*/_react.default.createElement(_choreographedContent.ChoreographedContent, {
|
|
249
|
+
messageId: "smart-link-pre-auth-value-proposition-modal",
|
|
250
|
+
isActive: isActive,
|
|
251
|
+
onUnavailable: onUnavailable,
|
|
252
|
+
shouldClaim: shouldClaim
|
|
253
|
+
}, function (_ref4) {
|
|
254
|
+
var hasPermission = _ref4.hasPermission;
|
|
255
|
+
return hasPermission && isEligible ? /*#__PURE__*/_react.default.createElement(_reactErrorBoundary.ErrorBoundary, {
|
|
256
|
+
fallback: null,
|
|
257
|
+
onError: onUnavailable
|
|
258
|
+
}, /*#__PURE__*/_react.default.createElement(ModalContent, (0, _extends2.default)({}, modal, {
|
|
259
|
+
onOpenChange: onOpenChange
|
|
260
|
+
}))) : null;
|
|
261
|
+
});
|
|
309
262
|
};
|
|
310
|
-
var PreAuthValuePropositionModal = exports.PreAuthValuePropositionModal = function PreAuthValuePropositionModal(
|
|
311
|
-
var onFinished = _ref3.onFinished,
|
|
312
|
-
onOpenChange = _ref3.onOpenChange,
|
|
313
|
-
url = _ref3.url;
|
|
263
|
+
var PreAuthValuePropositionModal = exports.PreAuthValuePropositionModal = function PreAuthValuePropositionModal(props) {
|
|
314
264
|
return /*#__PURE__*/_react.default.createElement(_SmartLinkAnalyticsContext.SmartLinkAnalyticsContext, {
|
|
315
265
|
display: "inline",
|
|
316
|
-
id: SMART_LINK_MODAL_ID,
|
|
266
|
+
id: _usePreAuthValuePropositionModal.SMART_LINK_MODAL_ID,
|
|
317
267
|
source: "preAuthValuePropositionModal",
|
|
318
|
-
url: url
|
|
319
|
-
}, /*#__PURE__*/_react.default.createElement(PreAuthValuePropositionModalContent,
|
|
320
|
-
onFinished: onFinished,
|
|
321
|
-
onOpenChange: onOpenChange,
|
|
322
|
-
url: url
|
|
323
|
-
}));
|
|
268
|
+
url: props.url
|
|
269
|
+
}, /*#__PURE__*/_react.default.createElement(PreAuthValuePropositionModalContent, props));
|
|
324
270
|
};
|
|
@@ -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
|
+
}
|
|
@@ -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.
|
|
7
|
+
packageVersion: "46.15.0" || ''
|
|
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: "46.
|
|
12
|
+
packageVersion: "46.15.0",
|
|
13
13
|
componentName: 'linkUrl'
|
|
14
14
|
};
|
|
15
15
|
const LinkUrl = ({
|