@atlaskit/smart-card 17.2.1 → 17.4.0

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 (67) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/cjs/constants.js +16 -1
  3. package/dist/cjs/extractors/flexible/icon/extract-document-type-icon.js +28 -7
  4. package/dist/cjs/extractors/flexible/icon/extract-file-formatIcon.js +88 -22
  5. package/dist/cjs/extractors/flexible/icon/extract-jira-task-icon.js +36 -9
  6. package/dist/cjs/extractors/flexible/icon/extract-jsonld-data-icon.js +33 -9
  7. package/dist/cjs/extractors/flexible/icon/extract-provider-icon.js +20 -3
  8. package/dist/cjs/extractors/flexible/icon/extract-url-icon.js +4 -1
  9. package/dist/cjs/extractors/flexible/icon/index.js +11 -20
  10. package/dist/cjs/extractors/flexible/index.js +5 -0
  11. package/dist/cjs/version.json +1 -1
  12. package/dist/cjs/view/FlexibleCard/components/blocks/metadata-block/index.js +17 -3
  13. package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +27 -7
  14. package/dist/cjs/view/FlexibleCard/components/common/atlaskit-icon/index.js +2 -0
  15. package/dist/cjs/view/FlexibleCard/components/elements/avatar-group/index.js +24 -2
  16. package/dist/cjs/view/FlexibleCard/components/elements/badge/index.js +2 -4
  17. package/dist/cjs/view/FlexibleCard/components/elements/index.js +6 -2
  18. package/dist/cjs/view/FlexibleCard/components/elements/text/index.js +6 -2
  19. package/dist/cjs/view/FlexibleCard/components/elements/utils.js +64 -39
  20. package/dist/es2019/constants.js +15 -1
  21. package/dist/es2019/extractors/flexible/icon/extract-document-type-icon.js +28 -7
  22. package/dist/es2019/extractors/flexible/icon/extract-file-formatIcon.js +88 -22
  23. package/dist/es2019/extractors/flexible/icon/extract-jira-task-icon.js +36 -9
  24. package/dist/es2019/extractors/flexible/icon/extract-jsonld-data-icon.js +33 -9
  25. package/dist/es2019/extractors/flexible/icon/extract-provider-icon.js +19 -3
  26. package/dist/es2019/extractors/flexible/icon/extract-url-icon.js +4 -1
  27. package/dist/es2019/extractors/flexible/icon/index.js +6 -9
  28. package/dist/es2019/extractors/flexible/index.js +5 -1
  29. package/dist/es2019/version.json +1 -1
  30. package/dist/es2019/view/FlexibleCard/components/blocks/metadata-block/index.js +17 -3
  31. package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +38 -6
  32. package/dist/es2019/view/FlexibleCard/components/common/atlaskit-icon/index.js +2 -0
  33. package/dist/es2019/view/FlexibleCard/components/elements/avatar-group/index.js +28 -2
  34. package/dist/es2019/view/FlexibleCard/components/elements/badge/index.js +2 -4
  35. package/dist/es2019/view/FlexibleCard/components/elements/index.js +3 -1
  36. package/dist/es2019/view/FlexibleCard/components/elements/text/index.js +5 -3
  37. package/dist/es2019/view/FlexibleCard/components/elements/utils.js +66 -37
  38. package/dist/esm/constants.js +15 -1
  39. package/dist/esm/extractors/flexible/icon/extract-document-type-icon.js +28 -7
  40. package/dist/esm/extractors/flexible/icon/extract-file-formatIcon.js +88 -22
  41. package/dist/esm/extractors/flexible/icon/extract-jira-task-icon.js +36 -9
  42. package/dist/esm/extractors/flexible/icon/extract-jsonld-data-icon.js +33 -9
  43. package/dist/esm/extractors/flexible/icon/extract-provider-icon.js +19 -3
  44. package/dist/esm/extractors/flexible/icon/extract-url-icon.js +4 -1
  45. package/dist/esm/extractors/flexible/icon/index.js +12 -20
  46. package/dist/esm/extractors/flexible/index.js +5 -1
  47. package/dist/esm/version.json +1 -1
  48. package/dist/esm/view/FlexibleCard/components/blocks/metadata-block/index.js +17 -3
  49. package/dist/esm/view/FlexibleCard/components/blocks/utils.js +25 -7
  50. package/dist/esm/view/FlexibleCard/components/common/atlaskit-icon/index.js +2 -0
  51. package/dist/esm/view/FlexibleCard/components/elements/avatar-group/index.js +24 -2
  52. package/dist/esm/view/FlexibleCard/components/elements/badge/index.js +2 -4
  53. package/dist/esm/view/FlexibleCard/components/elements/index.js +3 -1
  54. package/dist/esm/view/FlexibleCard/components/elements/text/index.js +7 -2
  55. package/dist/esm/view/FlexibleCard/components/elements/utils.js +64 -39
  56. package/dist/types/__fixtures__/flexible-ui-data-context.d.ts +3 -0
  57. package/dist/types/constants.d.ts +3 -1
  58. package/dist/types/extractors/flexible/icon/extract-provider-icon.d.ts +1 -1
  59. package/dist/types/extractors/flexible/icon/index.d.ts +3 -3
  60. package/dist/types/extractors/flexible/icon/types.d.ts +5 -1
  61. package/dist/types/state/flexible-ui-context/types.d.ts +4 -2
  62. package/dist/types/view/FlexibleCard/components/blocks/utils.d.ts +4 -2
  63. package/dist/types/view/FlexibleCard/components/elements/avatar-group/index.d.ts +1 -0
  64. package/dist/types/view/FlexibleCard/components/elements/avatar-group/types.d.ts +1 -2
  65. package/dist/types/view/FlexibleCard/components/elements/index.d.ts +2 -0
  66. package/dist/types/view/FlexibleCard/components/elements/text/types.d.ts +1 -0
  67. package/package.json +1 -1
