@atlaskit/smart-card 19.1.18 → 19.1.21

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 (60) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cjs/constants.js +2 -1
  3. package/dist/cjs/extractors/flexible/index.js +3 -0
  4. package/dist/cjs/extractors/flexible/latest-commit/index.js +21 -0
  5. package/dist/cjs/version.json +1 -1
  6. package/dist/cjs/view/FlexibleCard/components/blocks/element-group/index.js +19 -2
  7. package/dist/cjs/view/FlexibleCard/components/blocks/footer-block/index.js +19 -0
  8. package/dist/cjs/view/FlexibleCard/components/blocks/metadata-block/index.js +6 -25
  9. package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +2 -2
  10. package/dist/cjs/view/FlexibleCard/components/elements/avatar-group/index.js +5 -3
  11. package/dist/cjs/view/FlexibleCard/components/elements/badge/index.js +4 -4
  12. package/dist/cjs/view/FlexibleCard/components/elements/index.js +8 -2
  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/elements/utils.js +6 -0
  16. package/dist/cjs/view/FlexibleCard/components/utils.js +19 -2
  17. package/dist/cjs/view/HoverCard/components/hover-card-content.js +2 -1
  18. package/dist/cjs/view/HoverCard/utils.js +6 -3
  19. package/dist/es2019/constants.js +2 -1
  20. package/dist/es2019/extractors/flexible/index.js +2 -0
  21. package/dist/es2019/extractors/flexible/latest-commit/index.js +12 -0
  22. package/dist/es2019/version.json +1 -1
  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 +3 -1
  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/index.js +5 -0
  30. package/dist/es2019/view/FlexibleCard/components/elements/lozenge/index.js +1 -0
  31. package/dist/es2019/view/FlexibleCard/components/elements/media/index.js +2 -1
  32. package/dist/es2019/view/FlexibleCard/components/elements/utils.js +7 -0
  33. package/dist/es2019/view/FlexibleCard/components/utils.js +17 -1
  34. package/dist/es2019/view/HoverCard/components/hover-card-content.js +2 -1
  35. package/dist/es2019/view/HoverCard/utils.js +4 -3
  36. package/dist/esm/constants.js +2 -1
  37. package/dist/esm/extractors/flexible/index.js +2 -0
  38. package/dist/esm/extractors/flexible/latest-commit/index.js +12 -0
  39. package/dist/esm/version.json +1 -1
  40. package/dist/esm/view/FlexibleCard/components/blocks/element-group/index.js +19 -3
  41. package/dist/esm/view/FlexibleCard/components/blocks/footer-block/index.js +19 -1
  42. package/dist/esm/view/FlexibleCard/components/blocks/metadata-block/index.js +6 -26
  43. package/dist/esm/view/FlexibleCard/components/blocks/utils.js +2 -2
  44. package/dist/esm/view/FlexibleCard/components/elements/avatar-group/index.js +5 -3
  45. package/dist/esm/view/FlexibleCard/components/elements/badge/index.js +4 -4
  46. package/dist/esm/view/FlexibleCard/components/elements/index.js +5 -0
  47. package/dist/esm/view/FlexibleCard/components/elements/lozenge/index.js +1 -1
  48. package/dist/esm/view/FlexibleCard/components/elements/media/index.js +1 -1
  49. package/dist/esm/view/FlexibleCard/components/elements/utils.js +6 -0
  50. package/dist/esm/view/FlexibleCard/components/utils.js +15 -1
  51. package/dist/esm/view/HoverCard/components/hover-card-content.js +2 -1
  52. package/dist/esm/view/HoverCard/utils.js +4 -3
  53. package/dist/types/constants.d.ts +3 -2
  54. package/dist/types/extractors/common/__mocks__/jsonld.d.ts +91 -0
  55. package/dist/types/extractors/flexible/latest-commit/index.d.ts +2 -0
  56. package/dist/types/state/flexible-ui-context/types.d.ts +4 -0
  57. package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +1 -1
  58. package/dist/types/view/FlexibleCard/components/elements/index.d.ts +4 -0
  59. package/dist/types/view/FlexibleCard/components/utils.d.ts +1 -0
  60. package/package.json +3 -3
