@atlaskit/smart-card 26.50.13 → 26.50.15

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 (78) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/extractors/flexible/actions/index.js +17 -0
  3. package/dist/cjs/extractors/flexible/index.js +4 -3
  4. package/dist/cjs/state/flexible-ui-context/types.js +1 -3
  5. package/dist/cjs/state/hooks/use-ai-summary/ai-summary-service/index.js +6 -3
  6. package/dist/cjs/state/hooks/use-ai-summary/index.js +4 -2
  7. package/dist/cjs/utils/analytics/analytics.js +1 -1
  8. package/dist/cjs/view/FlexibleCard/components/actions/index.js +8 -12
  9. package/dist/cjs/view/FlexibleCard/components/actions/preview-action/index.js +83 -0
  10. package/dist/cjs/view/FlexibleCard/components/actions/types.js +5 -0
  11. package/dist/cjs/view/FlexibleCard/components/actions/utils.js +0 -13
  12. package/dist/cjs/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +8 -6
  13. package/dist/cjs/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +3 -1
  14. package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +45 -11
  15. package/dist/cjs/view/HoverCard/components/ContentContainer.js +6 -3
  16. package/dist/cjs/view/HoverCard/components/views/resolved/index.js +7 -3
  17. package/dist/cjs/view/LinkUrl/index.js +1 -1
  18. package/dist/es2019/extractors/flexible/actions/index.js +9 -0
  19. package/dist/es2019/extractors/flexible/index.js +5 -4
  20. package/dist/es2019/state/flexible-ui-context/types.js +6 -1
  21. package/dist/es2019/state/hooks/use-ai-summary/ai-summary-service/index.js +6 -3
  22. package/dist/es2019/state/hooks/use-ai-summary/index.js +4 -2
  23. package/dist/es2019/utils/analytics/analytics.js +1 -1
  24. package/dist/es2019/view/FlexibleCard/components/actions/index.js +1 -11
  25. package/dist/es2019/view/FlexibleCard/components/actions/preview-action/index.js +52 -0
  26. package/dist/es2019/view/FlexibleCard/components/actions/utils.js +0 -14
  27. package/dist/es2019/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +8 -6
  28. package/dist/es2019/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +3 -1
  29. package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +42 -33
  30. package/dist/es2019/view/HoverCard/components/ContentContainer.js +7 -4
  31. package/dist/es2019/view/HoverCard/components/views/resolved/index.js +8 -4
  32. package/dist/es2019/view/LinkUrl/index.js +1 -1
  33. package/dist/esm/extractors/flexible/actions/index.js +10 -0
  34. package/dist/esm/extractors/flexible/index.js +5 -4
  35. package/dist/esm/state/flexible-ui-context/types.js +6 -1
  36. package/dist/esm/state/hooks/use-ai-summary/ai-summary-service/index.js +6 -3
  37. package/dist/esm/state/hooks/use-ai-summary/index.js +4 -2
  38. package/dist/esm/utils/analytics/analytics.js +1 -1
  39. package/dist/esm/view/FlexibleCard/components/actions/index.js +1 -11
  40. package/dist/esm/view/FlexibleCard/components/actions/preview-action/index.js +73 -0
  41. package/dist/esm/view/FlexibleCard/components/actions/preview-action/types.js +1 -0
  42. package/dist/esm/view/FlexibleCard/components/actions/types.js +1 -0
  43. package/dist/esm/view/FlexibleCard/components/actions/utils.js +0 -13
  44. package/dist/esm/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +8 -6
  45. package/dist/esm/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +3 -1
  46. package/dist/esm/view/FlexibleCard/components/blocks/utils.js +45 -11
  47. package/dist/esm/view/HoverCard/components/ContentContainer.js +7 -4
  48. package/dist/esm/view/HoverCard/components/views/resolved/index.js +8 -4
  49. package/dist/esm/view/LinkUrl/index.js +1 -1
  50. package/dist/types/extractors/flexible/actions/index.d.ts +5 -0
  51. package/dist/types/state/flexible-ui-context/types.d.ts +14 -7
  52. package/dist/types/state/hooks/use-ai-summary/ai-summary-service/index.d.ts +1 -0
  53. package/dist/types/state/hooks/use-ai-summary/ai-summary-service/types.d.ts +7 -3
  54. package/dist/types/view/FlexibleCard/components/actions/index.d.ts +1 -7
  55. package/dist/types/view/FlexibleCard/components/actions/preview-action/index.d.ts +4 -0
  56. package/dist/types/view/FlexibleCard/components/actions/preview-action/types.d.ts +2 -0
  57. package/dist/types/view/FlexibleCard/components/actions/types.d.ts +7 -0
  58. package/dist/types/view/FlexibleCard/types.d.ts +20 -2
  59. package/dist/types-ts4.5/extractors/flexible/actions/index.d.ts +5 -0
  60. package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +14 -7
  61. package/dist/types-ts4.5/state/hooks/use-ai-summary/ai-summary-service/index.d.ts +1 -0
  62. package/dist/types-ts4.5/state/hooks/use-ai-summary/ai-summary-service/types.d.ts +7 -3
  63. package/dist/types-ts4.5/view/FlexibleCard/components/actions/index.d.ts +1 -7
  64. package/dist/types-ts4.5/view/FlexibleCard/components/actions/preview-action/index.d.ts +4 -0
  65. package/dist/types-ts4.5/view/FlexibleCard/components/actions/preview-action/types.d.ts +2 -0
  66. package/dist/types-ts4.5/view/FlexibleCard/components/actions/types.d.ts +7 -0
  67. package/dist/types-ts4.5/view/FlexibleCard/types.d.ts +20 -2
  68. package/package.json +3 -3
  69. package/dist/cjs/view/FlexibleCard/components/actions/action/preview-action/index.js +0 -87
  70. package/dist/es2019/view/FlexibleCard/components/actions/action/preview-action/index.js +0 -63
  71. package/dist/esm/view/FlexibleCard/components/actions/action/preview-action/index.js +0 -80
  72. package/dist/types/view/FlexibleCard/components/actions/action/preview-action/index.d.ts +0 -4
  73. package/dist/types/view/FlexibleCard/components/actions/action/preview-action/types.d.ts +0 -12
  74. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/preview-action/index.d.ts +0 -4
  75. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/preview-action/types.d.ts +0 -12
  76. /package/dist/cjs/view/FlexibleCard/components/actions/{action/preview-action → preview-action}/types.js +0 -0
  77. /package/dist/es2019/view/FlexibleCard/components/actions/{action/preview-action → preview-action}/types.js +0 -0
  78. /package/dist/{esm/view/FlexibleCard/components/actions/action/preview-action → es2019/view/FlexibleCard/components/actions}/types.js +0 -0
