@atlaskit/smart-card 23.3.1 → 23.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/cjs/constants.js +3 -0
  3. package/dist/cjs/extractors/common/actions/extractActions.js +3 -0
  4. package/dist/cjs/extractors/flexible/actions/extract-download-action.js +26 -0
  5. package/dist/cjs/extractors/flexible/actions/extract-preview-action.js +36 -0
  6. package/dist/cjs/extractors/flexible/actions/extract-view-action.js +26 -0
  7. package/dist/cjs/extractors/flexible/index.js +9 -0
  8. package/dist/cjs/state/flexible-ui-context/index.js +15 -2
  9. package/dist/cjs/version.json +1 -1
  10. package/dist/cjs/view/FlexibleCard/components/actions/action/download-action/index.js +110 -0
  11. package/dist/cjs/view/FlexibleCard/components/actions/action/download-action/types.js +5 -0
  12. package/dist/cjs/view/FlexibleCard/components/actions/action/preview-action/index.js +167 -0
  13. package/dist/cjs/view/FlexibleCard/components/actions/action/preview-action/types.js +5 -0
  14. package/dist/cjs/view/FlexibleCard/components/actions/action/view-action/index.js +92 -0
  15. package/dist/cjs/view/FlexibleCard/components/actions/action/view-action/types.js +5 -0
  16. package/dist/cjs/view/FlexibleCard/components/actions/index.js +26 -2
  17. package/dist/cjs/view/FlexibleCard/components/actions/utils.js +51 -2
  18. package/dist/cjs/view/FlexibleCard/components/blocks/action-group/index.js +19 -13
  19. package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +9 -4
  20. package/dist/cjs/view/FlexibleCard/components/elements/media/index.js +1 -1
  21. package/dist/cjs/view/FlexibleCard/index.js +6 -3
  22. package/dist/cjs/view/common/Icon.js +25 -13
  23. package/dist/es2019/constants.js +3 -0
  24. package/dist/es2019/extractors/common/actions/extractActions.js +1 -2
  25. package/dist/es2019/extractors/flexible/actions/extract-download-action.js +13 -0
  26. package/dist/es2019/extractors/flexible/actions/extract-preview-action.js +23 -0
  27. package/dist/es2019/extractors/flexible/actions/extract-view-action.js +13 -0
  28. package/dist/es2019/extractors/flexible/index.js +7 -1
  29. package/dist/es2019/state/flexible-ui-context/index.js +8 -1
  30. package/dist/es2019/version.json +1 -1
  31. package/dist/es2019/view/FlexibleCard/components/actions/action/download-action/index.js +66 -0
  32. package/dist/es2019/view/FlexibleCard/components/actions/action/download-action/types.js +1 -0
  33. package/dist/es2019/view/FlexibleCard/components/actions/action/preview-action/index.js +104 -0
  34. package/dist/es2019/view/FlexibleCard/components/actions/action/preview-action/types.js +1 -0
  35. package/dist/es2019/view/FlexibleCard/components/actions/action/view-action/index.js +46 -0
  36. package/dist/es2019/view/FlexibleCard/components/actions/action/view-action/types.js +1 -0
  37. package/dist/es2019/view/FlexibleCard/components/actions/index.js +23 -2
  38. package/dist/es2019/view/FlexibleCard/components/actions/utils.js +48 -2
  39. package/dist/es2019/view/FlexibleCard/components/blocks/action-group/index.js +12 -9
  40. package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +9 -4
  41. package/dist/es2019/view/FlexibleCard/components/elements/media/index.js +1 -1
  42. package/dist/es2019/view/FlexibleCard/index.js +7 -4
  43. package/dist/es2019/view/common/Icon.js +31 -13
  44. package/dist/esm/constants.js +3 -0
  45. package/dist/esm/extractors/common/actions/extractActions.js +1 -2
  46. package/dist/esm/extractors/flexible/actions/extract-download-action.js +15 -0
  47. package/dist/esm/extractors/flexible/actions/extract-preview-action.js +23 -0
  48. package/dist/esm/extractors/flexible/actions/extract-view-action.js +15 -0
  49. package/dist/esm/extractors/flexible/index.js +7 -1
  50. package/dist/esm/state/flexible-ui-context/index.js +9 -0
  51. package/dist/esm/version.json +1 -1
  52. package/dist/esm/view/FlexibleCard/components/actions/action/download-action/index.js +96 -0
  53. package/dist/esm/view/FlexibleCard/components/actions/action/download-action/types.js +1 -0
  54. package/dist/esm/view/FlexibleCard/components/actions/action/preview-action/index.js +136 -0
  55. package/dist/esm/view/FlexibleCard/components/actions/action/preview-action/types.js +1 -0
  56. package/dist/esm/view/FlexibleCard/components/actions/action/view-action/index.js +77 -0
  57. package/dist/esm/view/FlexibleCard/components/actions/action/view-action/types.js +1 -0
  58. package/dist/esm/view/FlexibleCard/components/actions/index.js +23 -2
  59. package/dist/esm/view/FlexibleCard/components/actions/utils.js +45 -2
  60. package/dist/esm/view/FlexibleCard/components/blocks/action-group/index.js +19 -13
  61. package/dist/esm/view/FlexibleCard/components/blocks/utils.js +9 -4
  62. package/dist/esm/view/FlexibleCard/components/elements/media/index.js +1 -1
  63. package/dist/esm/view/FlexibleCard/index.js +7 -4
  64. package/dist/esm/view/common/Icon.js +27 -13
  65. package/dist/types/constants.d.ts +3 -0
  66. package/dist/types/extractors/common/__mocks__/jsonld.d.ts +112 -0
  67. package/dist/types/extractors/common/actions/extractActions.d.ts +1 -0
  68. package/dist/types/extractors/flexible/actions/extract-download-action.d.ts +3 -0
  69. package/dist/types/extractors/flexible/actions/extract-preview-action.d.ts +3 -0
  70. package/dist/types/extractors/flexible/actions/extract-view-action.d.ts +3 -0
  71. package/dist/types/state/flexible-ui-context/index.d.ts +76 -0
  72. package/dist/types/state/flexible-ui-context/types.d.ts +32 -0
  73. package/dist/types/view/BlockCard/actions/PreviewAction.d.ts +2 -2
  74. package/dist/types/view/EmbedModal/index.d.ts +20 -2
  75. package/dist/types/view/EmbedModal/types.d.ts +1 -2
  76. package/dist/types/view/FlexibleCard/components/actions/action/download-action/index.d.ts +4 -0
  77. package/dist/types/view/FlexibleCard/components/actions/action/download-action/types.d.ts +8 -0
  78. package/dist/types/view/FlexibleCard/components/actions/action/preview-action/index.d.ts +5 -0
  79. package/dist/types/view/FlexibleCard/components/actions/action/preview-action/types.d.ts +15 -0
  80. package/dist/types/view/FlexibleCard/components/actions/action/view-action/index.d.ts +5 -0
  81. package/dist/types/view/FlexibleCard/components/actions/action/view-action/types.d.ts +8 -0
  82. package/dist/types/view/FlexibleCard/components/actions/index.d.ts +21 -0
  83. package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +50 -3
  84. package/dist/types/view/FlexibleCard/components/blocks/utils.d.ts +1 -1
  85. package/dist/types/view/FlexibleCard/types.d.ts +6 -0
  86. package/dist/types/view/common/Icon.d.ts +2 -1
  87. package/package.json +1 -1
  88. package/report.api.md +30 -2
  89. package/tmp/api-report-tmp.d.ts +25 -3
