@atlaskit/smart-card 26.50.14 → 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 (59) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/extractors/flexible/actions/index.js +17 -0
  3. package/dist/cjs/extractors/flexible/index.js +2 -2
  4. package/dist/cjs/state/flexible-ui-context/types.js +1 -3
  5. package/dist/cjs/utils/analytics/analytics.js +1 -1
  6. package/dist/cjs/view/FlexibleCard/components/actions/index.js +8 -12
  7. package/dist/cjs/view/FlexibleCard/components/actions/preview-action/index.js +83 -0
  8. package/dist/cjs/view/FlexibleCard/components/actions/types.js +5 -0
  9. package/dist/cjs/view/FlexibleCard/components/actions/utils.js +0 -13
  10. package/dist/cjs/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +8 -6
  11. package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +45 -11
  12. package/dist/cjs/view/LinkUrl/index.js +1 -1
  13. package/dist/es2019/extractors/flexible/actions/index.js +9 -0
  14. package/dist/es2019/extractors/flexible/index.js +2 -2
  15. package/dist/es2019/state/flexible-ui-context/types.js +6 -1
  16. package/dist/es2019/utils/analytics/analytics.js +1 -1
  17. package/dist/es2019/view/FlexibleCard/components/actions/index.js +1 -11
  18. package/dist/es2019/view/FlexibleCard/components/actions/preview-action/index.js +52 -0
  19. package/dist/es2019/view/FlexibleCard/components/actions/utils.js +0 -14
  20. package/dist/es2019/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +8 -6
  21. package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +42 -33
  22. package/dist/es2019/view/LinkUrl/index.js +1 -1
  23. package/dist/esm/extractors/flexible/actions/index.js +10 -0
  24. package/dist/esm/extractors/flexible/index.js +2 -2
  25. package/dist/esm/state/flexible-ui-context/types.js +6 -1
  26. package/dist/esm/utils/analytics/analytics.js +1 -1
  27. package/dist/esm/view/FlexibleCard/components/actions/index.js +1 -11
  28. package/dist/esm/view/FlexibleCard/components/actions/preview-action/index.js +73 -0
  29. package/dist/esm/view/FlexibleCard/components/actions/preview-action/types.js +1 -0
  30. package/dist/esm/view/FlexibleCard/components/actions/types.js +1 -0
  31. package/dist/esm/view/FlexibleCard/components/actions/utils.js +0 -13
  32. package/dist/esm/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +8 -6
  33. package/dist/esm/view/FlexibleCard/components/blocks/utils.js +45 -11
  34. package/dist/esm/view/LinkUrl/index.js +1 -1
  35. package/dist/types/extractors/flexible/actions/index.d.ts +5 -0
  36. package/dist/types/state/flexible-ui-context/types.d.ts +8 -7
  37. package/dist/types/view/FlexibleCard/components/actions/index.d.ts +1 -7
  38. package/dist/types/view/FlexibleCard/components/actions/preview-action/index.d.ts +4 -0
  39. package/dist/types/view/FlexibleCard/components/actions/preview-action/types.d.ts +2 -0
  40. package/dist/types/view/FlexibleCard/components/actions/types.d.ts +7 -0
  41. package/dist/types/view/FlexibleCard/types.d.ts +20 -2
  42. package/dist/types-ts4.5/extractors/flexible/actions/index.d.ts +5 -0
  43. package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +8 -7
  44. package/dist/types-ts4.5/view/FlexibleCard/components/actions/index.d.ts +1 -7
  45. package/dist/types-ts4.5/view/FlexibleCard/components/actions/preview-action/index.d.ts +4 -0
  46. package/dist/types-ts4.5/view/FlexibleCard/components/actions/preview-action/types.d.ts +2 -0
  47. package/dist/types-ts4.5/view/FlexibleCard/components/actions/types.d.ts +7 -0
  48. package/dist/types-ts4.5/view/FlexibleCard/types.d.ts +20 -2
  49. package/package.json +1 -1
  50. package/dist/cjs/view/FlexibleCard/components/actions/action/preview-action/index.js +0 -87
  51. package/dist/es2019/view/FlexibleCard/components/actions/action/preview-action/index.js +0 -63
  52. package/dist/esm/view/FlexibleCard/components/actions/action/preview-action/index.js +0 -80
  53. package/dist/types/view/FlexibleCard/components/actions/action/preview-action/index.d.ts +0 -4
  54. package/dist/types/view/FlexibleCard/components/actions/action/preview-action/types.d.ts +0 -12
  55. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/preview-action/index.d.ts +0 -4
  56. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/preview-action/types.d.ts +0 -12
  57. /package/dist/cjs/view/FlexibleCard/components/actions/{action/preview-action → preview-action}/types.js +0 -0
  58. /package/dist/es2019/view/FlexibleCard/components/actions/{action/preview-action → preview-action}/types.js +0 -0
  59. /package/dist/{esm/view/FlexibleCard/components/actions/action/preview-action → es2019/view/FlexibleCard/components/actions}/types.js +0 -0
