@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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
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
|
+
|
|
25
|
+
## 46.3.0
|
|
26
|
+
|
|
27
|
+
### Minor Changes
|
|
28
|
+
|
|
29
|
+
- [`457c77d8f6992`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/457c77d8f6992) -
|
|
30
|
+
Behind `platform-dst-top-layer-tooltip`: tooltips whose content changes on press (for example
|
|
31
|
+
"Copy" to "Copied!") stay open to show the new content. `@atlaskit/editor-common` floating toolbar
|
|
32
|
+
buttons and `@atlaskit/smart-card` stack-item actions add an optional
|
|
33
|
+
`hasNewContentOnTriggerClick` prop.
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- Updated dependencies
|
|
38
|
+
|
|
3
39
|
## 46.2.1
|
|
4
40
|
|
|
5
41
|
### Patch Changes
|
|
@@ -25,7 +25,7 @@ var ANALYTICS_CHANNEL = exports.ANALYTICS_CHANNEL = 'media';
|
|
|
25
25
|
var context = exports.context = {
|
|
26
26
|
componentName: 'smart-cards',
|
|
27
27
|
packageName: "@atlaskit/smart-card" || '',
|
|
28
|
-
packageVersion: "46.
|
|
28
|
+
packageVersion: "46.3.0" || ''
|
|
29
29
|
};
|
|
30
30
|
var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
31
31
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -10,12 +10,13 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
|
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
var _Tooltip = _interopRequireDefault(require("@atlaskit/tooltip/Tooltip"));
|
|
12
12
|
var _actionButton = _interopRequireDefault(require("./action-button"));
|
|
13
|
-
var _excluded = ["content", "tooltipMessage", "tooltipOnHide", "hideTooltipOnMouseDown", "hideTooltip"];
|
|
13
|
+
var _excluded = ["content", "tooltipMessage", "tooltipOnHide", "hideTooltipOnMouseDown", "hasNewContentOnTriggerClick", "hideTooltip"];
|
|
14
14
|
var ActionStackItem = function ActionStackItem(_ref) {
|
|
15
15
|
var content = _ref.content,
|
|
16
16
|
tooltipMessage = _ref.tooltipMessage,
|
|
17
17
|
tooltipOnHide = _ref.tooltipOnHide,
|
|
18
18
|
hideTooltipOnMouseDown = _ref.hideTooltipOnMouseDown,
|
|
19
|
+
hasNewContentOnTriggerClick = _ref.hasNewContentOnTriggerClick,
|
|
19
20
|
hideTooltip = _ref.hideTooltip,
|
|
20
21
|
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
21
22
|
return hideTooltip ? /*#__PURE__*/_react.default.createElement(_actionButton.default, (0, _extends2.default)({}, props, {
|
|
@@ -23,7 +24,8 @@ var ActionStackItem = function ActionStackItem(_ref) {
|
|
|
23
24
|
})) : /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
|
|
24
25
|
content: tooltipMessage || content,
|
|
25
26
|
onHide: tooltipOnHide,
|
|
26
|
-
hideTooltipOnMouseDown: hideTooltipOnMouseDown
|
|
27
|
+
hideTooltipOnMouseDown: hideTooltipOnMouseDown,
|
|
28
|
+
hasNewContentOnTriggerClick: hasNewContentOnTriggerClick
|
|
27
29
|
}, function (tooltipProps) {
|
|
28
30
|
return /*#__PURE__*/_react.default.createElement(_actionButton.default, (0, _extends2.default)({}, props, {
|
|
29
31
|
content: content,
|
|
@@ -36,6 +36,7 @@ var Action = function Action(_ref) {
|
|
|
36
36
|
tooltipOnHide = _ref.tooltipOnHide,
|
|
37
37
|
hideTooltip = _ref.hideTooltip,
|
|
38
38
|
hideTooltipOnMouseDown = _ref.hideTooltipOnMouseDown,
|
|
39
|
+
hasNewContentOnTriggerClick = _ref.hasNewContentOnTriggerClick,
|
|
39
40
|
style = _ref.style,
|
|
40
41
|
asDropDownItem = _ref.asDropDownItem,
|
|
41
42
|
className = _ref.className,
|
|
@@ -70,6 +71,7 @@ var Action = function Action(_ref) {
|
|
|
70
71
|
style: style,
|
|
71
72
|
tooltipOnHide: tooltipOnHide,
|
|
72
73
|
hideTooltipOnMouseDown: hideTooltipOnMouseDown,
|
|
74
|
+
hasNewContentOnTriggerClick: hasNewContentOnTriggerClick,
|
|
73
75
|
hideTooltip: hideTooltip,
|
|
74
76
|
ariaLabel: ariaLabel
|
|
75
77
|
});
|
package/dist/cjs/view/FlexibleCard/components/actions/ai-summary-action/copy-summary-action.js
CHANGED
|
@@ -61,6 +61,7 @@ function CopySummaryAction(_ref) {
|
|
|
61
61
|
tooltipMessage: /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, tooltipMessage),
|
|
62
62
|
tooltipOnHide: function tooltipOnHide() {
|
|
63
63
|
return setTooltipMessage(_messages.messages.copy_summary_action_description);
|
|
64
|
-
}
|
|
64
|
+
},
|
|
65
|
+
hasNewContentOnTriggerClick: true
|
|
65
66
|
}, props));
|
|
66
67
|
}
|
|
@@ -78,7 +78,8 @@ var CopyLinkAction = function CopyLinkAction(_ref) {
|
|
|
78
78
|
tooltipMessage: /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, tooltipMessage),
|
|
79
79
|
tooltipOnHide: function tooltipOnHide() {
|
|
80
80
|
return setTooltipMessage(_messages.messages.copy_url_to_clipboard);
|
|
81
|
-
}
|
|
81
|
+
},
|
|
82
|
+
hasNewContentOnTriggerClick: true
|
|
82
83
|
}, data, props)) : null;
|
|
83
84
|
};
|
|
84
85
|
var _default = exports.default = CopyLinkAction;
|
|
@@ -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
|
+
}
|