@atlaskit/smart-card 17.4.2 → 17.5.1

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 (66) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/constants.js +14 -2
  3. package/dist/cjs/extractors/flexible/extract-preview.js +21 -0
  4. package/dist/cjs/extractors/flexible/index.js +3 -0
  5. package/dist/cjs/utils/token.js +14 -24
  6. package/dist/cjs/version.json +1 -1
  7. package/dist/cjs/view/FlexibleCard/components/actions/action/index.js +18 -7
  8. package/dist/cjs/view/FlexibleCard/components/actions/utils.js +8 -1
  9. package/dist/cjs/view/FlexibleCard/components/blocks/action-group/index.js +3 -2
  10. package/dist/cjs/view/FlexibleCard/components/blocks/footer-block/index.js +50 -0
  11. package/dist/cjs/view/FlexibleCard/components/blocks/footer-block/types.js +5 -0
  12. package/dist/cjs/view/FlexibleCard/components/blocks/index.js +8 -0
  13. package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +24 -4
  14. package/dist/cjs/view/FlexibleCard/components/common/atlaskit-icon/index.js +1 -1
  15. package/dist/cjs/view/FlexibleCard/components/elements/index.js +3 -1
  16. package/dist/cjs/view/FlexibleCard/components/elements/media/index.js +45 -0
  17. package/dist/cjs/view/FlexibleCard/components/elements/media/types.js +5 -0
  18. package/dist/cjs/view/FlexibleCard/components/elements/utils.js +4 -0
  19. package/dist/es2019/constants.js +11 -1
  20. package/dist/es2019/extractors/flexible/extract-preview.js +12 -0
  21. package/dist/es2019/extractors/flexible/index.js +2 -0
  22. package/dist/es2019/utils/token.js +14 -22
  23. package/dist/es2019/version.json +1 -1
  24. package/dist/es2019/view/FlexibleCard/components/actions/action/index.js +34 -6
  25. package/dist/es2019/view/FlexibleCard/components/actions/utils.js +5 -1
  26. package/dist/es2019/view/FlexibleCard/components/blocks/action-group/index.js +3 -2
  27. package/dist/es2019/view/FlexibleCard/components/blocks/footer-block/index.js +35 -0
  28. package/dist/es2019/view/FlexibleCard/components/blocks/footer-block/types.js +1 -0
  29. package/dist/es2019/view/FlexibleCard/components/blocks/index.js +1 -0
  30. package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +20 -5
  31. package/dist/es2019/view/FlexibleCard/components/common/atlaskit-icon/index.js +1 -1
  32. package/dist/es2019/view/FlexibleCard/components/elements/index.js +1 -0
  33. package/dist/es2019/view/FlexibleCard/components/elements/media/index.js +35 -0
  34. package/dist/es2019/view/FlexibleCard/components/elements/media/types.js +1 -0
  35. package/dist/es2019/view/FlexibleCard/components/elements/utils.js +4 -0
  36. package/dist/esm/constants.js +11 -1
  37. package/dist/esm/extractors/flexible/extract-preview.js +12 -0
  38. package/dist/esm/extractors/flexible/index.js +2 -0
  39. package/dist/esm/utils/token.js +14 -22
  40. package/dist/esm/version.json +1 -1
  41. package/dist/esm/view/FlexibleCard/components/actions/action/index.js +17 -7
  42. package/dist/esm/view/FlexibleCard/components/actions/utils.js +9 -1
  43. package/dist/esm/view/FlexibleCard/components/blocks/action-group/index.js +3 -2
  44. package/dist/esm/view/FlexibleCard/components/blocks/footer-block/index.js +34 -0
  45. package/dist/esm/view/FlexibleCard/components/blocks/footer-block/types.js +1 -0
  46. package/dist/esm/view/FlexibleCard/components/blocks/index.js +1 -0
  47. package/dist/esm/view/FlexibleCard/components/blocks/utils.js +25 -6
  48. package/dist/esm/view/FlexibleCard/components/common/atlaskit-icon/index.js +1 -1
  49. package/dist/esm/view/FlexibleCard/components/elements/index.js +1 -0
  50. package/dist/esm/view/FlexibleCard/components/elements/media/index.js +34 -0
  51. package/dist/esm/view/FlexibleCard/components/elements/media/types.js +1 -0
  52. package/dist/esm/view/FlexibleCard/components/elements/utils.js +3 -0
  53. package/dist/types/constants.d.ts +7 -0
  54. package/dist/types/extractors/flexible/extract-preview.d.ts +4 -0
  55. package/dist/types/state/flexible-ui-context/types.d.ts +6 -1
  56. package/dist/types/utils/token.d.ts +13 -14
  57. package/dist/types/view/FlexibleCard/components/blocks/action-group/types.d.ts +2 -0
  58. package/dist/types/view/FlexibleCard/components/blocks/footer-block/index.d.ts +4 -0
  59. package/dist/types/view/FlexibleCard/components/blocks/footer-block/types.d.ts +4 -0
  60. package/dist/types/view/FlexibleCard/components/blocks/index.d.ts +1 -0
  61. package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +2 -0
  62. package/dist/types/view/FlexibleCard/components/blocks/utils.d.ts +1 -1
  63. package/dist/types/view/FlexibleCard/components/elements/index.d.ts +2 -0
  64. package/dist/types/view/FlexibleCard/components/elements/media/index.d.ts +5 -0
  65. package/dist/types/view/FlexibleCard/components/elements/media/types.d.ts +6 -0
  66. package/package.json +1 -1
