@atlaskit/smart-card 38.5.1 → 38.5.2

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 (109) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/cjs/extractors/flexible/extract-link-title.js +23 -0
  3. package/dist/cjs/extractors/flexible/index.js +13 -5
  4. package/dist/cjs/state/helpers.js +4 -1
  5. package/dist/cjs/state/hooks/useSmartLink.js +6 -2
  6. package/dist/cjs/utils/analytics/analytics.js +1 -1
  7. package/dist/cjs/view/BlockCard/views/ResolvedView.js +24 -15
  8. package/dist/cjs/view/BlockCard/views/unresolved-view/index.js +15 -10
  9. package/dist/cjs/view/BlockCard/views/utils/index.js +10 -2
  10. package/dist/cjs/view/CardWithUrl/component.js +29 -8
  11. package/dist/cjs/view/FlexibleCard/components/blocks/action-block/index.js +2 -2
  12. package/dist/cjs/view/FlexibleCard/components/blocks/ai-footer-block/index.js +17 -3
  13. package/dist/cjs/view/FlexibleCard/components/blocks/ai-summary-block/index.js +16 -4
  14. package/dist/cjs/view/FlexibleCard/components/blocks/footer-block/index.js +17 -3
  15. package/dist/cjs/view/FlexibleCard/components/blocks/metadata-block/index.js +64 -17
  16. package/dist/cjs/view/FlexibleCard/components/blocks/preview-block/index.js +9 -1
  17. package/dist/cjs/view/FlexibleCard/components/blocks/snippet-block/index.js +19 -5
  18. package/dist/cjs/view/FlexibleCard/components/blocks/title-block/index.js +18 -6
  19. package/dist/cjs/view/FlexibleCard/components/container/index.js +12 -2
  20. package/dist/cjs/view/FlexibleCard/components/elements/title-element/index.js +2 -1
  21. package/dist/cjs/view/FlexibleCard/components/elements/utils.js +3 -0
  22. package/dist/cjs/view/FlexibleCard/index.js +5 -2
  23. package/dist/cjs/view/FlexibleCard/utils.js +11 -18
  24. package/dist/cjs/view/HoverCard/components/HoverCardContent.js +2 -1
  25. package/dist/cjs/view/HoverCard/components/views/forbidden/index.js +21 -14
  26. package/dist/cjs/view/HoverCard/components/views/resolved/index.js +22 -14
  27. package/dist/cjs/view/HoverCard/styled.js +13 -1
  28. package/dist/cjs/view/LinkUrl/index.js +1 -1
  29. package/dist/es2019/extractors/flexible/extract-link-title.js +17 -0
  30. package/dist/es2019/extractors/flexible/index.js +9 -1
  31. package/dist/es2019/state/helpers.js +1 -0
  32. package/dist/es2019/state/hooks/useSmartLink.js +6 -2
  33. package/dist/es2019/utils/analytics/analytics.js +1 -1
  34. package/dist/es2019/view/BlockCard/views/ResolvedView.js +25 -16
  35. package/dist/es2019/view/BlockCard/views/unresolved-view/index.js +16 -11
  36. package/dist/es2019/view/BlockCard/views/utils/index.js +9 -1
  37. package/dist/es2019/view/CardWithUrl/component.js +30 -9
  38. package/dist/es2019/view/FlexibleCard/components/blocks/action-block/index.js +2 -2
  39. package/dist/es2019/view/FlexibleCard/components/blocks/ai-footer-block/index.js +17 -3
  40. package/dist/es2019/view/FlexibleCard/components/blocks/ai-summary-block/index.js +17 -5
  41. package/dist/es2019/view/FlexibleCard/components/blocks/footer-block/index.js +17 -3
  42. package/dist/es2019/view/FlexibleCard/components/blocks/metadata-block/index.js +48 -5
  43. package/dist/es2019/view/FlexibleCard/components/blocks/preview-block/index.js +9 -1
  44. package/dist/es2019/view/FlexibleCard/components/blocks/snippet-block/index.js +20 -6
  45. package/dist/es2019/view/FlexibleCard/components/blocks/title-block/index.js +19 -7
  46. package/dist/es2019/view/FlexibleCard/components/container/index.js +10 -2
  47. package/dist/es2019/view/FlexibleCard/components/elements/title-element/index.js +2 -1
  48. package/dist/es2019/view/FlexibleCard/components/elements/utils.js +3 -0
  49. package/dist/es2019/view/FlexibleCard/index.js +5 -2
  50. package/dist/es2019/view/FlexibleCard/utils.js +14 -21
  51. package/dist/es2019/view/HoverCard/components/HoverCardContent.js +3 -2
  52. package/dist/es2019/view/HoverCard/components/views/forbidden/index.js +21 -14
  53. package/dist/es2019/view/HoverCard/components/views/resolved/index.js +22 -14
  54. package/dist/es2019/view/HoverCard/styled.js +12 -0
  55. package/dist/es2019/view/LinkUrl/index.js +1 -1
  56. package/dist/esm/extractors/flexible/extract-link-title.js +17 -0
  57. package/dist/esm/extractors/flexible/index.js +13 -5
  58. package/dist/esm/state/helpers.js +3 -0
  59. package/dist/esm/state/hooks/useSmartLink.js +6 -2
  60. package/dist/esm/utils/analytics/analytics.js +1 -1
  61. package/dist/esm/view/BlockCard/views/ResolvedView.js +25 -16
  62. package/dist/esm/view/BlockCard/views/unresolved-view/index.js +16 -11
  63. package/dist/esm/view/BlockCard/views/utils/index.js +9 -1
  64. package/dist/esm/view/CardWithUrl/component.js +30 -9
  65. package/dist/esm/view/FlexibleCard/components/blocks/action-block/index.js +2 -2
  66. package/dist/esm/view/FlexibleCard/components/blocks/ai-footer-block/index.js +17 -3
  67. package/dist/esm/view/FlexibleCard/components/blocks/ai-summary-block/index.js +17 -5
  68. package/dist/esm/view/FlexibleCard/components/blocks/footer-block/index.js +17 -3
  69. package/dist/esm/view/FlexibleCard/components/blocks/metadata-block/index.js +64 -17
  70. package/dist/esm/view/FlexibleCard/components/blocks/preview-block/index.js +9 -1
  71. package/dist/esm/view/FlexibleCard/components/blocks/snippet-block/index.js +20 -6
  72. package/dist/esm/view/FlexibleCard/components/blocks/title-block/index.js +18 -6
  73. package/dist/esm/view/FlexibleCard/components/container/index.js +12 -2
  74. package/dist/esm/view/FlexibleCard/components/elements/title-element/index.js +2 -1
  75. package/dist/esm/view/FlexibleCard/components/elements/utils.js +3 -0
  76. package/dist/esm/view/FlexibleCard/index.js +5 -2
  77. package/dist/esm/view/FlexibleCard/utils.js +12 -19
  78. package/dist/esm/view/HoverCard/components/HoverCardContent.js +3 -2
  79. package/dist/esm/view/HoverCard/components/views/forbidden/index.js +21 -14
  80. package/dist/esm/view/HoverCard/components/views/resolved/index.js +22 -14
  81. package/dist/esm/view/HoverCard/styled.js +12 -0
  82. package/dist/esm/view/LinkUrl/index.js +1 -1
  83. package/dist/types/extractors/flexible/extract-link-title.d.ts +4 -0
  84. package/dist/types/extractors/flexible/index.d.ts +1 -1
  85. package/dist/types/state/flexible-ui-context/types.d.ts +11 -0
  86. package/dist/types/state/helpers.d.ts +1 -0
  87. package/dist/types/state/hooks/useSmartLink.d.ts +2 -0
  88. package/dist/types/utils/analytics/types.d.ts +1 -1
  89. package/dist/types/view/BlockCard/views/utils/index.d.ts +4 -0
  90. package/dist/types/view/FlexibleCard/components/blocks/title-block/index.d.ts +1 -1
  91. package/dist/types/view/FlexibleCard/components/blocks/title-block/types.d.ts +2 -0
  92. package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +1 -0
  93. package/dist/types/view/FlexibleCard/components/elements/common/base-icon-element/index.d.ts +1 -1
  94. package/dist/types/view/FlexibleCard/types.d.ts +1 -1
  95. package/dist/types/view/HoverCard/styled.d.ts +4 -0
  96. package/dist/types-ts4.5/extractors/flexible/extract-link-title.d.ts +4 -0
  97. package/dist/types-ts4.5/extractors/flexible/index.d.ts +1 -1
  98. package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +11 -0
  99. package/dist/types-ts4.5/state/helpers.d.ts +1 -0
  100. package/dist/types-ts4.5/state/hooks/useSmartLink.d.ts +2 -0
  101. package/dist/types-ts4.5/utils/analytics/types.d.ts +1 -1
  102. package/dist/types-ts4.5/view/BlockCard/views/utils/index.d.ts +4 -0
  103. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/title-block/index.d.ts +1 -1
  104. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/title-block/types.d.ts +2 -0
  105. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/types.d.ts +1 -0
  106. package/dist/types-ts4.5/view/FlexibleCard/components/elements/common/base-icon-element/index.d.ts +1 -1
  107. package/dist/types-ts4.5/view/FlexibleCard/types.d.ts +1 -1
  108. package/dist/types-ts4.5/view/HoverCard/styled.d.ts +4 -0
  109. package/package.json +7 -4
