@atlaskit/smart-card 26.70.0 → 26.72.0

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 (71) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/state/hooks/use-ai-summary/ai-summary-service/index.js +2 -2
  3. package/dist/cjs/state/hooks/use-ai-summary/ai-summary-service/utils.js +31 -1
  4. package/dist/cjs/utils/analytics/analytics.js +1 -1
  5. package/dist/cjs/view/FlexibleCard/components/actions/action/action-stack-item/action-button.js +87 -0
  6. package/dist/cjs/view/FlexibleCard/components/actions/action/action-stack-item/index.js +14 -78
  7. package/dist/cjs/view/FlexibleCard/components/actions/action/index.js +3 -1
  8. package/dist/cjs/view/FlexibleCard/components/actions/ai-summary-action/ai-summary-action-component.js +8 -1
  9. package/dist/cjs/view/FlexibleCard/components/blocks/action-block/index.js +11 -2
  10. package/dist/cjs/view/FlexibleCard/components/blocks/title-block/errored/index.js +3 -1
  11. package/dist/cjs/view/FlexibleCard/components/blocks/title-block/index.js +4 -2
  12. package/dist/cjs/view/FlexibleCard/components/blocks/title-block/resolved/index.js +3 -1
  13. package/dist/cjs/view/FlexibleCard/components/elements/icon/index.js +3 -2
  14. package/dist/cjs/view/LinkUrl/index.js +1 -1
  15. package/dist/es2019/state/hooks/use-ai-summary/ai-summary-service/index.js +3 -3
  16. package/dist/es2019/state/hooks/use-ai-summary/ai-summary-service/utils.js +30 -0
  17. package/dist/es2019/utils/analytics/analytics.js +1 -1
  18. package/dist/es2019/view/FlexibleCard/components/actions/action/action-stack-item/action-button.js +79 -0
  19. package/dist/es2019/view/FlexibleCard/components/actions/action/action-stack-item/index.js +15 -80
  20. package/dist/es2019/view/FlexibleCard/components/actions/action/index.js +3 -1
  21. package/dist/es2019/view/FlexibleCard/components/actions/ai-summary-action/ai-summary-action-component.js +5 -1
  22. package/dist/es2019/view/FlexibleCard/components/blocks/action-block/index.js +8 -2
  23. package/dist/es2019/view/FlexibleCard/components/blocks/title-block/errored/index.js +2 -0
  24. package/dist/es2019/view/FlexibleCard/components/blocks/title-block/index.js +3 -1
  25. package/dist/es2019/view/FlexibleCard/components/blocks/title-block/resolved/index.js +2 -0
  26. package/dist/es2019/view/FlexibleCard/components/elements/icon/index.js +3 -2
  27. package/dist/es2019/view/LinkUrl/index.js +1 -1
  28. package/dist/esm/state/hooks/use-ai-summary/ai-summary-service/index.js +3 -3
  29. package/dist/esm/state/hooks/use-ai-summary/ai-summary-service/utils.js +30 -0
  30. package/dist/esm/utils/analytics/analytics.js +1 -1
  31. package/dist/esm/view/FlexibleCard/components/actions/action/action-stack-item/action-button.js +78 -0
  32. package/dist/esm/view/FlexibleCard/components/actions/action/action-stack-item/index.js +14 -75
  33. package/dist/esm/view/FlexibleCard/components/actions/action/index.js +3 -1
  34. package/dist/esm/view/FlexibleCard/components/actions/ai-summary-action/ai-summary-action-component.js +5 -1
  35. package/dist/esm/view/FlexibleCard/components/blocks/action-block/index.js +11 -2
  36. package/dist/esm/view/FlexibleCard/components/blocks/title-block/errored/index.js +3 -1
  37. package/dist/esm/view/FlexibleCard/components/blocks/title-block/index.js +4 -2
  38. package/dist/esm/view/FlexibleCard/components/blocks/title-block/resolved/index.js +3 -1
  39. package/dist/esm/view/FlexibleCard/components/elements/icon/index.js +3 -2
  40. package/dist/esm/view/LinkUrl/index.js +1 -1
  41. package/dist/types/state/hooks/use-ai-summary/ai-summary-service/utils.d.ts +7 -0
  42. package/dist/types/view/BlockCard/index.d.ts +2 -2
  43. package/dist/types/view/BlockCard/views/flexible/unresolved-view/index.d.ts +1 -1
  44. package/dist/types/view/FlexibleCard/components/actions/action/action-stack-item/action-button.d.ts +12 -0
  45. package/dist/types/view/FlexibleCard/components/actions/action/action-stack-item/index.d.ts +3 -3
  46. package/dist/types/view/FlexibleCard/components/actions/action/action-stack-item/types.d.ts +2 -5
  47. package/dist/types/view/FlexibleCard/components/actions/action/types.d.ts +5 -0
  48. package/dist/types/view/FlexibleCard/components/blocks/title-block/errored/index.d.ts +1 -1
  49. package/dist/types/view/FlexibleCard/components/blocks/title-block/index.d.ts +1 -1
  50. package/dist/types/view/FlexibleCard/components/blocks/title-block/resolved/index.d.ts +1 -1
  51. package/dist/types/view/FlexibleCard/components/blocks/title-block/types.d.ts +10 -5
  52. package/dist/types/view/FlexibleCard/components/elements/icon/index.d.ts +1 -1
  53. package/dist/types/view/FlexibleCard/components/elements/icon/types.d.ts +7 -2
  54. package/dist/types/view/FlexibleCard/components/elements/link/index.d.ts +1 -1
  55. package/dist/types/view/FlexibleCard/components/elements/link/types.d.ts +3 -3
  56. package/dist/types-ts4.5/state/hooks/use-ai-summary/ai-summary-service/utils.d.ts +7 -0
  57. package/dist/types-ts4.5/view/BlockCard/index.d.ts +2 -2
  58. package/dist/types-ts4.5/view/BlockCard/views/flexible/unresolved-view/index.d.ts +1 -1
  59. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/action-stack-item/action-button.d.ts +12 -0
  60. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/action-stack-item/index.d.ts +3 -3
  61. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/action-stack-item/types.d.ts +2 -5
  62. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/types.d.ts +5 -0
  63. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/title-block/errored/index.d.ts +1 -1
  64. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/title-block/index.d.ts +1 -1
  65. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/title-block/resolved/index.d.ts +1 -1
  66. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/title-block/types.d.ts +10 -5
  67. package/dist/types-ts4.5/view/FlexibleCard/components/elements/icon/index.d.ts +1 -1
  68. package/dist/types-ts4.5/view/FlexibleCard/components/elements/icon/types.d.ts +7 -2
  69. package/dist/types-ts4.5/view/FlexibleCard/components/elements/link/index.d.ts +1 -1
  70. package/dist/types-ts4.5/view/FlexibleCard/components/elements/link/types.d.ts +3 -3
  71. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 26.72.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#103201](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/103201)
