@atlaskit/smart-card 46.13.16 → 46.14.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 46.14.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`75d086dab7677`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/75d086dab7677) -
8
+ Keep the One Click Chat spotlight arrow aligned when navigation moves its anchor, and use the
9
+ shared manual Popup for rendering. Controlled by `platform_sl_one_click_chat_spotlight_v2_fg`.
10
+
11
+ ### Patch Changes
12
+
13
+ - [`58dfe28c3560c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/58dfe28c3560c) -
14
+ Remove `platform_sl_inline_social_proof_hydration_fix` and keep inline Smart Link social proof
15
+ hydration safe across shared consumers.
16
+
17
+ ## 46.13.17
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies
22
+
3
23
  ## 46.13.16
4
24
 
5
25
  ### 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.13.16" || ''
28
+ packageVersion: "46.13.17" || ''
29
29
  };
30
30
  var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
31
31
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -86,7 +86,7 @@ var UnauthorisedConnectWithSocialProof = function UnauthorisedConnectWithSocialP
86
86
  var canUseCachedProviderPctMap = _react.default.useSyncExternalStore(noopSubscribe, function () {
87
87
  return true;
88
88
  }, function () {
89
- return !(0, _fg.fg)('platform_sl_inline_social_proof_hydration_fix');
89
+ return false;
90
90
  });
91
91
  var providerPctMap = canUseCachedProviderPctMap ? cachedProviderPctMap : null;
92
92
 
@@ -19,18 +19,12 @@ 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
21
  var _choreographedContent = require("@atlaskit/link-provider/choreographed-content");
22
- var _fg = require("@atlaskit/platform-feature-flags/fg");
23
22
  var _popup = require("@atlaskit/popup/popup");
24
23
  var _box = require("@atlaskit/primitives/compiled/box");
25
24
  var _inline = require("@atlaskit/primitives/compiled/inline");
26
25
  var _pressable = require("@atlaskit/primitives/compiled/pressable");
27
26
  var _stack = require("@atlaskit/primitives/compiled/stack");
28
27
  var _text = require("@atlaskit/primitives/compiled/text");
29
- var _getAriaForTrigger = require("@atlaskit/top-layer/get-aria-for-trigger");
30
- var _index = require("@atlaskit/top-layer/placement-map/index");
31
- var _popover = require("@atlaskit/top-layer/popover/popover");
32
- var _useAnchoredPopover = require("@atlaskit/top-layer/use-anchored-popover");
33
- var _usePopoverId = require("@atlaskit/top-layer/use-popover-id");
34
28
  var _constants = require("../../../../common/analytics/constants");
35
29
  var _getExtensionKey = require("../../../../state/getExtensionKey");
36
30
  var _useOneClickChatSpotlightEligibility = _interopRequireDefault(require("../../../../state/hooks/use-one-click-chat-spotlight-eligibility"));
@@ -73,21 +67,37 @@ var styles = {
73
67
  body: "_u5f31ejb",
74
68
  action: "_2rko12b0 _v564k6bl _1h6d8yml _1dqonqa1 _189ee4h9 _syaz15cr _bfhk1aqn _ca0qv77o _n3tdv77o _19bvu2gc _u5f3u2gc _irr31ibz _1ggl5xtf _1di6of27"
75
69
  };
70
+ var SpotlightOpenContext = /*#__PURE__*/(0, _react.createContext)(false);
76
71
  var TargetContext = /*#__PURE__*/(0, _react.createContext)(null);
72
+ var PositionUpdateContext = /*#__PURE__*/(0, _react.createContext)(null);
73
+ function LegacyPositionUpdater(_ref) {
74
+ var update = _ref.update;
75
+ var positionUpdate = (0, _react.useContext)(PositionUpdateContext);
76
+ (0, _react.useEffect)(function () {
77
+ if (!positionUpdate) return;
78
+ positionUpdate.current = update;
79
+ return function () {
80
+ positionUpdate.current = undefined;
81
+ };
82
+ }, [positionUpdate, update]);
83
+ return null;
84
+ }
77
85
 
78
86
  // Keep Popup's inline trigger and focus handling. The design-system Spotlight
79
87
  // target renders a block element; the Smart Link action must stay inline.
80
- var SpotlightSurface = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, forwardedRef) {
81
- var children = _ref.children,
82
- style = _ref.style,
83
- _fit = _ref.shouldFitViewport,
84
- _parent = _ref.shouldRenderToParent,
85
- _container = _ref.shouldFitContainer,
86
- _appearance = _ref.appearance,
87
- _xcss = _ref.xcss,
88
- _hidden = _ref.isReferenceHidden,
89
- props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
88
+ var SpotlightSurface = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, forwardedRef) {
89
+ var children = _ref2.children,
90
+ style = _ref2.style,
91
+ _fit = _ref2.shouldFitViewport,
92
+ _parent = _ref2.shouldRenderToParent,
93
+ _container = _ref2.shouldFitContainer,
94
+ _appearance = _ref2.appearance,
95
+ _xcss = _ref2.xcss,
96
+ _hidden = _ref2.isReferenceHidden,
97
+ props = (0, _objectWithoutProperties2.default)(_ref2, _excluded);
98
+ var isOpen = (0, _react.useContext)(SpotlightOpenContext);
90
99
  var target = (0, _react.useContext)(TargetContext);
100
+ var positionUpdate = (0, _react.useContext)(PositionUpdateContext);
91
101
  var surface = (0, _react.useRef)(null);
92
102
  var _useState = (0, _react.useState)({
93
103
  above: false,
@@ -103,38 +113,39 @@ var SpotlightSurface = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, forwa
103
113
  (0, _react.useEffect)(function () {
104
114
  var element = surface.current;
105
115
  var anchor = target === null || target === void 0 ? void 0 : target.current;
106
- if (!element || !anchor) return;
116
+ if (!isOpen || !element || !anchor) return;
107
117
  var frame = 0;
108
- var measure = function measure() {
118
+ var previousTrigger;
119
+ var previousCaret;
120
+ // Navigation can translate the anchor without a resize or scroll event.
121
+ // Only the visible spotlight samples geometry; unchanged geometry causes no updates.
122
+ var _measure = function measure() {
123
+ var _previousCaret;
124
+ frame = requestAnimationFrame(_measure);
109
125
  var card = element.getBoundingClientRect();
110
126
  var trigger = anchor.getBoundingClientRect();
127
+ if (previousTrigger && (trigger.left !== previousTrigger.left || trigger.top !== previousTrigger.top || trigger.width !== previousTrigger.width || trigger.height !== previousTrigger.height)) {
128
+ var _positionUpdate$curre;
129
+ // Reuse Popup's positioning engine rather than moving its DOM ourselves.
130
+ void (positionUpdate === null || positionUpdate === void 0 || (_positionUpdate$curre = positionUpdate.current) === null || _positionUpdate$curre === void 0 ? void 0 : _positionUpdate$curre.call(positionUpdate));
131
+ }
132
+ previousTrigger = trigger;
111
133
  if (!card.width) return;
112
134
  var above = card.bottom <= trigger.top;
113
135
  var left = Math.max(16, Math.min(card.width - 32, trigger.left + trigger.width / 2 - card.left - 8));
114
- setCaret(function (previous) {
115
- return previous.above === above && previous.left === left ? previous : {
136
+ if (((_previousCaret = previousCaret) === null || _previousCaret === void 0 ? void 0 : _previousCaret.above) !== above || previousCaret.left !== left) {
137
+ previousCaret = {
116
138
  above: above,
117
139
  left: left
118
140
  };
119
- });
120
- };
121
- var schedule = function schedule() {
122
- cancelAnimationFrame(frame);
123
- frame = requestAnimationFrame(measure);
141
+ setCaret(previousCaret);
142
+ }
124
143
  };
125
- var observer = new ResizeObserver(schedule);
126
- observer.observe(element);
127
- observer.observe(anchor);
128
- window.addEventListener('resize', schedule);
129
- window.addEventListener('scroll', schedule, true);
130
- schedule();
144
+ frame = requestAnimationFrame(_measure);
131
145
  return function () {
132
- cancelAnimationFrame(frame);
133
- observer.disconnect();
134
- window.removeEventListener('resize', schedule);
135
- window.removeEventListener('scroll', schedule, true);
146
+ return cancelAnimationFrame(frame);
136
147
  };
137
- }, [target]);
148
+ }, [target, positionUpdate, isOpen]);
138
149
  return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, props, {
139
150
  ref: ref,
140
151
  style: style,
@@ -149,49 +160,6 @@ var SpotlightSurface = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, forwa
149
160
  xcss: styles.card
150
161
  }, children));
151
162
  });
152
-
153
- // The native auto popover used by Popup can hide independently of React state.
154
- // Compose the existing manual primitive here so persistence stays local to Smart Card.
155
- function TopLayerSpotlight(_ref2) {
156
- var isOpen = _ref2.isOpen,
157
- label = _ref2.label,
158
- trigger = _ref2.trigger,
159
- children = _ref2.children;
160
- var anchorRef = (0, _react.useRef)(null);
161
- var popoverRef = (0, _react.useRef)(null);
162
- var id = (0, _usePopoverId.usePopoverId)();
163
- var placement = (0, _index.fromLegacyPlacement)({
164
- legacy: 'bottom-start'
165
- });
166
- (0, _useAnchoredPopover.useAnchoredPopover)({
167
- anchorRef: anchorRef,
168
- popoverRef: popoverRef,
169
- isOpen: isOpen,
170
- placement: placement,
171
- inlineSize: 'max-available',
172
- blockSize: 'max-available'
173
- });
174
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", (0, _extends2.default)({
175
- ref: anchorRef
176
- }, (0, _getAriaForTrigger.getAriaForTrigger)({
177
- role: 'dialog',
178
- isOpen: isOpen,
179
- popoverId: id
180
- })), trigger), /*#__PURE__*/_react.default.createElement(_popover.Popover, {
181
- ref: popoverRef,
182
- id: id,
183
- isOpen: isOpen,
184
- mode: "manual",
185
- role: "dialog",
186
- label: label,
187
- shouldAnimate: true,
188
- placement: placement
189
- }, /*#__PURE__*/_react.default.createElement(SpotlightSurface, {
190
- tabIndex: -1,
191
- "data-placement": "bottom-start",
192
- style: {}
193
- }, children)));
194
- }
195
163
  function VisibleSpotlightCard(_ref3) {
196
164
  var onShown = _ref3.onShown,
197
165
  body = _ref3.body,
@@ -235,6 +203,7 @@ function OneClickChatSpotlight(_ref4) {
235
203
  onInvoke = _ref4.onInvoke;
236
204
  var intl = (0, _reactIntl.useIntl)();
237
205
  var target = (0, _react.useRef)(null);
206
+ var positionUpdate = (0, _react.useRef)(undefined);
238
207
  var _useState3 = (0, _react.useState)(false),
239
208
  _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
240
209
  isOpportunity = _useState4[0],
@@ -334,26 +303,32 @@ function OneClickChatSpotlight(_ref4) {
334
303
  }
335
304
  }, /*#__PURE__*/_react.default.createElement(TargetContext.Provider, {
336
305
  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, {
306
+ }, /*#__PURE__*/_react.default.createElement(PositionUpdateContext.Provider, {
307
+ value: positionUpdate
308
+ }, /*#__PURE__*/_react.default.createElement(SpotlightOpenContext.Provider, {
309
+ value: hasPermission
310
+ }, /*#__PURE__*/_react.default.createElement(_popup.Popup, {
311
+ mode: "manual",
342
312
  popupComponent: SpotlightSurface,
343
313
  shouldFitViewport: true,
344
314
  isOpen: hasPermission,
345
315
  placement: "bottom-start",
346
316
  role: "dialog",
347
- label: intl.formatMessage(messages.heading),
317
+ label: intl.formatMessage(messages.heading)
318
+ // This span only anchors the popup; it does not toggle it.
319
+ ,
348
320
  trigger: function trigger(_ref8) {
349
321
  var ref = _ref8.ref;
350
322
  return /*#__PURE__*/_react.default.createElement("span", {
351
323
  ref: ref
352
324
  }, _trigger);
353
325
  },
354
- content: function content() {
355
- return _content;
326
+ content: function content(_ref9) {
327
+ var update = _ref9.update;
328
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(LegacyPositionUpdater, {
329
+ update: update
330
+ }), _content);
356
331
  }
357
- })));
332
+ })))));
358
333
  });
359
334
  }
@@ -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.16",
22
+ packageVersion: "46.13.17",
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.13.16" || ''
7
+ packageVersion: "46.13.17" || ''
8
8
  };
9
9
  export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -76,7 +76,7 @@ const UnauthorisedConnectWithSocialProof = ({
76
76
  }) => {
77
77
  var _context$trim;
78
78
  const cachedProviderPctMap = getCachedProviderPctMapAndRefresh(SOCIAL_PROOF_TRAIT_NAME);
79
- const canUseCachedProviderPctMap = React.useSyncExternalStore(noopSubscribe, () => true, () => !fg('platform_sl_inline_social_proof_hydration_fix'));
79
+ const canUseCachedProviderPctMap = React.useSyncExternalStore(noopSubscribe, () => true, () => false);
80
80
  const providerPctMap = canUseCachedProviderPctMap ? cachedProviderPctMap : null;
81
81
 
82
82
  // Will be false if this is the first render, when we fetch traits and store to local storage,
@@ -8,18 +8,12 @@ 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
10
  import { ChoreographedContent } from '@atlaskit/link-provider/choreographed-content';
11
- import { fg } from '@atlaskit/platform-feature-flags/fg';
12
11
  import { Popup } from '@atlaskit/popup/popup';
13
12
  import { Box } from '@atlaskit/primitives/compiled/box';
14
13
  import { Inline } from '@atlaskit/primitives/compiled/inline';
15
14
  import { Pressable } from '@atlaskit/primitives/compiled/pressable';
16
15
  import { Stack } from '@atlaskit/primitives/compiled/stack';
17
16
  import { Text } from '@atlaskit/primitives/compiled/text';
18
- import { getAriaForTrigger } from '@atlaskit/top-layer/get-aria-for-trigger';
19
- import { fromLegacyPlacement } from '@atlaskit/top-layer/placement-map/index';
20
- import { Popover } from '@atlaskit/top-layer/popover/popover';
21
- import { useAnchoredPopover } from '@atlaskit/top-layer/use-anchored-popover';
22
- import { usePopoverId } from '@atlaskit/top-layer/use-popover-id';
23
17
  import { EVENT_CHANNEL } from '../../../../common/analytics/constants';
24
18
  import { getExtensionKey } from '../../../../state/getExtensionKey';
25
19
  import useOneClickChatSpotlightEligibility from '../../../../state/hooks/use-one-click-chat-spotlight-eligibility';
@@ -58,7 +52,22 @@ const styles = {
58
52
  body: "_u5f31ejb",
59
53
  action: "_2rko12b0 _v564k6bl _1h6d8yml _1dqonqa1 _189ee4h9 _syaz15cr _bfhk1aqn _ca0qv77o _n3tdv77o _19bvu2gc _u5f3u2gc _irr31ibz _1ggl5xtf _1di6of27"
60
54
  };
55
+ const SpotlightOpenContext = /*#__PURE__*/createContext(false);
61
56
  const TargetContext = /*#__PURE__*/createContext(null);
57
+ const PositionUpdateContext = /*#__PURE__*/createContext(null);
58
+ function LegacyPositionUpdater({
59
+ update
60
+ }) {
61
+ const positionUpdate = useContext(PositionUpdateContext);
62
+ useEffect(() => {
63
+ if (!positionUpdate) return;
64
+ positionUpdate.current = update;
65
+ return () => {
66
+ positionUpdate.current = undefined;
67
+ };
68
+ }, [positionUpdate, update]);
69
+ return null;
70
+ }
62
71
 
63
72
  // Keep Popup's inline trigger and focus handling. The design-system Spotlight
64
73
  // target renders a block element; the Smart Link action must stay inline.
@@ -73,7 +82,9 @@ const SpotlightSurface = /*#__PURE__*/forwardRef(({
73
82
  isReferenceHidden: _hidden,
74
83
  ...props
75
84
  }, forwardedRef) => {
85
+ const isOpen = useContext(SpotlightOpenContext);
76
86
  const target = useContext(TargetContext);
87
+ const positionUpdate = useContext(PositionUpdateContext);
77
88
  const surface = useRef(null);
78
89
  const [caret, setCaret] = useState({
79
90
  above: false,
@@ -86,36 +97,37 @@ const SpotlightSurface = /*#__PURE__*/forwardRef(({
86
97
  useEffect(() => {
87
98
  const element = surface.current;
88
99
  const anchor = target === null || target === void 0 ? void 0 : target.current;
89
- if (!element || !anchor) return;
100
+ if (!isOpen || !element || !anchor) return;
90
101
  let frame = 0;
102
+ let previousTrigger;
103
+ let previousCaret;
104
+ // Navigation can translate the anchor without a resize or scroll event.
105
+ // Only the visible spotlight samples geometry; unchanged geometry causes no updates.
91
106
  const measure = () => {
107
+ var _previousCaret;
108
+ frame = requestAnimationFrame(measure);
92
109
  const card = element.getBoundingClientRect();
93
110
  const trigger = anchor.getBoundingClientRect();
111
+ if (previousTrigger && (trigger.left !== previousTrigger.left || trigger.top !== previousTrigger.top || trigger.width !== previousTrigger.width || trigger.height !== previousTrigger.height)) {
112
+ var _positionUpdate$curre;
113
+ // Reuse Popup's positioning engine rather than moving its DOM ourselves.
114
+ void (positionUpdate === null || positionUpdate === void 0 ? void 0 : (_positionUpdate$curre = positionUpdate.current) === null || _positionUpdate$curre === void 0 ? void 0 : _positionUpdate$curre.call(positionUpdate));
115
+ }
116
+ previousTrigger = trigger;
94
117
  if (!card.width) return;
95
118
  const above = card.bottom <= trigger.top;
96
119
  const left = Math.max(16, Math.min(card.width - 32, trigger.left + trigger.width / 2 - card.left - 8));
97
- setCaret(previous => previous.above === above && previous.left === left ? previous : {
98
- above,
99
- left
100
- });
101
- };
102
- const schedule = () => {
103
- cancelAnimationFrame(frame);
104
- frame = requestAnimationFrame(measure);
105
- };
106
- const observer = new ResizeObserver(schedule);
107
- observer.observe(element);
108
- observer.observe(anchor);
109
- window.addEventListener('resize', schedule);
110
- window.addEventListener('scroll', schedule, true);
111
- schedule();
112
- return () => {
113
- cancelAnimationFrame(frame);
114
- observer.disconnect();
115
- window.removeEventListener('resize', schedule);
116
- window.removeEventListener('scroll', schedule, true);
120
+ if (((_previousCaret = previousCaret) === null || _previousCaret === void 0 ? void 0 : _previousCaret.above) !== above || previousCaret.left !== left) {
121
+ previousCaret = {
122
+ above,
123
+ left
124
+ };
125
+ setCaret(previousCaret);
126
+ }
117
127
  };
118
- }, [target]);
128
+ frame = requestAnimationFrame(measure);
129
+ return () => cancelAnimationFrame(frame);
130
+ }, [target, positionUpdate, isOpen]);
119
131
  return /*#__PURE__*/React.createElement("div", _extends({}, props, {
120
132
  ref: ref,
121
133
  style: style,
@@ -130,50 +142,6 @@ const SpotlightSurface = /*#__PURE__*/forwardRef(({
130
142
  xcss: styles.card
131
143
  }, children));
132
144
  });
133
-
134
- // The native auto popover used by Popup can hide independently of React state.
135
- // Compose the existing manual primitive here so persistence stays local to Smart Card.
136
- function TopLayerSpotlight({
137
- isOpen,
138
- label,
139
- trigger,
140
- children
141
- }) {
142
- const anchorRef = useRef(null);
143
- const popoverRef = useRef(null);
144
- const id = usePopoverId();
145
- const placement = fromLegacyPlacement({
146
- legacy: 'bottom-start'
147
- });
148
- useAnchoredPopover({
149
- anchorRef,
150
- popoverRef,
151
- isOpen,
152
- placement,
153
- inlineSize: 'max-available',
154
- blockSize: 'max-available'
155
- });
156
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", _extends({
157
- ref: anchorRef
158
- }, getAriaForTrigger({
159
- role: 'dialog',
160
- isOpen,
161
- popoverId: id
162
- })), trigger), /*#__PURE__*/React.createElement(Popover, {
163
- ref: popoverRef,
164
- id: id,
165
- isOpen: isOpen,
166
- mode: "manual",
167
- role: "dialog",
168
- label: label,
169
- shouldAnimate: true,
170
- placement: placement
171
- }, /*#__PURE__*/React.createElement(SpotlightSurface, {
172
- tabIndex: -1,
173
- "data-placement": "bottom-start",
174
- style: {}
175
- }, children)));
176
- }
177
145
  function VisibleSpotlightCard({
178
146
  onShown,
179
147
  body,
@@ -217,6 +185,7 @@ export function OneClickChatSpotlight({
217
185
  }) {
218
186
  const intl = useIntl();
219
187
  const target = useRef(null);
188
+ const positionUpdate = useRef(undefined);
220
189
  const [isOpportunity, setOpportunity] = useState(false);
221
190
  const {
222
191
  createAnalyticsEvent
@@ -310,22 +279,29 @@ export function OneClickChatSpotlight({
310
279
  onKeyPress: event => event.stopPropagation()
311
280
  }, /*#__PURE__*/React.createElement(TargetContext.Provider, {
312
281
  value: target
313
- }, fg('platform-dst-top-layer') ? /*#__PURE__*/React.createElement(TopLayerSpotlight, {
314
- isOpen: hasPermission,
315
- label: intl.formatMessage(messages.heading),
316
- trigger: trigger
317
- }, content) : /*#__PURE__*/React.createElement(Popup, {
282
+ }, /*#__PURE__*/React.createElement(PositionUpdateContext.Provider, {
283
+ value: positionUpdate
284
+ }, /*#__PURE__*/React.createElement(SpotlightOpenContext.Provider, {
285
+ value: hasPermission
286
+ }, /*#__PURE__*/React.createElement(Popup, {
287
+ mode: "manual",
318
288
  popupComponent: SpotlightSurface,
319
289
  shouldFitViewport: true,
320
290
  isOpen: hasPermission,
321
291
  placement: "bottom-start",
322
292
  role: "dialog",
323
- label: intl.formatMessage(messages.heading),
293
+ label: intl.formatMessage(messages.heading)
294
+ // This span only anchors the popup; it does not toggle it.
295
+ ,
324
296
  trigger: ({
325
297
  ref
326
298
  }) => /*#__PURE__*/React.createElement("span", {
327
299
  ref: ref
328
300
  }, trigger),
329
- content: () => content
330
- }))));
301
+ content: ({
302
+ update
303
+ }) => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LegacyPositionUpdater, {
304
+ update: update
305
+ }), content)
306
+ }))))));
331
307
  }
@@ -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.16",
12
+ packageVersion: "46.13.17",
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.13.16" || ''
7
+ packageVersion: "46.13.17" || ''
8
8
  };
9
9
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -79,7 +79,7 @@ var UnauthorisedConnectWithSocialProof = function UnauthorisedConnectWithSocialP
79
79
  var canUseCachedProviderPctMap = React.useSyncExternalStore(noopSubscribe, function () {
80
80
  return true;
81
81
  }, function () {
82
- return !fg('platform_sl_inline_social_proof_hydration_fix');
82
+ return false;
83
83
  });
84
84
  var providerPctMap = canUseCachedProviderPctMap ? cachedProviderPctMap : null;
85
85
 
@@ -14,18 +14,12 @@ 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
16
  import { ChoreographedContent } from '@atlaskit/link-provider/choreographed-content';
17
- import { fg } from '@atlaskit/platform-feature-flags/fg';
18
17
  import { Popup } from '@atlaskit/popup/popup';
19
18
  import { Box } from '@atlaskit/primitives/compiled/box';
20
19
  import { Inline } from '@atlaskit/primitives/compiled/inline';
21
20
  import { Pressable } from '@atlaskit/primitives/compiled/pressable';
22
21
  import { Stack } from '@atlaskit/primitives/compiled/stack';
23
22
  import { Text } from '@atlaskit/primitives/compiled/text';
24
- import { getAriaForTrigger } from '@atlaskit/top-layer/get-aria-for-trigger';
25
- import { fromLegacyPlacement } from '@atlaskit/top-layer/placement-map/index';
26
- import { Popover } from '@atlaskit/top-layer/popover/popover';
27
- import { useAnchoredPopover } from '@atlaskit/top-layer/use-anchored-popover';
28
- import { usePopoverId } from '@atlaskit/top-layer/use-popover-id';
29
23
  import { EVENT_CHANNEL } from '../../../../common/analytics/constants';
30
24
  import { getExtensionKey } from '../../../../state/getExtensionKey';
31
25
  import useOneClickChatSpotlightEligibility from '../../../../state/hooks/use-one-click-chat-spotlight-eligibility';
@@ -64,21 +58,37 @@ var styles = {
64
58
  body: "_u5f31ejb",
65
59
  action: "_2rko12b0 _v564k6bl _1h6d8yml _1dqonqa1 _189ee4h9 _syaz15cr _bfhk1aqn _ca0qv77o _n3tdv77o _19bvu2gc _u5f3u2gc _irr31ibz _1ggl5xtf _1di6of27"
66
60
  };
61
+ var SpotlightOpenContext = /*#__PURE__*/createContext(false);
67
62
  var TargetContext = /*#__PURE__*/createContext(null);
63
+ var PositionUpdateContext = /*#__PURE__*/createContext(null);
64
+ function LegacyPositionUpdater(_ref) {
65
+ var update = _ref.update;
66
+ var positionUpdate = useContext(PositionUpdateContext);
67
+ useEffect(function () {
68
+ if (!positionUpdate) return;
69
+ positionUpdate.current = update;
70
+ return function () {
71
+ positionUpdate.current = undefined;
72
+ };
73
+ }, [positionUpdate, update]);
74
+ return null;
75
+ }
68
76
 
69
77
  // Keep Popup's inline trigger and focus handling. The design-system Spotlight
70
78
  // target renders a block element; the Smart Link action must stay inline.
71
- var SpotlightSurface = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
72
- var children = _ref.children,
73
- style = _ref.style,
74
- _fit = _ref.shouldFitViewport,
75
- _parent = _ref.shouldRenderToParent,
76
- _container = _ref.shouldFitContainer,
77
- _appearance = _ref.appearance,
78
- _xcss = _ref.xcss,
79
- _hidden = _ref.isReferenceHidden,
80
- props = _objectWithoutProperties(_ref, _excluded);
79
+ var SpotlightSurface = /*#__PURE__*/forwardRef(function (_ref2, forwardedRef) {
80
+ var children = _ref2.children,
81
+ style = _ref2.style,
82
+ _fit = _ref2.shouldFitViewport,
83
+ _parent = _ref2.shouldRenderToParent,
84
+ _container = _ref2.shouldFitContainer,
85
+ _appearance = _ref2.appearance,
86
+ _xcss = _ref2.xcss,
87
+ _hidden = _ref2.isReferenceHidden,
88
+ props = _objectWithoutProperties(_ref2, _excluded);
89
+ var isOpen = useContext(SpotlightOpenContext);
81
90
  var target = useContext(TargetContext);
91
+ var positionUpdate = useContext(PositionUpdateContext);
82
92
  var surface = useRef(null);
83
93
  var _useState = useState({
84
94
  above: false,
@@ -94,38 +104,39 @@ var SpotlightSurface = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
94
104
  useEffect(function () {
95
105
  var element = surface.current;
96
106
  var anchor = target === null || target === void 0 ? void 0 : target.current;
97
- if (!element || !anchor) return;
107
+ if (!isOpen || !element || !anchor) return;
98
108
  var frame = 0;
99
- var measure = function measure() {
109
+ var previousTrigger;
110
+ var previousCaret;
111
+ // Navigation can translate the anchor without a resize or scroll event.
112
+ // Only the visible spotlight samples geometry; unchanged geometry causes no updates.
113
+ var _measure = function measure() {
114
+ var _previousCaret;
115
+ frame = requestAnimationFrame(_measure);
100
116
  var card = element.getBoundingClientRect();
101
117
  var trigger = anchor.getBoundingClientRect();
118
+ if (previousTrigger && (trigger.left !== previousTrigger.left || trigger.top !== previousTrigger.top || trigger.width !== previousTrigger.width || trigger.height !== previousTrigger.height)) {
119
+ var _positionUpdate$curre;
120
+ // Reuse Popup's positioning engine rather than moving its DOM ourselves.
121
+ void (positionUpdate === null || positionUpdate === void 0 || (_positionUpdate$curre = positionUpdate.current) === null || _positionUpdate$curre === void 0 ? void 0 : _positionUpdate$curre.call(positionUpdate));
122
+ }
123
+ previousTrigger = trigger;
102
124
  if (!card.width) return;
103
125
  var above = card.bottom <= trigger.top;
104
126
  var left = Math.max(16, Math.min(card.width - 32, trigger.left + trigger.width / 2 - card.left - 8));
105
- setCaret(function (previous) {
106
- return previous.above === above && previous.left === left ? previous : {
127
+ if (((_previousCaret = previousCaret) === null || _previousCaret === void 0 ? void 0 : _previousCaret.above) !== above || previousCaret.left !== left) {
128
+ previousCaret = {
107
129
  above: above,
108
130
  left: left
109
131
  };
110
- });
111
- };
112
- var schedule = function schedule() {
113
- cancelAnimationFrame(frame);
114
- frame = requestAnimationFrame(measure);
132
+ setCaret(previousCaret);
133
+ }
115
134
  };
116
- var observer = new ResizeObserver(schedule);
117
- observer.observe(element);
118
- observer.observe(anchor);
119
- window.addEventListener('resize', schedule);
120
- window.addEventListener('scroll', schedule, true);
121
- schedule();
135
+ frame = requestAnimationFrame(_measure);
122
136
  return function () {
123
- cancelAnimationFrame(frame);
124
- observer.disconnect();
125
- window.removeEventListener('resize', schedule);
126
- window.removeEventListener('scroll', schedule, true);
137
+ return cancelAnimationFrame(frame);
127
138
  };
128
- }, [target]);
139
+ }, [target, positionUpdate, isOpen]);
129
140
  return /*#__PURE__*/React.createElement("div", _extends({}, props, {
130
141
  ref: ref,
131
142
  style: style,
@@ -140,49 +151,6 @@ var SpotlightSurface = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
140
151
  xcss: styles.card
141
152
  }, children));
142
153
  });
143
-
144
- // The native auto popover used by Popup can hide independently of React state.
145
- // Compose the existing manual primitive here so persistence stays local to Smart Card.
146
- function TopLayerSpotlight(_ref2) {
147
- var isOpen = _ref2.isOpen,
148
- label = _ref2.label,
149
- trigger = _ref2.trigger,
150
- children = _ref2.children;
151
- var anchorRef = useRef(null);
152
- var popoverRef = useRef(null);
153
- var id = usePopoverId();
154
- var placement = fromLegacyPlacement({
155
- legacy: 'bottom-start'
156
- });
157
- useAnchoredPopover({
158
- anchorRef: anchorRef,
159
- popoverRef: popoverRef,
160
- isOpen: isOpen,
161
- placement: placement,
162
- inlineSize: 'max-available',
163
- blockSize: 'max-available'
164
- });
165
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", _extends({
166
- ref: anchorRef
167
- }, getAriaForTrigger({
168
- role: 'dialog',
169
- isOpen: isOpen,
170
- popoverId: id
171
- })), trigger), /*#__PURE__*/React.createElement(Popover, {
172
- ref: popoverRef,
173
- id: id,
174
- isOpen: isOpen,
175
- mode: "manual",
176
- role: "dialog",
177
- label: label,
178
- shouldAnimate: true,
179
- placement: placement
180
- }, /*#__PURE__*/React.createElement(SpotlightSurface, {
181
- tabIndex: -1,
182
- "data-placement": "bottom-start",
183
- style: {}
184
- }, children)));
185
- }
186
154
  function VisibleSpotlightCard(_ref3) {
187
155
  var onShown = _ref3.onShown,
188
156
  body = _ref3.body,
@@ -226,6 +194,7 @@ export function OneClickChatSpotlight(_ref4) {
226
194
  onInvoke = _ref4.onInvoke;
227
195
  var intl = useIntl();
228
196
  var target = useRef(null);
197
+ var positionUpdate = useRef(undefined);
229
198
  var _useState3 = useState(false),
230
199
  _useState4 = _slicedToArray(_useState3, 2),
231
200
  isOpportunity = _useState4[0],
@@ -325,26 +294,32 @@ export function OneClickChatSpotlight(_ref4) {
325
294
  }
326
295
  }, /*#__PURE__*/React.createElement(TargetContext.Provider, {
327
296
  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, {
297
+ }, /*#__PURE__*/React.createElement(PositionUpdateContext.Provider, {
298
+ value: positionUpdate
299
+ }, /*#__PURE__*/React.createElement(SpotlightOpenContext.Provider, {
300
+ value: hasPermission
301
+ }, /*#__PURE__*/React.createElement(Popup, {
302
+ mode: "manual",
333
303
  popupComponent: SpotlightSurface,
334
304
  shouldFitViewport: true,
335
305
  isOpen: hasPermission,
336
306
  placement: "bottom-start",
337
307
  role: "dialog",
338
- label: intl.formatMessage(messages.heading),
308
+ label: intl.formatMessage(messages.heading)
309
+ // This span only anchors the popup; it does not toggle it.
310
+ ,
339
311
  trigger: function trigger(_ref8) {
340
312
  var ref = _ref8.ref;
341
313
  return /*#__PURE__*/React.createElement("span", {
342
314
  ref: ref
343
315
  }, _trigger);
344
316
  },
345
- content: function content() {
346
- return _content;
317
+ content: function content(_ref9) {
318
+ var update = _ref9.update;
319
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LegacyPositionUpdater, {
320
+ update: update
321
+ }), _content);
347
322
  }
348
- })));
323
+ })))));
349
324
  });
350
325
  }
@@ -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.16",
15
+ packageVersion: "46.13.17",
16
16
  componentName: 'linkUrl'
17
17
  };
18
18
  var LinkUrl = function LinkUrl(_ref) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "46.13.16",
3
+ "version": "46.14.0",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -47,7 +47,7 @@
47
47
  "@atlaskit/avatar-group": "^14.4.0",
48
48
  "@atlaskit/badge": "^22.0.0",
49
49
  "@atlaskit/browser-apis": "^1.2.0",
50
- "@atlaskit/button": "^25.7.0",
50
+ "@atlaskit/button": "^25.8.0",
51
51
  "@atlaskit/checkbox": "^19.3.0",
52
52
  "@atlaskit/css": "^1.1.0",
53
53
  "@atlaskit/docs": "^12.3.0",
@@ -94,10 +94,10 @@
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": "^260.0.0",
97
+ "@atlaskit/tmp-editor-statsig": "^261.0.0",
98
98
  "@atlaskit/tokens": "^20.11.0",
99
99
  "@atlaskit/tooltip": "^24.4.0",
100
- "@atlaskit/top-layer": "^7.1.0",
100
+ "@atlaskit/top-layer": "^7.2.0",
101
101
  "@atlaskit/ufo": "^2.0.0",
102
102
  "@atlaskit/width-detector": "^7.2.0",
103
103
  "@babel/runtime": "^7.0.0",
@@ -141,7 +141,7 @@
141
141
  "@atlassian/analytics-tooling": "workspace:^",
142
142
  "@atlassian/experiment-test-utils": "^0.2.0",
143
143
  "@atlassian/feature-flags-test-utils": "^1.3.0",
144
- "@atlassian/gemini": "^1.54.0",
144
+ "@atlassian/gemini": "^1.55.0",
145
145
  "@atlassian/structured-docs-types": "workspace:^",
146
146
  "@atlassian/testing-library": "^0.12.0",
147
147
  "@atlassian/workbench": "workspace:*",