@atlaskit/smart-card 26.70.0 → 26.71.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 (39) hide show
  1. package/CHANGELOG.md +11 -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/LinkUrl/index.js +1 -1
  11. package/dist/es2019/state/hooks/use-ai-summary/ai-summary-service/index.js +3 -3
  12. package/dist/es2019/state/hooks/use-ai-summary/ai-summary-service/utils.js +30 -0
  13. package/dist/es2019/utils/analytics/analytics.js +1 -1
  14. package/dist/es2019/view/FlexibleCard/components/actions/action/action-stack-item/action-button.js +79 -0
  15. package/dist/es2019/view/FlexibleCard/components/actions/action/action-stack-item/index.js +15 -80
  16. package/dist/es2019/view/FlexibleCard/components/actions/action/index.js +3 -1
  17. package/dist/es2019/view/FlexibleCard/components/actions/ai-summary-action/ai-summary-action-component.js +5 -1
  18. package/dist/es2019/view/FlexibleCard/components/blocks/action-block/index.js +8 -2
  19. package/dist/es2019/view/LinkUrl/index.js +1 -1
  20. package/dist/esm/state/hooks/use-ai-summary/ai-summary-service/index.js +3 -3
  21. package/dist/esm/state/hooks/use-ai-summary/ai-summary-service/utils.js +30 -0
  22. package/dist/esm/utils/analytics/analytics.js +1 -1
  23. package/dist/esm/view/FlexibleCard/components/actions/action/action-stack-item/action-button.js +78 -0
  24. package/dist/esm/view/FlexibleCard/components/actions/action/action-stack-item/index.js +14 -75
  25. package/dist/esm/view/FlexibleCard/components/actions/action/index.js +3 -1
  26. package/dist/esm/view/FlexibleCard/components/actions/ai-summary-action/ai-summary-action-component.js +5 -1
  27. package/dist/esm/view/FlexibleCard/components/blocks/action-block/index.js +11 -2
  28. package/dist/esm/view/LinkUrl/index.js +1 -1
  29. package/dist/types/state/hooks/use-ai-summary/ai-summary-service/utils.d.ts +7 -0
  30. package/dist/types/view/FlexibleCard/components/actions/action/action-stack-item/action-button.d.ts +12 -0
  31. package/dist/types/view/FlexibleCard/components/actions/action/action-stack-item/index.d.ts +3 -3
  32. package/dist/types/view/FlexibleCard/components/actions/action/action-stack-item/types.d.ts +2 -5
  33. package/dist/types/view/FlexibleCard/components/actions/action/types.d.ts +5 -0
  34. package/dist/types-ts4.5/state/hooks/use-ai-summary/ai-summary-service/utils.d.ts +7 -0
  35. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/action-stack-item/action-button.d.ts +12 -0
  36. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/action-stack-item/index.d.ts +3 -3
  37. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/action-stack-item/types.d.ts +2 -5
  38. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/types.d.ts +5 -0
  39. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 26.71.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#102381](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102381)
