@atlaskit/smart-card 46.10.3 → 46.11.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 (33) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/cjs/utils/analytics/analytics.js +1 -1
  3. package/dist/cjs/utils/get-icon-for-file-type.js +14 -0
  4. package/dist/cjs/utils/lazy-component.js +81 -0
  5. package/dist/cjs/view/EmbedCard/views/ResolvedView.js +14 -2
  6. package/dist/cjs/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/header/main.js +1 -9
  7. package/dist/cjs/view/FlexibleCard/components/actions/follow-action/index.js +31 -1
  8. package/dist/cjs/view/FlexibleCard/components/common/atlaskit-icon/index.js +23 -4
  9. package/dist/cjs/view/LinkUrl/index.js +1 -1
  10. package/dist/es2019/utils/analytics/analytics.js +1 -1
  11. package/dist/es2019/utils/get-icon-for-file-type.js +14 -0
  12. package/dist/es2019/utils/lazy-component.js +65 -0
  13. package/dist/es2019/view/EmbedCard/views/ResolvedView.js +10 -2
  14. package/dist/es2019/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/header/main.js +1 -10
  15. package/dist/es2019/view/FlexibleCard/components/actions/follow-action/index.js +21 -1
  16. package/dist/es2019/view/FlexibleCard/components/common/atlaskit-icon/index.js +23 -4
  17. package/dist/es2019/view/LinkUrl/index.js +1 -1
  18. package/dist/esm/utils/analytics/analytics.js +1 -1
  19. package/dist/esm/utils/get-icon-for-file-type.js +14 -0
  20. package/dist/esm/utils/lazy-component.js +73 -0
  21. package/dist/esm/view/EmbedCard/views/ResolvedView.js +12 -2
  22. package/dist/esm/view/FlexibleCard/components/actions/automation-action/automation-manual-triggers/manual-triggers-modal/sub-components/header/main.js +1 -9
  23. package/dist/esm/view/FlexibleCard/components/actions/follow-action/index.js +27 -1
  24. package/dist/esm/view/FlexibleCard/components/common/atlaskit-icon/index.js +23 -4
  25. package/dist/esm/view/LinkUrl/index.js +1 -1
  26. package/dist/types/utils/lazy-component.d.ts +36 -0
  27. package/package.json +6 -6
  28. package/dist/es2019/__tests__/vr-tests/__snapshots__/automation-modal-header/smart-card-automation-modal-header-title--default--platform-dst-modal-dialog-use-modal-title-true.png +0 -3
  29. package/dist/esm/__tests__/vr-tests/__snapshots__/automation-modal-header/smart-card-automation-modal-header-title--default--platform-dst-modal-dialog-use-modal-title-false.png +0 -3
  30. package/dist/esm/__tests__/vr-tests/__snapshots__/automation-modal-header/smart-card-automation-modal-header-title--default--platform-dst-modal-dialog-use-modal-title-true.png +0 -3
  31. /package/dist/cjs/__tests__/vr-tests/__snapshots__/automation-modal-header/{smart-card-automation-modal-header-title--default--platform-dst-modal-dialog-use-modal-title-false.png → smart-card-automation-modal-header-title--default.png} +0 -0
  32. /package/dist/{cjs/__tests__/vr-tests/__snapshots__/automation-modal-header/smart-card-automation-modal-header-title--default--platform-dst-modal-dialog-use-modal-title-true.png → es2019/__tests__/vr-tests/__snapshots__/automation-modal-header/smart-card-automation-modal-header-title--default.png} +0 -0
  33. /package/dist/{es2019/__tests__/vr-tests/__snapshots__/automation-modal-header/smart-card-automation-modal-header-title--default--platform-dst-modal-dialog-use-modal-title-false.png → esm/__tests__/vr-tests/__snapshots__/automation-modal-header/smart-card-automation-modal-header-title--default.png} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 46.11.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`4b0ec5ed92261`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4b0ec5ed92261) -
8
+ Update i18n NPM package versions for linking-platform,smart-experiences (Group 15)
9
+
10
+ ## 46.10.4
11
+
12
+ ### Patch Changes
13
+
14
+ - [`12b24838d8278`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/12b24838d8278) -
15
+ Replace react-loadable with React.lazy and Suspense for lazily loaded icons and the embed Rovo
16
+ actions footer, behind the feature gate platform_sl_replace_react_loadable, for React 19
17
+ compatibility. Loading and load-failure behaviour are unchanged: nothing renders while loading or
18
+ if the chunk fails to load.
19
+
20
+ Once the gate is fully rolled out, remove the react-loadable branches,
21
+ `components/importIcon.tsx`, the local `importIcon` in `get-icon-for-file-type.tsx`, the
22
+ `react-loadable` and `@types/react-loadable` dependencies, and the VR `ignoredErrors` entries for
23
+ react-loadable state update warnings.
24
+
25
+ - Updated dependencies
26
+
3
27
  ## 46.10.3
4
28
 
5
29
  ### Patch Changes
@@ -25,7 +25,7 @@ var ANALYTICS_CHANNEL = exports.ANALYTICS_CHANNEL = 'media';
25
25
  var context = exports.context = {
26
26
  componentName: 'smart-cards',
27
27
  packageName: "@atlaskit/smart-card" || '',
28
- packageVersion: "46.10.2" || ''
28
+ packageVersion: "46.10.4" || ''
29
29
  };
30
30
  var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
31
31
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -8,8 +8,10 @@ exports.getIconForFileType = void 0;
8
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
9
  var _react = _interopRequireDefault(require("react"));
10
10
  var _reactLoadable = _interopRequireDefault(require("react-loadable"));
11
+ var _fg = require("@atlaskit/platform-feature-flags/fg");
11
12
  var _extractFileFormatIcon = _interopRequireDefault(require("../extractors/flexible/icon/extract-file-formatIcon"));
12
13
  var _getLazyIcons = require("./get-lazy-icons");
