@atlaskit/smart-card 17.2.0 → 17.3.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 (58) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/cjs/constants.js +15 -1
  3. package/dist/cjs/extractors/flexible/index.js +2 -0
  4. package/dist/cjs/version.json +1 -1
  5. package/dist/cjs/view/FlexibleCard/components/actions/{delete-action → action}/index.js +40 -25
  6. package/dist/cjs/view/FlexibleCard/components/actions/{types.js → action/types.js} +0 -0
  7. package/dist/cjs/view/FlexibleCard/components/actions/index.js +3 -1
  8. package/dist/cjs/view/FlexibleCard/components/actions/utils.js +34 -6
  9. package/dist/cjs/view/FlexibleCard/components/blocks/action-group/index.js +1 -1
  10. package/dist/cjs/view/FlexibleCard/components/blocks/metadata-block/index.js +17 -3
  11. package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +27 -7
  12. package/dist/cjs/view/FlexibleCard/components/elements/avatar-group/index.js +24 -2
  13. package/dist/cjs/view/FlexibleCard/components/elements/index.js +3 -1
  14. package/dist/cjs/view/FlexibleCard/components/elements/text/index.js +6 -2
  15. package/dist/cjs/view/FlexibleCard/components/elements/utils.js +62 -39
  16. package/dist/es2019/constants.js +14 -1
  17. package/dist/es2019/extractors/flexible/index.js +3 -1
  18. package/dist/es2019/version.json +1 -1
  19. package/dist/es2019/view/FlexibleCard/components/actions/{delete-action → action}/index.js +31 -15
  20. package/dist/es2019/view/FlexibleCard/components/actions/{types.js → action/types.js} +0 -0
  21. package/dist/es2019/view/FlexibleCard/components/actions/index.js +5 -3
  22. package/dist/es2019/view/FlexibleCard/components/actions/utils.js +27 -4
  23. package/dist/es2019/view/FlexibleCard/components/blocks/action-group/index.js +1 -1
  24. package/dist/es2019/view/FlexibleCard/components/blocks/metadata-block/index.js +17 -3
  25. package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +37 -6
  26. package/dist/es2019/view/FlexibleCard/components/elements/avatar-group/index.js +28 -2
  27. package/dist/es2019/view/FlexibleCard/components/elements/index.js +1 -0
  28. package/dist/es2019/view/FlexibleCard/components/elements/text/index.js +5 -3
  29. package/dist/es2019/view/FlexibleCard/components/elements/utils.js +63 -37
  30. package/dist/esm/constants.js +14 -1
  31. package/dist/esm/extractors/flexible/index.js +3 -1
  32. package/dist/esm/version.json +1 -1
  33. package/dist/esm/view/FlexibleCard/components/actions/action/index.js +82 -0
  34. package/dist/esm/view/FlexibleCard/components/actions/{types.js → action/types.js} +0 -0
  35. package/dist/esm/view/FlexibleCard/components/actions/index.js +5 -3
  36. package/dist/esm/view/FlexibleCard/components/actions/utils.js +26 -4
  37. package/dist/esm/view/FlexibleCard/components/blocks/action-group/index.js +1 -1
  38. package/dist/esm/view/FlexibleCard/components/blocks/metadata-block/index.js +17 -3
  39. package/dist/esm/view/FlexibleCard/components/blocks/utils.js +25 -7
  40. package/dist/esm/view/FlexibleCard/components/elements/avatar-group/index.js +24 -2
  41. package/dist/esm/view/FlexibleCard/components/elements/index.js +1 -0
  42. package/dist/esm/view/FlexibleCard/components/elements/text/index.js +7 -2
  43. package/dist/esm/view/FlexibleCard/components/elements/utils.js +62 -39
  44. package/dist/types/constants.d.ts +1 -0
  45. package/dist/types/state/flexible-ui-context/types.d.ts +3 -2
  46. package/dist/types/view/FlexibleCard/components/actions/action/index.d.ts +5 -0
  47. package/dist/types/view/FlexibleCard/components/actions/action/types.d.ts +18 -0
  48. package/dist/types/view/FlexibleCard/components/actions/index.d.ts +1 -1
  49. package/dist/types/view/FlexibleCard/components/actions/utils.d.ts +2 -1
  50. package/dist/types/view/FlexibleCard/components/blocks/utils.d.ts +4 -2
  51. package/dist/types/view/FlexibleCard/components/elements/avatar-group/index.d.ts +1 -0
  52. package/dist/types/view/FlexibleCard/components/elements/avatar-group/types.d.ts +1 -2
  53. package/dist/types/view/FlexibleCard/components/elements/index.d.ts +1 -0
  54. package/dist/types/view/FlexibleCard/components/elements/text/types.d.ts +1 -0
  55. package/package.json +1 -1
  56. package/dist/esm/view/FlexibleCard/components/actions/delete-action/index.js +0 -64
  57. package/dist/types/view/FlexibleCard/components/actions/delete-action/index.d.ts +0 -5
  58. package/dist/types/view/FlexibleCard/components/actions/types.d.ts +0 -10
