@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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React, { useContext } from 'react';
|
|
3
|
+
import { css } from '@emotion/core';
|
|
3
4
|
import { ElementName, IconType } from '../../../../constants';
|
|
4
5
|
import Icon from './icon';
|
|
5
6
|
import Link from './link';
|
|
@@ -68,8 +69,10 @@ const elementMappings = {
|
|
|
68
69
|
[ElementName.Snippet]: {
|
|
69
70
|
component: Text,
|
|
70
71
|
props: {
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
maxLines: SNIPPET_DEFAULT_MAX_LINES,
|
|
73
|
+
overrideCss: css`
|
|
74
|
+
color: ${tokens.snippet};
|
|
75
|
+
`
|
|
73
76
|
}
|
|
74
77
|
},
|
|
75
78
|
[ElementName.State]: {
|
|
@@ -3,6 +3,12 @@ import React from 'react';
|
|
|
3
3
|
import Container from './components/container';
|
|
4
4
|
import { FlexibleUiContext } from '../../state/flexible-ui-context';
|
|
5
5
|
import { getContextByStatus, getRetryOptions } from './utils';
|
|
6
|
+
/**
|
|
7
|
+
* This represents a Flexible Card: a link represented by a card with metadata.
|
|
8
|
+
* This is the container in which all Flexible UI Blocks and Elements exist.
|
|
9
|
+
* Note: TitleBlock is mandatory for a Flexible Card to render.
|
|
10
|
+
* @see Container
|
|
11
|
+
*/
|
|
6
12
|
|
|
7
13
|
const FlexibleCard = ({
|
|
8
14
|
cardState,
|
|
@@ -10,34 +10,58 @@ import { SmartLinkSize, ActionName } from '../../constants';
|
|
|
10
10
|
import { useSmartLinkActions } from '../../state/hooks-external/useSmartLinkActions';
|
|
11
11
|
import { HoverCardContainer } from './styled';
|
|
12
12
|
import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
|
|
13
|
-
|
|
13
|
+
import { withAnalyticsEvents, withAnalyticsContext } from '@atlaskit/analytics-next';
|
|
14
|
+
import { fireSmartLinkEvent } from '../../utils/analytics';
|
|
15
|
+
import { useSmartCardState as useLinkState } from '../../state/store';
|
|
16
|
+
import { useSmartLinkAnalytics } from '../../state/analytics';
|
|
17
|
+
import { getExtensionKey, getDefinitionId } from '../../state/helpers';
|
|
18
|
+
export const HoverCardComponent = ({
|
|
14
19
|
children,
|
|
15
|
-
url
|
|
20
|
+
url,
|
|
21
|
+
createAnalyticsEvent
|
|
16
22
|
}) => {
|
|
23
|
+
const analyticsHandler = useCallback(analyticsPayload => {
|
|
24
|
+
fireSmartLinkEvent(analyticsPayload, createAnalyticsEvent);
|
|
25
|
+
}, [createAnalyticsEvent]);
|
|
17
26
|
const delay = 300;
|
|
18
27
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
19
28
|
const fadeOutTimeoutId = useRef();
|
|
20
29
|
const fadeInTimeoutId = useRef();
|
|
30
|
+
const cardOpenTime = useRef();
|
|
31
|
+
const linkState = useLinkState(url);
|
|
32
|
+
const analytics = useSmartLinkAnalytics(analyticsHandler);
|
|
33
|
+
const extensionKey = useMemo(() => getExtensionKey(linkState.details), [linkState]);
|
|
34
|
+
const definitionId = useMemo(() => getDefinitionId(linkState.details), [linkState]);
|
|
21
35
|
const initHideCard = useCallback(() => {
|
|
22
36
|
if (fadeInTimeoutId.current) {
|
|
23
37
|
clearTimeout(fadeInTimeoutId.current);
|
|
24
38
|
}
|
|
25
39
|
|
|
26
40
|
fadeOutTimeoutId.current = setTimeout(() => {
|
|
41
|
+
//Check its previously open to avoid firing events when moving between the child and hover card components
|
|
42
|
+
if (isOpen === true && cardOpenTime.current) {
|
|
43
|
+
const hoverTime = Date.now() - cardOpenTime.current;
|
|
44
|
+
analytics.ui.hoverCardDismissedEvent('card', hoverTime, definitionId, extensionKey);
|
|
45
|
+
}
|
|
46
|
+
|
|
27
47
|
setIsOpen(false);
|
|
28
48
|
}, delay);
|
|
29
|
-
}, [delay]);
|
|
49
|
+
}, [delay, isOpen, definitionId, extensionKey, analytics]);
|
|
30
50
|
const initShowCard = useCallback(() => {
|
|
31
51
|
if (fadeOutTimeoutId.current) {
|
|
32
52
|
clearTimeout(fadeOutTimeoutId.current);
|
|
33
53
|
}
|
|
34
54
|
|
|
35
55
|
fadeInTimeoutId.current = setTimeout(() => {
|
|
56
|
+
//Check if its previously closed to avoid firing events when moving between the child and hover card components
|
|
57
|
+
if (isOpen === false) {
|
|
58
|
+
cardOpenTime.current = Date.now();
|
|
59
|
+
analytics.ui.hoverCardViewedEvent('card', definitionId, extensionKey);
|
|
60
|
+
}
|
|
61
|
+
|
|
36
62
|
setIsOpen(true);
|
|
37
63
|
}, delay);
|
|
38
|
-
}, [delay
|
|
39
|
-
|
|
40
|
-
const analyticsHandler = useCallback(() => {}, []);
|
|
64
|
+
}, [delay, isOpen, definitionId, extensionKey, analytics]);
|
|
41
65
|
const linkActions = useSmartLinkActions({
|
|
42
66
|
url,
|
|
43
67
|
appearance: 'block',
|
|
@@ -57,10 +81,13 @@ export const HoverCard = ({
|
|
|
57
81
|
size: "medium"
|
|
58
82
|
}),
|
|
59
83
|
iconPosition: 'before',
|
|
60
|
-
onClick: () =>
|
|
84
|
+
onClick: () => {
|
|
85
|
+
window.open(url, '_blank');
|
|
86
|
+
analytics.ui.hoverCardOpenLinkClickedEvent('card', definitionId, extensionKey);
|
|
87
|
+
},
|
|
61
88
|
testId: 'hover-card-open-button'
|
|
62
89
|
};
|
|
63
|
-
}, [url]);
|
|
90
|
+
}, [url, definitionId, extensionKey, analytics]);
|
|
64
91
|
|
|
65
92
|
const cardComponent = () => jsx("div", {
|
|
66
93
|
onMouseEnter: initShowCard,
|
|
@@ -84,11 +111,14 @@ export const HoverCard = ({
|
|
|
84
111
|
testId: "hover-card",
|
|
85
112
|
isOpen: isOpen,
|
|
86
113
|
onClose: onClose,
|
|
87
|
-
placement: "bottom",
|
|
114
|
+
placement: "bottom-start",
|
|
88
115
|
content: cardComponent,
|
|
89
116
|
trigger: triggerProps => jsx("span", _extends({}, triggerProps, {
|
|
90
117
|
onMouseEnter: initShowCard,
|
|
91
118
|
onMouseLeave: initHideCard
|
|
92
119
|
}), children)
|
|
93
120
|
});
|
|
94
|
-
};
|
|
121
|
+
};
|
|
122
|
+
export const HoverCard = withAnalyticsContext({
|
|
123
|
+
source: 'smartLinkPreviewHoverCard'
|
|
124
|
+
})(withAnalyticsEvents()(HoverCardComponent));
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { css } from '@emotion/core';
|
|
2
|
+
import { loadingPlaceholderClassName } from '../../index';
|
|
2
3
|
export const HoverCardContainer = css`
|
|
3
4
|
background: none;
|
|
4
5
|
border-width: 0;
|
|
5
|
-
max-width:
|
|
6
|
+
max-width: 350px;
|
|
6
7
|
padding: 0;
|
|
8
|
+
|
|
9
|
+
.${loadingPlaceholderClassName} {
|
|
10
|
+
display: none;
|
|
11
|
+
}
|
|
7
12
|
`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { uiAuthEvent, uiAuthAlternateAccountEvent, uiCardClickedEvent, uiActionClickedEvent, uiClosedAuthEvent, uiRenderSuccessEvent, resolvedEvent as _resolvedEvent, unresolvedEvent as _unresolvedEvent, invokeSucceededEvent as _invokeSucceededEvent, invokeFailedEvent as _invokeFailedEvent, connectSucceededEvent as _connectSucceededEvent, connectFailedEvent as _connectFailedEvent, trackAppAccountConnected, screenAuthPopupEvent, instrumentEvent } from '../../utils/analytics';
|
|
1
|
+
import { uiAuthEvent, uiAuthAlternateAccountEvent, uiCardClickedEvent, uiActionClickedEvent, uiClosedAuthEvent, uiRenderSuccessEvent, uiHoverCardViewedEvent, uiHoverCardDismissedEvent, uiHoverCardOpenLinkClickedEvent, resolvedEvent as _resolvedEvent, unresolvedEvent as _unresolvedEvent, invokeSucceededEvent as _invokeSucceededEvent, invokeFailedEvent as _invokeFailedEvent, connectSucceededEvent as _connectSucceededEvent, connectFailedEvent as _connectFailedEvent, trackAppAccountConnected, screenAuthPopupEvent, instrumentEvent } from '../../utils/analytics';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { failUfoExperience, startUfoExperience, succeedUfoExperience } from './ufoExperiences';
|
|
4
4
|
export var useSmartLinkAnalytics = function useSmartLinkAnalytics(dispatchAnalytics) {
|
|
@@ -22,6 +22,9 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(dispatchAnalyt
|
|
|
22
22
|
});
|
|
23
23
|
dispatchAnalytics(uiActionClickedEvent(extensionKey, actionType, display));
|
|
24
24
|
},
|
|
25
|
+
hoverCardOpenLinkClickedEvent: function hoverCardOpenLinkClickedEvent(previewDisplay, definitionId, extensionKey, previewInvokeMethod) {
|
|
26
|
+
dispatchAnalytics(uiHoverCardOpenLinkClickedEvent(previewDisplay, definitionId, extensionKey, previewInvokeMethod));
|
|
27
|
+
},
|
|
25
28
|
closedAuthEvent: function closedAuthEvent(display, definitionId, extensionKey) {
|
|
26
29
|
return dispatchAnalytics(uiClosedAuthEvent(display, definitionId, extensionKey));
|
|
27
30
|
},
|
|
@@ -35,6 +38,12 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(dispatchAnalyt
|
|
|
35
38
|
display: display
|
|
36
39
|
});
|
|
37
40
|
dispatchAnalytics(uiRenderSuccessEvent(display, definitionId, extensionKey));
|
|
41
|
+
},
|
|
42
|
+
hoverCardViewedEvent: function hoverCardViewedEvent(hoverDisplay, definitionId, extensionKey, previewInvokeMethod) {
|
|
43
|
+
return dispatchAnalytics(uiHoverCardViewedEvent(hoverDisplay, definitionId, extensionKey, previewInvokeMethod));
|
|
44
|
+
},
|
|
45
|
+
hoverCardDismissedEvent: function hoverCardDismissedEvent(hoverDisplay, hoverTime, definitionId, extensionKey, previewInvokeMethod) {
|
|
46
|
+
return dispatchAnalytics(uiHoverCardDismissedEvent(hoverDisplay, hoverTime, definitionId, extensionKey, previewInvokeMethod));
|
|
38
47
|
}
|
|
39
48
|
};
|
|
40
49
|
}, [dispatchAnalytics]);
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { useContext, createContext } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This provides the data that will be used by Smart Links Flexible UI to populate it's
|
|
5
|
+
* underlying elements.
|
|
6
|
+
*/
|
|
2
7
|
export var FlexibleUiContext = /*#__PURE__*/createContext(undefined);
|
|
3
8
|
export var useFlexibleUiContext = function useFlexibleUiContext() {
|
|
4
9
|
return useContext(FlexibleUiContext);
|
|
@@ -252,4 +252,45 @@ export var uiRenderFailedEvent = function uiRenderFailedEvent(display, error, er
|
|
|
252
252
|
display: display
|
|
253
253
|
}
|
|
254
254
|
};
|
|
255
|
+
};
|
|
256
|
+
export var uiHoverCardViewedEvent = function uiHoverCardViewedEvent(hoverDisplay, definitionId, extensionKey, previewInvokeMethod) {
|
|
257
|
+
return {
|
|
258
|
+
action: 'viewed',
|
|
259
|
+
actionSubject: 'hoverCard',
|
|
260
|
+
eventType: 'ui',
|
|
261
|
+
attributes: _objectSpread(_objectSpread({}, context), {}, {
|
|
262
|
+
definitionId: definitionId || '',
|
|
263
|
+
extensionKey: extensionKey || '',
|
|
264
|
+
hoverDisplay: hoverDisplay,
|
|
265
|
+
previewInvokeMethod: previewInvokeMethod
|
|
266
|
+
})
|
|
267
|
+
};
|
|
268
|
+
};
|
|
269
|
+
export var uiHoverCardDismissedEvent = function uiHoverCardDismissedEvent(hoverDisplay, hoverTime, definitionId, extensionKey, previewInvokeMethod) {
|
|
270
|
+
return {
|
|
271
|
+
action: 'dismissed',
|
|
272
|
+
actionSubject: 'hoverCard',
|
|
273
|
+
eventType: 'ui',
|
|
274
|
+
attributes: _objectSpread(_objectSpread({}, context), {}, {
|
|
275
|
+
definitionId: definitionId || '',
|
|
276
|
+
extensionKey: extensionKey || '',
|
|
277
|
+
hoverTime: hoverTime,
|
|
278
|
+
hoverDisplay: hoverDisplay,
|
|
279
|
+
previewInvokeMethod: previewInvokeMethod
|
|
280
|
+
})
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
export var uiHoverCardOpenLinkClickedEvent = function uiHoverCardOpenLinkClickedEvent(previewDisplay, definitionId, extensionKey, previewInvokeMethod) {
|
|
284
|
+
return {
|
|
285
|
+
action: 'clicked',
|
|
286
|
+
actionSubject: 'button',
|
|
287
|
+
actionSubjectId: 'shortcutGoToLink',
|
|
288
|
+
eventType: 'ui',
|
|
289
|
+
attributes: _objectSpread(_objectSpread({}, context), {}, {
|
|
290
|
+
definitionId: definitionId || '',
|
|
291
|
+
extensionKey: extensionKey || '',
|
|
292
|
+
previewDisplay: previewDisplay,
|
|
293
|
+
previewInvokeMethod: previewInvokeMethod
|
|
294
|
+
})
|
|
295
|
+
};
|
|
255
296
|
};
|
|
@@ -6,7 +6,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
6
6
|
|
|
7
7
|
import { resolvedEvent, unresolvedEvent } from './analytics';
|
|
8
8
|
import { getMeasure } from '../performance';
|
|
9
|
-
export { ANALYTICS_CHANNEL, context, fireSmartLinkEvent, resolvedEvent, unresolvedEvent, invokeSucceededEvent, invokeFailedEvent, connectSucceededEvent, connectFailedEvent, trackAppAccountConnected, uiAuthEvent, uiAuthAlternateAccountEvent, uiCardClickedEvent, uiActionClickedEvent, uiClosedAuthEvent, screenAuthPopupEvent, uiRenderSuccessEvent, uiRenderFailedEvent } from './analytics';
|
|
9
|
+
export { ANALYTICS_CHANNEL, context, fireSmartLinkEvent, resolvedEvent, unresolvedEvent, invokeSucceededEvent, invokeFailedEvent, connectSucceededEvent, connectFailedEvent, trackAppAccountConnected, uiAuthEvent, uiAuthAlternateAccountEvent, uiCardClickedEvent, uiActionClickedEvent, uiClosedAuthEvent, screenAuthPopupEvent, uiRenderSuccessEvent, uiRenderFailedEvent, uiHoverCardViewedEvent, uiHoverCardDismissedEvent, uiHoverCardOpenLinkClickedEvent } from './analytics';
|
|
10
10
|
export var instrumentEvent = function instrumentEvent(id, status, definitionId, extensionKey, resourceType, error) {
|
|
11
11
|
var measure = getMeasure(id, status) || {
|
|
12
12
|
duration: undefined
|
package/dist/esm/version.json
CHANGED
|
@@ -25,7 +25,8 @@ export function CardWithUrlContent(_ref) {
|
|
|
25
25
|
embedIframeRef = _ref.embedIframeRef,
|
|
26
26
|
inlinePreloaderStyle = _ref.inlinePreloaderStyle,
|
|
27
27
|
ui = _ref.ui,
|
|
28
|
-
children = _ref.children
|
|
28
|
+
children = _ref.children,
|
|
29
|
+
showHoverPreview = _ref.showHoverPreview;
|
|
29
30
|
|
|
30
31
|
// Get state, actions for this card.
|
|
31
32
|
var _useSmartLink = useSmartLink(id, url, dispatchAnalytics),
|
|
@@ -129,7 +130,8 @@ export function CardWithUrlContent(_ref) {
|
|
|
129
130
|
isSelected: isSelected,
|
|
130
131
|
onResolve: onResolve,
|
|
131
132
|
testId: testId,
|
|
132
|
-
inlinePreloaderStyle: inlinePreloaderStyle
|
|
133
|
+
inlinePreloaderStyle: inlinePreloaderStyle,
|
|
134
|
+
showHoverPreview: showHoverPreview
|
|
133
135
|
});
|
|
134
136
|
|
|
135
137
|
case 'block':
|
|
@@ -45,7 +45,8 @@ export function CardWithURLRenderer(props) {
|
|
|
45
45
|
inlinePreloaderStyle = props.inlinePreloaderStyle,
|
|
46
46
|
createAnalyticsEvent = props.createAnalyticsEvent,
|
|
47
47
|
children = props.children,
|
|
48
|
-
ui = props.ui
|
|
48
|
+
ui = props.ui,
|
|
49
|
+
showHoverPreview = props.showHoverPreview; // Wrapper around analytics.
|
|
49
50
|
|
|
50
51
|
var dispatchAnalytics = useCallback(function (analyticsPayload) {
|
|
51
52
|
if (analyticsPayload && analyticsPayload.attributes) {
|
|
@@ -98,7 +99,8 @@ export function CardWithURLRenderer(props) {
|
|
|
98
99
|
platform: platform,
|
|
99
100
|
embedIframeRef: embedIframeRef,
|
|
100
101
|
inlinePreloaderStyle: inlinePreloaderStyle,
|
|
101
|
-
ui: ui
|
|
102
|
+
ui: ui,
|
|
103
|
+
showHoverPreview: showHoverPreview
|
|
102
104
|
};
|
|
103
105
|
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
104
106
|
FallbackComponent: ErrorFallback,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
3
3
|
|
|
4
|
-
var _templateObject, _templateObject2, _sizeToSpacing;
|
|
4
|
+
var _templateObject, _templateObject2, _templateObject3, _sizeToSpacing;
|
|
5
5
|
|
|
6
6
|
/** @jsx jsx */
|
|
7
7
|
import React from 'react';
|
|
@@ -32,7 +32,18 @@ var getIconStyles = function getIconStyles(size) {
|
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
var getButtonStyle = function getButtonStyle(size, iconOnly) {
|
|
35
|
-
|
|
35
|
+
switch (size) {
|
|
36
|
+
case SmartLinkSize.Large:
|
|
37
|
+
return iconOnly ? css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n button,\n button:hover,\n button:focus,\n button:active {\n padding: 0;\n > span {\n margin: 0;\n }\n }\n "]))) : '';
|
|
38
|
+
|
|
39
|
+
case SmartLinkSize.Small:
|
|
40
|
+
return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n font-size: 0.75rem;\n font-weight: 500;\n line-height: 1rem;\n button,\n button:hover,\n button:focus,\n button:active {\n line-height: 1rem;\n ", "\n }\n "])), iconOnly ? "\n padding: 0.125rem;\n " : "\n padding-left: 0.25rem;\n padding-right: 0.25rem;\n ");
|
|
41
|
+
|
|
42
|
+
case SmartLinkSize.XLarge:
|
|
43
|
+
case SmartLinkSize.Medium:
|
|
44
|
+
default:
|
|
45
|
+
return '';
|
|
46
|
+
}
|
|
36
47
|
};
|
|
37
48
|
|
|
38
49
|
var ActionIcon = function ActionIcon(_ref) {
|
|
@@ -46,6 +57,14 @@ var ActionIcon = function ActionIcon(_ref) {
|
|
|
46
57
|
};
|
|
47
58
|
|
|
48
59
|
export var sizeToSpacing = (_sizeToSpacing = {}, _defineProperty(_sizeToSpacing, SmartLinkSize.Small, 'none'), _defineProperty(_sizeToSpacing, SmartLinkSize.Medium, 'compact'), _defineProperty(_sizeToSpacing, SmartLinkSize.Large, 'compact'), _defineProperty(_sizeToSpacing, SmartLinkSize.XLarge, 'default'), _sizeToSpacing);
|
|
60
|
+
/**
|
|
61
|
+
* An action that can be triggered with an on click.
|
|
62
|
+
* @public
|
|
63
|
+
* @param {ActionProps} ActionProps - The props necessary for the Action.
|
|
64
|
+
* @see DeleteAction
|
|
65
|
+
* @see EditAction
|
|
66
|
+
* @see CustomAction
|
|
67
|
+
*/
|
|
49
68
|
|
|
50
69
|
var Action = function Action(_ref2) {
|
|
51
70
|
var _ref2$appearance = _ref2.appearance,
|
|
@@ -60,7 +79,8 @@ var Action = function Action(_ref2) {
|
|
|
60
79
|
_ref2$iconPosition = _ref2.iconPosition,
|
|
61
80
|
iconPosition = _ref2$iconPosition === void 0 ? 'before' : _ref2$iconPosition,
|
|
62
81
|
tooltipMessage = _ref2.tooltipMessage,
|
|
63
|
-
asDropDownItem = _ref2.asDropDownItem
|
|
82
|
+
asDropDownItem = _ref2.asDropDownItem,
|
|
83
|
+
overrideCss = _ref2.overrideCss;
|
|
64
84
|
|
|
65
85
|
if (!onClick) {
|
|
66
86
|
return null;
|
|
@@ -89,7 +109,8 @@ var Action = function Action(_ref2) {
|
|
|
89
109
|
return jsx(Tooltip, {
|
|
90
110
|
content: tooltipMessage
|
|
91
111
|
}, jsx("div", {
|
|
92
|
-
css: getButtonStyle(size, iconOnly)
|
|
112
|
+
css: [getButtonStyle(size, iconOnly), overrideCss],
|
|
113
|
+
"data-testid": "".concat(testId, "-button-wrapper")
|
|
93
114
|
}, jsx(Button, {
|
|
94
115
|
spacing: sizeToSpacing[size],
|
|
95
116
|
appearance: appearance,
|
|
@@ -2,9 +2,25 @@ import { ActionName } from '../../../../constants';
|
|
|
2
2
|
import { createUIAction } from './utils'; // Attention: Keep the export name and action name the same.
|
|
3
3
|
// This will help reducing the code for mapping action inside
|
|
4
4
|
// createAction and renderActionItems
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Creates a DeleteAction component. Accepts default ActionProps, but defaults
|
|
8
|
+
* the icon to a cross icon.
|
|
9
|
+
* @see Action
|
|
10
|
+
*/
|
|
7
11
|
|
|
8
12
|
export var DeleteAction = createUIAction(ActionName.DeleteAction);
|
|
13
|
+
/**
|
|
14
|
+
* Creates a EditAction component. Accepts default ActionProps, but defaults
|
|
15
|
+
* the icon to an edit (pencil) icon.
|
|
16
|
+
* @see Action
|
|
17
|
+
*/
|
|
18
|
+
|
|
9
19
|
export var EditAction = createUIAction(ActionName.EditAction);
|
|
20
|
+
/**
|
|
21
|
+
* Creates a CustomAction component. Accepts default ActionProps. Required to provide
|
|
22
|
+
* your own icon or text.
|
|
23
|
+
* @see Action
|
|
24
|
+
*/
|
|
25
|
+
|
|
10
26
|
export var CustomAction = createUIAction(ActionName.CustomAction);
|
|
@@ -15,6 +15,12 @@ import Button from '@atlaskit/button/standard-button';
|
|
|
15
15
|
import MoreIcon from '@atlaskit/icon/glyph/more';
|
|
16
16
|
import { sizeToSpacing } from '../../actions/action';
|
|
17
17
|
var styles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline-flex;\n line-height: 1rem;\n"])));
|
|
18
|
+
/**
|
|
19
|
+
* Creates a group of Action components. Accepts an array of Actions, in addition to some styling
|
|
20
|
+
* preferences.
|
|
21
|
+
* @param {ActionGroupProps} ActionGroupProps
|
|
22
|
+
* @see Action
|
|
23
|
+
*/
|
|
18
24
|
|
|
19
25
|
var ActionGroup = function ActionGroup(_ref) {
|
|
20
26
|
var _ref$items = _ref.items,
|
|
@@ -11,6 +11,13 @@ import { getBaseStyles, getGapSize, renderChildren } from '../utils';
|
|
|
11
11
|
var getBlockStyles = function getBlockStyles(direction, size) {
|
|
12
12
|
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", "\n justify-content: flex-start;\n [data-separator] + [data-separator]:before {\n content: '\u2022';\n margin-right: ", "rem;\n }\n"])), getBaseStyles(direction, size), getGapSize(size));
|
|
13
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* A block represents a collection of elements and actions that are arranged in a row.
|
|
16
|
+
* All elements and actions should be contained within a Block.
|
|
17
|
+
* @param {ActionGroupProps} ActionGroupProps
|
|
18
|
+
* @see Action
|
|
19
|
+
*/
|
|
20
|
+
|
|
14
21
|
|
|
15
22
|
var Block = function Block(_ref) {
|
|
16
23
|
var children = _ref.children,
|
|
@@ -20,9 +27,9 @@ var Block = function Block(_ref) {
|
|
|
20
27
|
size = _ref$size === void 0 ? SmartLinkSize.Medium : _ref$size,
|
|
21
28
|
_ref$testId = _ref.testId,
|
|
22
29
|
testId = _ref$testId === void 0 ? 'smart-block' : _ref$testId,
|
|
23
|
-
|
|
30
|
+
overrideCss = _ref.overrideCss;
|
|
24
31
|
return jsx("div", {
|
|
25
|
-
css: [getBlockStyles(direction, size),
|
|
32
|
+
css: [getBlockStyles(direction, size), overrideCss],
|
|
26
33
|
"data-smart-block": true,
|
|
27
34
|
"data-testid": testId
|
|
28
35
|
}, renderChildren(children, size));
|
|
@@ -22,12 +22,18 @@ var getAlignmentStyles = function getAlignmentStyles(align) {
|
|
|
22
22
|
export var getElementGroupStyles = function getElementGroupStyles(direction, size, align, width) {
|
|
23
23
|
return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n ", "\n ", "\n min-width: 10%;\n ", "\n"])), getBaseStyles(direction, size), getAlignmentStyles(align), width === SmartLinkWidth.Flexible ? "flex: 1 3;" : '');
|
|
24
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* Creates a group of Action components. Accepts an array of Actions, in addition to some styling
|
|
27
|
+
* preferences.
|
|
28
|
+
* @param {ActionGroupProps} ActionGroupProps
|
|
29
|
+
* @see Action
|
|
30
|
+
*/
|
|
25
31
|
|
|
26
32
|
var ElementGroup = function ElementGroup(_ref) {
|
|
27
33
|
var _ref$align = _ref.align,
|
|
28
34
|
align = _ref$align === void 0 ? SmartLinkAlignment.Left : _ref$align,
|
|
29
35
|
children = _ref.children,
|
|
30
|
-
|
|
36
|
+
overrideCss = _ref.overrideCss,
|
|
31
37
|
_ref$direction = _ref.direction,
|
|
32
38
|
direction = _ref$direction === void 0 ? SmartLinkDirection.Horizontal : _ref$direction,
|
|
33
39
|
_ref$size = _ref.size,
|
|
@@ -37,7 +43,7 @@ var ElementGroup = function ElementGroup(_ref) {
|
|
|
37
43
|
_ref$width = _ref.width,
|
|
38
44
|
width = _ref$width === void 0 ? SmartLinkWidth.FitToContent : _ref$width;
|
|
39
45
|
return jsx("div", {
|
|
40
|
-
css: [getElementGroupStyles(direction, size, align, width),
|
|
46
|
+
css: [getElementGroupStyles(direction, size, align, width), overrideCss],
|
|
41
47
|
"data-smart-element-group": true,
|
|
42
48
|
"data-testid": testId
|
|
43
49
|
}, renderChildren(children, size));
|
|
@@ -5,6 +5,12 @@ import Block from '../block';
|
|
|
5
5
|
import ElementGroup from '../element-group';
|
|
6
6
|
import { Provider } from '../../elements';
|
|
7
7
|
import ActionGroup from '../action-group';
|
|
8
|
+
/**
|
|
9
|
+
* Represents a FooterBlock, designed to contain elements and actions that should appear
|
|
10
|
+
* at the bottom of a link card.
|
|
11
|
+
* @param {FooterBlockProps} FooterBlockProps
|
|
12
|
+
* @see Block
|
|
13
|
+
*/
|
|
8
14
|
|
|
9
15
|
var FooterBlock = function FooterBlock(props) {
|
|
10
16
|
var status = props.status,
|
|
@@ -56,6 +56,13 @@ var getMaxLines = function getMaxLines(maxLines) {
|
|
|
56
56
|
|
|
57
57
|
return maxLines;
|
|
58
58
|
};
|
|
59
|
+
/**
|
|
60
|
+
* Represents a MetadataBlock, designed to contain groups of metadata in the form of elements.
|
|
61
|
+
* Accepts an array of elements to be shown either primary (left hand side) or secondary (right hand side).
|
|
62
|
+
* @param {MetadataBlockProps} MetadataBlockProps
|
|
63
|
+
* @see Block
|
|
64
|
+
*/
|
|
65
|
+
|
|
59
66
|
|
|
60
67
|
var MetadataBlock = function MetadataBlock(_ref) {
|
|
61
68
|
var _ref$maxLines = _ref.maxLines,
|
|
@@ -83,12 +90,12 @@ var MetadataBlock = function MetadataBlock(_ref) {
|
|
|
83
90
|
testId: "".concat(testId, "-resolved-view")
|
|
84
91
|
}), primaryElements && /*#__PURE__*/React.createElement(ElementGroup, {
|
|
85
92
|
align: SmartLinkAlignment.Left,
|
|
86
|
-
|
|
93
|
+
overrideCss: elementGroupStyles,
|
|
87
94
|
direction: SmartLinkDirection.Horizontal,
|
|
88
95
|
width: SmartLinkWidth.Flexible
|
|
89
96
|
}, primaryElements), secondaryElements && /*#__PURE__*/React.createElement(ElementGroup, {
|
|
90
97
|
align: SmartLinkAlignment.Right,
|
|
91
|
-
|
|
98
|
+
overrideCss: elementGroupStyles,
|
|
92
99
|
direction: SmartLinkDirection.Horizontal,
|
|
93
100
|
width: SmartLinkWidth.Flexible
|
|
94
101
|
}, secondaryElements));
|
|
@@ -5,6 +5,11 @@ import React from 'react';
|
|
|
5
5
|
import { SmartLinkStatus } from '../../../../../constants';
|
|
6
6
|
import Block from '../block';
|
|
7
7
|
import { Preview } from '../../elements';
|
|
8
|
+
/**
|
|
9
|
+
* Represents a PreviewBlock, which typically contains media or other large format content.
|
|
10
|
+
* @param {PreviewBlock} PreviewBlock
|
|
11
|
+
* @see Block
|
|
12
|
+
*/
|
|
8
13
|
|
|
9
14
|
var PreviewBlock = function PreviewBlock(_ref) {
|
|
10
15
|
var _ref$status = _ref.status,
|
|
@@ -9,6 +9,11 @@ import { getMaxLines } from '../../utils';
|
|
|
9
9
|
var DEFAULT_MAX_LINES = 3;
|
|
10
10
|
var MAXIMUM_MAX_LINES = 3;
|
|
11
11
|
var MINIMUM_MAX_LINES = 1;
|
|
12
|
+
/**
|
|
13
|
+
* Represents a SnippetBlock, which is used to display longer form text content, like descriptions.
|
|
14
|
+
* @param {SnippetBlock} SnippetBlock
|
|
15
|
+
* @see Block
|
|
16
|
+
*/
|
|
12
17
|
|
|
13
18
|
var SnippetBlock = function SnippetBlock(_ref) {
|
|
14
19
|
var _ref$maxLines = _ref.maxLines,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
3
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
4
|
+
var _excluded = ["actionGroup", "retry", "position", "testId", "title"];
|
|
3
5
|
|
|
4
6
|
var _templateObject, _templateObject2;
|
|
5
7
|
|
|
@@ -7,42 +9,57 @@ var _templateObject, _templateObject2;
|
|
|
7
9
|
import React from 'react';
|
|
8
10
|
import { FormattedMessage } from 'react-intl-next';
|
|
9
11
|
import { css, jsx } from '@emotion/core';
|
|
12
|
+
import { LinkIcon } from '../../../elements';
|
|
13
|
+
import Block from '../../block';
|
|
10
14
|
import { SmartLinkAlignment, SmartLinkDirection, SmartLinkSize } from '../../../../../../constants';
|
|
11
15
|
import { getLinkLineHeight, getLinkSizeStyles, getTruncateStyles } from '../../../utils';
|
|
12
16
|
import ElementGroup from '../../element-group';
|
|
13
17
|
import { tokens } from '../../../../../../utils/token';
|
|
14
|
-
import { BaseTitleBlockComponent } from '../utils';
|
|
15
18
|
var actionStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n cursor: pointer;\n :hover {\n color: ", ";\n text-decoration: underline;\n }\n"])), tokens.errorMessageHover);
|
|
16
19
|
|
|
17
20
|
var getMessageStyles = function getMessageStyles(size, hasAction) {
|
|
18
21
|
var sizeStyles = getLinkSizeStyles(size);
|
|
19
22
|
return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n flex: 1 1 auto;\n justify-content: flex-end;\n ", "\n ", "\n ", "\n color: ", ";\n "])), hasAction ? actionStyles : '', sizeStyles, getTruncateStyles(1, getLinkLineHeight(size)), tokens.errorMessage);
|
|
20
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Represents an Errored TitleBlock view.
|
|
26
|
+
* This will render when a Smart Link did not successfully resolve.
|
|
27
|
+
* This may be a result of a Smart Link not having the correct credentials,
|
|
28
|
+
* or the backend response was errored or malformed.
|
|
29
|
+
* @see TitleBlock
|
|
30
|
+
*/
|
|
21
31
|
|
|
22
|
-
var TitleBlockErroredView = function TitleBlockErroredView(props) {
|
|
23
|
-
var _props$size = props.size,
|
|
24
|
-
size = _props$size === void 0 ? SmartLinkSize.Medium : _props$size,
|
|
25
|
-
retry = props.retry,
|
|
26
|
-
testId = props.testId;
|
|
27
32
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
var TitleBlockErroredView = function TitleBlockErroredView(_ref) {
|
|
34
|
+
var actionGroup = _ref.actionGroup,
|
|
35
|
+
retry = _ref.retry,
|
|
36
|
+
position = _ref.position,
|
|
37
|
+
testId = _ref.testId,
|
|
38
|
+
title = _ref.title,
|
|
39
|
+
blockProps = _objectWithoutProperties(_ref, _excluded);
|
|
32
40
|
|
|
41
|
+
var _ref2 = retry || {},
|
|
42
|
+
descriptor = _ref2.descriptor,
|
|
43
|
+
onClick = _ref2.onClick,
|
|
44
|
+
values = _ref2.values;
|
|
45
|
+
|
|
46
|
+
var _blockProps$size = blockProps.size,
|
|
47
|
+
size = _blockProps$size === void 0 ? SmartLinkSize.Medium : _blockProps$size;
|
|
33
48
|
var hasAction = onClick !== undefined;
|
|
34
|
-
return jsx(
|
|
35
|
-
|
|
36
|
-
}),
|
|
49
|
+
return jsx(Block, _extends({}, blockProps, {
|
|
50
|
+
testId: "".concat(testId, "-errored-view")
|
|
51
|
+
}), jsx(LinkIcon, {
|
|
52
|
+
position: position
|
|
53
|
+
}), title, descriptor && jsx(ElementGroup, {
|
|
37
54
|
direction: SmartLinkDirection.Horizontal,
|
|
38
55
|
align: SmartLinkAlignment.Right
|
|
39
56
|
}, jsx("span", {
|
|
40
57
|
css: getMessageStyles(size, hasAction),
|
|
41
58
|
onClick: onClick,
|
|
42
59
|
"data-testid": "".concat(testId, "-errored-view-message")
|
|
43
|
-
}, jsx(FormattedMessage, _extends({},
|
|
44
|
-
values:
|
|
45
|
-
})))));
|
|
60
|
+
}, jsx(FormattedMessage, _extends({}, descriptor, {
|
|
61
|
+
values: values
|
|
62
|
+
})))), actionGroup);
|
|
46
63
|
};
|
|
47
64
|
|
|
48
65
|
export default TitleBlockErroredView;
|