@atlaskit/smart-card 26.50.14 → 26.51.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 (84) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/extractors/common/context/extractAccessContext.js +28 -67
  3. package/dist/cjs/extractors/common/context/index.js +2 -2
  4. package/dist/cjs/extractors/flexible/actions/index.js +17 -0
  5. package/dist/cjs/extractors/flexible/index.js +2 -2
  6. package/dist/cjs/state/flexible-ui-context/types.js +1 -3
  7. package/dist/cjs/utils/analytics/analytics.js +1 -1
  8. package/dist/cjs/view/BlockCard/index.js +7 -3
  9. package/dist/cjs/view/BlockCard/views/ForbiddenView.js +3 -2
  10. package/dist/cjs/view/FlexibleCard/components/actions/index.js +8 -12
  11. package/dist/cjs/view/FlexibleCard/components/actions/preview-action/index.js +83 -0
  12. package/dist/cjs/view/FlexibleCard/components/actions/types.js +5 -0
  13. package/dist/cjs/view/FlexibleCard/components/actions/utils.js +0 -13
  14. package/dist/cjs/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +8 -6
  15. package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +45 -11
  16. package/dist/cjs/view/FlexibleCard/components/elements/snippet-element/index.js +7 -3
  17. package/dist/cjs/view/FlexibleCard/utils.js +4 -4
  18. package/dist/cjs/view/LinkUrl/index.js +1 -1
  19. package/dist/cjs/view/common/ai-summary/index.js +5 -1
  20. package/dist/es2019/extractors/common/context/extractAccessContext.js +26 -68
  21. package/dist/es2019/extractors/common/context/index.js +1 -1
  22. package/dist/es2019/extractors/flexible/actions/index.js +9 -0
  23. package/dist/es2019/extractors/flexible/index.js +2 -2
  24. package/dist/es2019/state/flexible-ui-context/types.js +6 -1
  25. package/dist/es2019/utils/analytics/analytics.js +1 -1
  26. package/dist/es2019/view/BlockCard/index.js +9 -4
  27. package/dist/es2019/view/BlockCard/views/ForbiddenView.js +3 -2
  28. package/dist/es2019/view/FlexibleCard/components/actions/index.js +1 -11
  29. package/dist/es2019/view/FlexibleCard/components/actions/preview-action/index.js +52 -0
  30. package/dist/es2019/view/FlexibleCard/components/actions/utils.js +0 -14
  31. package/dist/es2019/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +8 -6
  32. package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +42 -33
  33. package/dist/es2019/view/FlexibleCard/components/elements/snippet-element/index.js +7 -4
  34. package/dist/es2019/view/FlexibleCard/utils.js +5 -5
  35. package/dist/es2019/view/LinkUrl/index.js +1 -1
  36. package/dist/es2019/view/common/ai-summary/index.js +5 -1
  37. package/dist/esm/extractors/common/context/extractAccessContext.js +27 -66
  38. package/dist/esm/extractors/common/context/index.js +1 -1
  39. package/dist/esm/extractors/flexible/actions/index.js +10 -0
  40. package/dist/esm/extractors/flexible/index.js +2 -2
  41. package/dist/esm/state/flexible-ui-context/types.js +6 -1
  42. package/dist/esm/utils/analytics/analytics.js +1 -1
  43. package/dist/esm/view/BlockCard/index.js +8 -4
  44. package/dist/esm/view/BlockCard/views/ForbiddenView.js +3 -2
  45. package/dist/esm/view/FlexibleCard/components/actions/index.js +1 -11
  46. package/dist/esm/view/FlexibleCard/components/actions/preview-action/index.js +73 -0
  47. package/dist/esm/view/FlexibleCard/components/actions/preview-action/types.js +1 -0
  48. package/dist/esm/view/FlexibleCard/components/actions/types.js +1 -0
  49. package/dist/esm/view/FlexibleCard/components/actions/utils.js +0 -13
  50. package/dist/esm/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +8 -6
  51. package/dist/esm/view/FlexibleCard/components/blocks/utils.js +45 -11
  52. package/dist/esm/view/FlexibleCard/components/elements/snippet-element/index.js +7 -3
  53. package/dist/esm/view/FlexibleCard/utils.js +5 -5
  54. package/dist/esm/view/LinkUrl/index.js +1 -1
  55. package/dist/esm/view/common/ai-summary/index.js +5 -1
  56. package/dist/types/extractors/common/context/extractAccessContext.d.ts +1 -6
  57. package/dist/types/extractors/common/context/index.d.ts +1 -1
  58. package/dist/types/extractors/flexible/actions/index.d.ts +5 -0
  59. package/dist/types/state/flexible-ui-context/types.d.ts +8 -7
  60. package/dist/types/view/FlexibleCard/components/actions/index.d.ts +1 -7
  61. package/dist/types/view/FlexibleCard/components/actions/preview-action/index.d.ts +4 -0
  62. package/dist/types/view/FlexibleCard/components/actions/preview-action/types.d.ts +2 -0
  63. package/dist/types/view/FlexibleCard/components/actions/types.d.ts +7 -0
  64. package/dist/types/view/FlexibleCard/types.d.ts +20 -2
  65. package/dist/types-ts4.5/extractors/common/context/extractAccessContext.d.ts +1 -6
  66. package/dist/types-ts4.5/extractors/common/context/index.d.ts +1 -1
  67. package/dist/types-ts4.5/extractors/flexible/actions/index.d.ts +5 -0
  68. package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +8 -7
  69. package/dist/types-ts4.5/view/FlexibleCard/components/actions/index.d.ts +1 -7
  70. package/dist/types-ts4.5/view/FlexibleCard/components/actions/preview-action/index.d.ts +4 -0
  71. package/dist/types-ts4.5/view/FlexibleCard/components/actions/preview-action/types.d.ts +2 -0
  72. package/dist/types-ts4.5/view/FlexibleCard/components/actions/types.d.ts +7 -0
  73. package/dist/types-ts4.5/view/FlexibleCard/types.d.ts +20 -2
  74. package/package.json +2 -2
  75. package/dist/cjs/view/FlexibleCard/components/actions/action/preview-action/index.js +0 -87
  76. package/dist/es2019/view/FlexibleCard/components/actions/action/preview-action/index.js +0 -63
  77. package/dist/esm/view/FlexibleCard/components/actions/action/preview-action/index.js +0 -80
  78. package/dist/types/view/FlexibleCard/components/actions/action/preview-action/index.d.ts +0 -4
  79. package/dist/types/view/FlexibleCard/components/actions/action/preview-action/types.d.ts +0 -12
  80. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/preview-action/index.d.ts +0 -4
  81. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/preview-action/types.d.ts +0 -12
  82. /package/dist/cjs/view/FlexibleCard/components/actions/{action/preview-action → preview-action}/types.js +0 -0
  83. /package/dist/es2019/view/FlexibleCard/components/actions/{action/preview-action → preview-action}/types.js +0 -0
  84. /package/dist/{esm/view/FlexibleCard/components/actions/action/preview-action → es2019/view/FlexibleCard/components/actions}/types.js +0 -0
