@atlaskit/smart-card 46.2.1 → 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 (42) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/cjs/utils/analytics/analytics.js +1 -1
  3. package/dist/cjs/view/FlexibleCard/components/actions/action/action-stack-item/index.js +4 -2
  4. package/dist/cjs/view/FlexibleCard/components/actions/action/index.js +2 -0
  5. package/dist/cjs/view/FlexibleCard/components/actions/ai-summary-action/copy-summary-action.js +2 -1
  6. package/dist/cjs/view/FlexibleCard/components/actions/copy-link-action/index.js +2 -1
  7. package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +14 -1
  8. package/dist/cjs/view/InlineCard/common/one-click-chat-spotlight/async.js +37 -0
  9. package/dist/cjs/view/InlineCard/common/one-click-chat-spotlight/index.compiled.css +36 -0
  10. package/dist/cjs/view/InlineCard/common/one-click-chat-spotlight/index.js +293 -0
  11. package/dist/cjs/view/InlineCard/common/rovo-actions-cta/index.js +109 -3
  12. package/dist/cjs/view/LinkUrl/index.js +1 -1
  13. package/dist/es2019/utils/analytics/analytics.js +1 -1
  14. package/dist/es2019/view/FlexibleCard/components/actions/action/action-stack-item/index.js +3 -1
  15. package/dist/es2019/view/FlexibleCard/components/actions/action/index.js +2 -0
  16. package/dist/es2019/view/FlexibleCard/components/actions/ai-summary-action/copy-summary-action.js +2 -1
  17. package/dist/es2019/view/FlexibleCard/components/actions/copy-link-action/index.js +2 -1
  18. package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +14 -1
  19. package/dist/es2019/view/InlineCard/common/one-click-chat-spotlight/async.js +21 -0
  20. package/dist/es2019/view/InlineCard/common/one-click-chat-spotlight/index.compiled.css +36 -0
  21. package/dist/es2019/view/InlineCard/common/one-click-chat-spotlight/index.js +267 -0
  22. package/dist/es2019/view/InlineCard/common/rovo-actions-cta/index.js +93 -1
  23. package/dist/es2019/view/LinkUrl/index.js +1 -1
  24. package/dist/esm/utils/analytics/analytics.js +1 -1
  25. package/dist/esm/view/FlexibleCard/components/actions/action/action-stack-item/index.js +4 -2
  26. package/dist/esm/view/FlexibleCard/components/actions/action/index.js +2 -0
  27. package/dist/esm/view/FlexibleCard/components/actions/ai-summary-action/copy-summary-action.js +2 -1
  28. package/dist/esm/view/FlexibleCard/components/actions/copy-link-action/index.js +2 -1
  29. package/dist/esm/view/HoverCard/components/HoverCardComponent.js +14 -1
  30. package/dist/esm/view/InlineCard/common/one-click-chat-spotlight/async.js +26 -0
  31. package/dist/esm/view/InlineCard/common/one-click-chat-spotlight/index.compiled.css +36 -0
  32. package/dist/esm/view/InlineCard/common/one-click-chat-spotlight/index.js +284 -0
  33. package/dist/esm/view/InlineCard/common/rovo-actions-cta/index.js +107 -1
  34. package/dist/esm/view/LinkUrl/index.js +1 -1
  35. package/dist/types/state/hooks/use-one-click-chat-spotlight-eligibility/suppression.d.ts +1 -1
  36. package/dist/types/view/FlexibleCard/components/actions/action/action-stack-item/index.d.ts +1 -1
  37. package/dist/types/view/FlexibleCard/components/actions/action/index.d.ts +1 -1
  38. package/dist/types/view/FlexibleCard/components/actions/action/types.d.ts +5 -0
  39. package/dist/types/view/InlineCard/common/one-click-chat-spotlight/async.d.ts +6 -0
  40. package/dist/types/view/InlineCard/common/one-click-chat-spotlight/index.d.ts +12 -0
  41. package/dist/types/view/InlineCard/common/rovo-actions-cta/index.d.ts +1 -1
  42. package/package.json +4 -4
@@ -4,6 +4,7 @@ import { ax, ix } from "@compiled/react/runtime";
4
4
  import React, { useCallback, useMemo } from 'react';