@@ -0,0 +1,136 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
+ import _extends from "@babel/runtime/helpers/extends";
4
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
+ var _excluded = ["popupMountPointId"];
6
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
7
+
8
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
9
+
10
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
11
+
12
+ import React from 'react';
13
+ import Action from '../index';
14
+ import ReactDOM from 'react-dom';
15
+ import { IntlProvider } from 'react-intl-next';
16
+ import { useFlexibleUiAnalyticsContext } from '../../../../../../state/flexible-ui-context';
17
+ import { useSmartLinkAnalytics } from '../../../../../../state';
18
+ import Icon from '../../../elements/icon';
19
+
20
+ var PreviewAction = function PreviewAction(props) {
21
+ var appearance = props.appearance,
22
+ asDropDownItem = props.asDropDownItem,
23
+ testId = props.testId,
24
+ _onClick = props.onClick,
25
+ linkIcon = props.linkIcon,
26
+ src = props.src,
27
+ url = props.url,
28
+ title = props.title,
29
+ providerName = props.providerName,
30
+ downloadUrl = props.downloadUrl;
31
+ var defaultAnalytics = useSmartLinkAnalytics(url, function () {});
32
+ var analytics = useFlexibleUiAnalyticsContext() || defaultAnalytics;
33
+ var EmbedIcon = {
34
+ icon: /*#__PURE__*/React.createElement(Icon, linkIcon),
35
+ isFlexibleUi: true
36
+ };
37
+
38
+ if (src && url) {
39
+ var embedModal = function embedModal() {
40
+ return previewFunction({
41
+ popupMountPointId: 'twp-editor-preview-iframe',
42
+ showModal: true,
43
+ iframeName: 'twp-editor-preview-iframe',
44
+ onClose: function onClose() {},
45
+ download: downloadUrl,
46
+ icon: EmbedIcon,
47
+ providerName: providerName || 'Preview',
48
+ src: src,
49
+ title: title,
50
+ url: url,
51
+ analytics: analytics,
52
+ origin: 'smartLinkCard'
53
+ });
54
+ };
55
+
56
+ var action = _objectSpread(_objectSpread({}, props), {}, {
57
+ onClick: function onClick() {
58
+ embedModal();
59
+
60
+ if (_onClick) {
61
+ _onClick();
62
+ }
63
+ }
64
+ });
65
+
66
+ return /*#__PURE__*/React.createElement(Action, _extends({}, action, {
67
+ appearance: appearance,
68
+ asDropDownItem: asDropDownItem,
69
+ testId: testId
70
+ }));
71
+ } else {
72
+ return null;
73
+ }
74
+ };
75
+ /*
76
+ Explanatory note:
77
+ Actions don't have access to the react tree of whatever is rendered them
78
+ (and this concept is fraught inside editor anyway) so we want to ensure
79
+ it is mounting to a new unique place. This function manages that, including
80
+ creating an element if it doesn't exist, as well as tidying up the react tree
81
+ (but not the element) upon closing the modal.
82
+
83
+ This may strike you as really uncomfortable as you read it, so I wanted to note
84
+ that a) this was discussed and agreed upon, and b) it's definitely odd, and if
85
+ you find an elegant solution around this, you should definitely feel free to
86
+ refactor it.
87
+ */
88
+
89
+
90
+ export function previewFunction(_x) {
91
+ return _previewFunction.apply(this, arguments);
92
+ }
93
+
94
+ function _previewFunction() {
95
+ _previewFunction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
96
+ var popupMountPointId, rest, popupMountPoint, Modal;
97
+ return _regeneratorRuntime.wrap(function _callee$(_context2) {
98
+ while (1) {
99
+ switch (_context2.prev = _context2.next) {
100
+ case 0:
101
+ popupMountPointId = _ref.popupMountPointId, rest = _objectWithoutProperties(_ref, _excluded);
102
+ popupMountPoint = document.getElementById(popupMountPointId);
103
+
104
+ if (!popupMountPoint) {
105
+ popupMountPoint = document.createElement('div');
106
+ popupMountPoint.id = popupMountPointId;
107
+ popupMountPoint.setAttribute('data-testid', 'preview-modal');
108
+ document.body.appendChild(popupMountPoint);
109
+ }
110
+
111
+ _context2.next = 5;
112
+ return import('../../../../../EmbedModal');
113
+
114
+ case 5:
115
+ Modal = _context2.sent;
116
+ ReactDOM.render( /*#__PURE__*/React.createElement(IntlProvider, {
117
+ locale: "en"
118
+ }, /*#__PURE__*/React.createElement(Modal.default, _extends({}, rest, {
119
+ onClose: function onClose(_context) {
120
+ if (popupMountPoint) {
121
+ ReactDOM.unmountComponentAtNode(popupMountPoint);
122
+ }
123
+ }
124
+ }))), popupMountPoint);
125
+
126
+ case 7:
127
+ case "end":
128
+ return _context2.stop();
129
+ }
130
+ }
131
+ }, _callee);
132
+ }));
133
+ return _previewFunction.apply(this, arguments);
134
+ }
135
+
136
+ export default PreviewAction;
@@ -0,0 +1,77 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _extends from "@babel/runtime/helpers/extends";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
5
+
6
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7
+
8
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
9
+
10
+ import React from 'react';
11
+ import Action from '../index';
12
+
13
+ var ViewAction = function ViewAction(props) {
14
+ var appearance = props.appearance,
15
+ asDropDownItem = props.asDropDownItem,
16
+ testId = props.testId,
17
+ _onClick = props.onClick,
18
+ viewUrl = props.viewUrl,
19
+ url = props.url;
20
+
21
+ if (viewUrl && url) {
22
+ var action = _objectSpread(_objectSpread({}, props), {}, {
23
+ onClick: function onClick() {
24
+ viewFunction({
25
+ url: viewUrl
26
+ });
27
+
28
+ if (_onClick) {
29
+ _onClick();
30
+ }
31
+ }
32
+ });
33
+
34
+ return /*#__PURE__*/React.createElement(Action, _extends({}, action, {
35
+ appearance: appearance,
36
+ asDropDownItem: asDropDownItem,
37
+ testId: testId
38
+ }));
39
+ } else {
40
+ return null;
41
+ }
42
+ };
43
+
44
+ export function viewFunction(_x) {
45
+ return _viewFunction.apply(this, arguments);
46
+ }
47
+
48
+ function _viewFunction() {
49
+ _viewFunction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
50
+ var url;
51
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
52
+ while (1) {
53
+ switch (_context.prev = _context.next) {
54
+ case 0:
55
+ url = _ref.url;
56
+
57
+ if (url) {
58
+ _context.next = 3;
59
+ break;
60
+ }
61
+
62
+ return _context.abrupt("return");
63
+
64
+ case 3:
65
+ window.open(url, '_blank', 'noopener=yes');
66
+
67
+ case 4:
68
+ case "end":
69
+ return _context.stop();
70
+ }
71
+ }
72
+ }, _callee);
73
+ }));
74
+ return _viewFunction.apply(this, arguments);
75
+ }
76
+
77
+ export default ViewAction;
@@ -1,5 +1,6 @@
1
1
  import { ActionName } from '../../../../constants';
