@atlaskit/smart-card 23.4.7 → 23.5.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 (74) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/constants.js +10 -2
  3. package/dist/cjs/index.js +6 -0
  4. package/dist/cjs/state/flexible-ui-context/utils.js +16 -0
  5. package/dist/cjs/utils/flexible.js +8 -2
  6. package/dist/cjs/version.json +1 -1
  7. package/dist/cjs/view/BlockCard/components/flexible/footer/index.js +2 -2
  8. package/dist/cjs/view/BlockCard/index.js +83 -12
  9. package/dist/cjs/view/BlockCard/views/flexible/FlexibleResolvedView.js +108 -0
  10. package/dist/cjs/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +1 -1
  11. package/dist/cjs/view/CardWithUrl/component.js +4 -2
  12. package/dist/cjs/view/EmbedModal/components/link-info/index.js +2 -1
  13. package/dist/cjs/view/FlexibleCard/components/blocks/preview-block/index.js +6 -9
  14. package/dist/cjs/view/FlexibleCard/components/blocks/preview-block/resolved/index.js +109 -0
  15. package/dist/cjs/view/FlexibleCard/components/common/image-icon/index.js +4 -2
  16. package/dist/cjs/view/FlexibleCard/components/container/index.js +40 -4
  17. package/dist/cjs/view/FlexibleCard/components/elements/media/index.js +2 -0
  18. package/dist/es2019/constants.js +8 -1
  19. package/dist/es2019/index.js +1 -1
  20. package/dist/es2019/state/flexible-ui-context/utils.js +5 -0
  21. package/dist/es2019/utils/flexible.js +3 -2
  22. package/dist/es2019/version.json +1 -1
  23. package/dist/es2019/view/BlockCard/components/flexible/footer/index.js +2 -2
  24. package/dist/es2019/view/BlockCard/index.js +80 -13
  25. package/dist/es2019/view/BlockCard/views/flexible/FlexibleErroredView.js +2 -2
  26. package/dist/es2019/view/BlockCard/views/flexible/FlexibleForbiddenView.js +2 -2
  27. package/dist/es2019/view/BlockCard/views/flexible/FlexibleNotFoundView.js +2 -2
  28. package/dist/es2019/view/BlockCard/views/flexible/FlexibleResolvedView.js +81 -0
  29. package/dist/es2019/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +3 -3
  30. package/dist/es2019/view/CardWithUrl/component.js +4 -2
  31. package/dist/es2019/view/EmbedModal/components/link-info/index.js +2 -1
  32. package/dist/es2019/view/FlexibleCard/components/blocks/preview-block/index.js +6 -7
  33. package/dist/es2019/view/FlexibleCard/components/blocks/preview-block/resolved/index.js +103 -0
  34. package/dist/es2019/view/FlexibleCard/components/common/image-icon/index.js +4 -2
  35. package/dist/es2019/view/FlexibleCard/components/container/index.js +73 -21
  36. package/dist/es2019/view/FlexibleCard/components/elements/media/index.js +2 -0
  37. package/dist/esm/constants.js +8 -1
  38. package/dist/esm/index.js +1 -1
  39. package/dist/esm/state/flexible-ui-context/utils.js +7 -0
  40. package/dist/esm/utils/flexible.js +4 -1
  41. package/dist/esm/version.json +1 -1
  42. package/dist/esm/view/BlockCard/components/flexible/footer/index.js +2 -2
  43. package/dist/esm/view/BlockCard/index.js +77 -12
  44. package/dist/esm/view/BlockCard/views/flexible/FlexibleErroredView.js +2 -2
  45. package/dist/esm/view/BlockCard/views/flexible/FlexibleForbiddenView.js +2 -2
  46. package/dist/esm/view/BlockCard/views/flexible/FlexibleNotFoundView.js +2 -2
  47. package/dist/esm/view/BlockCard/views/flexible/FlexibleResolvedView.js +87 -0
  48. package/dist/esm/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +3 -3
  49. package/dist/esm/view/CardWithUrl/component.js +4 -2
  50. package/dist/esm/view/EmbedModal/components/link-info/index.js +2 -1
  51. package/dist/esm/view/FlexibleCard/components/blocks/preview-block/index.js +7 -8
  52. package/dist/esm/view/FlexibleCard/components/blocks/preview-block/resolved/index.js +86 -0
  53. package/dist/esm/view/FlexibleCard/components/common/image-icon/index.js +4 -2
  54. package/dist/esm/view/FlexibleCard/components/container/index.js +42 -6
  55. package/dist/esm/view/FlexibleCard/components/elements/media/index.js +2 -0
  56. package/dist/types/constants.d.ts +4 -0
  57. package/dist/types/index.d.ts +1 -1
  58. package/dist/types/state/flexible-ui-context/utils.d.ts +6 -0
  59. package/dist/types/utils/flexible.d.ts +1 -0
  60. package/dist/types/view/BlockCard/components/flexible/footer/index.d.ts +2 -2
  61. package/dist/types/view/BlockCard/index.d.ts +1 -0
  62. package/dist/types/view/BlockCard/types.d.ts +1 -0
  63. package/dist/types/view/BlockCard/views/flexible/FlexibleResolvedView.d.ts +9 -0
  64. package/dist/types/view/BlockCard/views/flexible/FlexibleUnauthorisedView.d.ts +1 -1
  65. package/dist/types/view/FlexibleCard/components/blocks/preview-block/index.d.ts +1 -0
  66. package/dist/types/view/FlexibleCard/components/blocks/preview-block/resolved/index.d.ts +11 -0
  67. package/dist/types/view/FlexibleCard/components/blocks/preview-block/types.d.ts +15 -0
  68. package/dist/types/view/FlexibleCard/components/common/image-icon/types.d.ts +1 -0
  69. package/dist/types/view/FlexibleCard/components/container/index.d.ts +2 -2
  70. package/dist/types/view/FlexibleCard/components/container/types.d.ts +4 -0
  71. package/dist/types/view/FlexibleCard/components/elements/media/types.d.ts +1 -0
  72. package/package.json +2 -2
  73. package/report.api.md +10 -0
  74. package/tmp/api-report-tmp.d.ts +10 -0
