@atlaskit/smart-card 17.5.1 → 17.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/index.js +12 -0
  3. package/dist/cjs/version.json +1 -1
  4. package/dist/cjs/view/FlexibleCard/components/actions/action/index.js +28 -14
  5. package/dist/cjs/view/FlexibleCard/components/blocks/action-group/index.js +31 -3
  6. package/dist/cjs/view/FlexibleCard/components/blocks/index.js +8 -0
  7. package/dist/cjs/view/FlexibleCard/components/blocks/preview-block/index.js +41 -0
  8. package/dist/cjs/view/FlexibleCard/components/blocks/preview-block/types.js +5 -0
  9. package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +3 -1
  10. package/dist/cjs/view/InlineCard/Frame/index.js +1 -6
  11. package/dist/es2019/index.js +1 -1
  12. package/dist/es2019/version.json +1 -1
  13. package/dist/es2019/view/FlexibleCard/components/actions/action/index.js +26 -14
  14. package/dist/es2019/view/FlexibleCard/components/blocks/action-group/index.js +22 -3
  15. package/dist/es2019/view/FlexibleCard/components/blocks/index.js +1 -0
  16. package/dist/es2019/view/FlexibleCard/components/blocks/preview-block/index.js +21 -0
  17. package/dist/es2019/view/FlexibleCard/components/blocks/preview-block/types.js +1 -0
  18. package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +3 -2
  19. package/dist/es2019/view/InlineCard/Frame/index.js +1 -6
  20. package/dist/esm/index.js +1 -1
  21. package/dist/esm/version.json +1 -1
  22. package/dist/esm/view/FlexibleCard/components/actions/action/index.js +26 -14
  23. package/dist/esm/view/FlexibleCard/components/blocks/action-group/index.js +25 -3
  24. package/dist/esm/view/FlexibleCard/components/blocks/index.js +1 -0
  25. package/dist/esm/view/FlexibleCard/components/blocks/preview-block/index.js +25 -0
  26. package/dist/esm/view/FlexibleCard/components/blocks/preview-block/types.js +1 -0
  27. package/dist/esm/view/FlexibleCard/components/blocks/utils.js +3 -1
  28. package/dist/esm/view/InlineCard/Frame/index.js +1 -6
  29. package/dist/types/__tests_external__/page-objects/BaseCard.d.ts +0 -1
  30. package/dist/types/index.d.ts +1 -1
  31. package/dist/types/utils/index.d.ts +1 -1
  32. package/dist/types/view/FlexibleCard/components/actions/action/index.d.ts +3 -0
  33. package/dist/types/view/FlexibleCard/components/actions/action/types.d.ts +1 -0
  34. package/dist/types/view/FlexibleCard/components/blocks/index.d.ts +1 -0
  35. package/dist/types/view/FlexibleCard/components/blocks/preview-block/index.d.ts +4 -0
  36. package/dist/types/view/FlexibleCard/components/blocks/preview-block/types.d.ts +2 -0
  37. package/dist/types/view/FlexibleCard/components/blocks/utils.d.ts +1 -1
  38. package/package.json +3 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 17.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`0cab291e19e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/0cab291e19e) - Add "more" and dopdown for actions when there is more then 2
8
+
9
+ ## 17.5.3
10
+
11
+ ### Patch Changes
12
+
13
+ - [`e68f0f554fa`](https://bitbucket.org/atlassian/atlassian-frontend/commits/e68f0f554fa) - remove mousedown handler for inline links and add a vr test for the logic
14
+
15
+ ## 17.5.2
16
+
17
+ ### Patch Changes
18
+
19
+ - [`0fb7e85e70a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/0fb7e85e70a) - Flexible UI: Add PreviewBlock
20
+
3
21
  ## 17.5.1
4
22
 
5
23
  ### Patch Changes
package/dist/cjs/index.js CHANGED
@@ -53,12 +53,24 @@ Object.defineProperty(exports, "EmbedResizeMessageListener", {
53
53
  return _EmbedResizeMessageListener.EmbedResizeMessageListener;
54
54
  }
55
55
  });
56
+ Object.defineProperty(exports, "FooterBlock", {
57
+ enumerable: true,
58
+ get: function get() {
59
+ return _blocks.FooterBlock;
60
+ }
61
+ });
56
62
  Object.defineProperty(exports, "MetadataBlock", {
57
63
  enumerable: true,
58
64
  get: function get() {
59
65
  return _blocks.MetadataBlock;
60
66
  }
61
67
  });
