@atlaskit/smart-card 32.7.0 → 32.7.1

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 (160) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/analytics.spec.yaml +63 -9
  3. package/dist/cjs/common/analytics/types.js +5 -0
  4. package/dist/cjs/extractors/action/extract-invoke-copy-link-action.js +53 -0
  5. package/dist/cjs/extractors/action/extract-invoke-download-action.js +57 -0
  6. package/dist/cjs/extractors/action/extract-invoke-preview-action.js +78 -0
  7. package/dist/cjs/extractors/action/extract-invoke-view-action.js +60 -0
  8. package/dist/cjs/extractors/action/extractDownloadActionProps.js +4 -0
  9. package/dist/cjs/extractors/action/extractPreviewActionProps.js +4 -0
  10. package/dist/cjs/extractors/action/extractViewActionProps.js +4 -0
  11. package/dist/cjs/extractors/action/types.js +5 -0
  12. package/dist/cjs/extractors/flexible/actions/extract-copy-link-action.js +12 -1
  13. package/dist/cjs/extractors/flexible/actions/extract-download-action.js +12 -1
  14. package/dist/cjs/extractors/flexible/actions/extract-preview-action.js +12 -1
  15. package/dist/cjs/extractors/flexible/actions/extract-view-action.js +3 -0
  16. package/dist/cjs/extractors/flexible/actions/index.js +40 -3
  17. package/dist/cjs/extractors/flexible/extract-state.js +19 -5
  18. package/dist/cjs/extractors/flexible/index.js +22 -8
  19. package/dist/cjs/state/hooks/use-invoke-client-action/index.js +56 -17
  20. package/dist/cjs/state/hooks-external/useSmartLinkActions.js +22 -3
  21. package/dist/cjs/utils/analytics/LinkAnalyticsContext.js +7 -2
  22. package/dist/cjs/utils/analytics/analytics.js +1 -1
  23. package/dist/cjs/utils/mocks.js +4 -1
  24. package/dist/cjs/view/BlockCard/views/flexible/FlexibleResolvedView.js +1 -0
  25. package/dist/cjs/view/BlockCard/views/flexible/unresolved-view/index.js +1 -0
  26. package/dist/cjs/view/CardWithUrl/component.js +1 -0
  27. package/dist/cjs/view/EmbedModal/index.js +72 -51
  28. package/dist/cjs/view/FlexibleCard/components/actions/copy-link-action/index.js +65 -32
  29. package/dist/cjs/view/FlexibleCard/components/actions/download-action/index.js +36 -28
  30. package/dist/cjs/view/FlexibleCard/components/actions/preview-action/index.js +40 -32
  31. package/dist/cjs/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.js +13 -6
  32. package/dist/cjs/view/FlexibleCard/components/utils.js +4 -0
  33. package/dist/cjs/view/FlexibleCard/index.js +11 -1
  34. package/dist/cjs/view/HoverCard/components/HoverCardContent.js +1 -0
  35. package/dist/cjs/view/LinkUrl/index.js +1 -1
  36. package/dist/es2019/common/analytics/types.js +1 -0
  37. package/dist/es2019/extractors/action/extract-invoke-copy-link-action.js +29 -0
  38. package/dist/es2019/extractors/action/extract-invoke-download-action.js +31 -0
  39. package/dist/es2019/extractors/action/extract-invoke-preview-action.js +57 -0
  40. package/dist/es2019/extractors/action/extract-invoke-view-action.js +34 -0
  41. package/dist/es2019/extractors/action/extractDownloadActionProps.js +5 -0
  42. package/dist/es2019/extractors/action/extractPreviewActionProps.js +5 -0
  43. package/dist/es2019/extractors/action/extractViewActionProps.js +5 -0
  44. package/dist/es2019/extractors/action/types.js +1 -0
  45. package/dist/es2019/extractors/flexible/actions/extract-copy-link-action.js +11 -0
  46. package/dist/es2019/extractors/flexible/actions/extract-download-action.js +12 -0
  47. package/dist/es2019/extractors/flexible/actions/extract-preview-action.js +12 -0
  48. package/dist/es2019/extractors/flexible/actions/extract-view-action.js +4 -0
  49. package/dist/es2019/extractors/flexible/actions/index.js +48 -3
  50. package/dist/es2019/extractors/flexible/extract-state.js +17 -5
  51. package/dist/es2019/extractors/flexible/index.js +17 -6
  52. package/dist/es2019/state/hooks/use-invoke-client-action/index.js +91 -43
  53. package/dist/es2019/state/hooks-external/useSmartLinkActions.js +21 -3
  54. package/dist/es2019/utils/analytics/LinkAnalyticsContext.js +3 -0
  55. package/dist/es2019/utils/analytics/analytics.js +1 -1
  56. package/dist/es2019/utils/mocks.js +4 -1
  57. package/dist/es2019/view/BlockCard/views/flexible/FlexibleResolvedView.js +1 -0
  58. package/dist/es2019/view/BlockCard/views/flexible/unresolved-view/index.js +1 -0
  59. package/dist/es2019/view/CardWithUrl/component.js +1 -0
  60. package/dist/es2019/view/EmbedModal/index.js +41 -20
  61. package/dist/es2019/view/FlexibleCard/components/actions/copy-link-action/index.js +31 -16
  62. package/dist/es2019/view/FlexibleCard/components/actions/download-action/index.js +20 -12
  63. package/dist/es2019/view/FlexibleCard/components/actions/preview-action/index.js +25 -17
  64. package/dist/es2019/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.js +14 -7
  65. package/dist/es2019/view/FlexibleCard/components/utils.js +4 -0
  66. package/dist/es2019/view/FlexibleCard/index.js +12 -1
  67. package/dist/es2019/view/HoverCard/components/HoverCardContent.js +1 -0
  68. package/dist/es2019/view/LinkUrl/index.js +1 -1
  69. package/dist/esm/common/analytics/types.js +1 -0
  70. package/dist/esm/extractors/action/extract-invoke-copy-link-action.js +46 -0
  71. package/dist/esm/extractors/action/extract-invoke-download-action.js +50 -0
  72. package/dist/esm/extractors/action/extract-invoke-preview-action.js +71 -0
  73. package/dist/esm/extractors/action/extract-invoke-view-action.js +53 -0
  74. package/dist/esm/extractors/action/extractDownloadActionProps.js +5 -0
  75. package/dist/esm/extractors/action/extractPreviewActionProps.js +5 -0
  76. package/dist/esm/extractors/action/extractViewActionProps.js +5 -0
  77. package/dist/esm/extractors/action/types.js +1 -0
  78. package/dist/esm/extractors/flexible/actions/extract-copy-link-action.js +11 -0
  79. package/dist/esm/extractors/flexible/actions/extract-download-action.js +12 -0
  80. package/dist/esm/extractors/flexible/actions/extract-preview-action.js +12 -0
  81. package/dist/esm/extractors/flexible/actions/extract-view-action.js +4 -0
  82. package/dist/esm/extractors/flexible/actions/index.js +42 -5
  83. package/dist/esm/extractors/flexible/extract-state.js +19 -5
  84. package/dist/esm/extractors/flexible/index.js +19 -8
  85. package/dist/esm/state/hooks/use-invoke-client-action/index.js +56 -17
  86. package/dist/esm/state/hooks-external/useSmartLinkActions.js +22 -3
  87. package/dist/esm/utils/analytics/LinkAnalyticsContext.js +7 -2
  88. package/dist/esm/utils/analytics/analytics.js +1 -1
  89. package/dist/esm/utils/mocks.js +4 -1
  90. package/dist/esm/view/BlockCard/views/flexible/FlexibleResolvedView.js +1 -0
  91. package/dist/esm/view/BlockCard/views/flexible/unresolved-view/index.js +1 -0
  92. package/dist/esm/view/CardWithUrl/component.js +1 -0
  93. package/dist/esm/view/EmbedModal/index.js +73 -52
  94. package/dist/esm/view/FlexibleCard/components/actions/copy-link-action/index.js +65 -32
  95. package/dist/esm/view/FlexibleCard/components/actions/download-action/index.js +36 -28
  96. package/dist/esm/view/FlexibleCard/components/actions/preview-action/index.js +40 -32
  97. package/dist/esm/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.js +13 -6
  98. package/dist/esm/view/FlexibleCard/components/utils.js +4 -0
  99. package/dist/esm/view/FlexibleCard/index.js +11 -1
  100. package/dist/esm/view/HoverCard/components/HoverCardContent.js +1 -0
  101. package/dist/esm/view/LinkUrl/index.js +1 -1
  102. package/dist/types/common/analytics/generated/analytics.types.d.ts +63 -2
  103. package/dist/types/common/analytics/types.d.ts +2 -0
  104. package/dist/types/extractors/action/extract-invoke-copy-link-action.d.ts +3 -0
  105. package/dist/types/extractors/action/extract-invoke-download-action.d.ts +3 -0
  106. package/dist/types/extractors/action/extract-invoke-preview-action.d.ts +11 -0
  107. package/dist/types/extractors/action/extract-invoke-view-action.d.ts +3 -0
  108. package/dist/types/extractors/action/extractDownloadActionProps.d.ts +4 -0
  109. package/dist/types/extractors/action/extractPreviewActionProps.d.ts +5 -1
  110. package/dist/types/extractors/action/extractViewActionProps.d.ts +4 -0
  111. package/dist/types/extractors/action/types.d.ts +9 -0
  112. package/dist/types/extractors/flexible/actions/extract-copy-link-action.d.ts +6 -0
  113. package/dist/types/extractors/flexible/actions/extract-download-action.d.ts +6 -0
  114. package/dist/types/extractors/flexible/actions/extract-preview-action.d.ts +6 -0
  115. package/dist/types/extractors/flexible/actions/extract-view-action.d.ts +3 -0
  116. package/dist/types/extractors/flexible/actions/index.d.ts +21 -4
  117. package/dist/types/extractors/flexible/extract-state.d.ts +5 -2
  118. package/dist/types/extractors/flexible/index.d.ts +1 -1
  119. package/dist/types/state/flexible-ui-context/types.d.ts +9 -3
  120. package/dist/types/state/hooks/use-invoke/types.d.ts +7 -1
  121. package/dist/types/state/hooks/use-invoke-client-action/index.d.ts +2 -2
  122. package/dist/types/state/hooks/use-invoke-client-action/types.d.ts +24 -2
  123. package/dist/types/state/hooks/use-resolve/index.d.ts +1 -0
  124. package/dist/types/view/EmbedModal/index.d.ts +4 -0
  125. package/dist/types/view/EmbedModal/types.d.ts +7 -0
  126. package/dist/types/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.d.ts +1 -1
  127. package/dist/types/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/types.d.ts +6 -0
  128. package/dist/types/view/FlexibleCard/components/utils.d.ts +3 -0
  129. package/dist/types/view/FlexibleCard/index.d.ts +1 -1
  130. package/dist/types/view/FlexibleCard/types.d.ts +12 -3
  131. package/dist/types-ts4.5/common/analytics/generated/analytics.types.d.ts +63 -2
  132. package/dist/types-ts4.5/common/analytics/types.d.ts +2 -0
  133. package/dist/types-ts4.5/extractors/action/extract-invoke-copy-link-action.d.ts +3 -0
  134. package/dist/types-ts4.5/extractors/action/extract-invoke-download-action.d.ts +3 -0
  135. package/dist/types-ts4.5/extractors/action/extract-invoke-preview-action.d.ts +11 -0
  136. package/dist/types-ts4.5/extractors/action/extract-invoke-view-action.d.ts +3 -0
  137. package/dist/types-ts4.5/extractors/action/extractDownloadActionProps.d.ts +4 -0
  138. package/dist/types-ts4.5/extractors/action/extractPreviewActionProps.d.ts +5 -1
  139. package/dist/types-ts4.5/extractors/action/extractViewActionProps.d.ts +4 -0
  140. package/dist/types-ts4.5/extractors/action/types.d.ts +9 -0
  141. package/dist/types-ts4.5/extractors/flexible/actions/extract-copy-link-action.d.ts +6 -0
  142. package/dist/types-ts4.5/extractors/flexible/actions/extract-download-action.d.ts +6 -0
  143. package/dist/types-ts4.5/extractors/flexible/actions/extract-preview-action.d.ts +6 -0
  144. package/dist/types-ts4.5/extractors/flexible/actions/extract-view-action.d.ts +3 -0
  145. package/dist/types-ts4.5/extractors/flexible/actions/index.d.ts +21 -4
  146. package/dist/types-ts4.5/extractors/flexible/extract-state.d.ts +5 -2
  147. package/dist/types-ts4.5/extractors/flexible/index.d.ts +1 -1
  148. package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +9 -3
  149. package/dist/types-ts4.5/state/hooks/use-invoke/types.d.ts +7 -1
  150. package/dist/types-ts4.5/state/hooks/use-invoke-client-action/index.d.ts +2 -2
  151. package/dist/types-ts4.5/state/hooks/use-invoke-client-action/types.d.ts +24 -2
  152. package/dist/types-ts4.5/state/hooks/use-resolve/index.d.ts +1 -0
  153. package/dist/types-ts4.5/view/EmbedModal/index.d.ts +8 -0
  154. package/dist/types-ts4.5/view/EmbedModal/types.d.ts +7 -0
  155. package/dist/types-ts4.5/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/index.d.ts +1 -1
  156. package/dist/types-ts4.5/view/FlexibleCard/components/elements/lozenge/lozenge-action/lozenge-action-error/types.d.ts +6 -0
  157. package/dist/types-ts4.5/view/FlexibleCard/components/utils.d.ts +3 -0
  158. package/dist/types-ts4.5/view/FlexibleCard/index.d.ts +1 -1
  159. package/dist/types-ts4.5/view/FlexibleCard/types.d.ts +12 -3
  160. package/package.json +4 -1
