@atlaskit/smart-card 18.0.12 → 18.0.15
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 +25 -0
- package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +9 -0
- package/dist/cjs/state/flexible-ui-context/index.js +4 -0
- package/dist/cjs/utils/analytics/analytics.js +52 -2
- package/dist/cjs/utils/analytics/index.js +18 -0
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/CardWithUrl/component.js +4 -2
- package/dist/cjs/view/CardWithUrl/loader.js +4 -2
- package/dist/cjs/view/FlexibleCard/components/actions/action/index.js +26 -4
- package/dist/cjs/view/FlexibleCard/components/actions/index.js +18 -2
- package/dist/cjs/view/FlexibleCard/components/blocks/action-group/index.js +6 -0
- package/dist/cjs/view/FlexibleCard/components/blocks/block/index.js +9 -2
- package/dist/cjs/view/FlexibleCard/components/blocks/element-group/index.js +9 -2
- package/dist/cjs/view/FlexibleCard/components/blocks/footer-block/index.js +6 -0
- package/dist/cjs/view/FlexibleCard/components/blocks/metadata-block/index.js +9 -2
- package/dist/cjs/view/FlexibleCard/components/blocks/preview-block/index.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/blocks/snippet-block/index.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/blocks/title-block/errored/index.js +39 -19
- package/dist/cjs/view/FlexibleCard/components/blocks/title-block/index.js +92 -17
- package/dist/cjs/view/FlexibleCard/components/blocks/title-block/resolved/index.js +45 -9
- package/dist/cjs/view/FlexibleCard/components/blocks/title-block/resolving/index.js +23 -12
- package/dist/cjs/view/FlexibleCard/components/container/index.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/elements/avatar-group/index.js +12 -1
- package/dist/cjs/view/FlexibleCard/components/elements/badge/index.js +18 -3
- package/dist/cjs/view/FlexibleCard/components/elements/date-time/index.js +9 -1
- package/dist/cjs/view/FlexibleCard/components/elements/icon/index.js +9 -1
- package/dist/cjs/view/FlexibleCard/components/elements/index.js +96 -0
- package/dist/cjs/view/FlexibleCard/components/elements/link/index.js +9 -1
- package/dist/cjs/view/FlexibleCard/components/elements/lozenge/index.js +11 -3
- package/dist/cjs/view/FlexibleCard/components/elements/media/index.js +9 -2
- package/dist/cjs/view/FlexibleCard/components/elements/text/index.js +12 -6
- package/dist/cjs/view/FlexibleCard/components/elements/utils.js +7 -3
- package/dist/cjs/view/FlexibleCard/index.js +6 -0
- package/dist/cjs/view/HoverCard/index.js +48 -10
- package/dist/cjs/view/HoverCard/styled.js +3 -1
- package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +7 -2
- package/dist/es2019/state/flexible-ui-context/index.js +5 -0
- package/dist/es2019/utils/analytics/analytics.js +35 -0
- package/dist/es2019/utils/analytics/index.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/CardWithUrl/component.js +4 -2
- package/dist/es2019/view/CardWithUrl/loader.js +4 -2
- package/dist/es2019/view/FlexibleCard/components/actions/action/index.js +37 -4
- package/dist/es2019/view/FlexibleCard/components/actions/index.js +18 -2
- package/dist/es2019/view/FlexibleCard/components/blocks/action-group/index.js +6 -0
- package/dist/es2019/view/FlexibleCard/components/blocks/block/index.js +9 -2
- package/dist/es2019/view/FlexibleCard/components/blocks/element-group/index.js +8 -2
- package/dist/es2019/view/FlexibleCard/components/blocks/footer-block/index.js +6 -0
- package/dist/es2019/view/FlexibleCard/components/blocks/metadata-block/index.js +9 -2
- package/dist/es2019/view/FlexibleCard/components/blocks/preview-block/index.js +5 -0
- package/dist/es2019/view/FlexibleCard/components/blocks/snippet-block/index.js +5 -0
- package/dist/es2019/view/FlexibleCard/components/blocks/title-block/errored/index.js +31 -15
- package/dist/es2019/view/FlexibleCard/components/blocks/title-block/index.js +77 -15
- package/dist/es2019/view/FlexibleCard/components/blocks/title-block/resolved/index.js +35 -8
- package/dist/es2019/view/FlexibleCard/components/blocks/title-block/resolving/index.js +20 -11
- package/dist/es2019/view/FlexibleCard/components/container/index.js +5 -0
- package/dist/es2019/view/FlexibleCard/components/elements/avatar-group/index.js +12 -1
- package/dist/es2019/view/FlexibleCard/components/elements/badge/index.js +18 -3
- package/dist/es2019/view/FlexibleCard/components/elements/date-time/index.js +9 -1
- package/dist/es2019/view/FlexibleCard/components/elements/icon/index.js +9 -1
- package/dist/es2019/view/FlexibleCard/components/elements/index.js +96 -0
- package/dist/es2019/view/FlexibleCard/components/elements/link/index.js +9 -1
- package/dist/es2019/view/FlexibleCard/components/elements/lozenge/index.js +11 -3
- package/dist/es2019/view/FlexibleCard/components/elements/media/index.js +8 -1
- package/dist/es2019/view/FlexibleCard/components/elements/text/index.js +11 -4
- package/dist/es2019/view/FlexibleCard/components/elements/utils.js +5 -2
- package/dist/es2019/view/FlexibleCard/index.js +6 -0
- package/dist/es2019/view/HoverCard/index.js +40 -10
- package/dist/es2019/view/HoverCard/styled.js +6 -1
- package/dist/esm/state/analytics/useSmartLinkAnalytics.js +10 -1
- package/dist/esm/state/flexible-ui-context/index.js +5 -0
- package/dist/esm/utils/analytics/analytics.js +41 -0
- package/dist/esm/utils/analytics/index.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/CardWithUrl/component.js +4 -2
- package/dist/esm/view/CardWithUrl/loader.js +4 -2
- package/dist/esm/view/FlexibleCard/components/actions/action/index.js +25 -4
- package/dist/esm/view/FlexibleCard/components/actions/index.js +18 -2
- package/dist/esm/view/FlexibleCard/components/blocks/action-group/index.js +6 -0
- package/dist/esm/view/FlexibleCard/components/blocks/block/index.js +9 -2
- package/dist/esm/view/FlexibleCard/components/blocks/element-group/index.js +8 -2
- package/dist/esm/view/FlexibleCard/components/blocks/footer-block/index.js +6 -0
- package/dist/esm/view/FlexibleCard/components/blocks/metadata-block/index.js +9 -2
- package/dist/esm/view/FlexibleCard/components/blocks/preview-block/index.js +5 -0
- package/dist/esm/view/FlexibleCard/components/blocks/snippet-block/index.js +5 -0
- package/dist/esm/view/FlexibleCard/components/blocks/title-block/errored/index.js +33 -16
- package/dist/esm/view/FlexibleCard/components/blocks/title-block/index.js +79 -17
- package/dist/esm/view/FlexibleCard/components/blocks/title-block/resolved/index.js +39 -8
- package/dist/esm/view/FlexibleCard/components/blocks/title-block/resolving/index.js +22 -11
- package/dist/esm/view/FlexibleCard/components/container/index.js +5 -0
- package/dist/esm/view/FlexibleCard/components/elements/avatar-group/index.js +12 -1
- package/dist/esm/view/FlexibleCard/components/elements/badge/index.js +18 -3
- package/dist/esm/view/FlexibleCard/components/elements/date-time/index.js +9 -1
- package/dist/esm/view/FlexibleCard/components/elements/icon/index.js +9 -1
- package/dist/esm/view/FlexibleCard/components/elements/index.js +96 -0
- package/dist/esm/view/FlexibleCard/components/elements/link/index.js +9 -1
- package/dist/esm/view/FlexibleCard/components/elements/lozenge/index.js +11 -3
- package/dist/esm/view/FlexibleCard/components/elements/media/index.js +9 -2
- package/dist/esm/view/FlexibleCard/components/elements/text/index.js +12 -6
- package/dist/esm/view/FlexibleCard/components/elements/utils.js +5 -3
- package/dist/esm/view/FlexibleCard/index.js +6 -0
- package/dist/esm/view/HoverCard/index.js +42 -10
- package/dist/esm/view/HoverCard/styled.js +2 -1
- package/dist/types/client/errors.d.ts +3 -2
- package/dist/types/extractors/block/index.d.ts +2 -2
- package/dist/types/extractors/common/__mocks__/jsonld.d.ts +46 -66
- package/dist/types/extractors/common/actions/extractPreviewAction.d.ts +1 -1
- package/dist/types/extractors/common/title-prefix/extractTitlePrefix.d.ts +2 -1
- package/dist/types/extractors/embed/index.d.ts +1 -1
- package/dist/types/extractors/flexible/icon/extract-url-icon.d.ts +1 -1
- package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +4 -0
- package/dist/types/state/flexible-ui-context/index.d.ts +4 -0
- package/dist/types/state/flexible-ui-context/types.d.ts +102 -0
- package/dist/types/state/hooks/useSmartLink.d.ts +3 -0
- package/dist/types/utils/analytics/analytics.d.ts +5 -1
- package/dist/types/utils/analytics/index.d.ts +1 -1
- package/dist/types/utils/types.d.ts +2 -2
- package/dist/types/view/BlockCard/utils/handlers.d.ts +1 -1
- package/dist/types/view/Card/index.d.ts +1 -1
- package/dist/types/view/Card/types.d.ts +1 -0
- package/dist/types/view/CardWithUrl/component.d.ts +1 -1
- package/dist/types/view/CardWithUrl/types.d.ts +1 -0
- package/dist/types/view/EmbedCard/components/styled.d.ts +9 -9
- package/dist/types/view/FlexibleCard/components/actions/action/index.d.ts +8 -0
- package/dist/types/view/FlexibleCard/components/actions/action/types.d.ts +4 -2
- package/dist/types/view/FlexibleCard/components/actions/index.d.ts +15 -0
- package/dist/types/view/FlexibleCard/components/blocks/action-group/index.d.ts +6 -0
- package/dist/types/view/FlexibleCard/components/blocks/action-group/types.d.ts +1 -1
- package/dist/types/view/FlexibleCard/components/blocks/block/index.d.ts +6 -0
- package/dist/types/view/FlexibleCard/components/blocks/element-group/index.d.ts +6 -0
- package/dist/types/view/FlexibleCard/components/blocks/element-group/types.d.ts +2 -2
- package/dist/types/view/FlexibleCard/components/blocks/footer-block/index.d.ts +6 -0
- package/dist/types/view/FlexibleCard/components/blocks/metadata-block/index.d.ts +6 -0
- package/dist/types/view/FlexibleCard/components/blocks/preview-block/index.d.ts +5 -0
- package/dist/types/view/FlexibleCard/components/blocks/snippet-block/index.d.ts +5 -0
- package/dist/types/view/FlexibleCard/components/blocks/title-block/errored/index.d.ts +9 -2
- package/dist/types/view/FlexibleCard/components/blocks/title-block/index.d.ts +11 -0
- package/dist/types/view/FlexibleCard/components/blocks/title-block/resolved/index.d.ts +7 -3
- package/dist/types/view/FlexibleCard/components/blocks/title-block/resolving/index.d.ts +8 -2
- package/dist/types/view/FlexibleCard/components/blocks/title-block/types.d.ts +10 -1
- package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +7 -5
- package/dist/types/view/FlexibleCard/components/blocks/utils.d.ts +2 -1
- package/dist/types/view/FlexibleCard/components/container/index.d.ts +4 -0
- package/dist/types/view/FlexibleCard/components/container/types.d.ts +2 -2
- package/dist/types/view/FlexibleCard/components/elements/avatar-group/index.d.ts +7 -0
- package/dist/types/view/FlexibleCard/components/elements/badge/index.d.ts +13 -0
- package/dist/types/view/FlexibleCard/components/elements/date-time/index.d.ts +7 -0
- package/dist/types/view/FlexibleCard/components/elements/icon/index.d.ts +6 -0
- package/dist/types/view/FlexibleCard/components/elements/icon/types.d.ts +5 -1
- package/dist/types/view/FlexibleCard/components/elements/index.d.ts +77 -0
- package/dist/types/view/FlexibleCard/components/elements/link/index.d.ts +6 -0
- package/dist/types/view/FlexibleCard/components/elements/lozenge/index.d.ts +6 -0
- package/dist/types/view/FlexibleCard/components/elements/media/index.d.ts +6 -0
- package/dist/types/view/FlexibleCard/components/elements/text/index.d.ts +6 -0
- package/dist/types/view/FlexibleCard/components/elements/text/types.d.ts +1 -2
- package/dist/types/view/FlexibleCard/components/elements/types.d.ts +2 -0
- package/dist/types/view/FlexibleCard/index.d.ts +6 -0
- package/dist/types/view/HoverCard/index.d.ts +3 -2
- package/dist/types/view/HoverCard/types.d.ts +5 -2
- package/dist/types/view/InlineCard/Icon.d.ts +3 -3
- package/dist/types/view/InlineCard/IconAndTitleLayout/styled.d.ts +9 -9
- package/dist/types/view/InlineCard/ResolvingView/styled.d.ts +3 -3
- package/dist/types/view/InlineCard/styled.d.ts +4 -4
- package/package.json +8 -8
- package/dist/cjs/view/FlexibleCard/components/blocks/title-block/utils.js +0 -105
- package/dist/es2019/view/FlexibleCard/components/blocks/title-block/utils.js +0 -71
- package/dist/esm/view/FlexibleCard/components/blocks/title-block/utils.js +0 -76
- package/dist/types/view/FlexibleCard/components/blocks/title-block/utils.d.ts +0 -11
|
@@ -4,11 +4,12 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { FormattedMessage } from 'react-intl-next';
|
|
6
6
|
import { css, jsx } from '@emotion/core';
|
|
7
|
+
import { LinkIcon } from '../../../elements';
|
|
8
|
+
import Block from '../../block';
|
|
7
9
|
import { SmartLinkAlignment, SmartLinkDirection, SmartLinkSize } from '../../../../../../constants';
|
|
8
10
|
import { getLinkLineHeight, getLinkSizeStyles, getTruncateStyles } from '../../../utils';
|
|
9
11
|
import ElementGroup from '../../element-group';
|
|
10
12
|
import { tokens } from '../../../../../../utils/token';
|
|
11
|
-
import { BaseTitleBlockComponent } from '../utils';
|
|
12
13
|
const actionStyles = css`
|
|
13
14
|
cursor: pointer;
|
|
14
15
|
:hover {
|
|
@@ -28,31 +29,46 @@ const getMessageStyles = (size, hasAction) => {
|
|
|
28
29
|
color: ${tokens.errorMessage};
|
|
29
30
|
`;
|
|
30
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* Represents an Errored TitleBlock view.
|
|
34
|
+
* This will render when a Smart Link did not successfully resolve.
|
|
35
|
+
* This may be a result of a Smart Link not having the correct credentials,
|
|
36
|
+
* or the backend response was errored or malformed.
|
|
37
|
+
* @see TitleBlock
|
|
38
|
+
*/
|
|
31
39
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
|
|
41
|
+
const TitleBlockErroredView = ({
|
|
42
|
+
actionGroup,
|
|
43
|
+
retry,
|
|
44
|
+
position,
|
|
45
|
+
testId,
|
|
46
|
+
title,
|
|
47
|
+
...blockProps
|
|
48
|
+
}) => {
|
|
38
49
|
const {
|
|
39
|
-
descriptor
|
|
50
|
+
descriptor,
|
|
40
51
|
onClick,
|
|
41
|
-
values
|
|
52
|
+
values
|
|
42
53
|
} = retry || {};
|
|
54
|
+
const {
|
|
55
|
+
size = SmartLinkSize.Medium
|
|
56
|
+
} = blockProps;
|
|
43
57
|
const hasAction = onClick !== undefined;
|
|
44
|
-
return jsx(
|
|
45
|
-
|
|
46
|
-
}),
|
|
58
|
+
return jsx(Block, _extends({}, blockProps, {
|
|
59
|
+
testId: `${testId}-errored-view`
|
|
60
|
+
}), jsx(LinkIcon, {
|
|
61
|
+
position: position
|
|
62
|
+
}), title, descriptor && jsx(ElementGroup, {
|
|
47
63
|
direction: SmartLinkDirection.Horizontal,
|
|
48
64
|
align: SmartLinkAlignment.Right
|
|
49
65
|
}, jsx("span", {
|
|
50
66
|
css: getMessageStyles(size, hasAction),
|
|
51
67
|
onClick: onClick,
|
|
52
68
|
"data-testid": `${testId}-errored-view-message`
|
|
53
|
-
}, jsx(FormattedMessage, _extends({},
|
|
54
|
-
values:
|
|
55
|
-
})))));
|
|
69
|
+
}, jsx(FormattedMessage, _extends({}, descriptor, {
|
|
70
|
+
values: values
|
|
71
|
+
})))), actionGroup);
|
|
56
72
|
};
|
|
57
73
|
|
|
58
74
|
export default TitleBlockErroredView;
|
|
@@ -1,26 +1,37 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import { css } from '@emotion/core';
|
|
3
4
|
import { SmartLinkStatus } from '../../../../../constants';
|
|
4
5
|
import TitleBlockResolvedView from './resolved';
|
|
5
6
|
import TitleBlockErroredView from './errored';
|
|
6
7
|
import TitleBlockResolvingView from './resolving';
|
|
8
|
+
import ActionGroup from '../action-group';
|
|
9
|
+
import { Title } from '../../elements';
|
|
7
10
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const getActionStyles = (showOnHover, isOpen) => {
|
|
12
|
+
if (showOnHover && !isOpen) {
|
|
13
|
+
return css`
|
|
14
|
+
.actions-button-group {
|
|
15
|
+
visibility: hidden;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&:hover {
|
|
19
|
+
.actions-button-group {
|
|
20
|
+
visibility: visible;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const getTitleBlockViewComponent = status => {
|
|
13
28
|
switch (status) {
|
|
14
29
|
case SmartLinkStatus.Pending:
|
|
15
30
|
case SmartLinkStatus.Resolving:
|
|
16
|
-
return
|
|
17
|
-
testId: testId
|
|
18
|
-
}));
|
|
31
|
+
return TitleBlockResolvingView;
|
|
19
32
|
|
|
20
33
|
case SmartLinkStatus.Resolved:
|
|
21
|
-
return
|
|
22
|
-
testId: testId
|
|
23
|
-
}));
|
|
34
|
+
return TitleBlockResolvedView;
|
|
24
35
|
|
|
25
36
|
case SmartLinkStatus.Unauthorized:
|
|
26
37
|
case SmartLinkStatus.Forbidden:
|
|
@@ -28,10 +39,61 @@ const TitleBlock = ({
|
|
|
28
39
|
case SmartLinkStatus.Errored:
|
|
29
40
|
case SmartLinkStatus.Fallback:
|
|
30
41
|
default:
|
|
31
|
-
return
|
|
32
|
-
testId: testId
|
|
33
|
-
}));
|
|
42
|
+
return TitleBlockErroredView;
|
|
34
43
|
}
|
|
35
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* Represents a TitleBlock, which is the foundation of all Flexible Smart Links.
|
|
47
|
+
* This contains an icon, the link, and any associated metadata and actions in one block.
|
|
48
|
+
* The TitleBlock will also render differently given the state of the smart link.
|
|
49
|
+
* This can be found in the corresponding Resolving, Resolved and Errored views.
|
|
50
|
+
* @param {TitleBlockProps} TitleBlockProps
|
|
51
|
+
* @see Block
|
|
52
|
+
* @see TitleBlockResolvingView
|
|
53
|
+
* @see TitleBlockResolvedView
|
|
54
|
+
* @see TitleBlockErroredView
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
const TitleBlock = ({
|
|
59
|
+
actions = [],
|
|
60
|
+
anchorTarget,
|
|
61
|
+
maxLines,
|
|
62
|
+
onClick,
|
|
63
|
+
overrideCss,
|
|
64
|
+
status = SmartLinkStatus.Fallback,
|
|
65
|
+
showActionOnHover,
|
|
66
|
+
testId = 'smart-block-title',
|
|
67
|
+
text,
|
|
68
|
+
theme,
|
|
69
|
+
...props
|
|
70
|
+
}) => {
|
|
71
|
+
const [actionDropdownOpen, setActionDropdownOpen] = useState(false);
|
|
72
|
+
const actionGroup = actions.length > 0 && /*#__PURE__*/React.createElement(ActionGroup, {
|
|
73
|
+
items: actions,
|
|
74
|
+
visibleButtonsNum: showActionOnHover ? 1 : 2,
|
|
75
|
+
onDropdownOpenChange: isOpen => setActionDropdownOpen(isOpen)
|
|
76
|
+
});
|
|
77
|
+
const actionStyles = getActionStyles(showActionOnHover, actionDropdownOpen);
|
|
78
|
+
const combinedCss = css`
|
|
79
|
+
${actionStyles} ${overrideCss}
|
|
80
|
+
`;
|
|
81
|
+
const overrideText = !!text ? {
|
|
82
|
+
text
|
|
83
|
+
} : {};
|
|
84
|
+
const title = /*#__PURE__*/React.createElement(Title, _extends({
|
|
85
|
+
maxLines: maxLines,
|
|
86
|
+
onClick: onClick,
|
|
87
|
+
target: anchorTarget,
|
|
88
|
+
theme: theme
|
|
89
|
+
}, overrideText));
|
|
90
|
+
const Component = getTitleBlockViewComponent(status);
|
|
91
|
+
return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
|
|
92
|
+
actionGroup: actionGroup,
|
|
93
|
+
overrideCss: combinedCss,
|
|
94
|
+
testId: testId,
|
|
95
|
+
title: title
|
|
96
|
+
}));
|
|
97
|
+
};
|
|
36
98
|
|
|
37
99
|
export default TitleBlock;
|
|
@@ -1,14 +1,41 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
|
|
3
|
-
/** @jsx jsx */
|
|
4
2
|
import React from 'react';
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
3
|
+
import { LinkIcon } from '../../../elements';
|
|
4
|
+
import Block from '../../block';
|
|
5
|
+
import ElementGroup from '../../element-group';
|
|
6
|
+
import { SmartLinkAlignment, SmartLinkDirection, SmartLinkWidth } from '../../../../../../constants';
|
|
7
|
+
import { renderElementItems } from '../../utils';
|
|
8
|
+
/**
|
|
9
|
+
* This renders a fully resolved TitleBlock.
|
|
10
|
+
* This should render when a Smart Link returns a valid response.
|
|
11
|
+
* @see TitleBlock
|
|
12
|
+
*/
|
|
7
13
|
|
|
8
|
-
const TitleBlockResolvedView =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
const TitleBlockResolvedView = ({
|
|
15
|
+
actionGroup,
|
|
16
|
+
metadata = [],
|
|
17
|
+
position,
|
|
18
|
+
subtitle = [],
|
|
19
|
+
testId,
|
|
20
|
+
text,
|
|
21
|
+
title,
|
|
22
|
+
...blockProps
|
|
23
|
+
}) => {
|
|
24
|
+
const metadataElements = renderElementItems(metadata);
|
|
25
|
+
const subtitleElements = renderElementItems(subtitle);
|
|
26
|
+
return /*#__PURE__*/React.createElement(Block, _extends({}, blockProps, {
|
|
27
|
+
testId: `${testId}-resolved-view`
|
|
28
|
+
}), /*#__PURE__*/React.createElement(LinkIcon, {
|
|
29
|
+
position: position
|
|
30
|
+
}), /*#__PURE__*/React.createElement(ElementGroup, {
|
|
31
|
+
direction: SmartLinkDirection.Vertical,
|
|
32
|
+
width: SmartLinkWidth.Flexible
|
|
33
|
+
}, title, subtitleElements && /*#__PURE__*/React.createElement(ElementGroup, {
|
|
34
|
+
direction: SmartLinkDirection.Horizontal
|
|
35
|
+
}, subtitleElements)), metadataElements && /*#__PURE__*/React.createElement(ElementGroup, {
|
|
36
|
+
direction: SmartLinkDirection.Horizontal,
|
|
37
|
+
align: SmartLinkAlignment.Right
|
|
38
|
+
}, metadataElements), actionGroup);
|
|
12
39
|
};
|
|
13
40
|
|
|
14
41
|
export default TitleBlockResolvedView;
|
|
@@ -4,8 +4,8 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { jsx } from '@emotion/core';
|
|
6
6
|
import Spinner from '@atlaskit/spinner';
|
|
7
|
+
import Block from '../../block';
|
|
7
8
|
import { SmartLinkSize } from '../../../../../../constants';
|
|
8
|
-
import { BaseTitleBlockComponent } from '../utils';
|
|
9
9
|
|
|
10
10
|
const getSpinnerSize = size => {
|
|
11
11
|
// Spinner sizes should be equivalent or smaller than Icon size
|
|
@@ -25,20 +25,29 @@ const getSpinnerSize = size => {
|
|
|
25
25
|
return 12;
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* This represents a TitleBlock for a Smart Link that is currently waiting
|
|
30
|
+
* for a request to finish.
|
|
31
|
+
* This should render when a Smart Link has sent a request.
|
|
32
|
+
* @see TitleBlock
|
|
33
|
+
*/
|
|
28
34
|
|
|
29
|
-
|
|
35
|
+
|
|
36
|
+
const TitleBlockResolvingView = ({
|
|
37
|
+
actionGroup,
|
|
38
|
+
testId,
|
|
39
|
+
title,
|
|
40
|
+
...blockProps
|
|
41
|
+
}) => {
|
|
30
42
|
const {
|
|
31
|
-
size = SmartLinkSize.Medium
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
43
|
+
size = SmartLinkSize.Medium
|
|
44
|
+
} = blockProps;
|
|
45
|
+
return jsx(Block, _extends({}, blockProps, {
|
|
46
|
+
testId: `${testId}-resolving-view`
|
|
47
|
+
}), jsx(Spinner, {
|
|
35
48
|
size: getSpinnerSize(size),
|
|
36
49
|
testId: `${testId}-resolving-spinner`
|
|
37
|
-
});
|
|
38
|
-
return jsx(BaseTitleBlockComponent, _extends({}, props, {
|
|
39
|
-
blockIcon: spinnerIcon,
|
|
40
|
-
blockTestIdPostfix: "resolving-view"
|
|
41
|
-
}));
|
|
50
|
+
}), title, actionGroup);
|
|
42
51
|
};
|
|
43
52
|
|
|
44
53
|
export default TitleBlockResolvingView;
|
|
@@ -70,6 +70,11 @@ const renderChildren = (children, containerSize, containerTheme, status, retry,
|
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
});
|
|
73
|
+
/**
|
|
74
|
+
* This represents the container in which all Flexible UI Smart Links are rendered.
|
|
75
|
+
* @see Block
|
|
76
|
+
*/
|
|
77
|
+
|
|
73
78
|
|
|
74
79
|
const Container = ({
|
|
75
80
|
children,
|
|
@@ -26,10 +26,19 @@ const getStyles = size => {
|
|
|
26
26
|
`;
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* An element that displays a group of avatars.
|
|
31
|
+
* @public
|
|
32
|
+
* @param {AvatarGroupProps} AvatarGroupProps - The props necessary for the AvatarGroup.
|
|
33
|
+
* @see AuthorGroup
|
|
34
|
+
* @see CollaboratorGroup
|
|
35
|
+
*/
|
|
36
|
+
|
|
29
37
|
|
|
30
38
|
const AvatarGroup = ({
|
|
31
39
|
items = [],
|
|
32
40
|
maxCount = MAX_COUNT,
|
|
41
|
+
overrideCss,
|
|
33
42
|
size = SmartLinkSize.Medium,
|
|
34
43
|
testId = 'smart-element-avatar-group'
|
|
35
44
|
}) => {
|
|
@@ -38,7 +47,9 @@ const AvatarGroup = ({
|
|
|
38
47
|
}
|
|
39
48
|
|
|
40
49
|
return jsx("span", {
|
|
41
|
-
css: getStyles(size)
|
|
50
|
+
css: [getStyles(size), overrideCss],
|
|
51
|
+
"data-smart-element-avatar-group": true,
|
|
52
|
+
"data-testid": testId
|
|
42
53
|
}, jsx(AtlaskitAvatarGroup, {
|
|
43
54
|
maxCount: maxCount,
|
|
44
55
|
appearance: "stack",
|
|
@@ -70,12 +70,27 @@ const renderImageIcon = (url, testId) => {
|
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
|
+
/**
|
|
74
|
+
* An element that displays some text with an associated icon.
|
|
75
|
+
* @public
|
|
76
|
+
* @param {BadgeProps} BadgeProps - The props necessary for the Badge.
|
|
77
|
+
* @see CommentCount
|
|
78
|
+
* @see ViewCount
|
|
79
|
+
* @see ReactCount
|
|
80
|
+
* @see VoteCount
|
|
81
|
+
* @see SubscriberCount
|
|
82
|
+
* @see Priority
|
|
83
|
+
* @see ProgrammingLanguage
|
|
84
|
+
* @see Provider
|
|
85
|
+
*/
|
|
86
|
+
|
|
73
87
|
|
|
74
88
|
const Badge = ({
|
|
75
89
|
icon,
|
|
76
|
-
url,
|
|
77
90
|
label,
|
|
78
|
-
|
|
91
|
+
overrideCss,
|
|
92
|
+
testId = 'smart-element-badge',
|
|
93
|
+
url
|
|
79
94
|
}) => {
|
|
80
95
|
const formattedMessageOrLabel = getFormattedMessageFromIcon(icon) || label;
|
|
81
96
|
const badgeIcon = renderAtlaskitIcon(icon, testId) || renderImageIcon(url, testId);
|
|
@@ -85,7 +100,7 @@ const Badge = ({
|
|
|
85
100
|
}
|
|
86
101
|
|
|
87
102
|
return jsx("div", {
|
|
88
|
-
css: badgeStyles,
|
|
103
|
+
css: [badgeStyles, overrideCss],
|
|
89
104
|
"data-fit-to-content": true,
|
|
90
105
|
"data-smart-element-badge": true,
|
|
91
106
|
"data-testid": testId
|
|
@@ -18,9 +18,17 @@ const typeToDescriptorMap = {
|
|
|
18
18
|
created: messages.created_on,
|
|
19
19
|
modified: messages.modified_on
|
|
20
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* An element that displays an ISO Timestamp in text.
|
|
23
|
+
* @public
|
|
24
|
+
* @param {DateTimeProps} DateTimeProps - The props necessary for the DateTime element.
|
|
25
|
+
* @see CreatedOn
|
|
26
|
+
* @see ModifiedOn
|
|
27
|
+
*/
|
|
21
28
|
|
|
22
29
|
const DateTime = ({
|
|
23
30
|
date,
|
|
31
|
+
overrideCss,
|
|
24
32
|
type,
|
|
25
33
|
testId = 'smart-element-date-time'
|
|
26
34
|
}) => {
|
|
@@ -40,7 +48,7 @@ const DateTime = ({
|
|
|
40
48
|
numeric: 'auto'
|
|
41
49
|
});
|
|
42
50
|
return jsx("span", {
|
|
43
|
-
css: styles,
|
|
51
|
+
css: [styles, overrideCss],
|
|
44
52
|
"data-separator": true,
|
|
45
53
|
"data-smart-element-date-time": true,
|
|
46
54
|
"data-testid": testId
|
|
@@ -83,11 +83,19 @@ const renderImageIcon = (defaultIcon, icon, url, testId) => {
|
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
|
+
/**
|
|
87
|
+
* An element that displays an Icon or favicon.
|
|
88
|
+
* @public
|
|
89
|
+
* @param {IconProps} IconProps - The props necessary for the Icon element.
|
|
90
|
+
* @see LinkIcon
|
|
91
|
+
*/
|
|
92
|
+
|
|
86
93
|
|
|
87
94
|
const Icon = ({
|
|
88
95
|
icon,
|
|
89
96
|
label = 'Link',
|
|
90
97
|
position = SmartLinkPosition.Top,
|
|
98
|
+
overrideCss,
|
|
91
99
|
render,
|
|
92
100
|
size = SmartLinkSize.Medium,
|
|
93
101
|
testId = 'smart-element-icon',
|
|
@@ -101,7 +109,7 @@ const Icon = ({
|
|
|
101
109
|
const styles = getIconStyles(size, position, width);
|
|
102
110
|
const renderStyles = render ? getCustomRenderStyles(width) : undefined;
|
|
103
111
|
return jsx("div", {
|
|
104
|
-
css: [styles, renderStyles],
|
|
112
|
+
css: [styles, renderStyles, overrideCss],
|
|
105
113
|
"data-fit-to-content": true,
|
|
106
114
|
"data-smart-element-icon": true,
|
|
107
115
|
"data-testid": testId
|
|
@@ -3,22 +3,118 @@ import { ElementName } from '../../../../constants';
|
|
|
3
3
|
// Attention: Keep the export name and element name the same.
|
|
4
4
|
// This will help reducing the code for mapping elements inside
|
|
5
5
|
// createElement and renderElementItems
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Creates an AvatarGroup element using the data from AuthorGroup in the Flexible UI Context.
|
|
9
|
+
* @see AvatarGroup
|
|
10
|
+
*/
|
|
6
11
|
export const AuthorGroup = createElement(ElementName.AuthorGroup);
|
|
12
|
+
/**
|
|
13
|
+
* Creates an AvatarGroup element using the data from CollaboratorGroup in the Flexible UI Context.
|
|
14
|
+
* @see AvatarGroup
|
|
15
|
+
*/
|
|
16
|
+
|
|
7
17
|
export const CollaboratorGroup = createElement(ElementName.CollaboratorGroup);
|
|
18
|
+
/**
|
|
19
|
+
* Creates a CommentCount Badge element using the data from CommentCount in the Flexible UI Context.
|
|
20
|
+
* @see Badge
|
|
21
|
+
*/
|
|
22
|
+
|
|
8
23
|
export const CommentCount = createElement(ElementName.CommentCount);
|
|
24
|
+
/**
|
|
25
|
+
* Creates a ViewCount Badge element using the data from ViewCount in the Flexible UI Context.
|
|
26
|
+
* @see Badge
|
|
27
|
+
*/
|
|
28
|
+
|
|
9
29
|
export const ViewCount = createElement(ElementName.ViewCount);
|
|
30
|
+
/**
|
|
31
|
+
* Creates a ReactCount Badge element using the data from ReactCount in the Flexible UI Context.
|
|
32
|
+
* @see Badge
|
|
33
|
+
*/
|
|
34
|
+
|
|
10
35
|
export const ReactCount = createElement(ElementName.ReactCount);
|
|
36
|
+
/**
|
|
37
|
+
* Creates a VoteCount Badge element using the data from VoteCount in the Flexible UI Context.
|
|
38
|
+
* @see Badge
|
|
39
|
+
*/
|
|
40
|
+
|
|
11
41
|
export const VoteCount = createElement(ElementName.VoteCount);
|
|
42
|
+
/**
|
|
43
|
+
* Creates a CreatedBy text element using the data from CreatedBy in the Flexible UI Context.
|
|
44
|
+
* @see Text
|
|
45
|
+
*/
|
|
46
|
+
|
|
12
47
|
export const CreatedBy = createElement(ElementName.CreatedBy);
|
|
48
|
+
/**
|
|
49
|
+
* Creates a CreatedOn DateTime element using the data from CreatedOn in the Flexible UI Context.
|
|
50
|
+
* @see DateTime
|
|
51
|
+
*/
|
|
52
|
+
|
|
13
53
|
export const CreatedOn = createElement(ElementName.CreatedOn);
|
|
54
|
+
/**
|
|
55
|
+
* Creates a LinkIcon Icon element using the data from LinkIcon in the Flexible UI Context.
|
|
56
|
+
* @see Icon
|
|
57
|
+
*/
|
|
58
|
+
|
|
14
59
|
export const LinkIcon = createElement(ElementName.LinkIcon);
|
|
60
|
+
/**
|
|
61
|
+
* Creates a ModifiedBy Text element using the data from ModifiedBy in the Flexible UI Context.
|
|
62
|
+
* @see Text
|
|
63
|
+
*/
|
|
64
|
+
|
|
15
65
|
export const ModifiedBy = createElement(ElementName.ModifiedBy);
|
|
66
|
+
/**
|
|
67
|
+
* Creates a ModifiedOn DateTime element using the data from ModifiedOn in the Flexible UI Context.
|
|
68
|
+
* @see DateTime
|
|
69
|
+
*/
|
|
70
|
+
|
|
16
71
|
export const ModifiedOn = createElement(ElementName.ModifiedOn);
|
|
72
|
+
/**
|
|
73
|
+
* Creates a Preview element using the data from Preview in the Flexible UI Context.
|
|
74
|
+
* @see Preview
|
|
75
|
+
*/
|
|
76
|
+
|
|
17
77
|
export const Preview = createElement(ElementName.Preview);
|
|
78
|
+
/**
|
|
79
|
+
* Creates a Priority Badge element using the data from Priority in the Flexible UI Context.
|
|
80
|
+
* @see Badge
|
|
81
|
+
*/
|
|
82
|
+
|
|
18
83
|
export const Priority = createElement(ElementName.Priority);
|
|
84
|
+
/**
|
|
85
|
+
* Creates a ProgrammingLanguage Badge element using the data from ProgrammingLanguage in the Flexible UI Context.
|
|
86
|
+
* @see Badge
|
|
87
|
+
*/
|
|
88
|
+
|
|
19
89
|
export const ProgrammingLanguage = createElement(ElementName.ProgrammingLanguage);
|
|
90
|
+
/**
|
|
91
|
+
* Creates a Snippet element using the data from Snippet in the Flexible UI Context.
|
|
92
|
+
* @see Text
|
|
93
|
+
*/
|
|
94
|
+
|
|
20
95
|
export const Snippet = createElement(ElementName.Snippet);
|
|
96
|
+
/**
|
|
97
|
+
* Creates a State Lozenge element using the data from State in the Flexible UI Context.
|
|
98
|
+
* @see Lozenge
|
|
99
|
+
*/
|
|
100
|
+
|
|
21
101
|
export const State = createElement(ElementName.State);
|
|
102
|
+
/**
|
|
103
|
+
* Creates a SubscriberCount Badge element using the data from SubscriberCount in the Flexible UI Context.
|
|
104
|
+
* @see Badge
|
|
105
|
+
*/
|
|
106
|
+
|
|
22
107
|
export const SubscriberCount = createElement(ElementName.SubscriberCount);
|
|
108
|
+
/**
|
|
109
|
+
* Creates a Title Link element using the data from Title in the Flexible UI Context.
|
|
110
|
+
* This represents the main link text within the Smart Link.
|
|
111
|
+
* @see Link
|
|
112
|
+
*/
|
|
113
|
+
|
|
23
114
|
export const Title = createElement(ElementName.Title);
|
|
115
|
+
/**
|
|
116
|
+
* Creates a Provider Badge element using the data from Provider in the Flexible UI Context.
|
|
117
|
+
* @see Badge
|
|
118
|
+
*/
|
|
119
|
+
|
|
24
120
|
export const Provider = createElement(ElementName.Provider);
|
|
@@ -63,9 +63,17 @@ const getMaxLines = maxLines => {
|
|
|
63
63
|
|
|
64
64
|
return maxLines;
|
|
65
65
|
};
|
|
66
|
+
/**
|
|
67
|
+
* An element that represent.
|
|
68
|
+
* @public
|
|
69
|
+
* @param {LinkProps} LinkProps - The props necessary for the Icon element.
|
|
70
|
+
* @see LinkIcon
|
|
71
|
+
*/
|
|
72
|
+
|
|
66
73
|
|
|
67
74
|
const Link = ({
|
|
68
75
|
maxLines = DEFAULT_MAX_LINES,
|
|
76
|
+
overrideCss,
|
|
69
77
|
size = SmartLinkSize.Medium,
|
|
70
78
|
testId = 'smart-element-link',
|
|
71
79
|
text,
|
|
@@ -80,7 +88,7 @@ const Link = ({
|
|
|
80
88
|
testId: `${testId}-tooltip`,
|
|
81
89
|
tag: "span"
|
|
82
90
|
}, jsx("a", {
|
|
83
|
-
css: getAnchorStyles(size, theme, getMaxLines(maxLines)),
|
|
91
|
+
css: [getAnchorStyles(size, theme, getMaxLines(maxLines)), overrideCss],
|
|
84
92
|
"data-smart-element-link": true,
|
|
85
93
|
"data-testid": testId,
|
|
86
94
|
onClick: onClick,
|
|
@@ -5,9 +5,16 @@ import AtlaskitLozenge from '@atlaskit/lozenge';
|
|
|
5
5
|
const styles = css`
|
|
6
6
|
line-height: inherit;
|
|
7
7
|
`;
|
|
8
|
+
/**
|
|
9
|
+
* An element that displays a Lozenge.
|
|
10
|
+
* @public
|
|
11
|
+
* @param {LozengeProps} LozengeProps - The props necessary for the Lozenge element.
|
|
12
|
+
* @see State
|
|
13
|
+
*/
|
|
8
14
|
|
|
9
15
|
const Lozenge = ({
|
|
10
16
|
appearance = 'default',
|
|
17
|
+
overrideCss,
|
|
11
18
|
text,
|
|
12
19
|
testId = 'smart-element-lozenge'
|
|
13
20
|
}) => {
|
|
@@ -16,12 +23,13 @@ const Lozenge = ({
|
|
|
16
23
|
}
|
|
17
24
|
|
|
18
25
|
return jsx("span", {
|
|
19
|
-
css: styles,
|
|
26
|
+
css: [styles, overrideCss],
|
|
20
27
|
"data-fit-to-content": true,
|
|
21
|
-
"data-smart-element-lozenge": true
|
|
28
|
+
"data-smart-element-lozenge": true,
|
|
29
|
+
"data-testid": testId
|
|
22
30
|
}, jsx(AtlaskitLozenge, {
|
|
23
31
|
appearance: appearance,
|
|
24
|
-
testId: testId
|
|
32
|
+
testId: `${testId}-lozenge`
|
|
25
33
|
}, text));
|
|
26
34
|
};
|
|
27
35
|
|
|
@@ -45,8 +45,15 @@ const styles = css`
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
`;
|
|
48
|
+
/**
|
|
49
|
+
* An element that displays a Media.
|
|
50
|
+
* @public
|
|
51
|
+
* @param {MediaProps} MediaProps - The props necessary for the Media element.
|
|
52
|
+
* @see Preview
|
|
53
|
+
*/
|
|
48
54
|
|
|
49
55
|
const Media = ({
|
|
56
|
+
overrideCss,
|
|
50
57
|
testId = 'smart-element-media',
|
|
51
58
|
type,
|
|
52
59
|
url
|
|
@@ -56,7 +63,7 @@ const Media = ({
|
|
|
56
63
|
}
|
|
57
64
|
|
|
58
65
|
return jsx("div", {
|
|
59
|
-
css: styles,
|
|
66
|
+
css: [styles, overrideCss],
|
|
60
67
|
"data-smart-element-media": true,
|
|
61
68
|
"data-testid": testId
|
|
62
69
|
}, jsx(ImageIcon, {
|
|
@@ -4,18 +4,25 @@ import { css, jsx } from '@emotion/core';
|
|
|
4
4
|
import { getFormattedMessage, getTruncateStyles } from '../../utils';
|
|
5
5
|
import { tokens } from '../../../../../utils/token';
|
|
6
6
|
|
|
7
|
-
const getStyles =
|
|
8
|
-
color: ${
|
|
7
|
+
const getStyles = maxLines => css`
|
|
8
|
+
color: ${tokens.text};
|
|
9
9
|
font-size: 0.75rem;
|
|
10
10
|
line-height: 1rem;
|
|
11
11
|
${getTruncateStyles(maxLines)}
|
|
12
12
|
`;
|
|
13
|
+
/**
|
|
14
|
+
* An element that displays some Text.
|
|
15
|
+
* @public
|
|
16
|
+
* @param {TextProps} TextProps - The props necessary for the Text element.
|
|
17
|
+
* @see Title
|
|
18
|
+
*/
|
|
19
|
+
|
|
13
20
|
|
|
14
21
|
const Text = ({
|
|
15
|
-
color = tokens.text,
|
|
16
22
|
content,
|
|
17
23
|
maxLines = 1,
|
|
18
24
|
message,
|
|
25
|
+
overrideCss,
|
|
19
26
|
testId = 'smart-element-text'
|
|
20
27
|
}) => {
|
|
21
28
|
if (!message && !content) {
|
|
@@ -23,7 +30,7 @@ const Text = ({
|
|
|
23
30
|
}
|
|
24
31
|
|
|
25
32
|
return jsx("span", {
|
|
26
|
-
css: getStyles(maxLines,
|
|
33
|
+
css: [getStyles(maxLines), overrideCss],
|
|
27
34
|
"data-separator": true,
|
|
28
35
|
"data-smart-element-text": true,
|
|
29
36
|
"data-testid": testId
|