2
- import { createUIAction } from './utils'; // Attention: Keep the export name and action name the same.
2
+ import { createDataAction, createUIAction } from './utils';
3
+ // Attention: Keep the export name and action name the same.
3
4
  // This will help reducing the code for mapping action inside
4
5
  // createAction and renderActionItems
5
6
 
@@ -8,7 +9,6 @@ import { createUIAction } from './utils'; // Attention: Keep the export name and
8
9
  * the icon to a cross icon.
9
10
  * @see Action
10
11
  */
11
-
12
12
  export var DeleteAction = createUIAction(ActionName.DeleteAction);
13
13
  /**
14
14
  * Creates a EditAction component. Accepts default ActionProps, but defaults
@@ -17,6 +17,27 @@ export var DeleteAction = createUIAction(ActionName.DeleteAction);
17
17
  */
18
18
 
19
19
  export var EditAction = createUIAction(ActionName.EditAction);
20
+ /**
21
+ * Creates a PreviewAction component. Accepts default PreviewActionProps, and defaults
22
+ * to the text 'Preview' inside the button.
23
+ * @see Action
24
+ */
25
+
26
+ export var PreviewAction = createDataAction(ActionName.PreviewAction);
27
+ /**
28
+ * Creates a ViewAction component. Accepts default ViewActionProps, and defaults
29
+ * to the text 'View' inside the button.
30
+ * @see Action
31
+ */
32
+
33
+ export var ViewAction = createDataAction(ActionName.ViewAction);
34
+ /**
35
+ * Creates a DownloadAction component. Accepts default DownloadActionProps, and defaults
36
+ * to the text 'Download' inside the button.
37
+ * @see Action
38
+ */
39
+
40
+ export var DownloadAction = createDataAction(ActionName.DownloadAction);
20
41
  /**
21
42
  * Creates a CustomAction component. Accepts default ActionProps. Required to provide
22
43
  * your own icon or text.
@@ -15,6 +15,12 @@ import { FormattedMessage } from 'react-intl-next';
15
15
  import { messages } from '../../../../messages';
16
16
  import CrossIcon from '@atlaskit/icon/glyph/cross';
17
17
  import EditIcon from '@atlaskit/icon/glyph/edit';
18
+ import PreviewAction from './action/preview-action';
19
+ import VidFullScreenOnIcon from '@atlaskit/icon/glyph/vid-full-screen-on';
20
+ import ViewAction from './action/view-action';
21
+ import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
22
+ import DownloadAction from './action/download-action';
23
+ import DownloadIcon from '@atlaskit/icon/glyph/download';
18
24
  var actionMappings = (_actionMappings = {}, _defineProperty(_actionMappings, ActionName.CustomAction, {
19
25
  component: Action,
20
26
  props: {}
@@ -38,6 +44,36 @@ var actionMappings = (_actionMappings = {}, _defineProperty(_actionMappings, Act
38
44
  }),
39
45
  tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.edit)
40
46
  }
47
+ }), _defineProperty(_actionMappings, ActionName.PreviewAction, {
48
+ component: PreviewAction,
49
+ props: {
50
+ testId: 'smart-action-preview-action',
51
+ content: /*#__PURE__*/React.createElement(FormattedMessage, messages.preview),
52
+ icon: /*#__PURE__*/React.createElement(VidFullScreenOnIcon, {
53
+ label: "Preview"
54
+ }),
55
+ tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.preview)
56
+ }
57
+ }), _defineProperty(_actionMappings, ActionName.ViewAction, {
58
+ component: ViewAction,
59
+ props: {
60
+ testId: 'smart-action-view-action',
61
+ content: /*#__PURE__*/React.createElement(FormattedMessage, messages.view),
62
+ icon: /*#__PURE__*/React.createElement(ShortcutIcon, {
63
+ label: "View"
64
+ }),
65
+ tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.view)
66
+ }
67
+ }), _defineProperty(_actionMappings, ActionName.DownloadAction, {
68
+ component: DownloadAction,
69
+ props: {
70
+ testId: 'smart-action-download-action',
71
+ content: /*#__PURE__*/React.createElement(FormattedMessage, messages.download),
72
+ icon: /*#__PURE__*/React.createElement(DownloadIcon, {
73
+ label: "Download"
74
+ }),
75
+ tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.download)
76
+ }
41
77
  }), _actionMappings);