@@ -9,7 +9,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
9
9
  import { ActionName, ElementName, SmartLinkPosition, SmartLinkStatus } from '../../../constants';
10
10
  import FlexibleCard from '../../FlexibleCard';
11
11
  import { FooterBlock, MetadataBlock, PreviewBlock, SnippetBlock, TitleBlock } from '../../FlexibleCard/components/blocks';
12
- import { FlexibleCardUiOptions, getSimulatedBetterMetadata, PreviewBlockOptions, titleBlockOptions } from './utils';
12
+ import { FlexibleCardUiOptions, FlexibleCardUiOptionsOld, getSimulatedBetterMetadata, PreviewBlockOptions, titleBlockOptions } from './utils';
13
13
  import { withFlexibleUIBlockCardStyle } from './utils/withFlexibleUIBlockCardStyle';
14
14
  const titleBlockCssOld = null;
15
15
  const titleBlockCss = null;
@@ -66,35 +66,44 @@ const ResolvedView = ({
66
66
  origin: "smartLinkCard",
67
67
  actionOptions: actionOptions,
68
68
  testId: testId,
69
- ui: FlexibleCardUiOptions,
69
+ ui: fg('platform-linking-flexible-card-context') ? FlexibleCardUiOptions : FlexibleCardUiOptionsOld,
70
70
  url: url
71
71
  }, /*#__PURE__*/React.createElement(TitleBlock, _extends({}, titleBlockOptions, {
72
72
  metadata: titleMetadata,
73
73
  subtitle: [{
74
74
  name: ElementName.Location
75
75
  }],
76
- metadataPosition: SmartLinkPosition.Top,
77
- status: status,
76
+ metadataPosition: SmartLinkPosition.Top
77
+ }, fg('platform-linking-flexible-card-context') ? undefined : {
78
+ status
79
+ }, {
78
80
  className: ax([fg('platform-linking-visual-refresh-v1') ? "_zulpu2gc _13mh1pd9 _2yhz14q2" : "_zulpcxkx _13mh1pd9"])
79
- })), /*#__PURE__*/React.createElement(MetadataBlock, {
81
+ })), /*#__PURE__*/React.createElement(MetadataBlock, _extends({
80
82
  primary: topMetadata,
81
- maxLines: 1,
82
- status: SmartLinkStatus.Resolved,
83
+ maxLines: 1
84
+ }, fg('platform-linking-flexible-card-context') ? undefined : {
85
+ status: SmartLinkStatus.Resolved
86
+ }, {
83
87
  className: ax([!fg('platform-linking-visual-refresh-v1') && "_wwyvidpf _1sxbcxkx _i8d01j6v"])
84
- }), /*#__PURE__*/React.createElement(SnippetBlock, null), /*#__PURE__*/React.createElement(MetadataBlock, {
88
+ })), /*#__PURE__*/React.createElement(SnippetBlock, null), /*#__PURE__*/React.createElement(MetadataBlock, _extends({
85
89
  primary: bottomMetadata,
86
- maxLines: 1,
87
- status: SmartLinkStatus.Resolved,
90
+ maxLines: 1
91
+ }, fg('platform-linking-flexible-card-context') ? undefined : {
92
+ status: SmartLinkStatus.Resolved
93
+ }, {
88
94
  className: ax([!fg('platform-linking-visual-refresh-v1') && "_wwyvidpf _1sxbcxkx _i8d01j6v"])
89
- }), !isPreviewBlockErrored ? /*#__PURE__*/React.createElement(PreviewBlock, _extends({}, PreviewBlockOptions, {
95
+ })), !isPreviewBlockErrored ? /*#__PURE__*/React.createElement(PreviewBlock, _extends({}, PreviewBlockOptions, {
90
96
  onError: () => {
91
97
  setIsPreviewBlockErrored(true);
92
- },
98
+ }
99
+ }, fg('platform-linking-flexible-card-context') ? undefined : {
100
+ status: SmartLinkStatus.Resolved
101
+ })) : null, /*#__PURE__*/React.createElement(FooterBlock, _extends({
102
+ actions: footerActions
103
+ }, fg('platform-linking-flexible-card-context') ? undefined : {
93
104
  status: SmartLinkStatus.Resolved
94
- })) : null, /*#__PURE__*/React.createElement(FooterBlock, {
95
- actions: footerActions,
96
- status: SmartLinkStatus.Resolved,
105
+ }, {
97
106
  className: ax([fg('platform-linking-visual-refresh-v1') ? "_4t3i1k8s _1e0c1txw _1bah1yb4 _4cvresu3 _1wpz1fhb" : "_4t3i1k8s _g0eioxwj _1qryoxwj _sxbroxwj _1gyioxwj", safari && fg('platform-linking-visual-refresh-v2') && "_4t3i1osq"])
98
- }));
107
+ })));
99
108
  };
