@atlaskit/smart-card 19.1.19 → 19.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +7 -3
  3. package/dist/cjs/state/helpers.js +26 -4
  4. package/dist/cjs/utils/analytics/analytics.js +3 -2
  5. package/dist/cjs/version.json +1 -1
  6. package/dist/cjs/view/CardWithUrl/component.js +4 -2
  7. package/dist/cjs/view/FlexibleCard/components/blocks/element-group/index.js +19 -2
  8. package/dist/cjs/view/FlexibleCard/components/blocks/footer-block/index.js +19 -0
  9. package/dist/cjs/view/FlexibleCard/components/blocks/metadata-block/index.js +6 -25
  10. package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +1 -1
  11. package/dist/cjs/view/FlexibleCard/components/elements/avatar-group/index.js +5 -3
  12. package/dist/cjs/view/FlexibleCard/components/elements/badge/index.js +4 -4
  13. package/dist/cjs/view/FlexibleCard/components/elements/lozenge/index.js +1 -1
  14. package/dist/cjs/view/FlexibleCard/components/elements/media/index.js +1 -1
  15. package/dist/cjs/view/FlexibleCard/components/utils.js +19 -2
  16. package/dist/cjs/view/HoverCard/components/hover-card-content.js +2 -1
  17. package/dist/cjs/view/HoverCard/utils.js +6 -3
  18. package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +6 -3
  19. package/dist/es2019/state/helpers.js +25 -3
  20. package/dist/es2019/utils/analytics/analytics.js +3 -2
  21. package/dist/es2019/version.json +1 -1
  22. package/dist/es2019/view/CardWithUrl/component.js +5 -3
  23. package/dist/es2019/view/FlexibleCard/components/blocks/element-group/index.js +48 -1
  24. package/dist/es2019/view/FlexibleCard/components/blocks/footer-block/index.js +16 -1
  25. package/dist/es2019/view/FlexibleCard/components/blocks/metadata-block/index.js +6 -33
  26. package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +1 -0
  27. package/dist/es2019/view/FlexibleCard/components/elements/avatar-group/index.js +6 -1
  28. package/dist/es2019/view/FlexibleCard/components/elements/badge/index.js +7 -2
  29. package/dist/es2019/view/FlexibleCard/components/elements/lozenge/index.js +1 -0
  30. package/dist/es2019/view/FlexibleCard/components/elements/media/index.js +2 -1
  31. package/dist/es2019/view/FlexibleCard/components/utils.js +17 -1
  32. package/dist/es2019/view/HoverCard/components/hover-card-content.js +2 -1
  33. package/dist/es2019/view/HoverCard/utils.js +4 -3
  34. package/dist/esm/state/analytics/useSmartLinkAnalytics.js +8 -4
  35. package/dist/esm/state/helpers.js +19 -3
  36. package/dist/esm/utils/analytics/analytics.js +3 -2
  37. package/dist/esm/version.json +1 -1
  38. package/dist/esm/view/CardWithUrl/component.js +5 -3
  39. package/dist/esm/view/FlexibleCard/components/blocks/element-group/index.js +19 -3
  40. package/dist/esm/view/FlexibleCard/components/blocks/footer-block/index.js +19 -1
  41. package/dist/esm/view/FlexibleCard/components/blocks/metadata-block/index.js +6 -26
  42. package/dist/esm/view/FlexibleCard/components/blocks/utils.js +1 -1
  43. package/dist/esm/view/FlexibleCard/components/elements/avatar-group/index.js +5 -3
  44. package/dist/esm/view/FlexibleCard/components/elements/badge/index.js +4 -4
  45. package/dist/esm/view/FlexibleCard/components/elements/lozenge/index.js +1 -1
  46. package/dist/esm/view/FlexibleCard/components/elements/media/index.js +1 -1
  47. package/dist/esm/view/FlexibleCard/components/utils.js +15 -1
  48. package/dist/esm/view/HoverCard/components/hover-card-content.js +2 -1
  49. package/dist/esm/view/HoverCard/utils.js +4 -3
  50. package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +3 -1
  51. package/dist/types/state/helpers.d.ts +3 -0
  52. package/dist/types/state/hooks/useSmartLink.d.ts +1 -1
  53. package/dist/types/utils/analytics/analytics.d.ts +1 -1
  54. package/dist/types/utils/analytics/types.d.ts +1 -0
  55. package/dist/types/view/FlexibleCard/components/utils.d.ts +1 -0
  56. package/package.json +1 -1
@@ -2,7 +2,8 @@
2
2
  import React from 'react';
