@atlaskit/smart-card 27.19.0 → 27.20.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 (89) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/utils/analytics/analytics.js +1 -1
  3. package/dist/cjs/view/FlexibleCard/components/actions/follow-action/index.js +2 -4
  4. package/dist/cjs/view/FlexibleCard/components/actions/preview-action/index.js +4 -5
  5. package/dist/cjs/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +3 -0
  6. package/dist/cjs/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +6 -125
  7. package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +2 -16
  8. package/dist/cjs/view/HoverCard/components/HoverCardContent.js +5 -67
  9. package/dist/cjs/view/HoverCard/utils.js +2 -8
  10. package/dist/cjs/view/LinkUrl/index.js +1 -1
  11. package/dist/cjs/view/common/ai-icon/index.js +9 -69
  12. package/dist/cjs/view/common/ai-summary/index.js +1 -13
  13. package/dist/es2019/utils/analytics/analytics.js +1 -1
  14. package/dist/es2019/view/FlexibleCard/components/actions/follow-action/index.js +3 -5
  15. package/dist/es2019/view/FlexibleCard/components/actions/preview-action/index.js +4 -5
  16. package/dist/es2019/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +3 -0
  17. package/dist/es2019/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +6 -123
  18. package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +3 -15
  19. package/dist/es2019/view/HoverCard/components/HoverCardContent.js +5 -40
  20. package/dist/es2019/view/HoverCard/utils.js +2 -8
  21. package/dist/es2019/view/LinkUrl/index.js +1 -1
  22. package/dist/es2019/view/common/ai-icon/index.js +9 -69
  23. package/dist/es2019/view/common/ai-summary/index.js +1 -10
  24. package/dist/esm/utils/analytics/analytics.js +1 -1
  25. package/dist/esm/view/FlexibleCard/components/actions/follow-action/index.js +3 -5
  26. package/dist/esm/view/FlexibleCard/components/actions/preview-action/index.js +4 -5
  27. package/dist/esm/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +3 -0
  28. package/dist/esm/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.js +7 -126
  29. package/dist/esm/view/HoverCard/components/HoverCardComponent.js +3 -17
  30. package/dist/esm/view/HoverCard/components/HoverCardContent.js +5 -66
  31. package/dist/esm/view/HoverCard/utils.js +2 -8
  32. package/dist/esm/view/LinkUrl/index.js +1 -1
  33. package/dist/esm/view/common/ai-icon/index.js +9 -69
  34. package/dist/esm/view/common/ai-summary/index.js +1 -13
  35. package/dist/types/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.d.ts +0 -10
  36. package/dist/types/view/FlexibleCard/components/blocks/ai-summary-block/types.d.ts +1 -17
  37. package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +5 -1
  38. package/dist/types/view/HoverCard/components/HoverCardContent.d.ts +5 -3
  39. package/dist/types/view/HoverCard/types.d.ts +0 -2
  40. package/dist/types/view/HoverCard/utils.d.ts +0 -1
  41. package/dist/types/view/common/ai-summary/index.d.ts +1 -8
  42. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/ai-summary-block/resolved/index.d.ts +0 -10
  43. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/ai-summary-block/types.d.ts +1 -17
  44. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/types.d.ts +5 -1
  45. package/dist/types-ts4.5/view/HoverCard/components/HoverCardContent.d.ts +5 -3
  46. package/dist/types-ts4.5/view/HoverCard/types.d.ts +0 -2
  47. package/dist/types-ts4.5/view/HoverCard/utils.d.ts +0 -1
  48. package/dist/types-ts4.5/view/common/ai-summary/index.d.ts +1 -8
  49. package/package.json +4 -17
  50. package/dist/cjs/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/ai-indicator-container.js +0 -28
  51. package/dist/cjs/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/ai-indicator-tooltip.js +0 -52
  52. package/dist/cjs/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/ai-state-done.js +0 -137
  53. package/dist/cjs/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/ai-state-error.js +0 -71
  54. package/dist/cjs/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/ai-state-loading.js +0 -34
  55. package/dist/cjs/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/index.js +0 -46
  56. package/dist/cjs/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/types.js +0 -5
  57. package/dist/cjs/view/HoverCard/components/views/resolved/index.js +0 -181
  58. package/dist/es2019/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/ai-indicator-container.js +0 -22
  59. package/dist/es2019/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/ai-indicator-tooltip.js +0 -39
  60. package/dist/es2019/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/ai-state-done.js +0 -125
  61. package/dist/es2019/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/ai-state-error.js +0 -63
  62. package/dist/es2019/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/ai-state-loading.js +0 -28
  63. package/dist/es2019/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/index.js +0 -37
  64. package/dist/es2019/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/types.js +0 -1
  65. package/dist/es2019/view/HoverCard/components/views/resolved/index.js +0 -173
  66. package/dist/esm/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/ai-indicator-container.js +0 -21
  67. package/dist/esm/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/ai-indicator-tooltip.js +0 -41
  68. package/dist/esm/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/ai-state-done.js +0 -128
  69. package/dist/esm/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/ai-state-error.js +0 -64
  70. package/dist/esm/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/ai-state-loading.js +0 -27
  71. package/dist/esm/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/index.js +0 -38
  72. package/dist/esm/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/types.js +0 -1
  73. package/dist/esm/view/HoverCard/components/views/resolved/index.js +0 -172
  74. package/dist/types/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/ai-indicator-container.d.ts +0 -4
  75. package/dist/types/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/ai-indicator-tooltip.d.ts +0 -4
  76. package/dist/types/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/ai-state-done.d.ts +0 -4
  77. package/dist/types/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/ai-state-error.d.ts +0 -4
  78. package/dist/types/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/ai-state-loading.d.ts +0 -4
  79. package/dist/types/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/index.d.ts +0 -8
  80. package/dist/types/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/types.d.ts +0 -21
  81. package/dist/types/view/HoverCard/components/views/resolved/index.d.ts +0 -7
  82. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/ai-indicator-container.d.ts +0 -4
  83. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/ai-indicator-tooltip.d.ts +0 -4
  84. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/ai-state-done.d.ts +0 -4
  85. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/ai-state-error.d.ts +0 -4
  86. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/ai-state-loading.d.ts +0 -4
  87. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/index.d.ts +0 -8
  88. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/ai-summary-block/ai-state-indicator/types.d.ts +0 -21
  89. package/dist/types-ts4.5/view/HoverCard/components/views/resolved/index.d.ts +0 -7