8
+ [`52f7f4ff7d29`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/52f7f4ff7d29) -
9
+ Convert ProductType to expected x-product header for AI Mate
10
+ - [#102337](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102337)
11
+ [`cf716582b7d5`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/cf716582b7d5) -
12
+ Hide action block action tooltips while action block is in a loading state
13
+
3
14
  ## 26.70.0
4
15
 
5
16
  ### 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.71.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,
@@ -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.71.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.71.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;
@@ -1,87 +1,22 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import { Box, Inline, xcss } from '@atlaskit/primitives';
3
- import Spinner from '@atlaskit/spinner';
4
2
  import Tooltip from '@atlaskit/tooltip';
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
- });
3
+ import React from 'react';
4
+ import ActionButton from './action-button';
40
5
  const ActionStackItem = ({
41
6
  content,
42
- icon: iconOption,
43
- isDisabled,
44
- isLoading,
45
- onClick: onClickCallback,
46
- size,
47
- space: spaceOption,
48
- testId,
49
7
  tooltipMessage,
50
- xcss,
51
8
  tooltipOnHide,
52
- hideTooltipOnMouseDown
53
- }) => {
54
- const space = spaceOption !== null && spaceOption !== void 0 ? spaceOption : getPrimitivesInlineSpaceBySize(size);
55
- const onClick = useCallback(() => {
56
- if (!isDisabled && !isLoading && onClickCallback) {
57
- onClickCallback();
58
- }
59
- }, [isDisabled, isLoading, onClickCallback]);
60
- const icon = iconOption && isLoading ? /*#__PURE__*/React.createElement(ActionIcon, {
61
- asStackItemIcon: true,
62
- icon: /*#__PURE__*/React.createElement(Spinner, {
63
- testId: `${testId}-loading`
64
- }),
65
- size: size
66
- }) : iconOption;
67
-
68
- // Replace Box with Pressable once it becomes stable (currently beta)
69
- return /*#__PURE__*/React.createElement(Tooltip, {
70
- content: tooltipMessage || content,
71
- onHide: tooltipOnHide,
72
- hideTooltipOnMouseDown: hideTooltipOnMouseDown
73
- }, tooltipProps => /*#__PURE__*/React.createElement(Box, _extends({
74
- as: "button",
75
- xcss: [buttonStyles, xcss]
76
- }, tooltipProps, {
77
- onClick: onClick,
78
- testId: testId
79
- }), /*#__PURE__*/React.createElement(Inline, {
80
- alignBlock: "center",
81
- grow: "fill",
82
- space: space
83
- }, icon, /*#__PURE__*/React.createElement(Box, {
84
- xcss: contentStyles
85
- }, content))));
86
- };
9
+ hideTooltipOnMouseDown,
10
+ hideTooltip,
11
+ ...props
12
+ }) => hideTooltip ? /*#__PURE__*/React.createElement(ActionButton, _extends({}, props, {
13
+ content: content
14
+ })) : /*#__PURE__*/React.createElement(Tooltip, {
15
+ content: tooltipMessage || content,
16
+ onHide: tooltipOnHide,
17
+ hideTooltipOnMouseDown: hideTooltipOnMouseDown
18
+ }, tooltipProps => /*#__PURE__*/React.createElement(ActionButton, _extends({}, props, {
19
+ content: content,
20
+ tooltipProps: tooltipProps
21
+ })));
87
22
  export default ActionStackItem;
