@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
|
@@ -25,7 +25,9 @@ var _flexibleUiContext = require("../../../../state/flexible-ui-context");
|
|
|
25
25
|
|
|
26
26
|
var _layeredLink = _interopRequireDefault(require("./layered-link"));
|
|
27
27
|
|
|
28
|
-
var
|
|
28
|
+
var _utils = require("../../../../state/flexible-ui-context/utils");
|
|
29
|
+
|
|
30
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
29
31
|
|
|
30
32
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
31
33
|
|
|
@@ -69,8 +71,41 @@ var getPadding = function getPadding(size) {
|
|
|
69
71
|
|
|
70
72
|
var clickableContainerStyles = (0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\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"])));
|
|
71
73
|
|
|
72
|
-
var
|
|
73
|
-
|
|
74
|
+
var getContainerPaddingStyles = function getContainerPaddingStyles(size, hidePadding, childrenOptions) {
|
|
75
|
+
var padding = hidePadding ? '0rem' : getPadding(size);
|
|
76
|
+
var gap = getGap(size);
|
|
77
|
+
var previewOnLeft = childrenOptions.previewOnLeft,
|
|
78
|
+
previewOnRight = childrenOptions.previewOnRight;
|
|
79
|
+
return (0, _react2.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\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, ");") : '');
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
var getChildrenOptions = function getChildrenOptions(children, context) {
|
|
83
|
+
var options = {};
|
|
84
|
+
|
|
85
|
+
if ((0, _utils.isFlexUiPreviewPresent)(context)) {
|
|
86
|
+
_react.default.Children.map(children, function (child) {
|
|
87
|
+
if ( /*#__PURE__*/_react.default.isValidElement(child)) {
|
|
88
|
+
if ((0, _flexible.isFlexibleUiPreviewBlock)(child)) {
|
|
89
|
+
var placement = child.props.placement;
|
|
90
|
+
|
|
91
|
+
if (placement === _constants.MediaPlacement.Left) {
|
|
92
|
+
options.previewOnLeft = true;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (placement === _constants.MediaPlacement.Right) {
|
|
96
|
+
options.previewOnRight = true;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return options;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
var getContainerStyles = function getContainerStyles(size, hideBackground, hideElevation, hidePadding, clickableContainer, childrenOptions) {
|
|
107
|
+
var paddingCss = getContainerPaddingStyles(size, hidePadding, childrenOptions);
|
|
108
|
+
return (0, _react2.css)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\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(_token.tokens.background, ";"), paddingCss, hideElevation ? '' : elevationStyles, clickableContainer ? clickableContainerStyles : '');
|
|
74
109
|
};
|
|
75
110
|
|
|
76
111
|
exports.getContainerStyles = getContainerStyles;
|
|
@@ -157,8 +192,9 @@ var Container = function Container(_ref3) {
|
|
|
157
192
|
_ref3$theme = _ref3.theme,
|
|
158
193
|
theme = _ref3$theme === void 0 ? _constants.SmartLinkTheme.Link : _ref3$theme;
|
|
159
194
|
var context = (0, _react.useContext)(_flexibleUiContext.FlexibleUiContext);
|
|
195
|
+
var childrenOptions = getChildrenOptions(children, context);
|
|
160
196
|
return (0, _react2.jsx)("div", {
|
|
161
|
-
css: getContainerStyles(size, hideBackground, hideElevation, hidePadding, clickableContainer),
|
|
197
|
+
css: getContainerStyles(size, hideBackground, hideElevation, hidePadding, clickableContainer, childrenOptions),
|
|
162
198
|
"data-smart-link-container": true,
|
|
163
199
|
"data-testid": testId
|
|
164
200
|
}, clickableContainer ? getLayeredLink(testId, context, children, onClick) : null, renderChildren(children, size, theme, status, retry, onClick));
|
|
@@ -15,9 +15,12 @@ var _react2 = require("@emotion/react");
|
|
|
15
15
|
|
|
16
16
|
var _lozenge = _interopRequireDefault(require("@atlaskit/lozenge"));
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _chevronDown = _interopRequireDefault(require("@atlaskit/icon/glyph/chevron-down"));
|
|
19
|
+
|
|
20
|
+
var _templateObject, _templateObject2;
|
|
19
21
|
|
|
20
22
|
var styles = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: inline-flex;\n line-height: inherit;\n"])));
|
|
23
|
+
var actionStyles = (0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\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"])));
|
|
21
24
|
/**
|
|
22
25
|
* A base element that displays a Lozenge.
|
|
23
26
|
* @internal
|
|
@@ -29,6 +32,7 @@ var Lozenge = function Lozenge(_ref) {
|
|
|
29
32
|
var _ref$appearance = _ref.appearance,
|
|
30
33
|
appearance = _ref$appearance === void 0 ? 'default' : _ref$appearance,
|
|
31
34
|
name = _ref.name,
|
|
35
|
+
onClick = _ref.onClick,
|
|
32
36
|
overrideCss = _ref.overrideCss,
|
|
33
37
|
text = _ref.text,
|
|
34
38
|
_ref$testId = _ref.testId,
|
|
@@ -39,15 +43,19 @@ var Lozenge = function Lozenge(_ref) {
|
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
return (0, _react2.jsx)("span", {
|
|
42
|
-
css: [styles, overrideCss],
|
|
46
|
+
css: [styles, onClick ? actionStyles : undefined, overrideCss],
|
|
43
47
|
"data-fit-to-content": true,
|
|
44
48
|
"data-smart-element": name,
|
|
45
49
|
"data-smart-element-lozenge": true,
|
|
46
|
-
"data-testid": testId
|
|
50
|
+
"data-testid": testId,
|
|
51
|
+
onClick: onClick
|
|
47
52
|
}, (0, _react2.jsx)(_lozenge.default, {
|
|
48
53
|
appearance: appearance,
|
|
49
54
|
testId: "".concat(testId, "-lozenge")
|
|
50
|
-
}, text)
|
|
55
|
+
}, text, onClick && (0, _react2.jsx)(_chevronDown.default, {
|
|
56
|
+
label: "action",
|
|
57
|
+
testId: "".concat(testId, "-action")
|
|
58
|
+
})));
|
|
51
59
|
};
|
|
52
60
|
|
|
53
61
|
var _default = Lozenge;
|
|
@@ -42,6 +42,7 @@ var Media = function Media(_ref) {
|
|
|
42
42
|
testId = _ref$testId === void 0 ? 'smart-element-media' : _ref$testId,
|
|
43
43
|
type = _ref.type,
|
|
44
44
|
url = _ref.url,
|
|
45
|
+
onLoad = _ref.onLoad,
|
|
45
46
|
onError = _ref.onError;
|
|
46
47
|
|
|
47
48
|
if (!type || !url) {
|
|
@@ -57,6 +58,7 @@ var Media = function Media(_ref) {
|
|
|
57
58
|
testId: "".concat(testId, "-image"),
|
|
58
59
|
url: url,
|
|
59
60
|
onError: onError,
|
|
61
|
+
onLoad: onLoad,
|
|
60
62
|
defaultIcon: null
|
|
61
63
|
}));
|
|
62
64
|
};
|
|
@@ -9,6 +9,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
});
|
|
10
10
|
exports.toFooterActions = exports.getOpenAction = exports.default = void 0;
|
|
11
11
|
|
|
12
|
+
var _linkProvider = require("@atlaskit/link-provider");
|
|
13
|
+
|
|
12
14
|
var _shortcut = _interopRequireDefault(require("@atlaskit/icon/glyph/shortcut"));
|
|
13
15
|
|
|
14
16
|
var _extractors = require("@atlaskit/linking-common/extractors");
|
|
@@ -17,7 +19,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
17
19
|
|
|
18
20
|
var _constants = require("../../../constants");
|
|
19
21
|
|
|
20
|
-
var
|
|
22
|
+
var _extractMetadata = require("../../../extractors/hover/extractMetadata");
|
|
21
23
|
|
|
22
24
|
var _actions = require("../../../state/actions");
|
|
23
25
|
|
|
@@ -97,6 +99,7 @@ var HoverCardContent = function HoverCardContent(_ref) {
|
|
|
97
99
|
onResolve = _ref.onResolve,
|
|
98
100
|
renderers = _ref.renderers,
|
|
99
101
|
url = _ref.url;
|
|
102
|
+
var showActionableElement = (0, _linkProvider.useFeatureFlag)('enableActionableElement');
|
|
100
103
|
var actions = (0, _actions.useSmartCardActions)(id, url, analytics);
|
|
101
104
|
(0, _react.useEffect)(function () {
|
|
102
105
|
actions.loadMetadata();
|
|
@@ -129,12 +132,21 @@ var HoverCardContent = function HoverCardContent(_ref) {
|
|
|
129
132
|
return toFooterActions(cardActions, onActionClick);
|
|
130
133
|
}, [cardActions, onActionClick]);
|
|
131
134
|
var data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
|
|
132
|
-
var types = data ? (0, _extractors.extractType)(data) : undefined; //TODO: EDM-3224 deleted simulated and use real JsonLd
|
|
133
135
|
|
|
134
|
-
var
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
var _useMemo = (0, _react.useMemo)(function () {
|
|
137
|
+
var types = data ? (0, _extractors.extractType)(data) : undefined; //TODO: EDM-3224 deleted simulated and use real JsonLd
|
|
138
|
+
|
|
139
|
+
var metadata = (0, _extractMetadata.extractMetadata)((0, _utils2.getSimulatedMetadata)(extensionKey, types));
|
|
140
|
+
var primary = showActionableElement ? (0, _utils2.toActionableMetadata)(onActionClick, extensionKey, types, cardActions, metadata.primary) : metadata.primary;
|
|
141
|
+
return {
|
|
142
|
+
primary: primary,
|
|
143
|
+
secondary: metadata.secondary,
|
|
144
|
+
subtitle: metadata.subtitle
|
|
145
|
+
};
|
|
146
|
+
}, [cardActions, data, extensionKey, onActionClick, showActionableElement]),
|
|
147
|
+
primary = _useMemo.primary,
|
|
148
|
+
secondary = _useMemo.secondary,
|
|
149
|
+
subtitle = _useMemo.subtitle;
|
|
138
150
|
|
|
139
151
|
var titleMaxLines = subtitle && subtitle.length > 0 ? 1 : 2;
|
|
140
152
|
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
|
-
exports.getSimulatedMetadata = exports.SMART_CARD_ANALYTICS_DISPLAY = void 0;
|
|
8
|
+
exports.toActionableMetadata = exports.getSimulatedMetadata = exports.SMART_CARD_ANALYTICS_DISPLAY = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
7
11
|
|
|
8
12
|
var _constants = require("../../constants");
|
|
9
13
|
|
|
14
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
+
|
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
|
+
|
|
10
18
|
var SMART_CARD_ANALYTICS_DISPLAY = 'flexible';
|
|
11
19
|
exports.SMART_CARD_ANALYTICS_DISPLAY = SMART_CARD_ANALYTICS_DISPLAY;
|
|
12
20
|
|
|
@@ -92,4 +100,35 @@ var getSimulatedMetadata = function getSimulatedMetadata() {
|
|
|
92
100
|
}
|
|
93
101
|
};
|
|
94
102
|
|
|
95
|
-
exports.getSimulatedMetadata = getSimulatedMetadata;
|
|
103
|
+
exports.getSimulatedMetadata = getSimulatedMetadata;
|
|
104
|
+
|
|
105
|
+
var toActionableMetadata = function toActionableMetadata(onActionClick, extensionKey) {
|
|
106
|
+
var types = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
107
|
+
var cardActions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
108
|
+
var elementItems = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
109
|
+
|
|
110
|
+
// Actionable State for Jira issue
|
|
111
|
+
if (extensionKey === 'jira-object-provider' && types !== null && types !== void 0 && types.includes('atlassian:Task')) {
|
|
112
|
+
var previewAction = cardActions.find(function (action) {
|
|
113
|
+
return action.id === 'preview-content';
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
if (previewAction) {
|
|
117
|
+
return elementItems.map(function (elementItem) {
|
|
118
|
+
return elementItem.name === _constants.ElementName.State ? _objectSpread(_objectSpread({}, elementItem), {}, {
|
|
119
|
+
onClick: function onClick() {
|
|
120
|
+
if (onActionClick) {
|
|
121
|
+
onActionClick(previewAction.id);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return previewAction.invoke();
|
|
125
|
+
}
|
|
126
|
+
}) : elementItem;
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return elementItems;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
exports.toActionableMetadata = toActionableMetadata;
|
package/dist/es2019/constants.js
CHANGED
|
@@ -221,4 +221,11 @@ export let MediaType;
|
|
|
221
221
|
|
|
222
222
|
(function (MediaType) {
|
|
223
223
|
MediaType["Image"] = "image";
|
|
224
|
-
})(MediaType || (MediaType = {}));
|
|
224
|
+
})(MediaType || (MediaType = {}));
|
|
225
|
+
|
|
226
|
+
export let MediaPlacement;
|
|
227
|
+
|
|
228
|
+
(function (MediaPlacement) {
|
|
229
|
+
MediaPlacement["Left"] = "left";
|
|
230
|
+
MediaPlacement["Right"] = "right";
|
|
231
|
+
})(MediaPlacement || (MediaPlacement = {}));
|
package/dist/es2019/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';
|
|
@@ -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 const isFlexibleUiCard = children => {
|
|
6
6
|
if (children && React.Children.toArray(children).some(child => isFlexibleUiTitleBlock(child))) {
|
|
@@ -11,4 +11,5 @@ export const isFlexibleUiCard = children => {
|
|
|
11
11
|
};
|
|
12
12
|
export const isFlexibleUiBlock = node => /*#__PURE__*/React.isValidElement(node) && Object.values(Blocks).some(type => type === node.type);
|
|
13
13
|
export const isFlexibleUiElement = node => /*#__PURE__*/React.isValidElement(node) && Object.values(Elements).some(type => type === node.type);
|
|
14
|
-
export const isFlexibleUiTitleBlock = node => /*#__PURE__*/React.isValidElement(node) && node.type === TitleBlock;
|
|
14
|
+
export const isFlexibleUiTitleBlock = node => /*#__PURE__*/React.isValidElement(node) && node.type === TitleBlock;
|
|
15
|
+
export const isFlexibleUiPreviewBlock = node => /*#__PURE__*/React.isValidElement(node) && node.type === PreviewBlock;
|
package/dist/es2019/version.json
CHANGED
|
@@ -30,7 +30,7 @@ const providerStyles = css`
|
|
|
30
30
|
* @param props are the data required for the block, such as actions to be displayed.
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
|
-
const
|
|
33
|
+
const BlockCardFooter = props => {
|
|
34
34
|
const {
|
|
35
35
|
actions,
|
|
36
36
|
size = SmartLinkSize.Medium,
|
|
@@ -51,4 +51,4 @@ const Footer = props => {
|
|
|
51
51
|
})) : null);
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
export default
|
|
54
|
+
export default BlockCardFooter;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
/** @jsx jsx */
|
|
3
4
|
import { getExtensionKey } from '../../state/helpers';
|
|
4
5
|
import { extractBlockProps } from '../../extractors/block';
|
|
5
6
|
import { getEmptyJsonLd, getForbiddenJsonLd } from '../../utils/jsonld';
|
|
@@ -13,14 +14,23 @@ import { ResolvingView as BlockCardResolvingView } from './views/ResolvingView';
|
|
|
13
14
|
import { UnauthorizedView as BlockCardUnauthorisedView } from './views/UnauthorizedView';
|
|
14
15
|
import { ForbiddenView as BlockCardForbiddenView } from './views/ForbiddenView';
|
|
15
16
|
import { ErroredView as BlockCardErroredView } from './views/ErroredView';
|
|
17
|
+
import FlexibleResolvedView from './views/flexible/FlexibleResolvedView';
|
|
18
|
+
import FlexibleUnauthorisedView from './views/flexible/FlexibleUnauthorisedView';
|
|
19
|
+
import FlexibleNotFoundView from './views/flexible/FlexibleNotFoundView';
|
|
20
|
+
import FlexibleErroredView from './views/flexible/FlexibleErroredView';
|
|
21
|
+
import FlexibleForbiddenView from './views/flexible/FlexibleForbiddenView';
|
|
22
|
+
import { tokens } from '../../utils/token';
|
|
23
|
+
import { css, jsx } from '@emotion/react';
|
|
16
24
|
export { default as PreviewAction } from './actions/PreviewAction';
|
|
17
25
|
export { ForbiddenAction, AuthorizeAction, BlockCardResolvedView, BlockCardResolvingView, BlockCardUnauthorisedView, BlockCardForbiddenView, BlockCardErroredView, BlockCardNotFoundView };
|
|
26
|
+
const flexibleBlockCardElevationStyle = css`
|
|
27
|
+
border-radius: 1.5px;
|
|
28
|
+
box-shadow: ${tokens.elevation};
|
|
29
|
+
margin: 2px;
|
|
30
|
+
`;
|
|
18
31
|
export const BlockCard = ({
|
|
19
32
|
url,
|
|
20
|
-
cardState
|
|
21
|
-
status,
|
|
22
|
-
details
|
|
23
|
-
},
|
|
33
|
+
cardState,
|
|
24
34
|
authFlow,
|
|
25
35
|
handleAuthorize,
|
|
26
36
|
handleErrorRetry,
|
|
@@ -33,10 +43,15 @@ export const BlockCard = ({
|
|
|
33
43
|
testId,
|
|
34
44
|
showActions,
|
|
35
45
|
platform,
|
|
36
|
-
analytics
|
|
46
|
+
analytics,
|
|
47
|
+
enableFlexibleBlockCard
|
|
37
48
|
}) => {
|
|
38
49
|
var _details$meta, _forbiddenViewProps$c;
|
|
39
50
|
|
|
51
|
+
const {
|
|
52
|
+
status,
|
|
53
|
+
details
|
|
54
|
+
} = cardState;
|
|
40
55
|
const data = details && details.data || getEmptyJsonLd();
|
|
41
56
|
const meta = details && details.meta;
|
|
42
57
|
const extractorOpts = {
|
|
@@ -46,10 +61,62 @@ export const BlockCard = ({
|
|
|
46
61
|
extensionKey: getExtensionKey(details)
|
|
47
62
|
};
|
|
48
63
|
|
|
64
|
+
if (enableFlexibleBlockCard) {
|
|
65
|
+
const ui = {
|
|
66
|
+
hideElevation: true
|
|
67
|
+
};
|
|
68
|
+
const flexibleProps = {
|
|
69
|
+
cardState,
|
|
70
|
+
url,
|
|
71
|
+
testId,
|
|
72
|
+
onError,
|
|
73
|
+
renderers,
|
|
74
|
+
ui
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
switch (status) {
|
|
78
|
+
case 'pending':
|
|
79
|
+
case 'resolving':
|
|
80
|
+
case 'resolved':
|
|
81
|
+
return jsx("div", {
|
|
82
|
+
css: flexibleBlockCardElevationStyle
|
|
83
|
+
}, jsx(FlexibleResolvedView, flexibleProps));
|
|
84
|
+
|
|
85
|
+
case 'unauthorized':
|
|
86
|
+
return jsx("div", {
|
|
87
|
+
css: flexibleBlockCardElevationStyle
|
|
88
|
+
}, jsx(FlexibleUnauthorisedView, _extends({}, flexibleProps, {
|
|
89
|
+
onAuthorize: handleAuthorize
|
|
90
|
+
})));
|
|
91
|
+
|
|
92
|
+
case 'forbidden':
|
|
93
|
+
return jsx("div", {
|
|
94
|
+
css: flexibleBlockCardElevationStyle
|
|
95
|
+
}, jsx(FlexibleForbiddenView, _extends({}, flexibleProps, {
|
|
96
|
+
onAuthorize: handleAuthorize
|
|
97
|
+
})));
|
|
98
|
+
|
|
99
|
+
case 'not_found':
|
|
100
|
+
return jsx("div", {
|
|
101
|
+
css: flexibleBlockCardElevationStyle
|
|
102
|
+
}, jsx(FlexibleNotFoundView, _extends({}, flexibleProps, {
|
|
103
|
+
onAuthorize: handleAuthorize
|
|
104
|
+
})));
|
|
105
|
+
|
|
106
|
+
case 'fallback':
|
|
107
|
+
case 'errored':
|
|
108
|
+
return jsx("div", {
|
|
109
|
+
css: flexibleBlockCardElevationStyle
|
|
110
|
+
}, jsx(FlexibleErroredView, _extends({}, flexibleProps, {
|
|
111
|
+
onAuthorize: handleAuthorize
|
|
112
|
+
})));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
49
116
|
switch (status) {
|
|
50
117
|
case 'pending':
|
|
51
118
|
case 'resolving':
|
|
52
|
-
return
|
|
119
|
+
return jsx(BlockCardResolvingView, {
|
|
53
120
|
testId: testId,
|
|
54
121
|
isSelected: isSelected
|
|
55
122
|
});
|
|
@@ -64,7 +131,7 @@ export const BlockCard = ({
|
|
|
64
131
|
});
|
|
65
132
|
}
|
|
66
133
|
|
|
67
|
-
return
|
|
134
|
+
return jsx(BlockCardResolvedView, _extends({}, resolvedViewProps, {
|
|
68
135
|
isSelected: isSelected,
|
|
69
136
|
testId: testId,
|
|
70
137
|
showActions: showActions,
|
|
@@ -80,7 +147,7 @@ export const BlockCard = ({
|
|
|
80
147
|
}
|
|
81
148
|
|
|
82
149
|
const unauthorizedViewProps = extractBlockProps(data, meta, extractorOpts);
|
|
83
|
-
return
|
|
150
|
+
return jsx(BlockCardUnauthorisedView, _extends({}, unauthorizedViewProps, {
|
|
84
151
|
isSelected: isSelected,
|
|
85
152
|
testId: testId,
|
|
86
153
|
showActions: showActions,
|
|
@@ -103,7 +170,7 @@ export const BlockCard = ({
|
|
|
103
170
|
url,
|
|
104
171
|
context: (_forbiddenViewProps$c = forbiddenViewProps.context) === null || _forbiddenViewProps$c === void 0 ? void 0 : _forbiddenViewProps$c.text
|
|
105
172
|
});
|
|
106
|
-
return
|
|
173
|
+
return jsx(BlockCardForbiddenView, _extends({}, forbiddenViewProps, {
|
|
107
174
|
isSelected: isSelected,
|
|
108
175
|
showActions: showActions,
|
|
109
176
|
actions: handleAuthorize ? [ForbiddenAction(handleAuthorize)] : [],
|
|
@@ -120,7 +187,7 @@ export const BlockCard = ({
|
|
|
120
187
|
}
|
|
121
188
|
|
|
122
189
|
const notFoundViewProps = extractBlockProps(data, meta, extractorOpts);
|
|
123
|
-
return
|
|
190
|
+
return jsx(BlockCardNotFoundView, _extends({}, notFoundViewProps, {
|
|
124
191
|
isSelected: isSelected,
|
|
125
192
|
testId: testId,
|
|
126
193
|
onClick: handleFrameClick
|
|
@@ -137,7 +204,7 @@ export const BlockCard = ({
|
|
|
137
204
|
}
|
|
138
205
|
|
|
139
206
|
if (authFlow && authFlow === 'disabled') {
|
|
140
|
-
return
|
|
207
|
+
return jsx(CardLinkView, {
|
|
141
208
|
link: url,
|
|
142
209
|
isSelected: isSelected,
|
|
143
210
|
onClick: handleFrameClick,
|
|
@@ -145,7 +212,7 @@ export const BlockCard = ({
|
|
|
145
212
|
});
|
|
146
213
|
}
|
|
147
214
|
|
|
148
|
-
return
|
|
215
|
+
return jsx(BlockCardErroredView, {
|
|
149
216
|
link: url,
|
|
150
217
|
isSelected: isSelected,
|
|
151
218
|
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';
|
|
@@ -46,7 +46,7 @@ const FlexibleErroredView = ({
|
|
|
46
46
|
message: {
|
|
47
47
|
descriptor: messages.could_not_load_link
|
|
48
48
|
}
|
|
49
|
-
})), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(
|
|
49
|
+
})), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(BlockCardFooter, {
|
|
50
50
|
actions: actions,
|
|
51
51
|
status: status
|
|
52
52
|
})));
|
|
@@ -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
|
|
|
@@ -48,7 +48,7 @@ const FlexibleForbiddenView = ({
|
|
|
48
48
|
message: {
|
|
49
49
|
descriptor: messages.invalid_permissions_description
|
|
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
|
})));
|
|
@@ -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 @@ const FlexibleNotFoundView = ({
|
|
|
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,81 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import FlexibleCard from '../../../FlexibleCard';
|
|
3
|
+
import TitleBlock from '../../../FlexibleCard/components/blocks/title-block';
|
|
4
|
+
import { FooterBlock, MetadataBlock, PreviewBlock, SnippetBlock } from '../../../FlexibleCard/components/blocks';
|
|
5
|
+
import { ActionName, ElementName, MediaPlacement, SmartLinkPosition } from '../../../../constants';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* This view represents a Block card that has an 'Resolved' status.
|
|
9
|
+
* @see SmartLinkStatus
|
|
10
|
+
* @see FlexibleCardProps
|
|
11
|
+
*/
|
|
12
|
+
const FlexibleResolvedView = ({
|
|
13
|
+
cardState,
|
|
14
|
+
onClick,
|
|
15
|
+
onError,
|
|
16
|
+
testId = 'smart-block-resolved-view',
|
|
17
|
+
ui,
|
|
18
|
+
url
|
|
19
|
+
}) => {
|
|
20
|
+
const [isPreviewBlockErrored, setIsPreviewBlockErrored] = useState(false);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
setIsPreviewBlockErrored(false);
|
|
23
|
+
}, [url, cardState]);
|
|
24
|
+
return /*#__PURE__*/React.createElement(FlexibleCard, {
|
|
25
|
+
appearance: "block",
|
|
26
|
+
cardState: cardState,
|
|
27
|
+
onClick: onClick,
|
|
28
|
+
onError: onError,
|
|
29
|
+
testId: testId,
|
|
30
|
+
ui: ui,
|
|
31
|
+
url: url
|
|
32
|
+
}, /*#__PURE__*/React.createElement(TitleBlock, {
|
|
33
|
+
position: SmartLinkPosition.Center,
|
|
34
|
+
metadata: [{
|
|
35
|
+
name: ElementName.AuthorGroup
|
|
36
|
+
}, {
|
|
37
|
+
name: ElementName.Priority
|
|
38
|
+
}, {
|
|
39
|
+
name: ElementName.State
|
|
40
|
+
}],
|
|
41
|
+
hideRetry: true
|
|
42
|
+
}), /*#__PURE__*/React.createElement(MetadataBlock, {
|
|
43
|
+
primary: [{
|
|
44
|
+
name: ElementName.ModifiedBy
|
|
45
|
+
}, {
|
|
46
|
+
name: ElementName.ModifiedOn
|
|
47
|
+
}],
|
|
48
|
+
secondary: [{
|
|
49
|
+
name: ElementName.AttachmentCount
|
|
50
|
+
}, {
|
|
51
|
+
name: ElementName.CommentCount
|
|
52
|
+
}, {
|
|
53
|
+
name: ElementName.ReactCount
|
|
54
|
+
}, {
|
|
55
|
+
name: ElementName.SubscriberCount
|
|
56
|
+
}, {
|
|
57
|
+
name: ElementName.ViewCount
|
|
58
|
+
}, {
|
|
59
|
+
name: ElementName.VoteCount
|
|
60
|
+
}, {
|
|
61
|
+
name: ElementName.DueOn
|
|
62
|
+
}],
|
|
63
|
+
maxLines: 1
|
|
64
|
+
}), /*#__PURE__*/React.createElement(MetadataBlock, null), /*#__PURE__*/React.createElement(SnippetBlock, null), !isPreviewBlockErrored ? /*#__PURE__*/React.createElement(PreviewBlock, {
|
|
65
|
+
placement: MediaPlacement.Right,
|
|
66
|
+
ignoreContainerPadding: true,
|
|
67
|
+
onError: () => {
|
|
68
|
+
setIsPreviewBlockErrored(true);
|
|
69
|
+
}
|
|
70
|
+
}) : null, /*#__PURE__*/React.createElement(FooterBlock, {
|
|
71
|
+
actions: [{
|
|
72
|
+
name: ActionName.PreviewAction
|
|
73
|
+
}, {
|
|
74
|
+
name: ActionName.ViewAction
|
|
75
|
+
}, {
|
|
76
|
+
name: ActionName.DownloadAction
|
|
77
|
+
}]
|
|
78
|
+
}));
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
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
|
const FlexibleUnauthorisedView = ({
|
|
18
18
|
cardState,
|
|
@@ -44,7 +44,7 @@ const FlexibleUnauthorisedView = ({
|
|
|
44
44
|
context: providerName
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
})), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(
|
|
47
|
+
})), /*#__PURE__*/React.createElement(CustomBlock, null, /*#__PURE__*/React.createElement(BlockCardFooter, {
|
|
48
48
|
actions: actions,
|
|
49
49
|
status: status
|
|
50
50
|
})));
|