@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.
- package/CHANGELOG.md +31 -0
- package/analytics.spec.yaml +2 -2
- package/dist/cjs/__tests__/vr-tests/bitbucket-favicon.svg +1 -0
- package/dist/cjs/utils/analytics/analytics.js +1 -1
- package/dist/cjs/utils/get-icon-for-file-type.js +6 -25
- package/dist/cjs/view/EmbedCard/views/ResolvedView.js +1 -20
- package/dist/cjs/view/FlexibleCard/components/actions/follow-action/index.js +5 -41
- package/dist/cjs/view/FlexibleCard/components/common/atlaskit-icon/index.js +3 -35
- 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/__tests__/vr-tests/bitbucket-favicon.svg +1 -0
- package/dist/es2019/utils/analytics/analytics.js +1 -1
- package/dist/es2019/utils/get-icon-for-file-type.js +6 -19
- package/dist/es2019/view/EmbedCard/views/ResolvedView.js +1 -11
- package/dist/es2019/view/FlexibleCard/components/actions/follow-action/index.js +1 -26
- package/dist/es2019/view/FlexibleCard/components/common/atlaskit-icon/index.js +3 -29
- 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/__tests__/vr-tests/bitbucket-favicon.svg +1 -0
- package/dist/esm/utils/analytics/analytics.js +1 -1
- package/dist/esm/utils/get-icon-for-file-type.js +6 -25
- package/dist/esm/view/EmbedCard/views/ResolvedView.js +1 -17
- package/dist/esm/view/FlexibleCard/components/actions/follow-action/index.js +5 -36
- package/dist/esm/view/FlexibleCard/components/common/atlaskit-icon/index.js +3 -35
- 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 +7 -7
- package/dist/cjs/view/FlexibleCard/components/importIcon.js +0 -20
- package/dist/es2019/view/FlexibleCard/components/importIcon.js +0 -7
- package/dist/esm/view/FlexibleCard/components/importIcon.js +0 -13
- package/dist/types/view/FlexibleCard/components/importIcon.d.ts +0 -1
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
+
import { extractSmartLinkProvider } from '@atlaskit/link-extractors/extract-smart-link-provider';
|
|
4
|
+
import { expVal } from '@atlaskit/platform-feature-experiments/exp-val';
|
|
5
|
+
import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
|
|
6
|
+
import { getExtensionKey, getServices } from '../../state/helpers';
|
|
7
|
+
import useSocialProof from '../../state/hooks/use-social-proof';
|
|
8
|
+
import { useSmartLink } from '../../state/hooks/useSmartLink';
|
|
9
|
+
import { preAuthValuePropositionModalService } from '../../state/services/pre-auth-value-proposition-modal';
|
|
10
|
+
export var SMART_LINK_MODAL_ID = 'pre-auth-value-proposition-modal';
|
|
11
|
+
var getModalCloseMethod = function getModalCloseMethod(event) {
|
|
12
|
+
return 'key' in event && event.key === 'Escape' ? 'escape' : 'overlay';
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Eligibility, assignment and modal actions for one URL attempt.
|
|
17
|
+
* The existing choreographer adapter owns display permission and cleanup.
|
|
18
|
+
*/
|
|
19
|
+
export function usePreAuthValuePropositionModal(_ref) {
|
|
20
|
+
var url = _ref.url,
|
|
21
|
+
onFinished = _ref.onFinished;
|
|
22
|
+
var _useSmartLink = useSmartLink(SMART_LINK_MODAL_ID, url, 'inline'),
|
|
23
|
+
actions = _useSmartLink.actions,
|
|
24
|
+
config = _useSmartLink.config,
|
|
25
|
+
state = _useSmartLink.state;
|
|
26
|
+
var _useAnalyticsEvents = useAnalyticsEvents(),
|
|
27
|
+
fireEvent = _useAnalyticsEvents.fireEvent;
|
|
28
|
+
var _useState = useState(false),
|
|
29
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
30
|
+
isRequested = _useState2[0],
|
|
31
|
+
setIsRequested = _useState2[1];
|
|
32
|
+
var finished = useRef(false);
|
|
33
|
+
var hasOpened = useRef(false);
|
|
34
|
+
var hasRecordedShow = useRef(false);
|
|
35
|
+
var _useState3 = useState('modal_text_only'),
|
|
36
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
37
|
+
visibleVariant = _useState4[0],
|
|
38
|
+
setVisibleVariant = _useState4[1];
|
|
39
|
+
var modalOpenTimeRef = useRef(Date.now());
|
|
40
|
+
var provider = useMemo(function () {
|
|
41
|
+
return extractSmartLinkProvider(state.details);
|
|
42
|
+
}, [state.details]);
|
|
43
|
+
var providerName = provider === null || provider === void 0 ? void 0 : provider.text;
|
|
44
|
+
var services = getServices(state.details);
|
|
45
|
+
var extensionKey = getExtensionKey(state.details);
|
|
46
|
+
var _useSocialProof = useSocialProof(extensionKey, true),
|
|
47
|
+
connectedPct = _useSocialProof.connectedPct,
|
|
48
|
+
isSocialProofAvailable = _useSocialProof.isEnabled;
|
|
49
|
+
var hasSupportedAuthorization = (config === null || config === void 0 ? void 0 : config.authFlow) !== 'disabled' && services.length > 0;
|
|
50
|
+
var isBaseEligible = state.status === 'unauthorized' && Boolean(providerName) && Boolean(extensionKey) && hasSupportedAuthorization;
|
|
51
|
+
var finishCoordinatedAttempt = useCallback(function () {
|
|
52
|
+
if (finished.current) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
finished.current = true;
|
|
56
|
+
setIsRequested(false);
|
|
57
|
+
onFinished();
|
|
58
|
+
}, [onFinished]);
|
|
59
|
+
var handleUnavailable = useCallback(function () {
|
|
60
|
+
if (finished.current) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (hasOpened.current) {
|
|
64
|
+
fireEvent('ui.modal.closed.preAuthValueProposition', {
|
|
65
|
+
closeMethod: 'coordinator',
|
|
66
|
+
dwellTime: Date.now() - modalOpenTimeRef.current
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
finishCoordinatedAttempt();
|
|
70
|
+
}, [fireEvent, finishCoordinatedAttempt]);
|
|
71
|
+
var shouldClaim = useCallback(function () {
|
|
72
|
+
// Recheck at offer time: another attempt may have consumed the cap while we waited.
|
|
73
|
+
if (finished.current || !isBaseEligible || !extensionKey || preAuthValuePropositionModalService.hasReachedShowLimit(extensionKey)) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
var variant = expVal('platform_sl_3p_preauth_value_modal', 'variant', 'control');
|
|
77
|
+
if (variant !== 'modal_text_only' && variant !== 'modal_with_image') {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
setVisibleVariant(variant);
|
|
81
|
+
return true;
|
|
82
|
+
}, [extensionKey, isBaseEligible]);
|
|
83
|
+
|
|
84
|
+
// The editor mounts this flow only when platform_sl_3p_preauth_value_modal_killswitch is on.
|
|
85
|
+
useEffect(function () {
|
|
86
|
+
if (finished.current) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (state.status === 'pending' || state.status === 'resolving') {
|
|
90
|
+
// A previously eligible link that starts resolving again must release its slot.
|
|
91
|
+
if (isRequested) {
|
|
92
|
+
handleUnavailable();
|
|
93
|
+
}
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (!isBaseEligible || !extensionKey) {
|
|
97
|
+
handleUnavailable();
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (!isRequested) {
|
|
101
|
+
if (preAuthValuePropositionModalService.hasReachedShowLimit(extensionKey)) {
|
|
102
|
+
finishCoordinatedAttempt();
|
|
103
|
+
} else {
|
|
104
|
+
setIsRequested(true);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}, [extensionKey, isBaseEligible, state.status, isRequested, handleUnavailable, finishCoordinatedAttempt]);
|
|
108
|
+
var recordShowOnce = useCallback(function () {
|
|
109
|
+
if (hasRecordedShow.current || !extensionKey) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
hasRecordedShow.current = true;
|
|
113
|
+
preAuthValuePropositionModalService.recordShow(extensionKey);
|
|
114
|
+
}, [extensionKey]);
|
|
115
|
+
var dismissModal = useCallback(function (closeMethod) {
|
|
116
|
+
if (finished.current) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
// A user can dismiss the visible modal before its entrance animation completes.
|
|
120
|
+
recordShowOnce();
|
|
121
|
+
fireEvent('ui.modal.closed.preAuthValueProposition', {
|
|
122
|
+
closeMethod: closeMethod,
|
|
123
|
+
dwellTime: Date.now() - modalOpenTimeRef.current
|
|
124
|
+
});
|
|
125
|
+
finishCoordinatedAttempt();
|
|
126
|
+
}, [fireEvent, finishCoordinatedAttempt, recordShowOnce]);
|
|
127
|
+
var handleCloseButton = useCallback(function () {
|
|
128
|
+
dismissModal('button');
|
|
129
|
+
}, [dismissModal]);
|
|
130
|
+
var handleModalClose = useCallback(function (event) {
|
|
131
|
+
dismissModal(getModalCloseMethod(event));
|
|
132
|
+
}, [dismissModal]);
|
|
133
|
+
var handleOpenComplete = useCallback(function () {
|
|
134
|
+
if (finished.current || hasOpened.current || !extensionKey) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
hasOpened.current = true;
|
|
138
|
+
recordShowOnce();
|
|
139
|
+
modalOpenTimeRef.current = Date.now();
|
|
140
|
+
fireEvent('ui.modal.opened.preAuthValueProposition', {});
|
|
141
|
+
}, [fireEvent, extensionKey, recordShowOnce]);
|
|
142
|
+
var connectAccount = useCallback(function () {
|
|
143
|
+
if (finished.current) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
recordShowOnce();
|
|
147
|
+
fireEvent('track.applicationAccount.authStarted', {});
|
|
148
|
+
finishCoordinatedAttempt();
|
|
149
|
+
actions.authorize('inline');
|
|
150
|
+
}, [actions, fireEvent, finishCoordinatedAttempt, recordShowOnce]);
|
|
151
|
+
return {
|
|
152
|
+
isActive: isRequested,
|
|
153
|
+
isEligible: isBaseEligible,
|
|
154
|
+
onUnavailable: handleUnavailable,
|
|
155
|
+
shouldClaim: shouldClaim,
|
|
156
|
+
modal: {
|
|
157
|
+
provider: provider,
|
|
158
|
+
variant: visibleVariant,
|
|
159
|
+
connectedPct: connectedPct,
|
|
160
|
+
isSocialProofAvailable: isSocialProofAvailable,
|
|
161
|
+
onClose: handleModalClose,
|
|
162
|
+
onCloseButton: handleCloseButton,
|
|
163
|
+
onConnect: connectAccount,
|
|
164
|
+
onOpenComplete: handleOpenComplete
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Generates Typescript types for analytics events from analytics.spec.yaml
|
|
5
5
|
*
|
|
6
|
-
* @codegen <<SignedSource::
|
|
6
|
+
* @codegen <<SignedSource::bcb840e9445405411cf34af7d9171bf7>>
|
|
7
7
|
* @codegenCommand afm workspace @atlassian/analytics-tooling analytics:codegen smart-card
|
|
8
8
|
*/
|
|
9
9
|
export type PackageMetaDataContextType = {
|
|
@@ -109,7 +109,7 @@ export type ModalClosedRelatedLinksAttributesType = {
|
|
|
109
109
|
};
|
|
110
110
|
export type ModalOpenedPreAuthValuePropositionAttributesType = {};
|
|
111
111
|
export type ModalClosedPreAuthValuePropositionAttributesType = {
|
|
112
|
-
closeMethod: 'button' | 'escape' | 'overlay';
|
|
112
|
+
closeMethod: 'button' | 'escape' | 'overlay' | 'coordinator';
|
|
113
113
|
dwellTime: number;
|
|
114
114
|
};
|
|
115
115
|
export type RelatedLinksSuccessAttributesType = {
|
|
@@ -4,4 +4,4 @@ export type PreAuthValuePropositionModalProps = {
|
|
|
4
4
|
onOpenChange?: (isOpen: boolean) => void;
|
|
5
5
|
url: string;
|
|
6
6
|
};
|
|
7
|
-
export declare const PreAuthValuePropositionModal: (
|
|
7
|
+
export declare const PreAuthValuePropositionModal: (props: PreAuthValuePropositionModalProps) => JSX.Element;
|
package/dist/types/view/PreAuthValuePropositionModal/use-pre-auth-value-proposition-modal.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { extractSmartLinkProvider } from '@atlaskit/link-extractors/extract-smart-link-provider';
|
|
2
|
+
import type { KeyboardOrMouseEvent } from '@atlaskit/modal-dialog/types';
|
|
3
|
+
export declare const SMART_LINK_MODAL_ID = "pre-auth-value-proposition-modal";
|
|
4
|
+
type PreAuthValuePropositionModalOptions = {
|
|
5
|
+
onFinished: () => void;
|
|
6
|
+
url: string;
|
|
7
|
+
};
|
|
8
|
+
type PreAuthModalVariant = 'modal_text_only' | 'modal_with_image';
|
|
9
|
+
type PreAuthValuePropositionModalModel = {
|
|
10
|
+
connectedPct?: number;
|
|
11
|
+
isSocialProofAvailable: boolean;
|
|
12
|
+
onClose: (event: KeyboardOrMouseEvent) => void;
|
|
13
|
+
onCloseButton: () => void;
|
|
14
|
+
onConnect: () => void;
|
|
15
|
+
onOpenComplete: () => void;
|
|
16
|
+
provider: ReturnType<typeof extractSmartLinkProvider>;
|
|
17
|
+
variant: PreAuthModalVariant;
|
|
18
|
+
};
|
|
19
|
+
type PreAuthValuePropositionModalState = {
|
|
20
|
+
isActive: boolean;
|
|
21
|
+
isEligible: boolean;
|
|
22
|
+
modal: PreAuthValuePropositionModalModel;
|
|
23
|
+
onUnavailable: () => void;
|
|
24
|
+
shouldClaim: () => boolean;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Eligibility, assignment and modal actions for one URL attempt.
|
|
28
|
+
* The existing choreographer adapter owns display permission and cleanup.
|
|
29
|
+
*/
|
|
30
|
+
export declare function usePreAuthValuePropositionModal({ url, onFinished, }: PreAuthValuePropositionModalOptions): PreAuthValuePropositionModalState;
|
|
31
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/smart-card",
|
|
3
|
-
"version": "46.
|
|
3
|
+
"version": "46.16.0",
|
|
4
4
|
"description": "Smart card component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@atlaskit/adf-utils": "^20.9.0",
|
|
42
|
-
"@atlaskit/afm-i18n-platform-linking-platform-smart-card": "2.
|
|
42
|
+
"@atlaskit/afm-i18n-platform-linking-platform-smart-card": "2.312.0",
|
|
43
43
|
"@atlaskit/analytics-cross-product": "^2.3.0",
|
|
44
44
|
"@atlaskit/analytics-gas-types": "^6.2.0",
|
|
45
45
|
"@atlaskit/analytics-next": "^12.6.0",
|
|
@@ -108,14 +108,13 @@
|
|
|
108
108
|
"markdown-to-jsx": "^7.1.7",
|
|
109
109
|
"react-error-boundary": "^3.1.3",
|
|
110
110
|
"react-lazily-render": "^1.2.0",
|
|
111
|
-
"react-loadable": "^5.1.0",
|
|
112
111
|
"react-magnetic-di": "^3.1.4",
|
|
113
112
|
"react-render-image": "^1.1.3",
|
|
114
113
|
"use-sync-external-store": "^1.5.0",
|
|
115
114
|
"uuid": "^11.1.1"
|
|
116
115
|
},
|
|
117
116
|
"peerDependencies": {
|
|
118
|
-
"@atlaskit/link-provider": "^6.
|
|
117
|
+
"@atlaskit/link-provider": "^6.2.0",
|
|
119
118
|
"react": "^18.2.0",
|
|
120
119
|
"react-dom": "^18.2.0",
|
|
121
120
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
@@ -129,10 +128,10 @@
|
|
|
129
128
|
"@atlaskit/css-reset": "^8.4.0",
|
|
130
129
|
"@atlaskit/datetime-picker": "^19.5.0",
|
|
131
130
|
"@atlaskit/inline-message": "^16.4.0",
|
|
132
|
-
"@atlaskit/link-provider": "^6.
|
|
131
|
+
"@atlaskit/link-provider": "^6.2.0",
|
|
133
132
|
"@atlaskit/media-test-helpers": "^43.0.0",
|
|
134
133
|
"@atlaskit/page": "^15.3.0",
|
|
135
|
-
"@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-migration": "^3.
|
|
134
|
+
"@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-migration": "^3.5.0",
|
|
136
135
|
"@atlaskit/radio": "^10.2.0",
|
|
137
136
|
"@atlaskit/range": "^12.2.0",
|
|
138
137
|
"@atlaskit/ssr": "workspace:^",
|
|
@@ -142,16 +141,17 @@
|
|
|
142
141
|
"@atlassian/experiment-test-utils": "^0.2.0",
|
|
143
142
|
"@atlassian/feature-flags-test-utils": "^1.3.0",
|
|
144
143
|
"@atlassian/gemini": "^1.55.0",
|
|
144
|
+
"@atlassian/ipm-choreographer": "^0.35.0",
|
|
145
145
|
"@atlassian/structured-docs-types": "workspace:^",
|
|
146
146
|
"@atlassian/testing-library": "^0.12.0",
|
|
147
147
|
"@atlassian/workbench": "workspace:*",
|
|
148
|
+
"@atlassiansox/analytics-web-client": "^5.32.0",
|
|
148
149
|
"@testing-library/dom": "^10.1.0",
|
|
149
150
|
"@testing-library/jest-dom": "^6.4.5",
|
|
150
151
|
"@testing-library/react": "^16.3.0",
|
|
151
152
|
"@types/facepaint": "^1.2.1",
|
|
152
153
|
"@types/lorem-ipsum": "^1.0.2",
|
|
153
154
|
"@types/react": "^18.2.0",
|
|
154
|
-
"@types/react-loadable": "^5.4.1",
|
|
155
155
|
"@types/use-sync-external-store": "^1",
|
|
156
156
|
"abortcontroller-polyfill": "^1.1.9",
|
|
157
157
|
"brace": "^0.11.1",
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.importIcon = void 0;
|
|
8
|
-
var _reactLoadable = _interopRequireDefault(require("react-loadable"));
|
|
9
|
-
var importIcon = exports.importIcon = function importIcon(importFn) {
|
|
10
|
-
return (0, _reactLoadable.default)({
|
|
11
|
-
loader: function loader() {
|
|
12
|
-
return importFn().then(function (module) {
|
|
13
|
-
return module.default;
|
|
14
|
-
});
|
|
15
|
-
},
|
|
16
|
-
loading: function loading() {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
}); // Because we're using dynamic loading here, TS will not be able to infer the type.
|
|
20
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import Loadable from 'react-loadable';
|
|
2
|
-
export const importIcon = importFn => {
|
|
3
|
-
return Loadable({
|
|
4
|
-
loader: () => importFn().then(module => module.default),
|
|
5
|
-
loading: () => null
|
|
6
|
-
}); // Because we're using dynamic loading here, TS will not be able to infer the type.
|
|
7
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import Loadable from 'react-loadable';
|
|
2
|
-
export var importIcon = function importIcon(importFn) {
|
|
3
|
-
return Loadable({
|
|
4
|
-
loader: function loader() {
|
|
5
|
-
return importFn().then(function (module) {
|
|
6
|
-
return module.default;
|
|
7
|
-
});
|
|
8
|
-
},
|
|
9
|
-
loading: function loading() {
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
}); // Because we're using dynamic loading here, TS will not be able to infer the type.
|
|
13
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const importIcon: (importFn: () => Promise<any>) => any;
|