5
5
  import { useIntl } from 'react-intl';
6
6
  import { extractSmartLinkProvider } from '@atlaskit/link-extractors/extract-smart-link-provider';
7
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
7
8
  import { Box, Text } from '@atlaskit/primitives/compiled';
8
9
  import extractRovoChatAction from '../../../../extractors/flexible/actions/extract-rovo-chat-action';
9
10
  import { getExtensionKey } from '../../../../state/getExtensionKey';
@@ -13,10 +14,14 @@ import useRovoConfig from '../../../../state/hooks/use-rovo-config';
13
14
  import { useSmartCardState } from '../../../../state/store';
14
15
  import { getPromptAction, RovoChatPromptKey } from '../../../common/rovo-chat-utils';
15
16
  import { ActionButton } from '../action-button';
17
+ import { OneClickChatSpotlightLoader } from '../one-click-chat-spotlight/async';
16
18
  const styles = {
17
19
  text: "_19bv12x7 _1e0c116y _4cvr1h6o _s7n4nkob _19pk1i6y"
18
20
  };
19
- export const InlineRovoActionButton = ({
21
+
22
+ // Keep the master implementation intact while the spotlight rollout is disabled.
23
+ export const InlineRovoActionButton = props => fg('platform_sl_one_click_chat_spotlight_v2_fg') ? /*#__PURE__*/React.createElement(InlineRovoActionButtonWithSpotlight, props) : /*#__PURE__*/React.createElement(InlineRovoActionButtonLegacy, props);
24
+ const InlineRovoActionButtonLegacy = ({
20
25
  testId,
21
26
  url,
22
27
  actionOptions
@@ -93,4 +98,91 @@ export const InlineRovoActionButton = ({
93
98
  }, /*#__PURE__*/React.createElement(Text, {
94
99
  size: "small"
95
100
  }, content))) : null;
101
+ };
102
+ const InlineRovoActionButtonWithSpotlight = ({
103
+ testId,
104
+ url,
105
+ actionOptions
106
+ }) => {
107
+ const {
108
+ sendPromptMessage,
109
+ isRovoChatEnabled
110
+ } = useRovoChat();
111
+ const intl = useIntl();
112
+ const cardState = useSmartCardState(url !== null && url !== void 0 ? url : '');
113
+ const extensionKey = getExtensionKey(cardState.details);
114
+ const rovoConfig = useRovoConfig();
115
+ const rovoChatAction = useMemo(() => {
116
+ return cardState.details && extractRovoChatAction({
117
+ response: cardState.details,
118
+ actionOptions,
119
+ rovoConfig
120
+ });
121
+ }, [cardState.details, rovoConfig, actionOptions]);
122
+ const provider = useMemo(() => {
123
+ return cardState.details && extractSmartLinkProvider(cardState.details);
124
+ }, [cardState.details]);
125
+ const invoke = useInvokeClientAction({});
126
+ const promptKey = useMemo(() => {
127
+ var _cardState$details3, _cardState$details3$d, _cardState$details3$d2, _cardState$details4, _cardState$details4$d, _cardState$details4$d2;
128
+ if (extensionKey === 'google-object-provider' && (_cardState$details3 = cardState.details) !== null && _cardState$details3 !== void 0 && (_cardState$details3$d = _cardState$details3.data) !== null && _cardState$details3$d !== void 0 && (_cardState$details3$d2 = _cardState$details3$d['@type']) !== null && _cardState$details3$d2 !== void 0 && _cardState$details3$d2.includes('schema:SpreadsheetDigitalDocument')) {
129
+ return;
130
+ }
131
+ switch (extensionKey) {
132
+ case 'google-object-provider':
133
+ if ((_cardState$details4 = cardState.details) !== null && _cardState$details4 !== void 0 && (_cardState$details4$d = _cardState$details4.data) !== null && _cardState$details4$d !== void 0 && (_cardState$details4$d2 = _cardState$details4$d['@type']) !== null && _cardState$details4$d2 !== void 0 && _cardState$details4$d2.includes('schema:PresentationDigitalDocument')) {
134
+ return RovoChatPromptKey.SUMMARIZE_PRESENTATION;
135
+ }
136
+ return RovoChatPromptKey.SUMMARIZE_DOCUMENT;
137
+ case 'onedrive-object-provider':
138
+ return RovoChatPromptKey.SUMMARIZE_DOCUMENT;
139
+ case 'github-object-provider':
140
+ case 'gitlab-object-provider':
141
+ return RovoChatPromptKey.EXPLAIN_CODE;
142
+ case 'slack-object-provider':
143
+ case 'ms-teams-object-provider':
144
+ return RovoChatPromptKey.CATCH_UP;
145
+ case 'salesforce-object-provider':
146
+ return RovoChatPromptKey.SALESFORCE_PREP;
147
+ }
148
+ }, [extensionKey, cardState]);
149
+ const {
150
+ data: promptData,
151
+ content,
152
+ icon
153
+ } = promptKey ? getPromptAction({
154
+ promptKey,
155
+ intl,
156
+ url,
157
+ iconSize: 'small',
158
+ provider: provider === null || provider === void 0 ? void 0 : provider.text
159
+ }) || {} : {};
160
+ const invokePrompt = useCallback(() => {
161
+ if (isRovoChatEnabled && promptData && rovoChatAction !== null && rovoChatAction !== void 0 && rovoChatAction.invokeAction) {
162
+ invoke({
163
+ ...rovoChatAction.invokeAction,
164
+ actionFn: async () => sendPromptMessage(promptData),
165
+ prompt: promptKey
166
+ });
167
+ }
168
+ }, [sendPromptMessage, isRovoChatEnabled, promptData, rovoChatAction, promptKey, invoke]);
169
+ const handleClick = useCallback(event => {
170
+ event.preventDefault();
171
+ event.stopPropagation();
172
+ invokePrompt();
173
+ }, [invokePrompt]);
174
+ const button = promptData && content ? /*#__PURE__*/React.createElement(ActionButton, {
175
+ onClick: handleClick,
176
+ testId: testId
177
+ }, icon, /*#__PURE__*/React.createElement(Box, {
178
+ xcss: styles.text
179
+ }, /*#__PURE__*/React.createElement(Text, {
180
+ size: "small"
181
+ }, content))) : null;
182
+ return button && isRovoChatEnabled && rovoChatAction !== null && rovoChatAction !== void 0 && rovoChatAction.invokeAction ? /*#__PURE__*/React.createElement(OneClickChatSpotlightLoader, {
183
+ key: url,
184
+ url: url,
185
+ actionOptions: actionOptions,
186
+ onInvoke: invokePrompt
187
+ }, button) : button;
96
188
  };
@@ -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.2.0",
12
+ packageVersion: "46.3.0",
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.2.0" || ''
7
+ packageVersion: "46.3.0" || ''
8
8
  };
9
9
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["content", "tooltipMessage", "tooltipOnHide", "hideTooltipOnMouseDown", "hideTooltip"];
3
+ var _excluded = ["content", "tooltipMessage", "tooltipOnHide", "hideTooltipOnMouseDown", "hasNewContentOnTriggerClick", "hideTooltip"];
4
4
  import React from 'react';
5
5
  import Tooltip from '@atlaskit/tooltip/Tooltip';
6
6
  import ActionButton from './action-button';
@@ -9,6 +9,7 @@ var ActionStackItem = function ActionStackItem(_ref) {
9
9
  tooltipMessage = _ref.tooltipMessage,
10
10
  tooltipOnHide = _ref.tooltipOnHide,
11
11
  hideTooltipOnMouseDown = _ref.hideTooltipOnMouseDown,
12
+ hasNewContentOnTriggerClick = _ref.hasNewContentOnTriggerClick,
12
13
  hideTooltip = _ref.hideTooltip,
13
14
  props = _objectWithoutProperties(_ref, _excluded);
14
15
  return hideTooltip ? /*#__PURE__*/React.createElement(ActionButton, _extends({}, props, {
@@ -16,7 +17,8 @@ var ActionStackItem = function ActionStackItem(_ref) {
16
17
  })) : /*#__PURE__*/React.createElement(Tooltip, {
17
18
  content: tooltipMessage || content,
18
19
  onHide: tooltipOnHide,
19
- hideTooltipOnMouseDown: hideTooltipOnMouseDown
20
+ hideTooltipOnMouseDown: hideTooltipOnMouseDown,
21
+ hasNewContentOnTriggerClick: hasNewContentOnTriggerClick
20
22
  }, function (tooltipProps) {
21
23
  return /*#__PURE__*/React.createElement(ActionButton, _extends({}, props, {
22
24
  content: content,
@@ -29,6 +29,7 @@ var Action = function Action(_ref) {
29
29
  tooltipOnHide = _ref.tooltipOnHide,
30
30
  hideTooltip = _ref.hideTooltip,
31
31
  hideTooltipOnMouseDown = _ref.hideTooltipOnMouseDown,
32
+ hasNewContentOnTriggerClick = _ref.hasNewContentOnTriggerClick,
32
33
  style = _ref.style,
33
34
  asDropDownItem = _ref.asDropDownItem,
34
35
  className = _ref.className,
@@ -63,6 +64,7 @@ var Action = function Action(_ref) {
63
64
  style: style,
64
65
  tooltipOnHide: tooltipOnHide,
65
66
  hideTooltipOnMouseDown: hideTooltipOnMouseDown,
67
+ hasNewContentOnTriggerClick: hasNewContentOnTriggerClick,
66
68
  hideTooltip: hideTooltip,
67
69
  ariaLabel: ariaLabel
68
70
  });
@@ -52,6 +52,7 @@ export function CopySummaryAction(_ref) {
52
52
  tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, tooltipMessage),
53
53
  tooltipOnHide: function tooltipOnHide() {
54
54
  return setTooltipMessage(messages.copy_summary_action_description);
55
- }
55
+ },
56
+ hasNewContentOnTriggerClick: true
56
57
  }, props));
57
58
  }
@@ -69,7 +69,8 @@ var CopyLinkAction = function CopyLinkAction(_ref) {
69
69
  tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, tooltipMessage),
70
70
  tooltipOnHide: function tooltipOnHide() {
71
71
  return setTooltipMessage(messages.copy_url_to_clipboard);
72
- }
72
+ },
73
+ hasNewContentOnTriggerClick: true
73
74
  }, data, props)) : null;
