@atlaskit/smart-card 17.3.1 → 17.4.2

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 (90) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/cjs/constants.js +63 -0
  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/index.js +6 -0
  12. package/dist/cjs/utils/flexible.js +2 -2
  13. package/dist/cjs/utils/token.js +1 -0
  14. package/dist/cjs/version.json +1 -1
  15. package/dist/cjs/view/CardWithUrl/component.js +1 -1
  16. package/dist/cjs/view/FlexibleCard/components/blocks/index.js +10 -2
  17. package/dist/cjs/view/FlexibleCard/components/blocks/snippet-block/index.js +51 -0
  18. package/dist/cjs/view/FlexibleCard/components/blocks/snippet-block/types.js +5 -0
  19. package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +15 -3
  20. package/dist/cjs/view/FlexibleCard/components/common/atlaskit-icon/index.js +2 -0
  21. package/dist/cjs/view/FlexibleCard/components/elements/badge/index.js +2 -4
  22. package/dist/cjs/view/FlexibleCard/components/elements/index.js +6 -2
  23. package/dist/cjs/view/FlexibleCard/components/elements/text/index.js +9 -3
  24. package/dist/cjs/view/FlexibleCard/components/elements/utils.js +20 -0
  25. package/dist/cjs/view/FlexibleCard/components/utils.js +15 -1
  26. package/dist/es2019/constants.js +53 -0
  27. package/dist/es2019/extractors/flexible/icon/extract-document-type-icon.js +28 -7
  28. package/dist/es2019/extractors/flexible/icon/extract-file-formatIcon.js +88 -22
  29. package/dist/es2019/extractors/flexible/icon/extract-jira-task-icon.js +36 -9
  30. package/dist/es2019/extractors/flexible/icon/extract-jsonld-data-icon.js +33 -9
  31. package/dist/es2019/extractors/flexible/icon/extract-provider-icon.js +19 -3
  32. package/dist/es2019/extractors/flexible/icon/extract-url-icon.js +4 -1
  33. package/dist/es2019/extractors/flexible/icon/index.js +6 -9
  34. package/dist/es2019/extractors/flexible/index.js +5 -1
  35. package/dist/es2019/index.js +1 -1
  36. package/dist/es2019/utils/flexible.js +2 -2
  37. package/dist/es2019/utils/token.js +1 -0
  38. package/dist/es2019/version.json +1 -1
  39. package/dist/es2019/view/CardWithUrl/component.js +1 -1
  40. package/dist/es2019/view/FlexibleCard/components/blocks/index.js +3 -2
  41. package/dist/es2019/view/FlexibleCard/components/blocks/snippet-block/index.js +29 -0
  42. package/dist/es2019/view/FlexibleCard/components/blocks/snippet-block/types.js +1 -0
  43. package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +28 -4
  44. package/dist/es2019/view/FlexibleCard/components/common/atlaskit-icon/index.js +2 -0
  45. package/dist/es2019/view/FlexibleCard/components/elements/badge/index.js +2 -4
  46. package/dist/es2019/view/FlexibleCard/components/elements/index.js +3 -1
  47. package/dist/es2019/view/FlexibleCard/components/elements/text/index.js +7 -4
  48. package/dist/es2019/view/FlexibleCard/components/elements/utils.js +21 -0
  49. package/dist/es2019/view/FlexibleCard/components/utils.js +11 -0
  50. package/dist/esm/constants.js +53 -0
  51. package/dist/esm/extractors/flexible/icon/extract-document-type-icon.js +28 -7
  52. package/dist/esm/extractors/flexible/icon/extract-file-formatIcon.js +88 -22
  53. package/dist/esm/extractors/flexible/icon/extract-jira-task-icon.js +36 -9
  54. package/dist/esm/extractors/flexible/icon/extract-jsonld-data-icon.js +33 -9
  55. package/dist/esm/extractors/flexible/icon/extract-provider-icon.js +19 -3
  56. package/dist/esm/extractors/flexible/icon/extract-url-icon.js +4 -1
  57. package/dist/esm/extractors/flexible/icon/index.js +12 -20
  58. package/dist/esm/extractors/flexible/index.js +5 -1
  59. package/dist/esm/index.js +1 -1
  60. package/dist/esm/utils/flexible.js +2 -2
  61. package/dist/esm/utils/token.js +1 -0
  62. package/dist/esm/version.json +1 -1
  63. package/dist/esm/view/CardWithUrl/component.js +1 -1
  64. package/dist/esm/view/FlexibleCard/components/blocks/index.js +3 -2
  65. package/dist/esm/view/FlexibleCard/components/blocks/snippet-block/index.js +34 -0
  66. package/dist/esm/view/FlexibleCard/components/blocks/snippet-block/types.js +1 -0
  67. package/dist/esm/view/FlexibleCard/components/blocks/utils.js +14 -4
  68. package/dist/esm/view/FlexibleCard/components/common/atlaskit-icon/index.js +2 -0
  69. package/dist/esm/view/FlexibleCard/components/elements/badge/index.js +2 -4
  70. package/dist/esm/view/FlexibleCard/components/elements/index.js +3 -1
  71. package/dist/esm/view/FlexibleCard/components/elements/text/index.js +10 -3
  72. package/dist/esm/view/FlexibleCard/components/elements/utils.js +19 -0
  73. package/dist/esm/view/FlexibleCard/components/utils.js +11 -0
  74. package/dist/types/__fixtures__/flexible-ui-data-context.d.ts +3 -0
  75. package/dist/types/constants.d.ts +54 -1
  76. package/dist/types/extractors/flexible/icon/extract-provider-icon.d.ts +1 -1
  77. package/dist/types/extractors/flexible/icon/index.d.ts +3 -3
  78. package/dist/types/extractors/flexible/icon/types.d.ts +5 -1
  79. package/dist/types/index.d.ts +1 -1
  80. package/dist/types/state/flexible-ui-context/types.d.ts +4 -2
  81. package/dist/types/utils/flexible.d.ts +1 -2
  82. package/dist/types/utils/token.d.ts +1 -0
  83. package/dist/types/view/FlexibleCard/components/blocks/index.d.ts +2 -1
  84. package/dist/types/view/FlexibleCard/components/blocks/snippet-block/index.d.ts +4 -0
  85. package/dist/types/view/FlexibleCard/components/blocks/snippet-block/types.d.ts +4 -0
  86. package/dist/types/view/FlexibleCard/components/blocks/utils.d.ts +4 -2
  87. package/dist/types/view/FlexibleCard/components/elements/index.d.ts +2 -0
  88. package/dist/types/view/FlexibleCard/components/elements/text/types.d.ts +2 -0
  89. package/dist/types/view/FlexibleCard/components/utils.d.ts +1 -0
  90. package/package.json +1 -1