14
+ var _lazyComponent = require("./lazy-component");
13
15
  var getTypeToIconMap = function getTypeToIconMap(fileFormat) {
14
16
  var _lazyIcons$iconDescri, _iconDescriptor$label;
15
17
  var iconDescriptor = (0, _extractFileFormatIcon.default)(fileFormat);
@@ -32,6 +34,18 @@ var getIconForFileType = exports.getIconForFileType = function getIconForFileTyp
32
34
  if (!importCb) {
33
35
  return;
34
36
  }
37
+ if ((0, _fg.fg)('platform_sl_replace_react_loadable')) {
38
+ var _extractFileFormatIco;
39
+ var iconType = (_extractFileFormatIco = (0, _extractFileFormatIcon.default)(fileMimeType.toLowerCase())) === null || _extractFileFormatIco === void 0 ? void 0 : _extractFileFormatIco.icon;
40
+ if (iconType) {
41
+ var LazyIcon = (0, _lazyComponent.getLazyIconComponent)("".concat(iconType, ":default"), importCb);
42
+ var lazyLabel = (showIconLabel !== null && showIconLabel !== void 0 ? showIconLabel : true) ? icon[1] || '' : '';
43
+ return /*#__PURE__*/_react.default.createElement(LazyIcon, {
44
+ testId: "document-file-format-icon",
45
+ label: lazyLabel
46
+ });
47
+ }
48
+ }
35
49
  var Icon = (0, _reactLoadable.default)({
36
50
  loader: function loader() {
37
51
  return importCb().then(function (module) {
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.withSuspense = exports.renderNothingOnLoadError = exports.getLazyIconComponent = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
10
+ var RenderNothing = function RenderNothing() {
11
+ return null;
12
+ };
13
+
14
+ /**
15
+ * `.catch` handler for a lazy loader: renders nothing if the chunk fails to load, instead of
16
+ * throwing to the nearest error boundary (matches `react-loadable` with `loading: () => null`).
17
+ *
18
+ * @example lazy(() => import('./Foo').catch(renderNothingOnLoadError))
19
+ */
20
+ var renderNothingOnLoadError = exports.renderNothingOnLoadError = function renderNothingOnLoadError() {
21
+ return {
22
+ // Typed as `never` so the fallback is assignable to whatever component type the loader
23
+ // resolves to, and `lazy()` keeps inferring that component's props.
24
+ default: RenderNothing
25
+ };
26
+ };
27
+
28
+ /**
29
+ * Wraps a `React.lazy` component in its own `<Suspense fallback={null}>`, so it renders nothing
30
+ * while its chunk loads and never suspends (and blanks out) an ancestor such as the card itself.
31
+ *
32
+ * Call `lazy(() => import('...'))` inline at module scope and pass the result here, rather than
33
+ * passing a loader into a helper that calls `lazy()` for you. Product SSR tooling (e.g.
34
+ * Confluence's LoadableReactLazyBabelPlugin) only tracks and preloads `lazy()` calls whose loader
35
+ * reads no function parameters or other render-time values.
36
+ */
37
+ var withSuspense = exports.withSuspense = function withSuspense(LazyComponent, displayName) {
38
+ // Typed loosely internally: TS cannot spread generic props onto a LazyExoticComponent.
39
+ // The returned component is still strictly typed as ComponentType<P>.
40
+ var Component = LazyComponent;
41
+ var LazyComponentWithSuspense = function LazyComponentWithSuspense(props) {
42
+ return /*#__PURE__*/_react.default.createElement(_react.Suspense, {
43
+ fallback: null
44
+ }, /*#__PURE__*/_react.default.createElement(Component, props));
45
+ };
46
+ if (displayName) {
47
+ LazyComponentWithSuspense.displayName = displayName;
48
+ }
49
+ return LazyComponentWithSuspense;
50
+ };
51
+ var lazyIconCache = new Map();
52
+
53
+ /**
54
+ * Returns a lazily loaded icon component for a dynamic icon import.
55
+ *
56
+ * Callers resolve the icon on every render, so the component is cached by `cacheKey` to keep a
57
+ * stable component identity across renders (otherwise React would remount and re-suspend the
58
+ * icon on every render). The cache entry is dropped if the chunk fails to load, so the next
59
+ * render retries the import.
60
+ *
61
+ * Prefer an inline module-scope `lazy(() => import('...'))` with `withSuspense` where the set of
62
+ * components is known up front, so product SSR tooling can preload the chunks. This helper is a
63
+ * deliberate exception for open-ended icon sets (any Atlaskit icon / file type) that cannot be
64
+ * enumerated statically: its loader reads render-time values, so SSR tooling cannot preload it.
65
+ *
66
+ * @param cacheKey Must uniquely identify the module `importFn` resolves to.
67
+ */
68
+ var getLazyIconComponent = exports.getLazyIconComponent = function getLazyIconComponent(cacheKey, importFn) {
69
+ var cached = lazyIconCache.get(cacheKey);
70
+ if (cached) {
71
+ return cached;
72
+ }
73
+ var LazyIcon = withSuspense( /*#__PURE__*/(0, _react.lazy)(function () {
74
+ return importFn().catch(function () {
75
+ lazyIconCache.delete(cacheKey);
76
+ return renderNothingOnLoadError();
77
+ });
78
+ }), "lazy(".concat(cacheKey, ")"));
79
+ lazyIconCache.set(cacheKey, LazyIcon);
80
+ return LazyIcon;
81
+ };
@@ -10,7 +10,7 @@ require("./ResolvedView.compiled.css");
10
10
  var _runtime = require("@compiled/react/runtime");
11
11
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
12
12
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
- var _react = _interopRequireDefault(require("react"));
13
+ var _react = _interopRequireWildcard(require("react"));
14
14
  var _reactLoadable = _interopRequireDefault(require("react-loadable"));
15
15
  var _link = _interopRequireDefault(require("@atlaskit/icon/core/link"));
16
16
  var _useSmartLinkContext2 = require("@atlaskit/link-provider/use-smart-link-context");
@@ -24,6 +24,7 @@ var _useEmbedRovoActionsFooterExperiment = _interopRequireDefault(require("../..
24
24
  var _useRovoConfig2 = _interopRequireDefault(require("../../../state/hooks/use-rovo-config"));
25
25
  var _getPreviewUrlWithTheme = require("../../../utils/get-preview-url-with-theme");
26
26
  var _isProfileType = require("../../../utils/is-profile-type");
27
+ var _lazyComponent = require("../../../utils/lazy-component");
27
28
  var _rovoPostAuthPrompts = require("../../common/rovo-post-auth-prompts");
28
29
  var _ExpandedFrame = require("../components/ExpandedFrame");
29
30
  var _Frame = require("../components/Frame");
@@ -43,6 +44,13 @@ var EmbedRovoActionsFooter = (0, _reactLoadable.default)({
43
44
  }
44
45
  });
45
46
  EmbedRovoActionsFooter.displayName = 'lazy(EmbedRovoActionsFooter)';
47
+
48
+ // Inline module-scope lazy() so product SSR tooling can preload it before hydration.
49
+ var LazyEmbedRovoActionsFooter = (0, _lazyComponent.withSuspense)( /*#__PURE__*/(0, _react.lazy)(function () {
50
+ return Promise.resolve().then(function () {
51
+ return _interopRequireWildcard(require( /* webpackChunkName: "smart-card-embed-rovo-actions-footer" */'../components/rovo-actions-footer'));
52
+ }).catch(_lazyComponent.renderNothingOnLoadError);
53
+ }), 'lazy(EmbedRovoActionsFooter)');
46
54
  var styles = {
47
55
  contentWithFooter: "_1e0c1txw _2lx21bp4 _4t3i1osq _1tkeidpf",
48
56
  frameWithFooter: "_16jlkb7n _1tkeidpf",
@@ -80,7 +88,11 @@ var EmbedFrameWithRovoFooter = function EmbedFrameWithRovoFooter(_ref) {
80
88
  });
81
89
  }, [details, isEmbedRovoActionsFooterEnabled]);
82
90
  var footer = _react.default.useMemo(function () {
83
- return rovoActionData && prompts.length > 0 ? /*#__PURE__*/_react.default.createElement(EmbedRovoActionsFooter, {
91
+ return rovoActionData && prompts.length > 0 ? (0, _fg.fg)('platform_sl_replace_react_loadable') ? /*#__PURE__*/_react.default.createElement(LazyEmbedRovoActionsFooter, {
92
+ actionData: rovoActionData,
93
+ prompts: prompts,
94
+ testId: "".concat(testId, "-rovo-actions-footer")
95
+ }) : /*#__PURE__*/_react.default.createElement(EmbedRovoActionsFooter, {
84
96
  actionData: rovoActionData,
85
97
  prompts: prompts,
86
98
  testId: "".concat(testId, "-rovo-actions-footer")
@@ -11,12 +11,9 @@ require("./main.compiled.css");
11
11
  var React = _interopRequireWildcard(require("react"));
12
12
  var _runtime = require("@compiled/react/runtime");
13
13
  var _reactIntl = require("react-intl");
14
- var _heading = _interopRequireDefault(require("@atlaskit/heading/heading"));
15
14
  var _automation = _interopRequireDefault(require("@atlaskit/icon/core/automation"));
16
- var _hooks = require("@atlaskit/modal-dialog/hooks");
17
15
  var _modalHeader = _interopRequireDefault(require("@atlaskit/modal-dialog/modal-header"));
18
16
  var _modalTitle = _interopRequireDefault(require("@atlaskit/modal-dialog/modal-title"));
19
- var _fg = require("@atlaskit/platform-feature-flags/fg");
20
17
  var _box = require("@atlaskit/primitives/compiled/box");
21
18
  var _inline = require("@atlaskit/primitives/compiled/inline");
22
19
  var _stack = require("@atlaskit/primitives/compiled/stack");
@@ -41,8 +38,6 @@ var AutomationModalHeader = exports.AutomationModalHeader = function AutomationM
41
38
  var _useAutomationMenu = (0, _useAutomationMenu2.useAutomationMenu)(),
42
39
  initialised = _useAutomationMenu.initialised,
43
40
  rules = _useAutomationMenu.rules;
44
- var _useModal = (0, _hooks.useModal)(),
45
- titleId = _useModal.titleId;
46
41
  var showDescription = initialised && rules.length > 0 && !!modalDescription;
47
42
  return /*#__PURE__*/React.createElement(_modalHeader.default, {
48
43
  hasCloseButton: true
@@ -58,10 +53,7 @@ var AutomationModalHeader = exports.AutomationModalHeader = function AutomationM
58
53
  label: formatMessage(i18n.modalHeaderIconLabel),
59
54
  color: "var(--ds-icon-accent-green, #22A06B)",
60
55
  spacing: "compact"
61
- })), (0, _fg.fg)('platform_dst_modal-dialog-use-modal-title') ? /*#__PURE__*/React.createElement(_modalTitle.default, null, modalTitle) : /*#__PURE__*/React.createElement(_heading.default, {
62
- size: "medium",
63
- id: titleId
64
- }, modalTitle)), showDescription && /*#__PURE__*/React.createElement(_box.Box, {
56
+ })), /*#__PURE__*/React.createElement(_modalTitle.default, null, modalTitle)), showDescription && /*#__PURE__*/React.createElement(_box.Box, {
65
57
  xcss: styles.modalDescriptionStyle
66
58
  }, modalDescription)));
67
59
  };
@@ -8,12 +8,14 @@ exports.default = void 0;
8
8
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
9
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
10
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
- var _react = _interopRequireDefault(require("react"));
11
+ var _react = _interopRequireWildcard(require("react"));
12
12
  var _reactIntl = require("react-intl");
13
13
  var _featureGates = _interopRequireDefault(require("@atlaskit/feature-gate-js-client/feature-gates"));
14
+ var _fg = require("@atlaskit/platform-feature-flags/fg");
14
15
  var _constants = require("../../../../../constants");
15
16
  var _messages = require("../../../../../messages");
16
17
  var _useFlexibleUiContext = require("../../../../../state/flexible-ui-context/useFlexibleUiContext");
18
+ var _lazyComponent = require("../../../../../utils/lazy-component");
17
19
  var _importIcon = require("../../importIcon");
18
20
  var _serverAction = _interopRequireDefault(require("../action/server-action"));
19
21
  var _utils = require("./utils");
@@ -41,7 +43,35 @@ var importIconMapper = {
41
43
  });
42
44
  }
43
45
  };
46
+
47
+ // Inline module-scope lazy() calls so product SSR tooling can preload them before hydration.
48
+ var lazyIconMapper = {
49
+ goal: (0, _lazyComponent.withSuspense)( /*#__PURE__*/(0, _react.lazy)(function () {
50
+ return Promise.resolve().then(function () {
51
+ return _interopRequireWildcard(require( /* webpackChunkName: "glyphGoal" */'./goal-icon'));
52
+ }).then(function (_ref3) {
53
+ var GoalIcon = _ref3.GoalIcon;
54
+ return {
55
+ default: GoalIcon
56
+ };
57
+ }).catch(_lazyComponent.renderNothingOnLoadError);
58
+ }), 'lazy(GoalIcon)'),
59
+ projects: (0, _lazyComponent.withSuspense)( /*#__PURE__*/(0, _react.lazy)(function () {
60
+ return Promise.resolve().then(function () {
61
+ return _interopRequireWildcard(require( /* webpackChunkName: "glyphProjects" */'./projects-icon'));
62
+ }).then(function (_ref4) {
63
+ var ProjectsIcon = _ref4.ProjectsIcon;
64
+ return {
65
+ default: ProjectsIcon
66
+ };
67
+ }).catch(_lazyComponent.renderNothingOnLoadError);
68
+ }), 'lazy(ProjectsIcon)')
69
+ };
44
70
  var getIcon = function getIcon(stackIconType) {
71
+ if ((0, _fg.fg)('platform_sl_replace_react_loadable')) {
72
+ var _lazyIconMapper$stack;
73
+ return (_lazyIconMapper$stack = lazyIconMapper[stackIconType]) !== null && _lazyIconMapper$stack !== void 0 ? _lazyIconMapper$stack : null;
74
+ }
45
75
  var importFn = importIconMapper[stackIconType];
46
76
  if (!importFn) {
47
77
  return null;
@@ -16,6 +16,7 @@ var _transformSmartLinkSizeToIconTileSize = require("../../../../../common/ui/ic
16
16
  var _constants = require("../../../../../constants");
17
17
  var _getLazyIcons = require("../../../../../utils/get-lazy-icons");
18
18
  var _isIconSizeLarge = require("../../../../../utils/is-icon-size-large");
19
+ var _lazyComponent = require("../../../../../utils/lazy-component");
19
20
  var getIconImportFn = function getIconImportFn(icon, size) {
20
21
  var item = (0, _getLazyIcons.getLazyIcons)()[icon];
21
22
  if ((0, _isIconSizeLarge.isIconSizeLarge)(size) && item !== null && item !== void 0 && item.large) {
@@ -23,6 +24,16 @@ var getIconImportFn = function getIconImportFn(icon, size) {
23
24
  }
24
25
  return item === null || item === void 0 ? void 0 : item.default;
25
26
  };
27
+
28
+ // Only used when platform_sl_replace_react_loadable is on. Kept separate from getIconImportFn so
29
+ // the gate-off path is unchanged.
30
+ var getLazyIcon = function getLazyIcon(icon, size) {
31
+ var item = (0, _getLazyIcons.getLazyIcons)()[icon];
32
+ if ((0, _isIconSizeLarge.isIconSizeLarge)(size) && item !== null && item !== void 0 && item.large) {
33
+ return (0, _lazyComponent.getLazyIconComponent)("".concat(icon, ":large"), item.large);
34
+ }
35
+ return item !== null && item !== void 0 && item.default ? (0, _lazyComponent.getLazyIconComponent)("".concat(icon, ":default"), item.default) : undefined;
36
+ };
26
37
  var importIcon = function importIcon(importFn) {
27
38
  return (0, _reactLoadable.default)({
28
39
  loader: function loader() {
@@ -90,11 +101,19 @@ var AtlaskitIcon = function AtlaskitIcon(_ref) {
90
101
  });
91
102
  }
92
103
  }
93
- var importFn = getIconImportFn(icon, size);
94
- if (!importFn) {
95
- return null;
104
+ var ImportedIcon;
105
+ if ((0, _fg.fg)('platform_sl_replace_react_loadable')) {
106
+ ImportedIcon = getLazyIcon(icon, size);
107
+ if (!ImportedIcon) {
108
+ return null;
109
+ }
110
+ } else {
111
+ var importFn = getIconImportFn(icon, size);
112
+ if (!importFn) {
113
+ return null;
114
+ }
115
+ ImportedIcon = importIcon(importFn);
96
116
  }
97
- var ImportedIcon = importIcon(importFn);
98
117
  if (isCoreIcon(icon)) {
99
118
  var color;
100
119
  if (icon === _constants.IconType.Error || icon === _constants.IconType.Forbidden) {
@@ -19,7 +19,7 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId", "isLink
19
19
  _excluded2 = ["isLinkSafe", "showSafetyWarningModal"];
20
20
  var PACKAGE_DATA = {
21
21
  packageName: "@atlaskit/smart-card",
22
- packageVersion: "46.10.2",
22
+ packageVersion: "46.10.4",
23
23
  componentName: 'linkUrl'
24
24
  };
25
25
  var LinkUrl = function LinkUrl(_ref) {
@@ -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: "46.10.2" || ''
7
+ packageVersion: "46.10.4" || ''
8
8
  };
9
9
  export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -1,7 +1,9 @@
1
1
  import React from 'react';
2
2
  import Loadable from 'react-loadable';
3
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
3
4
  import extractFileFormatIcon from '../extractors/flexible/icon/extract-file-formatIcon';
4
5
  import { getLazyIcons } from './get-lazy-icons';
6
+ import { getLazyIconComponent } from './lazy-component';
5
7
  const getTypeToIconMap = fileFormat => {
6
8
  var _lazyIcons$iconDescri, _iconDescriptor$label;
7
9
  const iconDescriptor = extractFileFormatIcon(fileFormat);
@@ -23,6 +25,18 @@ export const getIconForFileType = (fileMimeType, showIconLabel) => {
23
25
  if (!importCb) {
24
26
  return;
25
27
  }
28
+ if (fg('platform_sl_replace_react_loadable')) {
29
+ var _extractFileFormatIco;
30
+ const iconType = (_extractFileFormatIco = extractFileFormatIcon(fileMimeType.toLowerCase())) === null || _extractFileFormatIco === void 0 ? void 0 : _extractFileFormatIco.icon;
31
+ if (iconType) {
32
+ const LazyIcon = getLazyIconComponent(`${iconType}:default`, importCb);
33
+ const lazyLabel = (showIconLabel !== null && showIconLabel !== void 0 ? showIconLabel : true) ? icon[1] || '' : '';
34
+ return /*#__PURE__*/React.createElement(LazyIcon, {
35
+ testId: "document-file-format-icon",
36
+ label: lazyLabel
37
+ });
38
+ }
39
+ }
26
40
  const Icon = Loadable({
27
41
  loader: () => importCb().then(module => module.default),
28
42
  loading: () => null
@@ -0,0 +1,65 @@
1
+ import React, { lazy, Suspense } from 'react';
2
+ const RenderNothing = () => null;
3
+
4
+ /**
5
+ * `.catch` handler for a lazy loader: renders nothing if the chunk fails to load, instead of
6
+ * throwing to the nearest error boundary (matches `react-loadable` with `loading: () => null`).
7
+ *
8
+ * @example lazy(() => import('./Foo').catch(renderNothingOnLoadError))
9
+ */
10
+ export const renderNothingOnLoadError = () => ({
11
+ // Typed as `never` so the fallback is assignable to whatever component type the loader
12
+ // resolves to, and `lazy()` keeps inferring that component's props.
13
+ default: RenderNothing
14
+ });
15
+
16
+ /**
17
+ * Wraps a `React.lazy` component in its own `<Suspense fallback={null}>`, so it renders nothing
18
+ * while its chunk loads and never suspends (and blanks out) an ancestor such as the card itself.
19
+ *
20
+ * Call `lazy(() => import('...'))` inline at module scope and pass the result here, rather than
21
+ * passing a loader into a helper that calls `lazy()` for you. Product SSR tooling (e.g.
22
+ * Confluence's LoadableReactLazyBabelPlugin) only tracks and preloads `lazy()` calls whose loader
23
+ * reads no function parameters or other render-time values.
24
+ */
25
+ export const withSuspense = (LazyComponent, displayName) => {
26
+ // Typed loosely internally: TS cannot spread generic props onto a LazyExoticComponent.
27
+ // The returned component is still strictly typed as ComponentType<P>.
28
+ const Component = LazyComponent;
29
+ const LazyComponentWithSuspense = props => /*#__PURE__*/React.createElement(Suspense, {
30
+ fallback: null
31
+ }, /*#__PURE__*/React.createElement(Component, props));
32
+ if (displayName) {
33
+ LazyComponentWithSuspense.displayName = displayName;
34
+ }
35
+ return LazyComponentWithSuspense;
36
+ };
37
+ const lazyIconCache = new Map();
38
+
39
+ /**
40
+ * Returns a lazily loaded icon component for a dynamic icon import.
41
+ *
42
+ * Callers resolve the icon on every render, so the component is cached by `cacheKey` to keep a
43
+ * stable component identity across renders (otherwise React would remount and re-suspend the
44
+ * icon on every render). The cache entry is dropped if the chunk fails to load, so the next
45
+ * render retries the import.
46
+ *
47
+ * Prefer an inline module-scope `lazy(() => import('...'))` with `withSuspense` where the set of
48
+ * components is known up front, so product SSR tooling can preload the chunks. This helper is a
49
+ * deliberate exception for open-ended icon sets (any Atlaskit icon / file type) that cannot be
50
+ * enumerated statically: its loader reads render-time values, so SSR tooling cannot preload it.
51
+ *
52
+ * @param cacheKey Must uniquely identify the module `importFn` resolves to.
53
+ */
54
+ export const getLazyIconComponent = (cacheKey, importFn) => {
55
+ const cached = lazyIconCache.get(cacheKey);
56
+ if (cached) {
57
+ return cached;
58
+ }
59
+ const LazyIcon = withSuspense( /*#__PURE__*/lazy(() => importFn().catch(() => {
60
+ lazyIconCache.delete(cacheKey);
61
+ return renderNothingOnLoadError();
62
+ })), `lazy(${cacheKey})`);
63
+ lazyIconCache.set(cacheKey, LazyIcon);
64
+ return LazyIcon;
65
+ };
@@ -1,7 +1,7 @@
1
1
  /* ResolvedView.tsx generated by @compiled/babel-plugin v3.0.2 */
2
2
  import "./ResolvedView.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
- import React from 'react';
4
+ import React, { lazy } from 'react';
5
5
  import Loadable from 'react-loadable';
6
6
  import LinkGlyph from '@atlaskit/icon/core/link';
7
7
  import { useSmartLinkContext } from '@atlaskit/link-provider/use-smart-link-context';
@@ -15,6 +15,7 @@ import useEmbedRovoActionsFooterExperiment from '../../../state/hooks/use-embed-
15
15
  import useRovoConfig from '../../../state/hooks/use-rovo-config';
16
16
  import { getPreviewUrlWithEmbedContext } from '../../../utils/get-preview-url-with-theme';
17
17
  import { isProfileType } from '../../../utils/is-profile-type';
18
+ import { renderNothingOnLoadError, withSuspense } from '../../../utils/lazy-component';
18
19
  import { getRovoPostAuthPromptKeys } from '../../common/rovo-post-auth-prompts';
19
20
  import { ExpandedFrame } from '../components/ExpandedFrame';
20
21
  import { Frame } from '../components/Frame';
@@ -25,6 +26,9 @@ const EmbedRovoActionsFooter = Loadable({
25
26
  loading: () => null
26
27
  });
27
28
  EmbedRovoActionsFooter.displayName = 'lazy(EmbedRovoActionsFooter)';
29
+
30
+ // Inline module-scope lazy() so product SSR tooling can preload it before hydration.
31
+ const LazyEmbedRovoActionsFooter = withSuspense( /*#__PURE__*/lazy(() => import( /* webpackChunkName: "smart-card-embed-rovo-actions-footer" */'../components/rovo-actions-footer').catch(renderNothingOnLoadError)), 'lazy(EmbedRovoActionsFooter)');
28
32
  const styles = {
29
33
  contentWithFooter: "_1e0c1txw _2lx21bp4 _4t3i1osq _1tkeidpf",
30
34
  frameWithFooter: "_16jlkb7n _1tkeidpf",
@@ -62,7 +66,11 @@ const EmbedFrameWithRovoFooter = ({
62
66
  extensionKey: getExtensionKey(details)
63
67
  });
64
68
  }, [details, isEmbedRovoActionsFooterEnabled]);
65
- const footer = React.useMemo(() => rovoActionData && prompts.length > 0 ? /*#__PURE__*/React.createElement(EmbedRovoActionsFooter, {
69
+ const footer = React.useMemo(() => rovoActionData && prompts.length > 0 ? fg('platform_sl_replace_react_loadable') ? /*#__PURE__*/React.createElement(LazyEmbedRovoActionsFooter, {
70
+ actionData: rovoActionData,
71
+ prompts: prompts,
72
+ testId: `${testId}-rovo-actions-footer`
73
+ }) : /*#__PURE__*/React.createElement(EmbedRovoActionsFooter, {
66
74
  actionData: rovoActionData,
67
75
  prompts: prompts,
68
76
  testId: `${testId}-rovo-actions-footer`
@@ -3,12 +3,9 @@ import "./main.compiled.css";
3
3
  import * as React from 'react';
4
4
  import { ax, ix } from "@compiled/react/runtime";
5
5
  import { defineMessages, useIntl } from 'react-intl';
6
- import Heading from '@atlaskit/heading/heading';
7
6
  import AutomationIcon from '@atlaskit/icon/core/automation';
8
- import { useModal } from '@atlaskit/modal-dialog/hooks';
9
7
  import ModalHeader from '@atlaskit/modal-dialog/modal-header';
10
8
  import ModalTitle from '@atlaskit/modal-dialog/modal-title';
11
- import { fg } from '@atlaskit/platform-feature-flags/fg';
12
9
  import { Box } from '@atlaskit/primitives/compiled/box';
13
10
  import { Inline } from '@atlaskit/primitives/compiled/inline';
14
11
  import { Stack } from '@atlaskit/primitives/compiled/stack';
@@ -35,9 +32,6 @@ export const AutomationModalHeader = ({
35
32
  initialised,
36
33
  rules
37
34
  } = useAutomationMenu();
38
- const {
39
- titleId
40
- } = useModal();
41
35
  const showDescription = initialised && rules.length > 0 && !!modalDescription;
42
36
  return /*#__PURE__*/React.createElement(ModalHeader, {
43
37
  hasCloseButton: true
@@ -53,10 +47,7 @@ export const AutomationModalHeader = ({
53
47
  label: formatMessage(i18n.modalHeaderIconLabel),
54
48
  color: "var(--ds-icon-accent-green, #22A06B)",
55
49
  spacing: "compact"
56
- })), fg('platform_dst_modal-dialog-use-modal-title') ? /*#__PURE__*/React.createElement(ModalTitle, null, modalTitle) : /*#__PURE__*/React.createElement(Heading, {
57
- size: "medium",
58
- id: titleId
59
- }, modalTitle)), showDescription && /*#__PURE__*/React.createElement(Box, {
50
+ })), /*#__PURE__*/React.createElement(ModalTitle, null, modalTitle)), showDescription && /*#__PURE__*/React.createElement(Box, {
60
51
  xcss: styles.modalDescriptionStyle
61
52
  }, modalDescription)));
62
53
  };
@@ -1,10 +1,12 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import React from 'react';
2
+ import React, { lazy } from 'react';
3
3
  import { FormattedMessage, useIntl } from 'react-intl';
4
4
  import FeatureGates from '@atlaskit/feature-gate-js-client/feature-gates';
5
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
5
6
  import { ActionName } from '../../../../../constants';
6
7
  import { messages } from '../../../../../messages';
7
8
  import { useFlexibleUiContext } from '../../../../../state/flexible-ui-context/useFlexibleUiContext';
9
+ import { renderNothingOnLoadError, withSuspense } from '../../../../../utils/lazy-component';
8
10
  import { importIcon } from '../../importIcon';
9
11
  import ServerAction from '../action/server-action';
10
12
  import { getFollowActionErrorMessage } from './utils';
@@ -20,7 +22,25 @@ const importIconMapper = {
20
22
  default: ProjectsIcon
21
23
  }))
22
24
  };
25
+
26
+ // Inline module-scope lazy() calls so product SSR tooling can preload them before hydration.
27
+ const lazyIconMapper = {
28
+ goal: withSuspense( /*#__PURE__*/lazy(() => import( /* webpackChunkName: "glyphGoal" */'./goal-icon').then(({
29
+ GoalIcon
30
+ }) => ({
31
+ default: GoalIcon
32
+ })).catch(renderNothingOnLoadError)), 'lazy(GoalIcon)'),
33
+ projects: withSuspense( /*#__PURE__*/lazy(() => import( /* webpackChunkName: "glyphProjects" */'./projects-icon').then(({
34
+ ProjectsIcon
35
+ }) => ({
36
+ default: ProjectsIcon
37
+ })).catch(renderNothingOnLoadError)), 'lazy(ProjectsIcon)')
38
+ };
23
39
  const getIcon = stackIconType => {
40
+ if (fg('platform_sl_replace_react_loadable')) {
41
+ var _lazyIconMapper$stack;
42
+ return (_lazyIconMapper$stack = lazyIconMapper[stackIconType]) !== null && _lazyIconMapper$stack !== void 0 ? _lazyIconMapper$stack : null;
43
+ }
24
44
  const importFn = importIconMapper[stackIconType];
25
45
  if (!importFn) {
26
46
  return null;
@@ -9,6 +9,7 @@ import { transformSmartLinkSizeToIconTileSize } from '../../../../../common/ui/i
9
9
  import { IconType, SmartLinkSize } from '../../../../../constants';
10
10
  import { getLazyIcons } from '../../../../../utils/get-lazy-icons';
11
11
  import { isIconSizeLarge } from '../../../../../utils/is-icon-size-large';
12
+ import { getLazyIconComponent } from '../../../../../utils/lazy-component';
12
13
  const getIconImportFn = (icon, size) => {
13
14
  const item = getLazyIcons()[icon];
14
15
  if (isIconSizeLarge(size) && item !== null && item !== void 0 && item.large) {
@@ -16,6 +17,16 @@ const getIconImportFn = (icon, size) => {
16
17
  }
17
18
  return item === null || item === void 0 ? void 0 : item.default;
18
19
  };
20
+
21
+ // Only used when platform_sl_replace_react_loadable is on. Kept separate from getIconImportFn so
22
+ // the gate-off path is unchanged.
23
+ const getLazyIcon = (icon, size) => {
24
+ const item = getLazyIcons()[icon];
25
+ if (isIconSizeLarge(size) && item !== null && item !== void 0 && item.large) {
26
+ return getLazyIconComponent(`${icon}:large`, item.large);
27
+ }
28
+ return item !== null && item !== void 0 && item.default ? getLazyIconComponent(`${icon}:default`, item.default) : undefined;
29
+ };
19
30
  const importIcon = importFn => {
20
31
  return Loadable({
21
32
  loader: () => importFn().then(module => module.default),
@@ -71,11 +82,19 @@ const AtlaskitIcon = ({
71
82
  });
72
83
  }
73
84
  }
74
- const importFn = getIconImportFn(icon, size);
75
- if (!importFn) {
76
- return null;
85
+ let ImportedIcon;
86
+ if (fg('platform_sl_replace_react_loadable')) {
87
+ ImportedIcon = getLazyIcon(icon, size);
88
+ if (!ImportedIcon) {
89
+ return null;
90
+ }
91
+ } else {
92
+ const importFn = getIconImportFn(icon, size);
93
+ if (!importFn) {
94
+ return null;
95
+ }
96
+ ImportedIcon = importIcon(importFn);
77
97
  }
78
- const ImportedIcon = importIcon(importFn);
79
98
  if (isCoreIcon(icon)) {
80
99
  let color;
81
100
  if (icon === IconType.Error || icon === IconType.Forbidden) {
@@ -9,7 +9,7 @@ import LinkWarningModal from './LinkWarningModal';
9
9
  import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
10
10
  const PACKAGE_DATA = {
11
11
  packageName: "@atlaskit/smart-card",
12
- packageVersion: "46.10.2",
12
+ packageVersion: "46.10.4",
13
13
  componentName: 'linkUrl'
14
14
  };
15
15
  const LinkUrl = ({
@@ -4,7 +4,7 @@ export var ANALYTICS_CHANNEL = 'media';
4
4
  export var context = {
5
5
  componentName: 'smart-cards',
6
6
  packageName: "@atlaskit/smart-card" || '',
7
- packageVersion: "46.10.2" || ''
7
+ packageVersion: "46.10.4" || ''
8
8
  };
9
9
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -1,8 +1,10 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import React from 'react';
3
3
  import Loadable from 'react-loadable';
4
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
4
5
  import extractFileFormatIcon from '../extractors/flexible/icon/extract-file-formatIcon';
5
6
  import { getLazyIcons } from './get-lazy-icons';
7
+ import { getLazyIconComponent } from './lazy-component';
6
8
  var getTypeToIconMap = function getTypeToIconMap(fileFormat) {
7
9
  var _lazyIcons$iconDescri, _iconDescriptor$label;
8
10
  var iconDescriptor = extractFileFormatIcon(fileFormat);
@@ -25,6 +27,18 @@ export var getIconForFileType = function getIconForFileType(fileMimeType, showIc
25
27
  if (!importCb) {
26
28
  return;
27
29
  }
30
+ if (fg('platform_sl_replace_react_loadable')) {
31
+ var _extractFileFormatIco;
32
+ var iconType = (_extractFileFormatIco = extractFileFormatIcon(fileMimeType.toLowerCase())) === null || _extractFileFormatIco === void 0 ? void 0 : _extractFileFormatIco.icon;
33
+ if (iconType) {
34
+ var LazyIcon = getLazyIconComponent("".concat(iconType, ":default"), importCb);
35
+ var lazyLabel = (showIconLabel !== null && showIconLabel !== void 0 ? showIconLabel : true) ? icon[1] || '' : '';
36
+ return /*#__PURE__*/React.createElement(LazyIcon, {
37
+ testId: "document-file-format-icon",
38
+ label: lazyLabel
39
+ });
40
+ }
41
+ }
28
42
  var Icon = Loadable({
29
43
  loader: function loader() {
30
44
  return importCb().then(function (module) {
@@ -0,0 +1,73 @@
1
+ import React, { lazy, Suspense } from 'react';
2
+ var RenderNothing = function RenderNothing() {
3
+ return null;
4
+ };
5
+
6
+ /**
7
+ * `.catch` handler for a lazy loader: renders nothing if the chunk fails to load, instead of
8
+ * throwing to the nearest error boundary (matches `react-loadable` with `loading: () => null`).
9
+ *
10
+ * @example lazy(() => import('./Foo').catch(renderNothingOnLoadError))
11
+ */
12
+ export var renderNothingOnLoadError = function renderNothingOnLoadError() {
13
+ return {
14
+ // Typed as `never` so the fallback is assignable to whatever component type the loader
15
+ // resolves to, and `lazy()` keeps inferring that component's props.
16
+ default: RenderNothing
17
+ };
18
+ };
19
+
20
+ /**
21
+ * Wraps a `React.lazy` component in its own `<Suspense fallback={null}>`, so it renders nothing
22
+ * while its chunk loads and never suspends (and blanks out) an ancestor such as the card itself.
23
+ *
24
+ * Call `lazy(() => import('...'))` inline at module scope and pass the result here, rather than
25
+ * passing a loader into a helper that calls `lazy()` for you. Product SSR tooling (e.g.
26
+ * Confluence's LoadableReactLazyBabelPlugin) only tracks and preloads `lazy()` calls whose loader
27
+ * reads no function parameters or other render-time values.
28
+ */
29
+ export var withSuspense = function withSuspense(LazyComponent, displayName) {
30
+ // Typed loosely internally: TS cannot spread generic props onto a LazyExoticComponent.
31
+ // The returned component is still strictly typed as ComponentType<P>.
32
+ var Component = LazyComponent;
33
+ var LazyComponentWithSuspense = function LazyComponentWithSuspense(props) {
34
+ return /*#__PURE__*/React.createElement(Suspense, {
35
+ fallback: null
36
+ }, /*#__PURE__*/React.createElement(Component, props));
37
+ };
38
+ if (displayName) {
39
+ LazyComponentWithSuspense.displayName = displayName;
40
+ }
41
+ return LazyComponentWithSuspense;
42
+ };
43
+ var lazyIconCache = new Map();
44
+
45
+ /**
46
+ * Returns a lazily loaded icon component for a dynamic icon import.
47
+ *
48
+ * Callers resolve the icon on every render, so the component is cached by `cacheKey` to keep a
49
+ * stable component identity across renders (otherwise React would remount and re-suspend the
50
+ * icon on every render). The cache entry is dropped if the chunk fails to load, so the next
51
+ * render retries the import.
52
+ *
53
+ * Prefer an inline module-scope `lazy(() => import('...'))` with `withSuspense` where the set of
54
+ * components is known up front, so product SSR tooling can preload the chunks. This helper is a
55
+ * deliberate exception for open-ended icon sets (any Atlaskit icon / file type) that cannot be
56
+ * enumerated statically: its loader reads render-time values, so SSR tooling cannot preload it.
57
+ *
58
+ * @param cacheKey Must uniquely identify the module `importFn` resolves to.
59
+ */
60
+ export var getLazyIconComponent = function getLazyIconComponent(cacheKey, importFn) {
61
+ var cached = lazyIconCache.get(cacheKey);
62
+ if (cached) {
63
+ return cached;
64
+ }
65
+ var LazyIcon = withSuspense( /*#__PURE__*/lazy(function () {
66
+ return importFn().catch(function () {
67
+ lazyIconCache.delete(cacheKey);
68
+ return renderNothingOnLoadError();
69
+ });
70
+ }), "lazy(".concat(cacheKey, ")"));
71
+ lazyIconCache.set(cacheKey, LazyIcon);
72
+ return LazyIcon;
73
+ };
@@ -2,7 +2,7 @@
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import "./ResolvedView.compiled.css";
4
4
  import { ax, ix } from "@compiled/react/runtime";
5
- import React from 'react';
5
+ import React, { lazy } from 'react';
6
6
  import Loadable from 'react-loadable';
7
7
  import LinkGlyph from '@atlaskit/icon/core/link';
8
8
  import { useSmartLinkContext } from '@atlaskit/link-provider/use-smart-link-context';
@@ -16,6 +16,7 @@ import useEmbedRovoActionsFooterExperiment from '../../../state/hooks/use-embed-
16
16
  import useRovoConfig from '../../../state/hooks/use-rovo-config';
17
17
  import { getPreviewUrlWithEmbedContext } from '../../../utils/get-preview-url-with-theme';
18
18
  import { isProfileType } from '../../../utils/is-profile-type';
19
+ import { renderNothingOnLoadError, withSuspense } from '../../../utils/lazy-component';
19
20
  import { getRovoPostAuthPromptKeys } from '../../common/rovo-post-auth-prompts';
20
21
  import { ExpandedFrame } from '../components/ExpandedFrame';
21
22
  import { Frame } from '../components/Frame';
@@ -32,6 +33,11 @@ var EmbedRovoActionsFooter = Loadable({
32
33
  }
33
34
  });
34
35
  EmbedRovoActionsFooter.displayName = 'lazy(EmbedRovoActionsFooter)';
36
+
37
+ // Inline module-scope lazy() so product SSR tooling can preload it before hydration.
38
+ var LazyEmbedRovoActionsFooter = withSuspense( /*#__PURE__*/lazy(function () {
39
+ return import( /* webpackChunkName: "smart-card-embed-rovo-actions-footer" */'../components/rovo-actions-footer').catch(renderNothingOnLoadError);
40
+ }), 'lazy(EmbedRovoActionsFooter)');
35
41
  var styles = {
36
42
  contentWithFooter: "_1e0c1txw _2lx21bp4 _4t3i1osq _1tkeidpf",
37
43
  frameWithFooter: "_16jlkb7n _1tkeidpf",
@@ -69,7 +75,11 @@ var EmbedFrameWithRovoFooter = function EmbedFrameWithRovoFooter(_ref) {
69
75
  });
70
76
  }, [details, isEmbedRovoActionsFooterEnabled]);
71
77
  var footer = React.useMemo(function () {
72
- return rovoActionData && prompts.length > 0 ? /*#__PURE__*/React.createElement(EmbedRovoActionsFooter, {
78
+ return rovoActionData && prompts.length > 0 ? fg('platform_sl_replace_react_loadable') ? /*#__PURE__*/React.createElement(LazyEmbedRovoActionsFooter, {
79
+ actionData: rovoActionData,
80
+ prompts: prompts,
81
+ testId: "".concat(testId, "-rovo-actions-footer")
82
+ }) : /*#__PURE__*/React.createElement(EmbedRovoActionsFooter, {
73
83
  actionData: rovoActionData,
74
84
  prompts: prompts,
75
85
  testId: "".concat(testId, "-rovo-actions-footer")
@@ -3,12 +3,9 @@ import "./main.compiled.css";
3
3
  import * as React from 'react';
4
4
  import { ax, ix } from "@compiled/react/runtime";
5
5
  import { defineMessages, useIntl } from 'react-intl';
6
- import Heading from '@atlaskit/heading/heading';
7
6
  import AutomationIcon from '@atlaskit/icon/core/automation';
8
- import { useModal } from '@atlaskit/modal-dialog/hooks';
9
7
  import ModalHeader from '@atlaskit/modal-dialog/modal-header';
10
8
  import ModalTitle from '@atlaskit/modal-dialog/modal-title';
11
- import { fg } from '@atlaskit/platform-feature-flags/fg';
12
9
  import { Box } from '@atlaskit/primitives/compiled/box';
13
10
  import { Inline } from '@atlaskit/primitives/compiled/inline';
14
11
  import { Stack } from '@atlaskit/primitives/compiled/stack';
@@ -32,8 +29,6 @@ export var AutomationModalHeader = function AutomationModalHeader(_ref) {
32
29
  var _useAutomationMenu = useAutomationMenu(),
33
30
  initialised = _useAutomationMenu.initialised,
34
31
  rules = _useAutomationMenu.rules;
35
- var _useModal = useModal(),
36
- titleId = _useModal.titleId;
37
32
  var showDescription = initialised && rules.length > 0 && !!modalDescription;
38
33
  return /*#__PURE__*/React.createElement(ModalHeader, {
39
34
  hasCloseButton: true
@@ -49,10 +44,7 @@ export var AutomationModalHeader = function AutomationModalHeader(_ref) {
49
44
  label: formatMessage(i18n.modalHeaderIconLabel),
50
45
  color: "var(--ds-icon-accent-green, #22A06B)",
51
46
  spacing: "compact"
52
- })), fg('platform_dst_modal-dialog-use-modal-title') ? /*#__PURE__*/React.createElement(ModalTitle, null, modalTitle) : /*#__PURE__*/React.createElement(Heading, {
53
- size: "medium",
54
- id: titleId
55
- }, modalTitle)), showDescription && /*#__PURE__*/React.createElement(Box, {
47
+ })), /*#__PURE__*/React.createElement(ModalTitle, null, modalTitle)), showDescription && /*#__PURE__*/React.createElement(Box, {
56
48
  xcss: styles.modalDescriptionStyle
57
49
  }, modalDescription)));
58
50
  };
@@ -1,12 +1,14 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  var _excluded = ["value", "isProject"];
4
- import React from 'react';
4
+ import React, { lazy } from 'react';
5
5
  import { FormattedMessage, useIntl } from 'react-intl';
6
6
  import FeatureGates from '@atlaskit/feature-gate-js-client/feature-gates';
7
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
7
8
  import { ActionName } from '../../../../../constants';
8
9
  import { messages } from '../../../../../messages';
9
10
  import { useFlexibleUiContext } from '../../../../../state/flexible-ui-context/useFlexibleUiContext';
11
+ import { renderNothingOnLoadError, withSuspense } from '../../../../../utils/lazy-component';
10
12
  import { importIcon } from '../../importIcon';
11
13
  import ServerAction from '../action/server-action';
12
14
  import { getFollowActionErrorMessage } from './utils';
@@ -28,7 +30,31 @@ var importIconMapper = {
28
30
  });
29
31
  }
30
32
  };
33
+
34
+ // Inline module-scope lazy() calls so product SSR tooling can preload them before hydration.
35
+ var lazyIconMapper = {
36
+ goal: withSuspense( /*#__PURE__*/lazy(function () {
37
+ return import( /* webpackChunkName: "glyphGoal" */'./goal-icon').then(function (_ref3) {
38
+ var GoalIcon = _ref3.GoalIcon;
39
+ return {
40
+ default: GoalIcon
41
+ };
42
+ }).catch(renderNothingOnLoadError);
43
+ }), 'lazy(GoalIcon)'),
44
+ projects: withSuspense( /*#__PURE__*/lazy(function () {
45
+ return import( /* webpackChunkName: "glyphProjects" */'./projects-icon').then(function (_ref4) {
46
+ var ProjectsIcon = _ref4.ProjectsIcon;
47
+ return {
48
+ default: ProjectsIcon
49
+ };
50
+ }).catch(renderNothingOnLoadError);
51
+ }), 'lazy(ProjectsIcon)')
52
+ };
31
53
  var getIcon = function getIcon(stackIconType) {
54
+ if (fg('platform_sl_replace_react_loadable')) {
55
+ var _lazyIconMapper$stack;
56
+ return (_lazyIconMapper$stack = lazyIconMapper[stackIconType]) !== null && _lazyIconMapper$stack !== void 0 ? _lazyIconMapper$stack : null;
57
+ }
32
58
  var importFn = importIconMapper[stackIconType];
33
59
  if (!importFn) {
34
60
  return null;
@@ -9,6 +9,7 @@ import { transformSmartLinkSizeToIconTileSize } from '../../../../../common/ui/i
9
9
  import { IconType, SmartLinkSize } from '../../../../../constants';
10
10
  import { getLazyIcons } from '../../../../../utils/get-lazy-icons';
11
11
  import { isIconSizeLarge } from '../../../../../utils/is-icon-size-large';
12
+ import { getLazyIconComponent } from '../../../../../utils/lazy-component';
12
13
  var getIconImportFn = function getIconImportFn(icon, size) {
13
14
  var item = getLazyIcons()[icon];
14
15
  if (isIconSizeLarge(size) && item !== null && item !== void 0 && item.large) {
@@ -16,6 +17,16 @@ var getIconImportFn = function getIconImportFn(icon, size) {
16
17
  }
17
18
  return item === null || item === void 0 ? void 0 : item.default;
18
19
  };
20
+
21
+ // Only used when platform_sl_replace_react_loadable is on. Kept separate from getIconImportFn so
22
+ // the gate-off path is unchanged.
23
+ var getLazyIcon = function getLazyIcon(icon, size) {
24
+ var item = getLazyIcons()[icon];
25
+ if (isIconSizeLarge(size) && item !== null && item !== void 0 && item.large) {
26
+ return getLazyIconComponent("".concat(icon, ":large"), item.large);
27
+ }
28
+ return item !== null && item !== void 0 && item.default ? getLazyIconComponent("".concat(icon, ":default"), item.default) : undefined;
29
+ };
19
30
  var importIcon = function importIcon(importFn) {
20
31
  return Loadable({
21
32
  loader: function loader() {
@@ -83,11 +94,19 @@ var AtlaskitIcon = function AtlaskitIcon(_ref) {
83
94
  });
84
95
  }
85
96
  }
86
- var importFn = getIconImportFn(icon, size);
87
- if (!importFn) {
88
- return null;
97
+ var ImportedIcon;
98
+ if (fg('platform_sl_replace_react_loadable')) {
99
+ ImportedIcon = getLazyIcon(icon, size);
100
+ if (!ImportedIcon) {
101
+ return null;
102
+ }
103
+ } else {
104
+ var importFn = getIconImportFn(icon, size);
105
+ if (!importFn) {
106
+ return null;
107
+ }
108
+ ImportedIcon = importIcon(importFn);
89
109
  }
90
- var ImportedIcon = importIcon(importFn);
91
110
  if (isCoreIcon(icon)) {
92
111
  var color;
93
112
  if (icon === IconType.Error || icon === IconType.Forbidden) {
@@ -12,7 +12,7 @@ import LinkWarningModal from './LinkWarningModal';
12
12
  import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
13
13
  var PACKAGE_DATA = {
14
14
  packageName: "@atlaskit/smart-card",
15
- packageVersion: "46.10.2",
15
+ packageVersion: "46.10.4",
16
16
  componentName: 'linkUrl'
17
17
  };
18
18
  var LinkUrl = function LinkUrl(_ref) {
@@ -0,0 +1,36 @@
1
+ import { type ComponentType, type LazyExoticComponent } from 'react';
2
+ /**
3
+ * `.catch` handler for a lazy loader: renders nothing if the chunk fails to load, instead of
4
+ * throwing to the nearest error boundary (matches `react-loadable` with `loading: () => null`).
5
+ *
6
+ * @example lazy(() => import('./Foo').catch(renderNothingOnLoadError))
7
+ */
8
+ export declare const renderNothingOnLoadError: () => {
9
+ default: never;
10
+ };
11
+ /**
12
+ * Wraps a `React.lazy` component in its own `<Suspense fallback={null}>`, so it renders nothing
13
+ * while its chunk loads and never suspends (and blanks out) an ancestor such as the card itself.
14
+ *
15
+ * Call `lazy(() => import('...'))` inline at module scope and pass the result here, rather than
16
+ * passing a loader into a helper that calls `lazy()` for you. Product SSR tooling (e.g.
17
+ * Confluence's LoadableReactLazyBabelPlugin) only tracks and preloads `lazy()` calls whose loader
18
+ * reads no function parameters or other render-time values.
19
+ */
20
+ export declare const withSuspense: <P extends object>(LazyComponent: ComponentType<P> | LazyExoticComponent<ComponentType<P>>, displayName?: string) => ComponentType<P>;
21
+ /**
22
+ * Returns a lazily loaded icon component for a dynamic icon import.
23
+ *
24
+ * Callers resolve the icon on every render, so the component is cached by `cacheKey` to keep a
25
+ * stable component identity across renders (otherwise React would remount and re-suspend the
26
+ * icon on every render). The cache entry is dropped if the chunk fails to load, so the next
27
+ * render retries the import.
28
+ *
29
+ * Prefer an inline module-scope `lazy(() => import('...'))` with `withSuspense` where the set of
30
+ * components is known up front, so product SSR tooling can preload the chunks. This helper is a
31
+ * deliberate exception for open-ended icon sets (any Atlaskit icon / file type) that cannot be
32
+ * enumerated statically: its loader reads render-time values, so SSR tooling cannot preload it.
33
+ *
34
+ * @param cacheKey Must uniquely identify the module `importFn` resolves to.
35
+ */
36
+ export declare const getLazyIconComponent: (cacheKey: string, importFn: () => Promise<any>) => ComponentType<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "46.10.3",
3
+ "version": "46.11.0",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@atlaskit/adf-utils": "^20.9.0",
42
- "@atlaskit/afm-i18n-platform-linking-platform-smart-card": "2.292.0",
42
+ "@atlaskit/afm-i18n-platform-linking-platform-smart-card": "2.295.0",
43
43
  "@atlaskit/analytics-cross-product": "^2.3.0",
44
44
  "@atlaskit/analytics-gas-types": "^6.2.0",
45
45
  "@atlaskit/analytics-next": "^12.6.0",
@@ -53,7 +53,7 @@
53
53
  "@atlaskit/docs": "^12.3.0",
54
54
  "@atlaskit/dropdown-menu": "^21.0.0",
55
55
  "@atlaskit/embedded-confluence": "^6.4.0",
56
- "@atlaskit/feature-gate-js-client": "^7.0.0",
56
+ "@atlaskit/feature-gate-js-client": "^7.1.0",
57
57
  "@atlaskit/flag": "^19.0.0",
58
58
  "@atlaskit/form": "^18.3.0",
59
59
  "@atlaskit/frontend-utilities": "^5.1.0",
@@ -69,7 +69,7 @@
69
69
  "@atlaskit/link-extractors": "^5.0.0",
70
70
  "@atlaskit/link-test-helpers": "^11.2.0",
71
71
  "@atlaskit/linking-common": "^13.0.0",
72
- "@atlaskit/linking-types": "^16.0.0",
72
+ "@atlaskit/linking-types": "^16.1.0",
73
73
  "@atlaskit/logo": "^23.3.0",
74
74
  "@atlaskit/lozenge": "^17.0.0",
75
75
  "@atlaskit/menu": "^11.0.0",
@@ -90,11 +90,11 @@
90
90
  "@atlaskit/spinner": "^20.4.0",
91
91
  "@atlaskit/tabs": "^21.3.0",
92
92
  "@atlaskit/tag": "^17.0.0",
93
- "@atlaskit/textarea": "^10.2.0",
93
+ "@atlaskit/textarea": "^10.3.0",
94
94
  "@atlaskit/textfield": "^10.3.0",
95
95
  "@atlaskit/theme": "^28.2.0",
96
96
  "@atlaskit/tile": "^5.0.0",
97
- "@atlaskit/tmp-editor-statsig": "^248.0.0",
97
+ "@atlaskit/tmp-editor-statsig": "^248.1.0",
98
98
  "@atlaskit/tokens": "^20.8.0",
99
99
  "@atlaskit/tooltip": "^24.4.0",
100
100
  "@atlaskit/top-layer": "^7.0.0",
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:33e60c7cbe7025308d524ba8a1f7016c45c5f8385dc94f20c8124a657ec90608
3
- size 9601
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:33e60c7cbe7025308d524ba8a1f7016c45c5f8385dc94f20c8124a657ec90608
3
- size 9601
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:33e60c7cbe7025308d524ba8a1f7016c45c5f8385dc94f20c8124a657ec90608
3
- size 9601