74
75
  };
75
76
  export default CopyLinkAction;
@@ -8,6 +8,7 @@ import { fg } from '@atlaskit/platform-feature-flags/fg';
8
8
  import { Popup } from '@atlaskit/popup/popup';
9
9
  import { ActionName, CardDisplay } from '../../../constants';
10
10
  import { useSmartCardActions } from '../../../state/actions';
11
+ import { isSpotlightActive } from '../../../state/hooks/use-one-click-chat-spotlight-eligibility/suppression';
11
12
  import { useSmartLinkRenderers } from '../../../state/renderers';
12
13
  import { useSmartCardState as useLinkState } from '../../../state/store';
13
14
  import { SmartLinkAnalyticsContext } from '../../../utils/analytics/SmartLinkAnalyticsContext';
@@ -158,6 +159,13 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
158
159
  }
159
160
  }, [linkState.metadataStatus, linkState.status, loadMetadata, register]);
160
161
  var initShowCard = useCallback(function (event) {
162
+ // Popup events bubble through the enclosing Smart Link, including portals.
163
+ // A second top-layer popup can light-dismiss the spotlight before its click runs.
164
+ if (fg('platform_sl_one_click_chat_spotlight_v2_fg') && isSpotlightActive()) {
165
+ initHideCard();
166
+ hideCard();
167
+ return;
168
+ }
161
169
  // clearing out fadeOutTimeoutId in case it's already counting down to hide the card
162
170
  if (fadeOutTimeoutId.current) {
163
171
  clearTimeout(fadeOutTimeoutId.current);
@@ -178,6 +186,11 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
178
186
  }
179
187
  } else {
180
188
  fadeInTimeoutId.current = setTimeout(function () {
189
+ // The spotlight may mount while this hover delay is pending.
190
+ if (fg('platform_sl_one_click_chat_spotlight_v2_fg') && isSpotlightActive()) {
191
+ fadeInTimeoutId.current = undefined;
192
+ return;
193
+ }
181
194
  if (handleSetIsOpen) {
182
195
  handleSetIsOpen(true);
183
196
  } else {
@@ -186,7 +199,7 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
186
199
  }, fadeInDelay);
187
200
  }
188
201
  }
189
- }, [initResolve, isOpen, setMousePosition, noFadeDelay, fadeInDelay, handleSetIsOpen]);
202
+ }, [initResolve, isOpen, setMousePosition, noFadeDelay, fadeInDelay, handleSetIsOpen, initHideCard, hideCard]);
190
203
  var onActionClick = useCallback(function (actionId) {
191
204
  if (actionId === ActionName.PreviewAction || actionId === ActionName.AutomationAction) {
192
205
  hideCard();
@@ -0,0 +1,26 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import React, { useEffect, useState } from 'react';
3
+ /** Keep the existing action usable during SSR, loading and chunk failures. */
4
+ export function OneClickChatSpotlightLoader(props) {
5
+ var _useState = useState(),
6
+ _useState2 = _slicedToArray(_useState, 2),
7
+ Spotlight = _useState2[0],
8
+ setSpotlight = _useState2[1];
9
+ useEffect(function () {
10
+ var active = true;
11
+ import( /* webpackChunkName: "@atlaskit-internal_smartcard-one-click-chat-spotlight" */'./index').then(function (_ref) {
12
+ var OneClickChatSpotlight = _ref.OneClickChatSpotlight;
13
+ if (active) {
14
+ setSpotlight(function () {
15
+ return OneClickChatSpotlight;
16
+ });
17
+ }
18
+ }).catch(function () {
19
+ // An optional spotlight must not break the existing inline action.
20
+ });
21
+ return function () {
22
+ active = false;
23
+ };
24
+ }, []);
25
+ return Spotlight ? /*#__PURE__*/React.createElement(Spotlight, props) : /*#__PURE__*/React.createElement(React.Fragment, null, props.children);
26
+ }
@@ -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,284 @@
1
+ /* index.tsx generated by @compiled/babel-plugin v3.0.2 */
2
+ import _extends from "@babel/runtime/helpers/extends";
3
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
+ var _excluded = ["children", "style", "shouldFitViewport", "shouldRenderToParent", "shouldFitContainer", "appearance", "xcss", "isReferenceHidden"];
6
+ import "./index.compiled.css";
7
+ import { ax, ix } from "@compiled/react/runtime";
8
+ import React, { createContext, forwardRef, useCallback, useContext, useEffect, useRef, useState } from 'react';
9
+ import { defineMessages, useIntl } from 'react-intl';
10
+ import { useAnalyticsEvents } from '@atlaskit/analytics-next/useAnalyticsEvents';
11
+ import { getDocument } from '@atlaskit/browser-apis';
12
+ import CrossIcon from '@atlaskit/icon/core/cross';
13
+ import { Popup } from '@atlaskit/popup/popup';
14
+ import { Box } from '@atlaskit/primitives/compiled/box';
15
+ import { Inline } from '@atlaskit/primitives/compiled/inline';
16
+ import { Pressable } from '@atlaskit/primitives/compiled/pressable';
17
+ import { Stack } from '@atlaskit/primitives/compiled/stack';
18
+ import { Text } from '@atlaskit/primitives/compiled/text';
19
+ import { EVENT_CHANNEL } from '../../../../common/analytics/constants';
20
+ import { getExtensionKey } from '../../../../state/getExtensionKey';
21
+ import useOneClickChatSpotlightEligibility from '../../../../state/hooks/use-one-click-chat-spotlight-eligibility';
22
+ import useRovoConfig from '../../../../state/hooks/use-rovo-config';
23
+ import { useSmartCardState } from '../../../../state/store';
24
+ var messages = defineMessages({
25
+ heading: {
26
+ id: 'smart-card.one-click-chat-spotlight-v2.heading.ai-non-final',
27
+ defaultMessage: 'Explore this link with Rovo',
28
+ description: 'Accessible name of a spotlight introducing the Rovo action beside a resolved Smart Link.'
29
+ },
30
+ drive: {
31
+ id: 'smart-card.one-click-chat-spotlight-v2.drive.ai-non-final',
32
+ defaultMessage: 'Discover insights from your Google Drive Smart Link using Rovo',
33
+ description: 'Spotlight text explaining that the inline action summarizes the linked Google Drive content.'
34
+ },
35
+ github: {
36
+ id: 'smart-card.one-click-chat-spotlight-v2.github.ai-non-final',
37
+ defaultMessage: 'Discover insights from your GitHub Smart Link using Rovo',
38
+ description: 'Spotlight text explaining that the inline action explains the linked GitHub code.'
39
+ },
40
+ dismiss: {
41
+ id: 'smart-card.one-click-chat-spotlight-v2.dismiss.ai-non-final',
42
+ defaultMessage: 'Dismiss spotlight',
43
+ description: 'Dismiss button in the Smart Link spotlight. Hides this spotlight for seven days.'
44
+ },
45
+ action: {
46
+ id: 'smart-card.one-click-chat-spotlight-v2.action.ai-non-final',
47
+ defaultMessage: 'Try Now',
48
+ description: 'Button in the spotlight that invokes the same Rovo action as the highlighted inline button.'
49
+ }
50
+ });
51
+ var styles = {
52
+ surface: "_1reo1wug _18m91wug _kqswh2mm _1bsbkpet _p12f1osq _vchhusvi _ca0qu2gc _n3tdu2gc _19bvu2gc _u5f3u2gc",
53
+ card: "_2rko1qi0 _bfhk1aqn _syaz15cr _16qs130s",
54
+ caret: "_kqswstnw _1bsb7vkz _4t3iftgi _bfhk1aqn _mkrz1oyg _lcxvglyw",
55
+ below: "_154iidpf",
56
+ above: "_94n5idpf _t9ec1sub",
57
+ close: "_2rko12b0 _v564k6bl _kqswstnw _154iu2gc _1xi2u2gc _ca0qv77o _n3tdv77o _19bvv77o _u5f3v77o _syaz15cr _bfhk1aqn _irr31ibz _1ggl5xtf _1di6of27",
58
+ content: "_kqswh2mm",
59
+ body: "_u5f31ejb",
60
+ action: "_2rko12b0 _v564k6bl _1h6d8yml _1dqonqa1 _189ee4h9 _syaz15cr _bfhk1aqn _ca0qv77o _n3tdv77o _19bvu2gc _u5f3u2gc _irr31ibz _1ggl5xtf _1di6of27"
61
+ };
62
+ var TargetContext = /*#__PURE__*/createContext(null);
63
+
64
+ // Keep Popup's inline trigger, dismissal and focus handling. The design-system Spotlight
65
+ // target renders a block element; the Smart Link action must stay inline.
66
+ var SpotlightSurface = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
67
+ var children = _ref.children,
68
+ style = _ref.style,
69
+ _fit = _ref.shouldFitViewport,
70
+ _parent = _ref.shouldRenderToParent,
71
+ _container = _ref.shouldFitContainer,
72
+ _appearance = _ref.appearance,
73
+ _xcss = _ref.xcss,
74
+ _hidden = _ref.isReferenceHidden,
75
+ props = _objectWithoutProperties(_ref, _excluded);
76
+ var target = useContext(TargetContext);
77
+ var surface = useRef(null);
78
+ var _useState = useState({
79
+ above: false,
80
+ left: 24
81
+ }),
82
+ _useState2 = _slicedToArray(_useState, 2),
83
+ caret = _useState2[0],
84
+ setCaret = _useState2[1];
85
+ var ref = useCallback(function (node) {
86
+ surface.current = node;
87
+ if (typeof forwardedRef === 'function') forwardedRef(node);else if (forwardedRef) forwardedRef.current = node;
88
+ }, [forwardedRef]);
89
+ useEffect(function () {
90
+ var element = surface.current;
91
+ var anchor = target === null || target === void 0 ? void 0 : target.current;
92
+ if (!element || !anchor) return;
93
+ var frame = 0;
94
+ var measure = function measure() {
95
+ var card = element.getBoundingClientRect();
96
+ var trigger = anchor.getBoundingClientRect();
97
+ if (!card.width) return;
98
+ var above = card.bottom <= trigger.top;
99
+ var left = Math.max(16, Math.min(card.width - 32, trigger.left + trigger.width / 2 - card.left - 8));
100
+ setCaret(function (previous) {
101
+ return previous.above === above && previous.left === left ? previous : {
102
+ above: above,
103
+ left: left
104
+ };
105
+ });
106
+ };
107
+ var schedule = function schedule() {
108
+ cancelAnimationFrame(frame);
109
+ frame = requestAnimationFrame(measure);
110
+ };
111
+ var observer = new ResizeObserver(schedule);
112
+ observer.observe(element);
113
+ observer.observe(anchor);
114
+ window.addEventListener('resize', schedule);
115
+ window.addEventListener('scroll', schedule, true);
116
+ schedule();
117
+ return function () {
118
+ cancelAnimationFrame(frame);
119
+ observer.disconnect();
120
+ window.removeEventListener('resize', schedule);
121
+ window.removeEventListener('scroll', schedule, true);
122
+ };
123
+ }, [target]);
124
+ return /*#__PURE__*/React.createElement("div", _extends({}, props, {
125
+ ref: ref,
126
+ style: style,
127
+ className: ax([styles.surface])
128
+ }), /*#__PURE__*/React.createElement("span", {
129
+ "aria-hidden": "true",
130
+ style: {
131
+ left: caret.left
132
+ },
133
+ className: ax([styles.caret, caret.above ? styles.above : styles.below])
134
+ }), /*#__PURE__*/React.createElement(Box, {
135
+ xcss: styles.card
136
+ }, children));
137
+ });
138
+ function VisibleSpotlightCard(_ref2) {
139
+ var onShown = _ref2.onShown,
140
+ body = _ref2.body,
141
+ dismissLabel = _ref2.dismissLabel,
142
+ actionLabel = _ref2.actionLabel,
143
+ onDismiss = _ref2.onDismiss,
144
+ onAction = _ref2.onAction;
145
+ useEffect(function () {
146
+ return onShown();
147
+ }, [onShown]);
148
+ return /*#__PURE__*/React.createElement(Box, {
149
+ testId: "one-click-chat-spotlight-v2",
150
+ xcss: styles.content,
151
+ padding: "space.150"
152
+ }, /*#__PURE__*/React.createElement(Pressable, {
153
+ xcss: styles.close,
154
+ onClick: onDismiss,
155
+ "aria-label": dismissLabel
156
+ }, /*#__PURE__*/React.createElement(CrossIcon, {
157
+ label: "",
158
+ size: "small"
159
+ })), /*#__PURE__*/React.createElement(Stack, {
160
+ space: "space.050"
161
+ }, /*#__PURE__*/React.createElement(Box, {
162
+ xcss: styles.body
163
+ }, /*#__PURE__*/React.createElement(Text, {
164
+ color: "color.text.inverse"
165
+ }, body)), /*#__PURE__*/React.createElement(Inline, {
166
+ alignInline: "end"
167
+ }, /*#__PURE__*/React.createElement(Pressable, {
168
+ xcss: styles.action,
169
+ onClick: onAction
170
+ }, /*#__PURE__*/React.createElement(Text, {
171
+ color: "color.text.inverse"
172
+ }, actionLabel)))));
173
+ }
174
+ export function OneClickChatSpotlight(_ref3) {
175
+ var children = _ref3.children,
176
+ url = _ref3.url,
177
+ actionOptions = _ref3.actionOptions,
178
+ onInvoke = _ref3.onInvoke;
179
+ var intl = useIntl();
180
+ var target = useRef(null);
181
+ var _useState3 = useState(false),
182
+ _useState4 = _slicedToArray(_useState3, 2),
183
+ isOpportunity = _useState4[0],
184
+ setOpportunity = _useState4[1];
185
+ var _useAnalyticsEvents = useAnalyticsEvents(),
186
+ createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
187
+ var _useRovoConfig = useRovoConfig(),
188
+ product = _useRovoConfig.product;
189
+ var card = useSmartCardState(url !== null && url !== void 0 ? url : '');
190
+ var provider = getExtensionKey(card.details);
191
+ var onInteraction = useCallback(function (interaction) {
192
+ createAnalyticsEvent({
193
+ eventType: interaction === 'impression' ? 'track' : 'ui',
194
+ action: interaction === 'impression' ? 'viewed' : interaction,
195
+ actionSubject: 'oneClickChatSpotlight',
196
+ actionSubjectId: 'oneClickChatSpotlightV2',
197
+ attributes: {
198
+ provider: provider === 'google-object-provider' ? 'google-drive' : 'github',
199
+ product: product === 'CONFLUENCE' ? 'confluence_web' : 'jira_web',
200
+ appearance: 'inline',
201
+ cohort: 'treatment',
202
+ variant: 'v2'
203
+ }
204
+ }).fire(EVENT_CHANNEL);
205
+ }, [createAnalyticsEvent, provider, product]);
206
+ var spotlight = useOneClickChatSpotlightEligibility({
207
+ url: url,
208
+ actionOptions: actionOptions,
209
+ isOpportunity: isOpportunity,
210
+ onInteraction: onInteraction
211
+ });
212
+ useEffect(function () {
213
+ var element = target.current;
214
+ var doc = getDocument();
215
+ if (!element || !doc || typeof IntersectionObserver === 'undefined') {
216
+ return;
217
+ }
218
+ var intersects = false;
219
+ var update = function update() {
220
+ return setOpportunity(intersects && doc.visibilityState === 'visible');
221
+ };
222
+ var observer = new IntersectionObserver(function (_ref4) {
223
+ var _ref5 = _slicedToArray(_ref4, 1),
224
+ entry = _ref5[0];
225
+ intersects = entry.isIntersecting;
226
+ update();
227
+ });
228
+ observer.observe(element);
229
+ doc.addEventListener('visibilitychange', update);
230
+ return function () {
231
+ observer.disconnect();
232
+ doc.removeEventListener('visibilitychange', update);
233
+ };
234
+ }, []);
235
+ return /*#__PURE__*/React.createElement("span", {
236
+ ref: target,
237
+ role: "none",
238
+ onClick: function onClick(event) {
239
+ // Top-layer popups remain inside the Smart Link's anchor in the DOM.
240
+ event.preventDefault();
241
+ event.stopPropagation();
242
+ }
243
+ // Match the enclosing Smart Link's keypress handler; leave Escape keydown for Popup.
244
+ ,
245
+ onKeyPress: function onKeyPress(event) {
246
+ return event.stopPropagation();
247
+ }
248
+ }, /*#__PURE__*/React.createElement(TargetContext.Provider, {
249
+ value: target
250
+ }, /*#__PURE__*/React.createElement(Popup, {
251
+ popupComponent: SpotlightSurface,
252
+ shouldFitViewport: true,
253
+ isOpen: spotlight.isEligible,
254
+ onClose: spotlight.onDismiss,
255
+ placement: "bottom-start",
256
+ role: "dialog",
257
+ label: intl.formatMessage(messages.heading),
258
+ trigger: function trigger(_ref6) {
259
+ var ref = _ref6.ref;
260
+ return /*#__PURE__*/React.createElement("span", {
261
+ ref: ref,
262
+ onClickCapture: function onClickCapture() {
263
+ if (spotlight.isEligible) {
264
+ spotlight.onClick();
265
+ }
266
+ }
267
+ }, children);
268
+ },
269
+ content: function content() {
270
+ return /*#__PURE__*/React.createElement(VisibleSpotlightCard, {
271
+ onShown: spotlight.onShown,
272
+ body: intl.formatMessage(provider === 'google-object-provider' ? messages.drive : messages.github),
273
+ dismissLabel: intl.formatMessage(messages.dismiss),
274
+ actionLabel: intl.formatMessage(messages.action),
275
+ onDismiss: spotlight.onDismiss,
276
+ onAction: function onAction() {
277
+ if (spotlight.onClick()) {
278
+ onInvoke();
279
+ }
280
+ }
281
+ });
282
+ }
283
+ })));
284
+ }