@@ -1,12 +1,16 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
4
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
5
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
6
  var _excluded = ["onClick"];
6
7
  import _regeneratorRuntime from "@babel/runtime/regenerator";
8
+ 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; }
9
+ 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; }
7
10
  import React, { useCallback, useState } from 'react';
8
11
  import { FormattedMessage } from 'react-intl-next';
9
12
  import LinkIcon from '@atlaskit/icon/core/migration/link';
13
+ import { fg } from '@atlaskit/platform-feature-flags';
10
14
  import { ActionName } from '../../../../../constants';
11
15
  import { messages } from '../../../../../messages';
12
16
  import { useFlexibleUiAnalyticsContext, useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
@@ -27,38 +31,67 @@ var CopyLinkAction = function CopyLinkAction(_ref) {
27
31
  tooltipMessage = _useState2[0],
28
32
  setTooltipMessage = _useState2[1];
29
33
  var onClick = useCallback(function () {
30
- if (data && data.url) {
31
- invoke({
32
- actionType: ActionName.CopyLinkAction,
33
- actionFn: function () {
34
- var _actionFn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
35
- var _data$url;
36
- return _regeneratorRuntime.wrap(function _callee$(_context) {
37
- while (1) switch (_context.prev = _context.next) {
38
- case 0:
39
- _context.next = 2;
40
- return navigator.clipboard.writeText((_data$url = data.url) !== null && _data$url !== void 0 ? _data$url : '');
41
- case 2:
42
- setTooltipMessage(messages.copied_url_to_clipboard);
43
- case 3:
44
- case "end":
45
- return _context.stop();
46
- }
47
- }, _callee);
48
- }));
49
- function actionFn() {
50
- return _actionFn.apply(this, arguments);
51
- }
52
- return actionFn;
53
- }(),
54
- // These values have already been set in analytics context.
55
- // We only pass these here for ufo experience.
56
- display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
57
- extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
58
- });
59
- }
60
- if (onClickCallback) {
61
- onClickCallback();
34
+ if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
35
+ if (data !== null && data !== void 0 && data.invokeAction) {
36
+ invoke(_objectSpread(_objectSpread({}, data.invokeAction), {}, {
37
+ actionFn: function () {
38
+ var _actionFn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
39
+ var _data$invokeAction;
40
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
41
+ while (1) switch (_context.prev = _context.next) {
42
+ case 0:
43
+ _context.next = 2;
44
+ return (_data$invokeAction = data.invokeAction) === null || _data$invokeAction === void 0 ? void 0 : _data$invokeAction.actionFn();
45
+ case 2:
46
+ setTooltipMessage(messages.copied_url_to_clipboard);
47
+ case 3:
48
+ case "end":
49
+ return _context.stop();
50
+ }
51
+ }, _callee);
52
+ }));
53
+ function actionFn() {
54
+ return _actionFn.apply(this, arguments);
55
+ }
56
+ return actionFn;
57
+ }()
58
+ }));
59
+ onClickCallback === null || onClickCallback === void 0 || onClickCallback();
60
+ }
61
+ } else {
62
+ if (data && data.url) {
63
+ invoke({
64
+ actionType: ActionName.CopyLinkAction,
65
+ actionFn: function () {
66
+ var _actionFn2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
67
+ var _data$url;
68
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
69
+ while (1) switch (_context2.prev = _context2.next) {
70
+ case 0:
71
+ _context2.next = 2;
72
+ return navigator.clipboard.writeText((_data$url = data.url) !== null && _data$url !== void 0 ? _data$url : '');
73
+ case 2:
74
+ setTooltipMessage(messages.copied_url_to_clipboard);
75
+ case 3:
76
+ case "end":
77
+ return _context2.stop();
78
+ }
79
+ }, _callee2);
80
+ }));
81
+ function actionFn() {
82
+ return _actionFn2.apply(this, arguments);
83
+ }
84
+ return actionFn;
85
+ }(),
86
+ // These values have already been set in analytics context.
87
+ // We only pass these here for ufo experience.
88
+ display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
89
+ extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
90
+ });
91
+ }
92
+ if (onClickCallback) {
93
+ onClickCallback();
94
+ }
62
95
  }
