@atlaskit/smart-card 26.53.0 → 26.55.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 (55) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/utils/analytics/analytics.js +1 -1
  3. package/dist/cjs/utils/index.js +16 -1
  4. package/dist/cjs/view/BlockCard/views/flexible/FlexibleResolvedView.js +0 -3
  5. package/dist/cjs/view/EmbedCard/views/ResolvedView.js +4 -3
  6. package/dist/cjs/view/EmbedModal/index.js +3 -3
  7. package/dist/cjs/view/FlexibleCard/components/actions/index.js +1 -10
  8. package/dist/cjs/view/FlexibleCard/components/blocks/action-block/index.js +2 -10
  9. package/dist/cjs/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +2 -10
  10. package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +4 -6
  11. package/dist/cjs/view/LinkUrl/index.js +1 -1
  12. package/dist/es2019/utils/analytics/analytics.js +1 -1
  13. package/dist/es2019/utils/index.js +15 -0
  14. package/dist/es2019/view/BlockCard/views/flexible/FlexibleResolvedView.js +0 -3
  15. package/dist/es2019/view/EmbedCard/views/ResolvedView.js +4 -4
  16. package/dist/es2019/view/EmbedModal/index.js +4 -5
  17. package/dist/es2019/view/FlexibleCard/components/actions/index.js +1 -10
  18. package/dist/es2019/view/FlexibleCard/components/blocks/action-block/index.js +2 -10
  19. package/dist/es2019/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +2 -10
  20. package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +4 -6
  21. package/dist/es2019/view/LinkUrl/index.js +1 -1
  22. package/dist/esm/utils/analytics/analytics.js +1 -1
  23. package/dist/esm/utils/index.js +15 -0
  24. package/dist/esm/view/BlockCard/views/flexible/FlexibleResolvedView.js +0 -3
  25. package/dist/esm/view/EmbedCard/views/ResolvedView.js +4 -3
  26. package/dist/esm/view/EmbedModal/index.js +4 -4
  27. package/dist/esm/view/FlexibleCard/components/actions/index.js +1 -10
  28. package/dist/esm/view/FlexibleCard/components/blocks/action-block/index.js +2 -10
  29. package/dist/esm/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +2 -10
  30. package/dist/esm/view/FlexibleCard/components/blocks/utils.js +4 -6
  31. package/dist/esm/view/LinkUrl/index.js +1 -1
  32. package/dist/types/constants.d.ts +3 -0
  33. package/dist/types/utils/index.d.ts +7 -0
  34. package/dist/types/view/FlexibleCard/components/actions/index.d.ts +0 -8
  35. package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +7 -1
  36. package/dist/types-ts4.5/constants.d.ts +3 -0
  37. package/dist/types-ts4.5/utils/index.d.ts +7 -0
  38. package/dist/types-ts4.5/view/FlexibleCard/components/actions/index.d.ts +0 -8
  39. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/types.d.ts +7 -1
  40. package/package.json +4 -1
  41. package/dist/cjs/view/FlexibleCard/components/actions/action/view-action/index.js +0 -72
  42. package/dist/cjs/view/FlexibleCard/components/actions/action/view-action/types.js +0 -5
  43. package/dist/cjs/view/FlexibleCard/components/actions/utils.js +0 -64
  44. package/dist/es2019/view/FlexibleCard/components/actions/action/view-action/index.js +0 -47
  45. package/dist/es2019/view/FlexibleCard/components/actions/action/view-action/types.js +0 -1
  46. package/dist/es2019/view/FlexibleCard/components/actions/utils.js +0 -55
  47. package/dist/esm/view/FlexibleCard/components/actions/action/view-action/index.js +0 -65
  48. package/dist/esm/view/FlexibleCard/components/actions/action/view-action/types.js +0 -1
  49. package/dist/esm/view/FlexibleCard/components/actions/utils.js +0 -54
  50. package/dist/types/view/FlexibleCard/components/actions/action/view-action/index.d.ts +0 -4
  51. package/dist/types/view/FlexibleCard/components/actions/action/view-action/types.d.ts +0 -5
  52. package/dist/types/view/FlexibleCard/components/actions/utils.d.ts +0 -3
  53. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/view-action/index.d.ts +0 -4
  54. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/view-action/types.d.ts +0 -5
  55. package/dist/types-ts4.5/view/FlexibleCard/components/actions/utils.d.ts +0 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 26.55.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#89962](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/89962) [`56ed342d14f6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/56ed342d14f6) - EDM-9541: append embedded smart-cards with themeState query parameter under FF `platform.linking-platform.smart-card.enable-theme-state-url`
