@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
@@ -9,6 +9,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
9
9
  import React, { useCallback, useMemo } from 'react';
10
10
  import { useIntl } from 'react-intl';
11
11
  import { extractSmartLinkProvider } from '@atlaskit/link-extractors/extract-smart-link-provider';
12
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
12
13
  import { Box, Text } from '@atlaskit/primitives/compiled';
13
14
  import extractRovoChatAction from '../../../../extractors/flexible/actions/extract-rovo-chat-action';
14
15
  import { getExtensionKey } from '../../../../state/getExtensionKey';
@@ -18,10 +19,16 @@ import useRovoConfig from '../../../../state/hooks/use-rovo-config';
18
19
  import { useSmartCardState } from '../../../../state/store';
19
20
  import { getPromptAction, RovoChatPromptKey } from '../../../common/rovo-chat-utils';
20
21
  import { ActionButton } from '../action-button';
22
+ import { OneClickChatSpotlightLoader } from '../one-click-chat-spotlight/async';
21
23
  var styles = {
22
24
  text: "_19bv12x7 _1e0c116y _4cvr1h6o _s7n4nkob _19pk1i6y"
23
25
  };
24
- export var InlineRovoActionButton = function InlineRovoActionButton(_ref) {
26
+
27
+ // Keep the master implementation intact while the spotlight rollout is disabled.
28
+ export var InlineRovoActionButton = function InlineRovoActionButton(props) {
29
+ return fg('platform_sl_one_click_chat_spotlight_v2_fg') ? /*#__PURE__*/React.createElement(InlineRovoActionButtonWithSpotlight, props) : /*#__PURE__*/React.createElement(InlineRovoActionButtonLegacy, props);
30
+ };
31
+ var InlineRovoActionButtonLegacy = function InlineRovoActionButtonLegacy(_ref) {
25
32
  var testId = _ref.testId,
26
33
  url = _ref.url,
27
34
  actionOptions = _ref.actionOptions;
@@ -110,4 +117,103 @@ export var InlineRovoActionButton = function InlineRovoActionButton(_ref) {
110
117
  }, /*#__PURE__*/React.createElement(Text, {
111
118
  size: "small"
112
119
  }, content))) : null;