3
3
  import { css, jsx } from '@emotion/core';
4
4
  import { SmartLinkAlignment, SmartLinkDirection, SmartLinkSize, SmartLinkWidth } from '../../../../../constants';
5
- import { getBaseStyles, renderChildren } from '../utils';
5
+ import { getBaseStyles, getGapSize, renderChildren } from '../utils';
6
+ import { getMaxLineHeight, getTruncateStyles } from '../../utils';
6
7
 
7
8
  const getAlignmentStyles = align => {
8
9
  switch (align) {
@@ -21,11 +22,57 @@ const getAlignmentStyles = align => {
21
22
  }
22
23
  };
23
24
 
25
+ const getGapStyles = (size, align) => {
26
+ const gap = getGapSize(size);
27
+
28
+ if (align === SmartLinkAlignment.Right) {
29
+ return css`
30
+ > span {
31
+ margin-left: ${gap}rem;
32
+ &:first-child {
33
+ margin-left: initial;
34
+ }
35
+ }
36
+ `;
37
+ }
38
+
39
+ return css`
40
+ > span {
41
+ margin-right: ${gap}rem;
42
+ &:last-child {
43
+ margin-right: initial;
44
+ }
45
+ }
46
+ `;
47
+ };
48
+
49
+ const getHorizontalDirectionStyles = (size, align) => {
50
+ const lineHeight = getMaxLineHeight(size);
51
+ return css`
52
+ display: block;
53
+ vertical-align: middle;
54
+ ${getTruncateStyles(1, lineHeight + 'rem')}
55
+
56
+ > span, > div {
57
+ vertical-align: middle;
58
+
59
+ &[data-smart-element-date-time],
60
+ &[data-smart-element-text] {
61
+ // Show all/wrapped/truncated
62
+ display: inline;
63
+ }
64
+ }
65
+
66
+ ${getGapStyles(size, align)}
67
+ `;
68
+ };
69
+
24
70
  export const getElementGroupStyles = (direction, size, align, width) => css`
25
71
  ${getBaseStyles(direction, size)}
26
72
  ${getAlignmentStyles(align)}
27
73
  min-width: 10%;
28
74
  ${width === SmartLinkWidth.Flexible ? `flex: 1 3;` : ''}
75
+ ${direction === SmartLinkDirection.Horizontal ? getHorizontalDirectionStyles(size, align) : ''}
29
76
  `;
30
77
  /**
31
78
  * Creates a group of Action components. Accepts an array of Actions, in addition to some styling
@@ -1,10 +1,22 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React from 'react';
3
- import { SmartLinkAlignment, SmartLinkDirection, SmartLinkStatus, SmartLinkWidth } from '../../../../../constants';
3
+ import { css } from '@emotion/core';
4
+ import { SmartLinkAlignment, SmartLinkDirection, SmartLinkSize, SmartLinkStatus, SmartLinkWidth } from '../../../../../constants';
4
5
  import Block from '../block';
5
6
  import ElementGroup from '../element-group';
6
7
  import { Provider } from '../../elements';
7
8
  import ActionGroup from '../action-group';
9
+
10
+ const getActionGroupStyles = size => {
11
+ if (size === SmartLinkSize.XLarge) {
12
+ // The biggest height of the action button exceeds the max line-height
13
+ // of the elements causing the action on the block with x-large size to
14
+ // get cut at the bottom.
15
+ return css`
16
+ max-height: 2rem;
17
+ `;
18
+ }
19
+ };
8
20
  /**
9
21
  * Represents a FooterBlock, designed to contain elements and actions that should appear
10
22
  * at the bottom of a link card.
@@ -13,10 +25,12 @@ import ActionGroup from '../action-group';
13
25
  * @see Block
14
26
  */
15
27
 
28
+
16
29
  const FooterBlock = props => {
17
30
  const {
18
31
  status,
19
32
  actions,
33
+ size = SmartLinkSize.Medium,
20
34
  testId = 'smart-footer-block'
21
35
  } = props;
22
36
 
@@ -32,6 +46,7 @@ const FooterBlock = props => {
32
46
  testId: "smart-element-group-actions",
33
47
  align: SmartLinkAlignment.Right,
34
48
  direction: SmartLinkDirection.Horizontal,
49
+ overrideCss: getActionGroupStyles(size),
35
50
  width: SmartLinkWidth.Flexible
36
51
  }, /*#__PURE__*/React.createElement(ActionGroup, {
37
52
  items: actions,
@@ -2,9 +2,10 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import React from 'react';
3
3
  import { css } from '@emotion/core';
4
4
  import { SmartLinkAlignment, SmartLinkDirection, SmartLinkSize, SmartLinkStatus, SmartLinkWidth } from '../../../../../constants';
5
- import { getGapSize, renderElementItems } from '../utils';
5
+ import { renderElementItems } from '../utils';
6
6
  import Block from '../block';
7
7
  import ElementGroup from '../element-group';
8
+ import { getMaxLineHeight, getTruncateStyles } from '../../utils';
8
9
  const DEFAULT_MAX_LINES = 2;
9
10
  const MAXIMUM_MAX_LINES = 2;
10
11
  const MINIMUM_MAX_LINES = 1;
@@ -12,43 +13,15 @@ const MINIMUM_MAX_LINES = 1;
12
13
  const getElementGroupStyles = (size, maxLines) => {
13
14
  // MetadataBlock allows metadata elements to be displayed in
14
15
  // multiple lines, with maximum of 2 lines.
15
- // a) We need the height of the line to be equal on both left and right
16
- // sides so they line up nicely.
17
- // b) There is no way to truncate non-text elements nicely. Here
18
- // it's fix max height of the element group so that anything that is
19
- // overflown will not be visible.
20
- const lineHeight = getLineHeight(size);
21
- const gap = getGapSize(size);
22
- const gapHeight = gap * (maxLines - 1);
23
- const height = lineHeight * maxLines + gapHeight;
16
+ // We need the height of the line to be equal on both left and right
17
+ // sides so they line up nicely.
18
+ const lineHeight = getMaxLineHeight(size);
24
19
  return css`
25
- flex-wrap: wrap;
26
20
  line-height: ${lineHeight}rem;
27
- max-height: ${height}rem;
28
- > span,
29
- > div {
30
- min-height: ${lineHeight}rem;
31
- max-height: ${lineHeight}rem;
32
- line-height: ${lineHeight}rem;
33
- }
21
+ ${getTruncateStyles(maxLines, lineHeight + 'rem')}
34
22
  `;
35
23
  };
36
24
 
37
- const getLineHeight = size => {
38
- // The maximum height of all elements in specific size.
39
- // These heights belongs to AvatarGroup.
40
- switch (size) {
41
- case SmartLinkSize.XLarge:
42
- case SmartLinkSize.Large:
43
- return 1.75;
44
-
45
- case SmartLinkSize.Medium:
46
- case SmartLinkSize.Small:
47
- default:
48
- return 1.5;
49
- }
50
- };
51
-
52
25
  const getMaxLines = maxLines => {
53
26
  if (maxLines > MAXIMUM_MAX_LINES) {
54
27
  return DEFAULT_MAX_LINES;
@@ -64,6 +64,7 @@ export const getGapSize = size => {
64
64
  }
65
65
  };
66
66
  export const getBaseStyles = (direction, size) => css`
67
+ align-items: center;
67
68
  display: flex;
68
69
  gap: ${getGapSize(size)}rem;
69
70
  line-height: 1rem;
@@ -6,16 +6,21 @@ import { SmartLinkSize } from '../../../../../constants';
6
6
  const MAX_COUNT = 4;
7
7
 
8
8
  const getStyles = size => {
9
+ const styles = css`
10
+ display: inline-flex;
11
+ `;
12
+
9
13
  switch (size) {
10
14
  case SmartLinkSize.XLarge:
11
15
  case SmartLinkSize.Large:
12
16
  // Default AK small size
13
- return;
17
+ return styles;
14
18
 
15
19
  case SmartLinkSize.Medium:
16
20
  case SmartLinkSize.Small:
17
21
  default:
18
22
  return css`
23
+ ${styles}
19
24
  li {
20
25
  span,
21
26
  svg {
@@ -9,15 +9,19 @@ import ImageIcon from '../../common/image-icon';
9
9
  import AtlaskitIcon from '../../common/atlaskit-icon';
10
10
  const badgeStyles = css`
11
11
  align-items: center;
12
- display: flex;
12
+ display: inline-flex;
13
13
  min-width: fit-content;
14
14
  `;
15
15
  const iconStyles = css`
16
16
  color: ${tokens.badgeIcon};
17
+ line-height: 0;
18
+ vertical-align: middle;
17
19
  ${getIconSizeStyles('1rem')}
20
+ img,
18
21
  span,
19
22
  svg {
20
23
  line-height: 0;
24
+ vertical-align: middle;
21
25
  }
22
26
  `;
23
27
  const labelStyles = css`
@@ -25,6 +29,7 @@ const labelStyles = css`
25
29
  font-size: 0.75rem;
26
30
  line-height: 1rem;
27
31
  padding-left: 0.125rem;
32
+ vertical-align: middle;
28
33
  `;
29
34
  const messageMapper = {
30
35
  [IconType.PriorityBlocker]: messages.priority_blocker,
@@ -99,7 +104,7 @@ const Badge = ({
99
104
  return null;
100
105
  }
101
106
 
102
- return jsx("div", {
107
+ return jsx("span", {
103
108
  css: [badgeStyles, overrideCss],
104
109
  "data-fit-to-content": true,
105
110
  "data-smart-element-badge": true,
@@ -3,6 +3,7 @@ import React from 'react';
3
3
  import { css, jsx } from '@emotion/core';
4
4
  import AtlaskitLozenge from '@atlaskit/lozenge';
5
5
  const styles = css`
6
+ display: inline-flex;
6
7
  line-height: inherit;
7
8
  `;
8
9
  /**
@@ -27,7 +27,8 @@ const styles = css`
27
27
  overflow: hidden;
28
28
  }
29
29
 
30
- > img {
30
+ > img,
31
+ > span {
31
32
  min-height: 100%;
32
33
  min-width: 100%;
33
34
  max-height: 100%;
@@ -96,6 +96,20 @@ export const getLinkSizeStyles = size => {
96
96
  `;
97
97
  }
98
98
  };
99
+ export const getMaxLineHeight = size => {
100
+ // The maximum line height based on all elements in specific size.
101
+ // These heights belongs to AvatarGroup.
102
+ switch (size) {
103
+ case SmartLinkSize.XLarge:
104
+ case SmartLinkSize.Large:
105
+ return 1.75;
106
+
107
+ case SmartLinkSize.Medium:
108
+ case SmartLinkSize.Small:
109
+ default:
110
+ return 1.5;
111
+ }
112
+ };
99
113
  export const getMaxLines = (value, defaultValue, max, min) => {
100
114
  if (value > max) {
101
115
  return defaultValue;
@@ -115,7 +129,9 @@ export const getTruncateStyles = (maxLines, lineHeight = '1rem', wordBreak = 'br
115
129
  -webkit-line-clamp: ${maxLines};
116
130
  -webkit-box-orient: vertical;
117
131
  // Fallback options
118
- max-height: calc(${maxLines} * ${lineHeight});
132
+ @supports not (-webkit-line-clamp: 1) {
133
+ max-height: calc(${maxLines} * ${lineHeight});
134
+ }
119
135
  `;
120
136
  export const hasWhiteSpace = str => {
121
137
  return str.search(/\s/) >= 0;
@@ -76,7 +76,8 @@ const HoverCardContent = ({
76
76
  actions: titleActions
77
77
  }), /*#__PURE__*/React.createElement(MetadataBlock, {
78
78
  primary: primary,
79
- secondary: secondary
79
+ secondary: secondary,
80
+ size: SmartLinkSize.Small
80
81
  }), body, /*#__PURE__*/React.createElement(FooterBlock, {
81
82
  actions: footerActions
82
83
  }));
@@ -1,10 +1,11 @@
1
+ import { ElementName } from '../../constants';
1
2
  export const HOVER_CARD_ANALYTICS_DISPLAY = 'flexible';
2
3
  export const getSimulatedMetadata = (extensionKey = '') => {
3
4
  switch (extensionKey) {
4
5
  case 'confluence-object-provider':
5
6
  return {
6
7
  metadata: {
7
- primary: ['AuthorGroup', 'CreatedBy', 'CommentCount', 'ReactCount'],
8
+ primary: [ElementName.AuthorGroup, ElementName.CreatedBy, ElementName.CommentCount, ElementName.ReactCount],
8
9
  secondary: []
9
10
  }
10
11
  };
@@ -12,7 +13,7 @@ export const getSimulatedMetadata = (extensionKey = '') => {
12
13
  case 'jira-object-provider':
13
14
  return {
14
15
  metadata: {
15
- primary: ['AuthorGroup', 'State', 'Priority'],
16
+ primary: [ElementName.AuthorGroup, ElementName.State, ElementName.Priority],
16
17
  secondary: []
17
18
  }
18
19
  };
@@ -20,7 +21,7 @@ export const getSimulatedMetadata = (extensionKey = '') => {
20
21
  default:
21
22
  return {
22
23
  metadata: {
23
- primary: ['ModifiedOn'],
24
+ primary: [ElementName.ModifiedOn, ElementName.CreatedBy],
24
25
  secondary: []
25
26
  }
26
27
  };
@@ -2,7 +2,7 @@ import { useMemo } from 'react';
2
2
  import { getUrl } from '@atlaskit/linking-common';
3
3
  import { uiAuthEvent, uiAuthAlternateAccountEvent, uiCardClickedEvent, uiActionClickedEvent, uiClosedAuthEvent, uiRenderSuccessEvent, uiHoverCardViewedEvent, uiHoverCardDismissedEvent, uiHoverCardOpenLinkClickedEvent, invokeSucceededEvent as _invokeSucceededEvent, invokeFailedEvent as _invokeFailedEvent, connectSucceededEvent as _connectSucceededEvent, connectFailedEvent as _connectFailedEvent, trackAppAccountConnected, screenAuthPopupEvent, instrumentEvent } from '../../utils/analytics';
4
4
  import { failUfoExperience, startUfoExperience, succeedUfoExperience } from './ufoExperiences';
5
- import { getDefinitionId, getExtensionKey, getResourceType } from '../helpers';
5
+ import { getDefinitionId, getExtensionKey, getResourceType, getSubproduct, getProduct } from '../helpers';
6
6
  import { useSmartLinkContext } from '@atlaskit/link-provider';
7
7
  /**
8
8
  * This hook provides usage of Smart Link analytics outside of the Card component.
@@ -24,6 +24,8 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
24
24
  var extractedDefinitionId = getDefinitionId(state.details);
25
25
  var extractedExtensionKey = getExtensionKey(state.details);
26
26
  var extractedResourceType = getResourceType(state.details);
27
+ var extractedSubproduct = getSubproduct(state.details);
28
+ var extractedProduct = getProduct(state.details);
27
29
  /** Contains all ui analytics events */
28
30
 
29
31
  var ui = useMemo(function () {
@@ -60,6 +62,7 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
60
62
  * This fires an event that represents when a user clicks on a Smart Link.
61
63
  * @param id The unique ID for this Smart Link.
62
64
  * @param display Whether the card was an Inline, Block, Embed or Flexible UI.
65
+ * @param status What status the Smart Link is currently in (e.g. resolved, unresolved)
63
66
  * @param definitionId The definitionId of the Smart Link resolver invoked.
64
67
  * @param extensionKey The extensionKey of the Smart Link resovler invoked.
65
68
  * @param isModifierKeyPressed Whether a modifier key was pressed when clicking the Smart Link.
@@ -75,8 +78,9 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
75
78
  var extensionKey = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : extractedExtensionKey;
76
79
  var isModifierKeyPressed = arguments.length > 5 ? arguments[5] : undefined;
77
80
  var location = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : defaultLocation;
78
- var destinationProduct = arguments.length > 7 ? arguments[7] : undefined;
79
- return dispatchAnalytics(uiCardClickedEvent(id, display, status, definitionId, extensionKey, isModifierKeyPressed, location, destinationProduct));
81
+ var destinationProduct = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : extractedProduct;
82
+ var destinationSubproduct = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : extractedSubproduct;
83
+ return dispatchAnalytics(uiCardClickedEvent(id, display, status, definitionId, extensionKey, isModifierKeyPressed, location, destinationProduct, destinationSubproduct));
80
84
  },
81
85
 
82
86
  /**
@@ -186,7 +190,7 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
186
190
  return dispatchAnalytics(uiHoverCardDismissedEvent(id, previewDisplay, hoverTime, definitionId, extensionKey, previewInvokeMethod));
187
191
  }
188
192
  };
189
- }, [defaultId, defaultLocation, extractedDefinitionId, extractedExtensionKey, dispatchAnalytics]);
193
+ }, [extractedDefinitionId, extractedExtensionKey, dispatchAnalytics, defaultId, defaultLocation, extractedProduct, extractedSubproduct]);
190
194
  /** Contains all operational analytics events */
191
195
 
192
196
  var operational = useMemo(function () {
@@ -18,13 +18,29 @@ export var getClickUrl = function getClickUrl(url, jsonLd) {
18
18
  return url;
19
19
  };
20
20
  export var getDefinitionId = function getDefinitionId(details) {
21
- return details && details.meta && details.meta.definitionId;
21
+ var _details$meta;
22
+
23
+ return details === null || details === void 0 ? void 0 : (_details$meta = details.meta) === null || _details$meta === void 0 ? void 0 : _details$meta.definitionId;
22
24
  };
23
25
  export var getExtensionKey = function getExtensionKey(details) {
24
- return details && details.meta && details.meta.key;
26
+ var _details$meta2;
27
+
28
+ return details === null || details === void 0 ? void 0 : (_details$meta2 = details.meta) === null || _details$meta2 === void 0 ? void 0 : _details$meta2.key;
25
29
  };
26
30
  export var getResourceType = function getResourceType(details) {
27
- return details && details.meta && details.meta.resourceType;
31
+ var _details$meta3;
32
+
33
+ return details === null || details === void 0 ? void 0 : (_details$meta3 = details.meta) === null || _details$meta3 === void 0 ? void 0 : _details$meta3.resourceType;
34
+ };
35
+ export var getProduct = function getProduct(details) {
36
+ var _details$meta4;
37
+
38
+ return details === null || details === void 0 ? void 0 : (_details$meta4 = details.meta) === null || _details$meta4 === void 0 ? void 0 : _details$meta4.product;
39
+ };
40
+ export var getSubproduct = function getSubproduct(details) {
41
+ var _details$meta5;
42
+
43
+ return details === null || details === void 0 ? void 0 : (_details$meta5 = details.meta) === null || _details$meta5 === void 0 ? void 0 : _details$meta5.subproduct;
28
44
  };
29
45
  export var getServices = function getServices(details) {
30
46
  return details && details.meta.auth || [];
@@ -187,7 +187,7 @@ export var uiAuthAlternateAccountEvent = function uiAuthAlternateAccountEvent(di
187
187
  })
188
188
  };
189
189
  };
190
- export var uiCardClickedEvent = function uiCardClickedEvent(id, display, status, definitionId, extensionKey, isModifierKeyPressed, location, destinationProduct) {
190
+ export var uiCardClickedEvent = function uiCardClickedEvent(id, display, status, definitionId, extensionKey, isModifierKeyPressed, location, destinationProduct, destinationSubproduct) {
191
191
  return {
192
192
  action: 'clicked',
193
193
  actionSubject: 'smartLink',
@@ -201,7 +201,8 @@ export var uiCardClickedEvent = function uiCardClickedEvent(id, display, status,
201
201
  display: display,
202
202
  isModifierKeyPressed: isModifierKeyPressed,
203
203
  location: location,
204
- destinationProduct: destinationProduct
204
+ destinationProduct: destinationProduct,
205
+ destinationSubproduct: destinationSubproduct
205
206
  })
206
207
  };
207
208
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "19.1.19",
3
+ "version": "19.1.22",
4
4
  "sideEffects": false
5
5
  }
@@ -1,7 +1,7 @@
1
1
  import React, { useEffect, useCallback, useMemo } from 'react';
2
2
  import { isSpecialEvent } from '../../utils';
3
3
  import * as measure from '../../utils/performance';
4
- import { getDefinitionId, getServices, isFinalState, getClickUrl, getResourceType, getExtensionKey } from '../../state/helpers';
4
+ import { getDefinitionId, getServices, isFinalState, getClickUrl, getResourceType, getExtensionKey, getSubproduct, getProduct } from '../../state/helpers';
5
5
  import { useSmartLink } from '../../state';
6
6
  import { BlockCard } from '../BlockCard';
7
7
  import { InlineCard } from '../InlineCard';
@@ -42,6 +42,8 @@ export function CardWithUrlContent(_ref) {
42
42
  var definitionId = getDefinitionId(state.details);
43
43
  var extensionKey = getExtensionKey(state.details);
44
44
  var resourceType = getResourceType(state.details);
45
+ var product = getProduct(state.details);
46
+ var subproduct = getSubproduct(state.details);
45
47
  var services = getServices(state.details);
46
48
  var isFlexibleUi = useMemo(function () {
47
49
  return isFlexibleUiCard(children);
@@ -53,14 +55,14 @@ export function CardWithUrlContent(_ref) {
53
55
  }, [state.details, url]);
54
56
  var handleClickWrapper = useCallback(function (event) {
55
57
  var isModifierKeyPressed = isSpecialEvent(event);
56
- analytics.ui.cardClickedEvent(id, isFlexibleUi ? 'flexible' : appearance, state.status, definitionId, extensionKey, isModifierKeyPressed);
58
+ analytics.ui.cardClickedEvent(id, isFlexibleUi ? 'flexible' : appearance, state.status, definitionId, extensionKey, isModifierKeyPressed, undefined, product, subproduct);
57
59
 
58
60
  if (onClick) {
59
61
  onClick(event);
60
62
  } else if (!isFlexibleUi) {
61
63
  handleClick(event);
62
64
  }
63
- }, [id, state.status, analytics.ui, appearance, definitionId, extensionKey, onClick, handleClick, isFlexibleUi]);
65
+ }, [id, state.status, analytics.ui, appearance, definitionId, extensionKey, onClick, handleClick, isFlexibleUi, product, subproduct]);
64
66
  var handleAuthorize = useCallback(function () {
65
67
  return actions.authorize(appearance);
66
68
  }, [actions, appearance]);
@@ -1,12 +1,13 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
2
 
3
- var _templateObject, _templateObject2, _templateObject3;
3
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
4
4
 
5
5
  /** @jsx jsx */
6
6
  import React from 'react';
7
7
  import { css, jsx } from '@emotion/core';
8
8
  import { SmartLinkAlignment, SmartLinkDirection, SmartLinkSize, SmartLinkWidth } from '../../../../../constants';
9
- import { getBaseStyles, renderChildren } from '../utils';
9
+ import { getBaseStyles, getGapSize, renderChildren } from '../utils';
10
+ import { getMaxLineHeight, getTruncateStyles } from '../../utils';
10
11
 
11
12
  var getAlignmentStyles = function getAlignmentStyles(align) {
12
13
  switch (align) {
@@ -19,8 +20,23 @@ var getAlignmentStyles = function getAlignmentStyles(align) {
19
20
  }
20
21
  };
21
22
 
23
+ var getGapStyles = function getGapStyles(size, align) {
24
+ var gap = getGapSize(size);
25
+
26
+ if (align === SmartLinkAlignment.Right) {
27
+ return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n > span {\n margin-left: ", "rem;\n &:first-child {\n margin-left: initial;\n }\n }\n "])), gap);
28
+ }
29
+
30
+ return css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n > span {\n margin-right: ", "rem;\n &:last-child {\n margin-right: initial;\n }\n }\n "])), gap);
31
+ };
32
+
33
+ var getHorizontalDirectionStyles = function getHorizontalDirectionStyles(size, align) {
34
+ var lineHeight = getMaxLineHeight(size);
35
+ return css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n display: block;\n vertical-align: middle;\n ", "\n\n > span, > div {\n vertical-align: middle;\n\n &[data-smart-element-date-time],\n &[data-smart-element-text] {\n // Show all/wrapped/truncated\n display: inline;\n }\n }\n\n ", "\n "])), getTruncateStyles(1, lineHeight + 'rem'), getGapStyles(size, align));
36
+ };
37
+
22
38
  export var getElementGroupStyles = function getElementGroupStyles(direction, size, align, width) {
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;" : '');
39
+ return css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n ", "\n ", "\n min-width: 10%;\n ", "\n ", "\n"])), getBaseStyles(direction, size), getAlignmentStyles(align), width === SmartLinkWidth.Flexible ? "flex: 1 3;" : '', direction === SmartLinkDirection.Horizontal ? getHorizontalDirectionStyles(size, align) : '');
24
40
  };
25
41
  /**
26
42
  * Creates a group of Action components. Accepts an array of Actions, in addition to some styling
@@ -1,10 +1,24 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
3
+
4
+ var _templateObject;
5
+
2
6
  import React from 'react';
3
- import { SmartLinkAlignment, SmartLinkDirection, SmartLinkStatus, SmartLinkWidth } from '../../../../../constants';
7
+ import { css } from '@emotion/core';
8
+ import { SmartLinkAlignment, SmartLinkDirection, SmartLinkSize, SmartLinkStatus, SmartLinkWidth } from '../../../../../constants';
4
9
  import Block from '../block';
5
10
  import ElementGroup from '../element-group';
6
11
  import { Provider } from '../../elements';
7
12
  import ActionGroup from '../action-group';
13
+
14
+ var getActionGroupStyles = function getActionGroupStyles(size) {
15
+ if (size === SmartLinkSize.XLarge) {
16
+ // The biggest height of the action button exceeds the max line-height
17
+ // of the elements causing the action on the block with x-large size to
18
+ // get cut at the bottom.
19
+ return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n max-height: 2rem;\n "])));
20
+ }
21
+ };
8
22
  /**
9
23
  * Represents a FooterBlock, designed to contain elements and actions that should appear
10
24
  * at the bottom of a link card.
@@ -13,9 +27,12 @@ import ActionGroup from '../action-group';
13
27
  * @see Block
14
28
  */
15
29
 
30
+
16
31
  var FooterBlock = function FooterBlock(props) {
17
32
  var status = props.status,
18
33
  actions = props.actions,
34
+ _props$size = props.size,
35
+ size = _props$size === void 0 ? SmartLinkSize.Medium : _props$size,
19
36
  _props$testId = props.testId,
20
37
  testId = _props$testId === void 0 ? 'smart-footer-block' : _props$testId;
21
38
 
@@ -31,6 +48,7 @@ var FooterBlock = function FooterBlock(props) {
31
48
  testId: "smart-element-group-actions",
32
49
  align: SmartLinkAlignment.Right,
33
50
  direction: SmartLinkDirection.Horizontal,
51
+ overrideCss: getActionGroupStyles(size),
34
52
  width: SmartLinkWidth.Flexible
35
53
  }, /*#__PURE__*/React.createElement(ActionGroup, {
36
54
  items: actions,
@@ -8,9 +8,10 @@ var _templateObject;
8
8
  import React from 'react';
9
9
  import { css } from '@emotion/core';
10
10
  import { SmartLinkAlignment, SmartLinkDirection, SmartLinkSize, SmartLinkStatus, SmartLinkWidth } from '../../../../../constants';
11
- import { getGapSize, renderElementItems } from '../utils';
11
+ import { renderElementItems } from '../utils';
12
12
  import Block from '../block';
13
13
  import ElementGroup from '../element-group';
14
+ import { getMaxLineHeight, getTruncateStyles } from '../../utils';
14
15
  var DEFAULT_MAX_LINES = 2;
15
16
  var MAXIMUM_MAX_LINES = 2;
16
17
  var MINIMUM_MAX_LINES = 1;
@@ -18,31 +19,10 @@ var MINIMUM_MAX_LINES = 1;
18
19
  var getElementGroupStyles = function getElementGroupStyles(size, maxLines) {
19
20
  // MetadataBlock allows metadata elements to be displayed in
20
21
  // multiple lines, with maximum of 2 lines.
21
- // a) We need the height of the line to be equal on both left and right
22
- // sides so they line up nicely.
23
- // b) There is no way to truncate non-text elements nicely. Here
24
- // it's fix max height of the element group so that anything that is
25
- // overflown will not be visible.
26
- var lineHeight = getLineHeight(size);
27
- var gap = getGapSize(size);
28
- var gapHeight = gap * (maxLines - 1);
29
- var height = lineHeight * maxLines + gapHeight;
30
- return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n flex-wrap: wrap;\n line-height: ", "rem;\n max-height: ", "rem;\n > span,\n > div {\n min-height: ", "rem;\n max-height: ", "rem;\n line-height: ", "rem;\n }\n "])), lineHeight, height, lineHeight, lineHeight, lineHeight);
31
- };
32
-
33
- var getLineHeight = function getLineHeight(size) {
34
- // The maximum height of all elements in specific size.
35
- // These heights belongs to AvatarGroup.
36
- switch (size) {
37
- case SmartLinkSize.XLarge:
38
- case SmartLinkSize.Large:
39
- return 1.75;
40
-
41
- case SmartLinkSize.Medium:
42
- case SmartLinkSize.Small:
43
- default:
44
- return 1.5;
45
- }
22
+ // We need the height of the line to be equal on both left and right
23
+ // sides so they line up nicely.
24
+ var lineHeight = getMaxLineHeight(size);
25
+ return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n line-height: ", "rem;\n ", "\n "])), lineHeight, getTruncateStyles(maxLines, lineHeight + 'rem'));
46
26
  };
47
27
 
48
28
  var getMaxLines = function getMaxLines(maxLines) {
@@ -50,7 +50,7 @@ export var getGapSize = function getGapSize(size) {
50
50
  }
51
51
  };
52
52
  export var getBaseStyles = function getBaseStyles(direction, size) {
53
- return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n gap: ", "rem;\n line-height: 1rem;\n min-width: 0;\n overflow: hidden;\n ", ";\n &:empty {\n display: none;\n }\n & > * {\n min-width: 0;\n }\n & > [data-fit-to-content] {\n min-width: fit-content;\n }\n"])), getGapSize(size), getDirectionStyles(direction));
53
+ return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n align-items: center;\n display: flex;\n gap: ", "rem;\n line-height: 1rem;\n min-width: 0;\n overflow: hidden;\n ", ";\n &:empty {\n display: none;\n }\n & > * {\n min-width: 0;\n }\n & > [data-fit-to-content] {\n min-width: fit-content;\n }\n"])), getGapSize(size), getDirectionStyles(direction));
54
54
  };
55
55
 
56
56
  var isActionGroup = function isActionGroup(node) {