@@ -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;
@@ -32,8 +32,10 @@ var AISummaryBlockResolvedView = function AISummaryBlockResolvedView(props) {
32
32
  fireEvent = _useAnalyticsEvents.fireEvent;
33
33
  var context = useFlexibleUiContext();
34
34
  var url = (context === null || context === void 0 ? void 0 : context.url) || '';
35
+ var ari = (context === null || context === void 0 ? void 0 : context.ari) || '';
35
36
  var _useAISummary = useAISummary({
36
- url: url
37
+ url: url,
38
+ ari: ari
37
39
  }),
38
40
  summariseUrl = _useAISummary.summariseUrl,
39
41
  _useAISummary$state = _useAISummary.state,
@@ -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
  };
@@ -12,9 +12,9 @@ import AIPrism from '../../common/ai-prism';
12
12
  import { hoverCardClassName } from './HoverCardContent';
13
13
  import { useAISummary } from '../../../state/hooks/use-ai-summary';
14
14
  import { useSmartCardState } from '../../../state/store';
15
- import { extractLink } from '@atlaskit/link-extractors';
15
+ import { extractAri, extractLink } from '@atlaskit/link-extractors';
16
16
  var ConnectedAIPrismContainer = function ConnectedAIPrismContainer(_ref) {
17
- var _extractLink, _cardState$details;
17
+ var _cardState$details, _extractLink, _extractAri;
18
18
  var children = _ref.children,
19
19
  _ref$isAIEnabled = _ref.isAIEnabled,
20
20
  isAIEnabled = _ref$isAIEnabled === void 0 ? false : _ref$isAIEnabled,
@@ -22,9 +22,12 @@ var ConnectedAIPrismContainer = function ConnectedAIPrismContainer(_ref) {
22
22
  url = _ref.url,
23
23
  props = _objectWithoutProperties(_ref, _excluded);
24
24
  var cardState = useSmartCardState(url);
25
- var dataUrl = (_extractLink = extractLink(cardState === null || cardState === void 0 || (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data)) !== null && _extractLink !== void 0 ? _extractLink : '';
25
+ var data = cardState === null || cardState === void 0 || (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
26
+ var dataUrl = (_extractLink = extractLink(data)) !== null && _extractLink !== void 0 ? _extractLink : '';
27
+ var dataAri = (_extractAri = extractAri(data)) !== null && _extractAri !== void 0 ? _extractAri : '';
26
28
  var _useAISummary = useAISummary({
27
- url: dataUrl
29
+ url: dataUrl,
30
+ ari: dataAri
28
31
  }),
29
32
  status = _useAISummary.state.status;
30
33
  var _useState = useState(status === 'loading'),
@@ -13,7 +13,7 @@ import { FormattedMessage } from 'react-intl-next';
13
13
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
14
14
  import { getCanBeDatasource } from '../../../../../state/helpers';
15
15
  import { useAISummary } from '../../../../../state/hooks/use-ai-summary';
16
- import { extractLink } from '@atlaskit/link-extractors';
16
+ import { extractAri, extractLink } from '@atlaskit/link-extractors';
17
17
  import { SmartLinkStatus } from '../../../../../constants';
18
18
  export var toFooterActions = function toFooterActions(cardActions, onActionClick) {
19
19
  var followAction = {
@@ -54,9 +54,11 @@ export var toFooterActions = function toFooterActions(cardActions, onActionClick
54
54
  var ConnectedAIBlock = function ConnectedAIBlock(_ref) {
55
55
  var bottomPrimary = _ref.bottomPrimary,
56
56
  imagePreview = _ref.imagePreview,
57
- url = _ref.url;
57
+ url = _ref.url,
58
+ ari = _ref.ari;
58
59
  var _useAISummary = useAISummary({
59
- url: url
60
+ url: url,
61
+ ari: ari
60
62
  }),
61
63
  _useAISummary$state = _useAISummary.state,
62
64
  status = _useAISummary$state.status,
@@ -76,7 +78,7 @@ var ConnectedAIBlock = function ConnectedAIBlock(_ref) {
76
78
  })) : null;
77
79
  };
78
80
  var HoverCardResolvedView = function HoverCardResolvedView(_ref2) {
79
- var _cardState$details, _extractLink;
81
+ var _cardState$details, _extractLink, _extractAri;
80
82
  var flexibleCardProps = _ref2.flexibleCardProps,
81
83
  titleBlockProps = _ref2.titleBlockProps,
82
84
  analytics = _ref2.analytics,
@@ -102,6 +104,7 @@ var HoverCardResolvedView = function HoverCardResolvedView(_ref2) {
102
104
  }, [cardActions, onActionClick]);
103
105
  var data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
104
106
  var dataUrl = (_extractLink = extractLink(data)) !== null && _extractLink !== void 0 ? _extractLink : '';
107
+ var dataAri = (_extractAri = extractAri(data)) !== null && _extractAri !== void 0 ? _extractAri : '';
105
108
  var _useMemo = useMemo(function () {
106
109
  var betterMetadata = getSimulatedBetterMetadata(extensionKey, data);
107
110
  return {
@@ -151,6 +154,7 @@ var HoverCardResolvedView = function HoverCardResolvedView(_ref2) {
151
154
  }, /*#__PURE__*/React.createElement(ConnectedAIBlock, {
152
155
  imagePreview: !!imagePreview,
153
156
  url: dataUrl,
157
+ ari: dataAri,
154
158
  bottomPrimary: bottomPrimary
155
159
  })), !isAISummaryEnabled && !imagePreview && /*#__PURE__*/React.createElement(SnippetBlock, {
156
160
  status: SmartLinkStatus.Resolved
@@ -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.13",
13
+ packageVersion: "26.50.15",
14
14
  componentName: 'linkUrl'
15
15
  };
16
16
  var Link = withLinkClickedEvent('a');
@@ -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;
@@ -1,6 +1,6 @@
1
1
  import { LinkLozenge } from '../../extractors/common/lozenge/types';
2
2
  import { LinkPerson } from '@atlaskit/link-extractors';
3
- import { IconType, MediaType } from '../../constants';
3
+ import { ActionName, IconType, MediaType } from '../../constants';
4
4
  import { InvokeRequestWithCardDetails } from '../hooks/use-invoke/types';
5
5
  import type { CardInnerAppearance } from '../../view/Card/types';
6
6
  import type { AnalyticsFacade } from '../analytics';
@@ -9,6 +9,10 @@ import type { AnalyticsFacade } from '../analytics';
9
9
  * underlying elements.
10
10
  */
11
11
  export type FlexibleUiDataContext = {
12
+ /**
13
+ * An object containing available action on the linked resource.
14
+ */
15
+ actions?: FlexibleUiActions;
12
16
  /**
13
17
  * An array containing data used to populate the AssignedToGroup element.
14
18
  * @see AvatarGroup
@@ -102,12 +106,6 @@ export type FlexibleUiDataContext = {
102
106
  * @see CreatedOn
103
107
  */
104
108
  createdOn?: string;
105
- /**
106
- * Contains data needed to show a preview action.
107
- * @type PreviewActionData
108
- * @see PreviewAction
109
- */
110
- previewAction?: PreviewActionData;
111
109
  /**
112
110
  * Contains data needed to show a view action.
113
111
  * @type ViewActionData
@@ -228,6 +226,12 @@ export type FlexibleUiDataContext = {
228
226
  * @see Title
229
227
  */
230
228
  url?: string;
229
+ /**
230
+ * Contains the atlassian resource identifier (ARI) of the linked resource.
231
+ * @type string
232
+ * @see Title
233
+ */
234
+ ari?: string;
231
235
  /**
232
236
  * Contains the name and url of the location that the resource is located in.
233
237
  * @type LinkLocation
@@ -248,6 +252,9 @@ export type Media = {
248
252
  type: MediaType;
249
253
  url: string;
250
254
  };
255
+ export type FlexibleUiActions = {
256
+ [ActionName.PreviewAction]?: PreviewActionData;
257
+ };
251
258
  export type PreviewActionData = {
252
259
  downloadUrl?: string;
253
260
  linkIcon?: Icon;
@@ -3,6 +3,7 @@ export declare class AISummaryService implements AISummaryServiceInt {
3
3
  state: AISummaryState;
4
4
  private config;
5
5
  private url;
6
+ private ari?;
6
7
  private subscribedStateSetters;
7
8
  private onStart?;
8
9
  private onSuccess?;
@@ -12,6 +12,7 @@ export type AISummaryServiceProps = {
12
12
  onSuccess?: (id: string) => void;
13
13
  product?: ProductType;
14
14
  url: string;
15
+ ari: string;
15
16
  };
16
17
  export type AISummaryServiceConfig = {
17
18
  baseUrl: string;
@@ -21,14 +22,17 @@ export type AISummaryStatus = 'ready' | 'loading' | 'error' | 'done';
21
22
  export type ProductType = 'confluence' | 'atlas' | 'jpd' | 'jsm' | 'jsw' | 'jwm' | 'bitbucket' | 'trello';
22
23
  export type PostAgentPayload = {
23
24
  recipient_agent_named_id: string;
24
- agent_input: AgentInput;
25
+ agent_input_context: AgentInputContext;
25
26
  user_intent?: string;
26
27
  };
27
- export type AgentInput = {
28
- urls: Array<string>;
28
+ export type AgentInputContext = {
29
+ content_url: string;
30
+ content_ari?: string;
29
31
  summary_style?: SummaryStyle;
32
+ summary_output_mimetype?: SummaryOutputMimeType;
30
33
  };
31
34
  export type SummaryStyle = 'short' | 'medium' | 'long';
35
+ export type SummaryOutputMimeType = 'text/adf' | 'text/markdown' | 'text/json';
32
36
  export declare const errorMessages: readonly ["NETWORK_ERROR", "NO_ANSWER", "RATE_LIMIT", "NO_AGENT", "PLUGIN_ERRORED", "OPENAI_RATE_LIMIT_USER_ABUSE", "ACCEPTABLE_USE_VIOLATIONS", "AI_DISABLED", "UNEXPECTED"];
33
37
  export type ErrorMessage = (typeof errorMessages)[number];
34
38
  export type AISummaryState = {
@@ -1,9 +1,9 @@
1
1
  /// <reference types="react" />
2
2
  import { ActionProps } from './action/types';
3
- import { PreviewActionProps } from './action/preview-action/types';
4
3
  import { ViewActionProps } from './action/view-action/types';
5
4
  import { DownloadActionProps } from './action/download-action/types';
6
5
  export { default as FollowAction } from './follow-action';
6
+ export { default as PreviewAction } from './preview-action';
7
7
  /**
8
8
  * Creates a DeleteAction component. Accepts default ActionProps, but defaults
9
9
  * the icon to a cross icon.
@@ -16,12 +16,6 @@ export declare const DeleteAction: import("react").FC<ActionProps>;
16
16
  * @see Action
17
17
  */
18
18
  export declare const EditAction: import("react").FC<ActionProps>;
19
- /**
20
- * Creates a PreviewAction component. Accepts default PreviewActionProps, and defaults
21
- * to the text 'Preview' inside the button.
22
- * @see Action
23
- */
24
- export declare const PreviewAction: import("react").FC<PreviewActionProps>;
25
19
  /**
26
20
  * Creates a ViewAction component. Accepts default ViewActionProps, and defaults
27
21
  * to the text 'View' inside the button.
@@ -0,0 +1,4 @@
1
+ import { type FC } from 'react';
2
+ import type { PreviewActionProps } from './types';
3
+ declare const PreviewAction: FC<PreviewActionProps>;
4
+ export default PreviewAction;
@@ -0,0 +1,2 @@
1
+ import { LinkActionProps } from '../types';
2
+ export type PreviewActionProps = LinkActionProps;
@@ -0,0 +1,7 @@
1
+ import type { Optional } from '../../types';
2
+ import type { ActionProps } from './action/types';
3
+ /**
4
+ * Action based on link data.
5
+ * Action behaviour is determined by the availability of the link data.
6
+ */
7
+ export type LinkActionProps = Optional<ActionProps, 'onClick'>;
@@ -79,12 +79,12 @@ export type FlexibleCardProps = {
79
79
  * Determine whether or not a preview card should show up when a user hovers
80
80
  * over the smartlink. Default value is false.
81
81
  */
82
- showHoverPreview?: Boolean;
82
+ showHoverPreview?: boolean;
83
83
  /**
84
84
  * Determines whether to show an unauthorised view of the hover card
85
85
  * when a user hovers over a smartlink.
86
86
  */
87
- showAuthTooltip?: Boolean;
87
+ showAuthTooltip?: boolean;
88
88
  };
89
89
  export type FlexibleUiOptions = {
90
90
  /**
@@ -146,3 +146,21 @@ export type ExtractFlexibleUiDataContextParams = Pick<FlexibleCardProps, 'id' |
146
146
  response?: JsonLd.Response;
147
147
  featureFlags?: Partial<LinkingPlatformFeatureFlags>;
148
148
  };
149
+ /**
150
+ * Mark a specific props in the type as optional.
151
+ * FlexibleCard use this concept where base component has required props
152
+ * and the extended component provides these props. The props become an optional
153
+ * for the extended component but is still available for override/callback.
154
+ *
155
+ * For example: Action component require onClick callback to perform action
156
+ * but PreviewAction defines the onClick behaviour inside its component.
157
+ * PreviewAction still wants the onClick for a callback to executed after the
158
+ * action completes, but it is optional.
159
+ *
160
+ * Usage:
161
+ * type ActionProps = { onClick: () => {}, content: string, icon?: React.ReactNode }
162
+ * type PreviewActionProps = Optional<ActionProps, 'onClick'>
163
+ */
164
+ export type Optional<T, K extends keyof T> = Omit<T, K> & {
165
+ [K in keyof T]?: T[K];
166
+ };
@@ -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;
@@ -1,6 +1,6 @@
1
1
  import { LinkLozenge } from '../../extractors/common/lozenge/types';
2
2
  import { LinkPerson } from '@atlaskit/link-extractors';
3
- import { IconType, MediaType } from '../../constants';
3
+ import { ActionName, IconType, MediaType } from '../../constants';
4
4
  import { InvokeRequestWithCardDetails } from '../hooks/use-invoke/types';
5
5
  import type { CardInnerAppearance } from '../../view/Card/types';
6
6
  import type { AnalyticsFacade } from '../analytics';
@@ -9,6 +9,10 @@ import type { AnalyticsFacade } from '../analytics';
9
9
  * underlying elements.
10
10
  */
11
11
  export type FlexibleUiDataContext = {
12
+ /**
13
+ * An object containing available action on the linked resource.
14
+ */
15
+ actions?: FlexibleUiActions;
12
16
  /**
13
17
  * An array containing data used to populate the AssignedToGroup element.
14
18
  * @see AvatarGroup
@@ -102,12 +106,6 @@ export type FlexibleUiDataContext = {
102
106
  * @see CreatedOn
103
107
  */
104
108
  createdOn?: string;
105
- /**
106
- * Contains data needed to show a preview action.
107
- * @type PreviewActionData
108
- * @see PreviewAction
109
- */
110
- previewAction?: PreviewActionData;
111
109
  /**
112
110
  * Contains data needed to show a view action.
113
111
  * @type ViewActionData
@@ -228,6 +226,12 @@ export type FlexibleUiDataContext = {
228
226
  * @see Title
229
227
  */
230
228
  url?: string;
229
+ /**
230
+ * Contains the atlassian resource identifier (ARI) of the linked resource.
231
+ * @type string
232
+ * @see Title
233
+ */
234
+ ari?: string;
231
235
  /**
232
236
  * Contains the name and url of the location that the resource is located in.
233
237
  * @type LinkLocation
@@ -248,6 +252,9 @@ export type Media = {
248
252
  type: MediaType;
249
253
  url: string;
250
254
  };
255
+ export type FlexibleUiActions = {
256
+ [ActionName.PreviewAction]?: PreviewActionData;
257
+ };
251
258
  export type PreviewActionData = {
252
259
  downloadUrl?: string;
253
260
  linkIcon?: Icon;
@@ -3,6 +3,7 @@ export declare class AISummaryService implements AISummaryServiceInt {
3
3
  state: AISummaryState;
4
4
  private config;
5
5
  private url;
6
+ private ari?;
6
7
  private subscribedStateSetters;
7
8
  private onStart?;
8
9
  private onSuccess?;
@@ -12,6 +12,7 @@ export type AISummaryServiceProps = {
12
12
  onSuccess?: (id: string) => void;
13
13
  product?: ProductType;
14
14
  url: string;
15
+ ari: string;
15
16
  };
16
17
  export type AISummaryServiceConfig = {
17
18
  baseUrl: string;
@@ -21,14 +22,17 @@ export type AISummaryStatus = 'ready' | 'loading' | 'error' | 'done';
21
22
  export type ProductType = 'confluence' | 'atlas' | 'jpd' | 'jsm' | 'jsw' | 'jwm' | 'bitbucket' | 'trello';
22
23
  export type PostAgentPayload = {
23
24
  recipient_agent_named_id: string;
24
- agent_input: AgentInput;
25
+ agent_input_context: AgentInputContext;
25
26
  user_intent?: string;
26
27
  };
27
- export type AgentInput = {
28
- urls: Array<string>;
28
+ export type AgentInputContext = {
29
+ content_url: string;
30
+ content_ari?: string;
29
31
  summary_style?: SummaryStyle;
32
+ summary_output_mimetype?: SummaryOutputMimeType;
30
33
  };
31
34
  export type SummaryStyle = 'short' | 'medium' | 'long';
35
+ export type SummaryOutputMimeType = 'text/adf' | 'text/markdown' | 'text/json';
32
36
  export declare const errorMessages: readonly [
33
37
  "NETWORK_ERROR",
34
38
  "NO_ANSWER",
@@ -1,9 +1,9 @@
1
1
  /// <reference types="react" />
2
2
  import { ActionProps } from './action/types';
3
- import { PreviewActionProps } from './action/preview-action/types';
4
3
  import { ViewActionProps } from './action/view-action/types';
5
4
  import { DownloadActionProps } from './action/download-action/types';
6
5
  export { default as FollowAction } from './follow-action';
6
+ export { default as PreviewAction } from './preview-action';
7
7
  /**
8
8
  * Creates a DeleteAction component. Accepts default ActionProps, but defaults
9
9
  * the icon to a cross icon.
@@ -16,12 +16,6 @@ export declare const DeleteAction: import("react").FC<ActionProps>;
16
16
  * @see Action
17
17
  */
18
18
  export declare const EditAction: import("react").FC<ActionProps>;
19
- /**
20
- * Creates a PreviewAction component. Accepts default PreviewActionProps, and defaults
21
- * to the text 'Preview' inside the button.
22
- * @see Action
23
- */
24
- export declare const PreviewAction: import("react").FC<PreviewActionProps>;
25
19
  /**
26
20
  * Creates a ViewAction component. Accepts default ViewActionProps, and defaults
27
21
  * to the text 'View' inside the button.
@@ -0,0 +1,4 @@
1
+ import { type FC } from 'react';
2
+ import type { PreviewActionProps } from './types';
3
+ declare const PreviewAction: FC<PreviewActionProps>;
4
+ export default PreviewAction;
@@ -0,0 +1,2 @@
1
+ import { LinkActionProps } from '../types';
2
+ export type PreviewActionProps = LinkActionProps;
@@ -0,0 +1,7 @@
1
+ import type { Optional } from '../../types';
2
+ import type { ActionProps } from './action/types';
3
+ /**
4
+ * Action based on link data.
5
+ * Action behaviour is determined by the availability of the link data.
6
+ */
7
+ export type LinkActionProps = Optional<ActionProps, 'onClick'>;
@@ -79,12 +79,12 @@ export type FlexibleCardProps = {
79
79
  * Determine whether or not a preview card should show up when a user hovers
80
80
  * over the smartlink. Default value is false.
81
81
  */
82
- showHoverPreview?: Boolean;
82
+ showHoverPreview?: boolean;
83
83
  /**
84
84
  * Determines whether to show an unauthorised view of the hover card
85
85
  * when a user hovers over a smartlink.
86
86
  */
87
- showAuthTooltip?: Boolean;
87
+ showAuthTooltip?: boolean;
88
88
  };
89
89
  export type FlexibleUiOptions = {
90
90
  /**
@@ -146,3 +146,21 @@ export type ExtractFlexibleUiDataContextParams = Pick<FlexibleCardProps, 'id' |
146
146
  response?: JsonLd.Response;
147
147
  featureFlags?: Partial<LinkingPlatformFeatureFlags>;
148
148
  };
149
+ /**
150
+ * Mark a specific props in the type as optional.
151
+ * FlexibleCard use this concept where base component has required props
152
+ * and the extended component provides these props. The props become an optional
153
+ * for the extended component but is still available for override/callback.
154
+ *
155
+ * For example: Action component require onClick callback to perform action
156
+ * but PreviewAction defines the onClick behaviour inside its component.
157
+ * PreviewAction still wants the onClick for a callback to executed after the
158
+ * action completes, but it is optional.
159
+ *
160
+ * Usage:
161
+ * type ActionProps = { onClick: () => {}, content: string, icon?: React.ReactNode }
162
+ * type PreviewActionProps = Optional<ActionProps, 'onClick'>
163
+ */
164
+ export type Optional<T, K extends keyof T> = Omit<T, K> & {
165
+ [K in keyof T]?: T[K];
166
+ };