120
+ };
121
+ var InlineRovoActionButtonWithSpotlight = function InlineRovoActionButtonWithSpotlight(_ref3) {
122
+ var testId = _ref3.testId,
123
+ url = _ref3.url,
124
+ actionOptions = _ref3.actionOptions;
125
+ var _useRovoChat2 = useRovoChat(),
126
+ sendPromptMessage = _useRovoChat2.sendPromptMessage,
127
+ isRovoChatEnabled = _useRovoChat2.isRovoChatEnabled;
128
+ var intl = useIntl();
129
+ var cardState = useSmartCardState(url !== null && url !== void 0 ? url : '');
130
+ var extensionKey = getExtensionKey(cardState.details);
131
+ var rovoConfig = useRovoConfig();
132
+ var rovoChatAction = useMemo(function () {
133
+ return cardState.details && extractRovoChatAction({
134
+ response: cardState.details,
135
+ actionOptions: actionOptions,
136
+ rovoConfig: rovoConfig
137
+ });
138
+ }, [cardState.details, rovoConfig, actionOptions]);
139
+ var provider = useMemo(function () {
140
+ return cardState.details && extractSmartLinkProvider(cardState.details);
141
+ }, [cardState.details]);
142
+ var invoke = useInvokeClientAction({});
143
+ var promptKey = useMemo(function () {
144
+ var _cardState$details3, _cardState$details4;
145
+ 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')) {
146
+ return;
147
+ }
148
+ switch (extensionKey) {
149
+ case 'google-object-provider':
150
+ 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')) {
151
+ return RovoChatPromptKey.SUMMARIZE_PRESENTATION;
152
+ }
153
+ return RovoChatPromptKey.SUMMARIZE_DOCUMENT;
154
+ case 'onedrive-object-provider':
155
+ return RovoChatPromptKey.SUMMARIZE_DOCUMENT;
156
+ case 'github-object-provider':
157
+ case 'gitlab-object-provider':
158
+ return RovoChatPromptKey.EXPLAIN_CODE;
159
+ case 'slack-object-provider':
160
+ case 'ms-teams-object-provider':
161
+ return RovoChatPromptKey.CATCH_UP;
162
+ case 'salesforce-object-provider':
163
+ return RovoChatPromptKey.SALESFORCE_PREP;
164
+ }
165
+ }, [extensionKey, cardState]);
166
+ var _ref4 = promptKey ? getPromptAction({
167
+ promptKey: promptKey,
168
+ intl: intl,
169
+ url: url,
170
+ iconSize: 'small',
171
+ provider: provider === null || provider === void 0 ? void 0 : provider.text
172
+ }) || {} : {},
173
+ promptData = _ref4.data,
174
+ content = _ref4.content,
175
+ icon = _ref4.icon;
176
+ var invokePrompt = useCallback(function () {
177
+ if (isRovoChatEnabled && promptData && rovoChatAction !== null && rovoChatAction !== void 0 && rovoChatAction.invokeAction) {
178
+ invoke(_objectSpread(_objectSpread({}, rovoChatAction.invokeAction), {}, {
179
+ actionFn: function () {
180
+ var _actionFn2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
181
+ return _regeneratorRuntime.wrap(function (_context2) {
182
+ while (1) switch (_context2.prev = _context2.next) {
183
+ case 0:
184
+ return _context2.abrupt("return", sendPromptMessage(promptData));
185
+ case 1:
186
+ case "end":
187
+ return _context2.stop();
188
+ }
189
+ }, _callee2);
190
+ }));
191
+ function actionFn() {
192
+ return _actionFn2.apply(this, arguments);
193
+ }
194
+ return actionFn;
195
+ }(),
196
+ prompt: promptKey
197
+ }));
198
+ }
199
+ }, [sendPromptMessage, isRovoChatEnabled, promptData, rovoChatAction, promptKey, invoke]);
200
+ var handleClick = useCallback(function (event) {
201
+ event.preventDefault();
202
+ event.stopPropagation();
203
+ invokePrompt();
204
+ }, [invokePrompt]);
205
+ var button = promptData && content ? /*#__PURE__*/React.createElement(ActionButton, {
206
+ onClick: handleClick,
207
+ testId: testId
208
+ }, icon, /*#__PURE__*/React.createElement(Box, {
209
+ xcss: styles.text
210
+ }, /*#__PURE__*/React.createElement(Text, {
211
+ size: "small"
212
+ }, content))) : null;
213
+ return button && isRovoChatEnabled && rovoChatAction !== null && rovoChatAction !== void 0 && rovoChatAction.invokeAction ? /*#__PURE__*/React.createElement(OneClickChatSpotlightLoader, {
214
+ key: url,
215
+ url: url,
216
+ actionOptions: actionOptions,
217
+ onInvoke: invokePrompt
218
+ }, button) : button;
113
219
  };
@@ -12,7 +12,7 @@ import LinkWarningModal from './LinkWarningModal';
12
12
  import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
13
13
  var PACKAGE_DATA = {
14
14
  packageName: "@atlaskit/smart-card",
15
- packageVersion: "46.2.0",
15
+ packageVersion: "46.3.0",
16
16
  componentName: 'linkUrl'
17
17
  };