42
78
 
43
79
  var getContextKey = function getContextKey(name) {
@@ -54,8 +90,13 @@ var getActionData = function getActionData(actionName, contextKey, context) {
54
90
  var data = context[contextKey];
55
91
 
56
92
  switch (actionName) {
57
- default:
93
+ case ActionName.PreviewAction:
94
+ case ActionName.ViewAction:
95
+ case ActionName.DownloadAction:
58
96
  return data;
97
+
98
+ default:
99
+ return undefined;
59
100
  }
60
101
  };
61
102
 
@@ -73,7 +114,9 @@ export var createDataAction = function createDataAction(name) {
73
114
  return function (overrides) {
74
115
  var context = useContext(FlexibleUiContext);
75
116
  var data = getActionData(name, contextKey, context);
76
- return /*#__PURE__*/React.createElement(BaseAction, _extends({}, props, data, overrides));
117
+ return data ? /*#__PURE__*/React.createElement(BaseAction, _extends({}, props, data, overrides, {
118
+ url: context === null || context === void 0 ? void 0 : context.url
119
+ })) : null;
77
120
  };
78
121
  };
79
122
  export var createUIAction = function createUIAction(name) {
@@ -43,17 +43,7 @@ var ActionGroup = function ActionGroup(_ref) {
43
43
  var _useState = useState(false),
44
44
  _useState2 = _slicedToArray(_useState, 2),
45
45
  isOpen = _useState2[0],
46
- setIsOpen = _useState2[1];
47
-
48
- var _useMemo = useMemo(function () {
49
- var isMoreThenTwoItems = items.length > visibleButtonsNum;
50
- var buttons = isMoreThenTwoItems ? items.slice(0, visibleButtonsNum - 1) : items;
51
- var dropdownItems = isMoreThenTwoItems ? items.slice(visibleButtonsNum - 1) : [];
52
- return [buttons, dropdownItems];
53
- }, [items, visibleButtonsNum]),
54
- _useMemo2 = _slicedToArray(_useMemo, 2),
55
- buttonActions = _useMemo2[0],
56
- dropdownItemActions = _useMemo2[1]; // Stop AK dropdown menu to propagate event on click.
46
+ setIsOpen = _useState2[1]; // Stop AK dropdown menu to propagate event on click.
57
47
 
58
48
 
59
49
  var onClick = useCallback(function (e) {
@@ -73,11 +63,27 @@ var ActionGroup = function ActionGroup(_ref) {
73
63
  });
74
64
  }
75
65
  }, [isOpen, onOpenChange]);
66
+ var renderableActions = items.filter(function (action) {
67
+ return renderActionItems([action]);
68
+ });
69
+
70
+ var _useMemo = useMemo(function () {
71
+ var isMoreThenTwoItems = renderableActions && renderableActions.length > visibleButtonsNum;
72
+ var buttons = isMoreThenTwoItems ? renderableActions.slice(0, visibleButtonsNum - 1) : renderableActions;
73
+ var dropdownItems = isMoreThenTwoItems ? renderableActions.slice(visibleButtonsNum - 1) : [];
74
+ return [buttons, dropdownItems];
75
+ }, [renderableActions, visibleButtonsNum]),
76
+ _useMemo2 = _slicedToArray(_useMemo, 2),
77
+ buttonActions = _useMemo2[0],
78
+ dropdownItemActions = _useMemo2[1];
79
+
80
+ var dropdownMenuElement = renderActionItems(dropdownItemActions, size, appearance, true, onActionClick);
81
+ var buttonGroupElement = renderActionItems(buttonActions, size, appearance, false, onActionClick);
76
82
  return jsx("div", {
77
83
  css: styles,
78
84
  className: "actions-button-group",
79
85
  onClick: onClick
80
- }, jsx(ButtonGroup, null, renderActionItems(buttonActions, size, appearance, false, onActionClick), dropdownItemActions.length > 0 ? jsx(DropdownMenu, {
86
+ }, jsx(ButtonGroup, null, buttonGroupElement, dropdownItemActions.length > 0 && dropdownMenuElement && dropdownMenuElement.length > 0 ? jsx(DropdownMenu, {
81
87
  isOpen: isOpen,
82
88
  onOpenChange: onOpenChange,
83
89
  trigger: function trigger(_ref2) {
@@ -99,7 +105,7 @@ var ActionGroup = function ActionGroup(_ref) {
99
105
  })));
100
106
  },
101
107
  testId: "action-group-dropdown"
102
- }, renderActionItems(dropdownItemActions, size, appearance, true, onActionClick)) : null));
108
+ }, dropdownMenuElement) : null));
103
109
  };
