@atlaskit/smart-card 46.6.1 → 46.6.3

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,21 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 46.6.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`a611c962045d6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a611c962045d6) -
8
+ Keep the One Click Chat V2 spotlight open on outside clicks behind
9
+ platform_sl_one_click_chat_spotlight_v2_fg, using the existing manual top-layer popover when
10
+ enabled. Retain explicit CTA, close-button, and Escape interactions.
11
+ - Updated dependencies
12
+
13
+ ## 46.6.2
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies
18
+
3
19
  ## 46.6.1
4
20
 
5
21
  ### 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.6.0" || ''
28
+ packageVersion: "46.6.2" || ''
29
29
  };
30
30
  var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
31
31
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -6,7 +6,14 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
- var _builders = require("@atlaskit/adf-utils/builders");
9
+ var _bulletList = require("@atlaskit/adf-utils/bullet-list");
10
+ var _code = require("@atlaskit/adf-utils/code");
11
+ var _doc = require("@atlaskit/adf-utils/doc");
12
+ var _inlineCard = require("@atlaskit/adf-utils/inline-card");
13
+ var _listItem = require("@atlaskit/adf-utils/list-item");
14
+ var _paragraph = require("@atlaskit/adf-utils/paragraph");
15
+ var _strong = require("@atlaskit/adf-utils/strong");
16
+ var _text = require("@atlaskit/adf-utils/text");
10
17
  /**
11
18
  * This is a simplified version of html to adf conversion,
12
19
  * used specifically for SL RovoChatAction prompt message,
@@ -73,19 +80,19 @@ var buildListItem = function buildListItem() {
73
80
  });
74
81
  if (hasOnlyInlineContent) {
75
82
  // Wrap text content in a paragraph
76
- return (0, _builders.li)([_builders.p.apply(void 0, (0, _toConsumableArray2.default)(content))]);
83
+ return (0, _listItem.listItem)([_paragraph.paragraph.apply(void 0, (0, _toConsumableArray2.default)(content))]);
77
84
  }
78
85
 
79
86
  // Content has block elements (like nested lists), use as-is
80
- return (0, _builders.li)(content);
87
+ return (0, _listItem.listItem)(content);
81
88
  };
82
89
  var blockToAdf = function blockToAdf(tagName) {
83
90
  var content = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
84
91
  switch (tagName) {
85
92
  case 'p':
86
- return _builders.p.apply(void 0, (0, _toConsumableArray2.default)(content));
93
+ return _paragraph.paragraph.apply(void 0, (0, _toConsumableArray2.default)(content));
87
94
  case 'ul':
88
- return _builders.ul.apply(void 0, (0, _toConsumableArray2.default)(content));
95
+ return _bulletList.bulletList.apply(void 0, (0, _toConsumableArray2.default)(content));
89
96
  case 'li':
90
97
  return buildListItem(content);
91
98
  }
@@ -94,16 +101,16 @@ var inlineToAdf = function inlineToAdf(tagName, content) {
94
101
  switch (tagName) {
95
102
  case 'b':
96
103
  case 'strong':
97
- return (0, _builders.b)(content);
104
+ return (0, _strong.strong)(content);
98
105
  case 'code':
99
- return (0, _builders.code)(content);
106
+ return (0, _code.code)(content);
100
107
  case 'a':
101
108
  case 'inlineCard':
102
- return (0, _builders.inlineCard)({
109
+ return (0, _inlineCard.inlineCard)({
103
110
  url: content
104
111
  });
105
112
  default:
106
- return (0, _builders.text)(content);
113
+ return (0, _text.text)(content);
107
114
  }
108
115
  };
109
116
  var parseTokensToAdf = function parseTokensToAdf(tokens) {
@@ -172,7 +179,7 @@ var htmlToAdf = function htmlToAdf(html) {
172
179
  try {
173
180
  var tokens = tokenizeHtml(html);
174
181
  var adfContent = parseTokensToAdf(tokens);
175
- return _builders.doc.apply(void 0, (0, _toConsumableArray2.default)(adfContent));
182
+ return _doc.doc.apply(void 0, (0, _toConsumableArray2.default)(adfContent));
176
183
  } catch (_unused) {
177
184
  return html;
178
185
  }
@@ -18,12 +18,18 @@ 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 _fg = require("@atlaskit/platform-feature-flags/fg");
21
22
  var _popup = require("@atlaskit/popup/popup");
22
23
  var _box = require("@atlaskit/primitives/compiled/box");
23
24
  var _inline = require("@atlaskit/primitives/compiled/inline");
24
25
  var _pressable = require("@atlaskit/primitives/compiled/pressable");
25
26
  var _stack = require("@atlaskit/primitives/compiled/stack");
26
27
  var _text = require("@atlaskit/primitives/compiled/text");
28
+ var _getAriaForTrigger = require("@atlaskit/top-layer/get-aria-for-trigger");
29
+ var _index = require("@atlaskit/top-layer/placement-map/index");
30
+ var _popover = require("@atlaskit/top-layer/popover/popover");
31
+ var _useAnchoredPopover = require("@atlaskit/top-layer/use-anchored-popover");
32
+ var _usePopoverId = require("@atlaskit/top-layer/use-popover-id");
27
33
  var _constants = require("../../../../common/analytics/constants");
28
34
  var _getExtensionKey = require("../../../../state/getExtensionKey");
29
35
  var _useOneClickChatSpotlightEligibility = _interopRequireDefault(require("../../../../state/hooks/use-one-click-chat-spotlight-eligibility"));
@@ -68,7 +74,7 @@ var styles = {
68
74
  };
69
75
  var TargetContext = /*#__PURE__*/(0, _react.createContext)(null);
70
76
 
71
- // Keep Popup's inline trigger, dismissal and focus handling. The design-system Spotlight
77
+ // Keep Popup's inline trigger and focus handling. The design-system Spotlight
72
78
  // target renders a block element; the Smart Link action must stay inline.
73
79
  var SpotlightSurface = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, forwardedRef) {
74
80
  var children = _ref.children,
@@ -142,13 +148,56 @@ var SpotlightSurface = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, forwa
142
148
  xcss: styles.card
143
149
  }, children));
144
150
  });
145
- function VisibleSpotlightCard(_ref2) {
146
- var onShown = _ref2.onShown,
147
- body = _ref2.body,
148
- dismissLabel = _ref2.dismissLabel,
149
- actionLabel = _ref2.actionLabel,
150
- onDismiss = _ref2.onDismiss,
151
- onAction = _ref2.onAction;
151
+
152
+ // The native auto popover used by Popup can hide independently of React state.
153
+ // Compose the existing manual primitive here so persistence stays local to Smart Card.
154
+ function TopLayerSpotlight(_ref2) {
155
+ var isOpen = _ref2.isOpen,
156
+ label = _ref2.label,
157
+ trigger = _ref2.trigger,
158
+ children = _ref2.children;
159
+ var anchorRef = (0, _react.useRef)(null);
160
+ var popoverRef = (0, _react.useRef)(null);
161
+ var id = (0, _usePopoverId.usePopoverId)();
162
+ var placement = (0, _index.fromLegacyPlacement)({
163
+ legacy: 'bottom-start'
164
+ });
165
+ (0, _useAnchoredPopover.useAnchoredPopover)({
166
+ anchorRef: anchorRef,
167
+ popoverRef: popoverRef,
168
+ isOpen: isOpen,
169
+ placement: placement,
170
+ inlineSize: 'max-available',
171
+ blockSize: 'max-available'
172
+ });
173
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", (0, _extends2.default)({
174
+ ref: anchorRef
175
+ }, (0, _getAriaForTrigger.getAriaForTrigger)({
176
+ role: 'dialog',
177
+ isOpen: isOpen,
178
+ popoverId: id
179
+ })), trigger), /*#__PURE__*/_react.default.createElement(_popover.Popover, {
180
+ ref: popoverRef,
181
+ id: id,
182
+ isOpen: isOpen,
183
+ mode: "manual",
184
+ role: "dialog",
185
+ label: label,
186
+ shouldAnimate: true,
187
+ placement: placement
188
+ }, /*#__PURE__*/_react.default.createElement(SpotlightSurface, {
189
+ tabIndex: -1,
190
+ "data-placement": "bottom-start",
191
+ style: {}
192
+ }, children)));
193
+ }
194
+ function VisibleSpotlightCard(_ref3) {
195
+ var onShown = _ref3.onShown,
196
+ body = _ref3.body,
197
+ dismissLabel = _ref3.dismissLabel,
198
+ actionLabel = _ref3.actionLabel,
199
+ onDismiss = _ref3.onDismiss,
200
+ onAction = _ref3.onAction;
152
201
  (0, _react.useEffect)(function () {
153
202
  return onShown();
154
203
  }, [onShown]);
@@ -178,11 +227,11 @@ function VisibleSpotlightCard(_ref2) {
178
227
  color: "color.text.inverse"
179
228
  }, actionLabel)))));
180
229
  }
181
- function OneClickChatSpotlight(_ref3) {
182
- var children = _ref3.children,
183
- url = _ref3.url,
184
- actionOptions = _ref3.actionOptions,
185
- onInvoke = _ref3.onInvoke;
230
+ function OneClickChatSpotlight(_ref4) {
231
+ var children = _ref4.children,
232
+ url = _ref4.url,
233
+ actionOptions = _ref4.actionOptions,
234
+ onInvoke = _ref4.onInvoke;
186
235
  var intl = (0, _reactIntl.useIntl)();
187
236
  var target = (0, _react.useRef)(null);
188
237
  var _useState3 = (0, _react.useState)(false),
@@ -228,9 +277,9 @@ function OneClickChatSpotlight(_ref3) {
228
277
  var update = function update() {
229
278
  return setOpportunity(intersects && doc.visibilityState === 'visible');
230
279
  };
231
- var observer = new IntersectionObserver(function (_ref4) {
232
- var _ref5 = (0, _slicedToArray2.default)(_ref4, 1),
233
- entry = _ref5[0];
280
+ var observer = new IntersectionObserver(function (_ref5) {
281
+ var _ref6 = (0, _slicedToArray2.default)(_ref5, 1),
282
+ entry = _ref6[0];
234
283
  intersects = entry.isIntersecting;
235
284
  update();
236
285
  });
@@ -241,6 +290,21 @@ function OneClickChatSpotlight(_ref3) {
241
290
  doc.removeEventListener('visibilitychange', update);
242
291
  };
243
292
  }, []);
293
+ var _trigger = /*#__PURE__*/_react.default.createElement("span", {
294
+ onClickCapture: function onClickCapture() {
295
+ if (spotlight.isEligible) spotlight.onClick('inlineAction');
296
+ }
297
+ }, children);
298
+ var _content = /*#__PURE__*/_react.default.createElement(VisibleSpotlightCard, {
299
+ onShown: spotlight.onShown,
300
+ body: intl.formatMessage(messages.body),
301
+ dismissLabel: intl.formatMessage(messages.dismiss),
302
+ actionLabel: intl.formatMessage(messages.action),
303
+ onDismiss: spotlight.onDismiss,
304
+ onAction: function onAction() {
305
+ if (spotlight.onClick('spotlightCta')) onInvoke();
306
+ }
307
+ });
244
308
  return /*#__PURE__*/_react.default.createElement("span", {
245
309
  ref: target,
246
310
  role: "none",
@@ -248,46 +312,40 @@ function OneClickChatSpotlight(_ref3) {
248
312
  // Top-layer popups remain inside the Smart Link's anchor in the DOM.
249
313
  event.preventDefault();
250
314
  event.stopPropagation();
315
+ },
316
+ onKeyDown: function onKeyDown(event) {
317
+ if (event.key === 'Escape' && spotlight.isEligible) {
318
+ event.preventDefault();
319
+ event.stopPropagation();
320
+ spotlight.onDismiss();
321
+ }
251
322
  }
252
- // Match the enclosing Smart Link's keypress handler; leave Escape keydown for Popup.
323
+ // Match the enclosing Smart Link's keypress handler.
253
324
  ,
254
325
  onKeyPress: function onKeyPress(event) {
255
326
  return event.stopPropagation();
256
327
  }
257
328
  }, /*#__PURE__*/_react.default.createElement(TargetContext.Provider, {
258
329
  value: target
259
- }, /*#__PURE__*/_react.default.createElement(_popup.Popup, {
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, {
260
335
  popupComponent: SpotlightSurface,
261
336
  shouldFitViewport: true,
262
337
  isOpen: spotlight.isEligible,
263
- onClose: spotlight.onDismiss,
264
338
  placement: "bottom-start",
265
339
  role: "dialog",
266
340
  label: intl.formatMessage(messages.heading),
267
- trigger: function trigger(_ref6) {
268
- var ref = _ref6.ref;
341
+ trigger: function trigger(_ref7) {
342
+ var ref = _ref7.ref;
269
343
  return /*#__PURE__*/_react.default.createElement("span", {
270
- ref: ref,
271
- onClickCapture: function onClickCapture() {
272
- if (spotlight.isEligible) {
273
- spotlight.onClick('inlineAction');
274
- }
275
- }
276
- }, children);
344
+ ref: ref
345
+ }, _trigger);
277
346
  },
278
347
  content: function content() {
279
- return /*#__PURE__*/_react.default.createElement(VisibleSpotlightCard, {
280
- onShown: spotlight.onShown,
281
- body: intl.formatMessage(messages.body),
282
- dismissLabel: intl.formatMessage(messages.dismiss),
283
- actionLabel: intl.formatMessage(messages.action),
284
- onDismiss: spotlight.onDismiss,
285
- onAction: function onAction() {
286
- if (spotlight.onClick('spotlightCta')) {
287
- onInvoke();
288
- }
289
- }
290
- });
348
+ return _content;
291
349
  }
292
350
  })));
293
351
  }
@@ -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.6.0",
22
+ packageVersion: "46.6.2",
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.6.0" || ''
7
+ packageVersion: "46.6.2" || ''
8
8
  };
9
9
  export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -6,7 +6,14 @@
6
6
  * Support: p, ul, li, text, b, strong, code, inlineCard (replace a hyperlink)
7
7
  */
8
8
 
9
- import { code, doc, inlineCard, p, b, ul, li, text } from '@atlaskit/adf-utils/builders';
9
+ import { bulletList as ul } from '@atlaskit/adf-utils/bullet-list';
10
+ import { code } from '@atlaskit/adf-utils/code';
11
+ import { doc } from '@atlaskit/adf-utils/doc';
12
+ import { inlineCard } from '@atlaskit/adf-utils/inline-card';
13
+ import { listItem as li } from '@atlaskit/adf-utils/list-item';
14
+ import { paragraph as p } from '@atlaskit/adf-utils/paragraph';
15
+ import { strong as b } from '@atlaskit/adf-utils/strong';
16
+ import { text } from '@atlaskit/adf-utils/text';
10
17
  const INLINE_TAG_NAMES = ['b', 'strong', 'code', 'a', 'inlineCard'];
11
18
  const BLOCK_TAG_NAMES = ['p', 'ul', 'ol', 'li'];
12
19
 
@@ -7,12 +7,18 @@ 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 { fg } from '@atlaskit/platform-feature-flags/fg';
10
11
  import { Popup } from '@atlaskit/popup/popup';
11
12
  import { Box } from '@atlaskit/primitives/compiled/box';
12
13
  import { Inline } from '@atlaskit/primitives/compiled/inline';
13
14
  import { Pressable } from '@atlaskit/primitives/compiled/pressable';
14
15
  import { Stack } from '@atlaskit/primitives/compiled/stack';
15
16
  import { Text } from '@atlaskit/primitives/compiled/text';
17
+ import { getAriaForTrigger } from '@atlaskit/top-layer/get-aria-for-trigger';
18
+ import { fromLegacyPlacement } from '@atlaskit/top-layer/placement-map/index';
19
+ import { Popover } from '@atlaskit/top-layer/popover/popover';
20
+ import { useAnchoredPopover } from '@atlaskit/top-layer/use-anchored-popover';
21
+ import { usePopoverId } from '@atlaskit/top-layer/use-popover-id';
16
22
  import { EVENT_CHANNEL } from '../../../../common/analytics/constants';
17
23
  import { getExtensionKey } from '../../../../state/getExtensionKey';
18
24
  import useOneClickChatSpotlightEligibility from '../../../../state/hooks/use-one-click-chat-spotlight-eligibility';
@@ -53,7 +59,7 @@ const styles = {
53
59
  };
54
60
  const TargetContext = /*#__PURE__*/createContext(null);
55
61
 
56
- // Keep Popup's inline trigger, dismissal and focus handling. The design-system Spotlight
62
+ // Keep Popup's inline trigger and focus handling. The design-system Spotlight
57
63
  // target renders a block element; the Smart Link action must stay inline.
58
64
  const SpotlightSurface = /*#__PURE__*/forwardRef(({
59
65
  children,
@@ -123,6 +129,50 @@ const SpotlightSurface = /*#__PURE__*/forwardRef(({
123
129
  xcss: styles.card
124
130
  }, children));
125
131
  });
132
+
133
+ // The native auto popover used by Popup can hide independently of React state.
134
+ // Compose the existing manual primitive here so persistence stays local to Smart Card.
135
+ function TopLayerSpotlight({
136
+ isOpen,
137
+ label,
138
+ trigger,
139
+ children
140
+ }) {
141
+ const anchorRef = useRef(null);
142
+ const popoverRef = useRef(null);
143
+ const id = usePopoverId();
144
+ const placement = fromLegacyPlacement({
145
+ legacy: 'bottom-start'
146
+ });
147
+ useAnchoredPopover({
148
+ anchorRef,
149
+ popoverRef,
150
+ isOpen,
151
+ placement,
152
+ inlineSize: 'max-available',
153
+ blockSize: 'max-available'
154
+ });
155
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", _extends({
156
+ ref: anchorRef
157
+ }, getAriaForTrigger({
158
+ role: 'dialog',
159
+ isOpen,
160
+ popoverId: id
161
+ })), trigger), /*#__PURE__*/React.createElement(Popover, {
162
+ ref: popoverRef,
163
+ id: id,
164
+ isOpen: isOpen,
165
+ mode: "manual",
166
+ role: "dialog",
167
+ label: label,
168
+ shouldAnimate: true,
169
+ placement: placement
170
+ }, /*#__PURE__*/React.createElement(SpotlightSurface, {
171
+ tabIndex: -1,
172
+ "data-placement": "bottom-start",
173
+ style: {}
174
+ }, children)));
175
+ }
126
176
  function VisibleSpotlightCard({
127
177
  onShown,
128
178
  body,
@@ -218,6 +268,21 @@ export function OneClickChatSpotlight({
218
268
  doc.removeEventListener('visibilitychange', update);
219
269
  };
220
270
  }, []);
271
+ const trigger = /*#__PURE__*/React.createElement("span", {
272
+ onClickCapture: () => {
273
+ if (spotlight.isEligible) spotlight.onClick('inlineAction');
274
+ }
275
+ }, children);
276
+ const content = /*#__PURE__*/React.createElement(VisibleSpotlightCard, {
277
+ onShown: spotlight.onShown,
278
+ body: intl.formatMessage(messages.body),
279
+ dismissLabel: intl.formatMessage(messages.dismiss),
280
+ actionLabel: intl.formatMessage(messages.action),
281
+ onDismiss: spotlight.onDismiss,
282
+ onAction: () => {
283
+ if (spotlight.onClick('spotlightCta')) onInvoke();
284
+ }
285
+ });
221
286
  return /*#__PURE__*/React.createElement("span", {
222
287
  ref: target,
223
288
  role: "none",
@@ -225,41 +290,35 @@ export function OneClickChatSpotlight({
225
290
  // Top-layer popups remain inside the Smart Link's anchor in the DOM.
226
291
  event.preventDefault();
227
292
  event.stopPropagation();
293
+ },
294
+ onKeyDown: event => {
295
+ if (event.key === 'Escape' && spotlight.isEligible) {
296
+ event.preventDefault();
297
+ event.stopPropagation();
298
+ spotlight.onDismiss();
299
+ }
228
300
  }
229
- // Match the enclosing Smart Link's keypress handler; leave Escape keydown for Popup.
301
+ // Match the enclosing Smart Link's keypress handler.
230
302
  ,
231
303
  onKeyPress: event => event.stopPropagation()
232
304
  }, /*#__PURE__*/React.createElement(TargetContext.Provider, {
233
305
  value: target
234
- }, /*#__PURE__*/React.createElement(Popup, {
306
+ }, fg('platform-dst-top-layer') ? /*#__PURE__*/React.createElement(TopLayerSpotlight, {
307
+ isOpen: spotlight.isEligible,
308
+ label: intl.formatMessage(messages.heading),
309
+ trigger: trigger
310
+ }, content) : /*#__PURE__*/React.createElement(Popup, {
235
311
  popupComponent: SpotlightSurface,
236
312
  shouldFitViewport: true,
237
313
  isOpen: spotlight.isEligible,
238
- onClose: spotlight.onDismiss,
239
314
  placement: "bottom-start",
240
315
  role: "dialog",
241
316
  label: intl.formatMessage(messages.heading),
242
317
  trigger: ({
243
318
  ref
244
319
  }) => /*#__PURE__*/React.createElement("span", {
245
- ref: ref,
246
- onClickCapture: () => {
247
- if (spotlight.isEligible) {
248
- spotlight.onClick('inlineAction');
249
- }
250
- }
251
- }, children),
252
- content: () => /*#__PURE__*/React.createElement(VisibleSpotlightCard, {
253
- onShown: spotlight.onShown,
254
- body: intl.formatMessage(messages.body),
255
- dismissLabel: intl.formatMessage(messages.dismiss),
256
- actionLabel: intl.formatMessage(messages.action),
257
- onDismiss: spotlight.onDismiss,
258
- onAction: () => {
259
- if (spotlight.onClick('spotlightCta')) {
260
- onInvoke();
261
- }
262
- }
263
- })
320
+ ref: ref
321
+ }, trigger),
322
+ content: () => content
264
323
  })));
265
324
  }
@@ -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.6.0",
12
+ packageVersion: "46.6.2",
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.6.0" || ''
7
+ packageVersion: "46.6.2" || ''
8
8
  };
9
9
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -7,7 +7,14 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
7
7
  * Support: p, ul, li, text, b, strong, code, inlineCard (replace a hyperlink)
8
8
  */
9
9
 
10
- import { code, doc, inlineCard, p, b, ul, li, text } from '@atlaskit/adf-utils/builders';
10
+ import { bulletList as ul } from '@atlaskit/adf-utils/bullet-list';
11
+ import { code } from '@atlaskit/adf-utils/code';
12
+ import { doc } from '@atlaskit/adf-utils/doc';
13
+ import { inlineCard } from '@atlaskit/adf-utils/inline-card';
14
+ import { listItem as li } from '@atlaskit/adf-utils/list-item';
15
+ import { paragraph as p } from '@atlaskit/adf-utils/paragraph';
16
+ import { strong as b } from '@atlaskit/adf-utils/strong';
17
+ import { text } from '@atlaskit/adf-utils/text';
11
18
  var INLINE_TAG_NAMES = ['b', 'strong', 'code', 'a', 'inlineCard'];
12
19
  var BLOCK_TAG_NAMES = ['p', 'ul', 'ol', 'li'];
13
20
 
@@ -13,12 +13,18 @@ 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 { fg } from '@atlaskit/platform-feature-flags/fg';
16
17
  import { Popup } from '@atlaskit/popup/popup';
17
18
  import { Box } from '@atlaskit/primitives/compiled/box';
18
19
  import { Inline } from '@atlaskit/primitives/compiled/inline';
19
20
  import { Pressable } from '@atlaskit/primitives/compiled/pressable';
20
21
  import { Stack } from '@atlaskit/primitives/compiled/stack';
21
22
  import { Text } from '@atlaskit/primitives/compiled/text';
23
+ import { getAriaForTrigger } from '@atlaskit/top-layer/get-aria-for-trigger';
24
+ import { fromLegacyPlacement } from '@atlaskit/top-layer/placement-map/index';
25
+ import { Popover } from '@atlaskit/top-layer/popover/popover';
26
+ import { useAnchoredPopover } from '@atlaskit/top-layer/use-anchored-popover';
27
+ import { usePopoverId } from '@atlaskit/top-layer/use-popover-id';
22
28
  import { EVENT_CHANNEL } from '../../../../common/analytics/constants';
23
29
  import { getExtensionKey } from '../../../../state/getExtensionKey';
24
30
  import useOneClickChatSpotlightEligibility from '../../../../state/hooks/use-one-click-chat-spotlight-eligibility';
@@ -59,7 +65,7 @@ var styles = {
59
65
  };
60
66
  var TargetContext = /*#__PURE__*/createContext(null);
61
67
 
62
- // Keep Popup's inline trigger, dismissal and focus handling. The design-system Spotlight
68
+ // Keep Popup's inline trigger and focus handling. The design-system Spotlight
63
69
  // target renders a block element; the Smart Link action must stay inline.
64
70
  var SpotlightSurface = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
65
71
  var children = _ref.children,
@@ -133,13 +139,56 @@ var SpotlightSurface = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
133
139
  xcss: styles.card
134
140
  }, children));
135
141
  });
136
- function VisibleSpotlightCard(_ref2) {
137
- var onShown = _ref2.onShown,
138
- body = _ref2.body,
139
- dismissLabel = _ref2.dismissLabel,
140
- actionLabel = _ref2.actionLabel,
141
- onDismiss = _ref2.onDismiss,
142
- onAction = _ref2.onAction;
142
+
143
+ // The native auto popover used by Popup can hide independently of React state.
144
+ // Compose the existing manual primitive here so persistence stays local to Smart Card.
145
+ function TopLayerSpotlight(_ref2) {
146
+ var isOpen = _ref2.isOpen,
147
+ label = _ref2.label,
148
+ trigger = _ref2.trigger,
149
+ children = _ref2.children;
150
+ var anchorRef = useRef(null);
151
+ var popoverRef = useRef(null);
152
+ var id = usePopoverId();
153
+ var placement = fromLegacyPlacement({
154
+ legacy: 'bottom-start'
155
+ });
156
+ useAnchoredPopover({
157
+ anchorRef: anchorRef,
158
+ popoverRef: popoverRef,
159
+ isOpen: isOpen,
160
+ placement: placement,
161
+ inlineSize: 'max-available',
162
+ blockSize: 'max-available'
163
+ });
164
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", _extends({
165
+ ref: anchorRef
166
+ }, getAriaForTrigger({
167
+ role: 'dialog',
168
+ isOpen: isOpen,
169
+ popoverId: id
170
+ })), trigger), /*#__PURE__*/React.createElement(Popover, {
171
+ ref: popoverRef,
172
+ id: id,
173
+ isOpen: isOpen,
174
+ mode: "manual",
175
+ role: "dialog",
176
+ label: label,
177
+ shouldAnimate: true,
178
+ placement: placement
179
+ }, /*#__PURE__*/React.createElement(SpotlightSurface, {
180
+ tabIndex: -1,
181
+ "data-placement": "bottom-start",
182
+ style: {}
183
+ }, children)));
184
+ }
185
+ function VisibleSpotlightCard(_ref3) {
186
+ var onShown = _ref3.onShown,
187
+ body = _ref3.body,
188
+ dismissLabel = _ref3.dismissLabel,
189
+ actionLabel = _ref3.actionLabel,
190
+ onDismiss = _ref3.onDismiss,
191
+ onAction = _ref3.onAction;
143
192
  useEffect(function () {
144
193
  return onShown();
145
194
  }, [onShown]);
@@ -169,11 +218,11 @@ function VisibleSpotlightCard(_ref2) {
169
218
  color: "color.text.inverse"
170
219
  }, actionLabel)))));
171
220
  }
172
- export function OneClickChatSpotlight(_ref3) {
173
- var children = _ref3.children,
174
- url = _ref3.url,
175
- actionOptions = _ref3.actionOptions,
176
- onInvoke = _ref3.onInvoke;
221
+ export function OneClickChatSpotlight(_ref4) {
222
+ var children = _ref4.children,
223
+ url = _ref4.url,
224
+ actionOptions = _ref4.actionOptions,
225
+ onInvoke = _ref4.onInvoke;
177
226
  var intl = useIntl();
178
227
  var target = useRef(null);
179
228
  var _useState3 = useState(false),
@@ -219,9 +268,9 @@ export function OneClickChatSpotlight(_ref3) {
219
268
  var update = function update() {
220
269
  return setOpportunity(intersects && doc.visibilityState === 'visible');
221
270
  };
222
- var observer = new IntersectionObserver(function (_ref4) {
223
- var _ref5 = _slicedToArray(_ref4, 1),
224
- entry = _ref5[0];
271
+ var observer = new IntersectionObserver(function (_ref5) {
272
+ var _ref6 = _slicedToArray(_ref5, 1),
273
+ entry = _ref6[0];
225
274
  intersects = entry.isIntersecting;
226
275
  update();
227
276
  });
@@ -232,6 +281,21 @@ export function OneClickChatSpotlight(_ref3) {
232
281
  doc.removeEventListener('visibilitychange', update);
233
282
  };
234
283
  }, []);
284
+ var _trigger = /*#__PURE__*/React.createElement("span", {
285
+ onClickCapture: function onClickCapture() {
286
+ if (spotlight.isEligible) spotlight.onClick('inlineAction');
287
+ }
288
+ }, children);
289
+ var _content = /*#__PURE__*/React.createElement(VisibleSpotlightCard, {
290
+ onShown: spotlight.onShown,
291
+ body: intl.formatMessage(messages.body),
292
+ dismissLabel: intl.formatMessage(messages.dismiss),
293
+ actionLabel: intl.formatMessage(messages.action),
294
+ onDismiss: spotlight.onDismiss,
295
+ onAction: function onAction() {
296
+ if (spotlight.onClick('spotlightCta')) onInvoke();
297
+ }
298
+ });
235
299
  return /*#__PURE__*/React.createElement("span", {
236
300
  ref: target,
237
301
  role: "none",
@@ -239,46 +303,40 @@ export function OneClickChatSpotlight(_ref3) {
239
303
  // Top-layer popups remain inside the Smart Link's anchor in the DOM.
240
304
  event.preventDefault();
241
305
  event.stopPropagation();
306
+ },
307
+ onKeyDown: function onKeyDown(event) {
308
+ if (event.key === 'Escape' && spotlight.isEligible) {
309
+ event.preventDefault();
310
+ event.stopPropagation();
311
+ spotlight.onDismiss();
312
+ }
242
313
  }
243
- // Match the enclosing Smart Link's keypress handler; leave Escape keydown for Popup.
314
+ // Match the enclosing Smart Link's keypress handler.
244
315
  ,
245
316
  onKeyPress: function onKeyPress(event) {
246
317
  return event.stopPropagation();
247
318
  }
248
319
  }, /*#__PURE__*/React.createElement(TargetContext.Provider, {
249
320
  value: target
250
- }, /*#__PURE__*/React.createElement(Popup, {
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, {
251
326
  popupComponent: SpotlightSurface,
252
327
  shouldFitViewport: true,
253
328
  isOpen: spotlight.isEligible,
254
- onClose: spotlight.onDismiss,
255
329
  placement: "bottom-start",
256
330
  role: "dialog",
257
331
  label: intl.formatMessage(messages.heading),
258
- trigger: function trigger(_ref6) {
259
- var ref = _ref6.ref;
332
+ trigger: function trigger(_ref7) {
333
+ var ref = _ref7.ref;
260
334
  return /*#__PURE__*/React.createElement("span", {
261
- ref: ref,
262
- onClickCapture: function onClickCapture() {
263
- if (spotlight.isEligible) {
264
- spotlight.onClick('inlineAction');
265
- }
266
- }
267
- }, children);
335
+ ref: ref
336
+ }, _trigger);
268
337
  },
269
338
  content: function content() {
270
- return /*#__PURE__*/React.createElement(VisibleSpotlightCard, {
271
- onShown: spotlight.onShown,
272
- body: intl.formatMessage(messages.body),
273
- dismissLabel: intl.formatMessage(messages.dismiss),
274
- actionLabel: intl.formatMessage(messages.action),
275
- onDismiss: spotlight.onDismiss,
276
- onAction: function onAction() {
277
- if (spotlight.onClick('spotlightCta')) {
278
- onInvoke();
279
- }
280
- }
281
- });
339
+ return _content;
282
340
  }
283
341
  })));
284
342
  }
@@ -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.6.0",
15
+ packageVersion: "46.6.2",
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.6.1",
3
+ "version": "46.6.3",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -93,9 +93,10 @@
93
93
  "@atlaskit/textfield": "^10.2.0",
94
94
  "@atlaskit/theme": "^28.2.0",
95
95
  "@atlaskit/tile": "^5.0.0",
96
- "@atlaskit/tmp-editor-statsig": "^230.0.0",
96
+ "@atlaskit/tmp-editor-statsig": "^232.0.0",
97
97
  "@atlaskit/tokens": "^20.4.0",
98
98
  "@atlaskit/tooltip": "^24.4.0",
99
+ "@atlaskit/top-layer": "^6.2.0",
99
100
  "@atlaskit/ufo": "^2.0.0",
100
101
  "@atlaskit/width-detector": "^7.2.0",
101
102
  "@babel/runtime": "^7.0.0",
@@ -166,6 +167,10 @@
166
167
  "xhr-mock": "^2.4.0"
167
168
  },
168
169
  "platform-feature-flags": {
170
+ "platform-dst-top-layer": {
171
+ "type": "boolean",
172
+ "referenceOnly": true
173
+ },
169
174
  "billplat_jira_list_dropdown_top_layer": {
170
175
  "type": "boolean",
171
176
  "referenceOnly": true