@@ -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
  };
package/dist/esm/index.js CHANGED
@@ -13,4 +13,4 @@ export { contentFooterClassName, metadataListClassName, blockCardResolvingViewCl
13
13
  export { loadingPlaceholderClassName } from './view/CardWithUrl/component-lazy/LazyFallback'; // Flexible UI
14
14
 
15
15
  export { ActionName, ElementName, SmartLinkDirection, SmartLinkPosition, SmartLinkSize, SmartLinkTheme } from './constants';
16
- export { MetadataBlock, TitleBlock } from './view/FlexibleCard/components/blocks';
16
+ export { MetadataBlock, SnippetBlock, TitleBlock } from './view/FlexibleCard/components/blocks';
@@ -2,8 +2,8 @@ import React from 'react';
2
2
  import * as Blocks from '../view/FlexibleCard/components/blocks';
3
3
  import { TitleBlock } from '../view/FlexibleCard/components/blocks';
4
4
  import * as Elements from '../view/FlexibleCard/components/elements';
5
- export var isFlexibleUiCard = function isFlexibleUiCard(appearance, children) {
6
- if ((appearance === 'inline' || appearance === 'block') && children && React.Children.toArray(children).some(function (child) {
5
+ export var isFlexibleUiCard = function isFlexibleUiCard(children) {
6
+ if (children && React.Children.toArray(children).some(function (child) {
7
7
  return isFlexibleUiBlock(child);
8
8
  })) {
9
9
  return true;
@@ -19,5 +19,6 @@ export var tokens = {
19
19
  elevation: safeToken('elevation.shadow.raised', '0px 1px 1px #091E4240, 0px 0px 1px #091E424F'),
20
20
  errorMessage: safeToken('color.text.disabled', '#6B778C'),
21
21
  errorMessageHover: safeToken('color.text.subtle', '#8993A4'),
22
+ snippet: safeToken('color.text', '#172B4D'),
22
23
  text: safeToken('color.text.subtlest', '#626F86')
23
24
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "17.3.1",
3
+ "version": "17.4.2",
4
4
  "sideEffects": false
5
5
  }
@@ -84,7 +84,7 @@ export function CardWithUrlContent(_ref) {
84
84
  throw error;
85
85
  }
86
86
 
87
- if (isFlexibleUiCard(appearance, children)) {
87
+ if (isFlexibleUiCard(children)) {
88
88
  return /*#__PURE__*/React.createElement(FlexibleCard, {
89
89
  cardState: state,
90
90
  onAuthorize: services.length && handleAuthorize || undefined,
@@ -1,2 +1,3 @@
1
- export { default as TitleBlock } from './title-block';
2
- export { default as MetadataBlock } from './metadata-block';
1
+ export { default as MetadataBlock } from './metadata-block';
2
+ export { default as SnippetBlock } from './snippet-block';
3
+ export { default as TitleBlock } from './title-block';
@@ -0,0 +1,34 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["maxLines", "status", "testId"];
4
+ import React from 'react';
5
+ import Block from '../block';
6
+ import { SmartLinkStatus } from '../../../../../constants';
7
+ import { Snippet } from '../../elements';
8
+ import { getMaxLines } from '../../utils';
9
+ var DEFAULT_MAX_LINES = 3;
10
+ var MAXIMUM_MAX_LINES = 3;
11
+ var MINIMUM_MAX_LINES = 1;
12
+
13
+ var SnippetBlock = function SnippetBlock(_ref) {
14
+ var _ref$maxLines = _ref.maxLines,
15
+ maxLines = _ref$maxLines === void 0 ? DEFAULT_MAX_LINES : _ref$maxLines,
16
+ _ref$status = _ref.status,
17
+ status = _ref$status === void 0 ? SmartLinkStatus.Fallback : _ref$status,
18
+ _ref$testId = _ref.testId,
19
+ testId = _ref$testId === void 0 ? 'smart-block-snippet' : _ref$testId,
20
+ blockProps = _objectWithoutProperties(_ref, _excluded);
21
+
22
+ if (status !== SmartLinkStatus.Resolved) {
23
+ return null;
24
+ }
25
+
26
+ var snippetMaxLines = getMaxLines(maxLines, DEFAULT_MAX_LINES, MAXIMUM_MAX_LINES, MINIMUM_MAX_LINES);
27
+ return /*#__PURE__*/React.createElement(Block, _extends({}, blockProps, {
28
+ testId: "".concat(testId, "-resolved-view")
29
+ }), /*#__PURE__*/React.createElement(Snippet, {
30
+ maxLines: snippetMaxLines
31
+ }));
32
+ };
33
+
34
+ export default SnippetBlock;
@@ -2,19 +2,22 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
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,12 @@ 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
+
54
63
  var isElementNull = function isElementNull(children) {
55
64
  return Boolean(children.type() === null);
56
65
  };
@@ -74,13 +83,14 @@ export var renderChildren = function renderChildren(children, size) {
74
83
  };
75
84
  export var renderElementItems = function renderElementItems() {
76
85
  var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
86
+ var display = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'inline';
77
87
  var elements = items.reduce(function (acc, curr, idx) {
78
88
  var name = curr.name,
79
89
  props = _objectWithoutProperties(curr, _excluded);
80
90
 
81
91
  var Element = Elements[name];
82
92
 
83
- if (Element) {
93
+ if (Element && isElementDisplayValid(name, display)) {
84
94
  var element = /*#__PURE__*/React.createElement(Element, _extends({
85
95
  key: idx
86
96
  }, props));
@@ -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,
@@ -17,7 +17,7 @@ var iconStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLite
17
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);
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
- var getFormattedMessageOrLabel = function getFormattedMessageOrLabel(icon, content) {
20
+ var getFormattedMessageFromIcon = function getFormattedMessageFromIcon(icon) {
21
21
  if (icon) {
22
22
  var descriptor = messageMapper[icon];
23
23
 
@@ -27,8 +27,6 @@ var getFormattedMessageOrLabel = function getFormattedMessageOrLabel(icon, conte
27
27
  });
28
28
  }
29
29
  }
30
-
31
- return content;
32
30
  };
33
31
 
34
32
  var renderAtlaskitIcon = function renderAtlaskitIcon(icon, testId) {
@@ -56,7 +54,7 @@ var Badge = function Badge(_ref) {
56
54
  label = _ref.label,
57
55
  _ref$testId = _ref.testId,
58
56
  testId = _ref$testId === void 0 ? 'smart-element-badge' : _ref$testId;
59
- var formattedMessageOrLabel = getFormattedMessageOrLabel(icon, label);
57
+ var formattedMessageOrLabel = getFormattedMessageFromIcon(icon) || label;
60
58
  var badgeIcon = renderAtlaskitIcon(icon, testId) || renderImageIcon(url, testId);
61
59
 
62
60
  if (!formattedMessageOrLabel || !badgeIcon) {
@@ -13,6 +13,8 @@ export var ModifiedBy = createElement(ElementName.ModifiedBy);
13
13
  export var ModifiedOn = createElement(ElementName.ModifiedOn);
14
14
  export var Priority = createElement(ElementName.Priority);
15
15
  export var ProgrammingLanguage = createElement(ElementName.ProgrammingLanguage);
16
+ export var Snippet = createElement(ElementName.Snippet);
16
17
  export var State = createElement(ElementName.State);
17
18
  export var SubscriberCount = createElement(ElementName.SubscriberCount);
18
- export var Title = createElement(ElementName.Title);
19
+ export var Title = createElement(ElementName.Title);
20
+ export var Provider = createElement(ElementName.Provider);
@@ -7,10 +7,17 @@ import React from 'react';
7
7
  import { css, jsx } from '@emotion/core';
8
8
  import { getFormattedMessage, getTruncateStyles } from '../../utils';
9
9
  import { tokens } from '../../../../../utils/token';
10
- var styles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n font-size: 0.75rem;\n line-height: 1rem;\n ", "\n"])), tokens.text, getTruncateStyles(1));
10
+
11
+ var getStyles = function getStyles(maxLines, color) {
12
+ return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n font-size: 0.75rem;\n line-height: 1rem;\n ", "\n"])), color, getTruncateStyles(maxLines));
13
+ };
11
14
 
12
15
  var Text = function Text(_ref) {
13
- var content = _ref.content,
16
+ var _ref$color = _ref.color,
17
+ color = _ref$color === void 0 ? tokens.text : _ref$color,
18
+ content = _ref.content,
19
+ _ref$maxLines = _ref.maxLines,
20
+ maxLines = _ref$maxLines === void 0 ? 1 : _ref$maxLines,
14
21
  message = _ref.message,
15
22
  _ref$testId = _ref.testId,
16
23
  testId = _ref$testId === void 0 ? 'smart-element-text' : _ref$testId;
@@ -20,7 +27,7 @@ var Text = function Text(_ref) {
20
27
  }
21
28
 
22
29
  return jsx("span", {
23
- css: styles,
30
+ css: getStyles(maxLines, color),
24
31
  "data-smart-element-text": true,
25
32
  "data-testid": testId
26
33
  }, getFormattedMessage(message) || content);
@@ -14,6 +14,8 @@ import AvatarGroup from './avatar-group';
14
14
  import Text from './text';
15
15
  import { messages } from '../../../../messages';
16
16
  import DateTime from './date-time';
17
+ import { tokens } from '../../../../utils/token';
18
+ var SNIPPET_DEFAULT_MAX_LINES = 3;
17
19
  var elementMappings = (_elementMappings = {}, _defineProperty(_elementMappings, ElementName.AuthorGroup, {
18
20
  component: AvatarGroup
19
21
  }), _defineProperty(_elementMappings, ElementName.CollaboratorGroup, {
@@ -36,6 +38,12 @@ var elementMappings = (_elementMappings = {}, _defineProperty(_elementMappings,
36
38
  props: {
37
39
  icon: IconType.ProgrammingLanguage
38
40
  }
41
+ }), _defineProperty(_elementMappings, ElementName.Snippet, {
42
+ component: Text,
43
+ props: {
44
+ color: tokens.snippet,
45
+ maxLines: SNIPPET_DEFAULT_MAX_LINES
46
+ }
39
47
  }), _defineProperty(_elementMappings, ElementName.State, {
40
48
  component: Lozenge
41
49
  }), _defineProperty(_elementMappings, ElementName.SubscriberCount, {
@@ -49,6 +57,8 @@ var elementMappings = (_elementMappings = {}, _defineProperty(_elementMappings,
49
57
  component: DateTime
50
58
  }), _defineProperty(_elementMappings, ElementName.ModifiedOn, {
51
59
  component: DateTime
60
+ }), _defineProperty(_elementMappings, ElementName.Provider, {
61
+ component: Badge
52
62
  }), _elementMappings);
53
63
 
54
64
  var getContextKey = function getContextKey(name) {
@@ -86,6 +96,9 @@ var getData = function getData(elementName, contextKey, context) {
86
96
  case ElementName.ModifiedOn:
87
97
  return toDateTimeProps('modified', context.modifiedOn);
88
98
 
99
+ case ElementName.Snippet:
100
+ return toTextProps(data);
101
+
89
102
  case ElementName.Title:
90
103
  return toLinkProps(context.title, context.url);
91
104
 
@@ -131,6 +144,12 @@ var toLinkProps = function toLinkProps(text, url) {
131
144
  } : undefined;
132
145
  };
133
146
 
147
+ var toTextProps = function toTextProps(content) {
148
+ return content ? {
149
+ content: content
150
+ } : undefined;
151
+ };
152
+
134
153
  export var createElement = function createElement(name) {
135
154
  var _ref = elementMappings[name] || {},
136
155
  BaseElement = _ref.component,
@@ -51,6 +51,17 @@ export var getLinkSizeStyles = function getLinkSizeStyles(size) {
51
51
  return css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n font-size: 0.75rem;\n font-weight: 500;\n letter-spacing: 0em;\n line-height: ", ";\n "])), getLinkLineHeight(size));
52
52
  }
53
53
  };
54
+ export var getMaxLines = function getMaxLines(value, defaultValue, max, min) {
55
+ if (value > max) {
56
+ return defaultValue;
57
+ }
58
+
59
+ if (value < min) {
60
+ return min;
61
+ }
62
+
63
+ return value;
64
+ };
54
65
  export var getTruncateStyles = function getTruncateStyles(maxLines) {
55
66
  var lineHeight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '1rem';
56
67
  return css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n display: -webkit-box;\n overflow: hidden;\n text-overflow: ellipsis;\n word-break: break-word;\n -webkit-line-clamp: ", ";\n -webkit-box-orient: vertical;\n // Fallback options\n max-height: calc(", " * ", ");\n "])), maxLines, maxLines, lineHeight);
@@ -0,0 +1,3 @@
1
+ import { FlexibleUiDataContext } from '../state/flexible-ui-context/types';
2
+ declare const context: FlexibleUiDataContext;
3
+ export default context;
@@ -1,21 +1,41 @@
1
+ /**
2
+ * The alignment of Flexible UI component.
3
+ */
1
4
  export declare enum SmartLinkAlignment {
2
5
  Left = "left",
3
6
  Right = "right"
4
7
  }
8
+ /**
9
+ * The direction of Flexible UI components. It establish the main-axis
10
+ * or how the child components laid out inside the parent component.
11
+ * Similar to flex's flex-direction concept.
12
+ */
5
13
  export declare enum SmartLinkDirection {
6
14
  Horizontal = "horizontal",
7
15
  Vertical = "vertical"
8
16
  }
17
+ /**
18
+ * The positioning of the component within the parent component.
19
+ * Similar to flex's align-items or align-self concept.
20
+ */
9
21
  export declare enum SmartLinkPosition {
10
22
  Top = "top",
11
23
  Center = "center"
12
24
  }
25
+ /**
26
+ * The sizing options of the Flexible UI component. Every component
27
+ * has or inherits the sizing props. Implementation varies
28
+ * as per component.
29
+ */
13
30
  export declare enum SmartLinkSize {
14
31
  XLarge = "xlarge",
15
32
  Large = "large",
16
33
  Medium = "medium",
17
34
  Small = "small"
18
35
  }
36
+ /**
37
+ * Smart Links link request status
38
+ */
19
39
  export declare enum SmartLinkStatus {
20
40
  Pending = "pending",
21
41
  Resolving = "resolving",
@@ -26,14 +46,39 @@ export declare enum SmartLinkStatus {
26
46
  Unauthorized = "unauthorized",
27
47
  Fallback = "fallback"
28
48
  }
49
+ /**
50
+ * Flexible UI theme available on the Card level.
51
+ * This determine the styling of the link.
52
+ */
29
53
  export declare enum SmartLinkTheme {
30
54
  Black = "black",
31
55
  Link = "link"
32
56
  }
57
+ /**
58
+ * Determines whether the container size will fit to the content
59
+ * or expand to the available width or the parent component.
60
+ * Similar to flex's flex-grow concept.
61
+ */
33
62
  export declare enum SmartLinkWidth {
34
63
  FitToContent = "fit-to-content",
35
64
  Flexible = "flexible"
36
65
  }
66
+ /**
67
+ * Flexible UI element name - each reflecting the link data its represented.
68
+ * When adding an element...
69
+ * 1) Create base element if it doesn't already existed.
70
+ * Base element are inside src/view/FlexibleCard/components/elements.
71
+ * E.g. Badge,DateTime, Icon, Lozenge, etc.
72
+ * 2) Update FlexibleUiContext with the new prop for data representing
73
+ * the element, preferably with the same name as the element itself.
74
+ * (src/state/flexible-ui-context/types.ts)
75
+ * 3) Update Flexible UI extractor (src/extractors/flexible/index.ts)
76
+ * 4) Set base element and data mapping
77
+ * (src/view/FlexibleCard/components/elements/utils.tsx)
78
+ * 5) Create element. (src/view/FlexibleCard/components/elements/index.ts)
79
+ * 6) Update element ElementDisplaySchema for inline/block display
80
+ * (src/view/FlexibleCard/components/blocks/utils.tsx)
81
+ */
37
82
  export declare enum ElementName {
38
83
  AuthorGroup = "AuthorGroup",
39
84
  CollaboratorGroup = "CollaboratorGroup",
@@ -45,13 +90,21 @@ export declare enum ElementName {
45
90
  ModifiedOn = "ModifiedOn",
46
91
  Priority = "Priority",
47
92
  ProgrammingLanguage = "ProgrammingLanguage",
93
+ Snippet = "Snippet",
48
94
  State = "State",
49
95
  SubscriberCount = "SubscriberCount",
50
- Title = "Title"
96
+ Title = "Title",
97
+ Provider = "Provider"
51
98
  }
99
+ /**
100
+ * Flexible UI action (button)
101
+ */
52
102
  export declare enum ActionName {
53
103
  DeleteAction = "DeleteAction"
54
104
  }
105
+ /**
106
+ * Flexible UI icons - each mapped to AK icons.
107
+ */
55
108
  export declare enum IconType {
56
109
  Archive = "FileType:Archive",
57
110
  Audio = "FileType:Audio",
@@ -1,4 +1,4 @@
1
1
  import { JsonLd } from 'json-ld-types';
2
2
  import { IconDescriptor } from './types';
3
- declare const extractProviderIcon: (provider?: string | undefined, icon?: string | JsonLd.Primitives.LinkModel | JsonLd.Primitives.Image | undefined, label?: string | undefined) => IconDescriptor | undefined;
3
+ declare const extractProviderIcon: (data?: JsonLd.Data.BaseData | undefined) => IconDescriptor | undefined;
4
4
  export default extractProviderIcon;
@@ -3,10 +3,10 @@ import { JsonLd } from 'json-ld-types';
3
3
  import { IconType, SmartLinkStatus } from '../../../constants';
4
4
  import { CardProviderRenderers } from '../../../state/context/types';
5
5
  export declare const extractLinkIcon: (response: JsonLd.Response, renderers?: CardProviderRenderers | undefined) => {
6
- icon: IconType | undefined;
7
- label: string | undefined;
8
6
  render: (() => import("react").ReactNode) | undefined;
9
- url: string | undefined;
7
+ icon?: IconType | undefined;
8
+ label?: string | undefined;
9
+ url?: string | undefined;
10
10
  };
11
11
  export declare const extractErrorIcon: (response?: JsonLd.Response<JsonLd.Data.BaseData> | undefined, status?: SmartLinkStatus | undefined) => {
12
12
  icon: IconType | undefined;
@@ -1,2 +1,6 @@
1
1
  import { IconType } from '../../../constants';
2
- export declare type IconDescriptor = [IconType?, string?, string?];
2
+ export declare type IconDescriptor = {
3
+ icon?: IconType;
4
+ label?: string;
5
+ url?: string;
6
+ };
@@ -17,5 +17,5 @@ export { useSmartLinkEvents } from './view/SmartLinkEvents/useSmartLinkEvents';
17
17
  export { contentFooterClassName, metadataListClassName, blockCardResolvingViewClassName, blockCardResolvedViewClassName, blockCardForbiddenViewClassName, blockCardIconImageClassName, blockCardResolvedViewByClassName, blockCardForbiddenViewLinkClassName, blockCardContentClassName, blockCardContentHeaderClassName, blockCardContentHeaderNameClassName, blockCardNotFoundViewClassName, blockCardErroredViewClassName, } from './classNames';
18
18
  export { loadingPlaceholderClassName } from './view/CardWithUrl/component-lazy/LazyFallback';
19
19
  export { ActionName, ElementName, SmartLinkDirection, SmartLinkPosition, SmartLinkSize, SmartLinkTheme, } from './constants';
20
- export { MetadataBlock, TitleBlock, } from './view/FlexibleCard/components/blocks';
20
+ export { MetadataBlock, SnippetBlock, TitleBlock, } from './view/FlexibleCard/components/blocks';
21
21
  export type { ActionItem, ElementItem, } from './view/FlexibleCard/components/blocks/types';
@@ -2,6 +2,8 @@ import { LinkLozenge } from '../../extractors/common/lozenge/types';
2
2
  import { LinkPerson } from '../../extractors/common/person/types';
3
3
  import { IconType } from '../../constants';
4
4
  export declare type FlexibleUiDataContext = {
5
+ authorGroup?: LinkPerson[];
6
+ collaboratorGroup?: LinkPerson[];
5
7
  commentCount?: number;
6
8
  createdBy?: string;
7
9
  createdOn?: string;
@@ -10,12 +12,12 @@ export declare type FlexibleUiDataContext = {
10
12
  modifiedOn?: string;
11
13
  priority?: Icon;
12
14
  programmingLanguage?: string;
15
+ snippet?: string;
13
16
  subscriberCount?: number;
14
17
  state?: LinkLozenge;
15
18
  title?: string;
16
19
  url?: string;
17
- authorGroup?: LinkPerson[];
18
- collaboratorGroup?: LinkPerson[];
20
+ provider?: Icon;
19
21
  };
20
22
  export declare type Icon = {
21
23
  icon?: IconType;
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
- import { CardAppearance } from '../view/Card';
3
- export declare const isFlexibleUiCard: (appearance: CardAppearance, children?: React.ReactNode) => boolean;
2
+ export declare const isFlexibleUiCard: (children?: React.ReactNode) => boolean;
4
3
  export declare const isFlexibleUiBlock: (node: React.ReactNode) => boolean;
5
4
  export declare const isFlexibleUiElement: (node: React.ReactNode) => boolean;
6
5
  export declare const isFlexibleUiTitleBlock: (node: React.ReactNode) => boolean;
@@ -11,5 +11,6 @@ export declare const tokens: {
11
11
  elevation: any;
12
12
  errorMessage: any;
13
13
  errorMessageHover: any;
14
+ snippet: any;
14
15
  text: any;
15
16
  };
@@ -1,2 +1,3 @@
1
- export { default as TitleBlock } from './title-block';
2
1
  export { default as MetadataBlock } from './metadata-block';
2
+ export { default as SnippetBlock } from './snippet-block';
3
+ export { default as TitleBlock } from './title-block';
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { SnippetBlockProps } from './types';
3
+ declare const SnippetBlock: React.FC<SnippetBlockProps>;
4
+ export default SnippetBlock;
@@ -0,0 +1,4 @@
1
+ import { BlockProps } from '../types';
2
+ export declare type SnippetBlockProps = BlockProps & {
3
+ maxLines?: number;
4
+ };
@@ -1,9 +1,11 @@
1
1
  import React from 'react';
2
2
  import { SerializedStyles } from '@emotion/core';
3
3
  import { ActionItem, ElementItem } from './types';
4
- import { SmartLinkDirection, SmartLinkSize } from '../../../../constants';
4
+ import { ElementName, SmartLinkDirection, SmartLinkSize } from '../../../../constants';
5
+ export declare type ElementDisplaySchemaType = 'inline' | 'block';
6
+ export declare const ElementDisplaySchema: Record<ElementName, ElementDisplaySchemaType[]>;
5
7
  export declare const getGapSize: (size: SmartLinkSize) => number;
6
8
  export declare const getBaseStyles: (direction: SmartLinkDirection, size: SmartLinkSize) => SerializedStyles;
7
9
  export declare const renderChildren: (children: React.ReactNode, size: SmartLinkSize) => React.ReactNode;
8
- export declare const renderElementItems: (items?: ElementItem[]) => React.ReactNode | undefined;
10
+ export declare const renderElementItems: (items?: ElementItem[], display?: ElementDisplaySchemaType) => React.ReactNode | undefined;
9
11
  export declare const renderActionItems: (items?: ActionItem[], size?: SmartLinkSize) => React.ReactNode | undefined;
@@ -16,6 +16,8 @@ export declare const ModifiedBy: import("react").FC<TextProps>;
16
16
  export declare const ModifiedOn: import("react").FC<DateTimeProps>;
17
17
  export declare const Priority: import("react").FC<BadgeProps>;
18
18
  export declare const ProgrammingLanguage: import("react").FC<BadgeProps>;
19
+ export declare const Snippet: import("react").FC<TextProps>;
19
20
  export declare const State: import("react").FC<LozengeProps>;
20
21
  export declare const SubscriberCount: import("react").FC<BadgeProps>;
21
22
  export declare const Title: import("react").FC<LinkProps>;
23
+ export declare const Provider: import("react").FC<BadgeProps>;
@@ -1,6 +1,8 @@
1
1
  import { ElementProps } from '../types';
2
2
  import { MessageProps } from '../../types';
3
3
  export declare type TextProps = ElementProps & {
4
+ color?: string;
4
5
  content?: string;
6
+ maxLines?: number;
5
7
  message?: MessageProps;
6
8
  };
@@ -6,4 +6,5 @@ export declare const getFormattedMessage: (message?: MessageProps | undefined) =
6
6
  export declare const getIconSizeStyles: (width: string) => SerializedStyles;
7
7
  export declare const getLinkLineHeight: (size: SmartLinkSize) => string;
8
8
  export declare const getLinkSizeStyles: (size: SmartLinkSize) => SerializedStyles;
9
+ export declare const getMaxLines: (value: number, defaultValue: number, max: number, min: number) => number;
9
10
  export declare const getTruncateStyles: (maxLines: number, lineHeight?: string) => SerializedStyles;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "17.3.1",
3
+ "version": "17.4.2",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"