100
109
  export default withFlexibleUIBlockCardStyle(ResolvedView);
@@ -8,7 +8,7 @@ import { browser } from '@atlaskit/linking-common/user-agent';
8
8
  import { fg } from '@atlaskit/platform-feature-flags';
9
9
  import FlexibleCard from '../../../FlexibleCard';
10
10
  import { CustomBlock, InternalFooterBlock, PreviewBlock, TitleBlock } from '../../../FlexibleCard/components/blocks';
11
- import { FlexibleCardUiOptions, PreviewBlockOptions, titleBlockOptions } from '../utils';
11
+ import { FlexibleCardUiOptions, FlexibleCardUiOptionsOld, PreviewBlockOptions, titleBlockOptions } from '../utils';
12
12
  const customBlockStylesOld = null;
13
13
  const customBlockStyles = null;
14
14
  const titleBlockCssOld = null;
@@ -41,23 +41,28 @@ const UnresolvedView = ({
41
41
  onError: onError,
42
42
  origin: "smartLinkCard",
43
43
  testId: testId,
44
- ui: FlexibleCardUiOptions,
44
+ ui: fg('platform-linking-flexible-card-context') ? FlexibleCardUiOptions : FlexibleCardUiOptionsOld,
45
45
  url: url
46
46
  }, /*#__PURE__*/React.createElement(TitleBlock, _extends({}, titleBlockOptions, {
47
47
  hideIcon: !!title,
48
- text: title,
49
- status: cardState.status,
48
+ text: title
49
+ }, fg('platform-linking-flexible-card-context') ? undefined : {
50
+ status: cardState.status
51
+ }, {
50
52
  className: ax([fg('platform-linking-visual-refresh-v1') ? "_zulpu2gc _13mh1pd9 _2yhz14q2" : "_zulp1f3t _13mh1pd9"])
51
- })), /*#__PURE__*/React.createElement(CustomBlock, {
52
- status: cardState.status,
53
+ })), /*#__PURE__*/React.createElement(CustomBlock, _extends({}, fg('platform-linking-flexible-card-context') ? undefined : {
54
+ status: cardState.status
55
+ }, {
53
56
  className: ax([fg('platform-linking-visual-refresh-v1') ? "_zulp1b66 _1e0c1txw _4cvr1y6m _1wpz1fhb _7yjtidpf _ngc01fxt" : "_4cvr1y6m"])
54
- }, children), showPreview && /*#__PURE__*/React.createElement(PreviewBlock, _extends({}, PreviewBlockOptions, {
57
+ }), children), showPreview && /*#__PURE__*/React.createElement(PreviewBlock, _extends({}, PreviewBlockOptions, fg('platform-linking-flexible-card-context') ? undefined : {
55
58
  status: cardState.status
56
- })), /*#__PURE__*/React.createElement(InternalFooterBlock, {
59
+ })), /*#__PURE__*/React.createElement(InternalFooterBlock, _extends({
57
60
  actions: actions,
58
- testId: "smart-block-card-footer",
59
- status: cardState.status,
61
+ testId: "smart-block-card-footer"
62
+ }, fg('platform-linking-flexible-card-context') ? undefined : {
63
+ status: cardState.status
64
+ }, {
60
65
  className: ax([fg('platform-linking-visual-refresh-v1') ? "_4t3i1k8s _1e0c1txw _1bah1yb4 _4cvresu3 _1wpz1fhb" : "_4t3i1k8s _g0eioxwj _1qryoxwj _sxbroxwj _1gyioxwj", safari && fg('platform-linking-visual-refresh-v2') && "_4t3i1osq"])
61
- }));
66
+ })));
62
67
  };
63
68
  export default UnresolvedView;