@@ -25,6 +25,7 @@ const Action = ({
25
25
  spaceInline,
26
26
  tooltipMessage,
27
27
  tooltipOnHide,
28
+ hideTooltip,
28
29
  hideTooltipOnMouseDown,
29
30
  xcss,
30
31
  asDropDownItem,
@@ -61,7 +62,8 @@ const Action = ({
61
62
  tooltipMessage: tooltipMessage || content,
62
63
  xcss: xcss,
63
64
  tooltipOnHide: tooltipOnHide,
64
- hideTooltipOnMouseDown: hideTooltipOnMouseDown
65
+ hideTooltipOnMouseDown: hideTooltipOnMouseDown,
66
+ hideTooltip: hideTooltip
65
67
  });
66
68
  }
67
69
  if (isDropdownItem) {
@@ -1,5 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import React from 'react';
2
+ import React, { useEffect } from 'react';
3
3
  import { di } from 'react-magnetic-di';
4
4
  import { useAISummary } from '../../../../../state/hooks/use-ai-summary';
5
5
  import { CopySummaryAction } from './copy-summary-action';
@@ -9,6 +9,7 @@ export const AISummaryActionComponent = props => {
9
9
  url,
10
10
  ari,
11
11
  product,
12
+ onLoadingChange,
12
13
  testId = 'smart-action-ai-summary-action'
13
14
  } = props;
14
15
  const {
@@ -22,6 +23,9 @@ export const AISummaryActionComponent = props => {
22
23
  ari,
23
24
  product
24
25
  });
26
+ useEffect(() => {
27
+ onLoadingChange === null || onLoadingChange === void 0 ? void 0 : onLoadingChange(status === 'loading');
28
+ }, [onLoadingChange, status]);
25
29
  return status === 'done' ? /*#__PURE__*/React.createElement(CopySummaryAction, _extends({}, props, {
26
30
  testId: testId,
27
31
  content: content
@@ -41,6 +41,10 @@ const ActionBlock = ({
41
41
  const context = useFlexibleUiContext();
42
42
  const ui = useFlexibleUiOptionContext();
43
43
  const [message, setMessage] = useState();
44
+ const [isLoading, setIsLoading] = useState(false);
45
+ const onLoadingChange = useCallback(isLoading => {
46
+ setIsLoading(isLoading);
47
+ }, [setIsLoading]);
44
48
  const padding = !(ui !== null && ui !== void 0 && ui.hidePadding) ? getPrimitivesPaddingSpaceBySize((ui === null || ui === void 0 ? void 0 : ui.size) || SmartLinkSize.Medium) : undefined;
45
49
  const onClick = useCallback(name => {
46
50
  setMessage(undefined);
@@ -63,13 +67,15 @@ const ActionBlock = ({
63
67
  key: name,
64
68
  onClick: () => onClick(name),
65
69
  onError: onError,
70
+ onLoadingChange: onLoadingChange,
66
71
  size: size,
67
72
  xcss: xcss({
68
73
  paddingInline: padding
69
- })
74
+ }),
75
+ hideTooltip: isLoading
70
76
  }) : null;
71
77
  });
72
- }, [context === null || context === void 0 ? void 0 : context.actions, onClick, onError, padding, size, spaceInline]);
78
+ }, [context === null || context === void 0 ? void 0 : context.actions, onClick, onError, padding, size, spaceInline, isLoading, onLoadingChange]);
73
79
  return actions ? jsx("div", {
74
80
  css: ignoreContainerPaddingStyles,
75
81
  ref: blockRef,
@@ -7,7 +7,7 @@ import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-m
7
7
  import LinkWarningModal from './LinkWarningModal';
8
8
  const PACKAGE_DATA = {
9
9
  packageName: "@atlaskit/smart-card",
10
- packageVersion: "26.70.0",
10
+ packageVersion: "26.71.0",
11
11
  componentName: 'linkUrl'
12
12
  };
13
13
  const Link = withLinkClickedEvent('a');
@@ -12,14 +12,14 @@ function _asyncIterator(r) { var n, t, o, e = 2; for ("undefined" != typeof Symb
12
12
  function AsyncFromSyncIterator(r) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var n = r.done; return Promise.resolve(r.value).then(function (r) { return { value: r, done: n }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(r) { this.s = r, this.n = r.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, return: function _return(r) { var n = this.s.return; return void 0 === n ? Promise.resolve({ value: r, done: !0 }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); }, throw: function _throw(r) { var n = this.s.return; return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(r); }
13
13
  import uuid from 'uuid';
14
14
  import { errorMessages } from './types';
15
- import { addPath } from './utils';
15
+ import { addPath, getXProductHeaderValue } from './utils';
16
16
  import { readStream } from './readStream';
17
17
  import { getBaseUrl } from '@atlaskit/linking-common';
18
18
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
19
19
  export var AISummaryService = /*#__PURE__*/function () {
20
20
  function AISummaryService(props) {
21
21
  var _this = this,
22
- _props$product;
22
+ _getXProductHeaderVal;
23
23
  _classCallCheck(this, AISummaryService);
24
24
  _defineProperty(this, "state", {
25
25
  content: '',
@@ -78,7 +78,7 @@ export var AISummaryService = /*#__PURE__*/function () {
78
78
  headers: _objectSpread({
79
79
  'Content-Type': 'application/json;charset=UTF-8',
80
80
  'x-experience-id': 'smart-link',
81
- 'x-product': ((_props$product = props.product) === null || _props$product === void 0 ? void 0 : _props$product.toLowerCase()) || 'confluence'
81
+ 'x-product': ((_getXProductHeaderVal = getXProductHeaderValue(props.product)) === null || _getXProductHeaderVal === void 0 ? void 0 : _getXProductHeaderVal.toLowerCase()) || 'confluence'
82
82
  }, props.headers)
83
83
  };
84
84
  this.url = props.url;
@@ -9,4 +9,34 @@ export var addPath = function addPath(baseUrl, path) {
9
9
  var pathWithoutLeadingSlash = !path.startsWith('/') ? path : path.substring(1, path.length);
10
10
  var 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
+ var 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
+ var isJiraProduct = function isJiraProduct(product) {
28
+ var 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 var getXProductHeaderValue = function getXProductHeaderValue(product) {
38
+ if (isJiraProduct(product)) {
39
+ return AiMateJiraXProduct[product];
40
+ }
41
+ return product;
12
42
  };
@@ -15,7 +15,7 @@ export var ANALYTICS_CHANNEL = 'media';
15
15
  export var context = {
16
16
  componentName: 'smart-cards',
17
17
  packageName: "@atlaskit/smart-card",
18
- packageVersion: "26.70.0"
18
+ packageVersion: "26.71.0"
19
19
  };
20
20
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
21
21
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -0,0 +1,78 @@
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
+ var 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
+ var 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
+ var ActionButton = function ActionButton(_ref) {
41
+ var content = _ref.content,
42
+ iconOption = _ref.icon,
43
+ isDisabled = _ref.isDisabled,
44
+ isLoading = _ref.isLoading,
45
+ onClickCallback = _ref.onClick,
46
+ size = _ref.size,
47
+ spaceOption = _ref.space,
48
+ testId = _ref.testId,
49
+ tooltipProps = _ref.tooltipProps,
50
+ xcss = _ref.xcss;
51
+ var space = spaceOption !== null && spaceOption !== void 0 ? spaceOption : getPrimitivesInlineSpaceBySize(size);
52
+ var onClick = useCallback(function () {
53
+ if (!isDisabled && !isLoading && onClickCallback) {
54
+ onClickCallback();
55
+ }
56
+ }, [isDisabled, isLoading, onClickCallback]);
57
+ var icon = iconOption && isLoading ? /*#__PURE__*/React.createElement(ActionIcon, {
58
+ asStackItemIcon: true,
59
+ icon: /*#__PURE__*/React.createElement(Spinner, {
60
+ testId: "".concat(testId, "-loading")
61
+ }),
62
+ size: size
63
+ }) : iconOption;
64
+ return /*#__PURE__*/React.createElement(Box, _extends({
65
+ as: "button",
66
+ xcss: [buttonStyles, xcss]
67
+ }, tooltipProps, {
68
+ onClick: onClick,
69
+ testId: testId
70
+ }), /*#__PURE__*/React.createElement(Inline, {
71
+ alignBlock: "center",
72
+ grow: "fill",
73
+ space: space
74
+ }, icon, /*#__PURE__*/React.createElement(Box, {
75
+ xcss: contentStyles
76
+ }, content)));
77
+ };
78
+ export default ActionButton;
@@ -1,88 +1,27 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import { Box, Inline, xcss } from '@atlaskit/primitives';
3
- import Spinner from '@atlaskit/spinner';
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["content", "tooltipMessage", "tooltipOnHide", "hideTooltipOnMouseDown", "hideTooltip"];
4
4
  import Tooltip from '@atlaskit/tooltip';
5
- import React, { useCallback } from 'react';
6
- import { getPrimitivesInlineSpaceBySize } from '../../../utils';
7
- import ActionIcon from '../action-icon';
8
- var 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
- var 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
- });
5
+ import React from 'react';
6
+ import ActionButton from './action-button';
40
7
  var ActionStackItem = function ActionStackItem(_ref) {
41
8
  var content = _ref.content,
42
- iconOption = _ref.icon,
43
- isDisabled = _ref.isDisabled,
44
- isLoading = _ref.isLoading,
45
- onClickCallback = _ref.onClick,
46
- size = _ref.size,
47
- spaceOption = _ref.space,
48
- testId = _ref.testId,
49
9
  tooltipMessage = _ref.tooltipMessage,
50
- xcss = _ref.xcss,
51
10
  tooltipOnHide = _ref.tooltipOnHide,
52
- hideTooltipOnMouseDown = _ref.hideTooltipOnMouseDown;
53
- var space = spaceOption !== null && spaceOption !== void 0 ? spaceOption : getPrimitivesInlineSpaceBySize(size);
54
- var onClick = useCallback(function () {
55
- if (!isDisabled && !isLoading && onClickCallback) {
56
- onClickCallback();
57
- }
58
- }, [isDisabled, isLoading, onClickCallback]);
59
- var icon = iconOption && isLoading ? /*#__PURE__*/React.createElement(ActionIcon, {
60
- asStackItemIcon: true,
61
- icon: /*#__PURE__*/React.createElement(Spinner, {
62
- testId: "".concat(testId, "-loading")
63
- }),
64
- size: size
65
- }) : iconOption;
66
-
67
- // Replace Box with Pressable once it becomes stable (currently beta)
68
- return /*#__PURE__*/React.createElement(Tooltip, {
11
+ hideTooltipOnMouseDown = _ref.hideTooltipOnMouseDown,
12
+ hideTooltip = _ref.hideTooltip,
13
+ props = _objectWithoutProperties(_ref, _excluded);
14
+ return hideTooltip ? /*#__PURE__*/React.createElement(ActionButton, _extends({}, props, {
15
+ content: content
16
+ })) : /*#__PURE__*/React.createElement(Tooltip, {
69
17
  content: tooltipMessage || content,
70
18
  onHide: tooltipOnHide,
71
19
  hideTooltipOnMouseDown: hideTooltipOnMouseDown
72
20
  }, function (tooltipProps) {
73
- return /*#__PURE__*/React.createElement(Box, _extends({
74
- as: "button",
75
- xcss: [buttonStyles, xcss]
76
- }, tooltipProps, {
77
- onClick: onClick,
78
- testId: testId
79
- }), /*#__PURE__*/React.createElement(Inline, {
80
- alignBlock: "center",
81
- grow: "fill",
82
- space: space
83
- }, icon, /*#__PURE__*/React.createElement(Box, {
84
- xcss: contentStyles
85
- }, content)));
21
+ return /*#__PURE__*/React.createElement(ActionButton, _extends({}, props, {
22
+ content: content,
23
+ tooltipProps: tooltipProps
24
+ }));
86
25
  });
87
26
  };
88
27
  export default ActionStackItem;
@@ -30,6 +30,7 @@ var Action = function Action(_ref) {
30
30
  spaceInline = _ref.spaceInline,
31
31
  tooltipMessage = _ref.tooltipMessage,
32
32
  tooltipOnHide = _ref.tooltipOnHide,
33
+ hideTooltip = _ref.hideTooltip,
33
34
  hideTooltipOnMouseDown = _ref.hideTooltipOnMouseDown,
34
35
  xcss = _ref.xcss,
35
36
  asDropDownItem = _ref.asDropDownItem,
@@ -65,7 +66,8 @@ var Action = function Action(_ref) {
65
66
  tooltipMessage: tooltipMessage || content,
66
67
  xcss: xcss,
67
68
  tooltipOnHide: tooltipOnHide,
68
- hideTooltipOnMouseDown: hideTooltipOnMouseDown
69
+ hideTooltipOnMouseDown: hideTooltipOnMouseDown,
70
+ hideTooltip: hideTooltip
69
71
  });
70
72
  }
71
73
  if (isDropdownItem) {
@@ -1,5 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import React from 'react';
2
+ import React, { useEffect } from 'react';
3
3
  import { di } from 'react-magnetic-di';
4
4
  import { useAISummary } from '../../../../../state/hooks/use-ai-summary';
5
5
  import { CopySummaryAction } from './copy-summary-action';
@@ -8,6 +8,7 @@ export var AISummaryActionComponent = function AISummaryActionComponent(props) {
8
8
  var url = props.url,
9
9
  ari = props.ari,
10
10
  product = props.product,
11
+ onLoadingChange = props.onLoadingChange,
11
12
  _props$testId = props.testId,
12
13
  testId = _props$testId === void 0 ? 'smart-action-ai-summary-action' : _props$testId;
13
14
  var _useAISummary = useAISummary({
@@ -19,6 +20,9 @@ export var AISummaryActionComponent = function AISummaryActionComponent(props) {
19
20
  status = _useAISummary$state.status,
20
21
  content = _useAISummary$state.content,
21
22
  summariseUrl = _useAISummary.summariseUrl;
23
+ useEffect(function () {
24
+ onLoadingChange === null || onLoadingChange === void 0 || onLoadingChange(status === 'loading');
25
+ }, [onLoadingChange, status]);
22
26
  return status === 'done' ? /*#__PURE__*/React.createElement(CopySummaryAction, _extends({}, props, {
23
27
  testId: testId,
24
28
  content: content
@@ -45,6 +45,13 @@ var ActionBlock = function ActionBlock(_ref) {
45
45
  _useState2 = _slicedToArray(_useState, 2),
46
46
  message = _useState2[0],
47
47
  setMessage = _useState2[1];
48
+ var _useState3 = useState(false),
49
+ _useState4 = _slicedToArray(_useState3, 2),
50
+ isLoading = _useState4[0],
51
+ setIsLoading = _useState4[1];
52
+ var onLoadingChange = useCallback(function (isLoading) {
53
+ setIsLoading(isLoading);
54
+ }, [setIsLoading]);
48
55
  var padding = !(ui !== null && ui !== void 0 && ui.hidePadding) ? getPrimitivesPaddingSpaceBySize((ui === null || ui === void 0 ? void 0 : ui.size) || SmartLinkSize.Medium) : undefined;
49
56
  var _onClick = useCallback(function (name) {
50
57
  setMessage(undefined);
@@ -69,13 +76,15 @@ var ActionBlock = function ActionBlock(_ref) {
69
76
  return _onClick(name);
70
77
  },
71
78
  onError: onError,
79
+ onLoadingChange: onLoadingChange,
72
80
  size: size,
73
81
  xcss: xcss({
74
82
  paddingInline: padding
75
- })
83
+ }),
84
+ hideTooltip: isLoading
76
85
  }) : null;
77
86
  });
78
- }, [context === null || context === void 0 ? void 0 : context.actions, _onClick, onError, padding, size, spaceInline]);
87
+ }, [context === null || context === void 0 ? void 0 : context.actions, _onClick, onError, padding, size, spaceInline, isLoading, onLoadingChange]);
79
88
  return actions ? jsx("div", {
80
89
  css: ignoreContainerPaddingStyles,
81
90
  ref: blockRef,
@@ -10,7 +10,7 @@ import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-m
10
10
  import LinkWarningModal from './LinkWarningModal';
11
11
  var PACKAGE_DATA = {
12
12
  packageName: "@atlaskit/smart-card",
13
- packageVersion: "26.70.0",
13
+ packageVersion: "26.71.0",
14
14
  componentName: 'linkUrl'
15
15
  };
16
16
  var Link = withLinkClickedEvent('a');
@@ -1,2 +1,9 @@
1
+ import { type ProductType } from '@atlaskit/linking-common';
1
2
  export declare const getBufferReader: (response: Response) => ReadableStreamDefaultReader<string>;
2
3
  export declare const addPath: (baseUrl: string, path: string) => string;
4
+ /**
5
+ * Converts a `ProductType` to the expected `x-product` header value for AI Mate.
6
+ *
7
+ * @see https://developer.atlassian.com/platform/assistance-service/security/entitlements/#approach
8
+ */
9
+ export declare const getXProductHeaderValue: (product: ProductType | undefined) => "CONFLUENCE" | "ATLAS" | "BITBUCKET" | "TRELLO" | "JSM" | "JPD" | "ELEVATE" | "JIRA-SOFTWARE" | "JIRA-CORE" | undefined;
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import type { ActionStackItemProps } from './types';
3
+ import type { TriggerProps } from '@atlaskit/tooltip';
4
+ declare const ActionButton: ({ content, icon: iconOption, isDisabled, isLoading, onClick: onClickCallback, size, space: spaceOption, testId, tooltipProps, xcss, }: import("../types").ActionProps & {
5
+ size: import("../../../../../..").SmartLinkSize;
6
+ space?: "space.0" | "space.025" | "space.050" | "space.075" | "space.100" | "space.150" | "space.200" | "space.250" | "space.300" | "space.400" | "space.500" | "space.600" | "space.800" | "space.1000" | undefined;
7
+ tooltipOnHide?: ((analyticsEvent: import("@atlaskit/analytics-next").UIAnalyticsEvent) => any) | undefined;
8
+ hideTooltipOnMouseDown?: boolean | undefined;
9
+ } & {
10
+ tooltipProps?: TriggerProps | undefined;
11
+ }) => JSX.Element;
12
+ export default ActionButton;
@@ -1,4 +1,4 @@
1
- import { type FC } from 'react';
2
- import { type ActionStackItemProps } from './types';
3
- declare const ActionStackItem: FC<ActionStackItemProps>;
1
+ /// <reference types="react" />
2
+ import type { ActionStackItemProps } from './types';
3
+ declare const ActionStackItem: ({ content, tooltipMessage, tooltipOnHide, hideTooltipOnMouseDown, hideTooltip, ...props }: ActionStackItemProps) => JSX.Element;
4
4
  export default ActionStackItem;
@@ -1,13 +1,10 @@
1
- import type { Space, XCSS } from '@atlaskit/primitives';
1
+ import type { Space } from '@atlaskit/primitives';
2
2
  import type { SmartLinkSize } from '../../../../../../constants';
3
3
  import type { ActionProps } from '../types';
4
- import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
4
+ import type { UIAnalyticsEvent } from '@atlaskit/analytics-next';
5
5
  export type ActionStackItemProps = ActionProps & {
6
- isLoading?: boolean;
7
6
  size: SmartLinkSize;
8
- isDisabled?: boolean;
9
7
  space?: Space;
10
- xcss?: XCSS;
11
8
  tooltipOnHide?: (analyticsEvent: UIAnalyticsEvent) => any;
12
9
  hideTooltipOnMouseDown?: boolean;
13
10
  };
@@ -60,6 +60,10 @@ export type ActionProps = {
60
60
  * Determines the hideTooltipOnMouseDown behaviour of the Tooltip
61
61
  */
62
62
  hideTooltipOnMouseDown?: boolean;
63
+ /**
64
+ * Determines if the tooltip should be hidden
65
+ */
66
+ hideTooltip?: boolean;
63
67
  /**
64
68
  * @deprecated Use 'as' instead
65
69
  * Used to determine whether the Action is in a Dropdown.
@@ -102,4 +106,5 @@ export type ActionProps = {
102
106
  * Cleanup on https://product-fabric.atlassian.net/browse/EDM-9649
103
107
  */
104
108
  wrapper?: React.ElementType;
109
+ onLoadingChange?: (isLoading: boolean) => void;
105
110
  };
@@ -1,2 +1,9 @@
1
+ import { type ProductType } from '@atlaskit/linking-common';
1
2
  export declare const getBufferReader: (response: Response) => ReadableStreamDefaultReader<string>;
2
3
  export declare const addPath: (baseUrl: string, path: string) => string;
4
+ /**
5
+ * Converts a `ProductType` to the expected `x-product` header value for AI Mate.
6
+ *
7
+ * @see https://developer.atlassian.com/platform/assistance-service/security/entitlements/#approach
8
+ */
9
+ export declare const getXProductHeaderValue: (product: ProductType | undefined) => "CONFLUENCE" | "ATLAS" | "BITBUCKET" | "TRELLO" | "JSM" | "JPD" | "ELEVATE" | "JIRA-SOFTWARE" | "JIRA-CORE" | undefined;
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import type { ActionStackItemProps } from './types';
3
+ import type { TriggerProps } from '@atlaskit/tooltip';
4
+ declare const ActionButton: ({ content, icon: iconOption, isDisabled, isLoading, onClick: onClickCallback, size, space: spaceOption, testId, tooltipProps, xcss, }: import("../types").ActionProps & {
5
+ size: import("../../../../../..").SmartLinkSize;
6
+ space?: "space.0" | "space.025" | "space.050" | "space.075" | "space.100" | "space.150" | "space.200" | "space.250" | "space.300" | "space.400" | "space.500" | "space.600" | "space.800" | "space.1000" | undefined;
7
+ tooltipOnHide?: ((analyticsEvent: import("@atlaskit/analytics-next").UIAnalyticsEvent) => any) | undefined;
8
+ hideTooltipOnMouseDown?: boolean | undefined;
9
+ } & {
10
+ tooltipProps?: TriggerProps | undefined;
11
+ }) => JSX.Element;
12
+ export default ActionButton;
@@ -1,4 +1,4 @@
1
- import { type FC } from 'react';
2
- import { type ActionStackItemProps } from './types';
3
- declare const ActionStackItem: FC<ActionStackItemProps>;
1
+ /// <reference types="react" />
2
+ import type { ActionStackItemProps } from './types';
3
+ declare const ActionStackItem: ({ content, tooltipMessage, tooltipOnHide, hideTooltipOnMouseDown, hideTooltip, ...props }: ActionStackItemProps) => JSX.Element;
4
4
  export default ActionStackItem;
@@ -1,13 +1,10 @@
1
- import type { Space, XCSS } from '@atlaskit/primitives';
1
+ import type { Space } from '@atlaskit/primitives';
2
2
  import type { SmartLinkSize } from '../../../../../../constants';
3
3
  import type { ActionProps } from '../types';
4
- import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
4
+ import type { UIAnalyticsEvent } from '@atlaskit/analytics-next';
5
5
  export type ActionStackItemProps = ActionProps & {
6
- isLoading?: boolean;
7
6
  size: SmartLinkSize;
8
- isDisabled?: boolean;
9
7
  space?: Space;
10
- xcss?: XCSS;
11
8
  tooltipOnHide?: (analyticsEvent: UIAnalyticsEvent) => any;
12
9
  hideTooltipOnMouseDown?: boolean;
13
10
  };
@@ -60,6 +60,10 @@ export type ActionProps = {
60
60
  * Determines the hideTooltipOnMouseDown behaviour of the Tooltip
61
61
  */
62
62
  hideTooltipOnMouseDown?: boolean;
63
+ /**
64
+ * Determines if the tooltip should be hidden
65
+ */
66
+ hideTooltip?: boolean;
63
67
  /**
64
68
  * @deprecated Use 'as' instead
65
69
  * Used to determine whether the Action is in a Dropdown.
@@ -102,4 +106,5 @@ export type ActionProps = {
102
106
  * Cleanup on https://product-fabric.atlassian.net/browse/EDM-9649
103
107
  */
104
108
  wrapper?: React.ElementType;
109
+ onLoadingChange?: (isLoading: boolean) => void;
105
110
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.70.0",
3
+ "version": "26.71.0",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"