104
110
 
105
111
  export default ActionGroup;
@@ -64,7 +64,7 @@ var isElementDisplayValid = function isElementDisplayValid(name, display) {
64
64
  return (_ElementDisplaySchema2 = (_ElementDisplaySchema3 = ElementDisplaySchema[name]) === null || _ElementDisplaySchema3 === void 0 ? void 0 : _ElementDisplaySchema3.includes(display)) !== null && _ElementDisplaySchema2 !== void 0 ? _ElementDisplaySchema2 : false;
65
65
  };
66
66
 
67
- var isElementNull = function isElementNull(children) {
67
+ var isJSXElementNull = function isJSXElementNull(children) {
68
68
  return Boolean(children.type() === null);
69
69
  };
70
70
 
@@ -100,7 +100,7 @@ export var renderElementItems = function renderElementItems() {
100
100
  key: idx
101
101
  }, typedProps));
102
102
 
103
- if (!isElementNull(element)) {
103
+ if (!isJSXElementNull(element)) {
104
104
  return [].concat(_toConsumableArray(acc), [element]);
105
105
  }
106
106
  }
@@ -148,13 +148,18 @@ export var renderActionItems = function renderActionItems() {
148
148
  }
149
149
  };
150
150
 
151
- return [].concat(_toConsumableArray(acc), [/*#__PURE__*/React.createElement(Action, _extends({
151
+ var action = /*#__PURE__*/React.createElement(Action, _extends({
152
+ url: '',
152
153
  asDropDownItem: asDropDownItems,
153
154
  size: size,
154
155
  key: idx,
155
156
  appearance: appearance,
156
157
  onClick: handleOnClick
157
- }, actionProps))]);
158
+ }, actionProps));
159
+
160
+ if (!isJSXElementNull(action)) {
161
+ return [].concat(_toConsumableArray(acc), [action]);
162
+ }
158
163
  }