@@ -5,73 +5,30 @@ import { messages } from '../../../messages';
5
5
  import { ForbiddenAction } from '../../../view/BlockCard/actions/ForbiddenAction';
6
6
  import extractHostname from '../hostname/extractHostname';
7
7
  import { ANALYTICS_CHANNEL } from '../../../utils/analytics';
8
- export var extractRequestAccessContext = function extractRequestAccessContext(_ref) {
8
+ export var extractRequestAccessContextImproved = function extractRequestAccessContextImproved(_ref) {
9
9
  var _jsonLd$requestAccess;
10
10
  var jsonLd = _ref.jsonLd,
11
11
  url = _ref.url,
12
- product = _ref.product;
12
+ product = _ref.product,
13
+ createAnalyticsEvent = _ref.createAnalyticsEvent;
13
14
  var requestAccess = jsonLd !== null && jsonLd !== void 0 && jsonLd.requestAccess ? _objectSpread(_objectSpread({}, jsonLd === null || jsonLd === void 0 ? void 0 : jsonLd.requestAccess), {}, {
14
15
  hostname: extractHostname(url)
15
16
  }) : undefined;
16
17
  switch (jsonLd === null || jsonLd === void 0 || (_jsonLd$requestAccess = jsonLd.requestAccess) === null || _jsonLd$requestAccess === void 0 ? void 0 : _jsonLd$requestAccess.accessType) {
17
- case 'DIRECT_ACCESS':
18
- return _objectSpread(_objectSpread({}, requestAccess), {}, {
19
- callToActionMessageKey: 'click_to_join',
20
- descriptiveMessageKey: 'click_to_join_description',
21
- action: ForbiddenAction(function () {
22
- return window.open(url);
23
- }, 'click_to_join', messages.click_to_join, {
24
- context: product
25
- })
26
- });
27
- case 'REQUEST_ACCESS':
28
- return _objectSpread(_objectSpread({}, requestAccess), {}, {
29
- callToActionMessageKey: 'request_access',
30
- descriptiveMessageKey: 'request_access_description',
31
- action: ForbiddenAction(function () {
32
- return window.open(url);
33
- }, 'request_access', messages.request_access, {
34
- product: product
35
- })
36
- });
37
- case 'PENDING_REQUEST_EXISTS':
38
- return _objectSpread(_objectSpread({}, requestAccess), {}, {
39
- descriptiveMessageKey: 'request_access_pending_description'
40
- });
41
- case 'FORBIDDEN':
42
- return _objectSpread(_objectSpread({}, requestAccess), {}, {
43
- descriptiveMessageKey: 'forbidden_description'
44
- });
45
- case 'DENIED_REQUEST_EXISTS':
46
- return _objectSpread(_objectSpread({}, requestAccess), {}, {
47
- descriptiveMessageKey: 'request_denied_description'
48
- });
49
- default:
50
- return requestAccess;
51
- }
52
- };
53
- export var extractRequestAccessContextImproved = function extractRequestAccessContextImproved(_ref2) {
54
- var _jsonLd$requestAccess2;
55
- var jsonLd = _ref2.jsonLd,
56
- url = _ref2.url,
57
- product = _ref2.product,
58
- createAnalyticsEvent = _ref2.createAnalyticsEvent;
59
- var requestAccess = jsonLd !== null && jsonLd !== void 0 && jsonLd.requestAccess ? _objectSpread(_objectSpread({}, jsonLd === null || jsonLd === void 0 ? void 0 : jsonLd.requestAccess), {}, {
60
- hostname: extractHostname(url)
61
- }) : undefined;
62
- switch (jsonLd === null || jsonLd === void 0 || (_jsonLd$requestAccess2 = jsonLd.requestAccess) === null || _jsonLd$requestAccess2 === void 0 ? void 0 : _jsonLd$requestAccess2.accessType) {
63
18
  case 'DIRECT_ACCESS':
64
19
  return _objectSpread(_objectSpread({}, requestAccess), {}, {
65
20
  titleMessageKey: 'direct_access_title',
66
21
  descriptiveMessageKey: 'direct_access_description',
67
22
  callToActionMessageKey: 'direct_access',
68
23
  action: ForbiddenAction(function () {
69
- createAnalyticsEvent({
70
- action: 'clicked',
71
- actionSubject: 'button',
72
- actionSubjectId: 'crossJoin',
73
- eventType: 'ui'
74
- }).fire(ANALYTICS_CHANNEL);
24
+ if (createAnalyticsEvent !== undefined) {
25
+ createAnalyticsEvent({
26
+ action: 'clicked',
27
+ actionSubject: 'button',
28
+ actionSubjectId: 'crossJoin',
29
+ eventType: 'ui'
30
+ }).fire(ANALYTICS_CHANNEL);
31
+ }
75
32
  window.open(url);
76
33
  }, 'direct_access', messages.direct_access, {
77
34
  product: product
@@ -83,12 +40,14 @@ export var extractRequestAccessContextImproved = function extractRequestAccessCo
83
40
  descriptiveMessageKey: 'request_access_description',
84
41
  callToActionMessageKey: 'request_access',
85
42
  action: ForbiddenAction(function () {
86
- createAnalyticsEvent({
87
- action: 'clicked',
88
- actionSubject: 'button',
89
- actionSubjectId: 'requestAccess',
90
- eventType: 'ui'
91
- }).fire(ANALYTICS_CHANNEL);
43
+ if (createAnalyticsEvent !== undefined) {
44
+ createAnalyticsEvent({
45
+ action: 'clicked',
46
+ actionSubject: 'button',
47
+ actionSubjectId: 'requestAccess',
48
+ eventType: 'ui'
49
+ }).fire(ANALYTICS_CHANNEL);
50
+ }
92
51
  window.open(url);
93
52
  }, 'request_access', messages.request_access)
94
53
  });
@@ -119,12 +78,14 @@ export var extractRequestAccessContextImproved = function extractRequestAccessCo
119
78
  descriptiveMessageKey: 'access_exists_description',
120
79
  callToActionMessageKey: 'request_access',
121
80
  action: ForbiddenAction(function () {
122
- createAnalyticsEvent({
123
- action: 'clicked',
124
- actionSubject: 'button',
125
- actionSubjectId: 'requestAccess',
126
- eventType: 'ui'
127
- }).fire(ANALYTICS_CHANNEL);
81
+ if (createAnalyticsEvent !== undefined) {
82
+ createAnalyticsEvent({
83
+ action: 'clicked',
84
+ actionSubject: 'button',
85
+ actionSubjectId: 'requestAccess',
86
+ eventType: 'ui'
87
+ }).fire(ANALYTICS_CHANNEL);
88
+ }
128
89
  window.open(url);
129
90
  }, 'access_exists', messages.request_access)
130
91
  });
@@ -1 +1 @@
1
- export { extractRequestAccessContext } from './extractAccessContext';
1
+ export { extractRequestAccessContextImproved } from './extractAccessContext';
@@ -0,0 +1,10 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import { ActionName } from '../../../constants';
3
+ import { extractPreviewAction } from './extract-preview-action';
4
+ var extractActions = function extractActions(response, actionOptions) {
5
+ var action = _defineProperty({}, ActionName.PreviewAction, extractPreviewAction(response, actionOptions));
6
+ return Object.values(action).some(function (value) {
7
+ return Boolean(value);
8
+ }) ? action : undefined;
9
+ };
10
+ export default extractActions;
@@ -1,4 +1,5 @@
1
1
  import { extractSummary } from '../common/primitives';
2
+ import extractActions from './actions';
2
3
  import extractFollowAction from './actions/extract-follow-action';
3
4
  import { extractLinkIcon } from './icon';
4
5
  import { extractAttachmentCount, extractChecklistProgress, extractCommentCount, extractCreatedBy, extractModifiedBy, extractProgrammingLanguage, extractSubscriberCount, extractViewCount, extractReactCount, extractVoteCount, extractSourceBranch, extractTargetBranch, extractDueOn, extractLocation, extractOwnedBy, extractAssignedTo, extractSubTasksProgress, extractStoryPoints, extractReadTime, extractSentOn, extractPersonAssignedToAsArray } from './utils';
@@ -9,7 +10,6 @@ import extractProviderIcon from './icon/extract-provider-icon';
9
10
  import extractPreview from './extract-preview';
10
11
  import extractState from './extract-state';
11
12
  import { extractLatestCommit } from './latest-commit';
12
- import { extractPreviewAction } from './actions/extract-preview-action';
13
13
  import { extractDownloadAction } from './actions/extract-download-action';
14
14
  import { extractViewAction } from './actions/extract-view-action';
15
15
  var extractFlexibleUiContext = function extractFlexibleUiContext() {
@@ -24,6 +24,7 @@ var extractFlexibleUiContext = function extractFlexibleUiContext() {
24
24
  var data = response.data;
25
25
  var url = extractLink(data);
26
26
  return {
27
+ actions: extractActions(response, actionOptions),
27
28
  assignedToGroup: extractPersonAssignedToAsArray(data),
28
29
  attachmentCount: extractAttachmentCount(data),
29
30
  authorGroup: extractPersonCreatedBy(data),
@@ -40,7 +41,6 @@ var extractFlexibleUiContext = function extractFlexibleUiContext() {
40
41
  createdOn: extractDateCreated(data),
41
42
  dueOn: extractDueOn(data),
42
43
  followAction: extractFollowAction(response, actionOptions, id),
43
- previewAction: extractPreviewAction(response, actionOptions),
44
44
  viewAction: extractViewAction(data, actionOptions),
45
45
  downloadAction: extractDownloadAction(data, actionOptions),
46
46
  latestCommit: extractLatestCommit(data),
@@ -1 +1,6 @@
1
- export {};
1
+ import { ActionName } from '../../constants';
2
+
3
+ /**
4
+ * This provides the data that will be used by Smart Links Flexible UI to populate it's
5
+ * underlying elements.
6
+ */
@@ -15,7 +15,7 @@ export var ANALYTICS_CHANNEL = 'media';
15
15
  export var context = {
16
16
  componentName: 'smart-cards',
17
17
  packageName: "@atlaskit/smart-card",
18
- packageVersion: "26.50.14"
18
+ packageVersion: "26.51.0"
19
19
  };
20
20
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
21
21
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -1,10 +1,11 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  /** @jsx jsx */
3
3
 
4
+ import { useAnalyticsEvents } from '@atlaskit/analytics-next';
4
5
  import { getExtensionKey } from '../../state/helpers';
5
6
  import { extractBlockProps } from '../../extractors/block';
6
7
  import { getEmptyJsonLd, getForbiddenJsonLd } from '../../utils/jsonld';
7
- import { extractRequestAccessContext } from '../../extractors/common/context';
8
+ import { extractRequestAccessContextImproved } from '../../extractors/common/context';
8
9
  import { CardLinkView } from '../LinkView';
9
10
  import { AuthorizeAction } from './actions/AuthorizeAction';
10
11
  import { ForbiddenAction } from './actions/ForbiddenAction';
@@ -24,7 +25,7 @@ import { handleClickCommon } from './utils/handlers';
24
25
  export { default as PreviewAction } from './actions/PreviewAction';
25
26
  export { ForbiddenAction, AuthorizeAction, BlockCardResolvedView, BlockCardResolvingView, BlockCardUnauthorisedView, BlockCardForbiddenView, BlockCardErroredView, BlockCardNotFoundView };
26
27
  export var BlockCard = function BlockCard(_ref) {
27
- var _details$meta, _forbiddenViewProps$c;
28
+ var _details$meta, _forbiddenViewProps$c, _forbiddenViewProps$c2;
28
29
  var id = _ref.id,
29
30
  url = _ref.url,
30
31
  cardState = _ref.cardState,
@@ -42,6 +43,8 @@ export var BlockCard = function BlockCard(_ref) {
42
43
  analytics = _ref.analytics,
43
44
  enableFlexibleBlockCard = _ref.enableFlexibleBlockCard,
44
45
  actionOptions = _ref.actionOptions;
46
+ var _useAnalyticsEvents = useAnalyticsEvents(),
47
+ createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
45
48
  var status = cardState.status,
46
49
  details = cardState.details;
47
50
  var data = details && details.data || getEmptyJsonLd();
@@ -155,10 +158,11 @@ export var BlockCard = function BlockCard(_ref) {
155
158
  }
156
159
  var forbiddenViewProps = extractBlockProps(data, meta, extractorOpts);
157
160
  var cardMetadata = (_details$meta = details === null || details === void 0 ? void 0 : details.meta) !== null && _details$meta !== void 0 ? _details$meta : getForbiddenJsonLd().meta;
158
- var requestAccessContext = extractRequestAccessContext({
161
+ var requestAccessContext = extractRequestAccessContextImproved({
159
162
  jsonLd: cardMetadata,
160
163
  url: url,
161
- product: (_forbiddenViewProps$c = forbiddenViewProps.context) === null || _forbiddenViewProps$c === void 0 ? void 0 : _forbiddenViewProps$c.text
164
+ product: (_forbiddenViewProps$c = (_forbiddenViewProps$c2 = forbiddenViewProps.context) === null || _forbiddenViewProps$c2 === void 0 ? void 0 : _forbiddenViewProps$c2.text) !== null && _forbiddenViewProps$c !== void 0 ? _forbiddenViewProps$c : '',
165
+ createAnalyticsEvent: createAnalyticsEvent
162
166
  });
163
167
  return jsx(BlockCardForbiddenView, _extends({}, forbiddenViewProps, {
164
168
  isSelected: isSelected,
@@ -56,8 +56,9 @@ export var ForbiddenView = function ForbiddenView(_ref) {
56
56
  _requestAccessContext = requestAccessContext.descriptiveMessageKey,
57
57
  descriptiveMessageKey = _requestAccessContext === void 0 ? 'invalid_permissions_description' : _requestAccessContext,
58
58
  _requestAccessContext2 = requestAccessContext.hostname,
59
- hostname = _requestAccessContext2 === void 0 ? '' : _requestAccessContext2;
60
- var items = action ? [].concat(_toConsumableArray(actions), [action]) : actions;
59
+ hostname = _requestAccessContext2 === void 0 ? '' : _requestAccessContext2,
60
+ buttonDisabled = requestAccessContext.buttonDisabled;
61
+ var items = action !== undefined && !(buttonDisabled !== null && buttonDisabled !== void 0 ? buttonDisabled : false) ? [].concat(_toConsumableArray(actions), [action]) : actions;
61
62
  return jsx(Frame, {
62
63
  isSelected: isSelected,
63
64
  testId: testId,
@@ -1,10 +1,7 @@
1
1
  import { ActionName } from '../../../../constants';
2
2
  import { createDataAction, createUIAction } from './utils';
3
3
  export { default as FollowAction } from './follow-action';
4
-
5
- // Attention: Keep the export name and action name the same.
6
- // This will help reducing the code for mapping action inside
7
- // createAction and renderActionItems
4
+ export { default as PreviewAction } from './preview-action';
8
5
 
9
6
  /**
10
7
  * Creates a DeleteAction component. Accepts default ActionProps, but defaults
@@ -19,13 +16,6 @@ export var DeleteAction = createUIAction(ActionName.DeleteAction);
19
16
  */
20
17
  export var EditAction = createUIAction(ActionName.EditAction);
21
18
 
22
- /**
23
- * Creates a PreviewAction component. Accepts default PreviewActionProps, and defaults
24
- * to the text 'Preview' inside the button.
25
- * @see Action
26
- */
27
- export var PreviewAction = createDataAction(ActionName.PreviewAction);
28
-
29
19
  /**
30
20
  * Creates a ViewAction component. Accepts default ViewActionProps, and defaults
31
21
  * to the text 'View' inside the button.
@@ -0,0 +1,73 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
4
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
+ var _excluded = ["onClick"];
6
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
7
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
8
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
9
+ import VidFullScreenOnIcon from '@atlaskit/icon/glyph/vid-full-screen-on';
10
+ import React, { useCallback } from 'react';
11
+ import { FormattedMessage } from 'react-intl-next';
12
+ import { ActionName } from '../../../../../constants';
13
+ import { messages } from '../../../../../messages';
14
+ import { useFlexibleUiAnalyticsContext, useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
15
+ import useInvokeClientAction from '../../../../../state/hooks/use-invoke-client-action';
16
+ import { openEmbedModalWithFlexibleUiIcon } from '../../utils';
17
+ import Action from '../action';
18
+ var PreviewAction = function PreviewAction(_ref) {
19
+ var _context$actions;
20
+ var onClickCallback = _ref.onClick,
21
+ props = _objectWithoutProperties(_ref, _excluded);
22
+ var context = useFlexibleUiContext();
23
+ var analytics = useFlexibleUiAnalyticsContext();
24
+ var invoke = useInvokeClientAction({
25
+ analytics: analytics
26
+ });
27
+ var data = context === null || context === void 0 || (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[ActionName.PreviewAction];
28
+ var onClick = useCallback(function () {
29
+ if (data) {
30
+ invoke({
31
+ actionType: ActionName.PreviewAction,
32
+ actionFn: function () {
33
+ var _actionFn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
34
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
35
+ while (1) switch (_context.prev = _context.next) {
36
+ case 0:
37
+ return _context.abrupt("return", openEmbedModalWithFlexibleUiIcon(_objectSpread({
38
+ download: data === null || data === void 0 ? void 0 : data.downloadUrl,
39
+ extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey,
40
+ analytics: analytics
41
+ }, data)));
42
+ case 1:
43
+ case "end":
44
+ return _context.stop();
45
+ }
46
+ }, _callee);
47
+ }));
48
+ function actionFn() {
49
+ return _actionFn.apply(this, arguments);
50
+ }
51
+ return actionFn;
52
+ }(),
53
+ // These values have already been set in analytics context.
54
+ // We only pass these here for ufo experience.
55
+ display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
56
+ extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
57
+ });
58
+ }
59
+ if (onClickCallback) {
60
+ onClickCallback();
61
+ }
62
+ }, [analytics, data, invoke, onClickCallback]);
63
+ return data ? /*#__PURE__*/React.createElement(Action, _extends({
64
+ content: /*#__PURE__*/React.createElement(FormattedMessage, messages.preview_improved),
65
+ icon: /*#__PURE__*/React.createElement(VidFullScreenOnIcon, {
66
+ label: "Open preview"
67
+ }),
68
+ onClick: onClick,
69
+ testId: "smart-action-preview-action",
70
+ tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.preview_improved)
71
+ }, data, props)) : null;
72
+ };
73
+ export default PreviewAction;
@@ -12,8 +12,6 @@ import { FormattedMessage } from 'react-intl-next';
12
12
  import { messages } from '../../../../messages';
13
13
  import CrossIcon from '@atlaskit/icon/glyph/cross';
14
14
  import EditIcon from '@atlaskit/icon/glyph/edit';
15
- import PreviewAction from './action/preview-action';
16
- import VidFullScreenOnIcon from '@atlaskit/icon/glyph/vid-full-screen-on';
17
15
  import ViewAction from './action/view-action';
18
16
  import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
19
17
  import DownloadAction from './action/download-action';
@@ -41,16 +39,6 @@ var actionMappings = (_actionMappings = {}, _defineProperty(_actionMappings, Act
41
39
  }),
42
40
  tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.edit)
43
41
  }
44
- }), _defineProperty(_actionMappings, ActionName.PreviewAction, {
45
- component: PreviewAction,
46
- props: {
47
- testId: 'smart-action-preview-action',
48
- content: /*#__PURE__*/React.createElement(FormattedMessage, messages.preview_improved),
49
- icon: /*#__PURE__*/React.createElement(VidFullScreenOnIcon, {
50
- label: "Open preview"
51
- }),
52
- tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.preview_improved)
53
- }
54
42
  }), _defineProperty(_actionMappings, ActionName.ViewAction, {
55
43
  component: ViewAction,
56
44
  props: {
@@ -83,7 +71,6 @@ var getActionData = function getActionData(actionName, contextKey, context) {
83
71
  }
84
72
  var data = context[contextKey];
85
73
  switch (actionName) {
86
- case ActionName.PreviewAction:
87
74
  case ActionName.ViewAction:
88
75
  case ActionName.DownloadAction:
89
76
  return data;
@@ -8,7 +8,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
8
8
  import { jsx } from '@emotion/react';
9
9
  import React, { useCallback } from 'react';
10
10
  import * as Actions from '../../../actions';
11
- import { isJSXElementNull } from '../../utils';
12
11
  var ActionGroupItem = function ActionGroupItem(_ref) {
13
12
  var item = _ref.item,
14
13
  size = _ref.size,
@@ -40,7 +39,14 @@ var ActionGroupItem = function ActionGroupItem(_ref) {
40
39
  if (hideIcon) {
41
40
  actionProps.icon = undefined;
42
41
  }
43
- var action = jsx(Action, _extends({
42
+ return jsx(Action
43
+ // Remove url once ViewAction is retired.
44
+ // This seems to be a typescript workaround
45
+ // because ViewAction marks it as required,
46
+ // which does not reflect actual implementation as the url
47
+ // came from data context and not all actions require url.
48
+ // https://product-fabric.atlassian.net/browse/EDM-9547
49
+ , _extends({
44
50
  url: "",
45
51
  asDropDownItem: asDropDownItems,
46
52
  size: size,
@@ -48,9 +54,5 @@ var ActionGroupItem = function ActionGroupItem(_ref) {
48
54
  onClick: handleOnClick,
49
55
  isDisabled: isDisabled
50
56
  }, actionProps));
51
- if (!isJSXElementNull(action)) {
52
- return action;
53
- }
54
- return null;
55
57
  };
56
58
  export default ActionGroupItem;
@@ -4,7 +4,7 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
4
4
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
5
5
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
6
6
  var _excluded = ["name"];
7
- var _ElementDisplaySchema, _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
7
+ var _ElementDisplaySchema, _templateObject;
8
8
  import React from 'react';
9
9
  import { css } from '@emotion/react';
10
10
  import { ActionName, ElementName, SmartLinkDirection, SmartLinkSize } from '../../../../constants';
@@ -19,10 +19,16 @@ export var ElementDisplaySchema = (_ElementDisplaySchema = {}, _defineProperty(_
19
19
  var getDirectionStyles = function getDirectionStyles(direction) {
20
20
  switch (direction) {
21
21
  case SmartLinkDirection.Vertical:
22
- return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n flex-direction: column;\n align-items: flex-start;\n "])));
22
+ return css({
23
+ flexDirection: 'column',
24
+ alignItems: 'flex-start'
25
+ });
23
26
  case SmartLinkDirection.Horizontal:
24
27
  default:
25
- return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n flex-direction: row;\n align-items: center;\n "])));
28
+ return css({
29
+ flexDirection: 'row',
30
+ alignItems: 'center'
31
+ });
26
32
  }
27
33
  };
28
34
  export var getGapSize = function getGapSize(size) {
@@ -39,9 +45,26 @@ export var getGapSize = function getGapSize(size) {
39
45
  }
40
46
  };
41
47
  export var getBaseStyles = function getBaseStyles(direction, size) {
42
- return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n align-items: center;\n display: flex;\n gap: ", "rem;\n line-height: 1rem;\n min-width: 0;\n overflow: hidden;\n ", ";\n &:empty {\n display: none;\n }\n & > * {\n min-width: 0;\n }\n & > [data-fit-to-content] {\n min-width: fit-content;\n }\n"])), getGapSize(size), getDirectionStyles(direction));
48
+ return css({
49
+ alignItems: 'center',
50
+ display: 'flex',
51
+ gap: "".concat(getGapSize(size), "rem"),
52
+ lineHeight: '1rem',
53
+ minWidth: 0,
54
+ overflow: 'hidden'
55
+ }, getDirectionStyles(direction), {
56
+ '&:empty': {
57
+ display: 'none'
58
+ },
59
+ '& > *': {
60
+ minWidth: 0
61
+ },
62
+ '& > [data-fit-to-content]': {
63
+ minWidth: 'fit-content'
64
+ }
65
+ });
43
66
  };
44
- export var highlightRemoveStyles = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n outline: none !important;\n outline-color: inherit;\n color: inherit;\n -webkit-tap-highlight-color: transparent;\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n"])));
67
+ export var highlightRemoveStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n outline: none !important;\n outline-color: inherit;\n color: inherit;\n -webkit-tap-highlight-color: transparent;\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n"])));
45
68
  var isActionGroup = function isActionGroup(node) {
46
69
  return /*#__PURE__*/React.isValidElement(node) && node.type === ActionGroup;
47
70
  };
@@ -60,26 +83,37 @@ export var getActionGroupStyles = function getActionGroupStyles(size) {
60
83
  // The biggest height of the action button exceeds the max line-height
61
84
  // of the elements causing the action on the block with x-large size to
62
85
  // get cut at the bottom.
63
- return css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n max-height: 2rem;\n "])));
86
+ return css({
87
+ maxHeight: '2rem'
88
+ });
64
89
  }
65
90
  };
66
91
  export var filterActionItems = function filterActionItems() {
67
92
  var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
68
93
  var context = arguments.length > 1 ? arguments[1] : undefined;
69
94
  return items.filter(function (item) {
95
+ var _context$actions;
70
96
  switch (item.name) {
71
- // Action that require data from the data context to render.
97
+ case ActionName.DeleteAction:
98
+ case ActionName.EditAction:
99
+ case ActionName.CustomAction:
100
+ // Named and custom actions that user defines.
101
+ return Boolean(ActionName[item.name]);
72
102
  case ActionName.DownloadAction:
103
+ // Remove once DownloadAction is refactored to context.action
104
+ // https://product-fabric.atlassian.net/browse/EDM-9545
73
105
  return Boolean(context === null || context === void 0 ? void 0 : context.downloadAction);
106
+ // Remove once FollowAction is refactored to context.action
107
+ // https://product-fabric.atlassian.net/browse/EDM-9559
74
108
  case ActionName.FollowAction:
75
109
  return Boolean(context === null || context === void 0 ? void 0 : context.followAction);
76
- case ActionName.PreviewAction:
77
- return Boolean(context === null || context === void 0 ? void 0 : context.previewAction);
110
+ // Remove once ViewAction is retired
111
+ // https://product-fabric.atlassian.net/browse/EDM-9547
78
112
  case ActionName.ViewAction:
79
113
  return Boolean(context === null || context === void 0 ? void 0 : context.viewAction);
80
114
  default:
81
- // Named and custom actions that user defines.
82
- return Boolean(ActionName[item.name]);
115
+ // Action that require data from the data context to render.
116
+ return Boolean(context === null || context === void 0 || (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[item.name]);
83
117
  }
84
118
  });
85
119
  };
@@ -1,8 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
4
3
  var _excluded = ["content", "maxLines", "overrideCss"];
5
- var _templateObject;
6
4
  /** @jsx jsx */
7
5
  import { css, jsx } from '@emotion/react';
8
6
  import React, { useContext } from 'react';
@@ -10,7 +8,13 @@ import { FlexibleUiContext } from '../../../../../state/flexible-ui-context';
10
8
  import Text from '../text';
11
9
  var SNIPPET_DEFAULT_MAX_LINES = 3;
12
10
  var getSnippetStyles = function getSnippetStyles(overrideCss) {
13
- return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n ", ";\n"])), "var(--ds-text, #172B4D)", overrideCss);
11
+ return css({
12
+ color: "var(--ds-text, #172B4D)",
13
+ WebkitUserSelect: 'text',
14
+ MozUserSelect: 'text',
15
+ MsUserSelect: 'text',
16
+ userSelect: 'text'
17
+ }, overrideCss);
14
18
  };
15
19
  var SnippetElement = function SnippetElement() {
16
20
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -1,6 +1,6 @@
1
1
  import { SmartLinkStatus } from '../../constants';
2
2
  import { getEmptyJsonLd, getForbiddenJsonLd } from '../../utils/jsonld';
3
- import { extractRequestAccessContext } from '../../extractors/common/context';
3
+ import { extractRequestAccessContextImproved } from '../../extractors/common/context';
4
4
  import { messages } from '../../messages';
5
5
  import extractFlexibleUiContext from '../../extractors/flexible';
6
6
  import { extractErrorIcon } from '../../extractors/flexible/icon';
@@ -59,7 +59,7 @@ var getForbiddenMessageKey = function getForbiddenMessageKey(meta) {
59
59
  }
60
60
  };
61
61
  export var getRetryOptions = function getRetryOptions(url, status, response, onAuthorize) {
62
- var _response$meta, _access$action;
62
+ var _response$meta, _access$action, _access$buttonDisable;
63
63
  var data = response && response.data || getEmptyJsonLd();
64
64
  var provider = extractProvider(data);
65
65
  var context = provider === null || provider === void 0 ? void 0 : provider.text;
@@ -69,15 +69,15 @@ export var getRetryOptions = function getRetryOptions(url, status, response, onA
69
69
  switch (status) {
70
70
  case SmartLinkStatus.Forbidden:
71
71
  var meta = (_response$meta = response === null || response === void 0 ? void 0 : response.meta) !== null && _response$meta !== void 0 ? _response$meta : getForbiddenJsonLd().meta;
72
- var access = extractRequestAccessContext({
72
+ var access = extractRequestAccessContextImproved({
73
73
  jsonLd: meta,
74
74
  url: url,
75
- product: context
75
+ product: context !== null && context !== void 0 ? context : ''
76
76
  });
77
77
  var messageKey = getForbiddenMessageKey(meta);
78
78
  var descriptor = messages[messageKey];
79
79
  var retry = onAuthorize || (access === null || access === void 0 || (_access$action = access.action) === null || _access$action === void 0 ? void 0 : _access$action.promise);
80
- var onClick = retry ? handleOnClick(retry) : undefined;
80
+ var onClick = retry && !((_access$buttonDisable = access === null || access === void 0 ? void 0 : access.buttonDisabled) !== null && _access$buttonDisable !== void 0 ? _access$buttonDisable : false) ? handleOnClick(retry) : undefined;
81
81
  return {
82
82
  descriptor: descriptor,
83
83
  onClick: onClick,
@@ -10,7 +10,7 @@ import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-m
10
10
  import LinkWarningModal from './LinkWarningModal';
11
11
  var PACKAGE_DATA = {
12
12
  packageName: "@atlaskit/smart-card",
13
- packageVersion: "26.50.14",
13
+ packageVersion: "26.51.0",
14
14
  componentName: 'linkUrl'
15
15
  };
16
16
  var Link = withLinkClickedEvent('a');
@@ -15,7 +15,11 @@ var AISummaryCSSStyles = css({
15
15
  fontSize: '0.75rem',
16
16
  lineHeight: '1rem',
17
17
  wordWrap: 'break-word',
18
- whiteSpace: 'normal'
18
+ whiteSpace: 'normal',
19
+ WebkitUserSelect: 'text',
20
+ MozUserSelect: 'text',
21
+ MsUserSelect: 'text',
22
+ userSelect: 'text'
19
23
  });
20
24
  /**
21
25
  * A component to render a response from AI in markdown text.
@@ -1,14 +1,9 @@
1
1
  import { JsonLd } from 'json-ld-types';
2
2
  import { RequestAccessContextProps } from '../../../view/types';
3
3
  import { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
4
- export declare const extractRequestAccessContext: ({ jsonLd, url, product, }: {
5
- jsonLd: JsonLd.Meta.BaseMeta;
6
- url: string;
7
- product?: string | undefined;
8
- }) => RequestAccessContextProps;
9
4
  export declare const extractRequestAccessContextImproved: ({ jsonLd, url, product, createAnalyticsEvent, }: {
10
5
  jsonLd: JsonLd.Meta.BaseMeta;
11
6
  url: string;
12
7
  product: string;
13
- createAnalyticsEvent: CreateUIAnalyticsEvent;
8
+ createAnalyticsEvent?: CreateUIAnalyticsEvent | undefined;
14
9
  }) => RequestAccessContextProps;
@@ -1 +1 @@
1
- export { extractRequestAccessContext } from './extractAccessContext';
1
+ export { extractRequestAccessContextImproved } from './extractAccessContext';
@@ -0,0 +1,5 @@
1
+ import type { JsonLd } from 'json-ld-types';
2
+ import type { FlexibleUiActions } from '../../../state/flexible-ui-context/types';
3
+ import type { CardActionOptions } from '../../../view/Card/types';
4
+ declare const extractActions: (response: JsonLd.Response, actionOptions?: CardActionOptions) => FlexibleUiActions | undefined;
5
+ export default extractActions;