@atlaskit/smart-card 26.54.0 → 26.55.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 26.55.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#90546](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/90546) [`e3e2542b4963`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e3e2542b4963) - Update TypeScript type parameters when using `FormattedMessage` from `react-intl` to improve compatibility with React 18
8
+
9
+ ## 26.55.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#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`
14
+
3
15
  ## 26.54.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.54.0"
25
+ packageVersion: "26.55.1"
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
  };
@@ -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%",
@@ -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.54.0",
20
+ packageVersion: "26.55.1",
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.54.0"
7
+ packageVersion: "26.55.1"
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
  };
@@ -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%",
@@ -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.54.0",
10
+ packageVersion: "26.55.1",
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.54.0"
18
+ packageVersion: "26.55.1"
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
  };
@@ -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%",
@@ -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.54.0",
13
+ packageVersion: "26.55.1",
14
14
  componentName: 'linkUrl'
15
15
  };
16
16
  var Link = withLinkClickedEvent('a');
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { CardProps } from '../view/Card';
3
3
  import { FrameStyle } from '../view/EmbedCard/types';
4
+ import { ActiveThemeState } from '@atlaskit/tokens/src/theme-config';
4
5
  export declare const isCardWithData: (props: CardProps) => boolean;
5
6
  export declare const isSpecialEvent: (evt: React.MouseEvent | React.KeyboardEvent) => boolean;
6
7
  export declare const isIframe: () => boolean;
@@ -29,3 +30,9 @@ export declare const openUrl: (url?: string) => Promise<void>;
29
30
  * This function is to be removed on deprecation of isFrameVisible.
30
31
  */
31
32
  export declare const combineFrameStyle: (frameStyle?: CardProps['frameStyle'], isFrameVisible?: CardProps['isFrameVisible']) => FrameStyle | undefined;
33
+ /**
34
+ * Append a theme to the URL if it exists
35
+ * @param previewUrl
36
+ * @param themeState
37
+ */
38
+ export declare const getPreviewUrlWithTheme: (previewUrl: string, themeState: Partial<ActiveThemeState>) => string;
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { CardProps } from '../view/Card';
3
3
  import { FrameStyle } from '../view/EmbedCard/types';
4
+ import { ActiveThemeState } from '@atlaskit/tokens/src/theme-config';
4
5
  export declare const isCardWithData: (props: CardProps) => boolean;
5
6
  export declare const isSpecialEvent: (evt: React.MouseEvent | React.KeyboardEvent) => boolean;
6
7
  export declare const isIframe: () => boolean;
@@ -29,3 +30,9 @@ export declare const openUrl: (url?: string) => Promise<void>;
29
30
  * This function is to be removed on deprecation of isFrameVisible.
30
31
  */
31
32
  export declare const combineFrameStyle: (frameStyle?: CardProps['frameStyle'], isFrameVisible?: CardProps['isFrameVisible']) => FrameStyle | undefined;
33
+ /**
34
+ * Append a theme to the URL if it exists
35
+ * @param previewUrl
36
+ * @param themeState
37
+ */
38
+ export declare const getPreviewUrlWithTheme: (previewUrl: string, themeState: Partial<ActiveThemeState>) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.54.0",
3
+ "version": "26.55.1",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -169,6 +169,9 @@
169
169
  },
170
170
  "platform.linking-platform.smart-card.hover-card-action-redesign": {
171
171
  "type": "boolean"
172
+ },
173
+ "platform.linking-platform.smart-card.enable-theme-state-url": {
174
+ "type": "boolean"
172
175
  }
173
176
  },
174
177
  "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"