159
164
 
160
165
  return acc;
@@ -41,7 +41,7 @@ var Media = function Media(_ref) {
41
41
  return jsx("div", {
42
42
  css: [styles, overrideCss],
43
43
  "data-smart-element": name,
44
- "data-smart-element-media": true,
44
+ "data-smart-element-media": type,
45
45
  "data-testid": testId
46
46
  }, jsx(ImageIcon, {
47
47
  testId: "".concat(testId, "-image"),
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { useEffect } from 'react';
3
3
  import { SmartLinkStatus } from '../../constants';
4
4
  import Container from './components/container';
5
- import { FlexibleUiContext } from '../../state/flexible-ui-context';
5
+ import { FlexibleUiAnalyticsContext, FlexibleUiContext } from '../../state/flexible-ui-context';
6
6
  import { getContextByStatus, getRetryOptions } from './utils';
7
7
  /**
8
8
  * This represents a Flexible Card: a link represented by a card with metadata.
@@ -21,7 +21,8 @@ var FlexibleCard = function FlexibleCard(_ref) {
21
21
  ui = _ref.ui,
22
22
  url = _ref.url,
23
23
  onClick = _ref.onClick,
24
- testId = _ref.testId;
24
+ testId = _ref.testId,
25
+ analytics = _ref.analytics;
25
26
  var cardType = cardState.status,
26
27
  details = cardState.details;
27
28
  var status = cardType;
@@ -58,7 +59,9 @@ var FlexibleCard = function FlexibleCard(_ref) {
58
59
  break;
59
60
  }
60
61
  }, [onError, onResolve, status, title, url]);
61
- return /*#__PURE__*/React.createElement(FlexibleUiContext.Provider, {
62
+ return /*#__PURE__*/React.createElement(FlexibleUiAnalyticsContext.Provider, {
63
+ value: analytics
64
+ }, /*#__PURE__*/React.createElement(FlexibleUiContext.Provider, {
62
65
  value: context
63
66
  }, /*#__PURE__*/React.createElement(Container, _extends({
64
67
  testId: testId
@@ -66,7 +69,7 @@ var FlexibleCard = function FlexibleCard(_ref) {
66
69
  onClick: onClick,
67
70
  retry: retry,
68
71
  status: status
69
- }), children));
72
+ }), children)));
70
73
  };
71
74
 
72
75
  export default FlexibleCard;
@@ -1,16 +1,39 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+
3
+ var _templateObject, _templateObject2;
4
+
1
5
  /** @jsx jsx */
2
- import { jsx } from '@emotion/react';
6
+ import { css, jsx } from '@emotion/react';
3
7
  import React from 'react';
4
8
  import ImageLoader from 'react-render-image';
5
9
  import LinkIcon from '@atlaskit/icon/glyph/link';
6
10
  import { gs } from './utils';
7
11
  export var blockCardIconImageClassName = 'block-card-icon-image';
12
+
13
+ var getImageStyles = function getImageStyles(isFlexibleUi) {
14
+ if (isFlexibleUi) {
15
+ return;
16
+ }
17
+
18
+ return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n height: ", ";\n width: ", ";\n "])), gs(2), gs(2));
19
+ };
20
+
21
+ var getSpanStyles = function getSpanStyles(isFlexibleUi) {
22
+ if (isFlexibleUi) {
23
+ return;
24
+ }
25
+
26
+ return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n height: ", ";\n width: ", ";\n display: flex;\n align-items: center;\n justify-content: center;\n "])), gs(2.5), gs(2));
27
+ };
28
+
8
29
  export var Icon = function Icon(_ref) {
9
30
  var url = _ref.url,
10
31
  icon = _ref.icon,
11
32
  defaultIcon = _ref.defaultIcon,
12
33
  _ref$testId = _ref.testId,
13
- testId = _ref$testId === void 0 ? 'block-card-icon' : _ref$testId;
34
+ testId = _ref$testId === void 0 ? 'block-card-icon' : _ref$testId,
35
+ _ref$isFlexibleUi = _ref.isFlexibleUi,
36
+ isFlexibleUi = _ref$isFlexibleUi === void 0 ? false : _ref$isFlexibleUi;
14
37
  var placeholder = defaultIcon || jsx(LinkIcon, {
15
38
  label: "link",
16
39
  size: "small",
@@ -19,23 +42,14 @@ export var Icon = function Icon(_ref) {
19
42
  var image = url && jsx(ImageLoader, {
20
43
  src: url,
21
44
  loaded: jsx("img", {
22
- css: {
23
- height: gs(2),
24
- width: gs(2)
25
- },
45
+ css: getImageStyles(isFlexibleUi),
26
46
  src: url,
27
47
  "data-testid": "".concat(testId, "-image")
28
48
  }),
29
49
  errored: placeholder
30
50
  });
31
51
  return jsx("span", {
32
- css: {
33
- height: gs(2.5),
34
- width: gs(2),
35
- display: 'flex',
36
- alignItems: 'center',
37
- justifyContent: 'center'
38
- },
52
+ css: getSpanStyles(isFlexibleUi),
39
53
  "data-testid": testId,
40
54
  className: blockCardIconImageClassName
41
55
  }, icon || image || placeholder);
@@ -112,6 +112,9 @@ export declare enum ElementName {
112
112
  export declare enum ActionName {
113
113
  DeleteAction = "DeleteAction",
114
114
  EditAction = "EditAction",
115
+ PreviewAction = "PreviewAction",
116
+ ViewAction = "ViewAction",
117
+ DownloadAction = "DownloadAction",
115
118
  CustomAction = "CustomAction"
116
119
  }
117
120
  /**