@atlaskit/smart-card 46.3.0 → 46.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/cjs/utils/analytics/analytics.js +1 -1
  3. package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +14 -1
  4. package/dist/cjs/view/InlineCard/common/one-click-chat-spotlight/async.js +37 -0
  5. package/dist/cjs/view/InlineCard/common/one-click-chat-spotlight/index.compiled.css +36 -0
  6. package/dist/cjs/view/InlineCard/common/one-click-chat-spotlight/index.js +293 -0
  7. package/dist/cjs/view/InlineCard/common/rovo-actions-cta/index.js +109 -3
  8. package/dist/cjs/view/LinkUrl/index.js +1 -1
  9. package/dist/es2019/utils/analytics/analytics.js +1 -1
  10. package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +14 -1
  11. package/dist/es2019/view/InlineCard/common/one-click-chat-spotlight/async.js +21 -0
  12. package/dist/es2019/view/InlineCard/common/one-click-chat-spotlight/index.compiled.css +36 -0
  13. package/dist/es2019/view/InlineCard/common/one-click-chat-spotlight/index.js +267 -0
  14. package/dist/es2019/view/InlineCard/common/rovo-actions-cta/index.js +93 -1
  15. package/dist/es2019/view/LinkUrl/index.js +1 -1
  16. package/dist/esm/utils/analytics/analytics.js +1 -1
  17. package/dist/esm/view/HoverCard/components/HoverCardComponent.js +14 -1
  18. package/dist/esm/view/InlineCard/common/one-click-chat-spotlight/async.js +26 -0
  19. package/dist/esm/view/InlineCard/common/one-click-chat-spotlight/index.compiled.css +36 -0
  20. package/dist/esm/view/InlineCard/common/one-click-chat-spotlight/index.js +284 -0
  21. package/dist/esm/view/InlineCard/common/rovo-actions-cta/index.js +107 -1
  22. package/dist/esm/view/LinkUrl/index.js +1 -1
  23. package/dist/types/state/hooks/use-one-click-chat-spotlight-eligibility/suppression.d.ts +1 -1
  24. package/dist/types/view/InlineCard/common/one-click-chat-spotlight/async.d.ts +6 -0
  25. package/dist/types/view/InlineCard/common/one-click-chat-spotlight/index.d.ts +12 -0
  26. package/dist/types/view/InlineCard/common/rovo-actions-cta/index.d.ts +1 -1
  27. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 46.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`f78306fac0d2b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f78306fac0d2b) -
8
+ Add the contextual inline One Click Chat Spotlight V2 UI, existing Rovo action integration and
9
+ safe analytics under platform_sl_one_click_chat_spotlight_v2_fg. Only show the spotlight when its
10
+ Rovo action is available, and prevent popup clicks from navigating the enclosing Smart Link.
11
+
12
+ Load the optional spotlight asynchronously after mount, preserving the inline action while loading
13
+ or if the chunk fails.
14
+
15
+ Preserve the original inline Rovo action implementation when the gate is off; isolate spotlight
16
+ refactoring in the gate-on component.
17
+
18
+ Match the project poster's compact dark spotlight with a caret, provider-specific message,
19
+ outlined Try Now action and accessible close control. Keep the existing gate, invocation,
20
+ analytics and dismissal cooldown behavior.
21
+
22
+ While Spotlight V2 is active, suppress competing hover previews (including pending hover timers)
23
+ so top-layer light dismissal cannot consume Try Now before the Rovo action runs.
24
+
3
25
  ## 46.3.0
4
26
 
5
27
  ### Minor 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.2.1" || ''
28
+ packageVersion: "46.3.0" || ''
29
29
  };
30
30
  var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
31
31
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -15,6 +15,7 @@ var _fg = require("@atlaskit/platform-feature-flags/fg");
15
15
  var _popup = require("@atlaskit/popup/popup");
16
16
  var _constants = require("../../../constants");
17
17
  var _actions = require("../../../state/actions");
18
+ var _suppression = require("../../../state/hooks/use-one-click-chat-spotlight-eligibility/suppression");
18
19
  var _renderers = require("../../../state/renderers");
19
20
  var _store = require("../../../state/store");
20
21
  var _SmartLinkAnalyticsContext = require("../../../utils/analytics/SmartLinkAnalyticsContext");
@@ -167,6 +168,13 @@ var HoverCardComponent = exports.HoverCardComponent = function HoverCardComponen
167
168
  }
168
169
  }, [linkState.metadataStatus, linkState.status, loadMetadata, register]);
169
170
  var initShowCard = (0, _react.useCallback)(function (event) {
171
+ // Popup events bubble through the enclosing Smart Link, including portals.
172
+ // A second top-layer popup can light-dismiss the spotlight before its click runs.
173
+ if ((0, _fg.fg)('platform_sl_one_click_chat_spotlight_v2_fg') && (0, _suppression.isSpotlightActive)()) {
174
+ initHideCard();
175
+ hideCard();
176
+ return;
177
+ }
170
178
  // clearing out fadeOutTimeoutId in case it's already counting down to hide the card
171
179
  if (fadeOutTimeoutId.current) {
172
180
  clearTimeout(fadeOutTimeoutId.current);
@@ -187,6 +195,11 @@ var HoverCardComponent = exports.HoverCardComponent = function HoverCardComponen
187
195
  }
188
196
  } else {
189
197
  fadeInTimeoutId.current = setTimeout(function () {
198
+ // The spotlight may mount while this hover delay is pending.
199
+ if ((0, _fg.fg)('platform_sl_one_click_chat_spotlight_v2_fg') && (0, _suppression.isSpotlightActive)()) {
200
+ fadeInTimeoutId.current = undefined;
201
+ return;
202
+ }
190
203
  if (handleSetIsOpen) {
191
204
  handleSetIsOpen(true);
192
205
  } else {
@@ -195,7 +208,7 @@ var HoverCardComponent = exports.HoverCardComponent = function HoverCardComponen
195
208
  }, fadeInDelay);
196
209
  }
197
210
  }
198
- }, [initResolve, isOpen, setMousePosition, noFadeDelay, fadeInDelay, handleSetIsOpen]);
211
+ }, [initResolve, isOpen, setMousePosition, noFadeDelay, fadeInDelay, handleSetIsOpen, initHideCard, hideCard]);
199
212
  var onActionClick = (0, _react.useCallback)(function (actionId) {
200
213
  if (actionId === _constants.ActionName.PreviewAction || actionId === _constants.ActionName.AutomationAction) {
201
214
  hideCard();
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.OneClickChatSpotlightLoader = OneClickChatSpotlightLoader;
9
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
+ var _react = _interopRequireWildcard(require("react"));
11
+ 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); }
12
+ /** Keep the existing action usable during SSR, loading and chunk failures. */
13
+ function OneClickChatSpotlightLoader(props) {
14
+ var _useState = (0, _react.useState)(),
15
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
16
+ Spotlight = _useState2[0],
17
+ setSpotlight = _useState2[1];
18
+ (0, _react.useEffect)(function () {
19
+ var active = true;
20
+ Promise.resolve().then(function () {
21
+ return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_smartcard-one-click-chat-spotlight" */'./index'));
22
+ }).then(function (_ref) {
23
+ var OneClickChatSpotlight = _ref.OneClickChatSpotlight;
24
+ if (active) {
25
+ setSpotlight(function () {
26
+ return OneClickChatSpotlight;
27
+ });
28
+ }
29
+ }).catch(function () {
30
+ // An optional spotlight must not break the existing inline action.
31
+ });
32
+ return function () {
33
+ active = false;
34
+ };
35
+ }, []);
36
+ return Spotlight ? /*#__PURE__*/_react.default.createElement(Spotlight, props) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, props.children);
37
+ }
@@ -0,0 +1,36 @@
1
+ ._2rko12b0{border-radius:var(--ds-radius-small,4px)}
2
+ ._2rko1qi0{border-radius:var(--ds-radius-medium,6px)}
3
+ ._v564k6bl{transition:var(--ds-button-hovered,background-color border-color .15s cubic-bezier(.4,1,.6,1))}
4
+ ._189ee4h9{border-width:var(--ds-border-width,1px)}
5
+ ._1dqonqa1{border-style:solid}
6
+ ._1h6d8yml{border-color:var(--ds-border-accent-gray,#7d818a)}._154iidpf{top:0}
7
+ ._154iu2gc{top:var(--ds-space-100,8px)}
8
+ ._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
9
+ ._18m91wug{overflow-y:auto}
10
+ ._19bvu2gc{padding-left:var(--ds-space-100,8px)}
11
+ ._19bvv77o{padding-left:var(--ds-space-025,2px)}
12
+ ._1bsb7vkz{width:1pc}
13
+ ._1bsbkpet{width:296px}
14
+ ._1reo1wug{overflow-x:auto}
15
+ ._1xi2u2gc{right:var(--ds-space-100,8px)}
16
+ ._4t3iftgi{height:8px}
17
+ ._94n5idpf{bottom:0}
18
+ ._bfhk1aqn{background-color:var(--ds-background-neutral-bold,#292a2e)}
19
+ ._ca0qu2gc{padding-top:var(--ds-space-100,8px)}
20
+ ._ca0qv77o{padding-top:var(--ds-space-025,2px)}
21
+ ._kqswh2mm{position:relative}
22
+ ._kqswstnw{position:absolute}
23
+ ._lcxvglyw{pointer-events:none}
24
+ ._mkrz1oyg{clip-path:polygon(50% 0,100% 100%,0 100%)}
25
+ ._n3tdu2gc{padding-bottom:var(--ds-space-100,8px)}
26
+ ._n3tdv77o{padding-bottom:var(--ds-space-025,2px)}
27
+ ._p12f1osq{max-width:100%}
28
+ ._syaz15cr{color:var(--ds-text-inverse,#fff)}
29
+ ._t9ec1sub{transform:rotate(180deg)}
30
+ ._u5f31ejb{padding-right:var(--ds-space-300,24px)}
31
+ ._u5f3u2gc{padding-right:var(--ds-space-100,8px)}
32
+ ._u5f3v77o{padding-right:var(--ds-space-025,2px)}
33
+ ._vchhusvi{box-sizing:border-box}
34
+ ._irr31ibz:hover{background-color:var(--ds-background-neutral-bold-hovered,#3b3d42)}
35
+ ._1ggl5xtf:active{transition:var(--ds-button-pressed,background-color border-color .15s cubic-bezier(.4,1,.6,1))}
36
+ ._1di6of27:active{background-color:var(--ds-background-neutral-bold-pressed,#505258)}
@@ -0,0 +1,293 @@
1
+ /* index.tsx generated by @compiled/babel-plugin v3.0.2 */
2
+ "use strict";
3
+
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+ Object.defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ exports.OneClickChatSpotlight = OneClickChatSpotlight;
10
+ require("./index.compiled.css");
11
+ var _runtime = require("@compiled/react/runtime");
12
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
14
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
15
+ var _react = _interopRequireWildcard(require("react"));
16
+ var _reactIntl = require("react-intl");
17
+ var _useAnalyticsEvents2 = require("@atlaskit/analytics-next/useAnalyticsEvents");
18
+ var _browserApis = require("@atlaskit/browser-apis");
19
+ var _cross = _interopRequireDefault(require("@atlaskit/icon/core/cross"));
20
+ var _popup = require("@atlaskit/popup/popup");
21
+ var _box = require("@atlaskit/primitives/compiled/box");
22
+ var _inline = require("@atlaskit/primitives/compiled/inline");
23
+ var _pressable = require("@atlaskit/primitives/compiled/pressable");
24
+ var _stack = require("@atlaskit/primitives/compiled/stack");
25
+ var _text = require("@atlaskit/primitives/compiled/text");
26
+ var _constants = require("../../../../common/analytics/constants");
27
+ var _getExtensionKey = require("../../../../state/getExtensionKey");
28
+ var _useOneClickChatSpotlightEligibility = _interopRequireDefault(require("../../../../state/hooks/use-one-click-chat-spotlight-eligibility"));
29
+ var _useRovoConfig2 = _interopRequireDefault(require("../../../../state/hooks/use-rovo-config"));
30
+ var _store = require("../../../../state/store");
31
+ var _excluded = ["children", "style", "shouldFitViewport", "shouldRenderToParent", "shouldFitContainer", "appearance", "xcss", "isReferenceHidden"];
32
+ 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); }
33
+ var messages = (0, _reactIntl.defineMessages)({
34
+ heading: {
35
+ id: 'smart-card.one-click-chat-spotlight-v2.heading.ai-non-final',
36
+ defaultMessage: 'Explore this link with Rovo',
37
+ description: 'Accessible name of a spotlight introducing the Rovo action beside a resolved Smart Link.'
38
+ },
39
+ drive: {
40
+ id: 'smart-card.one-click-chat-spotlight-v2.drive.ai-non-final',
41
+ defaultMessage: 'Discover insights from your Google Drive Smart Link using Rovo',
42
+ description: 'Spotlight text explaining that the inline action summarizes the linked Google Drive content.'
43
+ },
44
+ github: {
45
+ id: 'smart-card.one-click-chat-spotlight-v2.github.ai-non-final',
46
+ defaultMessage: 'Discover insights from your GitHub Smart Link using Rovo',
47
+ description: 'Spotlight text explaining that the inline action explains the linked GitHub code.'
48
+ },
49
+ dismiss: {
50
+ id: 'smart-card.one-click-chat-spotlight-v2.dismiss.ai-non-final',
51
+ defaultMessage: 'Dismiss spotlight',
52
+ description: 'Dismiss button in the Smart Link spotlight. Hides this spotlight for seven days.'
53
+ },
54
+ action: {
55
+ id: 'smart-card.one-click-chat-spotlight-v2.action.ai-non-final',
56
+ defaultMessage: 'Try Now',
57
+ description: 'Button in the spotlight that invokes the same Rovo action as the highlighted inline button.'
58
+ }
59
+ });
60
+ var styles = {
61
+ surface: "_1reo1wug _18m91wug _kqswh2mm _1bsbkpet _p12f1osq _vchhusvi _ca0qu2gc _n3tdu2gc _19bvu2gc _u5f3u2gc",
62
+ card: "_2rko1qi0 _bfhk1aqn _syaz15cr _16qs130s",
63
+ caret: "_kqswstnw _1bsb7vkz _4t3iftgi _bfhk1aqn _mkrz1oyg _lcxvglyw",
64
+ below: "_154iidpf",
65
+ above: "_94n5idpf _t9ec1sub",
66
+ close: "_2rko12b0 _v564k6bl _kqswstnw _154iu2gc _1xi2u2gc _ca0qv77o _n3tdv77o _19bvv77o _u5f3v77o _syaz15cr _bfhk1aqn _irr31ibz _1ggl5xtf _1di6of27",
67
+ content: "_kqswh2mm",
68
+ body: "_u5f31ejb",
69
+ action: "_2rko12b0 _v564k6bl _1h6d8yml _1dqonqa1 _189ee4h9 _syaz15cr _bfhk1aqn _ca0qv77o _n3tdv77o _19bvu2gc _u5f3u2gc _irr31ibz _1ggl5xtf _1di6of27"
70
+ };
71
+ var TargetContext = /*#__PURE__*/(0, _react.createContext)(null);
72
+
73
+ // Keep Popup's inline trigger, dismissal and focus handling. The design-system Spotlight
74
+ // target renders a block element; the Smart Link action must stay inline.
75
+ var SpotlightSurface = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, forwardedRef) {
76
+ var children = _ref.children,
77
+ style = _ref.style,
78
+ _fit = _ref.shouldFitViewport,
79
+ _parent = _ref.shouldRenderToParent,
80
+ _container = _ref.shouldFitContainer,
81
+ _appearance = _ref.appearance,
82
+ _xcss = _ref.xcss,
83
+ _hidden = _ref.isReferenceHidden,
84
+ props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
85
+ var target = (0, _react.useContext)(TargetContext);
86
+ var surface = (0, _react.useRef)(null);
87
+ var _useState = (0, _react.useState)({
88
+ above: false,
89
+ left: 24
90
+ }),
91
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
92
+ caret = _useState2[0],
93
+ setCaret = _useState2[1];
94
+ var ref = (0, _react.useCallback)(function (node) {
95
+ surface.current = node;
96
+ if (typeof forwardedRef === 'function') forwardedRef(node);else if (forwardedRef) forwardedRef.current = node;
97
+ }, [forwardedRef]);
98
+ (0, _react.useEffect)(function () {
99
+ var element = surface.current;
100
+ var anchor = target === null || target === void 0 ? void 0 : target.current;
101
+ if (!element || !anchor) return;
102
+ var frame = 0;
103
+ var measure = function measure() {
104
+ var card = element.getBoundingClientRect();
105
+ var trigger = anchor.getBoundingClientRect();
106
+ if (!card.width) return;
107
+ var above = card.bottom <= trigger.top;
108
+ var left = Math.max(16, Math.min(card.width - 32, trigger.left + trigger.width / 2 - card.left - 8));
109
+ setCaret(function (previous) {
110
+ return previous.above === above && previous.left === left ? previous : {
111
+ above: above,
112
+ left: left
113
+ };
114
+ });
115
+ };
116
+ var schedule = function schedule() {
117
+ cancelAnimationFrame(frame);
118
+ frame = requestAnimationFrame(measure);
119
+ };
120
+ var observer = new ResizeObserver(schedule);
121
+ observer.observe(element);
122
+ observer.observe(anchor);
123
+ window.addEventListener('resize', schedule);
124
+ window.addEventListener('scroll', schedule, true);
125
+ schedule();
126
+ return function () {
127
+ cancelAnimationFrame(frame);
128
+ observer.disconnect();
129
+ window.removeEventListener('resize', schedule);
130
+ window.removeEventListener('scroll', schedule, true);
131
+ };
132
+ }, [target]);
133
+ return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, props, {
134
+ ref: ref,
135
+ style: style,
136
+ className: (0, _runtime.ax)([styles.surface])
137
+ }), /*#__PURE__*/_react.default.createElement("span", {
138
+ "aria-hidden": "true",
139
+ style: {
140
+ left: caret.left
141
+ },
142
+ className: (0, _runtime.ax)([styles.caret, caret.above ? styles.above : styles.below])
143
+ }), /*#__PURE__*/_react.default.createElement(_box.Box, {
144
+ xcss: styles.card
145
+ }, children));
146
+ });
147
+ function VisibleSpotlightCard(_ref2) {
148
+ var onShown = _ref2.onShown,
149
+ body = _ref2.body,
150
+ dismissLabel = _ref2.dismissLabel,
151
+ actionLabel = _ref2.actionLabel,
152
+ onDismiss = _ref2.onDismiss,
153
+ onAction = _ref2.onAction;
154
+ (0, _react.useEffect)(function () {
155
+ return onShown();
156
+ }, [onShown]);
157
+ return /*#__PURE__*/_react.default.createElement(_box.Box, {
158
+ testId: "one-click-chat-spotlight-v2",
159
+ xcss: styles.content,
160
+ padding: "space.150"
161
+ }, /*#__PURE__*/_react.default.createElement(_pressable.Pressable, {
162
+ xcss: styles.close,
163
+ onClick: onDismiss,
164
+ "aria-label": dismissLabel
165
+ }, /*#__PURE__*/_react.default.createElement(_cross.default, {
166
+ label: "",
167
+ size: "small"
168
+ })), /*#__PURE__*/_react.default.createElement(_stack.Stack, {
169
+ space: "space.050"
170
+ }, /*#__PURE__*/_react.default.createElement(_box.Box, {
171
+ xcss: styles.body
172
+ }, /*#__PURE__*/_react.default.createElement(_text.Text, {
173
+ color: "color.text.inverse"
174
+ }, body)), /*#__PURE__*/_react.default.createElement(_inline.Inline, {
175
+ alignInline: "end"
176
+ }, /*#__PURE__*/_react.default.createElement(_pressable.Pressable, {
177
+ xcss: styles.action,
178
+ onClick: onAction
179
+ }, /*#__PURE__*/_react.default.createElement(_text.Text, {
180
+ color: "color.text.inverse"
181
+ }, actionLabel)))));
182
+ }
183
+ function OneClickChatSpotlight(_ref3) {
184
+ var children = _ref3.children,
185
+ url = _ref3.url,
186
+ actionOptions = _ref3.actionOptions,
187
+ onInvoke = _ref3.onInvoke;
188
+ var intl = (0, _reactIntl.useIntl)();
189
+ var target = (0, _react.useRef)(null);
190
+ var _useState3 = (0, _react.useState)(false),
191
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
192
+ isOpportunity = _useState4[0],
193
+ setOpportunity = _useState4[1];
194
+ var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(),
195
+ createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
196
+ var _useRovoConfig = (0, _useRovoConfig2.default)(),
197
+ product = _useRovoConfig.product;
198
+ var card = (0, _store.useSmartCardState)(url !== null && url !== void 0 ? url : '');
199
+ var provider = (0, _getExtensionKey.getExtensionKey)(card.details);
200
+ var onInteraction = (0, _react.useCallback)(function (interaction) {
201
+ createAnalyticsEvent({
202
+ eventType: interaction === 'impression' ? 'track' : 'ui',
203
+ action: interaction === 'impression' ? 'viewed' : interaction,
204
+ actionSubject: 'oneClickChatSpotlight',
205
+ actionSubjectId: 'oneClickChatSpotlightV2',
206
+ attributes: {
207
+ provider: provider === 'google-object-provider' ? 'google-drive' : 'github',
208
+ product: product === 'CONFLUENCE' ? 'confluence_web' : 'jira_web',
209
+ appearance: 'inline',
210
+ cohort: 'treatment',
211
+ variant: 'v2'
212
+ }
213
+ }).fire(_constants.EVENT_CHANNEL);
214
+ }, [createAnalyticsEvent, provider, product]);
215
+ var spotlight = (0, _useOneClickChatSpotlightEligibility.default)({
216
+ url: url,
217
+ actionOptions: actionOptions,
218
+ isOpportunity: isOpportunity,
219
+ onInteraction: onInteraction
220
+ });
221
+ (0, _react.useEffect)(function () {
222
+ var element = target.current;
223
+ var doc = (0, _browserApis.getDocument)();
224
+ if (!element || !doc || typeof IntersectionObserver === 'undefined') {
225
+ return;
226
+ }
227
+ var intersects = false;
228
+ var update = function update() {
229
+ return setOpportunity(intersects && doc.visibilityState === 'visible');
230
+ };
231
+ var observer = new IntersectionObserver(function (_ref4) {
232
+ var _ref5 = (0, _slicedToArray2.default)(_ref4, 1),
233
+ entry = _ref5[0];
234
+ intersects = entry.isIntersecting;
235
+ update();
236
+ });
237
+ observer.observe(element);
238
+ doc.addEventListener('visibilitychange', update);
239
+ return function () {
240
+ observer.disconnect();
241
+ doc.removeEventListener('visibilitychange', update);
242
+ };
243
+ }, []);
244
+ return /*#__PURE__*/_react.default.createElement("span", {
245
+ ref: target,
246
+ role: "none",
247
+ onClick: function onClick(event) {
248
+ // Top-layer popups remain inside the Smart Link's anchor in the DOM.
249
+ event.preventDefault();
250
+ event.stopPropagation();
251
+ }
252
+ // Match the enclosing Smart Link's keypress handler; leave Escape keydown for Popup.
253
+ ,
254
+ onKeyPress: function onKeyPress(event) {
255
+ return event.stopPropagation();
256
+ }
257
+ }, /*#__PURE__*/_react.default.createElement(TargetContext.Provider, {
258
+ value: target
259
+ }, /*#__PURE__*/_react.default.createElement(_popup.Popup, {
260
+ popupComponent: SpotlightSurface,
261
+ shouldFitViewport: true,
262
+ isOpen: spotlight.isEligible,
263
+ onClose: spotlight.onDismiss,
264
+ placement: "bottom-start",
265
+ role: "dialog",
266
+ label: intl.formatMessage(messages.heading),
267
+ trigger: function trigger(_ref6) {
268
+ var ref = _ref6.ref;
269
+ return /*#__PURE__*/_react.default.createElement("span", {
270
+ ref: ref,
271
+ onClickCapture: function onClickCapture() {
272
+ if (spotlight.isEligible) {
273
+ spotlight.onClick();
274
+ }
275
+ }
276
+ }, children);
277
+ },
278
+ content: function content() {
279
+ return /*#__PURE__*/_react.default.createElement(VisibleSpotlightCard, {
280
+ onShown: spotlight.onShown,
281
+ body: intl.formatMessage(provider === 'google-object-provider' ? messages.drive : messages.github),
282
+ dismissLabel: intl.formatMessage(messages.dismiss),
283
+ actionLabel: intl.formatMessage(messages.action),
284
+ onDismiss: spotlight.onDismiss,
285
+ onAction: function onAction() {
286
+ if (spotlight.onClick()) {
287
+ onInvoke();
288
+ }
289
+ }
290
+ });
291
+ }
292
+ })));
293
+ }
@@ -15,26 +15,33 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
15
15
  var _react = _interopRequireWildcard(require("react"));
16
16
  var _reactIntl = require("react-intl");
17
17
  var _extractSmartLinkProvider = require("@atlaskit/link-extractors/extract-smart-link-provider");
18
+ var _fg = require("@atlaskit/platform-feature-flags/fg");
18
19
  var _compiled = require("@atlaskit/primitives/compiled");
19
20
  var _extractRovoChatAction = _interopRequireDefault(require("../../../../extractors/flexible/actions/extract-rovo-chat-action"));
20
21
  var _getExtensionKey = require("../../../../state/getExtensionKey");
21
22
  var _useInvokeClientAction = _interopRequireDefault(require("../../../../state/hooks/use-invoke-client-action"));
22
- var _useRovoChat2 = _interopRequireDefault(require("../../../../state/hooks/use-rovo-chat"));
23
+ var _useRovoChat3 = _interopRequireDefault(require("../../../../state/hooks/use-rovo-chat"));
23
24
  var _useRovoConfig = _interopRequireDefault(require("../../../../state/hooks/use-rovo-config"));
24
25
  var _store = require("../../../../state/store");
25
26
  var _rovoChatUtils = require("../../../common/rovo-chat-utils");
26
27
  var _actionButton = require("../action-button");
28
+ var _async = require("../one-click-chat-spotlight/async");
27
29
  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); }
28
30
  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; }
29
31
  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; }
30
32
  var styles = {
31
33
  text: "_19bv12x7 _1e0c116y _4cvr1h6o _s7n4nkob _19pk1i6y"
32
34
  };
33
- var InlineRovoActionButton = exports.InlineRovoActionButton = function InlineRovoActionButton(_ref) {
35
+
36
+ // Keep the master implementation intact while the spotlight rollout is disabled.
37
+ var InlineRovoActionButton = exports.InlineRovoActionButton = function InlineRovoActionButton(props) {
38
+ return (0, _fg.fg)('platform_sl_one_click_chat_spotlight_v2_fg') ? /*#__PURE__*/_react.default.createElement(InlineRovoActionButtonWithSpotlight, props) : /*#__PURE__*/_react.default.createElement(InlineRovoActionButtonLegacy, props);
39
+ };
40
+ var InlineRovoActionButtonLegacy = function InlineRovoActionButtonLegacy(_ref) {
34
41
  var testId = _ref.testId,
35
42
  url = _ref.url,
36
43
  actionOptions = _ref.actionOptions;
37
- var _useRovoChat = (0, _useRovoChat2.default)(),
44
+ var _useRovoChat = (0, _useRovoChat3.default)(),
38
45
  sendPromptMessage = _useRovoChat.sendPromptMessage,
39
46
  isRovoChatEnabled = _useRovoChat.isRovoChatEnabled;
40
47
  var intl = (0, _reactIntl.useIntl)();
@@ -119,4 +126,103 @@ var InlineRovoActionButton = exports.InlineRovoActionButton = function InlineRov
119
126
  }, /*#__PURE__*/_react.default.createElement(_compiled.Text, {
120
127
  size: "small"
121
128
  }, content))) : null;
129
+ };
130
+ var InlineRovoActionButtonWithSpotlight = function InlineRovoActionButtonWithSpotlight(_ref3) {
131
+ var testId = _ref3.testId,
132
+ url = _ref3.url,
133
+ actionOptions = _ref3.actionOptions;
134
+ var _useRovoChat2 = (0, _useRovoChat3.default)(),
135
+ sendPromptMessage = _useRovoChat2.sendPromptMessage,
136
+ isRovoChatEnabled = _useRovoChat2.isRovoChatEnabled;
137
+ var intl = (0, _reactIntl.useIntl)();
138
+ var cardState = (0, _store.useSmartCardState)(url !== null && url !== void 0 ? url : '');
139
+ var extensionKey = (0, _getExtensionKey.getExtensionKey)(cardState.details);
140
+ var rovoConfig = (0, _useRovoConfig.default)();
141
+ var rovoChatAction = (0, _react.useMemo)(function () {
142
+ return cardState.details && (0, _extractRovoChatAction.default)({
143
+ response: cardState.details,
144
+ actionOptions: actionOptions,
145
+ rovoConfig: rovoConfig
146
+ });
147
+ }, [cardState.details, rovoConfig, actionOptions]);
148
+ var provider = (0, _react.useMemo)(function () {
149
+ return cardState.details && (0, _extractSmartLinkProvider.extractSmartLinkProvider)(cardState.details);
150
+ }, [cardState.details]);
151
+ var invoke = (0, _useInvokeClientAction.default)({});
152
+ var promptKey = (0, _react.useMemo)(function () {
153
+ var _cardState$details3, _cardState$details4;
154
+ if (extensionKey === 'google-object-provider' && (_cardState$details3 = cardState.details) !== null && _cardState$details3 !== void 0 && (_cardState$details3 = _cardState$details3.data) !== null && _cardState$details3 !== void 0 && (_cardState$details3 = _cardState$details3['@type']) !== null && _cardState$details3 !== void 0 && _cardState$details3.includes('schema:SpreadsheetDigitalDocument')) {
155
+ return;
156
+ }
157
+ switch (extensionKey) {
158
+ case 'google-object-provider':
159
+ if ((_cardState$details4 = cardState.details) !== null && _cardState$details4 !== void 0 && (_cardState$details4 = _cardState$details4.data) !== null && _cardState$details4 !== void 0 && (_cardState$details4 = _cardState$details4['@type']) !== null && _cardState$details4 !== void 0 && _cardState$details4.includes('schema:PresentationDigitalDocument')) {
160
+ return _rovoChatUtils.RovoChatPromptKey.SUMMARIZE_PRESENTATION;
161
+ }
162
+ return _rovoChatUtils.RovoChatPromptKey.SUMMARIZE_DOCUMENT;
163
+ case 'onedrive-object-provider':
164
+ return _rovoChatUtils.RovoChatPromptKey.SUMMARIZE_DOCUMENT;
165
+ case 'github-object-provider':
166
+ case 'gitlab-object-provider':
167
+ return _rovoChatUtils.RovoChatPromptKey.EXPLAIN_CODE;
168
+ case 'slack-object-provider':
169
+ case 'ms-teams-object-provider':
170
+ return _rovoChatUtils.RovoChatPromptKey.CATCH_UP;
171
+ case 'salesforce-object-provider':
172
+ return _rovoChatUtils.RovoChatPromptKey.SALESFORCE_PREP;
173
+ }
174
+ }, [extensionKey, cardState]);
175
+ var _ref4 = promptKey ? (0, _rovoChatUtils.getPromptAction)({
176
+ promptKey: promptKey,
177
+ intl: intl,
178
+ url: url,
179
+ iconSize: 'small',
180
+ provider: provider === null || provider === void 0 ? void 0 : provider.text
181
+ }) || {} : {},
182
+ promptData = _ref4.data,
183
+ content = _ref4.content,
184
+ icon = _ref4.icon;
185
+ var invokePrompt = (0, _react.useCallback)(function () {
186
+ if (isRovoChatEnabled && promptData && rovoChatAction !== null && rovoChatAction !== void 0 && rovoChatAction.invokeAction) {
187
+ invoke(_objectSpread(_objectSpread({}, rovoChatAction.invokeAction), {}, {
188
+ actionFn: function () {
189
+ var _actionFn2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
190
+ return _regenerator.default.wrap(function (_context2) {
191
+ while (1) switch (_context2.prev = _context2.next) {
192
+ case 0:
193
+ return _context2.abrupt("return", sendPromptMessage(promptData));
194
+ case 1:
195
+ case "end":
196
+ return _context2.stop();
197
+ }
198
+ }, _callee2);
199
+ }));
200
+ function actionFn() {
201
+ return _actionFn2.apply(this, arguments);
202
+ }
203
+ return actionFn;
204
+ }(),
205
+ prompt: promptKey
206
+ }));
207
+ }
208
+ }, [sendPromptMessage, isRovoChatEnabled, promptData, rovoChatAction, promptKey, invoke]);
209
+ var handleClick = (0, _react.useCallback)(function (event) {
210
+ event.preventDefault();
211
+ event.stopPropagation();
212
+ invokePrompt();
213
+ }, [invokePrompt]);
214
+ var button = promptData && content ? /*#__PURE__*/_react.default.createElement(_actionButton.ActionButton, {
215
+ onClick: handleClick,
216
+ testId: testId
217
+ }, icon, /*#__PURE__*/_react.default.createElement(_compiled.Box, {
218
+ xcss: styles.text
219
+ }, /*#__PURE__*/_react.default.createElement(_compiled.Text, {
220
+ size: "small"
221
+ }, content))) : null;
222
+ return button && isRovoChatEnabled && rovoChatAction !== null && rovoChatAction !== void 0 && rovoChatAction.invokeAction ? /*#__PURE__*/_react.default.createElement(_async.OneClickChatSpotlightLoader, {
223
+ key: url,
224
+ url: url,
225
+ actionOptions: actionOptions,
226
+ onInvoke: invokePrompt
227
+ }, button) : button;
122
228
  };
@@ -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.2.1",
22
+ packageVersion: "46.3.0",
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.2.1" || ''
7
+ packageVersion: "46.3.0" || ''
8
8
  };
9
9
  export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -5,6 +5,7 @@ import { fg } from '@atlaskit/platform-feature-flags/fg';
5
5
  import { Popup } from '@atlaskit/popup/popup';
6
6
  import { ActionName, CardDisplay } from '../../../constants';
7
7
  import { useSmartCardActions } from '../../../state/actions';
8
+ import { isSpotlightActive } from '../../../state/hooks/use-one-click-chat-spotlight-eligibility/suppression';
8
9
  import { useSmartLinkRenderers } from '../../../state/renderers';
9
10
  import { useSmartCardState as useLinkState } from '../../../state/store';
10
11
  import { SmartLinkAnalyticsContext } from '../../../utils/analytics/SmartLinkAnalyticsContext';
@@ -144,6 +145,13 @@ export const HoverCardComponent = ({
144
145
  }
145
146
  }, [linkState.metadataStatus, linkState.status, loadMetadata, register]);
146
147
  const initShowCard = useCallback(event => {
148
+ // Popup events bubble through the enclosing Smart Link, including portals.
149
+ // A second top-layer popup can light-dismiss the spotlight before its click runs.
150
+ if (fg('platform_sl_one_click_chat_spotlight_v2_fg') && isSpotlightActive()) {
151
+ initHideCard();
152
+ hideCard();
153
+ return;
154
+ }
147
155
  // clearing out fadeOutTimeoutId in case it's already counting down to hide the card
148
156
  if (fadeOutTimeoutId.current) {
149
157
  clearTimeout(fadeOutTimeoutId.current);
@@ -164,6 +172,11 @@ export const HoverCardComponent = ({
164
172
  }
165
173
  } else {
166
174
  fadeInTimeoutId.current = setTimeout(() => {
175
+ // The spotlight may mount while this hover delay is pending.
176
+ if (fg('platform_sl_one_click_chat_spotlight_v2_fg') && isSpotlightActive()) {
177
+ fadeInTimeoutId.current = undefined;
178
+ return;
179
+ }
167
180
  if (handleSetIsOpen) {
168
181
  handleSetIsOpen(true);
169
182
  } else {
@@ -172,7 +185,7 @@ export const HoverCardComponent = ({
172
185
  }, fadeInDelay);
173
186
  }
174
187
  }
175
- }, [initResolve, isOpen, setMousePosition, noFadeDelay, fadeInDelay, handleSetIsOpen]);
188
+ }, [initResolve, isOpen, setMousePosition, noFadeDelay, fadeInDelay, handleSetIsOpen, initHideCard, hideCard]);
176
189
  const onActionClick = useCallback(actionId => {
177
190
  if (actionId === ActionName.PreviewAction || actionId === ActionName.AutomationAction) {
178
191
  hideCard();