@@ -8,7 +8,8 @@ const ImageIcon = ({
8
8
  defaultIcon,
9
9
  testId,
10
10
  url,
11
- onError
11
+ onError,
12
+ onLoad
12
13
  }) => jsx(ImageLoader, {
13
14
  src: url,
14
15
  loading: jsx(LoadingSkeleton, {
@@ -19,7 +20,8 @@ const ImageIcon = ({
19
20
  "data-testid": `${testId}-image`
20
21
  }),
21
22
  errored: defaultIcon,
22
- onError: onError
23
+ onError: onError,
24
+ onLoad: onLoad
23
25
  });
24
26
 
25
27
  export default ImageIcon;
@@ -1,11 +1,12 @@
1
1
  /** @jsx jsx */
2
2
  import React, { useContext } from 'react';
3
3
  import { css, jsx } from '@emotion/react';
4
- import { SmartLinkSize, SmartLinkTheme } from '../../../../constants';
5
- import { isFlexibleUiBlock, isFlexibleUiTitleBlock } from '../../../../utils/flexible';
4
+ import { MediaPlacement, SmartLinkSize, SmartLinkTheme } from '../../../../constants';
5
+ import { isFlexibleUiBlock, isFlexibleUiPreviewBlock, isFlexibleUiTitleBlock } from '../../../../utils/flexible';
6
6
  import { tokens } from '../../../../utils/token';
7
7
  import { FlexibleUiContext } from '../../../../state/flexible-ui-context';
8
8
  import LayeredLink from './layered-link';
9
+ import { isFlexUiPreviewPresent } from '../../../../state/flexible-ui-context/utils';
9
10
  const elevationStyles = css`
10
11
  border: 1px solid transparent;
11
12
  border-radius: 1.5px;
@@ -56,25 +57,75 @@ const clickableContainerStyles = css`
56
57
  z-index: 1;
57
58
  }
58
59
  `;
59
- export const getContainerStyles = (size, hideBackground, hideElevation, hidePadding, clickableContainer) => css`
60
- display: flex;
61
- gap: ${getGap(size)} 0;
62
- flex-direction: column;
63
- min-width: 0;
64
- overflow-x: hidden;
65
- position: relative;
66
- ${hideBackground ? '' : `background-color: ${tokens.background};`}
67
- ${hidePadding ? '' : `padding: ${getPadding(size)};`}
68
- ${hideElevation ? '' : elevationStyles}
69
- ${clickableContainer ? clickableContainerStyles : ''}
70
- &:hover ~ .actions-button-group {
71
- opacity: 1;
72
- }
73
- a:focus,
74
- .has-action:focus {
75
- outline-offset: -2px;
60
+
61
+ const getContainerPaddingStyles = (size, hidePadding, childrenOptions) => {
62
+ const padding = hidePadding ? '0rem' : getPadding(size);
63
+ const gap = getGap(size);
64
+ const {
65
+ previewOnLeft,
66
+ previewOnRight
67
+ } = childrenOptions;
68
+ return css`
69
+ // Set variables for PreviewBlock to use.
70
+ --container-padding: ${padding};
71
+ --container-gap-left: ${previewOnLeft ? gap : padding};
72
+ --container-gap-right: ${previewOnRight ? gap : padding};
73
+ --preview-block-width: 30%;
74
+
75
+ padding: ${padding};
76
+ ${previewOnLeft ? `padding-left: calc(var(--preview-block-width) + ${gap});` : ''}
77
+ ${previewOnRight ? `padding-right: calc(var(--preview-block-width) + ${gap});` : ''}
78
+ `;
79
+ };
80
+
81
+ const getChildrenOptions = (children, context) => {
82
+ let options = {};
83
+
84
+ if (isFlexUiPreviewPresent(context)) {
85
+ React.Children.map(children, child => {
86
+ if ( /*#__PURE__*/React.isValidElement(child)) {
87
+ if (isFlexibleUiPreviewBlock(child)) {
88
+ const {
89
+ placement
90
+ } = child.props;
91
+
92
+ if (placement === MediaPlacement.Left) {
93
+ options.previewOnLeft = true;
94
+ }
95
+
96
+ if (placement === MediaPlacement.Right) {
97
+ options.previewOnRight = true;
98
+ }
99
+ }
100
+ }
101
+ });
76
102
  }
77
- `;
103
+
104
+ return options;
105
+ };
106
+
107
+ export const getContainerStyles = (size, hideBackground, hideElevation, hidePadding, clickableContainer, childrenOptions) => {
108
+ const paddingCss = getContainerPaddingStyles(size, hidePadding, childrenOptions);
109
+ return css`
110
+ display: flex;
111
+ gap: ${getGap(size)} 0;
112
+ flex-direction: column;
113
+ min-width: 0;
114
+ overflow-x: hidden;
115
+ position: relative;
116
+ ${hideBackground ? '' : `background-color: ${tokens.background};`}
117
+ ${paddingCss}
118
+ ${hideElevation ? '' : elevationStyles}
119
+ ${clickableContainer ? clickableContainerStyles : ''}
120
+ &:hover ~ .actions-button-group {
121
+ opacity: 1;
122
+ }
123
+ a:focus,
124
+ .has-action:focus {
125
+ outline-offset: -2px;
126
+ }
127
+ `;
128
+ };
78
129
 
79
130
  const renderChildren = (children, containerSize, containerTheme, status, retry, onClick) => React.Children.map(children, child => {
80
131
  if ( /*#__PURE__*/React.isValidElement(child) && isFlexibleUiBlock(child)) {
@@ -149,8 +200,9 @@ const Container = ({
149
200
  theme = SmartLinkTheme.Link
150
201
  }) => {
151
202
  const context = useContext(FlexibleUiContext);
203
+ const childrenOptions = getChildrenOptions(children, context);
152
204
  return jsx("div", {
153
- css: getContainerStyles(size, hideBackground, hideElevation, hidePadding, clickableContainer),
205
+ css: getContainerStyles(size, hideBackground, hideElevation, hidePadding, clickableContainer, childrenOptions),
154
206
  "data-smart-link-container": true,
155
207
  "data-testid": testId
156
208
  }, clickableContainer ? getLayeredLink(testId, context, children, onClick) : null, renderChildren(children, size, theme, status, retry, onClick));
@@ -60,6 +60,7 @@ const Media = ({
60
60
  testId = 'smart-element-media',
61
61
  type,
62
62
  url,
63
+ onLoad,
63
64
  onError
64
65
  }) => {
65
66
  if (!type || !url) {
@@ -75,6 +76,7 @@ const Media = ({
75
76
  testId: `${testId}-image`,
76
77
  url: url,
77
78
  onError: onError,
79
+ onLoad: onLoad,
78
80
  defaultIcon: null
79
81
  }));
80
82
  };
@@ -221,4 +221,11 @@ export var MediaType;
221
221
 
222
222
  (function (MediaType) {
223
223
  MediaType["Image"] = "image";
224
- })(MediaType || (MediaType = {}));
224
+ })(MediaType || (MediaType = {}));
225
+
226
+ export var MediaPlacement;
227
+
228
+ (function (MediaPlacement) {
229
+ MediaPlacement["Left"] = "left";
230
+ MediaPlacement["Right"] = "right";
231
+ })(MediaPlacement || (MediaPlacement = {}));
package/dist/esm/index.js CHANGED
@@ -12,5 +12,5 @@ export { useSmartLinkEvents } from './view/SmartLinkEvents/useSmartLinkEvents';
12
12
  export { contentFooterClassName, metadataListClassName, blockCardResolvingViewClassName, blockCardResolvedViewClassName, blockCardForbiddenViewClassName, blockCardIconImageClassName, blockCardResolvedViewByClassName, blockCardForbiddenViewLinkClassName, blockCardContentClassName, blockCardContentHeaderClassName, blockCardContentHeaderNameClassName, blockCardNotFoundViewClassName, blockCardErroredViewClassName } from './classNames';
13
13
  export { loadingPlaceholderClassName } from './view/CardWithUrl/component-lazy/LazyFallback'; // Flexible UI
14
14
 
15
- export { ActionName, ElementName, SmartLinkDirection, SmartLinkPosition, SmartLinkSize, SmartLinkTheme } from './constants';
15
+ export { ActionName, ElementName, MediaPlacement, SmartLinkDirection, SmartLinkPosition, SmartLinkSize, SmartLinkTheme } from './constants';
16
16
  export { MetadataBlock, PreviewBlock, SnippetBlock, TitleBlock, FooterBlock } from './view/FlexibleCard/components/blocks';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Returns true if preview data is available in the FlexibleUiDataContext
3
+ * @param context is the FlexibleUiDataContext
4
+ */
5
+ export var isFlexUiPreviewPresent = function isFlexUiPreviewPresent(context) {
6
+ return Boolean(context && context.preview);
7
+ };
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import * as Blocks from '../view/FlexibleCard/components/blocks';
3
- import { TitleBlock } from '../view/FlexibleCard/components/blocks';
3
+ import { PreviewBlock, TitleBlock } from '../view/FlexibleCard/components/blocks';
4
4
  import * as Elements from '../view/FlexibleCard/components/elements';
5
5
  export var isFlexibleUiCard = function isFlexibleUiCard(children) {
6
6
  if (children && React.Children.toArray(children).some(function (child) {
@@ -23,4 +23,7 @@ export var isFlexibleUiElement = function isFlexibleUiElement(node) {
23
23
  };
24
24
  export var isFlexibleUiTitleBlock = function isFlexibleUiTitleBlock(node) {
25
25
  return /*#__PURE__*/React.isValidElement(node) && node.type === TitleBlock;
26
+ };
27
+ export var isFlexibleUiPreviewBlock = function isFlexibleUiPreviewBlock(node) {
28
+ return /*#__PURE__*/React.isValidElement(node) && node.type === PreviewBlock;
26
29
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "23.4.7",
3
+ "version": "23.5.0",
4
4
  "sideEffects": false
5
5
  }
@@ -28,7 +28,7 @@ var providerStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplate
28
28
  * @param props are the data required for the block, such as actions to be displayed.
29
29
  */
30
30
 
31
- var Footer = function Footer(props) {
31
+ var BlockCardFooter = function BlockCardFooter(props) {
32
32
  var actions = props.actions,
33
33
  _props$size = props.size,
34
34
  size = _props$size === void 0 ? SmartLinkSize.Medium : _props$size,
@@ -49,4 +49,4 @@ var Footer = function Footer(props) {
49
49
  })) : null);
50
50
  };
51
51
 
52
- export default Footer;
52
+ export default BlockCardFooter;
@@ -1,5 +1,9 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import React from 'react';
2
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
3
+
4
+ var _templateObject;
5
+
6
+ /** @jsx jsx */
3
7
  import { getExtensionKey } from '../../state/helpers';
4
8
  import { extractBlockProps } from '../../extractors/block';
5
9
  import { getEmptyJsonLd, getForbiddenJsonLd } from '../../utils/jsonld';
@@ -13,15 +17,21 @@ import { ResolvingView as BlockCardResolvingView } from './views/ResolvingView';
13
17
  import { UnauthorizedView as BlockCardUnauthorisedView } from './views/UnauthorizedView';
14
18
  import { ForbiddenView as BlockCardForbiddenView } from './views/ForbiddenView';
15
19
  import { ErroredView as BlockCardErroredView } from './views/ErroredView';
20
+ import FlexibleResolvedView from './views/flexible/FlexibleResolvedView';
21
+ import FlexibleUnauthorisedView from './views/flexible/FlexibleUnauthorisedView';
22
+ import FlexibleNotFoundView from './views/flexible/FlexibleNotFoundView';
23
+ import FlexibleErroredView from './views/flexible/FlexibleErroredView';
24
+ import FlexibleForbiddenView from './views/flexible/FlexibleForbiddenView';
25
+ import { tokens } from '../../utils/token';
26
+ import { css, jsx } from '@emotion/react';
16
27
  export { default as PreviewAction } from './actions/PreviewAction';
17
28
  export { ForbiddenAction, AuthorizeAction, BlockCardResolvedView, BlockCardResolvingView, BlockCardUnauthorisedView, BlockCardForbiddenView, BlockCardErroredView, BlockCardNotFoundView };
29
+ var flexibleBlockCardElevationStyle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n border-radius: 1.5px;\n box-shadow: ", ";\n margin: 2px;\n"])), tokens.elevation);
18
30
  export var BlockCard = function BlockCard(_ref) {
19
31
  var _details$meta, _forbiddenViewProps$c;
20
32
 
21
33
  var url = _ref.url,
22
- _ref$cardState = _ref.cardState,
23
- status = _ref$cardState.status,
24
- details = _ref$cardState.details,
34
+ cardState = _ref.cardState,
25
35
  authFlow = _ref.authFlow,
26
36
  handleAuthorize = _ref.handleAuthorize,
27
37
  handleErrorRetry = _ref.handleErrorRetry,
@@ -34,7 +44,10 @@ export var BlockCard = function BlockCard(_ref) {
34
44
  testId = _ref.testId,
35
45
  showActions = _ref.showActions,
36
46
  platform = _ref.platform,
37
- analytics = _ref.analytics;
47
+ analytics = _ref.analytics,
48
+ enableFlexibleBlockCard = _ref.enableFlexibleBlockCard;
49
+ var status = cardState.status,
50
+ details = cardState.details;
38
51
  var data = details && details.data || getEmptyJsonLd();
39
52
  var meta = details && details.meta;
40
53
  var extractorOpts = {
@@ -44,10 +57,62 @@ export var BlockCard = function BlockCard(_ref) {
44
57
  extensionKey: getExtensionKey(details)
45
58
  };
46
59
 
60
+ if (enableFlexibleBlockCard) {
61
+ var ui = {
62
+ hideElevation: true
63
+ };
64
+ var flexibleProps = {
65
+ cardState: cardState,
66
+ url: url,
67
+ testId: testId,
68
+ onError: onError,
69
+ renderers: renderers,
70
+ ui: ui
71
+ };
72
+
73
+ switch (status) {
74
+ case 'pending':
75
+ case 'resolving':
76
+ case 'resolved':
77
+ return jsx("div", {
78
+ css: flexibleBlockCardElevationStyle
79
+ }, jsx(FlexibleResolvedView, flexibleProps));
80
+
81
+ case 'unauthorized':
82
+ return jsx("div", {
83
+ css: flexibleBlockCardElevationStyle
84
+ }, jsx(FlexibleUnauthorisedView, _extends({}, flexibleProps, {
85
+ onAuthorize: handleAuthorize
86
+ })));
87
+
88
+ case 'forbidden':
89
+ return jsx("div", {
90
+ css: flexibleBlockCardElevationStyle
91
+ }, jsx(FlexibleForbiddenView, _extends({}, flexibleProps, {
92
+ onAuthorize: handleAuthorize
93
+ })));
94
+
95
+ case 'not_found':
96
+ return jsx("div", {
97
+ css: flexibleBlockCardElevationStyle
98
+ }, jsx(FlexibleNotFoundView, _extends({}, flexibleProps, {
99
+ onAuthorize: handleAuthorize
100
+ })));
101
+
102
+ case 'fallback':
103
+ case 'errored':
104
+ return jsx("div", {
105
+ css: flexibleBlockCardElevationStyle
106
+ }, jsx(FlexibleErroredView, _extends({}, flexibleProps, {
107
+ onAuthorize: handleAuthorize
108
+ })));
109
+ }
110
+ }
111
+
47
112
  switch (status) {
48
113
  case 'pending':
49
114
  case 'resolving':
50
- return /*#__PURE__*/React.createElement(BlockCardResolvingView, {
115
+ return jsx(BlockCardResolvingView, {
51
116
  testId: testId,
52
117
  isSelected: isSelected
53
118
  });
@@ -62,7 +127,7 @@ export var BlockCard = function BlockCard(_ref) {
62
127
  });
63
128
  }
64
129
 
65
- return /*#__PURE__*/React.createElement(BlockCardResolvedView, _extends({}, resolvedViewProps, {
130
+ return jsx(BlockCardResolvedView, _extends({}, resolvedViewProps, {
66
131
  isSelected: isSelected,
67
132
  testId: testId,
68
133
  showActions: showActions,
@@ -78,7 +143,7 @@ export var BlockCard = function BlockCard(_ref) {
78
143
  }
79
144
 
80
145
  var unauthorizedViewProps = extractBlockProps(data, meta, extractorOpts);
81
- return /*#__PURE__*/React.createElement(BlockCardUnauthorisedView, _extends({}, unauthorizedViewProps, {
146
+ return jsx(BlockCardUnauthorisedView, _extends({}, unauthorizedViewProps, {
82
147
  isSelected: isSelected,
83
148
  testId: testId,
84
149
  showActions: showActions,
@@ -101,7 +166,7 @@ export var BlockCard = function BlockCard(_ref) {
101
166
  url: url,
102
167
  context: (_forbiddenViewProps$c = forbiddenViewProps.context) === null || _forbiddenViewProps$c === void 0 ? void 0 : _forbiddenViewProps$c.text
103
168
  });
104
- return /*#__PURE__*/React.createElement(BlockCardForbiddenView, _extends({}, forbiddenViewProps, {
169
+ return jsx(BlockCardForbiddenView, _extends({}, forbiddenViewProps, {
105
170
  isSelected: isSelected,
106
171
  showActions: showActions,
107
172
  actions: handleAuthorize ? [ForbiddenAction(handleAuthorize)] : [],
@@ -118,7 +183,7 @@ export var BlockCard = function BlockCard(_ref) {
118
183
  }
119
184
 
120
185
  var notFoundViewProps = extractBlockProps(data, meta, extractorOpts);
121
- return /*#__PURE__*/React.createElement(BlockCardNotFoundView, _extends({}, notFoundViewProps, {
186
+ return jsx(BlockCardNotFoundView, _extends({}, notFoundViewProps, {
122
187
  isSelected: isSelected,
123
188
  testId: testId,
124
189
  onClick: handleFrameClick
@@ -135,7 +200,7 @@ export var BlockCard = function BlockCard(_ref) {
135
200
  }
136
201
 
137
202
  if (authFlow && authFlow === 'disabled') {
138
- return /*#__PURE__*/React.createElement(CardLinkView, {
203
+ return jsx(CardLinkView, {
139
204
  link: url,
140
205
  isSelected: isSelected,
141
206
  onClick: handleFrameClick,
@@ -143,7 +208,7 @@ export var BlockCard = function BlockCard(_ref) {
143
208
  });
144
209
  }
145
210
 
146
- return /*#__PURE__*/React.createElement(BlockCardErroredView, {
211
+ return jsx(BlockCardErroredView, {
147
212
  link: url,
148
213
  isSelected: isSelected,
149
214
  onRetry: handleErrorRetry,
@@ -5,7 +5,7 @@ import { messages } from '../../../../messages';
5
5
  import { token } from '@atlaskit/tokens';
6
6
  import { R300 } from '@atlaskit/theme/colors';
7
7
  import WarningIcon from '@atlaskit/icon/glyph/warning';
8
- import Footer from '../../components/flexible/footer';
8
+ import BlockCardFooter from '../../components/flexible/footer';
9
9
  import { RetryAction } from '../../actions/flexible/RetryAction';
10
10
  import { CustomBlock } from '../../../FlexibleCard/components/blocks';
11
11
  import Text from '../../../FlexibleCard/components/elements/text';
@@ -48,7 +48,7 @@ var FlexibleErroredView = function FlexibleErroredView(_ref) {
48
48
  message: {
49
49
  descriptor: messages.could_not_load_link
50
50
  }
51
- })), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(Footer, {
51
+ })), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(BlockCardFooter, {
52
52
  actions: actions,
53
53
  status: status
54
54
  })));
@@ -6,7 +6,7 @@ import { token } from '@atlaskit/tokens';
6
6
  import { R300 } from '@atlaskit/theme/colors';
7
7
  import { messages } from '../../../../messages';
8
8
  import LockIcon from '@atlaskit/icon/glyph/lock-filled';
9
- import Footer from '../../components/flexible/footer';
9
+ import BlockCardFooter from '../../components/flexible/footer';
10
10
  import { ForbiddenAction } from '../../actions/flexible/ForbiddenAction';
11
11
  import Text from '../../../FlexibleCard/components/elements/text';
12
12
 
@@ -50,7 +50,7 @@ var FlexibleForbiddenView = function FlexibleForbiddenView(_ref) {
50
50
  message: {
51
51
  descriptor: messages.invalid_permissions_description
52
52
  }
53
- })), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(Footer, {
53
+ })), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(BlockCardFooter, {
54
54
  actions: actions,
55
55
  status: status
56
56
  })));
@@ -5,7 +5,7 @@ import { messages } from '../../../../messages';
5
5
  import WarningIcon from '@atlaskit/icon/glyph/warning';
6
6
  import { token } from '@atlaskit/tokens';
7
7
  import { R300 } from '@atlaskit/theme/colors';
8
- import Footer from '../../components/flexible/footer';
8
+ import BlockCardFooter from '../../components/flexible/footer';
9
9
  import Text from '../../../FlexibleCard/components/elements/text';
10
10
  import { CustomBlock } from '../../../FlexibleCard/components/blocks';
11
11
 
@@ -46,7 +46,7 @@ var FlexibleNotFoundView = function FlexibleNotFoundView(_ref) {
46
46
  descriptor: messages.not_found_description
47
47
  },
48
48
  testId: testId
49
- })), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(Footer, {
49
+ })), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(BlockCardFooter, {
50
50
  status: status
51
51
  })));
52
52
  };
@@ -0,0 +1,87 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import React, { useEffect, useState } from 'react';
3
+ import FlexibleCard from '../../../FlexibleCard';
4
+ import TitleBlock from '../../../FlexibleCard/components/blocks/title-block';
5
+ import { FooterBlock, MetadataBlock, PreviewBlock, SnippetBlock } from '../../../FlexibleCard/components/blocks';
6
+ import { ActionName, ElementName, MediaPlacement, SmartLinkPosition } from '../../../../constants';
7
+
8
+ /**
9
+ * This view represents a Block card that has an 'Resolved' status.
10
+ * @see SmartLinkStatus
11
+ * @see FlexibleCardProps
12
+ */
13
+ var FlexibleResolvedView = function FlexibleResolvedView(_ref) {
14
+ var cardState = _ref.cardState,
15
+ onClick = _ref.onClick,
16
+ onError = _ref.onError,
17
+ _ref$testId = _ref.testId,
18
+ testId = _ref$testId === void 0 ? 'smart-block-resolved-view' : _ref$testId,
19
+ ui = _ref.ui,
20
+ url = _ref.url;
21
+
22
+ var _useState = useState(false),
23
+ _useState2 = _slicedToArray(_useState, 2),
24
+ isPreviewBlockErrored = _useState2[0],
25
+ setIsPreviewBlockErrored = _useState2[1];
26
+
27
+ useEffect(function () {
28
+ setIsPreviewBlockErrored(false);
29
+ }, [url, cardState]);
30
+ return /*#__PURE__*/React.createElement(FlexibleCard, {
31
+ appearance: "block",
32
+ cardState: cardState,
33
+ onClick: onClick,
34
+ onError: onError,
35
+ testId: testId,
36
+ ui: ui,
37
+ url: url
38
+ }, /*#__PURE__*/React.createElement(TitleBlock, {
39
+ position: SmartLinkPosition.Center,
40
+ metadata: [{
41
+ name: ElementName.AuthorGroup
42
+ }, {
43
+ name: ElementName.Priority
44
+ }, {
45
+ name: ElementName.State
46
+ }],
47
+ hideRetry: true
48
+ }), /*#__PURE__*/React.createElement(MetadataBlock, {
49
+ primary: [{
50
+ name: ElementName.ModifiedBy
51
+ }, {
52
+ name: ElementName.ModifiedOn
53
+ }],
54
+ secondary: [{
55
+ name: ElementName.AttachmentCount
56
+ }, {
57
+ name: ElementName.CommentCount
58
+ }, {
59
+ name: ElementName.ReactCount
60
+ }, {
61
+ name: ElementName.SubscriberCount
62
+ }, {
63
+ name: ElementName.ViewCount
64
+ }, {
65
+ name: ElementName.VoteCount
66
+ }, {
67
+ name: ElementName.DueOn
68
+ }],
69
+ maxLines: 1
70
+ }), /*#__PURE__*/React.createElement(MetadataBlock, null), /*#__PURE__*/React.createElement(SnippetBlock, null), !isPreviewBlockErrored ? /*#__PURE__*/React.createElement(PreviewBlock, {
71
+ placement: MediaPlacement.Right,
72
+ ignoreContainerPadding: true,
73
+ onError: function onError() {
74
+ setIsPreviewBlockErrored(true);
75
+ }
76
+ }) : null, /*#__PURE__*/React.createElement(FooterBlock, {
77
+ actions: [{
78
+ name: ActionName.PreviewAction
79
+ }, {
80
+ name: ActionName.ViewAction
81
+ }, {
82
+ name: ActionName.DownloadAction
83
+ }]
84
+ }));
85
+ };
86
+
87
+ export default FlexibleResolvedView;
@@ -4,7 +4,7 @@ import TitleBlock from '../../../FlexibleCard/components/blocks/title-block';
4
4
  import { messages } from '../../../../messages';
5
5
  import Text from '../../../FlexibleCard/components/elements/text';
6
6
  import { AuthorizeAction } from '../../actions/flexible/AuthorizeAction';
7
- import Footer from '../../components/flexible/footer';
7
+ import BlockCardFooter from '../../components/flexible/footer';
8
8
  import { CustomBlock } from '../../../FlexibleCard/components/blocks';
9
9
 
10
10
  /**
@@ -12,7 +12,7 @@ import { CustomBlock } from '../../../FlexibleCard/components/blocks';
12
12
  * It should have a "Connect" button that will allow a user to connect their account and view the block card.
13
13
  *
14
14
  * @see SmartLinkStatus
15
- * @see UnauthorisedViewProps
15
+ * @see FlexibleCardProps
16
16
  */
17
17
  var FlexibleUnauthorisedView = function FlexibleUnauthorisedView(_ref) {
18
18
  var cardState = _ref.cardState,
@@ -47,7 +47,7 @@ var FlexibleUnauthorisedView = function FlexibleUnauthorisedView(_ref) {
47
47
  context: providerName
48
48
  }
49
49
  }
50
- })), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(Footer, {
50
+ })), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(BlockCardFooter, {
51
51
  actions: actions,
52
52
  status: status
53
53
  })));
@@ -54,8 +54,9 @@ export function CardWithUrlContent(_ref) {
54
54
 
55
55
  if (showHoverPreview === undefined && showHoverPreviewFlag !== undefined) {
56
56
  showHoverPreview = Boolean(showHoverPreviewFlag);
57
- } // Setup UI handlers.
57
+ }
58
58
 
59
+ var enableFlexibleBlockCardFlag = Boolean(useFeatureFlag('enableFlexibleBlockCard')); // Setup UI handlers.
59
60
 
60
61
  var handleClick = useCallback(function (event) {
61
62
  var clickUrl = getClickUrl(url, state.details);
@@ -188,7 +189,8 @@ export function CardWithUrlContent(_ref) {
188
189
  onError: onError,
189
190
  testId: testId,
190
191
  showActions: showActions,
191
- platform: platform
192
+ platform: platform,
193
+ enableFlexibleBlockCard: enableFlexibleBlockCardFlag
192
194
  });
193
195
 
194
196
  case 'embed':
@@ -38,7 +38,8 @@ var LinkInfo = function LinkInfo(_ref) {
38
38
  label: messages.download.defaultMessage
39
39
  }),
40
40
  onClick: onDownloadButtonClick,
41
- testId: "".concat(testId, "-download")
41
+ testId: "".concat(testId, "-download"),
42
+ target: "_blank"
42
43
  });
43
44
  }
44
45
  }, [downloadUrl, onDownloadButtonClick, testId]);
@@ -1,10 +1,12 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["status", "testId", "onError"];
3
+ var _excluded = ["status", "testId"];
4
+
5
+ /** @jsx jsx */
4
6
  import React from 'react';
7
+ import { jsx } from '@emotion/react';
5
8
  import { SmartLinkStatus } from '../../../../../constants';
6
- import Block from '../block';
7
- import { Preview } from '../../elements';
9
+ import PreviewBlockResolvedView from './resolved';
8
10
  /**
9
11
  * Represents a PreviewBlock, which typically contains media or other large format content.
10
12
  * @public
@@ -17,17 +19,14 @@ var PreviewBlock = function PreviewBlock(_ref) {
17
19
  status = _ref$status === void 0 ? SmartLinkStatus.Fallback : _ref$status,
18
20
  _ref$testId = _ref.testId,
19
21
  testId = _ref$testId === void 0 ? 'smart-block-preview' : _ref$testId,
20
- onError = _ref.onError,
21
22
  blockProps = _objectWithoutProperties(_ref, _excluded);
22
23
 
23
24
  if (status !== SmartLinkStatus.Resolved) {
24
25
  return null;
25
26
  }
26
27
 
27
- return /*#__PURE__*/React.createElement(Block, _extends({}, blockProps, {
28
- testId: "".concat(testId, "-resolved-view")
29
- }), /*#__PURE__*/React.createElement(Preview, {
30
- onError: onError
28
+ return jsx(PreviewBlockResolvedView, _extends({}, blockProps, {
29
+ testId: testId
31
30
  }));
32
31
  };
33
32