18
18
  var LinkUrl = function LinkUrl(_ref) {
@@ -10,4 +10,4 @@ export declare function createSuppressionStore(storage: StorageClient, isAvailab
10
10
  export declare function getSuppressionStore(): SpotlightSuppression | undefined;
11
11
  export declare function claimSpotlight(owner: symbol): boolean;
12
12
  export declare function releaseSpotlight(owner: symbol): void;
13
- export declare function isSpotlightActive(owner: symbol): boolean;
13
+ export declare function isSpotlightActive(owner?: symbol): boolean;
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import type { ActionStackItemProps } from './types';
3
- declare const ActionStackItem: ({ content, tooltipMessage, tooltipOnHide, hideTooltipOnMouseDown, hideTooltip, ...props }: ActionStackItemProps) => React.JSX.Element;
3
+ declare const ActionStackItem: ({ content, tooltipMessage, tooltipOnHide, hideTooltipOnMouseDown, hasNewContentOnTriggerClick, hideTooltip, ...props }: ActionStackItemProps) => React.JSX.Element;
4
4
  export default ActionStackItem;
@@ -5,5 +5,5 @@ import { type ActionProps } from './types';
5
5
  * @internal
6
6
  * @param {ActionProps} ActionProps - The props necessary for the Action.
7
7
  */
8
- declare const Action: ({ as, appearance, content, isLoading, onClick, size, testId, icon, iconPosition, spaceInline, tooltipMessage, tooltipOnHide, hideTooltip, hideTooltipOnMouseDown, style, asDropDownItem, className, isDisabled, href, ariaLabel, wrapper: Wrapper, }: ActionProps) => React.JSX.Element | null;
8
+ declare const Action: ({ as, appearance, content, isLoading, onClick, size, testId, icon, iconPosition, spaceInline, tooltipMessage, tooltipOnHide, hideTooltip, hideTooltipOnMouseDown, hasNewContentOnTriggerClick, style, asDropDownItem, className, isDisabled, href, ariaLabel, wrapper: Wrapper, }: ActionProps) => React.JSX.Element | null;
9
9
  export default Action;
@@ -81,6 +81,11 @@ export type ActionProps = {
81
81
  */
82
82
  onError?: (error: ActionMessage) => void;
83
83
  onLoadingChange?: (isLoading: boolean) => void;
84
+ /**
85
+ * Keeps the tooltip open when the action is pressed. Set it when a press changes
86
+ * `tooltipMessage`. Only used when `as` is `stack-item`.
87
+ */
88
+ hasNewContentOnTriggerClick?: boolean;
84
89
  /**
85
90
  * Determines the size of the Action. Corresponds to an Action appearance.
86
91
  */
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import type { OneClickChatSpotlight } from './index';
3
+ type SpotlightComponent = typeof OneClickChatSpotlight;
4
+ /** Keep the existing action usable during SSR, loading and chunk failures. */
5
+ export declare function OneClickChatSpotlightLoader(props: React.ComponentProps<SpotlightComponent>): React.JSX.Element;
6
+ export {};
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
5
+ import React from 'react';
6
+ import type { InternalCardActionOptions } from '../../../Card/types';
7
+ export declare function OneClickChatSpotlight({ children, url, actionOptions, onInvoke, }: {
8
+ actionOptions?: InternalCardActionOptions;
9
+ children: React.ReactNode;
10
+ onInvoke: () => void;
11
+ url?: string;
12
+ }): React.JSX.Element;
@@ -3,7 +3,7 @@
3
3
  * @jsx jsx
4
4
  */
5
5
  import type { InternalCardActionOptions as CardActionOptions } from '../../../Card/types';
6
- export declare const InlineRovoActionButton: ({ testId, url, actionOptions, }: {
6
+ export declare const InlineRovoActionButton: (props: {
7
7
  actionOptions?: CardActionOptions;
8
8
  testId?: string;
9
9
  url?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "46.2.1",
3
+ "version": "46.3.1",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -50,7 +50,7 @@
50
50
  "@atlaskit/button": "^25.4.0",
51
51
  "@atlaskit/checkbox": "^19.2.0",
52
52
  "@atlaskit/css": "^1.1.0",
53
- "@atlaskit/dropdown-menu": "^20.0.0",
53
+ "@atlaskit/dropdown-menu": "^21.0.0",
54
54
  "@atlaskit/embedded-confluence": "^6.4.0",
55
55
  "@atlaskit/feature-gate-js-client": "^7.0.0",
56
56
  "@atlaskit/flag": "^19.0.0",
@@ -79,7 +79,7 @@
79
79
  "@atlaskit/platform-feature-experiments": "^0.3.0",
80
80
  "@atlaskit/platform-feature-flags": "^2.2.0",
81
81
  "@atlaskit/platform-feature-flags-react": "^1.2.0",
82
- "@atlaskit/popup": "^8.1.0",
82
+ "@atlaskit/popup": "^9.0.0",
83
83
  "@atlaskit/primitives": "^22.5.0",
84
84
  "@atlaskit/react-compiler-gating": "^0.2.0",
85
85
  "@atlaskit/react-ufo": "^8.0.0",
@@ -95,7 +95,7 @@
95
95
  "@atlaskit/tile": "^5.0.0",
96
96
  "@atlaskit/tmp-editor-statsig": "^219.0.0",
97
97
  "@atlaskit/tokens": "^20.1.0",
98
- "@atlaskit/tooltip": "^24.3.0",
98
+ "@atlaskit/tooltip": "^24.4.0",
99
99
  "@atlaskit/ufo": "^2.0.0",
100
100
  "@atlaskit/width-detector": "^7.2.0",
101
101
  "@babel/runtime": "^7.0.0",