@@ -0,0 +1,82 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+
3
+ var _templateObject;
4
+
5
+ /** @jsx jsx */
6
+ import React from 'react';
7
+ import { css, jsx } from '@emotion/core';
8
+ import Button from '@atlaskit/button/custom-theme-button';
9
+ import { SmartLinkSize } from '../../../../../constants';
10
+ import Tooltip from '@atlaskit/tooltip';
11
+ import { getIconSizeStyles } from '../../utils';
12
+ import { tokens } from '../../../../../utils/token';
13
+ import { handleOnClick } from '../../../../../utils';
14
+
15
+ var getWidth = function getWidth(size) {
16
+ switch (size) {
17
+ case SmartLinkSize.XLarge:
18
+ case SmartLinkSize.Large:
19
+ return '1.5rem';
20
+
21
+ case SmartLinkSize.Medium:
22
+ case SmartLinkSize.Small:
23
+ default:
24
+ return '1rem';
25
+ }
26
+ };
27
+
28
+ var getIconStyles = function getIconStyles(size) {
29
+ return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n ", ";\n"])), tokens.actionIcon, getIconSizeStyles(getWidth(size)));
30
+ };
31
+
32
+ var ActionIcon = function ActionIcon(_ref) {
33
+ var size = _ref.size,
34
+ testId = _ref.testId,
35
+ icon = _ref.icon;
36
+ return jsx("span", {
37
+ css: getIconStyles(size),
38
+ "data-testid": "".concat(testId, "-icon")
39
+ }, icon);
40
+ };
41
+
42
+ var Action = function Action(_ref2) {
43
+ var _ref2$appearance = _ref2.appearance,
44
+ appearance = _ref2$appearance === void 0 ? 'subtle' : _ref2$appearance,
45
+ content = _ref2.content,
46
+ onClick = _ref2.onClick,
47
+ _ref2$size = _ref2.size,
48
+ size = _ref2$size === void 0 ? SmartLinkSize.Medium : _ref2$size,
49
+ _ref2$testId = _ref2.testId,
50
+ testId = _ref2$testId === void 0 ? 'smart-action' : _ref2$testId,
51
+ icon = _ref2.icon,
52
+ _ref2$iconPosition = _ref2.iconPosition,
53
+ iconPosition = _ref2$iconPosition === void 0 ? 'before' : _ref2$iconPosition,
54
+ tooltipMessage = _ref2.tooltipMessage;
55
+
56
+ if (!onClick) {
57
+ return null;
58
+ }
59
+
60
+ var iconBefore = iconPosition === 'before' ? jsx(ActionIcon, {
61
+ size: size,
62
+ testId: testId,
63
+ icon: icon
64
+ }) : undefined;
65
+ var iconAfter = iconPosition === 'after' ? jsx(ActionIcon, {
66
+ size: size,
67
+ testId: testId,
68
+ icon: icon
69
+ }) : undefined;
70
+ return jsx(Tooltip, {
71
+ content: tooltipMessage
72
+ }, jsx(Button, {
73
+ spacing: "none",
74
+ appearance: appearance,
75
+ testId: testId,
76
+ onClick: handleOnClick(onClick),
77
+ iconBefore: iconBefore,
78
+ iconAfter: iconAfter
79
+ }, content));
80
+ };
81
+
82
+ export default Action;
@@ -1,6 +1,8 @@
1
1
  import { ActionName } from '../../../../constants';
2
- import { createAction } from './utils';
3
- // Attention: Keep the export name and action name the same.
2
+ import { createUIAction } from './utils'; // Attention: Keep the export name and action name the same.
4
3
  // This will help reducing the code for mapping action inside
5
4
  // createAction and renderActionItems
6
- export var DeleteAction = createAction(ActionName.DeleteAction);
5
+ // UIActions infer that you do not need to get any data from the context.
6
+ // DataActions infer that the action depends on the data from the context.
7
+
8
+ export var DeleteAction = createUIAction(ActionName.DeleteAction);
@@ -3,10 +3,20 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import { ActionName } from '../../../../constants';
4
4
  import { FlexibleUiContext } from '../../../../state/flexible-ui-context';