@@ -8,7 +8,7 @@ import { getIconSizeStyles } from '../../utils';
8
8
  import { tokens } from '../../../../../utils/token';
9
9
  import { handleOnClick } from '../../../../../utils';
10
10
 
11
- const getWidth = size => {
11
+ const getIconWidth = size => {
12
12
  switch (size) {
13
13
  case SmartLinkSize.XLarge:
14
14
  case SmartLinkSize.Large:
@@ -23,9 +23,27 @@ const getWidth = size => {
23
23
 
24
24
  const getIconStyles = size => css`
25
25
  color: ${tokens.actionIcon};
26
- ${getIconSizeStyles(getWidth(size))};
26
+ ${getIconSizeStyles(getIconWidth(size))};
27
27
  `;
28
28
 
29
+ const getButtonStyle = (size, iconOnly) => size === SmartLinkSize.Small ? css`
30
+ font-size: 0.75rem;
31
+ font-weight: 500;
32
+ line-height: 1rem;
33
+ button,
34
+ button:hover,
35
+ button:focus,
36
+ button:active {
37
+ line-height: 1rem;
38
+ ${iconOnly ? `
39
+ padding: 0.125rem;
40
+ ` : `
41
+ padding-left: 0.25rem;
42
+ padding-right: 0.25rem;
43
+ `}
44
+ }
45
+ ` : '';
46
+
29
47
  const ActionIcon = ({
30
48
  size,
31
49
  testId,
@@ -35,6 +53,13 @@ const ActionIcon = ({
35
53
  "data-testid": `${testId}-icon`
36
54
  }, icon);
37
55
 
56
+ const sizeToSpacing = {
57
+ [SmartLinkSize.Small]: 'none',
58
+ [SmartLinkSize.Medium]: 'compact',
59
+ [SmartLinkSize.Large]: 'compact',
60
+ [SmartLinkSize.XLarge]: 'default'
61
+ };
62
+
38
63
  const Action = ({
39
64
  appearance = 'subtle',
40
65
  content,
@@ -49,26 +74,29 @@ const Action = ({
49
74
  return null;
50
75
  }
51
76
 
52
- const iconBefore = iconPosition === 'before' ? jsx(ActionIcon, {
77
+ const iconBefore = icon && iconPosition === 'before' ? jsx(ActionIcon, {
53
78
  size: size,
54
79
  testId: testId,
55
80
  icon: icon
56
81
  }) : undefined;
57
- const iconAfter = iconPosition === 'after' ? jsx(ActionIcon, {
82
+ const iconAfter = icon && iconPosition === 'after' ? jsx(ActionIcon, {
58
83
  size: size,
59
84
  testId: testId,
60
85
  icon: icon
61
86
  }) : undefined;
87
+ const iconOnly = !content;
62
88
  return jsx(Tooltip, {
63
89
  content: tooltipMessage
90
+ }, jsx("div", {
91
+ css: getButtonStyle(size, iconOnly)
64
92
  }, jsx(Button, {
65
- spacing: "none",
93
+ spacing: sizeToSpacing[size],
66
94
  appearance: appearance,
67
95
  testId: testId,
68
96
  onClick: handleOnClick(onClick),
69
97
  iconBefore: iconBefore,
70
98
  iconAfter: iconAfter
71
- }, content));
99
+ }, content)));
72
100
  };
73
101
 
74
102
  export default Action;
@@ -11,6 +11,7 @@ const actionMappings = {
11
11
  component: Action,
12
12
  props: {
13
13
  testId: 'smart-action-delete-action',
14
+ content: /*#__PURE__*/React.createElement(FormattedMessage, messages.delete),
14
15
  icon: /*#__PURE__*/React.createElement(CrossIcon, {
15
16
  label: "Delete"
16
17
  }),
@@ -66,6 +67,9 @@ export const createUIAction = name => {
66
67
  }
67
68
 
68
69
  return overrides => {
69
- return /*#__PURE__*/React.createElement(BaseAction, _extends({}, props, overrides));
70
+ const combinedProps = { ...props,
71
+ ...overrides
72
+ };
73
+ return /*#__PURE__*/React.createElement(BaseAction, combinedProps);
70
74
  };
71
75
  };
@@ -10,13 +10,14 @@ const styles = css`
10
10
 
11
11
  const ActionGroup = ({
12
12
  items = [],
13
- size = SmartLinkSize.Medium
13
+ size = SmartLinkSize.Medium,
14
+ appearance
14
15
  }) => {
15
16
  // Currently we only have delete action available, this prevents others from adding more delete actions
16
17
  const actionsToRender = items.slice(0, 1);
17
18
  return jsx("div", {
18
19
  css: styles
19
- }, jsx(ButtonGroup, null, renderActionItems(actionsToRender, size)));
20
+ }, jsx(ButtonGroup, null, renderActionItems(actionsToRender, size, appearance)));
20
21
  };
21
22
 
22
23
  export default ActionGroup;
@@ -0,0 +1,35 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React from 'react';
3
+ import { SmartLinkAlignment, SmartLinkDirection, SmartLinkStatus, SmartLinkWidth } from '../../../../../constants';
4
+ import Block from '../block';
5
+ import ElementGroup from '../element-group';
6
+ import { Provider } from '../../elements';
7
+ import ActionGroup from '../action-group';
8
+
9
+ const FooterBlock = props => {
10
+ const {
11
+ status,
12
+ actions,
13
+ testId = 'smart-footer-block'
14
+ } = props;
15
+
16
+ if (status !== SmartLinkStatus.Resolved) {
17
+ return null;
18
+ }
19
+
20
+ return /*#__PURE__*/React.createElement(Block, _extends({}, props, {
21
+ testId: `${testId}-resolved-view`
22
+ }), /*#__PURE__*/React.createElement(Provider, {
23
+ testId: `${testId}-provider`
24
+ }), actions && actions.length > 0 ? /*#__PURE__*/React.createElement(ElementGroup, {
25
+ testId: "smart-element-group-actions",
26
+ align: SmartLinkAlignment.Right,
27
+ direction: SmartLinkDirection.Horizontal,
28
+ width: SmartLinkWidth.Flexible
29
+ }, /*#__PURE__*/React.createElement(ActionGroup, {
30
+ items: actions,
31
+ appearance: "default"
32
+ })) : null);
33
+ };
34
+
35
+ export default FooterBlock;
@@ -1,3 +1,4 @@
1
+ export { default as FooterBlock } from './footer-block';
1
2
  export { default as MetadataBlock } from './metadata-block';
2
3
  export { default as SnippetBlock } from './snippet-block';
3
4
  export { default as TitleBlock } from './title-block';
@@ -6,8 +6,7 @@ import * as Elements from '../elements';
6
6
  import * as Actions from '../actions';
7
7
  import { isFlexibleUiElement } from '../../../../utils/flexible';
8
8
  import ActionGroup from './action-group';
9
- import ElementGroup from './element-group'; // Determine whether the element can be display as inline/block.
10
-
9
+ import ElementGroup from './element-group';
11
10
  export const ElementDisplaySchema = {
12
11
  [ElementName.AuthorGroup]: ['inline'],
13
12
  [ElementName.CollaboratorGroup]: ['inline'],
@@ -17,6 +16,7 @@ export const ElementDisplaySchema = {
17
16
  [ElementName.LinkIcon]: ['inline'],
18
17
  [ElementName.ModifiedBy]: ['inline'],
19
18
  [ElementName.ModifiedOn]: ['inline'],
19
+ [ElementName.Preview]: ['block'],
20
20
  [ElementName.Priority]: ['inline'],
21
21
  [ElementName.ProgrammingLanguage]: ['inline'],
22
22
  [ElementName.Snippet]: ['block'],
@@ -130,19 +130,34 @@ export const renderElementItems = (items = [], display = 'inline') => {
130
130
  return elements;
131
131
  }
132
132
  };
133
- export const renderActionItems = (items = [], size = SmartLinkSize.Medium) => {
133
+ export const renderActionItems = (items = [], size = SmartLinkSize.Medium, appearance) => {
134
134
  const actions = items.reduce((acc, curr, idx) => {
135
135
  const {
136
136
  name,
137
+ hideContent,
138
+ hideIcon,
139
+ onClick,
137
140
  ...props
138
141
  } = curr;
139
142
  const Action = Actions[name];
143
+ const actionProps = { ...props
144
+ };
145
+
146
+ if (hideContent) {
147
+ actionProps.content = '';
148
+ }
149
+
150
+ if (hideIcon) {
151
+ actionProps.icon = undefined;
152
+ }
140
153
 
141
154
  if (Action) {
142
155
  return [...acc, /*#__PURE__*/React.createElement(Action, _extends({
143
156
  size: size,
144
- key: idx
145
- }, props))];
157
+ key: idx,
158
+ appearance: appearance,
159
+ onClick: onClick
160
+ }, actionProps))];
146
161
  }
147
162
 
148
163
  return acc;
@@ -217,7 +217,7 @@ const AtlaskitIcon = ({
217
217
  case IconType.Jira:
218
218
  // Logo component has a different prop set from other icon components
219
219
  return /*#__PURE__*/React.createElement(ImportedIcon, {
220
- "data-testId": testId // Confluence and Jira imports don't have native testId prop
220
+ "data-testid": testId // Confluence and Jira imports don't have native testId prop
221
221
  ,
222
222
  textColor: N700,
223
223
  iconColor: B200,
@@ -11,6 +11,7 @@ export const CreatedOn = createElement(ElementName.CreatedOn);
11
11
  export const LinkIcon = createElement(ElementName.LinkIcon);
12
12
  export const ModifiedBy = createElement(ElementName.ModifiedBy);
13
13
  export const ModifiedOn = createElement(ElementName.ModifiedOn);
14
+ export const Preview = createElement(ElementName.Preview);
14
15
  export const Priority = createElement(ElementName.Priority);
15
16
  export const ProgrammingLanguage = createElement(ElementName.ProgrammingLanguage);
16
17
  export const Snippet = createElement(ElementName.Snippet);
@@ -0,0 +1,35 @@
1
+ /** @jsx jsx */
2
+ import React from 'react';
3
+ import { css, jsx } from '@emotion/core';
4
+ import ImageIcon from '../../common/image-icon';
5
+
6
+ const styles = url => css`
7
+ display: flex;
8
+ justify-content: center;
9
+ width: 100%;
10
+ > img {
11
+ max-width: 100%;
12
+ max-height: 100%;
13
+ }
14
+ `;
15
+
16
+ const Media = ({
17
+ testId = 'smart-element-media',
18
+ type,
19
+ url
20
+ }) => {
21
+ if (!type || !url) {
22
+ return null;
23
+ }
24
+
25
+ return jsx("div", {
26
+ css: styles(url),
27
+ "data-smart-element-media": true,
28
+ "data-testid": testId
29
+ }, jsx(ImageIcon, {
30
+ testId: `${testId}-image`,
31
+ url: url
32
+ }));
33
+ };
34
+
35
+ export default Media;
@@ -7,6 +7,7 @@ import Lozenge from './lozenge';
7
7
  import { FlexibleUiContext } from '../../../../state/flexible-ui-context';
8
8
  import Badge from './badge';
9
9
  import AvatarGroup from './avatar-group';
10
+ import Media from './media';
10
11
  import Text from './text';
11
12
  import { messages } from '../../../../messages';
12
13
  import DateTime from './date-time';
@@ -34,6 +35,9 @@ const elementMappings = {
34
35
  [ElementName.ModifiedBy]: {
35
36
  component: Text
36
37
  },
38
+ [ElementName.Preview]: {
39
+ component: Media
40
+ },
37
41
  [ElementName.Priority]: {
38
42
  component: Badge
39
43
  },
@@ -114,6 +114,7 @@ export var ElementName;
114
114
  ElementName["LinkIcon"] = "LinkIcon";
115
115
  ElementName["ModifiedBy"] = "ModifiedBy";
116
116
  ElementName["ModifiedOn"] = "ModifiedOn";
117
+ ElementName["Preview"] = "Preview";
117
118
  ElementName["Priority"] = "Priority";
118
119
  ElementName["ProgrammingLanguage"] = "ProgrammingLanguage";
119
120
  ElementName["Snippet"] = "Snippet";
@@ -133,6 +134,9 @@ export var ActionName;
133
134
  })(ActionName || (ActionName = {}));
134
135
 
135
136
  export var IconType;
137
+ /**
138
+ * Type for Flexible UI's Media element
139
+ */
136
140
 
137
141
  (function (IconType) {
138
142
  IconType["Archive"] = "FileType:Archive";
@@ -192,4 +196,10 @@ export var IconType;
192
196
  IconType["PriorityUndefined"] = "Badge:PriorityUndefined";
193
197
  IconType["ProgrammingLanguage"] = "Badge:ProgrammingLanguage";
194
198
  IconType["Subscriber"] = "Badge:Subscriber";
195
- })(IconType || (IconType = {}));
199
+ })(IconType || (IconType = {}));
200
+
201
+ export var MediaType;
202
+
203
+ (function (MediaType) {
204
+ MediaType["Image"] = "image";
205
+ })(MediaType || (MediaType = {}));
@@ -0,0 +1,12 @@
1
+ import { extractImage } from '../common/preview';
2
+ import { MediaType } from '../../constants';
3
+
4
+ var extractPreview = function extractPreview(data) {
5
+ var url = extractImage(data);
6
+ return url ? {
7
+ type: MediaType.Image,
8
+ url: url
9
+ } : undefined;
10
+ };
11
+
12
+ export default extractPreview;
@@ -8,6 +8,7 @@ import { extractDateUpdated } from '../common/date/extractDateUpdated';
8
8
  import { extractDateCreated } from '../common/date/extractDateCreated';
9
9
  import extractPriority from './extract-priority';
10
10
  import extractProviderIcon from './icon/extract-provider-icon';
11
+ import extractPreview from './extract-preview';
11
12
 
12
13
  var extractFlexibleUiContext = function extractFlexibleUiContext(response, renderers) {
13
14
  if (!response) {
@@ -25,6 +26,7 @@ var extractFlexibleUiContext = function extractFlexibleUiContext(response, rende
25
26
  linkIcon: extractLinkIcon(response, renderers),
26
27
  modifiedBy: extractModifiedBy(data),
27
28
  modifiedOn: extractDateUpdated(data),
29
+ preview: extractPreview(data),
28
30
  priority: extractPriority(data),
29
31
  programmingLanguage: extractProgrammingLanguage(data),
30
32
  snippet: extractSummary(data) || undefined,
@@ -1,24 +1,16 @@
1
- import { token } from '@atlaskit/tokens'; // Temporary safeguard while @atlaskit/tokens is being developed
2
-
3
- export var safeToken = function safeToken(path, fallback) {
4
- try {
5
- return token(path, fallback);
6
- } catch (e) {
7
- return fallback;
8
- }
9
- };
1
+ import { token } from '@atlaskit/tokens';
10
2
  export var tokens = {
11
- actionIcon: safeToken('color.icon', '#44546F'),
12
- background: safeToken('elevation.surface', '#FFFFFF'),
13
- badgeIcon: safeToken('color.icon.subtle', '#626F86'),
14
- badgeText: safeToken('color.text.subtlest', '#626F86'),
15
- blackLink: safeToken('color.text.subtle', '#44546F'),
16
- blackLinkPressed: safeToken('color.text', '#172B4D'),
17
- blueLink: safeToken('color.link', '#0C66E4'),
18
- blueLinkPressed: safeToken('color.link.pressed', '#0055CC'),
19
- elevation: safeToken('elevation.shadow.raised', '0px 1px 1px #091E4240, 0px 0px 1px #091E424F'),
20
- errorMessage: safeToken('color.text.disabled', '#6B778C'),
21
- errorMessageHover: safeToken('color.text.subtle', '#8993A4'),
22
- snippet: safeToken('color.text', '#172B4D'),
23
- text: safeToken('color.text.subtlest', '#626F86')
3
+ actionIcon: token('color.icon', '#44546F'),
4
+ background: token('elevation.surface', '#FFFFFF'),
5
+ badgeIcon: token('color.icon.subtle', '#626F86'),
6
+ badgeText: token('color.text.subtlest', '#626F86'),
7
+ blackLink: token('color.text.subtle', '#44546F'),
8
+ blackLinkPressed: token('color.text', '#172B4D'),
9
+ blueLink: token('color.link', '#0C66E4'),
10
+ blueLinkPressed: token('color.link.pressed', '#0055CC'),
11
+ elevation: token('elevation.shadow.raised', '0px 1px 1px #091E4240, 0px 0px 1px #091E424F'),
12
+ errorMessage: token('color.text.disabled', '#6B778C'),
13
+ errorMessageHover: token('color.text.subtle', '#8993A4'),
14
+ snippet: token('color.text', '#172B4D'),
15
+ text: token('color.text.subtlest', '#626F86')
24
16
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "17.4.2",
3
+ "version": "17.5.1",
4
4
  "sideEffects": false
5
5
  }
@@ -1,6 +1,7 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
2
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
3
 
3
- var _templateObject;
4
+ var _templateObject, _templateObject2, _sizeToSpacing;
4
5
 
5
6
  /** @jsx jsx */
6
7
  import React from 'react';
@@ -12,7 +13,7 @@ import { getIconSizeStyles } from '../../utils';
12
13
  import { tokens } from '../../../../../utils/token';
13
14
  import { handleOnClick } from '../../../../../utils';
14
15
 
15
- var getWidth = function getWidth(size) {
16
+ var getIconWidth = function getIconWidth(size) {
16
17
  switch (size) {
17
18
  case SmartLinkSize.XLarge:
18
19
  case SmartLinkSize.Large:
@@ -26,7 +27,11 @@ var getWidth = function getWidth(size) {
26
27
  };
27
28
 
28
29
  var getIconStyles = function getIconStyles(size) {
29
- return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n ", ";\n"])), tokens.actionIcon, getIconSizeStyles(getWidth(size)));
30
+ return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n ", ";\n"])), tokens.actionIcon, getIconSizeStyles(getIconWidth(size)));
31
+ };
32
+
33
+ var getButtonStyle = function getButtonStyle(size, iconOnly) {
34
+ return size === SmartLinkSize.Small ? css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n font-size: 0.75rem;\n font-weight: 500;\n line-height: 1rem;\n button,\n button:hover,\n button:focus,\n button:active {\n line-height: 1rem;\n ", "\n }\n "])), iconOnly ? "\n padding: 0.125rem;\n " : "\n padding-left: 0.25rem;\n padding-right: 0.25rem;\n ") : '';
30
35
  };
31
36
 
32
37
  var ActionIcon = function ActionIcon(_ref) {
@@ -39,6 +44,8 @@ var ActionIcon = function ActionIcon(_ref) {
39
44
  }, icon);
40
45
  };
41
46
 
47
+ var sizeToSpacing = (_sizeToSpacing = {}, _defineProperty(_sizeToSpacing, SmartLinkSize.Small, 'none'), _defineProperty(_sizeToSpacing, SmartLinkSize.Medium, 'compact'), _defineProperty(_sizeToSpacing, SmartLinkSize.Large, 'compact'), _defineProperty(_sizeToSpacing, SmartLinkSize.XLarge, 'default'), _sizeToSpacing);
48
+
42
49
  var Action = function Action(_ref2) {
43
50
  var _ref2$appearance = _ref2.appearance,
44
51
  appearance = _ref2$appearance === void 0 ? 'subtle' : _ref2$appearance,
@@ -57,26 +64,29 @@ var Action = function Action(_ref2) {
57
64
  return null;
58
65
  }
59
66
 
60
- var iconBefore = iconPosition === 'before' ? jsx(ActionIcon, {
67
+ var iconBefore = icon && iconPosition === 'before' ? jsx(ActionIcon, {
61
68
  size: size,
62
69
  testId: testId,
63
70
  icon: icon
64
71
  }) : undefined;
65
- var iconAfter = iconPosition === 'after' ? jsx(ActionIcon, {
72
+ var iconAfter = icon && iconPosition === 'after' ? jsx(ActionIcon, {
66
73
  size: size,
67
74
  testId: testId,
68
75
  icon: icon
69
76
  }) : undefined;
77
+ var iconOnly = !content;
70
78
  return jsx(Tooltip, {
71
79
  content: tooltipMessage
80
+ }, jsx("div", {
81
+ css: getButtonStyle(size, iconOnly)
72
82
  }, jsx(Button, {
73
- spacing: "none",
83
+ spacing: sizeToSpacing[size],
74
84
  appearance: appearance,
75
85
  testId: testId,
76
86
  onClick: handleOnClick(onClick),
77
87
  iconBefore: iconBefore,
78
88
  iconAfter: iconAfter
79
- }, content));
89
+ }, content)));
80
90
  };
81
91
 
82
92
  export default Action;
@@ -1,5 +1,10 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+
4
+ 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; }
5
+
6
+ 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; }
7
+
3
8
  import { ActionName } from '../../../../constants';
4
9
  import { FlexibleUiContext } from '../../../../state/flexible-ui-context';
5
10
  import React, { useContext } from 'react';
@@ -12,6 +17,7 @@ var actionMappings = _defineProperty({}, ActionName.DeleteAction, {
12
17
  component: Action,
13
18
  props: {
14
19
  testId: 'smart-action-delete-action',
20
+ content: /*#__PURE__*/React.createElement(FormattedMessage, messages.delete),
15
21
  icon: /*#__PURE__*/React.createElement(CrossIcon, {
16
22
  label: "Delete"
17
23
  }),
@@ -65,6 +71,8 @@ export var createUIAction = function createUIAction(name) {
65
71
  }
66
72
 
67
73
  return function (overrides) {
68
- return /*#__PURE__*/React.createElement(BaseAction, _extends({}, props, overrides));
74
+ var combinedProps = _objectSpread(_objectSpread({}, props), overrides);
75
+
76
+ return /*#__PURE__*/React.createElement(BaseAction, combinedProps);
69
77
  };
70
78
  };
@@ -13,12 +13,13 @@ var ActionGroup = function ActionGroup(_ref) {
13
13
  var _ref$items = _ref.items,
14
14
  items = _ref$items === void 0 ? [] : _ref$items,
15
15
  _ref$size = _ref.size,
16
- size = _ref$size === void 0 ? SmartLinkSize.Medium : _ref$size;
16
+ size = _ref$size === void 0 ? SmartLinkSize.Medium : _ref$size,
17
+ appearance = _ref.appearance;
17
18
  // Currently we only have delete action available, this prevents others from adding more delete actions
18
19
  var actionsToRender = items.slice(0, 1);
19
20
  return jsx("div", {
20
21
  css: styles
21
- }, jsx(ButtonGroup, null, renderActionItems(actionsToRender, size)));
22
+ }, jsx(ButtonGroup, null, renderActionItems(actionsToRender, size, appearance)));
22
23
  };
23
24
 
24
25
  export default ActionGroup;
@@ -0,0 +1,34 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React from 'react';
3
+ import { SmartLinkAlignment, SmartLinkDirection, SmartLinkStatus, SmartLinkWidth } from '../../../../../constants';
4
+ import Block from '../block';
5
+ import ElementGroup from '../element-group';
6
+ import { Provider } from '../../elements';
7
+ import ActionGroup from '../action-group';
8
+
9
+ var FooterBlock = function FooterBlock(props) {
10
+ var status = props.status,
11
+ actions = props.actions,
12
+ _props$testId = props.testId,
13
+ testId = _props$testId === void 0 ? 'smart-footer-block' : _props$testId;
14
+
15
+ if (status !== SmartLinkStatus.Resolved) {
16
+ return null;
17
+ }
18
+
19
+ return /*#__PURE__*/React.createElement(Block, _extends({}, props, {
20
+ testId: "".concat(testId, "-resolved-view")
21
+ }), /*#__PURE__*/React.createElement(Provider, {
22
+ testId: "".concat(testId, "-provider")
23
+ }), actions && actions.length > 0 ? /*#__PURE__*/React.createElement(ElementGroup, {
24
+ testId: "smart-element-group-actions",
25
+ align: SmartLinkAlignment.Right,
26
+ direction: SmartLinkDirection.Horizontal,
27
+ width: SmartLinkWidth.Flexible
28
+ }, /*#__PURE__*/React.createElement(ActionGroup, {
29
+ items: actions,
30
+ appearance: "default"
31
+ })) : null);
32
+ };
33
+
34
+ export default FooterBlock;
@@ -1,3 +1,4 @@
1
+ export { default as FooterBlock } from './footer-block';
1
2
  export { default as MetadataBlock } from './metadata-block';
2
3
  export { default as SnippetBlock } from './snippet-block';
3
4
  export { default as TitleBlock } from './title-block';
@@ -4,10 +4,14 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
4
4
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
5
5
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
6
6
  var _excluded = ["name"],
7
- _excluded2 = ["name"];
7
+ _excluded2 = ["name", "hideContent", "hideIcon", "onClick"];
8
8
 
9
9
  var _ElementDisplaySchema, _templateObject, _templateObject2, _templateObject3;
10
10
 
11
+ 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; }
12
+
13
+ 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; }
14
+
11
15
  import React from 'react';
12
16
  import { css } from '@emotion/core';
13
17
  import { ElementName, SmartLinkDirection, SmartLinkSize } from '../../../../constants';
@@ -15,9 +19,8 @@ import * as Elements from '../elements';
15
19
  import * as Actions from '../actions';
16
20
  import { isFlexibleUiElement } from '../../../../utils/flexible';
17
21
  import ActionGroup from './action-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);
22
+ import ElementGroup from './element-group';
23
+ export var ElementDisplaySchema = (_ElementDisplaySchema = {}, _defineProperty(_ElementDisplaySchema, ElementName.AuthorGroup, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CollaboratorGroup, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CommentCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CreatedBy, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CreatedOn, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.LinkIcon, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ModifiedBy, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ModifiedOn, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Preview, ['block']), _defineProperty(_ElementDisplaySchema, ElementName.Priority, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ProgrammingLanguage, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Snippet, ['block']), _defineProperty(_ElementDisplaySchema, ElementName.State, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.SubscriberCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Title, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Provider, ['inline']), _ElementDisplaySchema);
21
24
 
22
25
  var getDirectionStyles = function getDirectionStyles(direction) {
23
26
  switch (direction) {
@@ -110,17 +113,33 @@ export var renderElementItems = function renderElementItems() {
110
113
  export var renderActionItems = function renderActionItems() {
111
114
  var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
112
115
  var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : SmartLinkSize.Medium;
116
+ var appearance = arguments.length > 2 ? arguments[2] : undefined;
113
117
  var actions = items.reduce(function (acc, curr, idx) {
114
118
  var name = curr.name,
119
+ hideContent = curr.hideContent,
120
+ hideIcon = curr.hideIcon,
121
+ onClick = curr.onClick,
115
122
  props = _objectWithoutProperties(curr, _excluded2);
116
123
 
117
124
  var Action = Actions[name];
118
125
 
126
+ var actionProps = _objectSpread({}, props);
127
+
128
+ if (hideContent) {
129
+ actionProps.content = '';
130
+ }
131
+
132
+ if (hideIcon) {
133
+ actionProps.icon = undefined;
134
+ }
135
+
119
136
  if (Action) {
120
137
  return [].concat(_toConsumableArray(acc), [/*#__PURE__*/React.createElement(Action, _extends({
121
138
  size: size,
122
- key: idx
123
- }, props))]);
139
+ key: idx,
140
+ appearance: appearance,
141
+ onClick: onClick
142
+ }, actionProps))]);
124
143
  }
125
144
 
126
145
  return acc;
@@ -281,7 +281,7 @@ 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
284
+ "data-testid": testId // Confluence and Jira imports don't have native testId prop
285
285
  ,
286
286
  textColor: N700,
287
287
  iconColor: B200,