@atlaskit/smart-card 31.0.3 → 32.1.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 +26 -0
- package/dist/cjs/extractors/action/extractDownloadActionProps.js +28 -0
- package/dist/cjs/extractors/action/extractPreviewActionProps.js +43 -0
- package/dist/cjs/extractors/action/extractViewActionProps.js +27 -0
- package/dist/cjs/extractors/common/actions/extractActions.js +5 -0
- package/dist/cjs/extractors/common/actions/extractPreviewAction.js +5 -0
- package/dist/cjs/extractors/common/actions/types.js +5 -0
- package/dist/cjs/extractors/common/lozenge/extractLozenge.js +24 -5
- package/dist/cjs/extractors/flexible/actions/extract-preview-action.js +3 -1
- package/dist/cjs/state/hooks-external/useSmartLinkActions.js +38 -0
- package/dist/cjs/utils/actions/to-action.js +18 -0
- package/dist/cjs/utils/analytics/analytics.js +1 -1
- package/dist/cjs/view/LinkUrl/index.js +1 -1
- package/dist/es2019/extractors/action/extractDownloadActionProps.js +19 -0
- package/dist/es2019/extractors/action/extractPreviewActionProps.js +31 -0
- package/dist/es2019/extractors/action/extractViewActionProps.js +18 -0
- package/dist/es2019/extractors/common/actions/extractActions.js +5 -0
- package/dist/es2019/extractors/common/actions/extractPreviewAction.js +5 -0
- package/dist/es2019/extractors/common/actions/types.js +1 -0
- package/dist/es2019/extractors/common/lozenge/extractLozenge.js +19 -0
- package/dist/es2019/extractors/flexible/actions/extract-preview-action.js +3 -1
- package/dist/es2019/state/hooks-external/useSmartLinkActions.js +38 -0
- package/dist/es2019/utils/actions/to-action.js +9 -0
- package/dist/es2019/utils/analytics/analytics.js +1 -1
- package/dist/es2019/view/LinkUrl/index.js +1 -1
- package/dist/esm/extractors/action/extractDownloadActionProps.js +22 -0
- package/dist/esm/extractors/action/extractPreviewActionProps.js +36 -0
- package/dist/esm/extractors/action/extractViewActionProps.js +21 -0
- package/dist/esm/extractors/common/actions/extractActions.js +5 -0
- package/dist/esm/extractors/common/actions/extractPreviewAction.js +5 -0
- package/dist/esm/extractors/common/actions/types.js +1 -0
- package/dist/esm/extractors/common/lozenge/extractLozenge.js +24 -5
- package/dist/esm/extractors/flexible/actions/extract-preview-action.js +3 -1
- package/dist/esm/state/hooks-external/useSmartLinkActions.js +38 -0
- package/dist/esm/utils/actions/to-action.js +11 -0
- package/dist/esm/utils/analytics/analytics.js +1 -1
- package/dist/esm/view/LinkUrl/index.js +1 -1
- package/dist/types/extractors/action/extractDownloadActionProps.d.ts +3 -0
- package/dist/types/extractors/action/extractPreviewActionProps.d.ts +3 -0
- package/dist/types/extractors/action/extractViewActionProps.d.ts +3 -0
- package/dist/types/extractors/common/__mocks__/jsonld.d.ts +5 -0
- package/dist/types/extractors/common/actions/extractActions.d.ts +4 -0
- package/dist/types/extractors/common/actions/extractPreviewAction.d.ts +4 -0
- package/dist/types/extractors/common/actions/types.d.ts +21 -0
- package/dist/types/extractors/common/lozenge/extractState.d.ts +2 -3
- package/dist/types/extractors/common/lozenge/types.d.ts +2 -0
- package/dist/types/state/flexible-ui-context/types.d.ts +1 -0
- package/dist/types/state/hooks/use-invoke-client-action/index.d.ts +2 -2
- package/dist/types/state/hooks/use-invoke-client-action/types.d.ts +1 -0
- package/dist/types/utils/actions/to-action.d.ts +8 -0
- package/dist/types-ts4.5/extractors/action/extractDownloadActionProps.d.ts +3 -0
- package/dist/types-ts4.5/extractors/action/extractPreviewActionProps.d.ts +3 -0
- package/dist/types-ts4.5/extractors/action/extractViewActionProps.d.ts +3 -0
- package/dist/types-ts4.5/extractors/common/__mocks__/jsonld.d.ts +5 -0
- package/dist/types-ts4.5/extractors/common/actions/extractActions.d.ts +4 -0
- package/dist/types-ts4.5/extractors/common/actions/extractPreviewAction.d.ts +4 -0
- package/dist/types-ts4.5/extractors/common/actions/types.d.ts +21 -0
- package/dist/types-ts4.5/extractors/common/lozenge/extractState.d.ts +2 -3
- package/dist/types-ts4.5/extractors/common/lozenge/types.d.ts +2 -0
- package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +1 -0
- package/dist/types-ts4.5/state/hooks/use-invoke-client-action/index.d.ts +2 -2
- package/dist/types-ts4.5/state/hooks/use-invoke-client-action/types.d.ts +1 -0
- package/dist/types-ts4.5/utils/actions/to-action.d.ts +8 -0
- package/package.json +10 -5
- package/client/package.json +0 -15
- package/dist/cjs/client/index.js +0 -12
- package/dist/es2019/client/index.js +0 -5
- package/dist/esm/client/index.js +0 -5
- package/dist/types/client/index.d.ts +0 -5
- package/dist/types-ts4.5/client/index.d.ts +0 -5
|
@@ -57,6 +57,11 @@ export var getActionsFromJsonLd = function getActionsFromJsonLd(jsonLd) {
|
|
|
57
57
|
}
|
|
58
58
|
return actions;
|
|
59
59
|
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @private
|
|
63
|
+
* @deprecated - use flexible extractors instead
|
|
64
|
+
*/
|
|
60
65
|
export function extractClientActions(jsonLd, handler, actionOptions) {
|
|
61
66
|
var actions = getActionsFromJsonLd(jsonLd);
|
|
62
67
|
var clientActions = actions.filter(function (action) {
|
|
@@ -47,6 +47,11 @@ var getInvokeOpts = function getInvokeOpts(key, action, source) {
|
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @private
|
|
53
|
+
* @deprecated - use extractPreviewActionProps instead
|
|
54
|
+
*/
|
|
50
55
|
export var extractPreviewAction = function extractPreviewAction(_ref) {
|
|
51
56
|
var _ref$extensionKey = _ref.extensionKey,
|
|
52
57
|
extensionKey = _ref$extensionKey === void 0 ? 'empty-object-provider' : _ref$extensionKey,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { extractType } from '@atlaskit/link-extractors';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
import { extractState } from './extractState';
|
|
3
4
|
import { extractTag } from './extractTag';
|
|
4
5
|
import { extractTaskStatus } from './extractTaskStatus';
|
|
@@ -7,14 +8,32 @@ var DOC_TYPES = ['schema:BlogPosting', 'schema:TextDigitalDocument', 'schema:Dig
|
|
|
7
8
|
export var extractLozenge = function extractLozenge(jsonLd) {
|
|
8
9
|
var type = extractType(jsonLd);
|
|
9
10
|
if (type) {
|
|
11
|
+
if (fg('linking_platform_show_lozenge_atlassian_state')) {
|
|
12
|
+
if (type.includes('atlassian:Task')) {
|
|
13
|
+
var jsonLdTask = jsonLd;
|
|
14
|
+
var lozengeFromTag = extractTag(jsonLdTask);
|
|
15
|
+
var lozengeFromStatus = extractTaskStatus(jsonLdTask);
|
|
16
|
+
var lozengeFromTaskType = extractLozengeFromTaskType(jsonLdTask);
|
|
17
|
+
return lozengeFromTag || lozengeFromStatus || lozengeFromTaskType;
|
|
18
|
+
}
|
|
19
|
+
if (type.includes('atlassian:UndefinedLink')) {
|
|
20
|
+
return {
|
|
21
|
+
text: 'UNDEFINED',
|
|
22
|
+
appearance: 'inprogress'
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// casting it because `extractState` can safely handle missing properties
|
|
27
|
+
return extractState(jsonLd);
|
|
28
|
+
}
|
|
10
29
|
if (type.includes('atlassian:SourceCodePullRequest')) {
|
|
11
30
|
return extractState(jsonLd);
|
|
12
31
|
} else if (type.includes('atlassian:Task')) {
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
return
|
|
32
|
+
var _jsonLdTask = jsonLd;
|
|
33
|
+
var _lozengeFromTag = extractTag(_jsonLdTask);
|
|
34
|
+
var _lozengeFromStatus = extractTaskStatus(_jsonLdTask);
|
|
35
|
+
var _lozengeFromTaskType = extractLozengeFromTaskType(_jsonLdTask);
|
|
36
|
+
return _lozengeFromTag || _lozengeFromStatus || _lozengeFromTaskType;
|
|
18
37
|
} else if (type.some(function (types) {
|
|
19
38
|
return DOC_TYPES.includes(types);
|
|
20
39
|
})) {
|
|
@@ -3,6 +3,7 @@ import { canShowAction } from '../../../utils/actions/can-show-action';
|
|
|
3
3
|
import { CardAction } from '../../../view/Card/types';
|
|
4
4
|
import { extractDownloadUrl } from '../../common/detail';
|
|
5
5
|
import { extractIsSupportTheming } from '../../common/meta/extractIsSupportTheming';
|
|
6
|
+
import { extractIsTrusted } from '../../common/meta/extractIsTrusted';
|
|
6
7
|
import { extractLinkIcon } from '../icon';
|
|
7
8
|
export var extractPreviewAction = function extractPreviewAction(response, actionOptions) {
|
|
8
9
|
var _extractPreviewData;
|
|
@@ -21,7 +22,8 @@ export var extractPreviewAction = function extractPreviewAction(response, action
|
|
|
21
22
|
title: extractTitle(data),
|
|
22
23
|
linkIcon: extractLinkIcon(response),
|
|
23
24
|
url: extractLink(data),
|
|
24
|
-
isSupportTheming: extractIsSupportTheming(meta)
|
|
25
|
+
isSupportTheming: extractIsSupportTheming(meta),
|
|
26
|
+
isTrusted: extractIsTrusted(meta)
|
|
25
27
|
};
|
|
26
28
|
}
|
|
27
29
|
};
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import uuid from 'uuid';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
|
+
import { extractDownloadActionProps } from '../../extractors/action/extractDownloadActionProps';
|
|
5
|
+
import { extractPreviewActionProps } from '../../extractors/action/extractPreviewActionProps';
|
|
6
|
+
import { extractViewActionProps } from '../../extractors/action/extractViewActionProps';
|
|
3
7
|
import { extractBlockProps as extractCardProps } from '../../extractors/block';
|
|
8
|
+
import { messages } from '../../messages';
|
|
9
|
+
import { toAction } from '../../utils/actions/to-action';
|
|
4
10
|
import { useSmartCardActions as useLinkActions } from '../actions';
|
|
5
11
|
import { useSmartLinkAnalytics as useLinkAnalytics } from '../analytics';
|
|
6
12
|
import { getExtensionKey } from '../helpers';
|
|
13
|
+
import useInvokeClientAction from '../hooks/use-invoke-client-action';
|
|
7
14
|
import { useSmartCardState as useLinkState } from '../store';
|
|
8
15
|
export function useSmartLinkActions(_ref) {
|
|
9
16
|
var url = _ref.url,
|
|
@@ -18,6 +25,37 @@ export function useSmartLinkActions(_ref) {
|
|
|
18
25
|
var linkState = useLinkState(url);
|
|
19
26
|
var linkAnalytics = useLinkAnalytics(url, id);
|
|
20
27
|
var linkActions = useLinkActions(id, url, linkAnalytics);
|
|
28
|
+
var invokeClientAction = useInvokeClientAction({
|
|
29
|
+
analytics: linkAnalytics
|
|
30
|
+
});
|
|
31
|
+
if (fg('smart-card-use-refactored-usesmartlinkactions')) {
|
|
32
|
+
if (linkState.details && !(actionOptions !== null && actionOptions !== void 0 && actionOptions.hide)) {
|
|
33
|
+
var opts = {
|
|
34
|
+
response: linkState.details,
|
|
35
|
+
handleInvoke: invokeClientAction,
|
|
36
|
+
analytics: linkAnalytics,
|
|
37
|
+
origin: origin,
|
|
38
|
+
extensionKey: getExtensionKey(linkState.details),
|
|
39
|
+
source: appearance,
|
|
40
|
+
actionOptions: actionOptions
|
|
41
|
+
};
|
|
42
|
+
var actions = [];
|
|
43
|
+
var downloadActionProps = extractDownloadActionProps(opts);
|
|
44
|
+
if (downloadActionProps) {
|
|
45
|
+
actions.push(toAction(downloadActionProps, invokeClientAction, messages.download, 'download-content'));
|
|
46
|
+
}
|
|
47
|
+
var viewActionProps = extractViewActionProps(opts);
|
|
48
|
+
if (viewActionProps) {
|
|
49
|
+
actions.push(toAction(viewActionProps, invokeClientAction, messages.view, 'view-content'));
|
|
50
|
+
}
|
|
51
|
+
var previewActionProps = extractPreviewActionProps(opts);
|
|
52
|
+
if (previewActionProps) {
|
|
53
|
+
actions.push(toAction(previewActionProps, invokeClientAction, messages.preview_improved, 'preview-content'));
|
|
54
|
+
}
|
|
55
|
+
return actions;
|
|
56
|
+
}
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
21
59
|
if (linkState.details && !(actionOptions !== null && actionOptions !== void 0 && actionOptions.hide)) {
|
|
22
60
|
var cardProperties = extractCardProps(linkState.details.data, linkState.details.meta, {
|
|
23
61
|
handleInvoke: function handleInvoke(opts) {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
3
|
+
export var toAction = function toAction(action, invokeClientAction, message, id) {
|
|
4
|
+
return {
|
|
5
|
+
id: id,
|
|
6
|
+
text: /*#__PURE__*/React.createElement(FormattedMessage, message),
|
|
7
|
+
invoke: function invoke() {
|
|
8
|
+
return invokeClientAction(action);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -10,7 +10,7 @@ export var ANALYTICS_CHANNEL = 'media';
|
|
|
10
10
|
export var context = {
|
|
11
11
|
componentName: 'smart-cards',
|
|
12
12
|
packageName: "@atlaskit/smart-card",
|
|
13
|
-
packageVersion: "
|
|
13
|
+
packageVersion: "32.1.0"
|
|
14
14
|
};
|
|
15
15
|
export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
16
16
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -10,7 +10,7 @@ import LinkWarningModal from './LinkWarningModal';
|
|
|
10
10
|
import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
|
|
11
11
|
var PACKAGE_DATA = {
|
|
12
12
|
packageName: "@atlaskit/smart-card",
|
|
13
|
-
packageVersion: "
|
|
13
|
+
packageVersion: "32.1.0",
|
|
14
14
|
componentName: 'linkUrl'
|
|
15
15
|
};
|
|
16
16
|
var Link = withLinkClickedEvent('a');
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type InvokeClientActionProps } from '../../state/hooks/use-invoke-client-action/types';
|
|
2
|
+
import { type ExtractActionsProps } from '../common/actions/types';
|
|
3
|
+
export declare const extractDownloadActionProps: ({ response, actionOptions, extensionKey, source, }: ExtractActionsProps) => InvokeClientActionProps | undefined;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type InvokeClientActionProps } from '../../state/hooks/use-invoke-client-action/types';
|
|
2
|
+
import type { ExtractActionsProps } from '../common/actions/types';
|
|
3
|
+
export declare const extractPreviewActionProps: ({ response, analytics, extensionKey, source, actionOptions, origin, }: ExtractActionsProps) => InvokeClientActionProps | undefined;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type InvokeClientActionProps } from '../../state/hooks/use-invoke-client-action/types';
|
|
2
|
+
import { type ExtractActionsProps } from '../common/actions/types';
|
|
3
|
+
export declare const extractViewActionProps: ({ response, actionOptions, extensionKey, source, }: ExtractActionsProps) => InvokeClientActionProps | undefined;
|
|
@@ -41,3 +41,8 @@ export declare const PREVIEW: JsonLd.Data.BaseData['preview'];
|
|
|
41
41
|
export declare const TEST_DOCUMENT_WITH_PREVIEW: JsonLd.Data.BaseData;
|
|
42
42
|
export declare const TEST_DATA_WITH_LATEST_COMMIT_OBJ: JsonLd.Data.SourceCodeRepository;
|
|
43
43
|
export declare const TEST_DATA_WITH_LATEST_COMMIT_TEXT: JsonLd.Data.SourceCodeRepository;
|
|
44
|
+
export declare const TEST_RESPONSE: JsonLd.Response;
|
|
45
|
+
export declare const TEST_RESPONSE_WITH_PREVIEW_AND_DOWNLOAD: JsonLd.Response;
|
|
46
|
+
export declare const TEST_RESPONSE_WITH_DOWNLOAD: JsonLd.Response;
|
|
47
|
+
export declare const TEST_RESPONSE_WITH_PREVIEW: JsonLd.Response;
|
|
48
|
+
export declare const TEST_RESPONSE_WITH_VIEW: JsonLd.Response;
|
|
@@ -3,4 +3,8 @@ import { type InvokeHandler } from '../../../model/invoke-handler';
|
|
|
3
3
|
import { type ActionProps } from '../../../view/BlockCard/components/Action';
|
|
4
4
|
import { type CardActionOptions } from '../../../view/Card/types';
|
|
5
5
|
export declare const getActionsFromJsonLd: (jsonLd: JsonLd.Data.BaseData) => JsonLd.Primitives.Action[];
|
|
6
|
+
/**
|
|
7
|
+
* @private
|
|
8
|
+
* @deprecated - use flexible extractors instead
|
|
9
|
+
*/
|
|
6
10
|
export declare function extractClientActions(jsonLd: JsonLd.Data.BaseData, handler: InvokeHandler, actionOptions?: CardActionOptions): ActionProps[];
|
|
@@ -2,6 +2,10 @@ import { type JsonLd } from 'json-ld-types';
|
|
|
2
2
|
import { type BlockCardResolvedViewProps } from '../../../view/BlockCard';
|
|
3
3
|
import { type CardPlatform } from '../../../view/Card/types';
|
|
4
4
|
import { type ExtractBlockOpts } from '../../block/types';
|
|
5
|
+
/**
|
|
6
|
+
* @private
|
|
7
|
+
* @deprecated - use extractPreviewActionProps instead
|
|
8
|
+
*/
|
|
5
9
|
export declare const extractPreviewAction: ({ extensionKey, viewProps, jsonLd, handleInvoke, testId, platform, origin, source, analytics, meta, actionOptions, }: ExtractBlockOpts & {
|
|
6
10
|
viewProps: BlockCardResolvedViewProps;
|
|
7
11
|
jsonLd: JsonLd.Data.BaseData;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type JsonLd } from 'json-ld-types';
|
|
3
|
+
import { type AnalyticsFacade } from '../../../state/analytics';
|
|
4
|
+
import { type AnalyticsOrigin } from '../../../utils/types';
|
|
5
|
+
import { type CardActionOptions, type CardInnerAppearance } from '../../../view/Card/types';
|
|
6
|
+
export type ExtractActionsProps = {
|
|
7
|
+
response: JsonLd.Response;
|
|
8
|
+
analytics: AnalyticsFacade;
|
|
9
|
+
actionOptions?: CardActionOptions;
|
|
10
|
+
extensionKey?: string;
|
|
11
|
+
source?: CardInnerAppearance;
|
|
12
|
+
origin?: AnalyticsOrigin;
|
|
13
|
+
};
|
|
14
|
+
export interface ActionProps {
|
|
15
|
+
/** String identifier for the action (e.g. 'preview-content') */
|
|
16
|
+
id: string;
|
|
17
|
+
/** The text to be displayed in the action's button */
|
|
18
|
+
text: React.ReactNode;
|
|
19
|
+
/** The function to be called on clicking the action. This is a promise so the state can transition correctly after the action finishes */
|
|
20
|
+
invoke: () => Promise<any>;
|
|
21
|
+
}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
|
|
3
|
-
export declare const extractState: (jsonLd: JsonLd.Data.SourceCodePullRequest | JsonLd.Data.Document | JsonLd.Data.Project | JsonLd.Data.Goal) => LinkLozenge | undefined;
|
|
1
|
+
import { type LinkLozenge, type LinkStateType } from './types';
|
|
2
|
+
export declare const extractState: (jsonLd: LinkStateType) => LinkLozenge | undefined;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type JsonLd } from 'json-ld-types';
|
|
1
2
|
import { type LozengeProps as AtlaskitLozengeProps } from '@atlaskit/lozenge';
|
|
2
3
|
import { type InvokeActions } from '../../../state/hooks/use-invoke/types';
|
|
3
4
|
export type LinkLozengeColor = 'default' | 'success' | 'removed' | 'inprogress' | 'new' | 'moved';
|
|
@@ -12,3 +13,4 @@ export interface LinkLozenge {
|
|
|
12
13
|
export type LinkDocumentState = 'archived' | 'draft' | 'current';
|
|
13
14
|
export type LinkPullRequestState = 'open' | 'merged' | 'declined' | 'closed';
|
|
14
15
|
export type LinkState = LinkDocumentState & LinkPullRequestState;
|
|
16
|
+
export type LinkStateType = JsonLd.Data.Document | JsonLd.Data.SourceCodePullRequest | JsonLd.Data.Project | JsonLd.Data.Goal;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { InvokeClientActionHandler, UseInvokeClientActionProps } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Invoke client action such as preview, download and open link
|
|
4
4
|
*/
|
|
5
|
-
declare const useInvokeClientAction: ({ analytics }: UseInvokeClientActionProps) =>
|
|
5
|
+
declare const useInvokeClientAction: ({ analytics, }: UseInvokeClientActionProps) => InvokeClientActionHandler;
|
|
6
6
|
export default useInvokeClientAction;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type MessageDescriptor } from 'react-intl-next';
|
|
3
|
+
import { type InvokeClientActionHandler, type InvokeClientActionProps } from '../../state/hooks/use-invoke-client-action/types';
|
|
4
|
+
export declare const toAction: (action: InvokeClientActionProps, invokeClientAction: InvokeClientActionHandler, message: MessageDescriptor, id: string) => {
|
|
5
|
+
id: string;
|
|
6
|
+
text: JSX.Element;
|
|
7
|
+
invoke: () => Promise<void>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type InvokeClientActionProps } from '../../state/hooks/use-invoke-client-action/types';
|
|
2
|
+
import { type ExtractActionsProps } from '../common/actions/types';
|
|
3
|
+
export declare const extractDownloadActionProps: ({ response, actionOptions, extensionKey, source, }: ExtractActionsProps) => InvokeClientActionProps | undefined;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type InvokeClientActionProps } from '../../state/hooks/use-invoke-client-action/types';
|
|
2
|
+
import type { ExtractActionsProps } from '../common/actions/types';
|
|
3
|
+
export declare const extractPreviewActionProps: ({ response, analytics, extensionKey, source, actionOptions, origin, }: ExtractActionsProps) => InvokeClientActionProps | undefined;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type InvokeClientActionProps } from '../../state/hooks/use-invoke-client-action/types';
|
|
2
|
+
import { type ExtractActionsProps } from '../common/actions/types';
|
|
3
|
+
export declare const extractViewActionProps: ({ response, actionOptions, extensionKey, source, }: ExtractActionsProps) => InvokeClientActionProps | undefined;
|
|
@@ -41,3 +41,8 @@ export declare const PREVIEW: JsonLd.Data.BaseData['preview'];
|
|
|
41
41
|
export declare const TEST_DOCUMENT_WITH_PREVIEW: JsonLd.Data.BaseData;
|
|
42
42
|
export declare const TEST_DATA_WITH_LATEST_COMMIT_OBJ: JsonLd.Data.SourceCodeRepository;
|
|
43
43
|
export declare const TEST_DATA_WITH_LATEST_COMMIT_TEXT: JsonLd.Data.SourceCodeRepository;
|
|
44
|
+
export declare const TEST_RESPONSE: JsonLd.Response;
|
|
45
|
+
export declare const TEST_RESPONSE_WITH_PREVIEW_AND_DOWNLOAD: JsonLd.Response;
|
|
46
|
+
export declare const TEST_RESPONSE_WITH_DOWNLOAD: JsonLd.Response;
|
|
47
|
+
export declare const TEST_RESPONSE_WITH_PREVIEW: JsonLd.Response;
|
|
48
|
+
export declare const TEST_RESPONSE_WITH_VIEW: JsonLd.Response;
|
|
@@ -3,4 +3,8 @@ import { type InvokeHandler } from '../../../model/invoke-handler';
|
|
|
3
3
|
import { type ActionProps } from '../../../view/BlockCard/components/Action';
|
|
4
4
|
import { type CardActionOptions } from '../../../view/Card/types';
|
|
5
5
|
export declare const getActionsFromJsonLd: (jsonLd: JsonLd.Data.BaseData) => JsonLd.Primitives.Action[];
|
|
6
|
+
/**
|
|
7
|
+
* @private
|
|
8
|
+
* @deprecated - use flexible extractors instead
|
|
9
|
+
*/
|
|
6
10
|
export declare function extractClientActions(jsonLd: JsonLd.Data.BaseData, handler: InvokeHandler, actionOptions?: CardActionOptions): ActionProps[];
|
|
@@ -2,6 +2,10 @@ import { type JsonLd } from 'json-ld-types';
|
|
|
2
2
|
import { type BlockCardResolvedViewProps } from '../../../view/BlockCard';
|
|
3
3
|
import { type CardPlatform } from '../../../view/Card/types';
|
|
4
4
|
import { type ExtractBlockOpts } from '../../block/types';
|
|
5
|
+
/**
|
|
6
|
+
* @private
|
|
7
|
+
* @deprecated - use extractPreviewActionProps instead
|
|
8
|
+
*/
|
|
5
9
|
export declare const extractPreviewAction: ({ extensionKey, viewProps, jsonLd, handleInvoke, testId, platform, origin, source, analytics, meta, actionOptions, }: ExtractBlockOpts & {
|
|
6
10
|
viewProps: BlockCardResolvedViewProps;
|
|
7
11
|
jsonLd: JsonLd.Data.BaseData;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type JsonLd } from 'json-ld-types';
|
|
3
|
+
import { type AnalyticsFacade } from '../../../state/analytics';
|
|
4
|
+
import { type AnalyticsOrigin } from '../../../utils/types';
|
|
5
|
+
import { type CardActionOptions, type CardInnerAppearance } from '../../../view/Card/types';
|
|
6
|
+
export type ExtractActionsProps = {
|
|
7
|
+
response: JsonLd.Response;
|
|
8
|
+
analytics: AnalyticsFacade;
|
|
9
|
+
actionOptions?: CardActionOptions;
|
|
10
|
+
extensionKey?: string;
|
|
11
|
+
source?: CardInnerAppearance;
|
|
12
|
+
origin?: AnalyticsOrigin;
|
|
13
|
+
};
|
|
14
|
+
export interface ActionProps {
|
|
15
|
+
/** String identifier for the action (e.g. 'preview-content') */
|
|
16
|
+
id: string;
|
|
17
|
+
/** The text to be displayed in the action's button */
|
|
18
|
+
text: React.ReactNode;
|
|
19
|
+
/** The function to be called on clicking the action. This is a promise so the state can transition correctly after the action finishes */
|
|
20
|
+
invoke: () => Promise<any>;
|
|
21
|
+
}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
|
|
3
|
-
export declare const extractState: (jsonLd: JsonLd.Data.SourceCodePullRequest | JsonLd.Data.Document | JsonLd.Data.Project | JsonLd.Data.Goal) => LinkLozenge | undefined;
|
|
1
|
+
import { type LinkLozenge, type LinkStateType } from './types';
|
|
2
|
+
export declare const extractState: (jsonLd: LinkStateType) => LinkLozenge | undefined;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type JsonLd } from 'json-ld-types';
|
|
1
2
|
import { type LozengeProps as AtlaskitLozengeProps } from '@atlaskit/lozenge';
|
|
2
3
|
import { type InvokeActions } from '../../../state/hooks/use-invoke/types';
|
|
3
4
|
export type LinkLozengeColor = 'default' | 'success' | 'removed' | 'inprogress' | 'new' | 'moved';
|
|
@@ -12,3 +13,4 @@ export interface LinkLozenge {
|
|
|
12
13
|
export type LinkDocumentState = 'archived' | 'draft' | 'current';
|
|
13
14
|
export type LinkPullRequestState = 'open' | 'merged' | 'declined' | 'closed';
|
|
14
15
|
export type LinkState = LinkDocumentState & LinkPullRequestState;
|
|
16
|
+
export type LinkStateType = JsonLd.Data.Document | JsonLd.Data.SourceCodePullRequest | JsonLd.Data.Project | JsonLd.Data.Goal;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { InvokeClientActionHandler, UseInvokeClientActionProps } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Invoke client action such as preview, download and open link
|
|
4
4
|
*/
|
|
5
|
-
declare const useInvokeClientAction: ({ analytics }: UseInvokeClientActionProps) =>
|
|
5
|
+
declare const useInvokeClientAction: ({ analytics, }: UseInvokeClientActionProps) => InvokeClientActionHandler;
|
|
6
6
|
export default useInvokeClientAction;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type MessageDescriptor } from 'react-intl-next';
|
|
3
|
+
import { type InvokeClientActionHandler, type InvokeClientActionProps } from '../../state/hooks/use-invoke-client-action/types';
|
|
4
|
+
export declare const toAction: (action: InvokeClientActionProps, invokeClientAction: InvokeClientActionHandler, message: MessageDescriptor, id: string) => {
|
|
5
|
+
id: string;
|
|
6
|
+
text: JSX.Element;
|
|
7
|
+
invoke: () => Promise<void>;
|
|
8
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/smart-card",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "32.1.0",
|
|
4
4
|
"description": "Smart card component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"@atlaskit/button": "^20.3.0",
|
|
34
34
|
"@atlaskit/checkbox": "^15.2.0",
|
|
35
35
|
"@atlaskit/dropdown-menu": "^12.23.0",
|
|
36
|
-
"@atlaskit/form": "^10.
|
|
36
|
+
"@atlaskit/form": "^10.6.0",
|
|
37
37
|
"@atlaskit/frontend-utilities": "^2.7.0",
|
|
38
38
|
"@atlaskit/heading": "^3.1.0",
|
|
39
|
-
"@atlaskit/icon": "^22.
|
|
39
|
+
"@atlaskit/icon": "^22.27.0",
|
|
40
40
|
"@atlaskit/icon-file-type": "^6.7.0",
|
|
41
41
|
"@atlaskit/icon-object": "^6.7.0",
|
|
42
42
|
"@atlaskit/icon-priority": "^6.3.0",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@atlaskit/textarea": "^5.6.0",
|
|
61
61
|
"@atlaskit/textfield": "^6.6.0",
|
|
62
62
|
"@atlaskit/theme": "^14.0.0",
|
|
63
|
-
"@atlaskit/tokens": "^2.
|
|
63
|
+
"@atlaskit/tokens": "^2.4.0",
|
|
64
64
|
"@atlaskit/tooltip": "^18.9.0",
|
|
65
65
|
"@atlaskit/ufo": "^0.3.0",
|
|
66
66
|
"@babel/runtime": "^7.0.0",
|
|
@@ -152,7 +152,6 @@
|
|
|
152
152
|
},
|
|
153
153
|
"af:exports": {
|
|
154
154
|
"./ssr": "./src/ssr.tsx",
|
|
155
|
-
"./client": "./src/client/index.ts",
|
|
156
155
|
"./types": "./src/types.ts",
|
|
157
156
|
"./hooks": "./src/hooks.ts",
|
|
158
157
|
"./hover-card": "./src/hoverCard.ts",
|
|
@@ -172,8 +171,14 @@
|
|
|
172
171
|
"platform-visual-refresh-icons": {
|
|
173
172
|
"type": "boolean"
|
|
174
173
|
},
|
|
174
|
+
"linking_platform_show_lozenge_atlassian_state": {
|
|
175
|
+
"type": "boolean"
|
|
176
|
+
},
|
|
175
177
|
"smart_links_for_plans_platform": {
|
|
176
178
|
"type": "boolean"
|
|
179
|
+
},
|
|
180
|
+
"smart-card-use-refactored-usesmartlinkactions": {
|
|
181
|
+
"type": "boolean"
|
|
177
182
|
}
|
|
178
183
|
}
|
|
179
184
|
}
|
package/client/package.json
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@atlaskit/smart-card/client",
|
|
3
|
-
"main": "../dist/cjs/client/index.js",
|
|
4
|
-
"module": "../dist/esm/client/index.js",
|
|
5
|
-
"module:es2019": "../dist/es2019/client/index.js",
|
|
6
|
-
"sideEffects": false,
|
|
7
|
-
"types": "../dist/types/client/index.d.ts",
|
|
8
|
-
"typesVersions": {
|
|
9
|
-
">=4.5 <5.4": {
|
|
10
|
-
"*": [
|
|
11
|
-
"../dist/types-ts4.5/client/index.d.ts"
|
|
12
|
-
]
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
package/dist/cjs/client/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "default", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _linkProvider.CardClient;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
var _linkProvider = require("@atlaskit/link-provider");
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-15961 Internal documentation for deprecation (no external access)}
|
|
3
|
-
* Remove access from entrypoint /client and use `@atlaskit/link-provider`
|
|
4
|
-
**/
|
|
5
|
-
export { CardClient as default } from '@atlaskit/link-provider';
|
package/dist/esm/client/index.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-15961 Internal documentation for deprecation (no external access)}
|
|
3
|
-
* Remove access from entrypoint /client and use `@atlaskit/link-provider`
|
|
4
|
-
**/
|
|
5
|
-
export { CardClient as default } from '@atlaskit/link-provider';
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-15961 Internal documentation for deprecation (no external access)}
|
|
3
|
-
* Remove access from entrypoint /client and use `@atlaskit/link-provider`
|
|
4
|
-
**/
|
|
5
|
-
export { CardClient as default } from '@atlaskit/link-provider';
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-15961 Internal documentation for deprecation (no external access)}
|
|
3
|
-
* Remove access from entrypoint /client and use `@atlaskit/link-provider`
|
|
4
|
-
**/
|
|
5
|
-
export { CardClient as default } from '@atlaskit/link-provider';
|