@atlaskit/smart-card 23.4.8 → 23.5.1
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.
- package/CHANGELOG.md +17 -0
- package/dist/cjs/constants.js +10 -2
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/state/flexible-ui-context/utils.js +16 -0
- package/dist/cjs/utils/flexible.js +8 -2
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/BlockCard/components/flexible/footer/index.js +2 -2
- package/dist/cjs/view/BlockCard/index.js +83 -12
- package/dist/cjs/view/BlockCard/views/flexible/FlexibleResolvedView.js +108 -0
- package/dist/cjs/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +1 -1
- package/dist/cjs/view/CardWithUrl/component.js +4 -2
- package/dist/cjs/view/FlexibleCard/components/blocks/preview-block/index.js +6 -9
- package/dist/cjs/view/FlexibleCard/components/blocks/preview-block/resolved/index.js +109 -0
- package/dist/cjs/view/FlexibleCard/components/common/image-icon/index.js +4 -2
- package/dist/cjs/view/FlexibleCard/components/container/index.js +40 -4
- package/dist/cjs/view/FlexibleCard/components/elements/lozenge/index.js +12 -4
- package/dist/cjs/view/FlexibleCard/components/elements/media/index.js +2 -0
- package/dist/cjs/view/HoverCard/components/HoverCardContent.js +18 -6
- package/dist/cjs/view/HoverCard/utils.js +41 -2
- package/dist/es2019/constants.js +8 -1
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/state/flexible-ui-context/utils.js +5 -0
- package/dist/es2019/utils/flexible.js +3 -2
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/BlockCard/components/flexible/footer/index.js +2 -2
- package/dist/es2019/view/BlockCard/index.js +80 -13
- package/dist/es2019/view/BlockCard/views/flexible/FlexibleErroredView.js +2 -2
- package/dist/es2019/view/BlockCard/views/flexible/FlexibleForbiddenView.js +2 -2
- package/dist/es2019/view/BlockCard/views/flexible/FlexibleNotFoundView.js +2 -2
- package/dist/es2019/view/BlockCard/views/flexible/FlexibleResolvedView.js +81 -0
- package/dist/es2019/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +3 -3
- package/dist/es2019/view/CardWithUrl/component.js +4 -2
- package/dist/es2019/view/FlexibleCard/components/blocks/preview-block/index.js +6 -7
- package/dist/es2019/view/FlexibleCard/components/blocks/preview-block/resolved/index.js +103 -0
- package/dist/es2019/view/FlexibleCard/components/common/image-icon/index.js +4 -2
- package/dist/es2019/view/FlexibleCard/components/container/index.js +73 -21
- package/dist/es2019/view/FlexibleCard/components/elements/lozenge/index.js +22 -3
- package/dist/es2019/view/FlexibleCard/components/elements/media/index.js +2 -0
- package/dist/es2019/view/HoverCard/components/HoverCardContent.js +14 -4
- package/dist/es2019/view/HoverCard/utils.js +20 -0
- package/dist/esm/constants.js +8 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/state/flexible-ui-context/utils.js +7 -0
- package/dist/esm/utils/flexible.js +4 -1
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/BlockCard/components/flexible/footer/index.js +2 -2
- package/dist/esm/view/BlockCard/index.js +77 -12
- package/dist/esm/view/BlockCard/views/flexible/FlexibleErroredView.js +2 -2
- package/dist/esm/view/BlockCard/views/flexible/FlexibleForbiddenView.js +2 -2
- package/dist/esm/view/BlockCard/views/flexible/FlexibleNotFoundView.js +2 -2
- package/dist/esm/view/BlockCard/views/flexible/FlexibleResolvedView.js +87 -0
- package/dist/esm/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +3 -3
- package/dist/esm/view/CardWithUrl/component.js +4 -2
- package/dist/esm/view/FlexibleCard/components/blocks/preview-block/index.js +7 -8
- package/dist/esm/view/FlexibleCard/components/blocks/preview-block/resolved/index.js +86 -0
- package/dist/esm/view/FlexibleCard/components/common/image-icon/index.js +4 -2
- package/dist/esm/view/FlexibleCard/components/container/index.js +42 -6
- package/dist/esm/view/FlexibleCard/components/elements/lozenge/index.js +11 -4
- package/dist/esm/view/FlexibleCard/components/elements/media/index.js +2 -0
- package/dist/esm/view/HoverCard/components/HoverCardContent.js +17 -6
- package/dist/esm/view/HoverCard/utils.js +34 -0
- package/dist/types/constants.d.ts +4 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/state/flexible-ui-context/utils.d.ts +6 -0
- package/dist/types/utils/flexible.d.ts +1 -0
- package/dist/types/view/BlockCard/components/flexible/footer/index.d.ts +2 -2
- package/dist/types/view/BlockCard/index.d.ts +1 -0
- package/dist/types/view/BlockCard/types.d.ts +1 -0
- package/dist/types/view/BlockCard/views/flexible/FlexibleResolvedView.d.ts +9 -0
- package/dist/types/view/BlockCard/views/flexible/FlexibleUnauthorisedView.d.ts +1 -1
- package/dist/types/view/FlexibleCard/components/blocks/preview-block/index.d.ts +1 -0
- package/dist/types/view/FlexibleCard/components/blocks/preview-block/resolved/index.d.ts +11 -0
- package/dist/types/view/FlexibleCard/components/blocks/preview-block/types.d.ts +15 -0
- package/dist/types/view/FlexibleCard/components/common/image-icon/types.d.ts +1 -0
- package/dist/types/view/FlexibleCard/components/container/index.d.ts +2 -2
- package/dist/types/view/FlexibleCard/components/container/types.d.ts +4 -0
- package/dist/types/view/FlexibleCard/components/elements/lozenge/types.d.ts +5 -0
- package/dist/types/view/FlexibleCard/components/elements/media/types.d.ts +1 -0
- package/dist/types/view/HoverCard/utils.d.ts +3 -0
- package/package.json +2 -2
- package/report.api.md +10 -0
- package/tmp/api-report-tmp.d.ts +10 -0
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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(
|
|
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
|
|
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(
|
|
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
|
|
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(
|
|
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
|
|
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
|
|
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(
|
|
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
|
-
}
|
|
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':
|
|
@@ -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"
|
|
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
|
|
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
|
|
28
|
-
testId:
|
|
29
|
-
}), /*#__PURE__*/React.createElement(Preview, {
|
|
30
|
-
onError: onError
|
|
28
|
+
return jsx(PreviewBlockResolvedView, _extends({}, blockProps, {
|
|
29
|
+
testId: testId
|
|
31
30
|
}));
|
|
32
31
|
};
|
|
33
32
|
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
5
|
+
var _excluded = ["ignoreContainerPadding", "onError", "overrideCss", "placement", "testId"];
|
|
6
|
+
|
|
7
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
8
|
+
|
|
9
|
+
/** @jsx jsx */
|
|
10
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
11
|
+
import { css, jsx } from '@emotion/react';
|
|
12
|
+
import { MediaPlacement } from '../../../../../../constants';
|
|
13
|
+
import Block from '../../block';
|
|
14
|
+
import { Preview } from '../../../elements';
|
|
15
|
+
/**
|
|
16
|
+
* Due to its placement on the left/right and ignoreContainerPadding prop
|
|
17
|
+
* rely on its parent container styling, css variables are declared in
|
|
18
|
+
* <Container /> to preset the base values for the preview block styling.
|
|
19
|
+
*
|
|
20
|
+
* `--container-padding` is the padding of the Container. This value is based
|
|
21
|
+
* on size and hidePadding.
|
|
22
|
+
* `--container-gap-left` and `--container-gap-right` are the gap or padding of
|
|
23
|
+
* the Container depending on whether the container has other preview blocks
|
|
24
|
+
* with left/right positioning.
|
|
25
|
+
* `--preview-block-width` is the size of the preview image in relation to
|
|
26
|
+
* the Container width when the placement is left/right.
|
|
27
|
+
* @param placement
|
|
28
|
+
* @param ignoreContainerPadding
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
var getPreviewBlockStyles = function getPreviewBlockStyles(placement, ignoreContainerPadding) {
|
|
32
|
+
if (placement === MediaPlacement.Left || placement === MediaPlacement.Right) {
|
|
33
|
+
var containerPadding = ignoreContainerPadding ? '0rem' : 'var(--container-padding)';
|
|
34
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: absolute;\n top: ", ";\n bottom: ", ";\n width: calc(var(--preview-block-width) - ", ");\n\n ", "\n ", "\n\n [data-smart-element-media='image'] {\n aspect-ratio: unset;\n padding-top: unset;\n width: 100%;\n height: 100%;\n object-fit: cover;\n }\n "])), containerPadding, containerPadding, containerPadding, placement === MediaPlacement.Left ? "left: ".concat(containerPadding, ";") : '', placement === MediaPlacement.Right ? "right: ".concat(containerPadding, ";") : '');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (ignoreContainerPadding) {
|
|
38
|
+
return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n margin-left: calc(var(--container-gap-left) * -1);\n margin-right: calc(var(--container-gap-right) * -1);\n &:first-of-type {\n margin-top: calc(var(--container-padding) * -1);\n }\n &:last-of-type {\n margin-bottom: calc(var(--container-padding) * -1);\n }\n "])));
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Represents a resolved PreviewBlock, which typically contains media or other large format content.
|
|
43
|
+
* @public
|
|
44
|
+
* @param {PreviewBlock} PreviewBlock
|
|
45
|
+
* @see Block
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
var PreviewBlockResolvedView = function PreviewBlockResolvedView(_ref) {
|
|
50
|
+
var _ref$ignoreContainerP = _ref.ignoreContainerPadding,
|
|
51
|
+
ignoreContainerPadding = _ref$ignoreContainerP === void 0 ? false : _ref$ignoreContainerP,
|
|
52
|
+
onError = _ref.onError,
|
|
53
|
+
overrideCss = _ref.overrideCss,
|
|
54
|
+
placement = _ref.placement,
|
|
55
|
+
testId = _ref.testId,
|
|
56
|
+
blockProps = _objectWithoutProperties(_ref, _excluded);
|
|
57
|
+
|
|
58
|
+
var _useState = useState(overrideCss),
|
|
59
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
60
|
+
styles = _useState2[0],
|
|
61
|
+
setStyles = _useState2[1];
|
|
62
|
+
|
|
63
|
+
var updateStyles = useCallback(function () {
|
|
64
|
+
setStyles(css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n ", "\n ", "\n "])), getPreviewBlockStyles(placement, ignoreContainerPadding), overrideCss));
|
|
65
|
+
}, [ignoreContainerPadding, overrideCss, placement]);
|
|
66
|
+
useEffect(function () {
|
|
67
|
+
updateStyles();
|
|
68
|
+
}, [ignoreContainerPadding, overrideCss, placement, updateStyles]);
|
|
69
|
+
var handleOnLoad = useCallback(function () {
|
|
70
|
+
updateStyles();
|
|
71
|
+
}, [updateStyles]);
|
|
72
|
+
var handleOnError = useCallback(function () {
|
|
73
|
+
if (onError) {
|
|
74
|
+
onError();
|
|
75
|
+
}
|
|
76
|
+
}, [onError]);
|
|
77
|
+
return jsx(Block, _extends({}, blockProps, {
|
|
78
|
+
overrideCss: styles,
|
|
79
|
+
testId: "".concat(testId, "-resolved-view")
|
|
80
|
+
}), jsx(Preview, {
|
|
81
|
+
onError: handleOnError,
|
|
82
|
+
onLoad: handleOnLoad
|
|
83
|
+
}));
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export default PreviewBlockResolvedView;
|
|
@@ -8,7 +8,8 @@ var ImageIcon = function ImageIcon(_ref) {
|
|
|
8
8
|
var defaultIcon = _ref.defaultIcon,
|
|
9
9
|
testId = _ref.testId,
|
|
10
10
|
url = _ref.url,
|
|
11
|
-
onError = _ref.onError
|
|
11
|
+
onError = _ref.onError,
|
|
12
|
+
onLoad = _ref.onLoad;
|
|
12
13
|
return jsx(ImageLoader, {
|
|
13
14
|
src: url,
|
|
14
15
|
loading: jsx(LoadingSkeleton, {
|
|
@@ -19,7 +20,8 @@ var ImageIcon = function ImageIcon(_ref) {
|
|
|
19
20
|
"data-testid": "".concat(testId, "-image")
|
|
20
21
|
}),
|
|
21
22
|
errored: defaultIcon,
|
|
22
|
-
onError: onError
|
|
23
|
+
onError: onError,
|
|
24
|
+
onLoad: onLoad
|
|
23
25
|
});
|
|
24
26
|
};
|
|
25
27
|
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
2
|
|
|
3
|
-
var _templateObject, _templateObject2, _templateObject3;
|
|
3
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
4
4
|
|
|
5
5
|
/** @jsx jsx */
|
|
6
6
|
import React, { useContext } from 'react';
|
|
7
7
|
import { css, jsx } from '@emotion/react';
|
|
8
|
-
import { SmartLinkSize, SmartLinkTheme } from '../../../../constants';
|
|
9
|
-
import { isFlexibleUiBlock, isFlexibleUiTitleBlock } from '../../../../utils/flexible';
|
|
8
|
+
import { MediaPlacement, SmartLinkSize, SmartLinkTheme } from '../../../../constants';
|
|
9
|
+
import { isFlexibleUiBlock, isFlexibleUiPreviewBlock, isFlexibleUiTitleBlock } from '../../../../utils/flexible';
|
|
10
10
|
import { tokens } from '../../../../utils/token';
|
|
11
11
|
import { FlexibleUiContext } from '../../../../state/flexible-ui-context';
|
|
12
12
|
import LayeredLink from './layered-link';
|
|
13
|
+
import { isFlexUiPreviewPresent } from '../../../../state/flexible-ui-context/utils';
|
|
13
14
|
var elevationStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n border: 1px solid transparent;\n border-radius: 1.5px;\n box-shadow: ", ";\n margin: 2px;\n"])), tokens.elevation);
|
|
14
15
|
|
|
15
16
|
var getGap = function getGap(size) {
|
|
@@ -47,8 +48,42 @@ var getPadding = function getPadding(size) {
|
|
|
47
48
|
};
|
|
48
49
|
|
|
49
50
|
var clickableContainerStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n // Position any interactive elements at the top of the z-index stack.\n a,\n button,\n .has-action {\n position: relative;\n z-index: 1;\n }\n"])));
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
|
|
52
|
+
var getContainerPaddingStyles = function getContainerPaddingStyles(size, hidePadding, childrenOptions) {
|
|
53
|
+
var padding = hidePadding ? '0rem' : getPadding(size);
|
|
54
|
+
var gap = getGap(size);
|
|
55
|
+
var previewOnLeft = childrenOptions.previewOnLeft,
|
|
56
|
+
previewOnRight = childrenOptions.previewOnRight;
|
|
57
|
+
return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n // Set variables for PreviewBlock to use.\n --container-padding: ", ";\n --container-gap-left: ", ";\n --container-gap-right: ", ";\n --preview-block-width: 30%;\n\n padding: ", ";\n ", "\n ", "\n "])), padding, previewOnLeft ? gap : padding, previewOnRight ? gap : padding, padding, previewOnLeft ? "padding-left: calc(var(--preview-block-width) + ".concat(gap, ");") : '', previewOnRight ? "padding-right: calc(var(--preview-block-width) + ".concat(gap, ");") : '');
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
var getChildrenOptions = function getChildrenOptions(children, context) {
|
|
61
|
+
var options = {};
|
|
62
|
+
|
|
63
|
+
if (isFlexUiPreviewPresent(context)) {
|
|
64
|
+
React.Children.map(children, function (child) {
|
|
65
|
+
if ( /*#__PURE__*/React.isValidElement(child)) {
|
|
66
|
+
if (isFlexibleUiPreviewBlock(child)) {
|
|
67
|
+
var placement = child.props.placement;
|
|
68
|
+
|
|
69
|
+
if (placement === MediaPlacement.Left) {
|
|
70
|
+
options.previewOnLeft = true;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (placement === MediaPlacement.Right) {
|
|
74
|
+
options.previewOnRight = true;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return options;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export var getContainerStyles = function getContainerStyles(size, hideBackground, hideElevation, hidePadding, clickableContainer, childrenOptions) {
|
|
85
|
+
var paddingCss = getContainerPaddingStyles(size, hidePadding, childrenOptions);
|
|
86
|
+
return css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n display: flex;\n gap: ", " 0;\n flex-direction: column;\n min-width: 0;\n overflow-x: hidden;\n position: relative;\n ", "\n ", "\n ", "\n ", "\n &:hover ~ .actions-button-group {\n opacity: 1;\n }\n a:focus,\n .has-action:focus {\n outline-offset: -2px;\n }\n "])), getGap(size), hideBackground ? '' : "background-color: ".concat(tokens.background, ";"), paddingCss, hideElevation ? '' : elevationStyles, clickableContainer ? clickableContainerStyles : '');
|
|
52
87
|
};
|
|
53
88
|
|
|
54
89
|
var renderChildren = function renderChildren(children, containerSize, containerTheme, status, retry, onClick) {
|
|
@@ -133,8 +168,9 @@ var Container = function Container(_ref3) {
|
|
|
133
168
|
_ref3$theme = _ref3.theme,
|
|
134
169
|
theme = _ref3$theme === void 0 ? SmartLinkTheme.Link : _ref3$theme;
|
|
135
170
|
var context = useContext(FlexibleUiContext);
|
|
171
|
+
var childrenOptions = getChildrenOptions(children, context);
|
|
136
172
|
return jsx("div", {
|
|
137
|
-
css: getContainerStyles(size, hideBackground, hideElevation, hidePadding, clickableContainer),
|
|
173
|
+
css: getContainerStyles(size, hideBackground, hideElevation, hidePadding, clickableContainer, childrenOptions),
|
|
138
174
|
"data-smart-link-container": true,
|
|
139
175
|
"data-testid": testId
|
|
140
176
|
}, clickableContainer ? getLayeredLink(testId, context, children, onClick) : null, renderChildren(children, size, theme, status, retry, onClick));
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
2
|
|
|
3
|
-
var _templateObject;
|
|
3
|
+
var _templateObject, _templateObject2;
|
|
4
4
|
|
|
5
5
|
/** @jsx jsx */
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { css, jsx } from '@emotion/react';
|
|
8
8
|
import AtlaskitLozenge from '@atlaskit/lozenge';
|
|
9
|
+
import ChevronDownIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
9
10
|
var styles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline-flex;\n line-height: inherit;\n"])));
|
|
11
|
+
var actionStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n > span > span {\n display: inline-flex;\n align-items: center;\n margin-right: -2px;\n }\n\n svg {\n width: unset;\n height: unset;\n margin: -4px 0;\n }\n"])));
|
|
10
12
|
/**
|
|
11
13
|
* A base element that displays a Lozenge.
|
|
12
14
|
* @internal
|
|
@@ -18,6 +20,7 @@ var Lozenge = function Lozenge(_ref) {
|
|
|
18
20
|
var _ref$appearance = _ref.appearance,
|
|
19
21
|
appearance = _ref$appearance === void 0 ? 'default' : _ref$appearance,
|
|
20
22
|
name = _ref.name,
|
|
23
|
+
onClick = _ref.onClick,
|
|
21
24
|
overrideCss = _ref.overrideCss,
|
|
22
25
|
text = _ref.text,
|
|
23
26
|
_ref$testId = _ref.testId,
|
|
@@ -28,15 +31,19 @@ var Lozenge = function Lozenge(_ref) {
|
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
return jsx("span", {
|
|
31
|
-
css: [styles, overrideCss],
|
|
34
|
+
css: [styles, onClick ? actionStyles : undefined, overrideCss],
|
|
32
35
|
"data-fit-to-content": true,
|
|
33
36
|
"data-smart-element": name,
|
|
34
37
|
"data-smart-element-lozenge": true,
|
|
35
|
-
"data-testid": testId
|
|
38
|
+
"data-testid": testId,
|
|
39
|
+
onClick: onClick
|
|
36
40
|
}, jsx(AtlaskitLozenge, {
|
|
37
41
|
appearance: appearance,
|
|
38
42
|
testId: "".concat(testId, "-lozenge")
|
|
39
|
-
}, text
|
|
43
|
+
}, text, onClick && jsx(ChevronDownIcon, {
|
|
44
|
+
label: "action",
|
|
45
|
+
testId: "".concat(testId, "-action")
|
|
46
|
+
})));
|
|
40
47
|
};
|
|
41
48
|
|
|
42
49
|
export default Lozenge;
|
|
@@ -32,6 +32,7 @@ var Media = function Media(_ref) {
|
|
|
32
32
|
testId = _ref$testId === void 0 ? 'smart-element-media' : _ref$testId,
|
|
33
33
|
type = _ref.type,
|
|
34
34
|
url = _ref.url,
|
|
35
|
+
onLoad = _ref.onLoad,
|
|
35
36
|
onError = _ref.onError;
|
|
36
37
|
|
|
37
38
|
if (!type || !url) {
|
|
@@ -47,6 +48,7 @@ var Media = function Media(_ref) {
|
|
|
47
48
|
testId: "".concat(testId, "-image"),
|
|
48
49
|
url: url,
|
|
49
50
|
onError: onError,
|
|
51
|
+
onLoad: onLoad,
|
|
50
52
|
defaultIcon: null
|
|
51
53
|
}));
|
|
52
54
|
};
|