8
+
9
+ ## 26.54.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#88849](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/88849) [`45f940ac839e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/45f940ac839e) - [ux] Deprecate ActionName.ViewAction for FlexibleCard and remove usage except for public API
14
+
3
15
  ## 26.53.0
4
16
 
5
17
  ### Minor Changes
@@ -22,7 +22,7 @@ var ANALYTICS_CHANNEL = exports.ANALYTICS_CHANNEL = 'media';
22
22
  var context = exports.context = {
23
23
  componentName: 'smart-cards',
24
24
  packageName: "@atlaskit/smart-card",
25
- packageVersion: "26.53.0"
25
+ packageVersion: "26.55.0"
26
26
  };
27
27
  var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
28
28
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -5,12 +5,14 @@ var _typeof = require("@babel/runtime/helpers/typeof");
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.sleep = exports.openUrl = exports.isSpecialKey = exports.isSpecialEvent = exports.isSpecialClick = exports.isIntersectionObserverSupported = exports.isIframe = exports.isCardWithData = exports.importWithRetry = exports.handleOnClick = exports.getLabelForFileType = exports.getIframeSandboxAttribute = exports.getIconForFileType = exports.downloadUrl = exports.combineFrameStyle = void 0;
8
+ exports.sleep = exports.openUrl = exports.isSpecialKey = exports.isSpecialEvent = exports.isSpecialClick = exports.isIntersectionObserverSupported = exports.isIframe = exports.isCardWithData = exports.importWithRetry = exports.handleOnClick = exports.getPreviewUrlWithTheme = exports.getLabelForFileType = exports.getIframeSandboxAttribute = exports.getIconForFileType = exports.downloadUrl = exports.combineFrameStyle = void 0;
9
9
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
10
10
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
11
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
12
  var _react = _interopRequireDefault(require("react"));
13
13
  var _reactLoadable = _interopRequireDefault(require("react-loadable"));
14
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
15
+ var _tokens = require("@atlaskit/tokens");
14
16
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
15
17
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
18
  var isCardWithData = exports.isCardWithData = function isCardWithData(props) {
@@ -464,4 +466,17 @@ var combineFrameStyle = exports.combineFrameStyle = function combineFrameStyle(f
464
466
  if (isFrameVisible) {
465
467
  return 'show';
466
468
  }
469
+ };
470
+
471
+ /**
472
+ * Append a theme to the URL if it exists
473
+ * @param previewUrl
474
+ * @param themeState
475
+ */
476
+ var getPreviewUrlWithTheme = exports.getPreviewUrlWithTheme = function getPreviewUrlWithTheme(previewUrl, themeState) {
477
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.enable-theme-state-url')) {
478
+ var themeStateQueryString = encodeURIComponent((0, _tokens.themeObjectToString)(themeState));
479
+ return "".concat(previewUrl).concat(previewUrl.includes('?') ? '&' : '?', "themeState=").concat(themeStateQueryString);
480
+ }
481
+ return "".concat(previewUrl).concat(previewUrl.includes('?') ? '&' : '?', "themeMode=").concat(themeState.colorMode);
467
482
  };
@@ -50,9 +50,6 @@ var FlexibleResolvedView = function FlexibleResolvedView(_ref) {
50
50
  }, {
51
51
  name: _constants.ActionName.PreviewAction,
52
52
  hideIcon: true
53
- }, {
54
- name: _constants.ActionName.ViewAction,
55
- hideIcon: true
56
53
  }, {
57
54
  name: _constants.ActionName.DownloadAction,
58
55
  hideIcon: true
@@ -12,6 +12,7 @@ var _ExpandedFrame = require("../components/ExpandedFrame");
12
12
  var _ImageIcon = require("../components/ImageIcon");
13
13
  var _Frame = require("../components/Frame");
14
14
  var _tokens = require("@atlaskit/tokens");
15
+ var _utils = require("../../../utils");
15
16
  /** @jsx jsx */
16
17
 
17
18
  var EmbedCardResolvedView = exports.EmbedCardResolvedView = /*#__PURE__*/_react2.default.forwardRef(function (_ref, embedIframeRef) {
@@ -48,11 +49,11 @@ var EmbedCardResolvedView = exports.EmbedCardResolvedView = /*#__PURE__*/_react2
48
49
  default: linkGlyph
49
50
  });
50
51
  }, [src, linkGlyph, iconFromContext]);