@@ -1,21 +0,0 @@
1
- import React from 'react';
2
- import { Inline, xcss } from '@atlaskit/primitives';
3
- var contentStyles = xcss({
4
- color: 'color.text.subtle',
5
- fontSize: '12px',
6
- fontWeight: '400',
7
- lineHeight: '16px'
8
- });
9
- var AIIndicatorContainer = function AIIndicatorContainer(_ref) {
10
- var icon = _ref.icon,
11
- content = _ref.content,
12
- testId = _ref.testId;
13
- return /*#__PURE__*/React.createElement(Inline, {
14
- alignBlock: "start",
15
- alignInline: "start",
16
- space: "space.050",
17
- xcss: contentStyles,
18
- testId: testId
19
- }, icon, content);
20
- };
21
- export default AIIndicatorContainer;
@@ -1,41 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import React from 'react';
3
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
4
- import styled from '@emotion/styled';
5
- import Tooltip, { TooltipPrimitive } from '@atlaskit/tooltip';
6
- import { Box, xcss } from '@atlaskit/primitives';
7
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-styled -- To migrate as part of go/ui-styling-standard
8
- var AIIndicatorTooltipPrimitive = styled(TooltipPrimitive)({
9
- borderRadius: "var(--ds-border-radius, 3px)",
10
- backgroundColor: "var(--ds-surface-raised, white)",
11
- boxShadow: "var(--ds-shadow-overlay, 0px 8px 12px rgba(9, 30, 66, 0.15),0px 0px 1px rgba(9, 30, 66, 0.31))",
12
- boxSizing: 'content-box',
13
- padding: "var(--ds-space-200, 16px)",
14
- maxWidth: '350px'
15
- });
16
- var triggerStyles = xcss({
17
- display: 'inline-flex'
18
- });
19
- var AIIndicatorTooltip = function AIIndicatorTooltip(_ref) {
20
- var content = _ref.content,
21
- trigger = _ref.trigger,
22
- overrideXcss = _ref.xcss;
23
- return (
24
- /*#__PURE__*/
25
- // @ts-ignore: [PIT-1685] Fails in post-office due to backwards incompatibility issue with React 18
26
- React.createElement(Tooltip, {
27
- component: AIIndicatorTooltipPrimitive,
28
- content: content,
29
- tag: "span"
30
- }, function (tooltipProps) {
31
- return (
32
- /*#__PURE__*/
33
- // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
34
- React.createElement(Box, _extends({
35
- xcss: [triggerStyles, overrideXcss]
36
- }, tooltipProps), trigger)
37
- );
38
- })
39
- );
40
- };
41
- export default AIIndicatorTooltip;
@@ -1,128 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- /**
3
- * @jsxRuntime classic
4
- * @jsx jsx
5
- */
6
- import React from 'react';
7
- import { FormattedMessage } from 'react-intl-next';
8
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
9
- import { css, jsx } from '@emotion/react';
10
- import EditorPanelIcon from '@atlaskit/icon/utility/migration/information--editor-panel';
11
- import Lozenge from '@atlaskit/lozenge';
12
- import { Box, Inline, Stack, xcss } from '@atlaskit/primitives';
13
- import { fg } from '@atlaskit/platform-feature-flags';
14
- import { messages } from '../../../../../../messages';
15
- import AIIcon from '../../../../../common/ai-icon';
16
- import AIIndicatorTooltip from './ai-indicator-tooltip';
17
- import AIIndicatorContainer from './ai-indicator-container';
18
- import AILearnMoreAnchor from '../../../common/ai-summary/ai-learn-more-anchor';
19
- var tooltipMsgStyles = xcss({
20
- color: 'color.text',
21
- fontSize: '14px',
22
- fontWeight: '400',
23
- lineHeight: '20px'
24
- });
25
- var iconTooltipLinkStyles = css({
26
- color: "var(--ds-text-subtlest, #626F86)",
27
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
28
- '&:link, :visited': {
29
- color: "var(--ds-text-subtlest, #626F86)"
30
- },
31
- '&:hover': {
32
- color: "var(--ds-text-subtle, #44546F)"
33
- },
34
- '&:active': {
35
- color: "var(--ds-text, #172B4D)"
36
- },
37
- textDecoration: 'underline'
38
- });
39
- var iconTooltipTitleStyles = xcss({
40
- color: 'color.text',
41
- fontSize: '12px',
42
- fontWeight: '400',
43
- lineHeight: '16px'
44
- });
45
- var iconTooltipDescStyles = xcss({
46
- color: 'color.text.subtlest',
47
- fontSize: '11px',
48
- fontWeight: '400',
49
- lineHeight: '14px'
50
- });
51
- var iconTooltipTriggerStyles = xcss({
52
- verticalAlign: 'bottom'
53
- });
54
- var AIStateDone = function AIStateDone(_ref) {
55
- var appearance = _ref.appearance,
56
- testId = _ref.testId;
57
- var icon = jsx(AIIcon, {
58
- label: "AI",
59
- size: "small",
60
- testId: "".concat(testId, "-done-icon")
61
- });
62
- var title = fg('platform.linking-platform.smart-card.hover-card-ai-summaries-release-stable') ? jsx(Box, {
63
- testId: "".concat(testId, "-done-message")
64
- }, jsx(FormattedMessage, messages.ai_summarized)) : jsx(React.Fragment, null, jsx(Box, {
65
- testId: "".concat(testId, "-done-message")
66
- }, jsx(FormattedMessage, messages.ai_summarized_abbreviation)), jsx(Box, null, jsx(Lozenge, {
67
- appearance: "new",
68
- testId: "".concat(testId, "-beta")
69
- }, jsx(FormattedMessage, messages.beta))));
70
- switch (appearance) {
71
- case 'icon-only':
72
- return jsx(AIIndicatorTooltip, {
73
- content: jsx(Inline, {
74
- alignBlock: "center",
75
- space: "space.100"
76
- }, jsx(AIIcon, {
77
- label: "AI",
78
- size: "medium",
79
- testId: "".concat(testId, "-done-tooltip-icon")
80
- }), jsx(Stack, null, jsx(Inline, {
81
- alignBlock: "center",
82
- alignInline: "start",
83
- space: "space.050",
84
- xcss: iconTooltipTitleStyles
85
- }, title), jsx(Box, {
86
- xcss: iconTooltipDescStyles
87
- }, jsx(FormattedMessage, _extends({}, messages.ai_summarized_info, {
88
- values: {
89
- a: function a(chunks) {
90
- return jsx(AILearnMoreAnchor, {
91
- css: iconTooltipLinkStyles
92
- }, chunks);
93
- }
94
- }
95
- }))))),
96
- trigger: icon,
97
- xcss: iconTooltipTriggerStyles
98
- });
99
- default:
100
- return jsx(AIIndicatorContainer, {
101
- icon: icon,
102
- content: jsx(Inline, {
103
- alignBlock: "center",
104
- alignInline: "start",
105
- space: "space.050"
106
- }, title, jsx(AIIndicatorTooltip, {
107
- content: jsx(Box, {
108
- xcss: tooltipMsgStyles,
109
- testId: "".concat(testId, "-done-tooltip")
110
- }, jsx(FormattedMessage, _extends({}, messages.ai_summarized_info, {
111
- values: {
112
- a: function a(chunks) {
113
- return jsx(AILearnMoreAnchor, null, chunks);
114
- }
115
- }
116
- }))),
117
- trigger: jsx(EditorPanelIcon, {
118
- label: "Info",
119
- LEGACY_size: "small",
120
- testId: "".concat(testId, "-done-info"),
121
- color: "var(--ds-icon, #44546F)"
122
- })
123
- })),
124
- testId: "".concat(testId, "-done")
125
- });
126
- }
127
- };
128
- export default AIStateDone;
@@ -1,64 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import React from 'react';
3
- import { FormattedMessage } from 'react-intl-next';
4
- import ErrorIcon from '@atlaskit/icon/utility/migration/error';
5
- import { Box, xcss } from '@atlaskit/primitives';
6
- import { getAISummaryErrorMessage } from '../../../../../../utils/ai-summary';
7
- import AILearnMoreAnchor from '../../../common/ai-summary/ai-learn-more-anchor';
8
- import AIIndicatorContainer from './ai-indicator-container';
9
- var contentStyles = xcss({
10
- color: 'color.text.subtle',
11
- fontSize: '11px',
12
- fontStyle: 'normal',
13
- fontWeight: '400',
14
- lineHeight: '14px'
15
- });
16
- var alignTextWithIcon = {
17
- marginTop: '1px'
18
- };
19
- var FormattedErrorMessage = function FormattedErrorMessage(_ref) {
20
- var message = _ref.message,
21
- url = _ref.url;
22
- return /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, message, {
23
- values: {
24
- a: function a(chunks) {
25
- return /*#__PURE__*/React.createElement(AILearnMoreAnchor, {
26
- href: url
27
- }, chunks);
28
- }
29
- }
30
- }));
31
- };
32
- var AIStateError = function AIStateError(_ref2) {
33
- var appearance = _ref2.appearance,
34
- testId = _ref2.testId,
35
- error = _ref2.error;
36
- var _getAISummaryErrorMes = getAISummaryErrorMessage(error),
37
- message = _getAISummaryErrorMes.message,
38
- url = _getAISummaryErrorMes.url;
39
- switch (appearance) {
40
- case 'icon-only':
41
- return null;
42
- default:
43
- return /*#__PURE__*/React.createElement(AIIndicatorContainer, {
44
- icon: /*#__PURE__*/React.createElement(ErrorIcon, {
45
- color: "var(--ds-icon-danger, #C9372C)",
46
- label: "AI",
47
- LEGACY_size: "small",
48
- testId: "".concat(testId, "-error-icon")
49
- }),
50
- content: /*#__PURE__*/React.createElement(Box, {
51
- testId: "".concat(testId, "-error-message"),
52
- xcss: contentStyles
53
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
54
- ,
55
- style: alignTextWithIcon
56
- }, /*#__PURE__*/React.createElement(FormattedErrorMessage, {
57
- message: message,
58
- url: url
59
- })),
60
- testId: "".concat(testId, "-error")
61
- });
62
- }
63
- };
64
- export default AIStateError;
@@ -1,27 +0,0 @@
1
- import React from 'react';
2
- import { FormattedMessage } from 'react-intl-next';
3
- import { Box } from '@atlaskit/primitives';
4
- import { messages } from '../../../../../../messages';
5
- import AIIconLoading from '../../../../../common/ai-icon-loading';
6
- import AIIndicatorContainer from './ai-indicator-container';
7
- var AIStateLoading = function AIStateLoading(_ref) {
8
- var appearance = _ref.appearance,
9
- testId = _ref.testId;
10
- switch (appearance) {
11
- case 'icon-only':
12
- return null;
13
- default:
14
- return /*#__PURE__*/React.createElement(AIIndicatorContainer, {
15
- icon: /*#__PURE__*/React.createElement(AIIconLoading, {
16
- label: "AI",
17
- size: "small",
18
- testId: "".concat(testId, "-loading-icon")
19
- }),
20
- content: /*#__PURE__*/React.createElement(Box, {
21
- testId: "".concat(testId, "-loading-message")
22
- }, /*#__PURE__*/React.createElement(FormattedMessage, messages.ai_summarizing)),
23
- testId: "".concat(testId, "-loading")
24
- });
25
- }
26
- };
27
- export default AIStateLoading;
@@ -1,38 +0,0 @@
1
- /**
2
- * @jsxRuntime classic
3
- * @jsx jsx
4
- */
5
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
6
- import { jsx } from '@emotion/react';
7
- import AIStateLoading from './ai-state-loading';
8
- import AIStateDone from './ai-state-done';
9
- import AIStateError from './ai-state-error';
10
- var AIStateIndicator = function AIStateIndicator(_ref) {
11
- var state = _ref.state,
12
- _ref$appearance = _ref.appearance,
13
- appearance = _ref$appearance === void 0 ? 'default' : _ref$appearance,
14
- _ref$testId = _ref.testId,
15
- testId = _ref$testId === void 0 ? 'ai-state-indicator' : _ref$testId,
16
- error = _ref.error;
17
- switch (state) {
18
- case 'error':
19
- return jsx(AIStateError, {
20
- appearance: appearance,
21
- testId: testId,
22
- error: error
23
- });
24
- case 'loading':
25
- return jsx(AIStateLoading, {
26
- appearance: appearance,
27
- testId: testId
28
- });
29
- case 'done':
30
- return jsx(AIStateDone, {
31
- appearance: appearance,
32
- testId: testId
33
- });
34
- default:
35
- return null;
36
- }
37
- };
38
- export default AIStateIndicator;
@@ -1,172 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
- import React, { useCallback, useEffect, useMemo, useRef } from 'react';
4
- import { ActionName, CardDisplay, ElementName, SmartLinkPosition, SmartLinkSize, SmartLinkDirection } from '../../../../../constants';
5
- import { FooterBlock, MetadataBlock, RelatedUrlsBlock, SnippetBlock, TitleBlock, AISummaryBlock, CustomBlock } from '../../../../FlexibleCard/components/blocks';
6
- import { footerBlockCss, hiddenSnippetStyles, metadataBlockCss } from './styled';
7
- import FlexibleCard from '../../../../FlexibleCard';
8
- import { getMetadata } from '../../../utils';
9
- import ImagePreview from '../../ImagePreview';
10
- import { messages } from '../../../../../messages';
11
- import { FormattedMessage } from 'react-intl-next';
12
- import { fg } from '@atlaskit/platform-feature-flags';
13
- import { getCanBeDatasource } from '../../../../../state/helpers';
14
- import useAISummaryAction from '../../../../../state/hooks/use-ai-summary-action';
15
- import { SmartLinkStatus } from '../../../../../constants';
16
- import { di } from 'react-magnetic-di';
17
- export var toFooterActions = function toFooterActions(cardActions, onActionClick) {
18
- var followAction = {
19
- hideIcon: true,
20
- name: ActionName.FollowAction
21
- };
22
- var actions = cardActions.map(function (action) {
23
- if (action.id === 'preview-content') {
24
- return {
25
- content: /*#__PURE__*/React.createElement(FormattedMessage, messages.preview_improved),
26
- name: ActionName.CustomAction,
27
- onClick: function onClick() {
28
- if (onActionClick) {
29
- onActionClick(action.id);
30
- }
31
- return action.invoke();
32
- },
33
- testId: action.id,
34
- appearance: 'primary'
35
- };
36
- }
37
- return {
38
- content: action.text,
39
- name: ActionName.CustomAction,
40
- onClick: function onClick() {
41
- if (onActionClick) {
42
- onActionClick(action.id);
43
- }
44
- return action.invoke();
45
- },
46
- testId: action.id
47
- };
48
- });
49
- return [followAction].concat(_toConsumableArray(actions));
50
- };
51
- var ConnectedAIBlock = function ConnectedAIBlock(_ref) {
52
- var bottomPrimary = _ref.bottomPrimary,
53
- imagePreview = _ref.imagePreview,
54
- url = _ref.url;
55
- var _useAISummaryAction = useAISummaryAction(url),
56
- _useAISummaryAction$s = _useAISummaryAction.state,
57
- status = _useAISummaryAction$s.status,
58
- content = _useAISummaryAction$s.content;
59
- var showData = status === 'ready' || status === 'error' ||
60
- // Description & bottom metadata should only disappear when we start getting summary content
61
- !content && status === 'loading';
62
- return showData ? /*#__PURE__*/React.createElement(React.Fragment, null, !imagePreview && /*#__PURE__*/React.createElement(SnippetBlock, {
63
- testId: 'connected-AI',
64
- status: SmartLinkStatus.Resolved
65
- }), /*#__PURE__*/React.createElement(MetadataBlock, {
66
- primary: bottomPrimary,
67
- size: SmartLinkSize.Large,
68
- overrideCss: metadataBlockCss,
69
- maxLines: 1,
70
- status: SmartLinkStatus.Resolved
71
- })) : null;
72
- };
73
- var HoverCardResolvedView = function HoverCardResolvedView(_ref2) {
74
- var _cardState$details;
75
- var flexibleCardProps = _ref2.flexibleCardProps,
76
- titleBlockProps = _ref2.titleBlockProps,
77
- analytics = _ref2.analytics,
78
- cardState = _ref2.cardState,
79
- _ref2$cardActions = _ref2.cardActions,
80
- cardActions = _ref2$cardActions === void 0 ? [] : _ref2$cardActions,
81
- isAISummaryEnabled = _ref2.isAISummaryEnabled,
82
- onActionClick = _ref2.onActionClick,
83
- extensionKey = _ref2.extensionKey,
84
- url = _ref2.url;
85
- var canBeDatasource = getCanBeDatasource(cardState.details);
86
- useEffect(function () {
87
- // Since this hover view is only rendered on resolved status,
88
- // there is no need to check for statuses.
89
- analytics.ui.renderSuccessEvent({
90
- display: CardDisplay.HoverCardPreview,
91
- status: cardState.status,
92
- canBeDatasource: canBeDatasource
93
- });
94
- }, [analytics.ui, cardState.status, canBeDatasource]);
95
- var footerActions = useMemo(function () {
96
- return toFooterActions(cardActions, onActionClick);
97
- }, [cardActions, onActionClick]);
98
- var data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
99
- var _useMemo = useMemo(function () {
100
- return getMetadata(extensionKey, data);
101
- }, [data, extensionKey]),
102
- primary = _useMemo.primary,
103
- secondary = _useMemo.secondary,
104
- tertiary = _useMemo.tertiary;
105
- var snippetHeight = React.useRef(0);
106
- var snippetBlockRef = useRef(null);
107
- var onSnippetRender = useCallback(function () {
108
- var _snippetBlockRef$curr, _snippetBlockRef$curr2;
109
- snippetHeight.current = (_snippetBlockRef$curr = (_snippetBlockRef$curr2 = snippetBlockRef.current) === null || _snippetBlockRef$curr2 === void 0 ? void 0 : _snippetBlockRef$curr2.getBoundingClientRect().height) !== null && _snippetBlockRef$curr !== void 0 ? _snippetBlockRef$curr : 0;
110
- }, []);
111
-
112
- // We want to maintain the height of the HoverCard while summarizing and pass this height to the AISummaryBlock.
113
- // This approach will prevent any abrupt changes in the height of the HoverCard.
114
- var connectedAIBlockHeight = React.useRef(0);
115
- var connectedAIBlockRef = useRef(null);
116
- var onConnectedAIBlockRender = useCallback(function () {
117
- var _connectedAIBlockRef$, _connectedAIBlockRef$2;
118
- connectedAIBlockHeight.current = (_connectedAIBlockRef$ = (_connectedAIBlockRef$2 = connectedAIBlockRef.current) === null || _connectedAIBlockRef$2 === void 0 ? void 0 : _connectedAIBlockRef$2.getBoundingClientRect().height) !== null && _connectedAIBlockRef$ !== void 0 ? _connectedAIBlockRef$ : 0;
119
- }, []);
120
- var imagePreview = ImagePreview({
121
- data: data,
122
- fallbackElementHeight: snippetHeight.current
123
- });
124
- return /*#__PURE__*/React.createElement(FlexibleCard, flexibleCardProps, imagePreview, /*#__PURE__*/React.createElement(TitleBlock, _extends({}, titleBlockProps, {
125
- metadataPosition: SmartLinkPosition.Top
126
- })), /*#__PURE__*/React.createElement(MetadataBlock, {
127
- primary: primary,
128
- secondary: secondary,
129
- overrideCss: metadataBlockCss,
130
- maxLines: 1,
131
- size: SmartLinkSize.Medium
132
- }), isAISummaryEnabled &&
133
- /*#__PURE__*/
134
- // All custom elements should be contained within a CustomBlock.
135
- // Flex Container components check whether the direct child is a flex blocks. It removes anything that isn't
136
- React.createElement(CustomBlock, {
137
- direction: SmartLinkDirection.Vertical,
138
- onRender: onConnectedAIBlockRender,
139
- blockRef: connectedAIBlockRef
140
- }, /*#__PURE__*/React.createElement(ConnectedAIBlock, {
141
- imagePreview: !!imagePreview,
142
- bottomPrimary: tertiary,
143
- url: url
144
- })), !isAISummaryEnabled && !imagePreview && /*#__PURE__*/React.createElement(SnippetBlock, {
145
- status: SmartLinkStatus.Resolved
146
- }), /*#__PURE__*/React.createElement(SnippetBlock, {
147
- testId: 'hidden-snippet',
148
- onRender: onSnippetRender,
149
- blockRef: snippetBlockRef,
150
- overrideCss: hiddenSnippetStyles
151
- }), !isAISummaryEnabled && /*#__PURE__*/React.createElement(MetadataBlock, {
152
- primary: tertiary,
153
- size: SmartLinkSize.Large,
154
- overrideCss: metadataBlockCss,
155
- maxLines: 1,
156
- status: SmartLinkStatus.Resolved
157
- }), fg('platform.linking-platform.smart-card.enable-hover-card-related-urls') && /*#__PURE__*/React.createElement(RelatedUrlsBlock, {
158
- url: url,
159
- size: SmartLinkSize.Small
160
- }), isAISummaryEnabled && /*#__PURE__*/React.createElement(AISummaryBlock, {
161
- metadata: [{
162
- name: ElementName.Provider
163
- }],
164
- actions: footerActions,
165
- aiSummaryMinHeight: connectedAIBlockHeight.current
166
- }), !isAISummaryEnabled && /*#__PURE__*/React.createElement(FooterBlock, {
167
- actions: footerActions,
168
- size: SmartLinkSize.Large,
169
- overrideCss: footerBlockCss
170
- }));
171
- };
172
- export default HoverCardResolvedView;
@@ -1,4 +0,0 @@
1
- /// <reference types="react" />
2
- import { type AIIndicatorContainerProps } from './types';
3
- declare const AIIndicatorContainer: ({ icon, content, testId }: AIIndicatorContainerProps) => JSX.Element;
4
- export default AIIndicatorContainer;
@@ -1,4 +0,0 @@
1
- /// <reference types="react" />
2
- import type { AIIndicatorTooltipProps } from './types';
3
- declare const AIIndicatorTooltip: ({ content, trigger, xcss: overrideXcss }: AIIndicatorTooltipProps) => JSX.Element;
4
- export default AIIndicatorTooltip;
@@ -1,4 +0,0 @@
1
- import { jsx } from '@emotion/react';
2
- import type { AIStateIndicatorProps } from './types';
3
- declare const AIStateDone: ({ appearance, testId }: Partial<AIStateIndicatorProps>) => jsx.JSX.Element;
4
- export default AIStateDone;
@@ -1,4 +0,0 @@
1
- /// <reference types="react" />
2
- import { type AIStateIndicatorProps } from './types';
3
- declare const AIStateError: ({ appearance, testId, error }: Partial<AIStateIndicatorProps>) => JSX.Element | null;
4
- export default AIStateError;
@@ -1,4 +0,0 @@
1
- /// <reference types="react" />
2
- import { type AIStateIndicatorProps } from './types';
3
- declare const AIStateLoading: ({ appearance, testId }: Partial<AIStateIndicatorProps>) => JSX.Element | null;
4
- export default AIStateLoading;
@@ -1,8 +0,0 @@
1
- /**
2
- * @jsxRuntime classic
3
- * @jsx jsx
4
- */
5
- import { jsx } from '@emotion/react';
6
- import type { AIStateIndicatorProps } from './types';
7
- declare const AIStateIndicator: ({ state, appearance, testId, error, }: AIStateIndicatorProps) => jsx.JSX.Element | null;
8
- export default AIStateIndicator;
@@ -1,21 +0,0 @@
1
- /// <reference types="react" />
2
- import type { XCSS } from '@atlaskit/primitives';
3
- import type { TooltipProps } from '@atlaskit/tooltip';
4
- import type { AISummaryStatus, ErrorMessage } from '../../../../../../state/hooks/use-ai-summary/ai-summary-service/types';
5
- export type AIStateAppearance = 'default' | 'icon-only';
6
- export type AIStateIndicatorProps = {
7
- appearance?: AIStateAppearance;
8
- state: AISummaryStatus;
9
- testId?: string;
10
- error?: ErrorMessage;
11
- };
12
- export type AIIndicatorContainerProps = {
13
- icon?: React.ReactNode;
14
- content?: React.ReactNode;
15
- testId?: string;
16
- };
17
- export type AIIndicatorTooltipProps = {
18
- content: TooltipProps['content'];
19
- trigger: React.ReactNode;
20
- xcss?: XCSS;
21
- };
@@ -1,7 +0,0 @@
1
- /// <reference types="react" />
2
- import { type ActionItem } from '../../../../FlexibleCard/components/blocks/types';
3
- import { type LinkAction } from '../../../../../state/hooks-external/useSmartLinkActions';
4
- import { type HoverCardResolvedProps } from './types';
5
- export declare const toFooterActions: (cardActions: LinkAction[], onActionClick?: ((actionId: string) => void) | undefined) => ActionItem[];
6
- declare const HoverCardResolvedView: ({ flexibleCardProps, titleBlockProps, analytics, cardState, cardActions, isAISummaryEnabled, onActionClick, extensionKey, url, }: HoverCardResolvedProps) => JSX.Element;
7
- export default HoverCardResolvedView;
@@ -1,4 +0,0 @@
1
- /// <reference types="react" />
2
- import { type AIIndicatorContainerProps } from './types';
3
- declare const AIIndicatorContainer: ({ icon, content, testId }: AIIndicatorContainerProps) => JSX.Element;
4
- export default AIIndicatorContainer;
@@ -1,4 +0,0 @@
1
- /// <reference types="react" />
2
- import type { AIIndicatorTooltipProps } from './types';
3
- declare const AIIndicatorTooltip: ({ content, trigger, xcss: overrideXcss }: AIIndicatorTooltipProps) => JSX.Element;
4
- export default AIIndicatorTooltip;
@@ -1,4 +0,0 @@
1
- import { jsx } from '@emotion/react';
2
- import type { AIStateIndicatorProps } from './types';
3
- declare const AIStateDone: ({ appearance, testId }: Partial<AIStateIndicatorProps>) => jsx.JSX.Element;
4
- export default AIStateDone;
@@ -1,4 +0,0 @@
1
- /// <reference types="react" />
2
- import { type AIStateIndicatorProps } from './types';
3
- declare const AIStateError: ({ appearance, testId, error }: Partial<AIStateIndicatorProps>) => JSX.Element | null;
4
- export default AIStateError;
@@ -1,4 +0,0 @@
1
- /// <reference types="react" />
2
- import { type AIStateIndicatorProps } from './types';
3
- declare const AIStateLoading: ({ appearance, testId }: Partial<AIStateIndicatorProps>) => JSX.Element | null;
4
- export default AIStateLoading;
@@ -1,8 +0,0 @@
1
- /**
2
- * @jsxRuntime classic
3
- * @jsx jsx
4
- */
5
- import { jsx } from '@emotion/react';
6
- import type { AIStateIndicatorProps } from './types';
7
- declare const AIStateIndicator: ({ state, appearance, testId, error, }: AIStateIndicatorProps) => jsx.JSX.Element | null;
8
- export default AIStateIndicator;
@@ -1,21 +0,0 @@
1
- /// <reference types="react" />
2
- import type { XCSS } from '@atlaskit/primitives';
3
- import type { TooltipProps } from '@atlaskit/tooltip';
4
- import type { AISummaryStatus, ErrorMessage } from '../../../../../../state/hooks/use-ai-summary/ai-summary-service/types';
5
- export type AIStateAppearance = 'default' | 'icon-only';
6
- export type AIStateIndicatorProps = {
7
- appearance?: AIStateAppearance;
8
- state: AISummaryStatus;
9
- testId?: string;
10
- error?: ErrorMessage;
11
- };
12
- export type AIIndicatorContainerProps = {
13
- icon?: React.ReactNode;
14
- content?: React.ReactNode;
15
- testId?: string;
16
- };
17
- export type AIIndicatorTooltipProps = {
18
- content: TooltipProps['content'];
19
- trigger: React.ReactNode;
20
- xcss?: XCSS;
21
- };
@@ -1,7 +0,0 @@
1
- /// <reference types="react" />
2
- import { type ActionItem } from '../../../../FlexibleCard/components/blocks/types';
3
- import { type LinkAction } from '../../../../../state/hooks-external/useSmartLinkActions';
4
- import { type HoverCardResolvedProps } from './types';
5
- export declare const toFooterActions: (cardActions: LinkAction[], onActionClick?: ((actionId: string) => void) | undefined) => ActionItem[];
6
- declare const HoverCardResolvedView: ({ flexibleCardProps, titleBlockProps, analytics, cardState, cardActions, isAISummaryEnabled, onActionClick, extensionKey, url, }: HoverCardResolvedProps) => JSX.Element;
7
- export default HoverCardResolvedView;