@@ -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;
@@ -26,7 +26,8 @@ export const ElementDisplaySchema = {
26
26
  [ElementName.State]: ['inline'],
27
27
  [ElementName.SubscriberCount]: ['inline'],
28
28
  [ElementName.Title]: ['inline'],
29
- [ElementName.Provider]: ['inline']
29
+ [ElementName.Provider]: ['inline'],
30
+ [ElementName.LatestCommit]: ['inline']
30
31
  };
31
32
 
32
33
  const getDirectionStyles = direction => {
@@ -63,6 +64,7 @@ export const getGapSize = size => {
63
64
  }
64
65
  };
65
66
  export const getBaseStyles = (direction, size) => css`
67
+ align-items: center;
66
68
  display: flex;
67
69
  gap: ${getGapSize(size)}rem;
68
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,
@@ -51,6 +51,11 @@ export const CreatedBy = createElement(ElementName.CreatedBy);
51
51
  */
52
52
 
53
53
  export const CreatedOn = createElement(ElementName.CreatedOn);
54
+ /**
55
+ * Creates an element that contains Last Commit hash
56
+ */
57
+
58
+ export const LatestCommit = createElement(ElementName.LatestCommit);
54
59
  /**
55
60
  * Creates a LinkIcon Icon element using the data from LinkIcon in the Flexible UI Context.
56
61
  * @see Icon
@@ -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%;
@@ -95,6 +95,12 @@ const elementMappings = {
95
95
  },
96
96
  [ElementName.Provider]: {
97
97
  component: Badge
98
+ },
99
+ [ElementName.LatestCommit]: {
100
+ component: Badge,
101
+ props: {
102
+ icon: IconType.Commit
103
+ }
98
104
  }
99
105
  };
100
106
 
@@ -122,6 +128,7 @@ const getData = (elementName, contextKey, context) => {
122
128
  case ElementName.VoteCount:
123
129
  case ElementName.ProgrammingLanguage:
124
130
  case ElementName.SubscriberCount:
131
+ case ElementName.LatestCommit:
125
132
  return toBadgeProps(data);
126
133
 
127
134
  case ElementName.CreatedBy:
@@ -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
  };
@@ -81,7 +81,7 @@ export var SmartLinkWidth;
81
81
  /**
82
82
  * Flexible UI element name - each reflecting the link data its represented.
83
83
  * When adding an element...
84
- * 1) Create base element if it doesn't already existed.
84
+ * 1) Create base element if it doesn't already exist.
85
85
  * Base element are inside src/view/FlexibleCard/components/elements.
86
86
  * E.g. Badge,DateTime, Icon, Lozenge, etc.
87
87
  * 2) Update FlexibleUiContext with the new prop for data representing
@@ -125,6 +125,7 @@ export var ElementName;
125
125
  ElementName["Title"] = "Title";
126
126
  ElementName["ViewCount"] = "ViewCount";
127
127
  ElementName["VoteCount"] = "VoteCount";
128
+ ElementName["LatestCommit"] = "LatestCommit";
128
129
  })(ElementName || (ElementName = {}));
129
130
 
130
131
  export var ActionName;
@@ -9,6 +9,7 @@ import { extractDateCreated } from '../common/date/extractDateCreated';
9
9
  import extractPriority from './extract-priority';
10
10
  import extractProviderIcon from './icon/extract-provider-icon';
11
11
  import extractPreview from './extract-preview';
12
+ import { extractLatestCommit } from './latest-commit';
12
13
 
13
14
  var extractFlexibleUiContext = function extractFlexibleUiContext(response, renderers) {
14
15
  if (!response) {
@@ -38,6 +39,7 @@ var extractFlexibleUiContext = function extractFlexibleUiContext(response, rende
38
39
  subscriberCount: extractSubscriberCount(data),
39
40
  title: extractTitle(data) || url,
40
41
  provider: extractProviderIcon(data),
42
+ latestCommit: extractLatestCommit(data),
41
43
  url: url
42
44
  };
43
45
  };
@@ -0,0 +1,12 @@
1
+ export var extractLatestCommit = function extractLatestCommit(jsonLd) {
2
+ var latestCommit = jsonLd['atlassian:latestCommit'];
3
+
4
+ if (typeof latestCommit === 'string') {
5
+ return latestCommit;
6
+ }
7
+
8
+ if (latestCommit) {
9
+ //todo: change the properties to latestCommit.hash when BE is ready
10
+ return latestCommit ? latestCommit.name : undefined;
11
+ }
12
+ };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "19.1.18",
3
+ "version": "19.1.21",
4
4
  "sideEffects": false
5
5
  }
@@ -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) {
@@ -20,7 +20,7 @@ import * as Actions from '../actions';
20
20
  import { isFlexibleUiElement } from '../../../../utils/flexible';
21
21
  import ActionGroup from './action-group';
22
22
  import ElementGroup from './element-group';
23
- export var ElementDisplaySchema = (_ElementDisplaySchema = {}, _defineProperty(_ElementDisplaySchema, ElementName.AuthorGroup, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CollaboratorGroup, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CommentCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ViewCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ReactCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.VoteCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CreatedBy, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CreatedOn, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.LinkIcon, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ModifiedBy, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ModifiedOn, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Preview, ['block']), _defineProperty(_ElementDisplaySchema, ElementName.Priority, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ProgrammingLanguage, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Snippet, ['block']), _defineProperty(_ElementDisplaySchema, ElementName.State, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.SubscriberCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Title, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Provider, ['inline']), _ElementDisplaySchema);
23
+ export var ElementDisplaySchema = (_ElementDisplaySchema = {}, _defineProperty(_ElementDisplaySchema, ElementName.AuthorGroup, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CollaboratorGroup, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CommentCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ViewCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ReactCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.VoteCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CreatedBy, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CreatedOn, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.LinkIcon, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ModifiedBy, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ModifiedOn, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Preview, ['block']), _defineProperty(_ElementDisplaySchema, ElementName.Priority, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ProgrammingLanguage, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Snippet, ['block']), _defineProperty(_ElementDisplaySchema, ElementName.State, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.SubscriberCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Title, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Provider, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.LatestCommit, ['inline']), _ElementDisplaySchema);
24
24
 
25
25
  var getDirectionStyles = function getDirectionStyles(direction) {
26
26
  switch (direction) {
@@ -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) {
@@ -1,6 +1,6 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
2
 
3
- var _templateObject;
3
+ var _templateObject, _templateObject2;
4
4
 
5
5
  /** @jsx jsx */
6
6
  import React from 'react';
@@ -10,16 +10,18 @@ import { SmartLinkSize } from '../../../../../constants';
10
10
  var MAX_COUNT = 4;
11
11
 
12
12
  var getStyles = function getStyles(size) {
13
+ var styles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline-flex;\n "])));
14
+
13
15
  switch (size) {
14
16
  case SmartLinkSize.XLarge:
15
17
  case SmartLinkSize.Large:
16
18
  // Default AK small size
17
- return;
19
+ return styles;
18
20
 
19
21
  case SmartLinkSize.Medium:
20
22
  case SmartLinkSize.Small:
21
23
  default:
22
- return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n li {\n span,\n svg {\n max-height: 1.25rem;\n max-width: 1.25rem;\n }\n }\n "])));
24
+ return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", "\n li {\n span,\n svg {\n max-height: 1.25rem;\n max-width: 1.25rem;\n }\n }\n "])), styles);
23
25
  }
24
26
  };
25
27
  /**
@@ -12,9 +12,9 @@ import { IconType } from '../../../../../constants';
12
12
  import { messages } from '../../../../../messages';
13
13
  import ImageIcon from '../../common/image-icon';
14
14
  import AtlaskitIcon from '../../common/atlaskit-icon';
15
- var badgeStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n align-items: center;\n display: flex;\n min-width: fit-content;\n"])));
16
- var iconStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n color: ", ";\n ", "\n span,\n svg {\n line-height: 0;\n }\n"])), tokens.badgeIcon, getIconSizeStyles('1rem'));
17
- var labelStyles = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n color: ", ";\n font-size: 0.75rem;\n line-height: 1rem;\n padding-left: 0.125rem;\n"])), tokens.badgeText);
15
+ var badgeStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n align-items: center;\n display: inline-flex;\n min-width: fit-content;\n"])));
16
+ var iconStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n color: ", ";\n line-height: 0;\n vertical-align: middle;\n ", "\n img,\n span,\n svg {\n line-height: 0;\n vertical-align: middle;\n }\n"])), tokens.badgeIcon, getIconSizeStyles('1rem'));
17
+ var labelStyles = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n color: ", ";\n font-size: 0.75rem;\n line-height: 1rem;\n padding-left: 0.125rem;\n vertical-align: middle;\n"])), tokens.badgeText);
18
18
  var messageMapper = (_messageMapper = {}, _defineProperty(_messageMapper, IconType.PriorityBlocker, messages.priority_blocker), _defineProperty(_messageMapper, IconType.PriorityCritical, messages.priority_critical), _defineProperty(_messageMapper, IconType.PriorityHigh, messages.priority_high), _defineProperty(_messageMapper, IconType.PriorityHighest, messages.priority_highest), _defineProperty(_messageMapper, IconType.PriorityLow, messages.priority_low), _defineProperty(_messageMapper, IconType.PriorityLowest, messages.priority_lowest), _defineProperty(_messageMapper, IconType.PriorityMajor, messages.priority_major), _defineProperty(_messageMapper, IconType.PriorityMedium, messages.priority_medium), _defineProperty(_messageMapper, IconType.PriorityMinor, messages.priority_minor), _defineProperty(_messageMapper, IconType.PriorityTrivial, messages.priority_trivial), _defineProperty(_messageMapper, IconType.PriorityUndefined, messages.priority_undefined), _messageMapper);
19
19
 
20
20
  var getFormattedMessageFromIcon = function getFormattedMessageFromIcon(icon) {
@@ -76,7 +76,7 @@ var Badge = function Badge(_ref) {
76
76
  return null;
77
77
  }
78
78
 
79
- return jsx("div", {
79
+ return jsx("span", {
80
80
  css: [badgeStyles, overrideCss],
81
81
  "data-fit-to-content": true,
82
82
  "data-smart-element-badge": true,
@@ -51,6 +51,11 @@ export var CreatedBy = createElement(ElementName.CreatedBy);
51
51
  */
52
52
 
53
53
  export var CreatedOn = createElement(ElementName.CreatedOn);
54
+ /**
55
+ * Creates an element that contains Last Commit hash
56
+ */
57
+
58
+ export var LatestCommit = createElement(ElementName.LatestCommit);
54
59
  /**
55
60
  * Creates a LinkIcon Icon element using the data from LinkIcon in the Flexible UI Context.
56
61
  * @see Icon
@@ -6,7 +6,7 @@ var _templateObject;
6
6
  import React from 'react';
7
7
  import { css, jsx } from '@emotion/core';
8
8
  import AtlaskitLozenge from '@atlaskit/lozenge';
9
- var styles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n line-height: inherit;\n"])));
9
+ var styles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline-flex;\n line-height: inherit;\n"])));
10
10
  /**
11
11
  * A base element that displays a Lozenge.
12
12
  * @internal
@@ -17,7 +17,7 @@ import ImageIcon from '../../common/image-icon';
17
17
  * [object-position] Center alignment of the selected replaced element's
18
18
  * contents within the element's box.
19
19
  */
20
- var styles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n aspect-ratio: 16 / 9;\n display: flex;\n width: 100%;\n height: fit-content; // Fix Safari height not respecting aspect-ratio\n\n // fallback\n @supports not (aspect-ratio: auto) {\n padding-top: 56.25%; // 16:9 ratio (9 / 16 = 0.5625)\n height: 0;\n position: relative;\n overflow: hidden;\n }\n\n > img {\n min-height: 100%;\n min-width: 100%;\n max-height: 100%;\n max-width: 100%;\n object-fit: cover;\n object-position: center center;\n\n // fallback\n @supports not (aspect-ratio: auto) {\n position: absolute;\n transform: translate(-50%, -50%);\n left: 50%;\n top: 50%;\n width: auto;\n height: auto;\n }\n }\n"])));
20
+ var styles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n aspect-ratio: 16 / 9;\n display: flex;\n width: 100%;\n height: fit-content; // Fix Safari height not respecting aspect-ratio\n\n // fallback\n @supports not (aspect-ratio: auto) {\n padding-top: 56.25%; // 16:9 ratio (9 / 16 = 0.5625)\n height: 0;\n position: relative;\n overflow: hidden;\n }\n\n > img,\n > span {\n min-height: 100%;\n min-width: 100%;\n max-height: 100%;\n max-width: 100%;\n object-fit: cover;\n object-position: center center;\n\n // fallback\n @supports not (aspect-ratio: auto) {\n position: absolute;\n transform: translate(-50%, -50%);\n left: 50%;\n top: 50%;\n width: auto;\n height: auto;\n }\n }\n"])));
21
21
  /**
22
22
  * A base element that displays a Media.
23
23
  * @internal
@@ -79,6 +79,11 @@ var elementMappings = (_elementMappings = {}, _defineProperty(_elementMappings,
79
79
  component: DateTime
80
80
  }), _defineProperty(_elementMappings, ElementName.Provider, {
81
81
  component: Badge
82
+ }), _defineProperty(_elementMappings, ElementName.LatestCommit, {
83
+ component: Badge,
84
+ props: {
85
+ icon: IconType.Commit
86
+ }
82
87
  }), _elementMappings);
83
88
 
84
89
  var getContextKey = function getContextKey(name) {
@@ -105,6 +110,7 @@ var getData = function getData(elementName, contextKey, context) {
105
110
  case ElementName.VoteCount:
106
111
  case ElementName.ProgrammingLanguage:
107
112
  case ElementName.SubscriberCount:
113
+ case ElementName.LatestCommit:
108
114
  return toBadgeProps(data);
109
115
 
110
116
  case ElementName.CreatedBy:
@@ -67,6 +67,20 @@ export var getLinkSizeStyles = function getLinkSizeStyles(size) {
67
67
  return css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n font-size: 0.75rem;\n font-weight: 400;\n letter-spacing: 0em;\n line-height: ", ";\n "])), getLinkLineHeight(size));
68
68
  }
69
69
  };
70
+ export var getMaxLineHeight = function getMaxLineHeight(size) {
71
+ // The maximum line height based on all elements in specific size.
72
+ // These heights belongs to AvatarGroup.
73
+ switch (size) {
74
+ case SmartLinkSize.XLarge:
75
+ case SmartLinkSize.Large:
76
+ return 1.75;
77
+
78
+ case SmartLinkSize.Medium:
79
+ case SmartLinkSize.Small:
80
+ default:
81
+ return 1.5;
82
+ }
83
+ };
70
84
  export var getMaxLines = function getMaxLines(value, defaultValue, max, min) {
71
85
  if (value > max) {
72
86
  return defaultValue;
@@ -81,7 +95,7 @@ export var getMaxLines = function getMaxLines(value, defaultValue, max, min) {
81
95
  export var getTruncateStyles = function getTruncateStyles(maxLines) {
82
96
  var lineHeight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '1rem';
83
97
  var wordBreak = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'break-word';
84
- return css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n display: -webkit-box;\n overflow: hidden;\n text-overflow: ellipsis;\n word-break: ", ";\n -webkit-line-clamp: ", ";\n -webkit-box-orient: vertical;\n // Fallback options\n max-height: calc(", " * ", ");\n "])), wordBreak, maxLines, maxLines, lineHeight);
98
+ return css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n display: -webkit-box;\n overflow: hidden;\n text-overflow: ellipsis;\n word-break: ", ";\n -webkit-line-clamp: ", ";\n -webkit-box-orient: vertical;\n // Fallback options\n @supports not (-webkit-line-clamp: 1) {\n max-height: calc(", " * ", ");\n }\n "])), wordBreak, maxLines, maxLines, lineHeight);
85
99
  };
86
100
  export var hasWhiteSpace = function hasWhiteSpace(str) {
87
101
  return str.search(/\s/) >= 0;
@@ -90,7 +90,8 @@ var HoverCardContent = function HoverCardContent(_ref) {
90
90
  actions: titleActions
91
91
  }), /*#__PURE__*/React.createElement(MetadataBlock, {
92
92
  primary: primary,
93
- secondary: secondary
93
+ secondary: secondary,
94
+ size: SmartLinkSize.Small
94
95
  }), body, /*#__PURE__*/React.createElement(FooterBlock, {
95
96
  actions: footerActions
96
97
  }));