@@ -48,16 +48,16 @@ export const ElementDisplaySchema = {
48
48
  const getDirectionStyles = direction => {
49
49
  switch (direction) {
50
50
  case SmartLinkDirection.Vertical:
51
- return css`
52
- flex-direction: column;
53
- align-items: flex-start;
54
- `;
51
+ return css({
52
+ flexDirection: 'column',
53
+ alignItems: 'flex-start'
54
+ });
55
55
  case SmartLinkDirection.Horizontal:
56
56
  default:
57
- return css`
58
- flex-direction: row;
59
- align-items: center;
60
- `;
57
+ return css({
58
+ flexDirection: 'row',
59
+ alignItems: 'center'
60
+ });
61
61
  }
62
62
  };
63
63
  export const getGapSize = size => {
@@ -73,24 +73,24 @@ export const getGapSize = size => {
73
73
  return 0.25;
74
74
  }
75
75
  };
76
- export const getBaseStyles = (direction, size) => css`
77
- align-items: center;
78
- display: flex;
79
- gap: ${getGapSize(size)}rem;
80
- line-height: 1rem;
81
- min-width: 0;
82
- overflow: hidden;
83
- ${getDirectionStyles(direction)};
84
- &:empty {
85
- display: none;
76
+ export const getBaseStyles = (direction, size) => css({
77
+ alignItems: 'center',
78
+ display: 'flex',
79
+ gap: `${getGapSize(size)}rem`,
80
+ lineHeight: '1rem',
81
+ minWidth: 0,
82
+ overflow: 'hidden'
83
+ }, getDirectionStyles(direction), {
84
+ '&:empty': {
85
+ display: 'none'
86
+ },
87
+ '& > *': {
88
+ minWidth: 0
89
+ },
90
+ '& > [data-fit-to-content]': {
91
+ minWidth: 'fit-content'
86
92
  }
87
- & > * {
88
- min-width: 0;
89
- }
90
- & > [data-fit-to-content] {
91
- min-width: fit-content;
92
- }
93
- `;
93
+ });
94
94
  export const highlightRemoveStyles = css`
95
95
  outline: none !important;
96
96
  outline-color: inherit;
@@ -116,26 +116,35 @@ export const getActionGroupStyles = size => {
116
116
  // The biggest height of the action button exceeds the max line-height
117
117
  // of the elements causing the action on the block with x-large size to
118
118
  // get cut at the bottom.
119
- return css`
120
- max-height: 2rem;
121
- `;
119
+ return css({
120
+ maxHeight: '2rem'
121
+ });
122
122
  }
123
123
  };
124
124
  export const filterActionItems = (items = [], context) => {
125
125
  return items.filter(item => {
126
+ var _context$actions;
126
127
  switch (item.name) {
127
- // Action that require data from the data context to render.
128
+ case ActionName.DeleteAction:
129
+ case ActionName.EditAction:
130
+ case ActionName.CustomAction:
131
+ // Named and custom actions that user defines.
132
+ return Boolean(ActionName[item.name]);
128
133
  case ActionName.DownloadAction:
134
+ // Remove once DownloadAction is refactored to context.action
135
+ // https://product-fabric.atlassian.net/browse/EDM-9545
129
136
  return Boolean(context === null || context === void 0 ? void 0 : context.downloadAction);
137
+ // Remove once FollowAction is refactored to context.action
138
+ // https://product-fabric.atlassian.net/browse/EDM-9559
130
139
  case ActionName.FollowAction:
131
140
  return Boolean(context === null || context === void 0 ? void 0 : context.followAction);
132
- case ActionName.PreviewAction:
133
- return Boolean(context === null || context === void 0 ? void 0 : context.previewAction);
141
+ // Remove once ViewAction is retired
142
+ // https://product-fabric.atlassian.net/browse/EDM-9547
134
143
  case ActionName.ViewAction:
135
144
  return Boolean(context === null || context === void 0 ? void 0 : context.viewAction);
136
145
  default:
137
- // Named and custom actions that user defines.
138
- return Boolean(ActionName[item.name]);
146
+ // Action that require data from the data context to render.
147
+ return Boolean(context === null || context === void 0 ? void 0 : (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[item.name]);
139
148
  }
140
149
  });
141
150
  };
@@ -7,7 +7,7 @@ import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-m
7
7
  import LinkWarningModal from './LinkWarningModal';
8
8
  const PACKAGE_DATA = {
9
9
  packageName: "@atlaskit/smart-card",
10
- packageVersion: "26.50.14",
10
+ packageVersion: "26.50.15",
11
11
  componentName: 'linkUrl'
12
12
  };
13
13
  const Link = withLinkClickedEvent('a');
@@ -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.50.15"
19
19
  };
20
20
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
21
21
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -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
  };
@@ -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.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
@@ -254,6 +252,9 @@ export type Media = {
254
252
  type: MediaType;
255
253
  url: string;
256
254
  };
255
+ export type FlexibleUiActions = {
256
+ [ActionName.PreviewAction]?: PreviewActionData;
257
+ };
257
258
  export type PreviewActionData = {
258
259
  downloadUrl?: string;
259
260
  linkIcon?: Icon;
@@ -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
@@ -254,6 +252,9 @@ export type Media = {
254
252
  type: MediaType;
255
253
  url: string;
256
254
  };
255
+ export type FlexibleUiActions = {
256
+ [ActionName.PreviewAction]?: PreviewActionData;
257
+ };
257
258
  export type PreviewActionData = {
258
259
  downloadUrl?: string;
259
260
  linkIcon?: Icon;