51
- var _useThemeObserver = (0, _tokens.useThemeObserver)(),
52
- colorMode = _useThemeObserver.colorMode;
52
+ var themeState = (0, _tokens.useThemeObserver)();
53
+ var colorMode = themeState === null || themeState === void 0 ? void 0 : themeState.colorMode;
53
54
  var previewUrl = preview === null || preview === void 0 ? void 0 : preview.src;
54
55
  if (previewUrl && isSupportTheming && colorMode) {
55
- previewUrl = "".concat(previewUrl).concat(previewUrl.includes('?') ? '&' : '?', "themeMode=").concat(colorMode);
56
+ previewUrl = (0, _utils.getPreviewUrlWithTheme)(previewUrl, themeState);
56
57
  }
57
58
  return (0, _react.jsx)(_ExpandedFrame.ExpandedFrame, {
58
59
  isSelected: isSelected,
@@ -92,8 +92,8 @@ var EmbedModal = function EmbedModal(_ref) {
92
92
  });
93
93
  }
94
94
  }, [onResize, width]);
95
- var _useThemeObserver = (0, _tokens.useThemeObserver)(),
96
- colorMode = _useThemeObserver.colorMode;
95
+ var themeState = (0, _tokens.useThemeObserver)();
96
+ var colorMode = themeState === null || themeState === void 0 ? void 0 : themeState.colorMode;
97
97
  var previewUrl = src;