8
+ [`7cb62c61f30e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7cb62c61f30e) -
9
+ [ux] Added a new `icon` prop to override the icon rendered in the smart card TitleBlock
10
+ component.
11
+
12
+ ## 26.71.0
13
+
14
+ ### Minor Changes
15
+
16
+ - [#102381](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102381)
17
+ [`52f7f4ff7d29`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/52f7f4ff7d29) -
18
+ Convert ProductType to expected x-product header for AI Mate
19
+ - [#102337](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102337)
20
+ [`cf716582b7d5`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/cf716582b7d5) -
21
+ Hide action block action tooltips while action block is in a loading state
22
+
3
23
  ## 26.70.0
4
24
 
5
25
  ### Minor Changes
@@ -26,7 +26,7 @@ function AsyncFromSyncIterator(r) { function AsyncFromSyncIteratorContinuation(r
26
26
  var AISummaryService = exports.AISummaryService = /*#__PURE__*/function () {
27
27
  function AISummaryService(props) {
28
28
  var _this = this,
29
- _props$product;
29
+ _getXProductHeaderVal;
30
30
  (0, _classCallCheck2.default)(this, AISummaryService);
31
31
  (0, _defineProperty2.default)(this, "state", {
32
32
  content: '',
@@ -85,7 +85,7 @@ var AISummaryService = exports.AISummaryService = /*#__PURE__*/function () {
85
85
  headers: _objectSpread({
86
86
  'Content-Type': 'application/json;charset=UTF-8',
87
87
  'x-experience-id': 'smart-link',
88
- 'x-product': ((_props$product = props.product) === null || _props$product === void 0 ? void 0 : _props$product.toLowerCase()) || 'confluence'
88
+ 'x-product': ((_getXProductHeaderVal = (0, _utils.getXProductHeaderValue)(props.product)) === null || _getXProductHeaderVal === void 0 ? void 0 : _getXProductHeaderVal.toLowerCase()) || 'confluence'
89
89
  }, props.headers)
90
90
  };
91
91
  this.url = props.url;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getBufferReader = exports.addPath = void 0;
6
+ exports.getXProductHeaderValue = exports.getBufferReader = exports.addPath = void 0;
7
7
  var getBufferReader = exports.getBufferReader = function getBufferReader(response) {
8
8
  if (!response.body) {
9
9
  throw new Error('Response body is empty');
@@ -15,4 +15,34 @@ var addPath = exports.addPath = function addPath(baseUrl, path) {
15
15
  var pathWithoutLeadingSlash = !path.startsWith('/') ? path : path.substring(1, path.length);
16
16
  var url = [urlWithTrailingSlash, pathWithoutLeadingSlash].join('');
17
17
  return url;
18
+ };
19
+
20
+ /**
21
+ * Subset of a map of Jira `ProductTypes` to AI Mate expected values
22
+ * See for more info: https://atlassian.slack.com/archives/C066UP0G0G3/p1716341647677829?thread_ts=1716338063.255939&cid=C066UP0G0G3
23
+ */
24
+ var AiMateJiraXProduct = {
25
+ JSM: 'JSM',
26
+ JSW: 'JIRA-SOFTWARE',
27
+ JWM: 'JIRA-CORE',
28
+ JPD: 'JPD'
29
+ };
30
+ /**
31
+ * Checks if `product` is a Jira related product.
32
+ */
33
+ var isJiraProduct = function isJiraProduct(product) {
34
+ var JIRA_PRODUCTS = ['JPD', 'JSM', 'JSW', 'JWM'];
35
+ return product !== undefined && JIRA_PRODUCTS.includes(product);
36
+ };
37
+
38
+ /**
39
+ * Converts a `ProductType` to the expected `x-product` header value for AI Mate.
40
+ *
41
+ * @see https://developer.atlassian.com/platform/assistance-service/security/entitlements/#approach
42
+ */
43
+ var getXProductHeaderValue = exports.getXProductHeaderValue = function getXProductHeaderValue(product) {
44
+ if (isJiraProduct(product)) {
45
+ return AiMateJiraXProduct[product];
46
+ }
47
+ return product;
18
48
  };
@@ -22,7 +22,7 @@ var ANALYTICS_CHANNEL = exports.ANALYTICS_CHANNEL = 'media';
22
22
  var context = exports.context = {
23
23
  componentName: 'smart-cards',
24
24
  packageName: "@atlaskit/smart-card",
25
- packageVersion: "26.70.0"
25
+ packageVersion: "26.72.0"
26
26
  };
27
27
  var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
28
28
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -0,0 +1,87 @@
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.default = void 0;
9
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var _primitives = require("@atlaskit/primitives");
11
+ var _spinner = _interopRequireDefault(require("@atlaskit/spinner"));
12
+ var _react = _interopRequireWildcard(require("react"));
13
+ var _utils = require("../../../utils");
14
+ var _actionIcon = _interopRequireDefault(require("../action-icon"));
15
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
16
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
17
+ var buttonStyles = (0, _primitives.xcss)({
18
+ all: 'unset',
19
+ cursor: 'pointer',
20
+ padding: 'space.050',
21
+ width: '100%',
22
+ ':focus:not(:focus-visible)': {
23
+ outline: 'none'
24
+ },
25
+ ':focus': {
26
+ outlineColor: 'color.border.focused',
27
+ // xcss outlineOffset does not support space.negative.025
28
+ // @ts-ignore-next-line TS2322: Type "var(--ds-space-negative-025)" is not assignable to type
29
+ outlineOffset: "var(--ds-space-negative-025, -2px)",
30
+ outlineStyle: 'solid',
31
+ outlineWidth: 'border.width.outline'
32
+ },
33
+ ':hover': {
34
+ backgroundColor: 'color.background.neutral.subtle.hovered'
35
+ },
36
+ ':active': {
37
+ backgroundColor: 'color.background.neutral.subtle.pressed'
38
+ }
39
+ });
40
+ var contentStyles = (0, _primitives.xcss)({
41
+ color: 'color.text',
42
+ // Replace with font token once it becomes stable (currently alpha)
43
+ // font: 'font.body.small',
44
+ fontSize: '12px',
45
+ fontStyle: 'normal',
46
+ fontWeight: '400',
47
+ lineHeight: '20px'
48
+ });
49
+ var ActionButton = function ActionButton(_ref) {
50
+ var content = _ref.content,
51
+ iconOption = _ref.icon,
52
+ isDisabled = _ref.isDisabled,
53
+ isLoading = _ref.isLoading,
54
+ onClickCallback = _ref.onClick,
55
+ size = _ref.size,
56
+ spaceOption = _ref.space,
57
+ testId = _ref.testId,
58
+ tooltipProps = _ref.tooltipProps,
59
+ xcss = _ref.xcss;
60
+ var space = spaceOption !== null && spaceOption !== void 0 ? spaceOption : (0, _utils.getPrimitivesInlineSpaceBySize)(size);
61
+ var onClick = (0, _react.useCallback)(function () {
62
+ if (!isDisabled && !isLoading && onClickCallback) {
63
+ onClickCallback();
64
+ }
65
+ }, [isDisabled, isLoading, onClickCallback]);
66
+ var icon = iconOption && isLoading ? /*#__PURE__*/_react.default.createElement(_actionIcon.default, {
67
+ asStackItemIcon: true,
68
+ icon: /*#__PURE__*/_react.default.createElement(_spinner.default, {
69
+ testId: "".concat(testId, "-loading")
70
+ }),
71
+ size: size
72
+ }) : iconOption;
73
+ return /*#__PURE__*/_react.default.createElement(_primitives.Box, (0, _extends2.default)({
74
+ as: "button",
75
+ xcss: [buttonStyles, xcss]
76
+ }, tooltipProps, {
77
+ onClick: onClick,
78
+ testId: testId
79
+ }), /*#__PURE__*/_react.default.createElement(_primitives.Inline, {
80
+ alignBlock: "center",
81
+ grow: "fill",
82
+ space: space
83
+ }, icon, /*#__PURE__*/_react.default.createElement(_primitives.Box, {
84
+ xcss: contentStyles
85
+ }, content)));
86
+ };
87
+ var _default = exports.default = ActionButton;
@@ -1,98 +1,34 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
- var _primitives = require("@atlaskit/primitives");
11
- var _spinner = _interopRequireDefault(require("@atlaskit/spinner"));
9
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
12
10
  var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
13
- var _react = _interopRequireWildcard(require("react"));
14
- var _utils = require("../../../utils");
15
- var _actionIcon = _interopRequireDefault(require("../action-icon"));
16
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
17
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
- var buttonStyles = (0, _primitives.xcss)({
19
- all: 'unset',
20
- cursor: 'pointer',
21
- padding: 'space.050',
22
- width: '100%',
23
- ':focus:not(:focus-visible)': {
24
- outline: 'none'
25
- },
26
- ':focus': {
27
- outlineColor: 'color.border.focused',
28
- // xcss outlineOffset does not support space.negative.025
29
- // @ts-ignore-next-line TS2322: Type "var(--ds-space-negative-025)" is not assignable to type
30
- outlineOffset: "var(--ds-space-negative-025, -2px)",
31
- outlineStyle: 'solid',
32
- outlineWidth: 'border.width.outline'
33
- },
34
- ':hover': {
35
- backgroundColor: 'color.background.neutral.subtle.hovered'
36
- },
37
- ':active': {
38
- backgroundColor: 'color.background.neutral.subtle.pressed'
39
- }
40
- });
41
- var contentStyles = (0, _primitives.xcss)({
42
- color: 'color.text',
43
- // Replace with font token once it becomes stable (currently alpha)
44
- // font: 'font.body.small',
45
- fontSize: '12px',
46
- fontStyle: 'normal',
47
- fontWeight: '400',
48
- lineHeight: '20px'
49
- });
11
+ var _react = _interopRequireDefault(require("react"));
12
+ var _actionButton = _interopRequireDefault(require("./action-button"));
13
+ var _excluded = ["content", "tooltipMessage", "tooltipOnHide", "hideTooltipOnMouseDown", "hideTooltip"];
50
14
  var ActionStackItem = function ActionStackItem(_ref) {
51
15
  var content = _ref.content,
52
- iconOption = _ref.icon,
53
- isDisabled = _ref.isDisabled,
54
- isLoading = _ref.isLoading,
55
- onClickCallback = _ref.onClick,
56
- size = _ref.size,
57
- spaceOption = _ref.space,
58
- testId = _ref.testId,
59
16
  tooltipMessage = _ref.tooltipMessage,
60
- xcss = _ref.xcss,
61
17
  tooltipOnHide = _ref.tooltipOnHide,
62
- hideTooltipOnMouseDown = _ref.hideTooltipOnMouseDown;
63
- var space = spaceOption !== null && spaceOption !== void 0 ? spaceOption : (0, _utils.getPrimitivesInlineSpaceBySize)(size);
64
- var onClick = (0, _react.useCallback)(function () {
65
- if (!isDisabled && !isLoading && onClickCallback) {
66
- onClickCallback();
67
- }
68
- }, [isDisabled, isLoading, onClickCallback]);
69
- var icon = iconOption && isLoading ? /*#__PURE__*/_react.default.createElement(_actionIcon.default, {
70
- asStackItemIcon: true,
71
- icon: /*#__PURE__*/_react.default.createElement(_spinner.default, {
72
- testId: "".concat(testId, "-loading")
73
- }),
74
- size: size
75
- }) : iconOption;
76
-
77
- // Replace Box with Pressable once it becomes stable (currently beta)
78
- return /*#__PURE__*/_react.default.createElement(_tooltip.default, {
18
+ hideTooltipOnMouseDown = _ref.hideTooltipOnMouseDown,
19
+ hideTooltip = _ref.hideTooltip,
20
+ props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
21
+ return hideTooltip ? /*#__PURE__*/_react.default.createElement(_actionButton.default, (0, _extends2.default)({}, props, {
22
+ content: content
23
+ })) : /*#__PURE__*/_react.default.createElement(_tooltip.default, {
79
24
  content: tooltipMessage || content,
80
25
  onHide: tooltipOnHide,
81
26
  hideTooltipOnMouseDown: hideTooltipOnMouseDown
82
27
  }, function (tooltipProps) {
83
- return /*#__PURE__*/_react.default.createElement(_primitives.Box, (0, _extends2.default)({
84
- as: "button",
85
- xcss: [buttonStyles, xcss]
86
- }, tooltipProps, {
87
- onClick: onClick,
88
- testId: testId
89
- }), /*#__PURE__*/_react.default.createElement(_primitives.Inline, {
90
- alignBlock: "center",
91
- grow: "fill",
92
- space: space
93
- }, icon, /*#__PURE__*/_react.default.createElement(_primitives.Box, {
94
- xcss: contentStyles
95
- }, content)));
28
+ return /*#__PURE__*/_react.default.createElement(_actionButton.default, (0, _extends2.default)({}, props, {
29
+ content: content,
30
+ tooltipProps: tooltipProps
31
+ }));
96
32
  });
97
33
  };
98
34
  var _default = exports.default = ActionStackItem;
@@ -36,6 +36,7 @@ var Action = function Action(_ref) {
36
36
  spaceInline = _ref.spaceInline,
37
37
  tooltipMessage = _ref.tooltipMessage,
38
38
  tooltipOnHide = _ref.tooltipOnHide,
39
+ hideTooltip = _ref.hideTooltip,
39
40
  hideTooltipOnMouseDown = _ref.hideTooltipOnMouseDown,
40
41
  xcss = _ref.xcss,
41
42
  asDropDownItem = _ref.asDropDownItem,
@@ -71,7 +72,8 @@ var Action = function Action(_ref) {
71
72
  tooltipMessage: tooltipMessage || content,
72
73
  xcss: xcss,
73
74
  tooltipOnHide: tooltipOnHide,
74
- hideTooltipOnMouseDown: hideTooltipOnMouseDown
75
+ hideTooltipOnMouseDown: hideTooltipOnMouseDown,
76
+ hideTooltip: hideTooltip
75
77
  });
76
78
  }
77
79
  if (isDropdownItem) {
@@ -1,20 +1,24 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.AISummaryActionComponent = void 0;
8
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
- var _react = _interopRequireDefault(require("react"));
10
+ var _react = _interopRequireWildcard(require("react"));
10
11
  var _reactMagneticDi = require("react-magnetic-di");
11
12
  var _useAiSummary = require("../../../../../state/hooks/use-ai-summary");
12
13
  var _copySummaryAction = require("./copy-summary-action");
13
14
  var _aiSummariseAction = require("./ai-summarise-action");
15
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
16
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
17
  var AISummaryActionComponent = exports.AISummaryActionComponent = function AISummaryActionComponent(props) {
15
18
  var url = props.url,
16
19
  ari = props.ari,
17
20
  product = props.product,
21
+ onLoadingChange = props.onLoadingChange,
18
22
  _props$testId = props.testId,
19
23
  testId = _props$testId === void 0 ? 'smart-action-ai-summary-action' : _props$testId;
20
24
  var _useAISummary = (0, _useAiSummary.useAISummary)({
@@ -26,6 +30,9 @@ var AISummaryActionComponent = exports.AISummaryActionComponent = function AISum
26
30
  status = _useAISummary$state.status,
27
31
  content = _useAISummary$state.content,
28
32
  summariseUrl = _useAISummary.summariseUrl;
33
+ (0, _react.useEffect)(function () {
34
+ onLoadingChange === null || onLoadingChange === void 0 || onLoadingChange(status === 'loading');
35
+ }, [onLoadingChange, status]);
29
36
  return status === 'done' ? /*#__PURE__*/_react.default.createElement(_copySummaryAction.CopySummaryAction, (0, _extends2.default)({}, props, {
30
37
  testId: testId,
31
38
  content: content
@@ -56,6 +56,13 @@ var ActionBlock = function ActionBlock(_ref) {
56
56
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
57
57
  message = _useState2[0],
58
58
  setMessage = _useState2[1];
59
+ var _useState3 = (0, _react2.useState)(false),
60
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
61
+ isLoading = _useState4[0],
62
+ setIsLoading = _useState4[1];
63
+ var onLoadingChange = (0, _react2.useCallback)(function (isLoading) {
64
+ setIsLoading(isLoading);
65
+ }, [setIsLoading]);
59
66
  var padding = !(ui !== null && ui !== void 0 && ui.hidePadding) ? (0, _utils.getPrimitivesPaddingSpaceBySize)((ui === null || ui === void 0 ? void 0 : ui.size) || _constants.SmartLinkSize.Medium) : undefined;
60
67
  var _onClick = (0, _react2.useCallback)(function (name) {
61
68
  setMessage(undefined);
@@ -80,13 +87,15 @@ var ActionBlock = function ActionBlock(_ref) {
80
87
  return _onClick(name);
81
88
  },
82
89
  onError: onError,
90
+ onLoadingChange: onLoadingChange,
83
91
  size: size,
84
92
  xcss: (0, _primitives.xcss)({
85
93
  paddingInline: padding
86
- })
94
+ }),
95
+ hideTooltip: isLoading
87
96
  }) : null;
88
97
  });
89
- }, [context === null || context === void 0 ? void 0 : context.actions, _onClick, onError, padding, size, spaceInline]);
98
+ }, [context === null || context === void 0 ? void 0 : context.actions, _onClick, onError, padding, size, spaceInline, isLoading, onLoadingChange]);
90
99
  return actions ? (0, _react.jsx)("div", {
91
100
  css: ignoreContainerPaddingStyles,
92
101
  ref: blockRef,
@@ -15,7 +15,7 @@ var _block = _interopRequireDefault(require("../../block"));
15
15
  var _constants = require("../../../../../../constants");
16
16
  var _utils = require("../../../utils");
17
17
  var _elementGroup = _interopRequireDefault(require("../../element-group"));
18
- var _excluded = ["actionGroup", "retry", "position", "testId", "title", "hideIcon"];
18
+ var _excluded = ["actionGroup", "retry", "position", "testId", "title", "icon", "hideIcon"];
19
19
  /** @jsx jsx */
20
20
  var actionStyles = (0, _react2.css)({
21
21
  cursor: 'pointer',
@@ -50,6 +50,7 @@ var TitleBlockErroredView = function TitleBlockErroredView(_ref) {
50
50
  position = _ref.position,
51
51
  testId = _ref.testId,
52
52
  title = _ref.title,
53
+ icon = _ref.icon,
53
54
  hideIcon = _ref.hideIcon,
54
55
  blockProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
55
56
  var _ref2 = retry || {},
@@ -62,6 +63,7 @@ var TitleBlockErroredView = function TitleBlockErroredView(_ref) {
62
63
  return (0, _react2.jsx)(_block.default, (0, _extends2.default)({}, blockProps, {
63
64
  testId: "".concat(testId, "-errored-view")
64
65
  }), !hideIcon && (0, _react2.jsx)(_elements.LinkIcon, {
66
+ overrideIcon: icon,
65
67
  position: position
66
68
  }), title, descriptor && (0, _react2.jsx)(_elementGroup.default, {
67
69
  direction: _constants.SmartLinkDirection.Horizontal,
@@ -18,7 +18,7 @@ var _errored = _interopRequireDefault(require("./errored"));
18
18
  var _resolving = _interopRequireDefault(require("./resolving"));
19
19
  var _actionGroup = _interopRequireDefault(require("../action-group"));
20
20
  var _elements = require("../../elements");
21
- var _excluded = ["actions", "anchorTarget", "hideTitleTooltip", "maxLines", "onActionMenuOpenChange", "onClick", "overrideCss", "status", "showActionOnHover", "testId", "text", "theme", "hideRetry", "metadataPosition", "hideIcon"];
21
+ var _excluded = ["actions", "anchorTarget", "hideTitleTooltip", "maxLines", "onActionMenuOpenChange", "onClick", "overrideCss", "status", "showActionOnHover", "testId", "text", "icon", "theme", "hideRetry", "metadataPosition", "hideIcon"];
22
22
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
23
23
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
24
24
  var getActionStyles = function getActionStyles(showOnHover, isOpen) {
@@ -77,6 +77,7 @@ var TitleBlock = function TitleBlock(_ref) {
77
77
  _ref$testId = _ref.testId,
78
78
  testId = _ref$testId === void 0 ? 'smart-block-title' : _ref$testId,
79
79
  text = _ref.text,
80
+ icon = _ref.icon,
80
81
  theme = _ref.theme,
81
82
  hideRetry = _ref.hideRetry,
82
83
  metadataPosition = _ref.metadataPosition,
@@ -124,7 +125,8 @@ var TitleBlock = function TitleBlock(_ref) {
124
125
  testId: testId,
125
126
  title: title,
126
127
  metadataPosition: metadataPosition,
127
- hideIcon: hideIcon
128
+ hideIcon: hideIcon,
129
+ icon: icon
128
130
  }));
129
131
  };
130
132
  var _default = exports.default = TitleBlock;
@@ -14,7 +14,7 @@ var _block = _interopRequireDefault(require("../../block"));
14
14
  var _elementGroup = _interopRequireDefault(require("../../element-group"));
15
15
  var _constants = require("../../../../../../constants");
16
16
  var _utils = require("../../utils");
17
- var _excluded = ["actionGroup", "metadata", "position", "subtitle", "testId", "text", "title", "metadataPosition", "hideIcon"];
17
+ var _excluded = ["actionGroup", "metadata", "position", "subtitle", "testId", "text", "icon", "title", "metadataPosition", "hideIcon"];
18
18
  /**
19
19
  * This renders a fully resolved TitleBlock.
20
20
  * This should render when a Smart Link returns a valid response.
@@ -29,6 +29,7 @@ var TitleBlockResolvedView = function TitleBlockResolvedView(_ref) {
29
29
  subtitle = _ref$subtitle === void 0 ? [] : _ref$subtitle,
30
30
  testId = _ref.testId,
31
31
  text = _ref.text,
32
+ icon = _ref.icon,
32
33
  title = _ref.title,
33
34
  metadataPosition = _ref.metadataPosition,
34
35
  hideIcon = _ref.hideIcon,
@@ -38,6 +39,7 @@ var TitleBlockResolvedView = function TitleBlockResolvedView(_ref) {
38
39
  return /*#__PURE__*/_react.default.createElement(_block.default, (0, _extends2.default)({}, blockProps, {
39
40
  testId: "".concat(testId, "-resolved-view")
40
41
  }), !hideIcon && /*#__PURE__*/_react.default.createElement(_elements.LinkIcon, {
42
+ overrideIcon: icon,
41
43
  position: position
42
44
  }), /*#__PURE__*/_react.default.createElement(_elementGroup.default, {
43
45
  direction: _constants.SmartLinkDirection.Vertical,
@@ -81,6 +81,7 @@ var renderImageIcon = function renderImageIcon(defaultIcon, url, testId) {
81
81
  */
82
82
  var Icon = function Icon(_ref) {
83
83
  var icon = _ref.icon,
84
+ overrideIcon = _ref.overrideIcon,
84
85
  _ref$label = _ref.label,
85
86
  label = _ref$label === void 0 ? 'Link' : _ref$label,
86
87
  name = _ref.name,
@@ -95,8 +96,8 @@ var Icon = function Icon(_ref) {
95
96
  url = _ref.url;
96
97
  var element = (0, _react.useMemo)(function () {
97
98
  var defaultIcon = renderDefaultIcon(label, testId);
98
- return (render === null || render === void 0 ? void 0 : render()) || renderImageIcon(defaultIcon, url, testId) || renderAtlaskitIcon(icon, label, testId) || defaultIcon;
99
- }, [icon, label, render, testId, url]);
99
+ return overrideIcon || (render === null || render === void 0 ? void 0 : render()) || renderImageIcon(defaultIcon, url, testId) || renderAtlaskitIcon(icon, label, testId) || defaultIcon;
100
+ }, [overrideIcon, icon, label, render, testId, url]);
100
101
  var width = (0, _utils.getIconWidth)(size);
101
102
  var styles = getIconStyles(position, width);
102
103
  var renderStyles = render ? getCustomRenderStyles(width) : undefined;
@@ -17,7 +17,7 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId"],
17
17
  _excluded2 = ["isLinkSafe", "showSafetyWarningModal"];
18
18
  var PACKAGE_DATA = {
19
19
  packageName: "@atlaskit/smart-card",
20
- packageVersion: "26.70.0",
20
+ packageVersion: "26.72.0",
21
21
  componentName: 'linkUrl'
22
22
  };
23
23
  var Link = (0, _click.withLinkClickedEvent)('a');
@@ -1,13 +1,13 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import uuid from 'uuid';
3
3
  import { errorMessages } from './types';
4
- import { addPath } from './utils';
4
+ import { addPath, getXProductHeaderValue } from './utils';
5
5
  import { readStream } from './readStream';
6
6
  import { getBaseUrl } from '@atlaskit/linking-common';
7
7
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
8
8
  export class AISummaryService {
9
9
  constructor(props) {
10
- var _props$product;
10
+ var _getXProductHeaderVal;
11
11
  _defineProperty(this, "state", {
12
12
  content: '',
13
13
  status: 'ready'
@@ -52,7 +52,7 @@ export class AISummaryService {
52
52
  headers: {
53
53
  'Content-Type': 'application/json;charset=UTF-8',
54
54
  'x-experience-id': 'smart-link',
55
- 'x-product': ((_props$product = props.product) === null || _props$product === void 0 ? void 0 : _props$product.toLowerCase()) || 'confluence',
55
+ 'x-product': ((_getXProductHeaderVal = getXProductHeaderValue(props.product)) === null || _getXProductHeaderVal === void 0 ? void 0 : _getXProductHeaderVal.toLowerCase()) || 'confluence',
56
56
  ...props.headers
57
57
  }
58
58
  };
@@ -9,4 +9,34 @@ export const addPath = (baseUrl, path) => {
9
9
  const pathWithoutLeadingSlash = !path.startsWith('/') ? path : path.substring(1, path.length);
10
10
  const url = [urlWithTrailingSlash, pathWithoutLeadingSlash].join('');
11
11
  return url;
12
+ };
13
+
14
+ /**
15
+ * Subset of a map of Jira `ProductTypes` to AI Mate expected values
16
+ * See for more info: https://atlassian.slack.com/archives/C066UP0G0G3/p1716341647677829?thread_ts=1716338063.255939&cid=C066UP0G0G3
17
+ */
18
+ const AiMateJiraXProduct = {
19
+ JSM: 'JSM',
20
+ JSW: 'JIRA-SOFTWARE',
21
+ JWM: 'JIRA-CORE',
22
+ JPD: 'JPD'
23
+ };
24
+ /**
25
+ * Checks if `product` is a Jira related product.
26
+ */
27
+ const isJiraProduct = product => {
28
+ const JIRA_PRODUCTS = ['JPD', 'JSM', 'JSW', 'JWM'];
29
+ return product !== undefined && JIRA_PRODUCTS.includes(product);
30
+ };
31
+
32
+ /**
33
+ * Converts a `ProductType` to the expected `x-product` header value for AI Mate.
34
+ *
35
+ * @see https://developer.atlassian.com/platform/assistance-service/security/entitlements/#approach
36
+ */
37
+ export const getXProductHeaderValue = product => {
38
+ if (isJiraProduct(product)) {
39
+ return AiMateJiraXProduct[product];
40
+ }
41
+ return product;
12
42
  };
@@ -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: "26.70.0"
7
+ packageVersion: "26.72.0"
8
8
  };
9
9
  export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -0,0 +1,79 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import { xcss } from '@atlaskit/primitives';
3
+ import { Box, Inline } from '@atlaskit/primitives';
4
+ import Spinner from '@atlaskit/spinner';
5
+ import React, { useCallback } from 'react';
6
+ import { getPrimitivesInlineSpaceBySize } from '../../../utils';
7
+ import ActionIcon from '../action-icon';
8
+ const buttonStyles = xcss({
9
+ all: 'unset',
10
+ cursor: 'pointer',
11
+ padding: 'space.050',
12
+ width: '100%',
13
+ ':focus:not(:focus-visible)': {
14
+ outline: 'none'
15
+ },
16
+ ':focus': {
17
+ outlineColor: 'color.border.focused',
18
+ // xcss outlineOffset does not support space.negative.025
19
+ // @ts-ignore-next-line TS2322: Type "var(--ds-space-negative-025)" is not assignable to type
20
+ outlineOffset: "var(--ds-space-negative-025, -2px)",
21
+ outlineStyle: 'solid',
22
+ outlineWidth: 'border.width.outline'
23
+ },
24
+ ':hover': {
25
+ backgroundColor: 'color.background.neutral.subtle.hovered'
26
+ },
27
+ ':active': {
28
+ backgroundColor: 'color.background.neutral.subtle.pressed'
29
+ }
30
+ });
31
+ const contentStyles = xcss({
32
+ color: 'color.text',
33
+ // Replace with font token once it becomes stable (currently alpha)
34
+ // font: 'font.body.small',
35
+ fontSize: '12px',
36
+ fontStyle: 'normal',
37
+ fontWeight: '400',
38
+ lineHeight: '20px'
39
+ });
40
+ const ActionButton = ({
41
+ content,
42
+ icon: iconOption,
43
+ isDisabled,
44
+ isLoading,
45
+ onClick: onClickCallback,
46
+ size,
47
+ space: spaceOption,
48
+ testId,
49
+ tooltipProps,
50
+ xcss
51
+ }) => {
52
+ const space = spaceOption !== null && spaceOption !== void 0 ? spaceOption : getPrimitivesInlineSpaceBySize(size);
53
+ const onClick = useCallback(() => {
54
+ if (!isDisabled && !isLoading && onClickCallback) {
55
+ onClickCallback();
56
+ }
57
+ }, [isDisabled, isLoading, onClickCallback]);
58
+ const icon = iconOption && isLoading ? /*#__PURE__*/React.createElement(ActionIcon, {
59
+ asStackItemIcon: true,
60
+ icon: /*#__PURE__*/React.createElement(Spinner, {
61
+ testId: `${testId}-loading`
62
+ }),
63
+ size: size
64
+ }) : iconOption;
65
+ return /*#__PURE__*/React.createElement(Box, _extends({
66
+ as: "button",
67
+ xcss: [buttonStyles, xcss]
68
+ }, tooltipProps, {
69
+ onClick: onClick,
70
+ testId: testId
71
+ }), /*#__PURE__*/React.createElement(Inline, {
72
+ alignBlock: "center",
73
+ grow: "fill",
74
+ space: space
75
+ }, icon, /*#__PURE__*/React.createElement(Box, {
76
+ xcss: contentStyles
77
+ }, content)));
78
+ };
79
+ export default ActionButton;