@atlaskit/smart-card 46.13.1 → 46.13.2

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 (30) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/cjs/state/hooks/use-hydration-safe-content/index.js +25 -0
  3. package/dist/cjs/state/hooks/use-one-click-chat-spotlight-eligibility/index.js +10 -1
  4. package/dist/cjs/state/hooks/use-social-proof/index.js +10 -2
  5. package/dist/cjs/utils/analytics/analytics.js +1 -1
  6. package/dist/cjs/view/FlexibleCard/components/actions/follow-action/index.js +1 -1
  7. package/dist/cjs/view/FlexibleCard/components/elements/common/base-date-time-element/index.js +10 -1
  8. package/dist/cjs/view/InlineCard/common/one-click-chat-spotlight/index.js +49 -41
  9. package/dist/cjs/view/LinkUrl/index.js +1 -1
  10. package/dist/es2019/state/hooks/use-hydration-safe-content/index.js +12 -0
  11. package/dist/es2019/state/hooks/use-one-click-chat-spotlight-eligibility/index.js +8 -0
  12. package/dist/es2019/state/hooks/use-social-proof/index.js +10 -2
  13. package/dist/es2019/utils/analytics/analytics.js +1 -1
  14. package/dist/es2019/view/FlexibleCard/components/actions/follow-action/index.js +1 -1
  15. package/dist/es2019/view/FlexibleCard/components/elements/common/base-date-time-element/index.js +11 -1
  16. package/dist/es2019/view/InlineCard/common/one-click-chat-spotlight/index.js +13 -6
  17. package/dist/es2019/view/LinkUrl/index.js +1 -1
  18. package/dist/esm/state/hooks/use-hydration-safe-content/index.js +19 -0
  19. package/dist/esm/state/hooks/use-one-click-chat-spotlight-eligibility/index.js +10 -1
  20. package/dist/esm/state/hooks/use-social-proof/index.js +10 -2
  21. package/dist/esm/utils/analytics/analytics.js +1 -1
  22. package/dist/esm/view/FlexibleCard/components/actions/follow-action/index.js +1 -1
  23. package/dist/esm/view/FlexibleCard/components/elements/common/base-date-time-element/index.js +10 -1
  24. package/dist/esm/view/InlineCard/common/one-click-chat-spotlight/index.js +49 -41
  25. package/dist/esm/view/LinkUrl/index.js +1 -1
  26. package/dist/types/state/hooks/use-hydration-safe-content/index.d.ts +2 -0
  27. package/dist/types/state/hooks/use-one-click-chat-spotlight-eligibility/evaluate.d.ts +1 -1
  28. package/dist/types/state/hooks/use-one-click-chat-spotlight-eligibility/index.d.ts +1 -0
  29. package/dist/types/state/hooks/use-social-proof/index.d.ts +2 -1
  30. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 46.13.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`8dbc6d82d98b0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8dbc6d82d98b0) -
8
+ Prevent cached social proof and date formatting hydration mismatches behind the
9
+ platform_sl_hydration_safe_content experiment (isEnabled parameter). Preserve cache-first
10
+ personalization and local date formatting after hydration.
11
+
12
+ Evaluate the experiment only for eligible server-rendered content, avoiding exposures on
13
+ client-only mounts and additional hydration updates in control.
14
+
15
+ - [`4fc5a097ea8ce`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4fc5a097ea8ce) -
16
+ Add reusable host choreography and an adapter factory for Smart Card experiments. The one-click
17
+ chat spotlight uses it behind platform_sl_one_click_chat_spotlight_v2_fg, preserving local
18
+ eligibility and dismissal policy. Missing-host notifications do not repeat when only the
19
+ unavailable callback changes. The adapter keeps its choreography callbacks and return value stable
20
+ between unchanged renders, and render functions receive a named `{ hasPermission }` value.
21
+ - [`7823af8452d72`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7823af8452d72) -
22
+ Remove the redundant 'Follow' text alternative from the decorative follow-action icon in the hover
23
+ card and preview dialog action group, so assistive technology only announces the button's own
24
+ accessible name.
25
+ - Updated dependencies
26
+
3
27
  ## 46.13.1
4
28
 
5
29
  ### Patch Changes
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useHydrationSafeContent;
7
+ var _react = require("react");
8
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
9
+ var subscribe = function subscribe() {
10
+ return function () {};
11
+ };
12
+ var getClientSnapshot = function getClientSnapshot() {
13
+ return false;
14
+ };
15
+
16
+ /** Use deterministic content only during SSR/hydration in the experiment treatment. */
17
+ function useHydrationSafeContent() {
18
+ var isEligible = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
19
+ return (0, _react.useSyncExternalStore)(subscribe, getClientSnapshot,
20
+ // React only reads this snapshot during SSR/hydration, so client-only mounts
21
+ // never fire an exposure. Control matches the client snapshot and needs no update.
22
+ function () {
23
+ return isEligible && (0, _isExperimentEnabled.isExperimentEnabled)('platform_sl_hydration_safe_content');
24
+ });
25
+ }
@@ -176,7 +176,16 @@ function useOneClickChatSpotlightEligibility(_ref) {
176
176
  var onDismiss = (0, _react.useCallback)(function () {
177
177
  finish('dismissed');
178
178
  }, [finish]);
179
- return _objectSpread(_objectSpread({}, eligibility), {}, {
179
+ var onUnavailable = (0, _react.useCallback)(function () {
180
+ (0, _suppression.releaseSpotlight)(owner.current);
181
+ setEligibility({
182
+ isEligible: false,
183
+ reason: 'choreography_unavailable'
184
+ });
185
+ }, []);
186
+ return _objectSpread(_objectSpread({
187
+ onUnavailable: onUnavailable
188
+ }, eligibility), {}, {
180
189
  isEligible: eligibility.isEligible && gateEnabled && isOpportunity && !!suppression,
181
190
  provider: provider,
182
191
  product: hostProduct,
@@ -12,6 +12,7 @@ var _getCurrentSiteCloudIdSync = require("../../services/current-site-cloud-id/g
12
12
  var _constants = require("../../services/personalization/constants");
13
13
  var _getProviderPctMap = require("../../services/personalization/getProviderPctMap");
14
14
  var _getProviderPctMapSync = require("../../services/personalization/getProviderPctMapSync");
15
+ var _useHydrationSafeContent = _interopRequireDefault(require("../use-hydration-safe-content"));
15
16
  var NOT_ENABLED_RESULT = {
16
17
  connectedPct: undefined,
17
18
  isEnabled: false,
@@ -31,7 +32,8 @@ var NOT_ENABLED_RESULT = {
31
32
  * This means:
32
33
  * - First page visit (cold): no social proof rendered, no experiment exposure fired.
33
34
  * Background fetch populates localStorage for next time.
34
- * - Second page visit (warm): social proof renders immediately from localStorage.
35
+ * - Second page visit (warm): social proof renders from localStorage, after hydration
36
+ * when the platform_sl_hydration_safe_content experiment is enabled (immediately on client-only mounts).
35
37
  * Background refresh keeps localStorage fresh.
36
38
  *
37
39
  * Callers decide separately (e.g. via Statsig experiment) whether to surface the data.
@@ -40,6 +42,7 @@ var useSocialProof = function useSocialProof(extensionKey) {
40
42
  var isKillswitchOn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
41
43
  var baseUriWithNoTrailingSlash = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
42
44
  var isEnabled = isKillswitchOn;
45
+ var shouldUseHydrationSafeContent = (0, _useHydrationSafeContent.default)(isEnabled);
43
46
  var _useState = (0, _react.useState)(function () {
44
47
  if (!isEnabled) {
45
48
  return {
@@ -66,6 +69,11 @@ var useSocialProof = function useSocialProof(extensionKey) {
66
69
  });
67
70
  }, [baseUriWithNoTrailingSlash, isEnabled]);
68
71
  return (0, _react.useMemo)(function () {
72
+ if (shouldUseHydrationSafeContent) {
73
+ // SSR cannot access this browser's cache. Match its fallback through hydration
74
+ // before revealing the mount-stable snapshot; async refresh still affects future mounts only.
75
+ return NOT_ENABLED_RESULT;
76
+ }
69
77
  if (!isEnabled) {
70
78
  return NOT_ENABLED_RESULT;
71
79
  }
@@ -74,6 +82,6 @@ var useSocialProof = function useSocialProof(extensionKey) {
74
82
  isEnabled: Boolean(snapshot.cloudId && snapshot.providerPctMap),
75
83
  isLoading: false // sync read is instant; never in "loading" state
76
84
  };
77
- }, [extensionKey, isEnabled, snapshot]);
85
+ }, [extensionKey, isEnabled, shouldUseHydrationSafeContent, snapshot]);
78
86
  };
79
87
  var _default = exports.default = useSocialProof;
@@ -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.13.0" || ''
28
+ packageVersion: "46.13.1" || ''
29
29
  };
30
30
  var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
31
31
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -102,7 +102,7 @@ var FollowAction = function FollowAction(props) {
102
102
  var stackIconType = isProject ? 'projects' : 'goal';
103
103
  var ImportedIcon = getIcon(stackIconType);
104
104
  var followIcon = /*#__PURE__*/_react.default.createElement(ImportedIcon, {
105
- label: "Follow",
105
+ label: "",
106
106
  testId: "smart-action-follow-action-".concat(stackIconType, "-icon")
107
107
  });
108
108
  var handleError = function handleError() {
@@ -16,6 +16,7 @@ var _intlUtils = require("@formatjs/intl-utils");
16
16
  var _reactIntl = require("react-intl");
17
17
  var _fg = require("@atlaskit/platform-feature-flags/fg");
18
18
  var _messages = require("../../../../../../messages");
19
+ var _useHydrationSafeContent = _interopRequireDefault(require("../../../../../../state/hooks/use-hydration-safe-content"));
19
20
  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); }
20
21
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
21
22
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -89,13 +90,21 @@ var BaseDateTimeElement = function BaseDateTimeElement(_ref2) {
89
90
  var _useIntl = (0, _reactIntl.useIntl)(),
90
91
  formatRelativeTime = _useIntl.formatRelativeTime,
91
92
  formatDate = _useIntl.formatDate;
93
+ var shouldUseHydrationSafeContent = (0, _useHydrationSafeContent.default)(Boolean(type && date));
92
94
  if (!type || !date) {
93
95
  return null;
94
96
  }
95
97
  var isLongerThenWeek = Math.abs(date.getTime() - Date.now()) > 1000 * 60 * 60 * 24 * 7;
96
98
  var context;
97
99
  var typeVariant;
98
- if (isLongerThenWeek) {
100
+ if (shouldUseHydrationSafeContent) {
101
+ // Use the same absolute date on SSR and the first client render. The browser's
102
+ // timezone and clock are only used after hydration (or on client-only mounts).
103
+ typeVariant = 'absolute';
104
+ context = formatDate(date, _objectSpread(_objectSpread({}, ABSOLUTE_DATE_FORMAT), {}, {
105
+ timeZone: (0, _fg.fg)('dfo_issue_view_remote_data_srr_group') && timeZone && isValidTimeZone(timeZone) ? timeZone : 'UTC'
106
+ }));
107
+ } else if (isLongerThenWeek) {
99
108
  typeVariant = 'absolute';
100
109
  context = (0, _fg.fg)('dfo_issue_view_remote_data_srr_group') ? formatAbsoluteDateWithOptionalTimeZone({
101
110
  date: date,
@@ -18,6 +18,7 @@ var _reactIntl = require("react-intl");
18
18
  var _useAnalyticsEvents2 = require("@atlaskit/analytics-next/useAnalyticsEvents");
19
19
  var _browserApis = require("@atlaskit/browser-apis");
20
20
  var _cross = _interopRequireDefault(require("@atlaskit/icon/core/cross"));
21
+ var _choreographedContent = require("@atlaskit/link-provider/choreographed-content");
21
22
  var _fg = require("@atlaskit/platform-feature-flags/fg");
22
23
  var _popup = require("@atlaskit/popup/popup");
23
24
  var _box = require("@atlaskit/primitives/compiled/box");
@@ -292,7 +293,7 @@ function OneClickChatSpotlight(_ref4) {
292
293
  }, []);
293
294
  var _trigger = /*#__PURE__*/_react.default.createElement("span", {
294
295
  onClickCapture: function onClickCapture() {
295
- if (spotlight.isEligible) spotlight.onClick('inlineAction');
296
+ if (spotlight.isEligible && !spotlight.onClick('inlineAction')) spotlight.onUnavailable();
296
297
  }
297
298
  }, children);
298
299
  var _content = /*#__PURE__*/_react.default.createElement(VisibleSpotlightCard, {
@@ -305,47 +306,54 @@ function OneClickChatSpotlight(_ref4) {
305
306
  if (spotlight.onClick('spotlightCta')) onInvoke();
306
307
  }
307
308
  });
308
- return /*#__PURE__*/_react.default.createElement("span", {
309
- ref: target,
310
- role: "none",
311
- onClick: function onClick(event) {
312
- // Top-layer popups remain inside the Smart Link's anchor in the DOM.
313
- event.preventDefault();
314
- event.stopPropagation();
315
- },
316
- onKeyDown: function onKeyDown(event) {
317
- if (event.key === 'Escape' && spotlight.isEligible) {
309
+ return /*#__PURE__*/_react.default.createElement(_choreographedContent.ChoreographedContent, {
310
+ messageId: "smart-link-one-click-chat-spotlight-v2",
311
+ isActive: spotlight.isEligible,
312
+ onUnavailable: spotlight.onUnavailable
313
+ }, function (_ref7) {
314
+ var hasPermission = _ref7.hasPermission;
315
+ return /*#__PURE__*/_react.default.createElement("span", {
316
+ ref: target,
317
+ role: "none",
318
+ onClick: function onClick(event) {
319
+ // Top-layer popups remain inside the Smart Link's anchor in the DOM.
318
320
  event.preventDefault();
319
321
  event.stopPropagation();
320
- spotlight.onDismiss();
322
+ },
323
+ onKeyDown: function onKeyDown(event) {
324
+ if (event.key === 'Escape' && hasPermission) {
325
+ event.preventDefault();
326
+ event.stopPropagation();
327
+ spotlight.onDismiss();
328
+ }
321
329
  }
322
- }
323
- // Match the enclosing Smart Link's keypress handler.
324
- ,
325
- onKeyPress: function onKeyPress(event) {
326
- return event.stopPropagation();
327
- }
328
- }, /*#__PURE__*/_react.default.createElement(TargetContext.Provider, {
329
- value: target
330
- }, (0, _fg.fg)('platform-dst-top-layer') ? /*#__PURE__*/_react.default.createElement(TopLayerSpotlight, {
331
- isOpen: spotlight.isEligible,
332
- label: intl.formatMessage(messages.heading),
333
- trigger: _trigger
334
- }, _content) : /*#__PURE__*/_react.default.createElement(_popup.Popup, {
335
- popupComponent: SpotlightSurface,
336
- shouldFitViewport: true,
337
- isOpen: spotlight.isEligible,
338
- placement: "bottom-start",
339
- role: "dialog",
340
- label: intl.formatMessage(messages.heading),
341
- trigger: function trigger(_ref7) {
342
- var ref = _ref7.ref;
343
- return /*#__PURE__*/_react.default.createElement("span", {
344
- ref: ref
345
- }, _trigger);
346
- },
347
- content: function content() {
348
- return _content;
349
- }
350
- })));
330
+ // Match the enclosing Smart Link's keypress handler.
331
+ ,
332
+ onKeyPress: function onKeyPress(event) {
333
+ return event.stopPropagation();
334
+ }
335
+ }, /*#__PURE__*/_react.default.createElement(TargetContext.Provider, {
336
+ value: target
337
+ }, (0, _fg.fg)('platform-dst-top-layer') ? /*#__PURE__*/_react.default.createElement(TopLayerSpotlight, {
338
+ isOpen: hasPermission,
339
+ label: intl.formatMessage(messages.heading),
340
+ trigger: _trigger
341
+ }, _content) : /*#__PURE__*/_react.default.createElement(_popup.Popup, {
342
+ popupComponent: SpotlightSurface,
343
+ shouldFitViewport: true,
344
+ isOpen: hasPermission,
345
+ placement: "bottom-start",
346
+ role: "dialog",
347
+ label: intl.formatMessage(messages.heading),
348
+ trigger: function trigger(_ref8) {
349
+ var ref = _ref8.ref;
350
+ return /*#__PURE__*/_react.default.createElement("span", {
351
+ ref: ref
352
+ }, _trigger);
353
+ },
354
+ content: function content() {
355
+ return _content;
356
+ }
357
+ })));
358
+ });
351
359
  }
@@ -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.13.0",
22
+ packageVersion: "46.13.1",
23
23
  componentName: 'linkUrl'
24
24
  };
25
25
  var LinkUrl = function LinkUrl(_ref) {
@@ -0,0 +1,12 @@
1
+ import { useSyncExternalStore } from 'react';
2
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
3
+ const subscribe = () => () => {};
4
+ const getClientSnapshot = () => false;
5
+
6
+ /** Use deterministic content only during SSR/hydration in the experiment treatment. */
7
+ export default function useHydrationSafeContent(isEligible = true) {
8
+ return useSyncExternalStore(subscribe, getClientSnapshot,
9
+ // React only reads this snapshot during SSR/hydration, so client-only mounts
10
+ // never fire an exposure. Control matches the client snapshot and needs no update.
11
+ () => isEligible && isExperimentEnabled('platform_sl_hydration_safe_content'));
12
+ }
@@ -150,7 +150,15 @@ export default function useOneClickChatSpotlightEligibility({
150
150
  const onDismiss = useCallback(() => {
151
151
  finish('dismissed');
152
152
  }, [finish]);
153
+ const onUnavailable = useCallback(() => {
154
+ releaseSpotlight(owner.current);
155
+ setEligibility({
156
+ isEligible: false,
157
+ reason: 'choreography_unavailable'
158
+ });
159
+ }, []);
153
160
  return {
161
+ onUnavailable,
154
162
  ...eligibility,
155
163
  isEligible: eligibility.isEligible && gateEnabled && isOpportunity && !!suppression,
156
164
  provider,
@@ -4,6 +4,7 @@ import { getCurrentSiteCloudIdSync } from '../../services/current-site-cloud-id/
4
4
  import { personalizationConstants } from '../../services/personalization/constants';
5
5
  import { getProviderPctMap } from '../../services/personalization/getProviderPctMap';
6
6
  import { getProviderPctMapSync } from '../../services/personalization/getProviderPctMapSync';
7
+ import useHydrationSafeContent from '../use-hydration-safe-content';
7
8
  const NOT_ENABLED_RESULT = {
8
9
  connectedPct: undefined,
9
10
  isEnabled: false,
@@ -23,13 +24,15 @@ const NOT_ENABLED_RESULT = {
23
24
  * This means:
24
25
  * - First page visit (cold): no social proof rendered, no experiment exposure fired.
25
26
  * Background fetch populates localStorage for next time.
26
- * - Second page visit (warm): social proof renders immediately from localStorage.
27
+ * - Second page visit (warm): social proof renders from localStorage, after hydration
28
+ * when the platform_sl_hydration_safe_content experiment is enabled (immediately on client-only mounts).
27
29
  * Background refresh keeps localStorage fresh.
28
30
  *
29
31
  * Callers decide separately (e.g. via Statsig experiment) whether to surface the data.
30
32
  */
31
33
  const useSocialProof = (extensionKey, isKillswitchOn = false, baseUriWithNoTrailingSlash = '') => {
32
34
  const isEnabled = isKillswitchOn;
35
+ const shouldUseHydrationSafeContent = useHydrationSafeContent(isEnabled);
33
36
  const [snapshot] = useState(() => {
34
37
  if (!isEnabled) {
35
38
  return {
@@ -54,6 +57,11 @@ const useSocialProof = (extensionKey, isKillswitchOn = false, baseUriWithNoTrail
54
57
  });
55
58
  }, [baseUriWithNoTrailingSlash, isEnabled]);
56
59
  return useMemo(() => {
60
+ if (shouldUseHydrationSafeContent) {
61
+ // SSR cannot access this browser's cache. Match its fallback through hydration
62
+ // before revealing the mount-stable snapshot; async refresh still affects future mounts only.
63
+ return NOT_ENABLED_RESULT;
64
+ }
57
65
  if (!isEnabled) {
58
66
  return NOT_ENABLED_RESULT;
59
67
  }
@@ -62,6 +70,6 @@ const useSocialProof = (extensionKey, isKillswitchOn = false, baseUriWithNoTrail
62
70
  isEnabled: Boolean(snapshot.cloudId && snapshot.providerPctMap),
63
71
  isLoading: false // sync read is instant; never in "loading" state
64
72
  };
65
- }, [extensionKey, isEnabled, snapshot]);
73
+ }, [extensionKey, isEnabled, shouldUseHydrationSafeContent, snapshot]);
66
74
  };
67
75
  export default useSocialProof;
@@ -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.13.0" || ''
7
+ packageVersion: "46.13.1" || ''
8
8
  };
9
9
  export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -73,7 +73,7 @@ const FollowAction = props => {
73
73
  const stackIconType = isProject ? 'projects' : 'goal';
74
74
  const ImportedIcon = getIcon(stackIconType);
75
75
  const followIcon = /*#__PURE__*/React.createElement(ImportedIcon, {
76
- label: "Follow",
76
+ label: "",
77
77
  testId: `smart-action-follow-action-${stackIconType}-icon`
78
78
  });
79
79
  const handleError = () => {
@@ -7,6 +7,7 @@ import { selectUnit } from '@formatjs/intl-utils';
7
7
  import { FormattedMessage, useIntl } from 'react-intl';
8
8
  import { fg } from '@atlaskit/platform-feature-flags/fg';
9
9
  import { messages } from '../../../../../../messages';
10
+ import useHydrationSafeContent from '../../../../../../state/hooks/use-hydration-safe-content';
10
11
  const styles = null;
11
12
  const ABSOLUTE_DATE_FORMAT = {
12
13
  month: 'short',
@@ -79,13 +80,22 @@ const BaseDateTimeElement = ({
79
80
  formatRelativeTime,
80
81
  formatDate
81
82
  } = useIntl();
83
+ const shouldUseHydrationSafeContent = useHydrationSafeContent(Boolean(type && date));
82
84
  if (!type || !date) {
83
85
  return null;
84
86
  }
85
87
  const isLongerThenWeek = Math.abs(date.getTime() - Date.now()) > 1000 * 60 * 60 * 24 * 7;
86
88
  let context;
87
89
  let typeVariant;
88
- if (isLongerThenWeek) {
90
+ if (shouldUseHydrationSafeContent) {
91
+ // Use the same absolute date on SSR and the first client render. The browser's
92
+ // timezone and clock are only used after hydration (or on client-only mounts).
93
+ typeVariant = 'absolute';
94
+ context = formatDate(date, {
95
+ ...ABSOLUTE_DATE_FORMAT,
96
+ timeZone: fg('dfo_issue_view_remote_data_srr_group') && timeZone && isValidTimeZone(timeZone) ? timeZone : 'UTC'
97
+ });
98
+ } else if (isLongerThenWeek) {
89
99
  typeVariant = 'absolute';
90
100
  context = fg('dfo_issue_view_remote_data_srr_group') ? formatAbsoluteDateWithOptionalTimeZone({
91
101
  date,
@@ -7,6 +7,7 @@ import { defineMessages, useIntl } from 'react-intl';
7
7
  import { useAnalyticsEvents } from '@atlaskit/analytics-next/useAnalyticsEvents';
8
8
  import { getDocument } from '@atlaskit/browser-apis';
9
9
  import CrossIcon from '@atlaskit/icon/core/cross';
10
+ import { ChoreographedContent } from '@atlaskit/link-provider/choreographed-content';
10
11
  import { fg } from '@atlaskit/platform-feature-flags/fg';
11
12
  import { Popup } from '@atlaskit/popup/popup';
12
13
  import { Box } from '@atlaskit/primitives/compiled/box';
@@ -270,7 +271,7 @@ export function OneClickChatSpotlight({
270
271
  }, []);
271
272
  const trigger = /*#__PURE__*/React.createElement("span", {
272
273
  onClickCapture: () => {
273
- if (spotlight.isEligible) spotlight.onClick('inlineAction');
274
+ if (spotlight.isEligible && !spotlight.onClick('inlineAction')) spotlight.onUnavailable();
274
275
  }
275
276
  }, children);
276
277
  const content = /*#__PURE__*/React.createElement(VisibleSpotlightCard, {
@@ -283,7 +284,13 @@ export function OneClickChatSpotlight({
283
284
  if (spotlight.onClick('spotlightCta')) onInvoke();
284
285
  }
285
286
  });
286
- return /*#__PURE__*/React.createElement("span", {
287
+ return /*#__PURE__*/React.createElement(ChoreographedContent, {
288
+ messageId: "smart-link-one-click-chat-spotlight-v2",
289
+ isActive: spotlight.isEligible,
290
+ onUnavailable: spotlight.onUnavailable
291
+ }, ({
292
+ hasPermission
293
+ }) => /*#__PURE__*/React.createElement("span", {
287
294
  ref: target,
288
295
  role: "none",
289
296
  onClick: event => {
@@ -292,7 +299,7 @@ export function OneClickChatSpotlight({
292
299
  event.stopPropagation();
293
300
  },
294
301
  onKeyDown: event => {
295
- if (event.key === 'Escape' && spotlight.isEligible) {
302
+ if (event.key === 'Escape' && hasPermission) {
296
303
  event.preventDefault();
297
304
  event.stopPropagation();
298
305
  spotlight.onDismiss();
@@ -304,13 +311,13 @@ export function OneClickChatSpotlight({
304
311
  }, /*#__PURE__*/React.createElement(TargetContext.Provider, {
305
312
  value: target
306
313
  }, fg('platform-dst-top-layer') ? /*#__PURE__*/React.createElement(TopLayerSpotlight, {
307
- isOpen: spotlight.isEligible,
314
+ isOpen: hasPermission,
308
315
  label: intl.formatMessage(messages.heading),
309
316
  trigger: trigger
310
317
  }, content) : /*#__PURE__*/React.createElement(Popup, {
311
318
  popupComponent: SpotlightSurface,
312
319
  shouldFitViewport: true,
313
- isOpen: spotlight.isEligible,
320
+ isOpen: hasPermission,
314
321
  placement: "bottom-start",
315
322
  role: "dialog",
316
323
  label: intl.formatMessage(messages.heading),
@@ -320,5 +327,5 @@ export function OneClickChatSpotlight({
320
327
  ref: ref
321
328
  }, trigger),
322
329
  content: () => content
323
- })));
330
+ }))));
324
331
  }
@@ -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.13.0",
12
+ packageVersion: "46.13.1",
13
13
  componentName: 'linkUrl'
14
14
  };
15
15
  const LinkUrl = ({
@@ -0,0 +1,19 @@
1
+ import { useSyncExternalStore } from 'react';
2
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
3
+ var subscribe = function subscribe() {
4
+ return function () {};
5
+ };
6
+ var getClientSnapshot = function getClientSnapshot() {
7
+ return false;
8
+ };
9
+
10
+ /** Use deterministic content only during SSR/hydration in the experiment treatment. */
11
+ export default function useHydrationSafeContent() {
12
+ var isEligible = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
13
+ return useSyncExternalStore(subscribe, getClientSnapshot,
14
+ // React only reads this snapshot during SSR/hydration, so client-only mounts
15
+ // never fire an exposure. Control matches the client snapshot and needs no update.
16
+ function () {
17
+ return isEligible && isExperimentEnabled('platform_sl_hydration_safe_content');
18
+ });
19
+ }
@@ -169,7 +169,16 @@ export default function useOneClickChatSpotlightEligibility(_ref) {
169
169
  var onDismiss = useCallback(function () {
170
170
  finish('dismissed');
171
171
  }, [finish]);
172
- return _objectSpread(_objectSpread({}, eligibility), {}, {
172
+ var onUnavailable = useCallback(function () {
173
+ releaseSpotlight(owner.current);
174
+ setEligibility({
175
+ isEligible: false,
176
+ reason: 'choreography_unavailable'
177
+ });
178
+ }, []);
179
+ return _objectSpread(_objectSpread({
180
+ onUnavailable: onUnavailable
181
+ }, eligibility), {}, {
173
182
  isEligible: eligibility.isEligible && gateEnabled && isOpportunity && !!suppression,
174
183
  provider: provider,
175
184
  product: hostProduct,
@@ -5,6 +5,7 @@ import { getCurrentSiteCloudIdSync } from '../../services/current-site-cloud-id/
5
5
  import { personalizationConstants } from '../../services/personalization/constants';
6
6
  import { getProviderPctMap } from '../../services/personalization/getProviderPctMap';
7
7
  import { getProviderPctMapSync } from '../../services/personalization/getProviderPctMapSync';
8
+ import useHydrationSafeContent from '../use-hydration-safe-content';
8
9
  var NOT_ENABLED_RESULT = {
9
10
  connectedPct: undefined,
10
11
  isEnabled: false,
@@ -24,7 +25,8 @@ var NOT_ENABLED_RESULT = {
24
25
  * This means:
25
26
  * - First page visit (cold): no social proof rendered, no experiment exposure fired.
26
27
  * Background fetch populates localStorage for next time.
27
- * - Second page visit (warm): social proof renders immediately from localStorage.
28
+ * - Second page visit (warm): social proof renders from localStorage, after hydration
29
+ * when the platform_sl_hydration_safe_content experiment is enabled (immediately on client-only mounts).
28
30
  * Background refresh keeps localStorage fresh.
29
31
  *
30
32
  * Callers decide separately (e.g. via Statsig experiment) whether to surface the data.
@@ -33,6 +35,7 @@ var useSocialProof = function useSocialProof(extensionKey) {
33
35
  var isKillswitchOn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
34
36
  var baseUriWithNoTrailingSlash = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
35
37
  var isEnabled = isKillswitchOn;
38
+ var shouldUseHydrationSafeContent = useHydrationSafeContent(isEnabled);
36
39
  var _useState = useState(function () {
37
40
  if (!isEnabled) {
38
41
  return {
@@ -59,6 +62,11 @@ var useSocialProof = function useSocialProof(extensionKey) {
59
62
  });
60
63
  }, [baseUriWithNoTrailingSlash, isEnabled]);
61
64
  return useMemo(function () {
65
+ if (shouldUseHydrationSafeContent) {
66
+ // SSR cannot access this browser's cache. Match its fallback through hydration
67
+ // before revealing the mount-stable snapshot; async refresh still affects future mounts only.
68
+ return NOT_ENABLED_RESULT;
69
+ }
62
70
  if (!isEnabled) {
63
71
  return NOT_ENABLED_RESULT;
64
72
  }
@@ -67,6 +75,6 @@ var useSocialProof = function useSocialProof(extensionKey) {
67
75
  isEnabled: Boolean(snapshot.cloudId && snapshot.providerPctMap),
68
76
  isLoading: false // sync read is instant; never in "loading" state
69
77
  };
70
- }, [extensionKey, isEnabled, snapshot]);
78
+ }, [extensionKey, isEnabled, shouldUseHydrationSafeContent, snapshot]);
71
79
  };
72
80
  export default useSocialProof;
@@ -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.13.0" || ''
7
+ packageVersion: "46.13.1" || ''
8
8
  };
9
9
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -85,7 +85,7 @@ var FollowAction = function FollowAction(props) {
85
85
  var stackIconType = isProject ? 'projects' : 'goal';
86
86
  var ImportedIcon = getIcon(stackIconType);
87
87
  var followIcon = /*#__PURE__*/React.createElement(ImportedIcon, {
88
- label: "Follow",
88
+ label: "",
89
89
  testId: "smart-action-follow-action-".concat(stackIconType, "-icon")
90
90
  });
91
91
  var handleError = function handleError() {
@@ -10,6 +10,7 @@ import { selectUnit } from '@formatjs/intl-utils';
10
10
  import { FormattedMessage, useIntl } from 'react-intl';
11
11
  import { fg } from '@atlaskit/platform-feature-flags/fg';
12
12
  import { messages } from '../../../../../../messages';
13
+ import useHydrationSafeContent from '../../../../../../state/hooks/use-hydration-safe-content';
13
14
  var styles = null;
14
15
  var ABSOLUTE_DATE_FORMAT = {
15
16
  month: 'short',
@@ -80,13 +81,21 @@ var BaseDateTimeElement = function BaseDateTimeElement(_ref2) {
80
81
  var _useIntl = useIntl(),
81
82
  formatRelativeTime = _useIntl.formatRelativeTime,
82
83
  formatDate = _useIntl.formatDate;
84
+ var shouldUseHydrationSafeContent = useHydrationSafeContent(Boolean(type && date));
83
85
  if (!type || !date) {
84
86
  return null;
85
87
  }
86
88
  var isLongerThenWeek = Math.abs(date.getTime() - Date.now()) > 1000 * 60 * 60 * 24 * 7;
87
89
  var context;
88
90
  var typeVariant;
89
- if (isLongerThenWeek) {
91
+ if (shouldUseHydrationSafeContent) {
92
+ // Use the same absolute date on SSR and the first client render. The browser's
93
+ // timezone and clock are only used after hydration (or on client-only mounts).
94
+ typeVariant = 'absolute';
95
+ context = formatDate(date, _objectSpread(_objectSpread({}, ABSOLUTE_DATE_FORMAT), {}, {
96
+ timeZone: fg('dfo_issue_view_remote_data_srr_group') && timeZone && isValidTimeZone(timeZone) ? timeZone : 'UTC'
97
+ }));
98
+ } else if (isLongerThenWeek) {
90
99
  typeVariant = 'absolute';
91
100
  context = fg('dfo_issue_view_remote_data_srr_group') ? formatAbsoluteDateWithOptionalTimeZone({
92
101
  date: date,
@@ -13,6 +13,7 @@ import { defineMessages, useIntl } from 'react-intl';
13
13
  import { useAnalyticsEvents } from '@atlaskit/analytics-next/useAnalyticsEvents';
14
14
  import { getDocument } from '@atlaskit/browser-apis';
15
15
  import CrossIcon from '@atlaskit/icon/core/cross';
16
+ import { ChoreographedContent } from '@atlaskit/link-provider/choreographed-content';
16
17
  import { fg } from '@atlaskit/platform-feature-flags/fg';
17
18
  import { Popup } from '@atlaskit/popup/popup';
18
19
  import { Box } from '@atlaskit/primitives/compiled/box';
@@ -283,7 +284,7 @@ export function OneClickChatSpotlight(_ref4) {
283
284
  }, []);
284
285
  var _trigger = /*#__PURE__*/React.createElement("span", {
285
286
  onClickCapture: function onClickCapture() {
286
- if (spotlight.isEligible) spotlight.onClick('inlineAction');
287
+ if (spotlight.isEligible && !spotlight.onClick('inlineAction')) spotlight.onUnavailable();
287
288
  }
288
289
  }, children);
289
290
  var _content = /*#__PURE__*/React.createElement(VisibleSpotlightCard, {
@@ -296,47 +297,54 @@ export function OneClickChatSpotlight(_ref4) {
296
297
  if (spotlight.onClick('spotlightCta')) onInvoke();
297
298
  }
298
299
  });
299
- return /*#__PURE__*/React.createElement("span", {
300
- ref: target,
301
- role: "none",
302
- onClick: function onClick(event) {
303
- // Top-layer popups remain inside the Smart Link's anchor in the DOM.
304
- event.preventDefault();
305
- event.stopPropagation();
306
- },
307
- onKeyDown: function onKeyDown(event) {
308
- if (event.key === 'Escape' && spotlight.isEligible) {
300
+ return /*#__PURE__*/React.createElement(ChoreographedContent, {
301
+ messageId: "smart-link-one-click-chat-spotlight-v2",
302
+ isActive: spotlight.isEligible,
303
+ onUnavailable: spotlight.onUnavailable
304
+ }, function (_ref7) {
305
+ var hasPermission = _ref7.hasPermission;
306
+ return /*#__PURE__*/React.createElement("span", {
307
+ ref: target,
308
+ role: "none",
309
+ onClick: function onClick(event) {
310
+ // Top-layer popups remain inside the Smart Link's anchor in the DOM.
309
311
  event.preventDefault();
310
312
  event.stopPropagation();
311
- spotlight.onDismiss();
313
+ },
314
+ onKeyDown: function onKeyDown(event) {
315
+ if (event.key === 'Escape' && hasPermission) {
316
+ event.preventDefault();
317
+ event.stopPropagation();
318
+ spotlight.onDismiss();
319
+ }
312
320
  }
313
- }
314
- // Match the enclosing Smart Link's keypress handler.
315
- ,
316
- onKeyPress: function onKeyPress(event) {
317
- return event.stopPropagation();
318
- }
319
- }, /*#__PURE__*/React.createElement(TargetContext.Provider, {
320
- value: target
321
- }, fg('platform-dst-top-layer') ? /*#__PURE__*/React.createElement(TopLayerSpotlight, {
322
- isOpen: spotlight.isEligible,
323
- label: intl.formatMessage(messages.heading),
324
- trigger: _trigger
325
- }, _content) : /*#__PURE__*/React.createElement(Popup, {
326
- popupComponent: SpotlightSurface,
327
- shouldFitViewport: true,
328
- isOpen: spotlight.isEligible,
329
- placement: "bottom-start",
330
- role: "dialog",
331
- label: intl.formatMessage(messages.heading),
332
- trigger: function trigger(_ref7) {
333
- var ref = _ref7.ref;
334
- return /*#__PURE__*/React.createElement("span", {
335
- ref: ref
336
- }, _trigger);
337
- },
338
- content: function content() {
339
- return _content;
340
- }
341
- })));
321
+ // Match the enclosing Smart Link's keypress handler.
322
+ ,
323
+ onKeyPress: function onKeyPress(event) {
324
+ return event.stopPropagation();
325
+ }
326
+ }, /*#__PURE__*/React.createElement(TargetContext.Provider, {
327
+ value: target
328
+ }, fg('platform-dst-top-layer') ? /*#__PURE__*/React.createElement(TopLayerSpotlight, {
329
+ isOpen: hasPermission,
330
+ label: intl.formatMessage(messages.heading),
331
+ trigger: _trigger
332
+ }, _content) : /*#__PURE__*/React.createElement(Popup, {
333
+ popupComponent: SpotlightSurface,
334
+ shouldFitViewport: true,
335
+ isOpen: hasPermission,
336
+ placement: "bottom-start",
337
+ role: "dialog",
338
+ label: intl.formatMessage(messages.heading),
339
+ trigger: function trigger(_ref8) {
340
+ var ref = _ref8.ref;
341
+ return /*#__PURE__*/React.createElement("span", {
342
+ ref: ref
343
+ }, _trigger);
344
+ },
345
+ content: function content() {
346
+ return _content;
347
+ }
348
+ })));
349
+ });
342
350
  }
@@ -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.13.0",
15
+ packageVersion: "46.13.1",
16
16
  componentName: 'linkUrl'
17
17
  };
18
18
  var LinkUrl = function LinkUrl(_ref) {
@@ -0,0 +1,2 @@
1
+ /** Use deterministic content only during SSR/hydration in the experiment treatment. */
2
+ export default function useHydrationSafeContent(isEligible?: boolean): boolean;
@@ -1,5 +1,5 @@
1
1
  /** No link, content, or account identifiers belong in eligibility diagnostics. */
2
- export type EligibilityReason = 'gate_off' | 'not_resolved_inline' | 'unsupported_provider' | 'provider_unauthorized' | 'object_inaccessible' | 'rovo_unavailable' | 'consumer_not_opted_in' | 'unsupported_product' | 'suppression_unavailable' | 'spotlight_active' | 'dismissal_cooldown' | 'shown_today' | 'weekly_limit' | 'experiment_unavailable' | 'control' | 'eligible';
2
+ export type EligibilityReason = 'gate_off' | 'not_resolved_inline' | 'unsupported_provider' | 'provider_unauthorized' | 'object_inaccessible' | 'rovo_unavailable' | 'consumer_not_opted_in' | 'unsupported_product' | 'suppression_unavailable' | 'spotlight_active' | 'choreography_unavailable' | 'dismissal_cooldown' | 'shown_today' | 'weekly_limit' | 'experiment_unavailable' | 'control' | 'eligible';
3
3
  export interface SpotlightHistory {
4
4
  dismissedAt?: number;
5
5
  impressions: readonly number[];
@@ -6,6 +6,7 @@ export interface SpotlightEligibility extends EligibilityResult {
6
6
  onClick: (source?: RovoInteractionSource) => boolean;
7
7
  onDismiss: () => void;
8
8
  onShown: () => void;
9
+ onUnavailable: () => void;
9
10
  product?: string;
10
11
  provider?: string;
11
12
  }
@@ -17,7 +17,8 @@ export interface SocialProof {
17
17
  * This means:
18
18
  * - First page visit (cold): no social proof rendered, no experiment exposure fired.
19
19
  * Background fetch populates localStorage for next time.
20
- * - Second page visit (warm): social proof renders immediately from localStorage.
20
+ * - Second page visit (warm): social proof renders from localStorage, after hydration
21
+ * when the platform_sl_hydration_safe_content experiment is enabled (immediately on client-only mounts).
21
22
  * Background refresh keeps localStorage fresh.
22
23
  *
23
24
  * Callers decide separately (e.g. via Statsig experiment) whether to surface the data.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "46.13.1",
3
+ "version": "46.13.2",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -115,7 +115,7 @@
115
115
  "uuid": "^11.1.1"
116
116
  },
117
117
  "peerDependencies": {
118
- "@atlaskit/link-provider": "^6.0.0",
118
+ "@atlaskit/link-provider": "^6.1.0",
119
119
  "react": "^18.2.0",
120
120
  "react-dom": "^18.2.0",
121
121
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
@@ -129,7 +129,7 @@
129
129
  "@atlaskit/css-reset": "^8.4.0",
130
130
  "@atlaskit/datetime-picker": "^19.4.0",
131
131
  "@atlaskit/inline-message": "^16.4.0",
132
- "@atlaskit/link-provider": "^6.0.0",
132
+ "@atlaskit/link-provider": "^6.1.0",
133
133
  "@atlaskit/media-test-helpers": "^43.0.0",
134
134
  "@atlaskit/page": "^15.3.0",
135
135
  "@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-migration": "^3.4.0",