68
+ Object.defineProperty(exports, "PreviewBlock", {
69
+ enumerable: true,
70
+ get: function get() {
71
+ return _blocks.PreviewBlock;
72
+ }
73
+ });
62
74
  Object.defineProperty(exports, "Provider", {
63
75
  enumerable: true,
64
76
  get: function get() {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "17.5.1",
3
+ "version": "17.6.0",
4
4
  "sideEffects": false
5
5
  }
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.default = void 0;
8
+ exports.sizeToSpacing = exports.default = void 0;
9
9
 
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
 
@@ -21,6 +21,8 @@ var _constants = require("../../../../../constants");
21
21
 
22
22
  var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
23
23
 
24
+ var _dropdownMenu = require("@atlaskit/dropdown-menu");
25
+
24
26
  var _utils = require("../../utils");
25
27
 
26
28
  var _token = require("../../../../../utils/token");
@@ -61,6 +63,7 @@ var ActionIcon = function ActionIcon(_ref) {
61
63
  };
62
64
 
63
65
  var sizeToSpacing = (_sizeToSpacing = {}, (0, _defineProperty2.default)(_sizeToSpacing, _constants.SmartLinkSize.Small, 'none'), (0, _defineProperty2.default)(_sizeToSpacing, _constants.SmartLinkSize.Medium, 'compact'), (0, _defineProperty2.default)(_sizeToSpacing, _constants.SmartLinkSize.Large, 'compact'), (0, _defineProperty2.default)(_sizeToSpacing, _constants.SmartLinkSize.XLarge, 'default'), _sizeToSpacing);
66
+ exports.sizeToSpacing = sizeToSpacing;
64
67
 
65
68
  var Action = function Action(_ref2) {
66
69
  var _ref2$appearance = _ref2.appearance,
@@ -74,7 +77,8 @@ var Action = function Action(_ref2) {
74
77
  icon = _ref2.icon,
75
78
  _ref2$iconPosition = _ref2.iconPosition,
76
79
  iconPosition = _ref2$iconPosition === void 0 ? 'before' : _ref2$iconPosition,
77
- tooltipMessage = _ref2.tooltipMessage;
80
+ tooltipMessage = _ref2.tooltipMessage,
81
+ asDropDownItem = _ref2.asDropDownItem;
78
82
 
79
83
  if (!onClick) {
80
84
  return null;
@@ -91,18 +95,28 @@ var Action = function Action(_ref2) {
91
95
  icon: icon
92
96
  }) : undefined;
93
97
  var iconOnly = !content;
94
- return (0, _core.jsx)(_tooltip.default, {
95
- content: tooltipMessage
96
- }, (0, _core.jsx)("div", {
97
- css: getButtonStyle(size, iconOnly)
98
- }, (0, _core.jsx)(_customThemeButton.default, {
99
- spacing: sizeToSpacing[size],
100
- appearance: appearance,
101
- testId: testId,
102
- onClick: (0, _utils2.handleOnClick)(onClick),
103
- iconBefore: iconBefore,
104
- iconAfter: iconAfter
105
- }, content)));
98
+
99
+ if (asDropDownItem) {
100
+ return (0, _core.jsx)(_dropdownMenu.DropdownItem, {
101
+ elemBefore: iconBefore,
102
+ elemAfter: iconAfter,
103
+ testId: testId,
104
+ onClick: (0, _utils2.handleOnClick)(onClick)
105
+ }, content);
106
+ } else {
107
+ return (0, _core.jsx)(_tooltip.default, {
108
+ content: tooltipMessage
109
+ }, (0, _core.jsx)("div", {
110
+ css: getButtonStyle(size, iconOnly)
111
+ }, (0, _core.jsx)(_customThemeButton.default, {
112
+ spacing: sizeToSpacing[size],
113
+ appearance: appearance,
114
+ testId: testId,
115
+ onClick: (0, _utils2.handleOnClick)(onClick),
116
+ iconBefore: iconBefore,
117
+ iconAfter: iconAfter
118
+ }, content)));
119
+ }
106
120
  };
107
121
 
108
122
  var _default = Action;
@@ -7,6 +7,10 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+
12
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
13
+
10
14
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
11
15
 
12
16
  var _core = require("@emotion/core");
@@ -15,8 +19,18 @@ var _buttonGroup = _interopRequireDefault(require("@atlaskit/button/button-group
15
19
 
16
20
  var _utils = require("../utils");
17
21
 
22
+ var _dropdownMenu = _interopRequireDefault(require("@atlaskit/dropdown-menu"));
23
+
18
24
  var _constants = require("../../../../../constants");
19
25
 
26
+ var _standardButton = _interopRequireDefault(require("@atlaskit/button/standard-button"));
27
+
28
+ var _more = _interopRequireDefault(require("@atlaskit/icon/glyph/more"));
29
+
30
+ var _action = require("../../actions/action");
31
+
32
+ var _excluded = ["triggerRef"];
33
+
20
34
  var _templateObject;
21
35
 
22
36
  var styles = (0, _core.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: inline-flex;\n line-height: 1rem;\n"])));
@@ -27,11 +41,25 @@ var ActionGroup = function ActionGroup(_ref) {
27
41
  _ref$size = _ref.size,
28
42
  size = _ref$size === void 0 ? _constants.SmartLinkSize.Medium : _ref$size,
29
43
  appearance = _ref.appearance;
30
- // Currently we only have delete action available, this prevents others from adding more delete actions
31
- var actionsToRender = items.slice(0, 1);
44
+ var isMoreThenTwoItems = items.length > 2;
45
+ var firstActions = isMoreThenTwoItems ? items.slice(0, 1) : items;
46
+ var restActions = isMoreThenTwoItems ? items.slice(1) : [];
32
47
  return (0, _core.jsx)("div", {
33
48
  css: styles
34
- }, (0, _core.jsx)(_buttonGroup.default, null, (0, _utils.renderActionItems)(actionsToRender, size, appearance)));
49
+ }, (0, _core.jsx)(_buttonGroup.default, null, (0, _utils.renderActionItems)(firstActions, size, appearance), restActions.length > 0 ? (0, _core.jsx)(_dropdownMenu.default, {
50
+ trigger: function trigger(_ref2) {
51
+ var triggerRef = _ref2.triggerRef,
52
+ props = (0, _objectWithoutProperties2.default)(_ref2, _excluded);
53
+ return (0, _core.jsx)(_standardButton.default, (0, _extends2.default)({}, props, {
54
+ spacing: _action.sizeToSpacing[size],
55
+ testId: "action-group-more-button",
56
+ iconBefore: (0, _core.jsx)(_more.default, {
57
+ label: "more"
58
+ }),
59
+ ref: triggerRef
60
+ }));
61
+ }
62
+ }, (0, _utils.renderActionItems)(restActions, size, appearance, true)) : null));
35
63
  };
36
64
 
37
65
  var _default = ActionGroup;
@@ -17,6 +17,12 @@ Object.defineProperty(exports, "MetadataBlock", {
17
17
  return _metadataBlock.default;
18
18
  }
19
19
  });
20
+ Object.defineProperty(exports, "PreviewBlock", {
21
+ enumerable: true,
22
+ get: function get() {
23
+ return _previewBlock.default;
24
+ }
25
+ });
20
26
  Object.defineProperty(exports, "SnippetBlock", {
21
27
  enumerable: true,
22
28
  get: function get() {
@@ -34,6 +40,8 @@ var _footerBlock = _interopRequireDefault(require("./footer-block"));
34
40
 
35
41
  var _metadataBlock = _interopRequireDefault(require("./metadata-block"));
36
42
 
43
+ var _previewBlock = _interopRequireDefault(require("./preview-block"));
44
+
37
45
  var _snippetBlock = _interopRequireDefault(require("./snippet-block"));
38
46
 
39
47
  var _titleBlock = _interopRequireDefault(require("./title-block"));
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+
12
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
13
+
14
+ var _react = _interopRequireDefault(require("react"));
15
+
16
+ var _constants = require("../../../../../constants");
17
+
18
+ var _block = _interopRequireDefault(require("../block"));
19
+
20
+ var _elements = require("../../elements");
21
+
22
+ var _excluded = ["status", "testId"];
23
+
24
+ var PreviewBlock = function PreviewBlock(_ref) {
25
+ var _ref$status = _ref.status,
26
+ status = _ref$status === void 0 ? _constants.SmartLinkStatus.Fallback : _ref$status,
27
+ _ref$testId = _ref.testId,
28
+ testId = _ref$testId === void 0 ? 'smart-block-preview' : _ref$testId,
29
+ blockProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
30
+
31
+ if (status !== _constants.SmartLinkStatus.Resolved) {
32
+ return null;
33
+ }
34
+
35
+ return /*#__PURE__*/_react.default.createElement(_block.default, (0, _extends2.default)({}, blockProps, {
36
+ testId: "".concat(testId, "-resolved-view")
37
+ }), /*#__PURE__*/_react.default.createElement(_elements.Preview, null));
38
+ };
39
+
40
+ var _default = PreviewBlock;
41
+ exports.default = _default;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -153,6 +153,7 @@ var renderActionItems = function renderActionItems() {
153
153
  var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
154
154
  var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _constants.SmartLinkSize.Medium;
155
155
  var appearance = arguments.length > 2 ? arguments[2] : undefined;
156
+ var asDropDownItems = arguments.length > 3 ? arguments[3] : undefined;
156
157
  var actions = items.reduce(function (acc, curr, idx) {
157
158
  var name = curr.name,
158
159
  hideContent = curr.hideContent,
@@ -163,7 +164,7 @@ var renderActionItems = function renderActionItems() {
163
164
 
164
165
  var actionProps = _objectSpread({}, props);
165
166
 
166
- if (hideContent) {
167
+ if (hideContent && !asDropDownItems) {
167
168
  actionProps.content = '';
168
169
  }
169
170
 
@@ -173,6 +174,7 @@ var renderActionItems = function renderActionItems() {
173
174
 
174
175
  if (Action) {
175
176
  return [].concat((0, _toConsumableArray2.default)(acc), [/*#__PURE__*/_react.default.createElement(Action, (0, _extends2.default)({
177
+ asDropDownItem: asDropDownItems,
176
178
  size: size,
177
179
  key: idx,
178
180
  appearance: appearance,
@@ -43,11 +43,7 @@ var Frame = function Frame(props) {
43
43
  event.stopPropagation();
44
44
  onClick(event);
45
45
  }
46
- }, [onClick]); // prevent default on mousedown to avoid inline card losing focus
47
-
48
- var handleMouseDown = (0, _react.useCallback)(function (e) {
49
- e.preventDefault();
50
- }, []);
46
+ }, [onClick]);
51
47
  var isInteractive = Boolean(onClick); // TODO Theming doesn't work right now in editor. Required React context does not trickle down atm.
52
48
  // It will be worked as part of https://product-fabric.atlassian.net/jira/servicedesk/projects/DTR/queues/issue/DTR-154
53
49
 
@@ -61,7 +57,6 @@ var Frame = function Frame(props) {
61
57
  tabIndex: isInteractive ? 0 : undefined,
62
58
  role: isInteractive ? 'button' : undefined,
63
59
  onClick: handleClick,
64
- onMouseDown: handleMouseDown,
65
60
  onKeyPress: handleKeyPress,
66
61
  "data-testid": testId,
67
62
  className: className
@@ -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, SnippetBlock, TitleBlock } from './view/FlexibleCard/components/blocks';
16
+ export { MetadataBlock, PreviewBlock, SnippetBlock, TitleBlock, FooterBlock } from './view/FlexibleCard/components/blocks';
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "17.5.1",
3
+ "version": "17.6.0",
4
4
  "sideEffects": false
5
5
  }
@@ -4,6 +4,7 @@ import { css, jsx } from '@emotion/core';
4
4
  import Button from '@atlaskit/button/custom-theme-button';
5
5
  import { SmartLinkSize } from '../../../../../constants';
6
6
  import Tooltip from '@atlaskit/tooltip';
7
+ import { DropdownItem } from '@atlaskit/dropdown-menu';
7
8
  import { getIconSizeStyles } from '../../utils';
8
9
  import { tokens } from '../../../../../utils/token';
9
10
  import { handleOnClick } from '../../../../../utils';
@@ -53,7 +54,7 @@ const ActionIcon = ({
53
54
  "data-testid": `${testId}-icon`
54
55
  }, icon);
55
56
 
56
- const sizeToSpacing = {
57
+ export const sizeToSpacing = {
57
58
  [SmartLinkSize.Small]: 'none',
58
59
  [SmartLinkSize.Medium]: 'compact',
59
60
  [SmartLinkSize.Large]: 'compact',
@@ -68,7 +69,8 @@ const Action = ({
68
69
  testId = 'smart-action',
69
70
  icon,
70
71
  iconPosition = 'before',
71
- tooltipMessage
72
+ tooltipMessage,
73
+ asDropDownItem
72
74
  }) => {
73
75
  if (!onClick) {
74
76
  return null;
@@ -85,18 +87,28 @@ const Action = ({
85
87
  icon: icon
86
88
  }) : undefined;
87
89
  const iconOnly = !content;
88
- return jsx(Tooltip, {
89
- content: tooltipMessage
90
- }, jsx("div", {
91
- css: getButtonStyle(size, iconOnly)
92
- }, jsx(Button, {
93
- spacing: sizeToSpacing[size],
94
- appearance: appearance,
95
- testId: testId,
96
- onClick: handleOnClick(onClick),
97
- iconBefore: iconBefore,
98
- iconAfter: iconAfter
99
- }, content)));
90
+
91
+ if (asDropDownItem) {
92
+ return jsx(DropdownItem, {
93
+ elemBefore: iconBefore,
94
+ elemAfter: iconAfter,
95
+ testId: testId,
96
+ onClick: handleOnClick(onClick)
97
+ }, content);
98
+ } else {
99
+ return jsx(Tooltip, {
100
+ content: tooltipMessage
101
+ }, jsx("div", {
102
+ css: getButtonStyle(size, iconOnly)
103
+ }, jsx(Button, {
104
+ spacing: sizeToSpacing[size],
105
+ appearance: appearance,
106
+ testId: testId,
107
+ onClick: handleOnClick(onClick),
108
+ iconBefore: iconBefore,
109
+ iconAfter: iconAfter
110
+ }, content)));
111
+ }
100
112
  };
101
113
 
102
114
  export default Action;
@@ -1,8 +1,14 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+
1
3
  /** @jsx jsx */
2
4
  import { css, jsx } from '@emotion/core';
3
5
  import ButtonGroup from '@atlaskit/button/button-group';
4
6
  import { renderActionItems } from '../utils';
7
+ import DropdownMenu from '@atlaskit/dropdown-menu';
5
8
  import { SmartLinkSize } from '../../../../../constants';
9
+ import Button from '@atlaskit/button/standard-button';
10
+ import MoreIcon from '@atlaskit/icon/glyph/more';
11
+ import { sizeToSpacing } from '../../actions/action';
6
12
  const styles = css`
7
13
  display: inline-flex;
8
14
  line-height: 1rem;
@@ -13,11 +19,24 @@ const ActionGroup = ({
13
19
  size = SmartLinkSize.Medium,
14
20
  appearance
15
21
  }) => {
16
- // Currently we only have delete action available, this prevents others from adding more delete actions
17
- const actionsToRender = items.slice(0, 1);
22
+ const isMoreThenTwoItems = items.length > 2;
23
+ const firstActions = isMoreThenTwoItems ? items.slice(0, 1) : items;
24
+ const restActions = isMoreThenTwoItems ? items.slice(1) : [];
18
25
  return jsx("div", {
19
26
  css: styles
20
- }, jsx(ButtonGroup, null, renderActionItems(actionsToRender, size, appearance)));
27
+ }, jsx(ButtonGroup, null, renderActionItems(firstActions, size, appearance), restActions.length > 0 ? jsx(DropdownMenu, {
28
+ trigger: ({
29
+ triggerRef,
30
+ ...props
31
+ }) => jsx(Button, _extends({}, props, {
32
+ spacing: sizeToSpacing[size],
33
+ testId: "action-group-more-button",
34
+ iconBefore: jsx(MoreIcon, {
35
+ label: "more"
36
+ }),
37
+ ref: triggerRef
38
+ }))
39
+ }, renderActionItems(restActions, size, appearance, true)) : null));
21
40
  };
22
41
 
23
42
  export default ActionGroup;
@@ -1,4 +1,5 @@
1
1
  export { default as FooterBlock } from './footer-block';
2
2
  export { default as MetadataBlock } from './metadata-block';
3
+ export { default as PreviewBlock } from './preview-block';
3
4
  export { default as SnippetBlock } from './snippet-block';
4
5
  export { default as TitleBlock } from './title-block';
@@ -0,0 +1,21 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React from 'react';
3
+ import { SmartLinkStatus } from '../../../../../constants';
4
+ import Block from '../block';
5
+ import { Preview } from '../../elements';
6
+
7
+ const PreviewBlock = ({
8
+ status = SmartLinkStatus.Fallback,
9
+ testId = 'smart-block-preview',
10
+ ...blockProps
11
+ }) => {
12
+ if (status !== SmartLinkStatus.Resolved) {
13
+ return null;
14
+ }
15
+
16
+ return /*#__PURE__*/React.createElement(Block, _extends({}, blockProps, {
17
+ testId: `${testId}-resolved-view`
18
+ }), /*#__PURE__*/React.createElement(Preview, null));
19
+ };
20
+
21
+ export default PreviewBlock;
@@ -130,7 +130,7 @@ export const renderElementItems = (items = [], display = 'inline') => {
130
130
  return elements;
131
131
  }
132
132
  };
133
- export const renderActionItems = (items = [], size = SmartLinkSize.Medium, appearance) => {
133
+ export const renderActionItems = (items = [], size = SmartLinkSize.Medium, appearance, asDropDownItems) => {
134
134
  const actions = items.reduce((acc, curr, idx) => {
135
135
  const {
136
136
  name,
@@ -143,7 +143,7 @@ export const renderActionItems = (items = [], size = SmartLinkSize.Medium, appea
143
143
  const actionProps = { ...props
144
144
  };
145
145
 
146
- if (hideContent) {
146
+ if (hideContent && !asDropDownItems) {
147
147
  actionProps.content = '';
148
148
  }
149
149
 
@@ -153,6 +153,7 @@ export const renderActionItems = (items = [], size = SmartLinkSize.Medium, appea
153
153
 
154
154
  if (Action) {
155
155
  return [...acc, /*#__PURE__*/React.createElement(Action, _extends({
156
+ asDropDownItem: asDropDownItems,
156
157
  size: size,
157
158
  key: idx,
158
159
  appearance: appearance,
@@ -29,11 +29,7 @@ export const Frame = props => {
29
29
  event.stopPropagation();
30
30
  onClick(event);
31
31
  }
32
- }, [onClick]); // prevent default on mousedown to avoid inline card losing focus
33
-
34
- const handleMouseDown = useCallback(e => {
35
- e.preventDefault();
36
- }, []);
32
+ }, [onClick]);
37
33
  const isInteractive = Boolean(onClick); // TODO Theming doesn't work right now in editor. Required React context does not trickle down atm.
38
34
  // It will be worked as part of https://product-fabric.atlassian.net/jira/servicedesk/projects/DTR/queues/issue/DTR-154
39
35
 
@@ -47,7 +43,6 @@ export const Frame = props => {
47
43
  tabIndex: isInteractive ? 0 : undefined,
48
44
  role: isInteractive ? 'button' : undefined,
49
45
  onClick: handleClick,
50
- onMouseDown: handleMouseDown,
51
46
  onKeyPress: handleKeyPress,
52
47
  "data-testid": testId,
53
48
  className: className
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, SnippetBlock, TitleBlock } from './view/FlexibleCard/components/blocks';
16
+ export { MetadataBlock, PreviewBlock, SnippetBlock, TitleBlock, FooterBlock } from './view/FlexibleCard/components/blocks';
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "17.5.1",
3
+ "version": "17.6.0",
4
4
  "sideEffects": false
5
5
  }
@@ -9,6 +9,7 @@ import { css, jsx } from '@emotion/core';
9
9
  import Button from '@atlaskit/button/custom-theme-button';
10
10
  import { SmartLinkSize } from '../../../../../constants';
11
11
  import Tooltip from '@atlaskit/tooltip';
12
+ import { DropdownItem } from '@atlaskit/dropdown-menu';
12
13
  import { getIconSizeStyles } from '../../utils';
13
14
  import { tokens } from '../../../../../utils/token';
14
15
  import { handleOnClick } from '../../../../../utils';
@@ -44,7 +45,7 @@ var ActionIcon = function ActionIcon(_ref) {
44
45
  }, icon);
45
46
  };
46
47
 
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
+ export 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
49
 
49
50
  var Action = function Action(_ref2) {
50
51
  var _ref2$appearance = _ref2.appearance,
@@ -58,7 +59,8 @@ var Action = function Action(_ref2) {
58
59
  icon = _ref2.icon,
59
60
  _ref2$iconPosition = _ref2.iconPosition,
60
61
  iconPosition = _ref2$iconPosition === void 0 ? 'before' : _ref2$iconPosition,
61
- tooltipMessage = _ref2.tooltipMessage;
62
+ tooltipMessage = _ref2.tooltipMessage,
63
+ asDropDownItem = _ref2.asDropDownItem;
62
64
 
63
65
  if (!onClick) {
64
66
  return null;
@@ -75,18 +77,28 @@ var Action = function Action(_ref2) {
75
77
  icon: icon
76
78
  }) : undefined;
77
79
  var iconOnly = !content;
78
- return jsx(Tooltip, {
79
- content: tooltipMessage
80
- }, jsx("div", {
81
- css: getButtonStyle(size, iconOnly)
82
- }, jsx(Button, {
83
- spacing: sizeToSpacing[size],
84
- appearance: appearance,
85
- testId: testId,
86
- onClick: handleOnClick(onClick),
87
- iconBefore: iconBefore,
88
- iconAfter: iconAfter
89
- }, content)));
80
+
81
+ if (asDropDownItem) {
82
+ return jsx(DropdownItem, {
83
+ elemBefore: iconBefore,
84
+ elemAfter: iconAfter,
85
+ testId: testId,
86
+ onClick: handleOnClick(onClick)
87
+ }, content);
88
+ } else {
89
+ return jsx(Tooltip, {
90
+ content: tooltipMessage
91
+ }, jsx("div", {
92
+ css: getButtonStyle(size, iconOnly)
93
+ }, jsx(Button, {
94
+ spacing: sizeToSpacing[size],
95
+ appearance: appearance,
96
+ testId: testId,
97
+ onClick: handleOnClick(onClick),
98
+ iconBefore: iconBefore,
99
+ iconAfter: iconAfter
100
+ }, content)));
101
+ }
90
102
  };
91
103
 
92
104
  export default Action;
@@ -1,4 +1,7 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
1
3
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
4
+ var _excluded = ["triggerRef"];
2
5
 
3
6
  var _templateObject;
4
7
 
@@ -6,7 +9,11 @@ var _templateObject;
6
9
  import { css, jsx } from '@emotion/core';
7
10
  import ButtonGroup from '@atlaskit/button/button-group';
8
11
  import { renderActionItems } from '../utils';
12
+ import DropdownMenu from '@atlaskit/dropdown-menu';
9
13
  import { SmartLinkSize } from '../../../../../constants';
14
+ import Button from '@atlaskit/button/standard-button';
15
+ import MoreIcon from '@atlaskit/icon/glyph/more';
16
+ import { sizeToSpacing } from '../../actions/action';
10
17
  var styles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline-flex;\n line-height: 1rem;\n"])));
11
18
 
12
19
  var ActionGroup = function ActionGroup(_ref) {
@@ -15,11 +22,26 @@ var ActionGroup = function ActionGroup(_ref) {
15
22
  _ref$size = _ref.size,
16
23
  size = _ref$size === void 0 ? SmartLinkSize.Medium : _ref$size,
17
24
  appearance = _ref.appearance;
18
- // Currently we only have delete action available, this prevents others from adding more delete actions
19
- var actionsToRender = items.slice(0, 1);
25
+ var isMoreThenTwoItems = items.length > 2;
26
+ var firstActions = isMoreThenTwoItems ? items.slice(0, 1) : items;
27
+ var restActions = isMoreThenTwoItems ? items.slice(1) : [];
20
28
  return jsx("div", {
21
29
  css: styles
22
- }, jsx(ButtonGroup, null, renderActionItems(actionsToRender, size, appearance)));
30
+ }, jsx(ButtonGroup, null, renderActionItems(firstActions, size, appearance), restActions.length > 0 ? jsx(DropdownMenu, {
31
+ trigger: function trigger(_ref2) {
32
+ var triggerRef = _ref2.triggerRef,
33
+ props = _objectWithoutProperties(_ref2, _excluded);
34
+
35
+ return jsx(Button, _extends({}, props, {
36
+ spacing: sizeToSpacing[size],
37
+ testId: "action-group-more-button",
38
+ iconBefore: jsx(MoreIcon, {
39
+ label: "more"
40
+ }),
41
+ ref: triggerRef
42
+ }));
43
+ }
44
+ }, renderActionItems(restActions, size, appearance, true)) : null));
23
45
  };
24
46
 
25
47
  export default ActionGroup;
@@ -1,4 +1,5 @@
1
1
  export { default as FooterBlock } from './footer-block';
2
2
  export { default as MetadataBlock } from './metadata-block';
3
+ export { default as PreviewBlock } from './preview-block';
3
4
  export { default as SnippetBlock } from './snippet-block';
4
5
  export { default as TitleBlock } from './title-block';
@@ -0,0 +1,25 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["status", "testId"];
4
+ import React from 'react';
5
+ import { SmartLinkStatus } from '../../../../../constants';
6
+ import Block from '../block';
7
+ import { Preview } from '../../elements';
8
+
9
+ var PreviewBlock = function PreviewBlock(_ref) {
10
+ var _ref$status = _ref.status,
11
+ status = _ref$status === void 0 ? SmartLinkStatus.Fallback : _ref$status,
12
+ _ref$testId = _ref.testId,
13
+ testId = _ref$testId === void 0 ? 'smart-block-preview' : _ref$testId,
14
+ blockProps = _objectWithoutProperties(_ref, _excluded);
15
+
16
+ if (status !== SmartLinkStatus.Resolved) {
17
+ return null;
18
+ }
19
+
20
+ return /*#__PURE__*/React.createElement(Block, _extends({}, blockProps, {
21
+ testId: "".concat(testId, "-resolved-view")
22
+ }), /*#__PURE__*/React.createElement(Preview, null));
23
+ };
24
+
25
+ export default PreviewBlock;
@@ -114,6 +114,7 @@ export var renderActionItems = function renderActionItems() {
114
114
  var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
115
115
  var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : SmartLinkSize.Medium;
116
116
  var appearance = arguments.length > 2 ? arguments[2] : undefined;
117
+ var asDropDownItems = arguments.length > 3 ? arguments[3] : undefined;
117
118
  var actions = items.reduce(function (acc, curr, idx) {
118
119
  var name = curr.name,
119
120
  hideContent = curr.hideContent,
@@ -125,7 +126,7 @@ export var renderActionItems = function renderActionItems() {
125
126
 
126
127
  var actionProps = _objectSpread({}, props);
127
128
 
128
- if (hideContent) {
129
+ if (hideContent && !asDropDownItems) {
129
130
  actionProps.content = '';
130
131
  }
131
132
 
@@ -135,6 +136,7 @@ export var renderActionItems = function renderActionItems() {
135
136
 
136
137
  if (Action) {
137
138
  return [].concat(_toConsumableArray(acc), [/*#__PURE__*/React.createElement(Action, _extends({
139
+ asDropDownItem: asDropDownItems,
138
140
  size: size,
139
141
  key: idx,
140
142
  appearance: appearance,
@@ -27,11 +27,7 @@ export var Frame = function Frame(props) {
27
27
  event.stopPropagation();
28
28
  onClick(event);
29
29
  }
30
- }, [onClick]); // prevent default on mousedown to avoid inline card losing focus
31
-
32
- var handleMouseDown = useCallback(function (e) {
33
- e.preventDefault();
34
- }, []);
30
+ }, [onClick]);
35
31
  var isInteractive = Boolean(onClick); // TODO Theming doesn't work right now in editor. Required React context does not trickle down atm.
36
32
  // It will be worked as part of https://product-fabric.atlassian.net/jira/servicedesk/projects/DTR/queues/issue/DTR-154
37
33
 
@@ -45,7 +41,6 @@ export var Frame = function Frame(props) {
45
41
  tabIndex: isInteractive ? 0 : undefined,
46
42
  role: isInteractive ? 'button' : undefined,
47
43
  onClick: handleClick,
48
- onMouseDown: handleMouseDown,
49
44
  onKeyPress: handleKeyPress,
50
45
  "data-testid": testId,
51
46
  className: className
@@ -1,5 +1,4 @@
1
1
  /// <reference types="cypress" />
2
- /// <reference types="jquery" />
3
2
  import { InProductTestPageObject, CypressType } from '@atlaskit/in-product-testing';
4
3
  import { CardType } from '../../state/store/types';
5
4
  import { CardAppearance } from '../../view/Card';
@@ -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, SnippetBlock, TitleBlock, } from './view/FlexibleCard/components/blocks';
20
+ export { MetadataBlock, PreviewBlock, SnippetBlock, TitleBlock, FooterBlock, } from './view/FlexibleCard/components/blocks';
21
21
  export type { ActionItem, ElementItem, } from './view/FlexibleCard/components/blocks/types';
@@ -8,4 +8,4 @@ export declare const isSpecialClick: (event: React.MouseEvent) => boolean;
8
8
  export declare const getIconForFileType: (fileMimeType: string) => React.ReactNode | undefined;
9
9
  export declare const getLabelForFileType: (fileMimeType: string) => React.ReactNode | undefined;
10
10
  export declare const getIframeSandboxAttribute: (isTrusted: boolean) => "allow-downloads allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts" | undefined;
11
- export declare const handleOnClick: (handler: Function) => (e: React.MouseEvent<HTMLElement>) => void;
11
+ export declare const handleOnClick: (handler: Function) => (e: React.BaseSyntheticEvent) => void;
@@ -1,5 +1,8 @@
1
1
  /** @jsx jsx */
2
2
  import React from 'react';
3
+ import { Spacing } from '@atlaskit/button';
4
+ import { SmartLinkSize } from '../../../../../constants';
3
5
  import { ActionProps } from './types';
6
+ export declare const sizeToSpacing: Record<SmartLinkSize, Spacing>;
4
7
  declare const Action: React.FC<ActionProps>;
5
8
  export default Action;
@@ -10,6 +10,7 @@ export declare type ActionProps = {
10
10
  icon?: ReactChild;
11
11
  iconPosition?: 'before' | 'after';
12
12
  tooltipMessage?: React.ReactNode;
13
+ asDropDownItem?: boolean;
13
14
  };
14
15
  export declare type ActionIconProps = {
15
16
  size?: SmartLinkSize;
@@ -1,4 +1,5 @@
1
1
  export { default as FooterBlock } from './footer-block';
2
2
  export { default as MetadataBlock } from './metadata-block';
3
+ export { default as PreviewBlock } from './preview-block';
3
4
  export { default as SnippetBlock } from './snippet-block';
4
5
  export { default as TitleBlock } from './title-block';
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { PreviewBlockProps } from './types';
3
+ declare const PreviewBlock: React.FC<PreviewBlockProps>;
4
+ export default PreviewBlock;
@@ -0,0 +1,2 @@
1
+ import { BlockProps } from '../types';
2
+ export declare type PreviewBlockProps = BlockProps;
@@ -8,4 +8,4 @@ export declare const getGapSize: (size: SmartLinkSize) => number;
8
8
  export declare const getBaseStyles: (direction: SmartLinkDirection, size: SmartLinkSize) => SerializedStyles;
9
9
  export declare const renderChildren: (children: React.ReactNode, size: SmartLinkSize) => React.ReactNode;
10
10
  export declare const renderElementItems: (items?: ElementItem[], display?: ElementDisplaySchemaType) => React.ReactNode | undefined;
11
- export declare const renderActionItems: (items?: ActionItem[], size?: SmartLinkSize, appearance?: "link" | "default" | "danger" | "primary" | "subtle" | "subtle-link" | "warning" | undefined) => React.ReactNode | undefined;
11
+ export declare const renderActionItems: (items?: ActionItem[], size?: SmartLinkSize, appearance?: "link" | "default" | "danger" | "primary" | "subtle" | "subtle-link" | "warning" | undefined, asDropDownItems?: boolean | undefined) => React.ReactNode | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "17.5.1",
3
+ "version": "17.6.0",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -27,6 +27,7 @@
27
27
  "@atlaskit/avatar": "^20.5.0",
28
28
  "@atlaskit/avatar-group": "^8.5.5",
29
29
  "@atlaskit/button": "^16.1.4",
30
+ "@atlaskit/dropdown-menu": "^11.1.0",
30
31
  "@atlaskit/droplist": "^11.0.0",
31
32
  "@atlaskit/icon": "^21.10.0",
32
33
  "@atlaskit/icon-file-type": "^6.3.0",
@@ -80,6 +81,7 @@
80
81
  "@atlaskit/media-test-helpers": "^29.1.0",
81
82
  "@atlaskit/page": "^12.1.0",
82
83
  "@atlaskit/radio": "^5.3.0",
84
+ "@atlaskit/range": "^6.0.0",
83
85
  "@atlaskit/section-message": "^6.1.5",
84
86
  "@atlaskit/select": "^15.2.0",
85
87
  "@atlaskit/table-tree": "^9.1.0",