98
98
  var handleOnViewActionClick = (0, _react.useCallback)(function () {
99
99
  invoke({
@@ -144,7 +144,7 @@ var EmbedModal = function EmbedModal(_ref) {
144
144
  });
145
145
  }, [download, extensionKey, invoke]);
146
146
  if (previewUrl && isSupportTheming && colorMode) {
147
- previewUrl = "".concat(previewUrl).concat(previewUrl.includes('?') ? '&' : '?', "themeMode=").concat(colorMode);
147
+ previewUrl = (0, _utils.getPreviewUrlWithTheme)(previewUrl, themeState);
148
148
  }
149
149
  return /*#__PURE__*/_react.default.createElement(_modalDialog.ModalTransition, null, isOpen && /*#__PURE__*/_react.default.createElement(_modalDialog.default, {
150
150
  height: "100%",
@@ -40,18 +40,9 @@ Object.defineProperty(exports, "PreviewAction", {
40
40
  return _previewAction.default;
41
41
  }
42
42
  });
43
- exports.ViewAction = void 0;
44
- var _constants = require("../../../../constants");
45
- var _utils = require("./utils");
46
43
  var _action = _interopRequireDefault(require("./action"));
47
44
  var _deleteAction = _interopRequireDefault(require("./delete-action"));
48
45
  var _editAction = _interopRequireDefault(require("./edit-action"));
49
46
  var _downloadAction = _interopRequireDefault(require("./download-action"));
50
47
  var _followAction = _interopRequireDefault(require("./follow-action"));
51
- var _previewAction = _interopRequireDefault(require("./preview-action"));
52
- /**
53
- * Creates a ViewAction component. Accepts default ViewActionProps, and defaults
54
- * to the text 'View' inside the button.
55
- * @see Action
56
- */
57
- var ViewAction = exports.ViewAction = (0, _utils.createDataAction)(_constants.ActionName.ViewAction);
48
+ var _previewAction = _interopRequireDefault(require("./preview-action"));
@@ -39,7 +39,7 @@ var ActionBlock = function ActionBlock(_ref) {
39
39
  arr.sort(sort);
40
40
  }
41
41
  return arr.map(function (name) {
42
- var Action = Actions[name];
42
+ var Action = name in Actions ? Actions[name] : undefined;
43
43
  return Action ? /*#__PURE__*/_react.default.createElement(Action, {
44
44
  as: "stack-item",
45
45
  spaceInline: spaceInline,
@@ -47,15 +47,7 @@ var ActionBlock = function ActionBlock(_ref) {
47
47
  onClick: function onClick() {
48
48
  return onClickCallback === null || onClickCallback === void 0 ? void 0 : onClickCallback(name);
49
49
  },
50
- size: size
51
- // Remove url once ViewAction is retired.
52
- // This seems to be a typescript workaround
53
- // because ViewAction marks it as required,
54
- // which does not reflect actual implementation as the url
55
- // came from data context and not all actions require url.
56
- // https://product-fabric.atlassian.net/browse/EDM-9547
57
- ,
58
- url: "",
50
+ size: size,
59
51
  xcss: (0, _primitives.xcss)({
60
52
  paddingInline: padding
61
53
  })
@@ -38,7 +38,7 @@ var ActionGroupItem = function ActionGroupItem(_ref) {
38
38
  onClick();
39
39
  }
40
40
  }, [onActionItemClick, onClick]);
41
- var Action = Actions[name];
41
+ var Action = name in Actions ? Actions[name] : undefined;
42
42
  if (!Action) {
43
43
  return null;
44
44
  }
@@ -49,15 +49,7 @@ var ActionGroupItem = function ActionGroupItem(_ref) {
49
49
  if (hideIcon) {
50
50
  actionProps.icon = undefined;
51
51
  }
52
- return (0, _react.jsx)(Action
53
- // Remove url once ViewAction is retired.
54
- // This seems to be a typescript workaround
55
- // because ViewAction marks it as required,
56
- // which does not reflect actual implementation as the url
57
- // came from data context and not all actions require url.
58
- // https://product-fabric.atlassian.net/browse/EDM-9547
59
- , (0, _extends2.default)({
60
- url: "",
52
+ return (0, _react.jsx)(Action, (0, _extends2.default)({
61
53
  asDropDownItem: asDropDownItems,
62
54
  size: size,
63
55
  appearance: appearance,
@@ -107,20 +107,18 @@ var filterActionItems = exports.filterActionItems = function filterActionItems()
107
107
  var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
108
108
  var context = arguments.length > 1 ? arguments[1] : undefined;
109
109
  return items.filter(function (item) {
110
- var _context$actions;
111
110
  switch (item.name) {
112
111
  case _constants.ActionName.DeleteAction:
113
112
  case _constants.ActionName.EditAction:
114
113
  case _constants.ActionName.CustomAction:
115
114
  // Named and custom actions that user defines.
116
115
  return Boolean(_constants.ActionName[item.name]);
117
- // Remove once ViewAction is retired
118
- // https://product-fabric.atlassian.net/browse/EDM-9547
119
- case _constants.ActionName.ViewAction:
120
- return Boolean(context === null || context === void 0 ? void 0 : context.viewAction);
121
116
  default:
122
117
  // Action that require data from the data context to render.
123
- return Boolean(context === null || context === void 0 || (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[item.name]);
118
+ if ((context === null || context === void 0 ? void 0 : context.actions) === undefined) {
119
+ return false;
120
+ }
121
+ return Boolean(item.name in context.actions ? context.actions[item.name] : undefined);
124
122
  }
125
123
  });
126
124
  };
@@ -17,7 +17,7 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId"],
17
17
  _excluded2 = ["isLinkSafe", "showSafetyWarningModal"];
18
18
  var PACKAGE_DATA = {
19
19
  packageName: "@atlaskit/smart-card",
20
- packageVersion: "26.53.0",
20
+ packageVersion: "26.55.0",
21
21
  componentName: 'linkUrl'
22
22
  };
23
23
  var Link = (0, _click.withLinkClickedEvent)('a');
@@ -4,7 +4,7 @@ export const ANALYTICS_CHANNEL = 'media';
4
4
  export const context = {
5
5
  componentName: 'smart-cards',
6
6
  packageName: "@atlaskit/smart-card",
7
- packageVersion: "26.53.0"
7
+ packageVersion: "26.55.0"
8
8
  };
9
9
  export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -1,5 +1,7 @@
1
1
  import React from 'react';
2
2
  import Loadable from 'react-loadable';
3
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
4
+ import { themeObjectToString } from '@atlaskit/tokens';
3
5
  export const isCardWithData = props => !!props.data;
4
6
  export const isSpecialEvent = evt => evt.isDefaultPrevented() && (isIframe() || isSpecialKey(evt) || isSpecialClick(evt));
5
7
  export const isIframe = () => window.parent !== parent;
@@ -167,4 +169,17 @@ export const combineFrameStyle = (frameStyle, isFrameVisible) => {
167
169
  if (isFrameVisible) {
168
170
  return 'show';
169
171
  }
172
+ };
173
+
174
+ /**
175
+ * Append a theme to the URL if it exists
176
+ * @param previewUrl
177
+ * @param themeState
178
+ */
179
+ export const getPreviewUrlWithTheme = (previewUrl, themeState) => {
180
+ if (getBooleanFF('platform.linking-platform.smart-card.enable-theme-state-url')) {
181
+ const themeStateQueryString = encodeURIComponent(themeObjectToString(themeState));
182
+ return `${previewUrl}${previewUrl.includes('?') ? '&' : '?'}themeState=${themeStateQueryString}`;
183
+ }
184
+ return `${previewUrl}${previewUrl.includes('?') ? '&' : '?'}themeMode=${themeState.colorMode}`;
170
185
  };
@@ -36,9 +36,6 @@ const FlexibleResolvedView = ({
36
36
  }, {
37
37
  name: ActionName.PreviewAction,
38
38
  hideIcon: true
39
- }, {
40
- name: ActionName.ViewAction,
41
- hideIcon: true
42
39
  }, {
43
40
  name: ActionName.DownloadAction,
44
41
  hideIcon: true
@@ -6,6 +6,7 @@ import { ExpandedFrame } from '../components/ExpandedFrame';
6
6
  import { ImageIcon } from '../components/ImageIcon';
7
7
  import { Frame } from '../components/Frame';
8
8
  import { useThemeObserver } from '@atlaskit/tokens';
9
+ import { getPreviewUrlWithTheme } from '../../../utils';
9
10
  export const EmbedCardResolvedView = /*#__PURE__*/React.forwardRef(({
10
11
  link,
11
12
  context,
@@ -38,12 +39,11 @@ export const EmbedCardResolvedView = /*#__PURE__*/React.forwardRef(({
38
39
  default: linkGlyph
39
40
  });
40
41
  }, [src, linkGlyph, iconFromContext]);
41
- const {
42
- colorMode
43
- } = useThemeObserver();
42
+ const themeState = useThemeObserver();
43
+ const colorMode = themeState === null || themeState === void 0 ? void 0 : themeState.colorMode;
44
44
  let previewUrl = preview === null || preview === void 0 ? void 0 : preview.src;
45
45
  if (previewUrl && isSupportTheming && colorMode) {
46
- previewUrl = `${previewUrl}${previewUrl.includes('?') ? '&' : '?'}themeMode=${colorMode}`;
46
+ previewUrl = getPreviewUrlWithTheme(previewUrl, themeState);
47
47
  }
48
48
  return jsx(ExpandedFrame, {
49
49
  isSelected: isSelected,
@@ -9,7 +9,7 @@ import withAnalytics from './components/analytics';
9
9
  import { useThemeObserver } from '@atlaskit/tokens';
10
10
  import useInvokeClientAction from '../../state/hooks/use-invoke-client-action';
11
11
  import { ActionName, CardDisplay } from '../../constants';
12
- import { downloadUrl, openUrl } from '../../utils';
12
+ import { downloadUrl, getPreviewUrlWithTheme, openUrl } from '../../utils';
13
13
  const toSize = width => width === MAX_MODAL_SIZE ? EmbedModalSize.Large : EmbedModalSize.Small;
14
14
  const toWidth = size => size === EmbedModalSize.Large ? MAX_MODAL_SIZE : MIN_MODAL_SIZE;
15
15
  const EmbedModal = ({
@@ -65,9 +65,8 @@ const EmbedModal = ({
65
65
  });
66
66
  }
67
67
  }, [onResize, width]);
68
- const {
69
- colorMode
70
- } = useThemeObserver();
68
+ const themeState = useThemeObserver();
69
+ const colorMode = themeState === null || themeState === void 0 ? void 0 : themeState.colorMode;
71
70
  let previewUrl = src;
72
71
  const handleOnViewActionClick = useCallback(() => {
73
72
  invoke({
@@ -86,7 +85,7 @@ const EmbedModal = ({
86
85
  });
87
86
  }, [download, extensionKey, invoke]);
88
87
  if (previewUrl && isSupportTheming && colorMode) {
89
- previewUrl = `${previewUrl}${previewUrl.includes('?') ? '&' : '?'}themeMode=${colorMode}`;
88
+ previewUrl = getPreviewUrlWithTheme(previewUrl, themeState);
90
89
  }
91
90
  return /*#__PURE__*/React.createElement(ModalTransition, null, isOpen && /*#__PURE__*/React.createElement(ModalDialog, {
92
91
  height: "100%",
@@ -1,15 +1,6 @@
1
- import { ActionName } from '../../../../constants';
2
- import { createDataAction } from './utils';
3
1
  export { default as CustomAction } from './action';
4
2
  export { default as DeleteAction } from './delete-action';
5
3
  export { default as EditAction } from './edit-action';
6
4
  export { default as DownloadAction } from './download-action';
7
5
  export { default as FollowAction } from './follow-action';
8
- export { default as PreviewAction } from './preview-action';
9
-
10
- /**
11
- * Creates a ViewAction component. Accepts default ViewActionProps, and defaults
12
- * to the text 'View' inside the button.
13
- * @see Action
14
- */
15
- export const ViewAction = createDataAction(ActionName.ViewAction);
6
+ export { default as PreviewAction } from './preview-action';
@@ -30,21 +30,13 @@ const ActionBlock = ({
30
30
  arr.sort(sort);
31
31
  }
32
32
  return arr.map(name => {
33
- const Action = Actions[name];
33
+ const Action = name in Actions ? Actions[name] : undefined;
34
34
  return Action ? /*#__PURE__*/React.createElement(Action, {
35
35
  as: "stack-item",
36
36
  spaceInline: spaceInline,
37
37
  key: name,
38
38
  onClick: () => onClickCallback === null || onClickCallback === void 0 ? void 0 : onClickCallback(name),
39
- size: size
40
- // Remove url once ViewAction is retired.
41
- // This seems to be a typescript workaround
42
- // because ViewAction marks it as required,
43
- // which does not reflect actual implementation as the url
44
- // came from data context and not all actions require url.
45
- // https://product-fabric.atlassian.net/browse/EDM-9547
46
- ,
47
- url: "",
39
+ size: size,
48
40
  xcss: xcss({
49
41
  paddingInline: padding
50
42
  })
@@ -26,7 +26,7 @@ const ActionGroupItem = ({
26
26
  onClick();
27
27
  }
28
28
  }, [onActionItemClick, onClick]);
29
- const Action = Actions[name];
29
+ const Action = name in Actions ? Actions[name] : undefined;
30
30
  if (!Action) {
31
31
  return null;
32
32
  }
@@ -39,15 +39,7 @@ const ActionGroupItem = ({
39
39
  if (hideIcon) {
40
40
  actionProps.icon = undefined;
41
41
  }
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({
50
- url: "",
42
+ return jsx(Action, _extends({
51
43
  asDropDownItem: asDropDownItems,
52
44
  size: size,
53
45
  appearance: appearance,
@@ -129,20 +129,18 @@ export const getActionGroupStyles = size => {
129
129
  };
130
130
  export const filterActionItems = (items = [], context) => {
131
131
  return items.filter(item => {
132
- var _context$actions;
133
132
  switch (item.name) {
134
133
  case ActionName.DeleteAction:
135
134
  case ActionName.EditAction:
136
135
  case ActionName.CustomAction:
137
136
  // Named and custom actions that user defines.
138
137
  return Boolean(ActionName[item.name]);
139
- // Remove once ViewAction is retired
140
- // https://product-fabric.atlassian.net/browse/EDM-9547
141
- case ActionName.ViewAction:
142
- return Boolean(context === null || context === void 0 ? void 0 : context.viewAction);
143
138
  default:
144
139
  // Action that require data from the data context to render.
145
- return Boolean(context === null || context === void 0 ? void 0 : (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[item.name]);
140
+ if ((context === null || context === void 0 ? void 0 : context.actions) === undefined) {
141
+ return false;
142
+ }
143
+ return Boolean(item.name in context.actions ? context.actions[item.name] : undefined);
146
144
  }
147
145
  });
148
146
  };
@@ -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.53.0",
10
+ packageVersion: "26.55.0",
11
11
  componentName: 'linkUrl'
12
12
  };
13
13
  const Link = withLinkClickedEvent('a');
@@ -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.53.0"
18
+ packageVersion: "26.55.0"
19
19
  };
20
20
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
21
21
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -3,6 +3,8 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
4
4
  import React from 'react';
5
5
  import Loadable from 'react-loadable';
6
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
7
+ import { themeObjectToString } from '@atlaskit/tokens';
6
8
  export var isCardWithData = function isCardWithData(props) {
7
9
  return !!props.data;
8
10
  };
@@ -354,4 +356,17 @@ export var combineFrameStyle = function combineFrameStyle(frameStyle, isFrameVis
354
356
  if (isFrameVisible) {
355
357
  return 'show';
356
358
  }
359
+ };
360
+
361
+ /**
362
+ * Append a theme to the URL if it exists
363
+ * @param previewUrl
364
+ * @param themeState
365
+ */
366
+ export var getPreviewUrlWithTheme = function getPreviewUrlWithTheme(previewUrl, themeState) {
367
+ if (getBooleanFF('platform.linking-platform.smart-card.enable-theme-state-url')) {
368
+ var themeStateQueryString = encodeURIComponent(themeObjectToString(themeState));
369
+ return "".concat(previewUrl).concat(previewUrl.includes('?') ? '&' : '?', "themeState=").concat(themeStateQueryString);
370
+ }
371
+ return "".concat(previewUrl).concat(previewUrl.includes('?') ? '&' : '?', "themeMode=").concat(themeState.colorMode);
357
372
  };
@@ -40,9 +40,6 @@ var FlexibleResolvedView = function FlexibleResolvedView(_ref) {
40
40
  }, {
41
41
  name: ActionName.PreviewAction,
42
42
  hideIcon: true
43
- }, {
44
- name: ActionName.ViewAction,
45
- hideIcon: true
46
43
  }, {
47
44
  name: ActionName.DownloadAction,
48
45
  hideIcon: true
@@ -6,6 +6,7 @@ import { ExpandedFrame } from '../components/ExpandedFrame';
6
6
  import { ImageIcon } from '../components/ImageIcon';
7
7
  import { Frame } from '../components/Frame';
8
8
  import { useThemeObserver } from '@atlaskit/tokens';
9
+ import { getPreviewUrlWithTheme } from '../../../utils';
9
10
  export var EmbedCardResolvedView = /*#__PURE__*/React.forwardRef(function (_ref, embedIframeRef) {
10
11
  var link = _ref.link,
11
12
  context = _ref.context,
@@ -40,11 +41,11 @@ export var EmbedCardResolvedView = /*#__PURE__*/React.forwardRef(function (_ref,
40
41
  default: linkGlyph
41
42
  });
42
43
  }, [src, linkGlyph, iconFromContext]);
43
- var _useThemeObserver = useThemeObserver(),
44
- colorMode = _useThemeObserver.colorMode;
44
+ var themeState = useThemeObserver();
45
+ var colorMode = themeState === null || themeState === void 0 ? void 0 : themeState.colorMode;
45
46
  var previewUrl = preview === null || preview === void 0 ? void 0 : preview.src;
46
47
  if (previewUrl && isSupportTheming && colorMode) {
47
- previewUrl = "".concat(previewUrl).concat(previewUrl.includes('?') ? '&' : '?', "themeMode=").concat(colorMode);
48
+ previewUrl = getPreviewUrlWithTheme(previewUrl, themeState);
48
49
  }
49
50
  return jsx(ExpandedFrame, {
50
51
  isSelected: isSelected,
@@ -12,7 +12,7 @@ import withAnalytics from './components/analytics';
12
12
  import { useThemeObserver } from '@atlaskit/tokens';
13
13
  import useInvokeClientAction from '../../state/hooks/use-invoke-client-action';
14
14
  import { ActionName, CardDisplay } from '../../constants';
15
- import { downloadUrl, openUrl } from '../../utils';
15
+ import { downloadUrl, getPreviewUrlWithTheme, openUrl } from '../../utils';
16
16
  var toSize = function toSize(width) {
17
17
  return width === MAX_MODAL_SIZE ? EmbedModalSize.Large : EmbedModalSize.Small;
18
18
  };
@@ -82,8 +82,8 @@ var EmbedModal = function EmbedModal(_ref) {
82
82
  });
83
83
  }
84
84
  }, [onResize, width]);
85
- var _useThemeObserver = useThemeObserver(),
86
- colorMode = _useThemeObserver.colorMode;
85
+ var themeState = useThemeObserver();
86
+ var colorMode = themeState === null || themeState === void 0 ? void 0 : themeState.colorMode;
87
87
  var previewUrl = src;
88
88
  var handleOnViewActionClick = useCallback(function () {
89
89
  invoke({
@@ -134,7 +134,7 @@ var EmbedModal = function EmbedModal(_ref) {
134
134
  });
135
135
  }, [download, extensionKey, invoke]);
136
136
  if (previewUrl && isSupportTheming && colorMode) {
137
- previewUrl = "".concat(previewUrl).concat(previewUrl.includes('?') ? '&' : '?', "themeMode=").concat(colorMode);
137
+ previewUrl = getPreviewUrlWithTheme(previewUrl, themeState);
138
138
  }
139
139
  return /*#__PURE__*/React.createElement(ModalTransition, null, isOpen && /*#__PURE__*/React.createElement(ModalDialog, {
140
140
  height: "100%",
@@ -1,15 +1,6 @@
1
- import { ActionName } from '../../../../constants';
2
- import { createDataAction } from './utils';
3
1
  export { default as CustomAction } from './action';
4
2
  export { default as DeleteAction } from './delete-action';
5
3
  export { default as EditAction } from './edit-action';
6
4
  export { default as DownloadAction } from './download-action';
7
5
  export { default as FollowAction } from './follow-action';
8
- export { default as PreviewAction } from './preview-action';
9
-
10
- /**
11
- * Creates a ViewAction component. Accepts default ViewActionProps, and defaults
12
- * to the text 'View' inside the button.
13
- * @see Action
14
- */
15
- export var ViewAction = createDataAction(ActionName.ViewAction);
6
+ export { default as PreviewAction } from './preview-action';
@@ -30,7 +30,7 @@ var ActionBlock = function ActionBlock(_ref) {
30
30
  arr.sort(sort);
31
31
  }
32
32
  return arr.map(function (name) {
33
- var Action = Actions[name];
33
+ var Action = name in Actions ? Actions[name] : undefined;
34
34
  return Action ? /*#__PURE__*/React.createElement(Action, {
35
35
  as: "stack-item",
36
36
  spaceInline: spaceInline,
@@ -38,15 +38,7 @@ var ActionBlock = function ActionBlock(_ref) {
38
38
  onClick: function onClick() {
39
39
  return onClickCallback === null || onClickCallback === void 0 ? void 0 : onClickCallback(name);
40
40
  },
41
- size: size
42
- // Remove url once ViewAction is retired.
43
- // This seems to be a typescript workaround
44
- // because ViewAction marks it as required,
45
- // which does not reflect actual implementation as the url
46
- // came from data context and not all actions require url.
47
- // https://product-fabric.atlassian.net/browse/EDM-9547
48
- ,
49
- url: "",
41
+ size: size,
50
42
  xcss: xcss({
51
43
  paddingInline: padding
52
44
  })
@@ -28,7 +28,7 @@ var ActionGroupItem = function ActionGroupItem(_ref) {
28
28
  onClick();
29
29
  }
30
30
  }, [onActionItemClick, onClick]);
31
- var Action = Actions[name];
31
+ var Action = name in Actions ? Actions[name] : undefined;
32
32
  if (!Action) {
33
33
  return null;
34
34
  }
@@ -39,15 +39,7 @@ var ActionGroupItem = function ActionGroupItem(_ref) {
39
39
  if (hideIcon) {
40
40
  actionProps.icon = undefined;
41
41
  }
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({
50
- url: "",
42
+ return jsx(Action, _extends({
51
43
  asDropDownItem: asDropDownItems,
52
44
  size: size,
53
45
  appearance: appearance,
@@ -98,20 +98,18 @@ export var filterActionItems = function filterActionItems() {
98
98
  var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
99
99
  var context = arguments.length > 1 ? arguments[1] : undefined;
100
100
  return items.filter(function (item) {
101
- var _context$actions;
102
101
  switch (item.name) {
103
102
  case ActionName.DeleteAction:
104
103
  case ActionName.EditAction:
105
104
  case ActionName.CustomAction:
106
105
  // Named and custom actions that user defines.
107
106
  return Boolean(ActionName[item.name]);
108
- // Remove once ViewAction is retired
109
- // https://product-fabric.atlassian.net/browse/EDM-9547
110
- case ActionName.ViewAction:
111
- return Boolean(context === null || context === void 0 ? void 0 : context.viewAction);
112
107
  default:
113
108
  // Action that require data from the data context to render.
114
- return Boolean(context === null || context === void 0 || (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[item.name]);
109
+ if ((context === null || context === void 0 ? void 0 : context.actions) === undefined) {
110
+ return false;
111
+ }
112
+ return Boolean(item.name in context.actions ? context.actions[item.name] : undefined);
115
113
  }
116
114
  });
117
115
  };