63
96
  }, [analytics, data, invoke, onClickCallback]);
64
97
  return data ? /*#__PURE__*/React.createElement(Action, _extends({
@@ -6,6 +6,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
6
6
  import React, { useCallback } from 'react';
7
7
  import { FormattedMessage } from 'react-intl-next';
8
8
  import DownloadIcon from '@atlaskit/icon/core/migration/download';
9
+ import { fg } from '@atlaskit/platform-feature-flags';
9
10
  import { ActionName } from '../../../../../constants';
10
11
  import { messages } from '../../../../../messages';
11
12
  import { useFlexibleUiAnalyticsContext, useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
@@ -23,36 +24,43 @@ var DownloadAction = function DownloadAction(_ref) {
23
24
  });
24
25
  var data = context === null || context === void 0 || (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[ActionName.DownloadAction];
25
26
  var onClick = useCallback(function () {
26
- if (data !== null && data !== void 0 && data.downloadUrl) {
27
- invoke({
28
- actionType: ActionName.DownloadAction,
29
- actionFn: function () {
30
- var _actionFn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
31
- return _regeneratorRuntime.wrap(function _callee$(_context) {
32
- while (1) switch (_context.prev = _context.next) {
33
- case 0:
34
- return _context.abrupt("return", download(data === null || data === void 0 ? void 0 : data.downloadUrl));
35
- case 1:
36
- case "end":
37
- return _context.stop();
38
- }
39
- }, _callee);
40
- }));
41
- function actionFn() {
42
- return _actionFn.apply(this, arguments);
43
- }
44
- return actionFn;
45
- }(),
46
- // These values have already been set in analytics context.
47
- // We only pass these here for ufo experience.
48
- display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
49
- extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
50
- });
51
- if (onClickCallback) {
52
- onClickCallback();
27
+ if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
28
+ if (data !== null && data !== void 0 && data.invokeAction) {
29
+ invoke(data.invokeAction);
30
+ onClickCallback === null || onClickCallback === void 0 || onClickCallback();
31
+ }
32
+ } else {
33
+ if (data !== null && data !== void 0 && data.downloadUrl) {
34
+ invoke({
35
+ actionType: ActionName.DownloadAction,
36
+ actionFn: function () {
37
+ var _actionFn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
38
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
39
+ while (1) switch (_context.prev = _context.next) {
40
+ case 0:
41
+ return _context.abrupt("return", download(data === null || data === void 0 ? void 0 : data.downloadUrl));
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
+ if (onClickCallback) {
59
+ onClickCallback();
60
+ }
53
61
  }
54
62
  }
55
- }, [analytics, data === null || data === void 0 ? void 0 : data.downloadUrl, invoke, onClickCallback]);
63
+ }, [analytics, data, invoke, onClickCallback]);
56
64
  var isStackItem = props.as === 'stack-item';
57
65
  var label = isStackItem ? messages.download_file : messages.download;
58
66
  var tooltipMessage = isStackItem ? messages.download_description : messages.download;
@@ -9,6 +9,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
9
9
  import React, { useCallback } from 'react';
10
10
  import { FormattedMessage } from 'react-intl-next';
11
11
  import MediaServicesActualSizeIcon from '@atlaskit/icon/core/migration/grow-diagonal--media-services-actual-size';
12
+ import { fg } from '@atlaskit/platform-feature-flags';
12
13
  import { ActionName } from '../../../../../constants';
13
14
  import { messages } from '../../../../../messages';
14
15
  import { useFlexibleUiAnalyticsContext, useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
@@ -26,38 +27,45 @@ var PreviewAction = function PreviewAction(_ref) {
26
27
  });
27
28
  var data = context === null || context === void 0 || (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[ActionName.PreviewAction];
28
29
  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();
30
+ if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
31
+ if (data !== null && data !== void 0 && data.invokeAction) {
32
+ invoke(data.invokeAction);
33
+ onClickCallback === null || onClickCallback === void 0 || onClickCallback();
34
+ }
35
+ } else {
36
+ if (data) {
37
+ invoke({
38
+ actionType: ActionName.PreviewAction,
39
+ actionFn: function () {
40
+ var _actionFn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
41
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
42
+ while (1) switch (_context.prev = _context.next) {
43
+ case 0:
44
+ return _context.abrupt("return", openEmbedModalWithFlexibleUiIcon(_objectSpread({
45
+ download: data === null || data === void 0 ? void 0 : data.downloadUrl,
46
+ extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey,
47
+ analytics: analytics
48
+ }, data)));
49
+ case 1:
50
+ case "end":
51
+ return _context.stop();
52
+ }
53
+ }, _callee);
54
+ }));
55
+ function actionFn() {
56
+ return _actionFn.apply(this, arguments);
57
+ }
58
+ return actionFn;
59
+ }(),
60
+ // These values have already been set in analytics context.
61
+ // We only pass these here for ufo experience.
62
+ display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
63
+ extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
64
+ });
65
+ }
66
+ if (onClickCallback) {
67
+ onClickCallback();
68
+ }
61
69
  }