@@ -152,10 +152,18 @@ export const getSimulatedBetterMetadata = cardDetails => {
152
152
  };
153
153
  }
154
154
  };
155
- export const FlexibleCardUiOptions = {
155
+ /**
156
+ * @deprecated Remove on platform-linking-flexible-card-context cleanup
157
+ */
158
+ export const FlexibleCardUiOptionsOld = {
156
159
  hideElevation: true,
157
160
  hideLegacyButton: true
158
161
  };
162
+ export const FlexibleCardUiOptions = {
163
+ hideElevation: true,
164
+ hideLegacyButton: true,
165
+ removeBlockRestriction: true
166
+ };
159
167
  export const titleBlockOptions = {
160
168
  anchorTarget: '_self',
161
169
  position: SmartLinkPosition.Center,
@@ -5,7 +5,7 @@ import { useAnalyticsEvents } from '../../common/analytics/generated/use-analyti
5
5
  import { CardDisplay } from '../../constants';
6
6
  import { useSmartLink } from '../../state';
7
7
  import { succeedUfoExperience } from '../../state/analytics';
8
- import { getClickUrl, getDefinitionId, getExtensionKey, getResourceType, getServices, isFinalState } from '../../state/helpers';
8
+ import { getClickUrl, getDefinitionId, getExtensionKey, getObjectAri, getResourceType, getServices, isFinalState } from '../../state/helpers';
9
9
  import { SmartLinkModalProvider } from '../../state/modal';
10
10
  import { isSpecialEvent } from '../../utils';
11
11
  import { combineActionOptions } from '../../utils/actions/combine-action-options';
@@ -55,8 +55,11 @@ function Component({
55
55
  actions,
56
56
  config,
57
57
  renderers,
58
- error
58
+ error,
59
+ isGlancePanelAvailable,
60
+ openGlancePanel
59
61
  } = useSmartLink(id, url);
62
+ const ari = fg('fun-1765_wire_up_glance_panel_to_smart_cards') ? getObjectAri(state.details) : undefined;
60
63
  const definitionId = getDefinitionId(state.details);
61
64
  const extensionKey = getExtensionKey(state.details);
62
65
  const resourceType = getResourceType(state.details);
@@ -70,19 +73,37 @@ function Component({
70
73
  // Setup UI handlers.
71
74
  const handleClickWrapper = useCallback(event => {
72
75
  const isModifierKeyPressed = isSpecialEvent(event);
76
+ // Ctrl+left click on mac typically doesn't trigger onClick
77
+ // The event could have potentially had `e.preventDefault()` called on it by now
78
+ // event by smart card internally
79
+ // If it has been called then only then can `isModifierKeyPressed` be true.
80
+ const target = isModifierKeyPressed ? '_blank' : '_self';
73
81
  fireEvent('ui.smartLink.clicked', {
74
82
  id,
75
83
  display: isFlexibleUi ? CardDisplay.Flexible : appearance,
76
84
  definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
77
85
  isModifierKeyPressed
78
86
  });
79
- if (!onClick && !isFlexibleUi) {
87
+
88
+ // If glance panel is available and the user clicked on the link,
89
+ // delegate the click to the glance panel handler
90
+ if (
91
+ // eslint-disable-next-line @atlaskit/platform/no-preconditioning
92
+ fg('fun-1765_wire_up_glance_panel_to_smart_cards') && target !== '_blank' && ari && isGlancePanelAvailable !== null && isGlancePanelAvailable !== void 0 && isGlancePanelAvailable({
93
+ url,
94
+ ari
95
+ }) && openGlancePanel) {
96
+ openGlancePanel({
97
+ url,
98
+ ari
99
+ });
100
+ fireLinkClickedEvent(createAnalyticsEvent)(event, {
101
+ attributes: {
102
+ clickOutcome: 'glancePanel'
103
+ }
104
+ });
105
+ } else if (!onClick && !isFlexibleUi) {
80
106
  const clickUrl = getClickUrl(url, state.details);
81
- // Ctrl+left click on mac typically doesn't trigger onClick
82
- // The event could have potentially had `e.preventDefault()` called on it by now
83
- // event by smart card internally
84
- // If it has been called then only then can `isModifierKeyPressed` be true.
85
- const target = isModifierKeyPressed ? '_blank' : '_self';
86
107
  window.open(clickUrl, target);
87
108
  fireLinkClickedEvent(createAnalyticsEvent)(event, {
88
109
  attributes: {
@@ -95,7 +116,7 @@ function Component({
95
116
  }
96
117
  fireLinkClickedEvent(createAnalyticsEvent)(event);
97
118
  }
98
- }, [id, url, state.details, appearance, definitionId, onClick, isFlexibleUi, createAnalyticsEvent, fireEvent]);
119
+ }, [fireEvent, id, isFlexibleUi, appearance, definitionId, onClick, url, state.details, ari, isGlancePanelAvailable, openGlancePanel, createAnalyticsEvent]);
99
120
  const handleAuthorize = useCallback(() => actions.authorize(appearance), [actions, appearance]);
100
121
  const handleRetry = useCallback(() => {
101
122
  actions.reload();
@@ -80,7 +80,7 @@ const ActionBlock = ({
80
80
  onClick: () => onClick(name),
81
81
  onError: onError,
82
82
  onLoadingChange: onLoadingChange,
83
- size: size
83
+ size: fg('platform-linking-flexible-card-context') ? size || (ui === null || ui === void 0 ? void 0 : ui.size) : size
84
84
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop, @atlaskit/design-system/no-unsafe-design-token-usage
85
85
  ,
86
86
  style: padding && {
@@ -89,7 +89,7 @@ const ActionBlock = ({
89
89
  hideTooltip: isLoading
90
90
  }) : null;
91
91
  });
92
- }, [context === null || context === void 0 ? void 0 : context.actions, onClick, onError, padding, size, spaceInline, isLoading, onLoadingChange]);
92
+ }, [context === null || context === void 0 ? void 0 : context.actions, spaceInline, onError, onLoadingChange, size, ui === null || ui === void 0 ? void 0 : ui.size, padding, isLoading, onClick]);
93
93
  return actions ? /*#__PURE__*/React.createElement("div", {
94
94
  ref: blockRef,
95
95
  "data-testid": testId
@@ -1,6 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React from 'react';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  import { SmartLinkStatus } from '../../../../../constants';
5
+ import { useFlexibleCardContext } from '../../../../../state/flexible-ui-context';
4
6
  import AIFooterBlockResolvedView from './resolved';
5
7
  /**
6
8
  * Represents a AIFooterBlock, designed to show provider metadata in
@@ -13,10 +15,22 @@ const AIFooterBlock = ({
13
15
  testId = 'smart-ai-footer-block',
14
16
  ...props
15
17
  }) => {
16
- if (status !== SmartLinkStatus.Resolved) {
17
- return null;
18
+ var _props$size, _cardContext$ui;
19
+ const cardContext = fg('platform-linking-flexible-card-context') ?
20
+ // eslint-disable-next-line react-hooks/rules-of-hooks
21
+ useFlexibleCardContext() : undefined;
22
+ if (fg('platform-linking-flexible-card-context')) {
23
+ if ((cardContext === null || cardContext === void 0 ? void 0 : cardContext.status) !== SmartLinkStatus.Resolved) {
24
+ return null;
25
+ }
26
+ } else {
27
+ if (status !== SmartLinkStatus.Resolved) {
28
+ return null;
29
+ }
18
30
  }
19
- return /*#__PURE__*/React.createElement(AIFooterBlockResolvedView, _extends({}, props, {
31
+ return /*#__PURE__*/React.createElement(AIFooterBlockResolvedView, _extends({}, props, fg('platform-linking-flexible-card-context') ? {
32
+ size: (_props$size = props.size) !== null && _props$size !== void 0 ? _props$size : cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$ui = cardContext.ui) === null || _cardContext$ui === void 0 ? void 0 : _cardContext$ui.size
33
+ } : undefined, {
20
34
  testId: testId
21
35
  }));
22
36
  };
@@ -1,7 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React from 'react';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  import { InternalActionName, SmartLinkStatus } from '../../../../../constants';
4
- import { useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
5
+ import { useFlexibleCardContext, useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
5
6
  import AISummaryBlockResolvedView from './resolved';
6
7
  /**
7
8
  * Represents an AISummaryBlock, designed to summarising link resource
@@ -15,16 +16,27 @@ const AISummaryBlock = ({
15
16
  testId = 'smart-ai-summary-block',
16
17
  ...props
17
18
  }) => {
18
- var _context$actions;
19
+ var _context$actions, _props$size, _cardContext$ui;
20
+ const cardContext = fg('platform-linking-flexible-card-context') ?
21
+ // eslint-disable-next-line react-hooks/rules-of-hooks
22
+ useFlexibleCardContext() : undefined;
19
23
  const context = useFlexibleUiContext();
20
24
  const actionData = context === null || context === void 0 ? void 0 : (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[InternalActionName.AISummaryAction];
21
- if (status !== SmartLinkStatus.Resolved) {
22
- return null;
25
+ if (fg('platform-linking-flexible-card-context')) {
26
+ if ((cardContext === null || cardContext === void 0 ? void 0 : cardContext.status) !== SmartLinkStatus.Resolved) {
27
+ return null;
28
+ }
29
+ } else {
30
+ if (status !== SmartLinkStatus.Resolved) {
31
+ return null;
32
+ }
23
33
  }
24
34
  if (!(actionData !== null && actionData !== void 0 && actionData.url)) {
25
35
  return null;
26
36
  }
27
- return /*#__PURE__*/React.createElement(AISummaryBlockResolvedView, _extends({}, props, {
37
+ return /*#__PURE__*/React.createElement(AISummaryBlockResolvedView, _extends({}, props, fg('platform-linking-flexible-card-context') ? {
38
+ size: (_props$size = props.size) !== null && _props$size !== void 0 ? _props$size : cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$ui = cardContext.ui) === null || _cardContext$ui === void 0 ? void 0 : _cardContext$ui.size
39
+ } : undefined, {
28
40
  testId: testId,
29
41
  url: actionData.url
30
42
  }));
@@ -1,6 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React from 'react';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  import { SmartLinkStatus } from '../../../../../constants';
5
+ import { useFlexibleCardContext } from '../../../../../state/flexible-ui-context';
4
6
  import FooterBlockResolvedView from './resolved';
5
7
  /**
6
8
  * Represents a FooterBlock, designed to contain elements and actions that should appear
@@ -15,10 +17,22 @@ const FooterBlock = ({
15
17
  alwaysShow,
16
18
  ...props
17
19
  }) => {
18
- if (status !== SmartLinkStatus.Resolved && !alwaysShow) {
19
- return null;
20
+ var _props$size, _cardContext$ui;
21
+ const cardContext = fg('platform-linking-flexible-card-context') ?
22
+ // eslint-disable-next-line react-hooks/rules-of-hooks
23
+ useFlexibleCardContext() : undefined;
24
+ if (fg('platform-linking-flexible-card-context')) {
25
+ if ((cardContext === null || cardContext === void 0 ? void 0 : cardContext.status) !== SmartLinkStatus.Resolved && !alwaysShow) {
26
+ return null;
27
+ }
28
+ } else {
29
+ if (status !== SmartLinkStatus.Resolved && !alwaysShow) {
30
+ return null;
31
+ }
20
32
  }
21
- return /*#__PURE__*/React.createElement(FooterBlockResolvedView, _extends({}, props, {
33
+ return /*#__PURE__*/React.createElement(FooterBlockResolvedView, _extends({}, props, fg('platform-linking-flexible-card-context') ? {
34
+ size: (_props$size = props.size) !== null && _props$size !== void 0 ? _props$size : cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$ui = cardContext.ui) === null || _cardContext$ui === void 0 ? void 0 : _cardContext$ui.size
35
+ } : undefined, {
22
36
  testId: testId
23
37
  }));
24
38
  };
@@ -7,6 +7,7 @@ import { ax, ix } from "@compiled/react/runtime";
7
7
 
8
8
  import { fg } from '@atlaskit/platform-feature-flags';
9
9
  import { SmartLinkAlignment, SmartLinkDirection, SmartLinkSize, SmartLinkStatus, SmartLinkWidth } from '../../../../../constants';
10
+ import { useFlexibleCardContext } from '../../../../../state/flexible-ui-context';
10
11
  import Block from '../block';
11
12
  import ElementGroup from '../element-group';
12
13
  import { renderElementItems } from '../utils';
@@ -38,6 +39,22 @@ const getMaxLines = maxLines => {
38
39
  }
39
40
  return maxLines;
40
41
  };
42
+ const ElementItemRenderer = ({
43
+ align = SmartLinkAlignment.Left,
44
+ items = [],
45
+ display = 'inline',
46
+ size = SmartLinkSize.Medium,
47
+ maxLines = DEFAULT_MAX_LINES
48
+ }) => {
49
+ const elements = renderElementItems(items, display);
50
+ return elements && /*#__PURE__*/React.createElement(ElementGroup, {
51
+ align: align,
52
+ direction: SmartLinkDirection.Horizontal,
53
+ width: SmartLinkWidth.Flexible,
54
+ size: size,
55
+ className: ax([truncateStyles[maxLines], !fg('platform-linking-visual-refresh-v1') && sizeStylesOld[size], fg('platform-linking-visual-refresh-v1') && sizeStyles[size]])
56
+ }, elements);
57
+ };
41
58
 
42
59
  /**
43
60
  * Represents a MetadataBlock, designed to contain groups of metadata in the form of elements.
@@ -54,15 +71,41 @@ const MetadataBlock = ({
54
71
  secondary = [],
55
72
  ...blockProps
56
73
  }) => {
57
- if (primary.length === 0 && secondary.length === 0 || status !== SmartLinkStatus.Resolved) {
58
- return null;
74
+ var _ref, _blockProps$size, _cardContext$ui;
75
+ const cardContext = fg('platform-linking-flexible-card-context') ?
76
+ // eslint-disable-next-line react-hooks/rules-of-hooks
77
+ useFlexibleCardContext() : undefined;
78
+ if (fg('platform-linking-flexible-card-context')) {
79
+ if (primary.length === 0 && secondary.length === 0 || (cardContext === null || cardContext === void 0 ? void 0 : cardContext.status) !== SmartLinkStatus.Resolved) {
80
+ return null;
81
+ }
82
+ } else {
83
+ if (primary.length === 0 && secondary.length === 0 || status !== SmartLinkStatus.Resolved) {
84
+ return null;
85
+ }
59
86
  }
60
- const primaryElements = renderElementItems(primary);
61
- const secondaryElements = renderElementItems(secondary);
62
87
  const {
63
- size = SmartLinkSize.Medium
88
+ size: sizeProp = SmartLinkSize.Medium
64
89
  } = blockProps;
90
+ const size = fg('platform-linking-flexible-card-context') ? (_ref = (_blockProps$size = blockProps === null || blockProps === void 0 ? void 0 : blockProps.size) !== null && _blockProps$size !== void 0 ? _blockProps$size : cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$ui = cardContext.ui) === null || _cardContext$ui === void 0 ? void 0 : _cardContext$ui.size) !== null && _ref !== void 0 ? _ref : SmartLinkSize.Medium : sizeProp;
65
91
  const maxLinesTotal = getMaxLines(maxLines);
92
+ if (fg('platform-linking-flexible-card-context')) {
93
+ return /*#__PURE__*/React.createElement(Block, _extends({}, blockProps, {
94
+ size: size,
95
+ testId: `${testId}-resolved-view`
96
+ }), /*#__PURE__*/React.createElement(ElementItemRenderer, {
97
+ items: primary,
98
+ size: size,
99
+ maxLines: maxLinesTotal
100
+ }), /*#__PURE__*/React.createElement(ElementItemRenderer, {
101
+ align: SmartLinkAlignment.Right,
102
+ items: secondary,
103
+ size: size,
104
+ maxLines: maxLinesTotal
105
+ }));
106
+ }
107
+ const primaryElements = renderElementItems(primary);
108
+ const secondaryElements = renderElementItems(secondary);
66
109
  return /*#__PURE__*/React.createElement(Block, _extends({}, blockProps, {
67
110
  testId: `${testId}-resolved-view`
68
111
  }), primaryElements && /*#__PURE__*/React.createElement(ElementGroup, {
@@ -1,6 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React from 'react';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  import { SmartLinkStatus } from '../../../../../constants';
5
+ import { useFlexibleUiOptionContext } from '../../../../../state/flexible-ui-context';
4
6
  import PreviewBlockResolvedView from './resolved';
5
7
  /**
6
8
  * Represents a PreviewBlock, which typically contains media or other large format content.
@@ -15,7 +17,13 @@ const PreviewBlock = ({
15
17
  overrideUrl,
16
18
  ...blockProps
17
19
  }) => {
18
- return /*#__PURE__*/React.createElement(PreviewBlockResolvedView, _extends({}, blockProps, {
20
+ var _blockProps$size;
21
+ const ui = fg('platform-linking-flexible-card-context') ?
22
+ // eslint-disable-next-line react-hooks/rules-of-hooks
23
+ useFlexibleUiOptionContext() : undefined;
24
+ return /*#__PURE__*/React.createElement(PreviewBlockResolvedView, _extends({}, blockProps, fg('platform-linking-flexible-card-context') ? {
25
+ size: (_blockProps$size = blockProps.size) !== null && _blockProps$size !== void 0 ? _blockProps$size : ui === null || ui === void 0 ? void 0 : ui.size
26
+ } : undefined, {
19
27
  testId: testId,
20
28
  overrideUrl: overrideUrl
21
29
  }));
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import React from 'react';
3
3
  import { fg } from '@atlaskit/platform-feature-flags';
4
4
  import { SmartLinkStatus } from '../../../../../constants';
5
- import { useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
5
+ import { useFlexibleCardContext, useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
6
6
  import { useSmartLinkRenderers } from '../../../../../state/renderers';
7
7
  import { Snippet } from '../../elements';
8
8
  import { getMaxLines } from '../../utils';
@@ -24,15 +24,24 @@ const SnippetBlock = ({
24
24
  text,
25
25
  ...blockProps
26
26
  }) => {
27
- var _ref, _context$meta$objectI, _context$meta, _context$meta$resourc, _context$meta2, _context$meta$tenantI, _context$meta3;
27
+ var _blockProps$size2, _cardContext$ui2, _ref, _context$meta$objectI, _context$meta, _context$meta$resourc, _context$meta2, _context$meta$tenantI, _context$meta3;
28
28
  const context = fg('cc-ai-linking-platform-snippet-renderer') ?
29
29
  // eslint-disable-next-line react-hooks/rules-of-hooks
30
30
  useFlexibleUiContext() : undefined;
31
31
  const renderers = fg('cc-ai-linking-platform-snippet-renderer') ?
32
32
  // eslint-disable-next-line react-hooks/rules-of-hooks
33
33
  useSmartLinkRenderers() : undefined;
34
- if (status !== SmartLinkStatus.Resolved && !text) {
35
- return null;
34
+ const cardContext = fg('platform-linking-flexible-card-context') ?
35
+ // eslint-disable-next-line react-hooks/rules-of-hooks
36
+ useFlexibleCardContext() : undefined;
37
+ if (fg('platform-linking-flexible-card-context')) {
38
+ if ((cardContext === null || cardContext === void 0 ? void 0 : cardContext.status) !== SmartLinkStatus.Resolved && !text) {
39
+ return null;
40
+ }
41
+ } else {
42
+ if (status !== SmartLinkStatus.Resolved && !text) {
43
+ return null;
44
+ }
36
45
  }
37
46
  const snippetMaxLines = getMaxLines(maxLines, DEFAULT_MAX_LINES, MAXIMUM_MAX_LINES, MINIMUM_MAX_LINES);
38
47
  const statusTestId = !text ? 'resolved' : 'non-resolved';
@@ -41,12 +50,17 @@ const SnippetBlock = ({
41
50
  content: text
42
51
  });
43
52
  if (!fg('cc-ai-linking-platform-snippet-renderer')) {
44
- return /*#__PURE__*/React.createElement(Block, _extends({}, blockProps, {
53
+ var _blockProps$size, _cardContext$ui;
54
+ return /*#__PURE__*/React.createElement(Block, _extends({}, blockProps, fg('platform-linking-flexible-card-context') ? {
55
+ size: (_blockProps$size = blockProps.size) !== null && _blockProps$size !== void 0 ? _blockProps$size : cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$ui = cardContext.ui) === null || _cardContext$ui === void 0 ? void 0 : _cardContext$ui.size
56
+ } : undefined, {
45
57
  testId: `${testId}-${statusTestId}-view`
46
58
  }), snippet);
47
59
  }
48
60
  const SnippetReplacement = renderers === null || renderers === void 0 ? void 0 : renderers.snippet;
49
- return /*#__PURE__*/React.createElement(Block, _extends({}, blockProps, {
61
+ return /*#__PURE__*/React.createElement(Block, _extends({}, blockProps, fg('platform-linking-flexible-card-context') ? {
62
+ size: (_blockProps$size2 = blockProps.size) !== null && _blockProps$size2 !== void 0 ? _blockProps$size2 : cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$ui2 = cardContext.ui) === null || _cardContext$ui2 === void 0 ? void 0 : _cardContext$ui2.size
63
+ } : undefined, {
50
64
  testId: `${testId}-${statusTestId}-view`
51
65
  }), SnippetReplacement ? /*#__PURE__*/React.createElement(SnippetReplacement, {
52
66
  fallbackText: (_ref = text || (context === null || context === void 0 ? void 0 : context.snippet)) !== null && _ref !== void 0 ? _ref : '',
@@ -7,6 +7,7 @@ import { useCallback, useState } from 'react';
7
7
  import { fg } from '@atlaskit/platform-feature-flags';
8
8
  import { SmartLinkStatus } from '../../../../../constants';
9
9
  import { useMouseDownEvent } from '../../../../../state/analytics/useLinkClicked';
10
+ import { useFlexibleCardContext } from '../../../../../state/flexible-ui-context';
10
11
  import { Title } from '../../elements';
11
12
  import ActionGroup from '../action-group';
12
13
  import TitleBlockErroredView from './errored';
@@ -49,7 +50,7 @@ const TitleBlock = ({
49
50
  maxLines,
50
51
  onActionMenuOpenChange,
51
52
  onClick,
52
- status = SmartLinkStatus.Fallback,
53
+ status: statusProp = SmartLinkStatus.Fallback,
53
54
  showActionOnHover,
54
55
  testId = 'smart-block-title',
55
56
  text,
@@ -62,6 +63,14 @@ const TitleBlock = ({
62
63
  anchorRef,
63
64
  ...props
64
65
  }) => {
66
+ var _props$size;
67
+ const cardContext = fg('platform-linking-flexible-card-context') ?
68
+ // eslint-disable-next-line react-hooks/rules-of-hooks
69
+ useFlexibleCardContext() : undefined;
70
+ const {
71
+ status = SmartLinkStatus.Fallback,
72
+ ui
73
+ } = cardContext || {};
65
74
  if (!fg('platform-linking-flexible-card-unresolved-action')) {
66
75
  if (hideRetry && props.retry) {
67
76
  delete props.retry;
@@ -87,14 +96,16 @@ const TitleBlock = ({
87
96
  const onMouseDown = useMouseDownEvent();
88
97
  const title = /*#__PURE__*/React.createElement(Title, _extends({
89
98
  hideTooltip: hideTitleTooltip,
90
- maxLines: maxLines,
91
- onClick: onClick,
99
+ maxLines: maxLines
100
+ }, fg('platform-linking-flexible-card-context') ? undefined : {
101
+ onClick
102
+ }, {
92
103
  onMouseDown: onMouseDown,
93
104
  target: anchorTarget,
94
- theme: theme,
105
+ theme: fg('platform-linking-flexible-card-context') ? ui === null || ui === void 0 ? void 0 : ui.theme : theme,
95
106
  anchorRef: anchorRef
96
107
  }, overrideText));
97
- const Component = getTitleBlockViewComponent(status);
108
+ const Component = getTitleBlockViewComponent(fg('platform-linking-flexible-card-context') ? status : statusProp);
98
109
  return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
99
110
  actionGroup: actionGroup
100
111
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
@@ -108,8 +119,9 @@ const TitleBlock = ({
108
119
  hideRetry
109
120
  } : undefined, {
110
121
  icon: icon,
111
- size: props.size,
112
- theme: theme
122
+ size: fg('platform-linking-flexible-card-context') ? (_props$size = props.size) !== null && _props$size !== void 0 ? _props$size : ui === null || ui === void 0 ? void 0 : ui.size : props === null || props === void 0 ? void 0 : props.size
123
+ }, fg('platform-linking-flexible-card-context') ? undefined : {
124
+ theme
113
125
  }));
114
126
  };
115
127
  export default TitleBlock;
@@ -35,6 +35,14 @@ export const getChildrenOptions = (children, context) => {
35
35
  }
36
36
  return options;
37
37
  };
38
+ const filterChildren = (children, removeBlockRestriction) => {
39
+ if (fg('platform-linking-flexible-card-openness')) {
40
+ if (removeBlockRestriction) {
41
+ return children;
42
+ }
43
+ }
44
+ return React.Children.map(children, child => /*#__PURE__*/React.isValidElement(child) && isFlexibleUiBlock(child) ? child : undefined);
45
+ };
38
46
  const renderChildren = (children, containerSize, containerTheme, status, retry, onClick, removeBlockRestriction) => {
39
47
  return React.Children.map(children, child => {
40
48
  if ( /*#__PURE__*/React.isValidElement(child) && isFlexibleUiBlock(child)) {
@@ -333,7 +341,7 @@ const Container = ({
333
341
  "--_73mooq": ix(previewOnLeft ? gap : padding),
334
342
  "--_12k13bg": ix(previewOnRight ? gap : padding)
335
343
  }
336
- }, clickableContainer ? getLayeredLink(testId, context, children, onClick) : null, renderChildren(children, size, theme, status, retry, onClick, removeBlockRestriction)) : /*#__PURE__*/React.createElement("div", {
344
+ }, clickableContainer ? getLayeredLink(testId, context, children, onClick) : null, fg('platform-linking-flexible-card-context') ? filterChildren(children, removeBlockRestriction) : renderChildren(children, size, theme, status, retry, onClick, removeBlockRestriction)) : /*#__PURE__*/React.createElement("div", {
337
345
  "data-smart-link-container": true,
338
346
  "data-testid": testId,
339
347
  className: ax(["_1e0c1txw _2lx21bp4 _1ul9idpf _1reo15vq _kqswh2mm _1pcmkb7n _1v7y1i6y _ufn21i6y", gapStyleMapOld[size], !hideBackground && "_bfhkhp5a", "_1yt418y6 _jb7v18y6 _y5vk167t _1yob1wow _r37x1r5k", previewOnLeft && previewOnLeftStyleMapOld[size], previewOnRight && previewOnRightStyleMapOld[size], !hideElevation && "_19ith6cr _2rkopd34 _19pkv77o _2hwxv77o _otyrv77o _18u0v77o", clickableContainer && "_nqwih2mm _18ywh2mm _1nq3h2mm _1t4ckb7n _1nxdkb7n _xnbykb7n"]),
@@ -342,7 +350,7 @@ const Container = ({
342
350
  "--_73mooq": ix(previewOnLeft ? gap : padding),
343
351
  "--_12k13bg": ix(previewOnRight ? gap : padding)
344
352
  }
345
- }, clickableContainer ? getLayeredLink(testId, context, children, onClick) : null, renderChildren(children, size, theme, status, retry, onClick, removeBlockRestriction));
353
+ }, clickableContainer ? getLayeredLink(testId, context, children, onClick) : null, fg('platform-linking-flexible-card-context') ? filterChildren(children, removeBlockRestriction) : renderChildren(children, size, theme, status, retry, onClick, removeBlockRestriction));
346
354
  if (context !== null && context !== void 0 && context.url && (canShowHoverPreview || canShowAuthTooltip)) {
347
355
  return /*#__PURE__*/React.createElement(HoverCardControl, {
348
356
  isHoverPreview: canShowHoverPreview,
@@ -1,11 +1,12 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React from 'react';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  import { ElementName } from '../../../../../constants';
4
5
  import { useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
5
6
  import { BaseLinkElement, toLinkProps } from '../common';
6
7
  const TitleElement = props => {
7
8
  const context = useFlexibleUiContext();
8
- const data = context ? toLinkProps(context.title, context.url) : null;
9
+ const data = context ? fg('platform-linking-flexible-card-context') ? context === null || context === void 0 ? void 0 : context.linkTitle : toLinkProps(context.title, context.url) : null;
9
10
  return data ? /*#__PURE__*/React.createElement(BaseLinkElement, _extends({}, data, props, {
10
11
  name: ElementName.Title
11
12
  })) : null;
@@ -283,6 +283,9 @@ const getData = (elementName, contextKey, context) => {
283
283
  case ElementName.TargetBranch:
284
284
  return toTextProps(data);
285
285
  case ElementName.Title:
286
+ if (fg('platform-linking-flexible-card-context')) {
287
+ return context.linkTitle;
288
+ }
286
289
  return toLinkProps(context.title, context.url);
287
290
  case ElementName.LinkIcon:
288
291
  if (fg('platform-linking-visual-refresh-v2')) {