@@ -3,25 +3,46 @@ import { IconType } from '../../../constants';
3
3
  var extractDocumentTypeIcon = function extractDocumentTypeIcon(documentType, label) {
4
4
  switch (documentType) {
5
5
  case 'schema:BlogPosting':
6
- return [IconType.Blog, label || 'Blog'];
6
+ return {
7
+ icon: IconType.Blog,
8
+ label: label || 'Blog'
9
+ };
7
10
 
8
11
  case 'schema:DigitalDocument':
9
- return [IconType.File, label || 'File'];
12
+ return {
13
+ icon: IconType.File,
14
+ label: label || 'File'
15
+ };
10
16
 
11
17
  case 'schema:TextDigitalDocument':
12
- return [IconType.Document, label || 'Document'];
18
+ return {
19
+ icon: IconType.Document,
20
+ label: label || 'Document'
21
+ };
13
22
 
14
23
  case 'schema:PresentationDigitalDocument':
15
- return [IconType.Presentation, label || 'Presentation'];
24
+ return {
25
+ icon: IconType.Presentation,
26
+ label: label || 'Presentation'
27
+ };
16
28
 
17
29
  case 'schema:SpreadsheetDigitalDocument':
18
- return [IconType.Spreadsheet, label || 'Spreadsheet'];
30
+ return {
31
+ icon: IconType.Spreadsheet,
32
+ label: label || 'Spreadsheet'
33
+ };
19
34
 
20
35
  case 'atlassian:Template':
21
- return [IconType.Template, label || 'Template'];
36
+ return {
37
+ icon: IconType.Template,
38
+ label: label || 'Template'
39
+ };
22
40
 
23
41
  case 'atlassian:UndefinedLink':
24
- return [IconType.Document, label || 'Undefined link'];
42
+ return {
43
+ icon: IconType.Document,
44
+ label: label || 'Undefined link'
45
+ };
25
46
 
26
47
  default:
27
48
  return undefined;
@@ -4,66 +4,111 @@ var extractFileFormatIcon = function extractFileFormatIcon(fileFormat) {
4
4
  switch (fileFormat) {
5
5
  // Generic documents
6
6
  case 'folder':
7
- return [IconType.Folder, 'Folder'];
7
+ return {
8
+ icon: IconType.Folder,
9
+ label: 'Folder'
10
+ };
8
11
 
9
12
  case 'text/plain':
10
13
  case 'application/vnd.oasis.opendocument.text':
11
14
  case 'application/vnd.apple.pages':
12
- return [IconType.Document, 'Document'];
15
+ return {
16
+ icon: IconType.Document,
17
+ label: 'Document'
18
+ };
13
19
 
14
20
  case 'application/pdf':
15
- return [IconType.PDF, 'PDF document'];
21
+ return {
22
+ icon: IconType.PDF,
23
+ label: 'PDF document'
24
+ };
16
25
 
17
26
  case 'application/vnd.oasis.opendocument.presentation':
18
27
  case 'application/vnd.apple.keynote':
19
- return [IconType.Presentation, 'Presentation'];
28
+ return {
29
+ icon: IconType.Presentation,
30
+ label: 'Presentation'
31
+ };
20
32
 
21
33
  case 'application/vnd.oasis.opendocument.spreadsheet':
22
34
  case 'application/vnd.apple.numbers':
23
- return [IconType.Spreadsheet, 'Spreadsheet'];
35
+ return {
36
+ icon: IconType.Spreadsheet,
37
+ label: 'Spreadsheet'
38
+ };
24
39
  // Google Drive
25
40
 
26
41
  case 'application/vnd.google-apps.document':
27
- return [IconType.GoogleDocs, 'Google Docs'];
42
+ return {
43
+ icon: IconType.GoogleDocs,
44
+ label: 'Google Docs'
45
+ };
28
46
 
29
47
  case 'application/vnd.google-apps.form':
30
- return [IconType.GoogleForms, 'Google Form'];
48
+ return {
49
+ icon: IconType.GoogleForms,
50
+ label: 'Google Form'
51
+ };
31
52
 
32
53
  case 'application/vnd.google-apps.spreadsheet':
33
- return [IconType.GoogleSheets, 'Google Sheets'];
54
+ return {
55
+ icon: IconType.GoogleSheets,
56
+ label: 'Google Sheets'
57
+ };
34
58
 
35
59
  case 'application/vnd.google-apps.presentation':
36
- return [IconType.GoogleSlides, 'Google Slides'];
60
+ return {
61
+ icon: IconType.GoogleSlides,
62
+ label: 'Google Slides'
63
+ };
37
64
  // Microsoft
38
65
 
39
66
  case 'application/vnd.ms-excel':
40
67
  case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
41
- return [IconType.MSExcel, 'Excel spreadsheet'];
68
+ return {
69
+ icon: IconType.MSExcel,
70
+ label: 'Excel spreadsheet'
71
+ };
42
72
 
43
73
  case 'application/vnd.ms-powerpoint':
44
74
  case 'application/vnd.openxmlformats-officedocument.presentationml.presentation':
45
- return [IconType.MSPowerpoint, 'PowerPoint presentation'];
75
+ return {
76
+ icon: IconType.MSPowerpoint,
77
+ label: 'PowerPoint presentation'
78
+ };
46
79
 
47
80
  case 'application/msword':
48
81
  case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
49
- return [IconType.MSWord, 'Word document'];
82
+ return {
83
+ icon: IconType.MSWord,
84
+ label: 'Word document'
85
+ };
50
86
 
51
87
  case 'image/png':
52
88
  case 'image/jpeg':
53
89
  case 'image/bmp':
54
90
  case 'image/webp':
55
91
  case 'image/svg+xml':
56
- return [IconType.Image, 'Image'];
92
+ return {
93
+ icon: IconType.Image,
94
+ label: 'Image'
95
+ };
57
96
 
58
97
  case 'image/gif':
59
- return [IconType.GIF, 'GIF'];
98
+ return {
99
+ icon: IconType.GIF,
100
+ label: 'GIF'
101
+ };
60
102
 
61
103
  case 'audio/midi':
62
104
  case 'audio/mpeg':
63
105
  case 'audio/webm':
64
106
  case 'audio/ogg':
65
107
  case 'audio/wav':
66
- return [IconType.Audio, 'Audio'];
108
+ return {
109
+ icon: IconType.Audio,
110
+ label: 'Audio'
111
+ };
67
112
 
68
113
  case 'video/mp4':
69
114
  case 'video/quicktime':
@@ -72,13 +117,19 @@ var extractFileFormatIcon = function extractFileFormatIcon(fileFormat) {
72
117
  case 'video/ogg':
73
118
  case 'video/x-ms-wmv':
74
119
  case 'video/x-msvideo':
75
- return [IconType.Video, 'Video'];
120
+ return {
121
+ icon: IconType.Video,
122
+ label: 'Video'
123
+ };
76
124
  // Others
77
125
 
78
126
  case 'text/css':
79
127
  case 'text/html':
80
128
  case 'application/javascript':
81
- return [IconType.Code, 'Source Code'];
129
+ return {
130
+ icon: IconType.Code,
131
+ label: 'Source Code'
132
+ };
82
133
 
83
134
  case 'application/zip':
84
135
  case 'application/x-tar':
@@ -86,19 +137,34 @@ var extractFileFormatIcon = function extractFileFormatIcon(fileFormat) {
86
137
  case 'application/x-7z-compressed':
87
138
  case 'application/x-apple-diskimage':
88
139
  case 'application/vnd.rar':
89
- return [IconType.Archive, 'Archive'];
140
+ return {
141
+ icon: IconType.Archive,
142
+ label: 'Archive'
143
+ };
90
144
 
91
145
  case 'application/dmg':
92
- return [IconType.Executable, 'Executable'];
146
+ return {
147
+ icon: IconType.Executable,
148
+ label: 'Executable'
149
+ };
93
150
 
94
151
  case 'application/sketch':
95
- return [IconType.Sketch, 'Sketch'];
152
+ return {
153
+ icon: IconType.Sketch,
154
+ label: 'Sketch'
155
+ };
96
156
 
97
157
  case 'application/octet-stream':
98
- return [IconType.Generic, 'Binary file'];
158
+ return {
159
+ icon: IconType.Generic,
160
+ label: 'Binary file'
161
+ };
99
162
 
100
163
  case 'application/invision.prototype':
101
- return [IconType.Generic, 'Prototype'];
164
+ return {
165
+ icon: IconType.Generic,
166
+ label: 'Prototype'
167
+ };
102
168
 
103
169
  default:
104
170
  return undefined;
@@ -5,32 +5,59 @@ var extractJiraTaskIcon = function extractJiraTaskIcon(taskType) {
5
5
 
6
6
  switch (taskType) {
7
7
  case 'JiraBug':
8
- return [IconType.Bug, label];
8
+ return {
9
+ icon: IconType.Bug,
10
+ label: label
11
+ };
9
12
 
10
13
  case 'JiraChange':
11
- return [IconType.Change, label];
14
+ return {
15
+ icon: IconType.Change,
16
+ label: label
17
+ };
12
18
 
13
19
  case 'JiraEpic':
14
- return [IconType.Epic, label];
20
+ return {
21
+ icon: IconType.Epic,
22
+ label: label
23
+ };
15
24
 
16
25
  case 'JiraIncident':
17
- return [IconType.Incident, label];
26
+ return {
27
+ icon: IconType.Incident,
28
+ label: label
29
+ };
18
30
 
19
31
  case 'JiraProblem':
20
- return [IconType.Problem, label];
32
+ return {
33
+ icon: IconType.Problem,
34
+ label: label
35
+ };
21
36
 
22
37
  case 'JiraServiceRequest':
23
- return [IconType.ServiceRequest, label];
38
+ return {
39
+ icon: IconType.ServiceRequest,
40
+ label: label
41
+ };
24
42
 
25
43
  case 'JiraStory':
26
- return [IconType.Story, label];
44
+ return {
45
+ icon: IconType.Story,
46
+ label: label
47
+ };
27
48
 
28
49
  case 'JiraSubTask':
29
- return [IconType.SubTask, label];
50
+ return {
51
+ icon: IconType.SubTask,
52
+ label: label
53
+ };
30
54
 
31
55
  case 'JiraTask':
32
56
  default:
33
- return [IconType.Task, label];
57
+ return {
58
+ icon: IconType.Task,
59
+ label: label
60
+ };
34
61
  }
35
62
  };
36
63
 
@@ -15,7 +15,10 @@ var extractTask = function extractTask(data, label) {
15
15
  url = _ref.icon;
16
16
 
17
17
  var taskType = id === null || id === void 0 ? void 0 : id.split('#').pop();
18
- var taskIcon = url ? [undefined, label, url] : undefined;
18
+ var taskIcon = url ? {
19
+ label: label,
20
+ url: url
21
+ } : undefined;
19
22
  return {
20
23
  taskType: taskType,
21
24
  taskIcon: taskIcon
@@ -47,7 +50,7 @@ var extractJsonldDataIcon = function extractJsonldDataIcon(data) {
47
50
  var type = extractType(data);
48
51
  var urlIcon = extractUrlIcon(data.icon, label);
49
52
  var provider = generator === null || generator === void 0 ? void 0 : generator['@id'];
50
- var providerIcon = extractProviderIcon(provider, generator === null || generator === void 0 ? void 0 : generator.icon, label);
53
+ var providerIcon = extractProviderIcon(data);
51
54
 
52
55
  switch (type) {
53
56
  case 'Document':
@@ -76,25 +79,46 @@ var extractJsonldDataIcon = function extractJsonldDataIcon(data) {
76
79
  taskType = _extractTask.taskType,
77
80
  taskIcon = _extractTask.taskIcon;
78
81
 
79
- return taskType === 'JiraCustomTaskType' ? taskIcon || urlIcon || providerIcon || [IconType.Task, taskLabel] : extractJiraTaskIcon(taskType, taskLabel);
82
+ return taskType === 'JiraCustomTaskType' ? taskIcon || urlIcon || providerIcon || {
83
+ icon: IconType.Task,
84
+ label: taskLabel
85
+ } : extractJiraTaskIcon(taskType, taskLabel);
80
86
  }
81
87
 
82
- return [IconType.Task, taskLabel];
88
+ return {
89
+ icon: IconType.Task,
90
+ label: taskLabel
91
+ };
83
92
 
84
93
  case 'atlassian:Project':
85
- return urlIcon || [IconType.Project, label || 'Project'];
94
+ return urlIcon || {
95
+ icon: IconType.Project,
96
+ label: label || 'Project'
97
+ };
86
98
 
87
99
  case 'atlassian:SourceCodeCommit':
88
- return [IconType.Commit, label || 'Commit'];
100
+ return {
101
+ icon: IconType.Commit,
102
+ label: label || 'Commit'
103
+ };
89
104
 
90
105
  case 'atlassian:SourceCodePullRequest':
91
- return [IconType.PullRequest, label || 'Pull request'];
106
+ return {
107
+ icon: IconType.PullRequest,
108
+ label: label || 'Pull request'
109
+ };
92
110
 
93
111
  case 'atlassian:SourceCodeReference':
94
- return [IconType.Branch, label || 'Reference'];
112
+ return {
113
+ icon: IconType.Branch,
114
+ label: label || 'Reference'
115
+ };
95
116
 
96
117
  case 'atlassian:SourceCodeRepository':
97
- return [IconType.Repo, label || 'Repository'];
118
+ return {
119
+ icon: IconType.Repo,
120
+ label: label || 'Repository'
121
+ };
98
122
 
99
123
  default:
100
124
  return providerIcon;
@@ -1,14 +1,30 @@
1
1
  import { CONFLUENCE_GENERATOR_ID, JIRA_GENERATOR_ID } from '../../constants';
2
2
  import { IconType } from '../../../constants';
3
3
  import extractUrlIcon from './extract-url-icon';
4
+ import { extractTitle } from '../../common/primitives';
5
+
6
+ var extractProviderIcon = function extractProviderIcon(data) {
7
+ if (!data) {
8
+ return undefined;
9
+ }
10
+
11
+ var generator = data.generator;
12
+ var provider = generator === null || generator === void 0 ? void 0 : generator['@id'];
13
+ var icon = generator === null || generator === void 0 ? void 0 : generator.icon;
14
+ var label = (generator === null || generator === void 0 ? void 0 : generator.name) || extractTitle(data);
4
15
 
5
- var extractProviderIcon = function extractProviderIcon(provider, icon, label) {
6
16
  if (provider === CONFLUENCE_GENERATOR_ID) {
7
- return [IconType.Confluence, label || 'Confluence'];
17
+ return {
18
+ icon: IconType.Confluence,
19
+ label: label || 'Confluence'
20
+ };
8
21
  }
9
22
 
10
23
  if (provider === JIRA_GENERATOR_ID) {
11
- return [IconType.Jira, label || 'Jira'];
24
+ return {
25
+ icon: IconType.Jira,
26
+ label: label || 'Jira'
27
+ };
12
28
  }
13
29
 
14
30
  return extractUrlIcon(icon, label);
@@ -2,7 +2,10 @@ import { extractUrlFromIconJsonLd } from '../../common/utils';
2
2
 
3
3
  var extractUrlIcon = function extractUrlIcon(icon, label) {
4
4
  var url = icon && extractUrlFromIconJsonLd(icon);
5
- return url ? [undefined, label, url] : undefined;
5
+ return url ? {
6
+ label: label,
7
+ url: url
8
+ } : undefined;
6
9
  };
7
10
 
8
11
  export default extractUrlIcon;
@@ -1,36 +1,28 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
+
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
+
2
7
  import extractJsonldDataIcon from './extract-jsonld-data-icon';
3
8
  import extractProviderIcon from './extract-provider-icon';
4
9
  import { IconType, SmartLinkStatus } from '../../../constants';
5
10
  import extractIconRenderer from './extract-icon-renderer';
6
11
  export var extractLinkIcon = function extractLinkIcon(response, renderers) {
7
12
  var data = response.data;
8
-
9
- var _ref = extractJsonldDataIcon(data) || [],
10
- _ref2 = _slicedToArray(_ref, 3),
11
- icon = _ref2[0],
12
- label = _ref2[1],
13
- url = _ref2[2];
14
-
15
13
  var render = extractIconRenderer(data, renderers);
16
- return {
17
- icon: icon,
18
- label: label,
19
- render: render,
20
- url: url
21
- };
14
+ return _objectSpread(_objectSpread({}, extractJsonldDataIcon(data)), {}, {
15
+ render: render
16
+ });
22
17
  };
23
18
  export var extractErrorIcon = function extractErrorIcon(response, status) {
24
19
  // Try to get provider icon first.
25
20
  if (response) {
26
21
  var data = response.data;
27
- var generator = data.generator;
28
- var provider = generator === null || generator === void 0 ? void 0 : generator['@id'];
29
22
 
30
- var _ref3 = extractProviderIcon(provider, generator === null || generator === void 0 ? void 0 : generator.icon) || [],
31
- _ref4 = _slicedToArray(_ref3, 3),
32
- icon = _ref4[0],
33
- url = _ref4[2];
23
+ var _ref = extractProviderIcon(data) || {},
24
+ icon = _ref.icon,
25
+ url = _ref.url;
34
26
 
35
27
  if (icon || url) {
36
28
  return {
@@ -1,4 +1,4 @@
1
- import { extractLink, extractTitle } from '../common/primitives';
1
+ import { extractLink, extractSummary, extractTitle } from '../common/primitives';
2
2
  import { extractLozenge } from '../common/lozenge';
3
3
  import { extractLinkIcon } from './icon';
4
4
  import { extractCommentCount, extractCreatedBy, extractModifiedBy, extractProgrammingLanguage, extractSubscriberCount } from './utils';
@@ -7,6 +7,7 @@ import { extractPersonsUpdatedBy } from './collaboratorGroup';
7
7
  import { extractDateUpdated } from '../common/date/extractDateUpdated';
8
8
  import { extractDateCreated } from '../common/date/extractDateCreated';
9
9
  import extractPriority from './extract-priority';
10
+ import extractProviderIcon from './icon/extract-provider-icon';
10
11
 
11
12
  var extractFlexibleUiContext = function extractFlexibleUiContext(response, renderers) {
12
13
  if (!response) {
@@ -26,9 +27,12 @@ var extractFlexibleUiContext = function extractFlexibleUiContext(response, rende
26
27
  modifiedOn: extractDateUpdated(data),
27
28
  priority: extractPriority(data),
28
29
  programmingLanguage: extractProgrammingLanguage(data),
30
+ snippet: extractSummary(data) || undefined,
31
+ // Explicitly set here to remove an empty string
29
32
  state: extractLozenge(data),
30
33
  subscriberCount: extractSubscriberCount(data),
31
34
  title: extractTitle(data) || url,
35
+ provider: extractProviderIcon(data),
32
36
  url: url
33
37
  };
34
38
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "17.2.1",
3
+ "version": "17.4.0",
4
4
  "sideEffects": false
5
5
  }
@@ -19,18 +19,32 @@ var getElementGroupStyles = function getElementGroupStyles(size, maxLines) {
19
19
  // MetadataBlock allows metadata elements to be displayed in
20
20
  // multiple lines, with maximum of 2 lines.
21
21
  // a) We need the height of the line to be equal on both left and right
22
- // sides so they line up nicely. 1.75 is the The maximum height of
23
- // all elements in specific size. This height belongs to AvatarGroup.
22
+ // sides so they line up nicely.
24
23
  // b) There is no way to truncate non-text elements nicely. Here
25
24
  // it's fix max height of the element group so that anything that is
26
25
  // overflown will not be visible.
27
- var lineHeight = 1.75;
26
+ var lineHeight = getLineHeight(size);
28
27
  var gap = getGapSize(size);
29
28
  var gapHeight = gap * (maxLines - 1);
30
29
  var height = lineHeight * maxLines + gapHeight;
31
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);
32
31
  };
33
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
+ }
46
+ };
47
+
34
48
  var getMaxLines = function getMaxLines(maxLines) {
35
49
  if (maxLines > MAXIMUM_MAX_LINES) {
36
50
  return DEFAULT_MAX_LINES;
@@ -1,20 +1,23 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _extends from "@babel/runtime/helpers/extends";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
4
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
5
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
6
  var _excluded = ["name"],
6
7
  _excluded2 = ["name"];
7
8
 
8
- var _templateObject, _templateObject2, _templateObject3;
9
+ var _ElementDisplaySchema, _templateObject, _templateObject2, _templateObject3;
9
10
 
10
11
  import React from 'react';
11
12
  import { css } from '@emotion/core';
12
- import { SmartLinkDirection, SmartLinkSize } from '../../../../constants';
13
+ import { ElementName, SmartLinkDirection, SmartLinkSize } from '../../../../constants';
13
14
  import * as Elements from '../elements';
14
15
  import * as Actions from '../actions';
15
16
  import { isFlexibleUiElement } from '../../../../utils/flexible';
16
17
  import ActionGroup from './action-group';
17
- import ElementGroup from './element-group';
18
+ import ElementGroup from './element-group'; // Determine whether the element can be display as inline/block.
19
+
20
+ export var ElementDisplaySchema = (_ElementDisplaySchema = {}, _defineProperty(_ElementDisplaySchema, ElementName.AuthorGroup, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CollaboratorGroup, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CommentCount, ['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.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);
18
21
 
19
22
  var getDirectionStyles = function getDirectionStyles(direction) {
20
23
  switch (direction) {
@@ -51,6 +54,16 @@ var isActionGroup = function isActionGroup(node) {
51
54
  return /*#__PURE__*/React.isValidElement(node) && node.type === ActionGroup;
52
55
  };
53
56
 
57
+ var isElementDisplayValid = function isElementDisplayValid(name, display) {
58
+ var _ElementDisplaySchema2, _ElementDisplaySchema3;
59
+
60
+ return (_ElementDisplaySchema2 = (_ElementDisplaySchema3 = ElementDisplaySchema[name]) === null || _ElementDisplaySchema3 === void 0 ? void 0 : _ElementDisplaySchema3.includes(display)) !== null && _ElementDisplaySchema2 !== void 0 ? _ElementDisplaySchema2 : false;
61
+ };
62
+
63
+ var isElementNull = function isElementNull(children) {
64
+ return Boolean(children.type() === null);
65
+ };
66
+
54
67
  var isElementOrElementGroup = function isElementOrElementGroup(node) {
55
68
  return /*#__PURE__*/React.isValidElement(node) && (isFlexibleUiElement(node) || node.type === ElementGroup);
56
69
  };
@@ -70,16 +83,21 @@ export var renderChildren = function renderChildren(children, size) {
70
83
  };
71
84
  export var renderElementItems = function renderElementItems() {
72
85
  var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
86
+ var display = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'inline';
73
87
  var elements = items.reduce(function (acc, curr, idx) {
74
88
  var name = curr.name,
75
89
  props = _objectWithoutProperties(curr, _excluded);
76
90
 
77
91
  var Element = Elements[name];
78
92
 
79
- if (Element) {
80
- return [].concat(_toConsumableArray(acc), [/*#__PURE__*/React.createElement(Element, _extends({
93
+ if (Element && isElementDisplayValid(name, display)) {
94
+ var element = /*#__PURE__*/React.createElement(Element, _extends({
81
95
  key: idx
82
- }, props))]);
96
+ }, props));
97
+
98
+ if (!isElementNull(element)) {
99
+ return [].concat(_toConsumableArray(acc), [element]);
100
+ }
83
101
  }
84
102
 
85
103
  return acc;
@@ -281,6 +281,8 @@ var AtlaskitIcon = function AtlaskitIcon(_ref3) {
281
281
  case IconType.Jira:
282
282
  // Logo component has a different prop set from other icon components
283
283
  return /*#__PURE__*/React.createElement(ImportedIcon, {
284
+ "data-testId": testId // Confluence and Jira imports don't have native testId prop
285
+ ,
284
286
  textColor: N700,
285
287
  iconColor: B200,
286
288
  iconGradientStart: B400,