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