62
70
  }, [analytics, data, invoke, onClickCallback]);
63
71
  var isStackItem = props.as === 'stack-item';
@@ -17,6 +17,7 @@ import { R50, R500 } from '@atlaskit/theme/colors';
17
17
  import { useAnalyticsEvents } from '../../../../../../../common/analytics/generated/use-analytics-events';
18
18
  import { messages } from '../../../../../../../messages';
19
19
  import { useFlexibleUiAnalyticsContext } from '../../../../../../../state/flexible-ui-context';
20
+ import useInvokeClientAction from '../../../../../../../state/hooks/use-invoke-client-action';
20
21
  import useResolve from '../../../../../../../state/hooks/use-resolve';
21
22
  import { getFormattedMessage, openEmbedModalWithFlexibleUiIcon } from '../../../../utils';
22
23
  import { contentStyles, dropdownItemGroupStyles, linkStyles, textStyles } from './styled';
@@ -26,13 +27,15 @@ var LozengeActionError = function LozengeActionError(_ref) {
26
27
  testId = _ref.testId,
27
28
  _ref$maxLineNumber = _ref.maxLineNumber,
28
29
  maxLineNumber = _ref$maxLineNumber === void 0 ? MAX_LINE_NUMBER : _ref$maxLineNumber,
30
+ invokePreviewAction = _ref.invokePreviewAction,
29
31
  url = _ref.url,
30
32
  previewData = _ref.previewData;
31
33
  var _useAnalyticsEvents = useAnalyticsEvents(),
32
34
  fireEvent = _useAnalyticsEvents.fireEvent;
33
35
  var reload = useResolve();
34
36
  var analytics = useFlexibleUiAnalyticsContext();
35
- var isPreviewAvailable = previewData && previewData.src !== undefined;
37
+ var invoke = useInvokeClientAction({});
38
+ var isPreviewAvailable = fg('platform-smart-card-migrate-embed-modal-analytics') ? invokePreviewAction !== undefined : previewData && previewData.src !== undefined;
36
39
  var handlePreviewClose = useCallback(function () {
37
40
  if (url) {
38
41
  reload(url, true);
@@ -45,12 +48,16 @@ var LozengeActionError = function LozengeActionError(_ref) {
45
48
  } else {
46
49
  analytics === null || analytics === void 0 || analytics.ui.smartLinkLozengeActionErrorOpenPreviewClickedEvent();
47
50
  }
48
- return openEmbedModalWithFlexibleUiIcon(_objectSpread(_objectSpread({}, previewData), {}, {
49
- analytics: analytics,
50
- onClose: handlePreviewClose
51
- }));
51
+ if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
52
+ invokePreviewAction && invoke(invokePreviewAction);
53
+ } else {
54
+ return openEmbedModalWithFlexibleUiIcon(_objectSpread(_objectSpread({}, previewData), {}, {
55
+ analytics: analytics,
56
+ onClose: handlePreviewClose
57
+ }));
58
+ }
52
59
  }
53
- }, [analytics, handlePreviewClose, isPreviewAvailable, previewData, fireEvent]);
60
+ }, [analytics, handlePreviewClose, isPreviewAvailable, invoke, invokePreviewAction, previewData, fireEvent]);
54
61
  var content = useMemo(function () {
55
62
  return jsx(Fragment, null, jsx("div", {
56
63
  css: contentStyles
@@ -197,6 +197,10 @@ export var getTruncateStyles = function getTruncateStyles(maxLines) {
197
197
  export var hasWhiteSpace = function hasWhiteSpace(str) {
198
198
  return str.search(/\s/) >= 0;
199
199
  };
200
+
201
+ /**
202
+ * TODO: Remove on cleanup of platform-smart-card-migrate-embed-modal-analytics
203
+ */
200
204
  export var openEmbedModalWithFlexibleUiIcon = function openEmbedModalWithFlexibleUiIcon(_ref) {
201
205
  var linkIcon = _ref.linkIcon,
202
206
  props = _objectWithoutProperties(_ref, _excluded);
@@ -3,9 +3,11 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  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; }
4
4
  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; }
5
5
  import React, { useEffect, useMemo } from 'react';
6
+ import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
6
7
  import { SmartLinkStatus } from '../../constants';
7
8
  import { FlexibleUiAnalyticsContext, FlexibleUiContext, FlexibleUiOptionContext } from '../../state/flexible-ui-context';
8
9
  import { useAISummaryConfig } from '../../state/hooks/use-ai-summary-config';
10
+ import useResolve from '../../state/hooks/use-resolve';
9
11
  import Container from './components/container';
10
12
  import { getContextByStatus, getRetryOptions } from './utils';
11
13
 
@@ -27,6 +29,7 @@ var FlexibleCard = function FlexibleCard(_ref) {
27
29
  onClick = _ref.onClick,
28
30
  onError = _ref.onError,
29
31
  onResolve = _ref.onResolve,
32
+ origin = _ref.origin,
30
33
  renderers = _ref.renderers,
31
34
  showAuthTooltip = _ref.showAuthTooltip,
32
35
  showHoverPreview = _ref.showHoverPreview,
@@ -36,20 +39,27 @@ var FlexibleCard = function FlexibleCard(_ref) {
36
39
  ui = _ref.ui,
37
40
  url = _ref.url;
38
41
  var aiSummaryConfig = useAISummaryConfig();
42
+ var resolve = useResolve();
43
+ var _useAnalyticsEvents = useAnalyticsEvents(),
44
+ fireEvent = _useAnalyticsEvents.fireEvent;
39
45
  var cardType = cardState.status,
40
46
  details = cardState.details;
41
47
  var status = cardType;
42
48
  var context = useMemo(function () {
43
49
  return getContextByStatus({
44
50
  aiSummaryConfig: aiSummaryConfig,
51
+ appearance: appearance,
52
+ fireEvent: fireEvent,
45
53
  response: details,
46
54
  id: id,
55
+ origin: origin,
47
56
  renderers: renderers,
57
+ resolve: resolve,
48
58
  actionOptions: actionOptions,
49
59
  status: status,
50
60
  url: url
51
61
  });
52
- }, [aiSummaryConfig, details, id, renderers, actionOptions, status, url]);
62
+ }, [aiSummaryConfig, appearance, details, fireEvent, id, origin, renderers, actionOptions, resolve, status, url]);
53
63
  var retry = getRetryOptions(url, status, details, onAuthorize);
54
64
  var _ref2 = context || {},
55
65
  title = _ref2.title;
@@ -153,6 +153,7 @@ var HoverCardContent = function HoverCardContent(_ref) {
153
153
  cardState: cardState,
154
154
  onClick: onClick,
155
155
  onResolve: onResolve,
156
+ origin: 'smartLinkPreviewHoverCard',
156
157
  renderers: renderers,
157
158
  actionOptions: actionOptions,
158
159
  ui: flexibleUiOptions,
@@ -13,7 +13,7 @@ import LinkWarningModal from './LinkWarningModal';
13
13
  import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
14
14
  var PACKAGE_DATA = {
15
15
  packageName: "@atlaskit/smart-card",
16
- packageVersion: "32.7.0",
16
+ packageVersion: "32.7.1",
17
17
  componentName: 'linkUrl'
18
18
  };
19
19
  var Anchor = withLinkClickedEvent('a');
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Generates Typescript types for analytics events from analytics.spec.yaml
5
5
  *
6
- * @codegen <<SignedSource::050cd99cdd30e3c38674dc47986e3214>>
6
+ * @codegen <<SignedSource::f06f113d9e5f9e84ba897b1fbfca3db4>>
7
7
  * @codegenCommand yarn workspace @atlassian/analytics-tooling run analytics:codegen smart-card
8
8
  */
9
9
  export type PackageMetaDataContextType = {
@@ -12,7 +12,6 @@ export type PackageMetaDataContextType = {
12
12
  };
13
13
  export type CommonContextType = {
14
14
  extensionKey: string | null;
15
- resourceType: string | null;
16
15
  destinationObjectType: string | null;
17
16
  destinationSubproduct: string | null;
18
17
  destinationProduct: string | null;
@@ -33,6 +32,33 @@ export type ResolvedContextType = {
33
32
  destinationTenantId: string | null;
34
33
  canBeDatasource: boolean | null;
35
34
  location: string | null;
35
+ };
36
+ export type ButtonClickedCopyLinkAttributesType = {
37
+ actionType: string | null;
38
+ id: string | null;
39
+ definitionId: string | null;
40
+ display: 'inline' | 'block' | 'embed' | 'embedPreview' | 'flexible' | 'hoverCardPreview' | null;
41
+ resourceType: string | null;
42
+ };
43
+ export type ButtonClickedDownloadDocumentAttributesType = {
44
+ actionType: string | null;
45
+ id: string | null;
46
+ definitionId: string | null;
47
+ display: 'inline' | 'block' | 'embed' | 'embedPreview' | 'flexible' | 'hoverCardPreview' | null;
48
+ resourceType: string | null;
49
+ };
50
+ export type ButtonClickedInvokePreviewScreenAttributesType = {
51
+ actionType: string | null;
52
+ id: string | null;
53
+ definitionId: string | null;
54
+ display: 'inline' | 'block' | 'embed' | 'embedPreview' | 'flexible' | 'hoverCardPreview' | null;
55
+ resourceType: string | null;
56
+ };
57
+ export type ButtonClickedShortcutGoToLinkAttributesType = {
58
+ actionType: string | null;
59
+ id: string | null;
60
+ definitionId: string | null;
61
+ display: 'inline' | 'block' | 'embed' | 'embedPreview' | 'flexible' | 'hoverCardPreview' | null;
36
62
  resourceType: string | null;
37
63
  };
38
64
  export type ButtonClickedAiSummaryAttributesType = {};
@@ -115,6 +141,23 @@ export type SmartLinkChunkLoadFailedAttributesType = {
115
141
  error: Record<string, unknown>;
116
142
  errorInfo: Record<string, unknown>;
117
143
  };
144
+ export type SmartLinkActionResolvedAttributesType = {
145
+ actionType: string | null;
146
+ id: string | null;
147
+ definitionId: string | null;
148
+ display: 'inline' | 'block' | 'embed' | 'embedPreview' | 'flexible' | 'hoverCardPreview' | null;
149
+ resourceType: string | null;
150
+ duration: number | null;
151
+ };
152
+ export type SmartLinkActionUnresolvedAttributesType = {
153
+ actionType: string | null;
154
+ id: string | null;
155
+ definitionId: string | null;
156
+ display: 'inline' | 'block' | 'embed' | 'embedPreview' | 'flexible' | 'hoverCardPreview' | null;
157
+ resourceType: string | null;
158
+ duration: number | null;
159
+ reason: string | null;
160
+ };
118
161
  export type SmartLinkClickedAttributesType = {
119
162
  id: string;
120
163
  display: 'inline' | 'block' | 'embed' | 'embedPreview' | 'flexible' | 'hoverCardPreview';
@@ -158,6 +201,18 @@ export type ButtonClickedSmartLinkFollowButtonAttributesType = {};
158
201
  export type ButtonClickedStatusUpdateActionAttributesType = {};
159
202
  export type ButtonClickedGetStatusTransitionsActionAttributesType = {};
160
203
  export type AnalyticsEventAttributes = {
204
+ /**
205
+ * Fired when an copy link is clicked */
206
+ 'ui.button.clicked.copyLink': ButtonClickedCopyLinkAttributesType;
207
+ /**
208
+ * Fired when an download is clicked */
209
+ 'ui.button.clicked.downloadDocument': ButtonClickedDownloadDocumentAttributesType;
210
+ /**
211
+ * Fired when an preview is clicked */
212
+ 'ui.button.clicked.invokePreviewScreen': ButtonClickedInvokePreviewScreenAttributesType;
213
+ /**
214
+ * Fired when an view link is clicked */
215
+ 'ui.button.clicked.shortcutGoToLink': ButtonClickedShortcutGoToLinkAttributesType;
161
216
  /**
162
217
  * fired when an ai summary is clicked */
163
218
  'ui.button.clicked.aiSummary': ButtonClickedAiSummaryAttributesType;
@@ -236,6 +291,12 @@ export type AnalyticsEventAttributes = {
236
291
  /**
237
292
  * fires an event that represents when a Smart Link renders unsuccessfully. */
238
293
  'operational.smartLink.chunkLoadFailed': SmartLinkChunkLoadFailedAttributesType;
294
+ /**
295
+ * Fires an event when a Smart Link action is successfully resolved. */
296
+ 'operational.smartLinkAction.resolved': SmartLinkActionResolvedAttributesType;
297
+ /**
298
+ * Fires an event when a Smart Link action is failed to resolved. */
299
+ 'operational.smartLinkAction.unresolved': SmartLinkActionUnresolvedAttributesType;
239
300
  /**
240
301
  * fires an event that represents when a user clicks on a Smart Link. */
241
302
  'ui.smartLink.clicked': SmartLinkClickedAttributesType;
@@ -0,0 +1,2 @@
1
+ import { type useAnalyticsEvents } from './generated/use-analytics-events';
2
+ export type FireEventFunction = ReturnType<typeof useAnalyticsEvents>['fireEvent'];
@@ -0,0 +1,3 @@
1
+ import { type InvokeClientActionProps } from '../../state/hooks/use-invoke-client-action/types';
2
+ import { type ExtractClientActionsParam } from './types';
3
+ export declare const extractInvokeCopyLinkAction: ({ actionOptions, appearance, id, response, }: ExtractClientActionsParam) => InvokeClientActionProps | undefined;
@@ -0,0 +1,3 @@
1
+ import { type InvokeClientActionProps } from '../../state/hooks/use-invoke-client-action/types';
2
+ import { type ExtractClientActionsParam } from './types';
3
+ export declare const extractInvokeDownloadAction: ({ actionOptions, appearance, id, response, }: ExtractClientActionsParam) => InvokeClientActionProps | undefined;
@@ -0,0 +1,11 @@
1
+ import { type FireEventFunction } from '../../common/analytics/types';
2
+ import { type InvokeClientActionProps } from '../../state/hooks/use-invoke-client-action/types';
3
+ import { type AnalyticsOrigin } from '../../utils/types';
4
+ import { type EmbedModalProps } from '../../view/EmbedModal/types';
5
+ import { type ExtractClientActionsParam } from './types';
6
+ export type ExtractInvokePreviewActionParam = ExtractClientActionsParam & {
7
+ fireEvent?: FireEventFunction;
8
+ onClose?: EmbedModalProps['onClose'];
9
+ origin?: AnalyticsOrigin;
10
+ };
11
+ export declare const extractInvokePreviewAction: (param: ExtractInvokePreviewActionParam) => InvokeClientActionProps | undefined;
@@ -0,0 +1,3 @@
1
+ import { type InvokeClientActionProps } from '../../state/hooks/use-invoke-client-action/types';
2
+ import { type ExtractClientActionsParam } from './types';
3
+ export declare const extractInvokeViewAction: ({ actionOptions, appearance, id, response }: ExtractClientActionsParam, force?: boolean) => InvokeClientActionProps | undefined;
@@ -1,3 +1,7 @@
1
1
  import { type InvokeClientActionProps } from '../../state/hooks/use-invoke-client-action/types';
2
2
  import { type ExtractActionsProps } from '../common/actions/types';
3
+ /**
4
+ * TODO: Remove on cleanup of platform-smart-card-migrate-embed-modal-analytics
5
+ * Replace with platform/packages/linking-platform/smart-card/src/extractors/action/extract-invoke-download-action.ts
6
+ */
3
7
  export declare const extractDownloadActionProps: ({ response, actionOptions, extensionKey, source, }: ExtractActionsProps) => InvokeClientActionProps | undefined;
@@ -1,3 +1,7 @@
1
1
  import { type InvokeClientActionProps } from '../../state/hooks/use-invoke-client-action/types';
2
- import type { ExtractActionsProps } from '../common/actions/types';
2
+ import { type ExtractActionsProps } from '../common/actions/types';
3
+ /**
4
+ * TODO: Remove on cleanup of platform-smart-card-migrate-embed-modal-analytics
5
+ * Replaced with platform/packages/linking-platform/smart-card/src/extractors/action/extract-invoke-preview-action.ts
6
+ */
3
7
  export declare const extractPreviewActionProps: ({ response, analytics, extensionKey, source, actionOptions, origin, }: ExtractActionsProps) => InvokeClientActionProps | undefined;
@@ -1,3 +1,7 @@
1
1
  import { type InvokeClientActionProps } from '../../state/hooks/use-invoke-client-action/types';
2
2
  import { type ExtractActionsProps } from '../common/actions/types';
3
+ /**
4
+ * TODO: Remove on cleanup of platform-smart-card-migrate-embed-modal-analytics
5
+ * Replace with platform/packages/linking-platform/smart-card/src/extractors/action/extract-invoke-view-action.ts
6
+ */
3
7
  export declare const extractViewActionProps: ({ response, actionOptions, extensionKey, source, }: ExtractActionsProps) => InvokeClientActionProps | undefined;
@@ -0,0 +1,9 @@
1
+ import type { JsonLd } from 'json-ld-types';
2
+ import type { CardActionOptions } from '../../view/Card/types';
3
+ import type { FlexibleCardProps } from '../../view/FlexibleCard/types';
4
+ export type ExtractClientActionsParam = {
5
+ actionOptions?: CardActionOptions;
6
+ appearance?: FlexibleCardProps['appearance'];
7
+ id?: string;
8
+ response: JsonLd.Response;
9
+ };
@@ -1,4 +1,10 @@
1
1
  import { type JsonLd } from 'json-ld-types';
2
2
  import { type CopyLinkActionData } from '../../../state/flexible-ui-context/types';
3
3
  import { type CardActionOptions } from '../../../view/Card/types';
4
+ import { type ExtractClientActionsParam } from '../../action/types';
5
+ /**
6
+ * TODO: Remove on cleanup of platform-smart-card-migrate-embed-modal-analytics
7
+ * Replaced with extractCopyLinkClientAction()
8
+ */
4
9
  export declare const extractCopyLinkAction: (data: JsonLd.Data.BaseData, actionOptions?: CardActionOptions) => CopyLinkActionData | undefined;
10
+ export declare const extractCopyLinkClientAction: (param: ExtractClientActionsParam) => CopyLinkActionData | undefined;
@@ -1,4 +1,10 @@
1
1
  import { type JsonLd } from 'json-ld-types';
2
2
  import { type DownloadActionData } from '../../../state/flexible-ui-context/types';
3
3
  import { type CardActionOptions } from '../../../view/Card/types';
4
+ import { type ExtractClientActionsParam } from '../../action/types';
5
+ /**
6
+ * TODO: Remove on cleanup of platform-smart-card-migrate-embed-modal-analytics
7
+ * Replaced with extractDownloadClientAction()
8
+ */
4
9
  export declare const extractDownloadAction: (data: JsonLd.Data.BaseData, actionOptions?: CardActionOptions) => DownloadActionData | undefined;
10
+ export declare const extractDownloadClientAction: (param: ExtractClientActionsParam) => DownloadActionData | undefined;
@@ -1,4 +1,10 @@
1
1
  import { type JsonLd } from 'json-ld-types';
2
2
  import { type PreviewActionData } from '../../../state/flexible-ui-context/types';
3
3
  import { type CardActionOptions } from '../../../view/Card/types';
4
+ import { type ExtractInvokePreviewActionParam } from '../../action/extract-invoke-preview-action';
5
+ /**
6
+ * TODO: Remove on cleanup of platform-smart-card-migrate-embed-modal-analytics
7
+ * Replaced with extractPreviewClientAction()
8
+ */
4
9
  export declare const extractPreviewAction: (response: JsonLd.Response, actionOptions?: CardActionOptions) => PreviewActionData | undefined;
10
+ export declare const extractPreviewClientAction: (param: ExtractInvokePreviewActionParam) => PreviewActionData | undefined;