5
5
  import React, { useContext } from 'react';
6
- import DeleteAction from './delete-action';
6
+ import Action from './action';
7
+ import { FormattedMessage } from 'react-intl-next';
8
+ import { messages } from '../../../../messages';
9
+ import CrossIcon from '@atlaskit/icon/glyph/cross';
7
10
 
8
11
  var actionMappings = _defineProperty({}, ActionName.DeleteAction, {
9
- component: DeleteAction
12
+ component: Action,
13
+ props: {
14
+ testId: 'smart-action-delete-action',
15
+ icon: /*#__PURE__*/React.createElement(CrossIcon, {
16
+ label: "Delete"
17
+ }),
18
+ toolTipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.delete)
19
+ }
10
20
  });
11
21
 
12
22
  var getContextKey = function getContextKey(name) {
@@ -23,13 +33,12 @@ var getActionData = function getActionData(actionName, contextKey, context) {
23
33
  var data = context[contextKey];
24
34
 
25
35
  switch (actionName) {
26
- case ActionName.DeleteAction:
27
36
  default:
28
37
  return data;
29
38
  }
30
39
  };
31
40
 
32
- export var createAction = function createAction(name) {
41
+ export var createDataAction = function createDataAction(name) {
33
42
  var _ref = actionMappings[name] || {},
34
43
  BaseAction = _ref.component,
35
44
  props = _ref.props;
@@ -45,4 +54,17 @@ export var createAction = function createAction(name) {
45
54
  var data = getActionData(name, contextKey, context);
46
55
  return /*#__PURE__*/React.createElement(BaseAction, _extends({}, props, data, overrides));
47
56
  };
57
+ };
58
+ export var createUIAction = function createUIAction(name) {
59
+ var _ref2 = actionMappings[name] || {},
60
+ BaseAction = _ref2.component,
61
+ props = _ref2.props;
62
+
63
+ if (!BaseAction) {
64
+ throw Error("Action ".concat(name, " does not exist."));
65
+ }
66
+
67
+ return function (overrides) {
68
+ return /*#__PURE__*/React.createElement(BaseAction, _extends({}, props, overrides));
69
+ };
48
70
  };
@@ -7,7 +7,7 @@ import { css, jsx } from '@emotion/core';
7
7
  import ButtonGroup from '@atlaskit/button/button-group';
8
8
  import { renderActionItems } from '../utils';
9
9
  import { SmartLinkSize } from '../../../../../constants';
10
- var styles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline-flex;\n line-height: 0;\n"])));
10
+ var styles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline-flex;\n line-height: 1rem;\n"])));
11
11
 
12
12
  var ActionGroup = function ActionGroup(_ref) {
13
13
  var _ref$items = _ref.items,
@@ -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']), _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;
@@ -1,8 +1,28 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+
3
+ var _templateObject;
4
+
5
+ /** @jsx jsx */
1
6
  import React from 'react';
7
+ import { css, jsx } from '@emotion/core';
2
8
  import AtlaskitAvatarGroup from '@atlaskit/avatar-group';
3
9
  import { SmartLinkSize } from '../../../../../constants';
4
10
  var MAX_COUNT = 4;
5
11
 
12
+ var getStyles = function getStyles(size) {
13
+ switch (size) {
14
+ case SmartLinkSize.XLarge:
15
+ case SmartLinkSize.Large:
16
+ // Default AK small size
17
+ return;
18
+
19
+ case SmartLinkSize.Medium:
20
+ case SmartLinkSize.Small:
21
+ 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 "])));
23
+ }
24
+ };
25
+
6
26
  var AvatarGroup = function AvatarGroup(_ref) {
7
27
  var _ref$items = _ref.items,
8
28
  items = _ref$items === void 0 ? [] : _ref$items,
@@ -17,13 +37,15 @@ var AvatarGroup = function AvatarGroup(_ref) {
17
37
  return null;
18
38
  }
19
39
 
20
- return /*#__PURE__*/React.createElement(AtlaskitAvatarGroup, {
40
+ return jsx("span", {
41
+ css: getStyles(size)
42
+ }, jsx(AtlaskitAvatarGroup, {
21
43
  maxCount: maxCount,
22
44
  appearance: "stack",
23
45
  size: "small",
24
46
  data: items,
25
47
  testId: testId
26
- });
48
+ }));
27
49
  };
28
50
 
29
51
  export default AvatarGroup;
@@ -13,6 +13,7 @@ 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
19
  export var Title = createElement(ElementName.Title);
@@ -7,10 +7,15 @@ 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) {
12
+ return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n font-size: 0.75rem;\n line-height: 1rem;\n ", "\n"])), tokens.text, getTruncateStyles(maxLines));
13
+ };
11
14
 
12
15
  var Text = function Text(_ref) {
13
16
  var content = _ref.content,
17
+ _ref$maxLines = _ref.maxLines,
18
+ maxLines = _ref$maxLines === void 0 ? 1 : _ref$maxLines,
14
19
  message = _ref.message,
15
20
  _ref$testId = _ref.testId,
16
21
  testId = _ref$testId === void 0 ? 'smart-element-text' : _ref$testId;
@@ -20,7 +25,7 @@ var Text = function Text(_ref) {
20
25
  }
21
26
 
22
27
  return jsx("span", {
23
- css: styles,
28
+ css: getStyles(maxLines),
24
29
  "data-smart-element-text": true,
25
30
  "data-testid": testId
26
31
  }, getFormattedMessage(message) || content);
@@ -36,6 +36,11 @@ var elementMappings = (_elementMappings = {}, _defineProperty(_elementMappings,
36
36
  props: {
37
37
  icon: IconType.ProgrammingLanguage
38
38
  }
39
+ }), _defineProperty(_elementMappings, ElementName.Snippet, {
40
+ component: Text,
41
+ props: {
42
+ maxLines: 3
43
+ }
39
44
  }), _defineProperty(_elementMappings, ElementName.State, {
40
45
  component: Lozenge
41
46
  }), _defineProperty(_elementMappings, ElementName.SubscriberCount, {
@@ -57,17 +62,6 @@ var getContextKey = function getContextKey(name) {
57
62
  return name.length > 0 ? name.charAt(0).toLowerCase() + name.slice(1) : undefined;
58
63
  };
59
64
 
60
- var getFormattedMessage = function getFormattedMessage(descriptor, value) {
61
- return value ? {
62
- message: {
63
- descriptor: descriptor,
64
- values: {
65
- context: value
66
- }
67
- }
68
- } : undefined;
69
- };
70
-
71
65
  var getData = function getData(elementName, contextKey, context) {
72
66
  if (!context) {
73
67
  return undefined;
@@ -76,52 +70,81 @@ var getData = function getData(elementName, contextKey, context) {
76
70
  var data = context[contextKey];
77
71
 
78
72
  switch (elementName) {
73
+ case ElementName.AuthorGroup:
74
+ case ElementName.CollaboratorGroup:
75
+ return toAvatarGroupProps(data);
76
+
79
77
  case ElementName.CommentCount:
80
78
  case ElementName.ProgrammingLanguage:
81
79
  case ElementName.SubscriberCount:
82
- return {
83
- label: data
84
- };
85
-
86
- case ElementName.AuthorGroup:
87
- return {
88
- items: context.authorGroup
89
- };
90
-
91
- case ElementName.CollaboratorGroup:
92
- return {
93
- items: context.collaboratorGroup
94
- };
80
+ return toBadgeProps(data);
95
81
 
96
82
  case ElementName.CreatedBy:
97
- return getFormattedMessage(messages.created_by, context.createdBy);
83
+ return toFormattedTextProps(messages.created_by, context.createdBy);
84
+
85
+ case ElementName.CreatedOn:
86
+ return toDateTimeProps('created', context.createdOn);
98
87
 
99
88
  case ElementName.ModifiedBy:
100
- return getFormattedMessage(messages.modified_by, context.modifiedBy);
89
+ return toFormattedTextProps(messages.modified_by, context.modifiedBy);
101
90
 
102
91
  case ElementName.ModifiedOn:
103
- return context.modifiedOn ? {
104
- date: new Date(context.modifiedOn),
105
- type: 'modified'
106
- } : undefined;
92
+ return toDateTimeProps('modified', context.modifiedOn);
107
93
 
108
- case ElementName.CreatedOn:
109
- return context.createdOn ? {
110
- date: new Date(context.createdOn),
111
- type: 'created'
112
- } : undefined;
94
+ case ElementName.Snippet:
95
+ return toTextProps(data);
113
96
 
114
97
  case ElementName.Title:
115
- return {
116
- text: context.title,
117
- url: context.url
118
- };
98
+ return toLinkProps(context.title, context.url);
119
99
 
120
100
  default:
121
101
  return data;
122
102
  }
123
103
  };
124
104
 
105
+ var toAvatarGroupProps = function toAvatarGroupProps(items) {
106
+ return items ? {
107
+ items: items
108
+ } : undefined;
109
+ };
110
+
111
+ var toBadgeProps = function toBadgeProps(label) {
112
+ return label ? {
113
+ label: label
114
+ } : undefined;
115
+ };
116
+
117
+ var toDateTimeProps = function toDateTimeProps(type, dateString) {
118
+ return dateString ? {
119
+ date: new Date(dateString),
120
+ type: type
121
+ } : undefined;
122
+ };
123
+
124
+ var toFormattedTextProps = function toFormattedTextProps(descriptor, context) {
125
+ return context ? {
126
+ message: {
127
+ descriptor: descriptor,
128
+ values: {
129
+ context: context
130
+ }
131
+ }
132
+ } : undefined;
133
+ };
134
+
135
+ var toLinkProps = function toLinkProps(text, url) {
136
+ return text ? {
137
+ text: text,
138
+ url: url
139
+ } : undefined;
140
+ };
141
+
142
+ var toTextProps = function toTextProps(content) {
143
+ return content ? {
144
+ content: content
145
+ } : undefined;
146
+ };
147
+
125
148
  export var createElement = function createElement(name) {
126
149
  var _ref = elementMappings[name] || {},
127
150
  BaseElement = _ref.component,
@@ -45,6 +45,7 @@ export declare enum ElementName {
45
45
  ModifiedOn = "ModifiedOn",
46
46
  Priority = "Priority",
47
47
  ProgrammingLanguage = "ProgrammingLanguage",
48
+ Snippet = "Snippet",
48
49
  State = "State",
49
50
  SubscriberCount = "SubscriberCount",
50
51
  Title = "Title"
@@ -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,11 @@ 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[];
19
20
  };
20
21
  export declare type Icon = {
21
22
  icon?: IconType;
@@ -0,0 +1,5 @@
1
+ /** @jsx jsx */
2
+ import React from 'react';
3
+ import { ActionProps } from './types';
4
+ declare const Action: React.FC<ActionProps>;
5
+ export default Action;
@@ -0,0 +1,18 @@
1
+ import { SmartLinkSize } from '../../../../../constants';
2
+ import { Appearance } from '@atlaskit/button/types';
3
+ import { ReactChild } from 'react';
4
+ export declare type ActionProps = {
5
+ size?: SmartLinkSize;
6
+ testId?: string;
7
+ content?: React.ReactNode;
8
+ appearance?: Appearance;
9
+ onClick: () => any;
10
+ icon?: ReactChild;
11
+ iconPosition?: 'before' | 'after';
12
+ tooltipMessage?: React.ReactNode;
13
+ };
14
+ export declare type ActionIconProps = {
15
+ size?: SmartLinkSize;
16
+ testId?: string;
17
+ icon?: ReactChild;
18
+ };
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
- import { ActionProps } from './types';
2
+ import { ActionProps } from './action/types';
3
3
  export declare const DeleteAction: import("react").FC<ActionProps>;
@@ -1,3 +1,4 @@
1
1
  import { ActionName } from '../../../../constants';
2
2
  import React from 'react';
3
- export declare const createAction: <P extends {}>(name: ActionName) => React.FC<P>;
3
+ export declare const createDataAction: <P extends {}>(name: ActionName) => React.FC<P>;
4
+ export declare const createUIAction: <P extends {}>(name: ActionName) => React.FC<P>;
@@ -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;
@@ -1,3 +1,4 @@
1
+ /** @jsx jsx */
1
2
  import React from 'react';
2
3
  import { AvatarGroupProps } from './types';
3
4
  declare const AvatarGroup: React.FC<AvatarGroupProps>;
@@ -1,5 +1,5 @@
1
1
  import { ElementProps } from '../types';
2
- declare type AvatarItemProps = {
2
+ export declare type AvatarItemProps = {
3
3
  src?: string;
4
4
  name: string;
5
5
  };
@@ -7,4 +7,3 @@ export declare type AvatarGroupProps = ElementProps & {
7
7
  items?: AvatarItemProps[];
8
8
  maxCount?: number;
9
9
  };
10
- export {};
@@ -16,6 +16,7 @@ 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>;
@@ -2,5 +2,6 @@ import { ElementProps } from '../types';
2
2
  import { MessageProps } from '../../types';
3
3
  export declare type TextProps = ElementProps & {
4
4
  content?: string;
5
+ maxLines?: number;
5
6
  message?: MessageProps;
6
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "17.2.0",
3
+ "version": "17.3.2",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"