@atlaskit/smart-card 17.5.3 → 17.7.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 (38) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/cjs/constants.js +1 -0
  3. package/dist/cjs/index.js +6 -0
  4. package/dist/cjs/version.json +1 -1
  5. package/dist/cjs/view/BlockCard/components/ActionList.js +33 -30
  6. package/dist/cjs/view/FlexibleCard/components/actions/action/index.js +28 -14
  7. package/dist/cjs/view/FlexibleCard/components/actions/index.js +4 -2
  8. package/dist/cjs/view/FlexibleCard/components/actions/utils.js +7 -2
  9. package/dist/cjs/view/FlexibleCard/components/blocks/action-group/index.js +31 -3
  10. package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +3 -1
  11. package/dist/es2019/constants.js +1 -0
  12. package/dist/es2019/index.js +1 -1
  13. package/dist/es2019/version.json +1 -1
  14. package/dist/es2019/view/BlockCard/components/ActionList.js +22 -17
  15. package/dist/es2019/view/FlexibleCard/components/actions/action/index.js +26 -14
  16. package/dist/es2019/view/FlexibleCard/components/actions/index.js +2 -1
  17. package/dist/es2019/view/FlexibleCard/components/actions/utils.js +4 -0
  18. package/dist/es2019/view/FlexibleCard/components/blocks/action-group/index.js +22 -3
  19. package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +3 -2
  20. package/dist/esm/constants.js +1 -0
  21. package/dist/esm/index.js +1 -1
  22. package/dist/esm/version.json +1 -1
  23. package/dist/esm/view/BlockCard/components/ActionList.js +25 -26
  24. package/dist/esm/view/FlexibleCard/components/actions/action/index.js +26 -14
  25. package/dist/esm/view/FlexibleCard/components/actions/index.js +2 -1
  26. package/dist/esm/view/FlexibleCard/components/actions/utils.js +7 -3
  27. package/dist/esm/view/FlexibleCard/components/blocks/action-group/index.js +25 -3
  28. package/dist/esm/view/FlexibleCard/components/blocks/utils.js +3 -1
  29. package/dist/types/__tests_external__/page-objects/BaseCard.d.ts +0 -1
  30. package/dist/types/constants.d.ts +2 -1
  31. package/dist/types/index.d.ts +1 -1
  32. package/dist/types/utils/index.d.ts +1 -1
  33. package/dist/types/view/FlexibleCard/components/actions/action/index.d.ts +3 -0
  34. package/dist/types/view/FlexibleCard/components/actions/action/types.d.ts +1 -0
  35. package/dist/types/view/FlexibleCard/components/actions/index.d.ts +1 -0
  36. package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +16 -2
  37. package/dist/types/view/FlexibleCard/components/blocks/utils.d.ts +1 -1
  38. package/package.json +8 -8
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 17.7.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`123201c5105`](https://bitbucket.org/atlassian/atlassian-frontend/commits/123201c5105) - Add ability to add custom action item
8
+
9
+ ## 17.7.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`924aa854655`](https://bitbucket.org/atlassian/atlassian-frontend/commits/924aa854655) - Replaced deprecated dependency with @atlaskit/droplist and @atlaskit/item with @atlaskit/dropdown-menu in block card actions list
14
+ - [`fb15a8a421c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/fb15a8a421c) - move smart-card views and helpers from media-ui into smart-card
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies
19
+
20
+ ## 17.6.0
21
+
22
+ ### Minor Changes
23
+
24
+ - [`0cab291e19e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/0cab291e19e) - Add "more" and dopdown for actions when there is more then 2
25
+
3
26
  ## 17.5.3
4
27
 
5
28
  ### Patch Changes
@@ -156,6 +156,7 @@ exports.ActionName = ActionName;
156
156
 
157
157
  (function (ActionName) {
158
158
  ActionName["DeleteAction"] = "DeleteAction";
159
+ ActionName["CustomAction"] = "CustomAction";
159
160
  })(ActionName || (exports.ActionName = ActionName = {}));
160
161
 
161
162
  var IconType;
package/dist/cjs/index.js CHANGED
@@ -53,6 +53,12 @@ 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() {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "17.5.3",
3
+ "version": "17.7.1",
4
4
  "sideEffects": false
5
5
  }
@@ -2,40 +2,39 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
5
7
  Object.defineProperty(exports, "__esModule", {
6
8
  value: true
7
9
  });
8
10
  exports.ActionList = void 0;
9
11
 
10
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
12
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
13
 
12
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
14
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
15
 
14
16
  var _core = require("@emotion/core");
15
17
 
16
- var _react = require("react");
17
-
18
- var _item = _interopRequireDefault(require("@atlaskit/item"));
18
+ var _buttonGroup = _interopRequireDefault(require("@atlaskit/button/button-group"));
19
19
 
20
- var _droplist = _interopRequireDefault(require("@atlaskit/droplist"));
20
+ var _standardButton = _interopRequireDefault(require("@atlaskit/button/standard-button"));
21
21
 
22
- var _buttonGroup = _interopRequireDefault(require("@atlaskit/button/button-group"));
22
+ var _dropdownMenu = _interopRequireWildcard(require("@atlaskit/dropdown-menu"));
23
23
 
24
- var _customThemeButton = _interopRequireDefault(require("@atlaskit/button/custom-theme-button"));
24
+ var _more = _interopRequireDefault(require("@atlaskit/icon/glyph/more"));
25
25
 
26
26
  var _Action = require("./Action");
27
27
 
28
28
  var _utils = require("../utils");
29
29
 
30
- /** @jsx jsx */
31
- var ActionList = function ActionList(_ref) {
32
- var items = _ref.items;
30
+ var _excluded = ["triggerRef"];
31
+
32
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
33
33
 
34
- var _useState = (0, _react.useState)(false),
35
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
36
- isOpen = _useState2[0],
37
- setOpen = _useState2[1];
34
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
38
35
 
36
+ var ActionList = function ActionList(_ref) {
37
+ var items = _ref.items;
39
38
  var actionsToShow = items.slice(0, 2);
40
39
  var actionsToList = items.slice(2, items.length);
41
40
  return (0, _core.jsx)("div", {
@@ -51,25 +50,29 @@ var ActionList = function ActionList(_ref) {
51
50
  css: {
52
51
  marginLeft: (0, _utils.gs)(0.5)
53
52
  }
54
- }, (0, _core.jsx)(_droplist.default, {
55
- appearance: "default",
56
- position: "right top",
57
- isTriggerNotTabbable: true,
58
- onOpenChange: function onOpenChange() {
59
- return setOpen(true);
60
- },
61
- onClick: function onClick() {
62
- return setOpen(!isOpen);
53
+ }, (0, _core.jsx)(_dropdownMenu.default, {
54
+ trigger: function trigger(_ref2) {
55
+ var triggerRef = _ref2.triggerRef,
56
+ props = (0, _objectWithoutProperties2.default)(_ref2, _excluded);
57
+ return (0, _core.jsx)(_standardButton.default, (0, _extends2.default)({}, props, {
58
+ iconBefore: (0, _core.jsx)(_more.default, {
59
+ label: "more"
60
+ }),
61
+ ref: triggerRef,
62
+ css: {
63
+ height: 'auto'
64
+ },
65
+ testId: "dropdown-trigger"
66
+ }));
63
67
  },
64
- isOpen: isOpen,
65
- trigger: (0, _core.jsx)(_customThemeButton.default, {
66
- spacing: "compact"
67
- }, "...")
68
+ placement: "right-start"
69
+ }, (0, _core.jsx)(_dropdownMenu.DropdownItemGroup, {
70
+ testId: "dropdown-menu"
68
71
  }, actionsToList.map(function (actionToList) {
69
- return (0, _core.jsx)(_item.default, {
72
+ return (0, _core.jsx)(_dropdownMenu.DropdownItem, {
70
73
  key: actionToList.id
71
74
  }, actionToList.text);
72
- }))) : null);
75
+ })))) : null);
73
76
  };
74
77
 
75
78
  exports.ActionList = ActionList;
@@ -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;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.DeleteAction = void 0;
6
+ exports.DeleteAction = exports.CustomAction = void 0;
7
7
 
8
8
  var _constants = require("../../../../constants");
9
9
 
@@ -15,4 +15,6 @@ var _utils = require("./utils");
15
15
  // UIActions infer that you do not need to get any data from the context.
16
16
  // DataActions infer that the action depends on the data from the context.
17
17
  var DeleteAction = (0, _utils.createUIAction)(_constants.ActionName.DeleteAction);
18
- exports.DeleteAction = DeleteAction;
18
+ exports.DeleteAction = DeleteAction;
19
+ var CustomAction = (0, _utils.createUIAction)(_constants.ActionName.CustomAction);
20
+ exports.CustomAction = CustomAction;
@@ -27,6 +27,8 @@ var _messages = require("../../../../messages");
27
27
 
28
28
  var _cross = _interopRequireDefault(require("@atlaskit/icon/glyph/cross"));
29
29
 
30
+ var _actionMappings;
31
+
30
32
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
31
33
 
32
34
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -35,7 +37,10 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
35
37
 
36
38
  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) { (0, _defineProperty2.default)(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; }
37
39
 
38
- var actionMappings = (0, _defineProperty2.default)({}, _constants.ActionName.DeleteAction, {
40
+ var actionMappings = (_actionMappings = {}, (0, _defineProperty2.default)(_actionMappings, _constants.ActionName.CustomAction, {
41
+ component: _action.default,
42
+ props: {}
43
+ }), (0, _defineProperty2.default)(_actionMappings, _constants.ActionName.DeleteAction, {
39
44
  component: _action.default,
40
45
  props: {
41
46
  testId: 'smart-action-delete-action',
@@ -45,7 +50,7 @@ var actionMappings = (0, _defineProperty2.default)({}, _constants.ActionName.Del
45
50
  }),
46
51
  toolTipMessage: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, _messages.messages.delete)
47
52
  }
48
- });
53
+ }), _actionMappings);
49
54
 
50
55
  var getContextKey = function getContextKey(name) {
51
56
  // Attempt to predict context prop name in advance to reduce the amount of
@@ -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;
@@ -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,
@@ -131,6 +131,7 @@ export let ActionName;
131
131
 
132
132
  (function (ActionName) {
133
133
  ActionName["DeleteAction"] = "DeleteAction";
134
+ ActionName["CustomAction"] = "CustomAction";
134
135
  })(ActionName || (ActionName = {}));
135
136
 
136
137
  export let IconType;
@@ -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, PreviewBlock, 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.3",
3
+ "version": "17.7.1",
4
4
  "sideEffects": false
5
5
  }
@@ -2,17 +2,15 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
 
3
3
  /** @jsx jsx */
4
4
  import { jsx } from '@emotion/core';
5
- import { useState } from 'react';
6
- import Item from '@atlaskit/item';
7
- import DropList from '@atlaskit/droplist';
8
5
  import ButtonGroup from '@atlaskit/button/button-group';
9
- import Button from '@atlaskit/button/custom-theme-button';
6
+ import Button from '@atlaskit/button/standard-button';
7
+ import DropdownMenu, { DropdownItem, DropdownItemGroup } from '@atlaskit/dropdown-menu';
8
+ import MoreIcon from '@atlaskit/icon/glyph/more';
10
9
  import { Action } from './Action';
11
10
  import { gs, mq } from '../utils';
12
11
  export const ActionList = ({
13
12
  items
14
13
  }) => {
15
- const [isOpen, setOpen] = useState(false);
16
14
  const actionsToShow = items.slice(0, 2);
17
15
  const actionsToList = items.slice(2, items.length);
18
16
  return jsx("div", {
@@ -26,17 +24,24 @@ export const ActionList = ({
26
24
  css: {
27
25
  marginLeft: gs(0.5)
28
26
  }
29
- }, jsx(DropList, {
30
- appearance: "default",
31
- position: "right top",
32
- isTriggerNotTabbable: true,
33
- onOpenChange: () => setOpen(true),
34
- onClick: () => setOpen(!isOpen),
35
- isOpen: isOpen,
36
- trigger: jsx(Button, {
37
- spacing: "compact"
38
- }, "...")
39
- }, actionsToList.map(actionToList => jsx(Item, {
27
+ }, jsx(DropdownMenu, {
28
+ trigger: ({
29
+ triggerRef,
30
+ ...props
31
+ }) => jsx(Button, _extends({}, props, {
32
+ iconBefore: jsx(MoreIcon, {
33
+ label: "more"
34
+ }),
35
+ ref: triggerRef,
36
+ css: {
37
+ height: 'auto'
38
+ },
39
+ testId: "dropdown-trigger"
40
+ })),
41
+ placement: "right-start"
42
+ }, jsx(DropdownItemGroup, {
43
+ testId: "dropdown-menu"
44
+ }, actionsToList.map(actionToList => jsx(DropdownItem, {
40
45
  key: actionToList.id
41
- }, actionToList.text)))) : null);
46
+ }, actionToList.text))))) : null);
42
47
  };
@@ -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;
@@ -5,4 +5,5 @@ import { createUIAction } from './utils'; // Attention: Keep the export name and
5
5
  // UIActions infer that you do not need to get any data from the context.
6
6
  // DataActions infer that the action depends on the data from the context.
7
7
 
8
- export const DeleteAction = createUIAction(ActionName.DeleteAction);
8
+ export const DeleteAction = createUIAction(ActionName.DeleteAction);
9
+ export const CustomAction = createUIAction(ActionName.CustomAction);
@@ -7,6 +7,10 @@ import { FormattedMessage } from 'react-intl-next';
7
7
  import { messages } from '../../../../messages';
8
8
  import CrossIcon from '@atlaskit/icon/glyph/cross';
9
9
  const actionMappings = {
10
+ [ActionName.CustomAction]: {
11
+ component: Action,
12
+ props: {}
13
+ },
10
14
  [ActionName.DeleteAction]: {
11
15
  component: Action,
12
16
  props: {
@@ -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;
@@ -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,
@@ -131,6 +131,7 @@ export var ActionName;
131
131
 
132
132
  (function (ActionName) {
133
133
  ActionName["DeleteAction"] = "DeleteAction";
134
+ ActionName["CustomAction"] = "CustomAction";
134
135
  })(ActionName || (ActionName = {}));
135
136
 
136
137
  export var IconType;
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, PreviewBlock, 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.3",
3
+ "version": "17.7.1",
4
4
  "sideEffects": false
5
5
  }
@@ -1,23 +1,17 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
1
2
  import _extends from "@babel/runtime/helpers/extends";
2
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ var _excluded = ["triggerRef"];
3
4
 
4
5
  /** @jsx jsx */
5
6
  import { jsx } from '@emotion/core';
6
- import { useState } from 'react';
7
- import Item from '@atlaskit/item';
8
- import DropList from '@atlaskit/droplist';
9
7
  import ButtonGroup from '@atlaskit/button/button-group';
10
- import Button from '@atlaskit/button/custom-theme-button';
8
+ import Button from '@atlaskit/button/standard-button';
9
+ import DropdownMenu, { DropdownItem, DropdownItemGroup } from '@atlaskit/dropdown-menu';
10
+ import MoreIcon from '@atlaskit/icon/glyph/more';
11
11
  import { Action } from './Action';
12
12
  import { gs, mq } from '../utils';
13
13
  export var ActionList = function ActionList(_ref) {
14
14
  var items = _ref.items;
15
-
16
- var _useState = useState(false),
17
- _useState2 = _slicedToArray(_useState, 2),
18
- isOpen = _useState2[0],
19
- setOpen = _useState2[1];
20
-
21
15
  var actionsToShow = items.slice(0, 2);
22
16
  var actionsToList = items.slice(2, items.length);
23
17
  return jsx("div", {
@@ -33,23 +27,28 @@ export var ActionList = function ActionList(_ref) {
33
27
  css: {
34
28
  marginLeft: gs(0.5)
35
29
  }
36
- }, jsx(DropList, {
37
- appearance: "default",
38
- position: "right top",
39
- isTriggerNotTabbable: true,
40
- onOpenChange: function onOpenChange() {
41
- return setOpen(true);
42
- },
43
- onClick: function onClick() {
44
- return setOpen(!isOpen);
30
+ }, 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
+ iconBefore: jsx(MoreIcon, {
37
+ label: "more"
38
+ }),
39
+ ref: triggerRef,
40
+ css: {
41
+ height: 'auto'
42
+ },
43
+ testId: "dropdown-trigger"
44
+ }));
45
45
  },
46
- isOpen: isOpen,
47
- trigger: jsx(Button, {
48
- spacing: "compact"
49
- }, "...")
46
+ placement: "right-start"
47
+ }, jsx(DropdownItemGroup, {
48
+ testId: "dropdown-menu"
50
49
  }, actionsToList.map(function (actionToList) {
51
- return jsx(Item, {
50
+ return jsx(DropdownItem, {
52
51
  key: actionToList.id
53
52
  }, actionToList.text);
54
- }))) : null);
53
+ })))) : null);
55
54
  };
@@ -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;
@@ -5,4 +5,5 @@ import { createUIAction } from './utils'; // Attention: Keep the export name and
5
5
  // UIActions infer that you do not need to get any data from the context.
6
6
  // DataActions infer that the action depends on the data from the context.
7
7
 
8
- export var DeleteAction = createUIAction(ActionName.DeleteAction);
8
+ export var DeleteAction = createUIAction(ActionName.DeleteAction);
9
+ export var CustomAction = createUIAction(ActionName.CustomAction);
@@ -1,6 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
 
4
+ var _actionMappings;
5
+
4
6
  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
7
 
6
8
  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; }
@@ -12,8 +14,10 @@ import Action from './action';
12
14
  import { FormattedMessage } from 'react-intl-next';
13
15
  import { messages } from '../../../../messages';
14
16
  import CrossIcon from '@atlaskit/icon/glyph/cross';
15
-
16
- var actionMappings = _defineProperty({}, ActionName.DeleteAction, {
17
+ var actionMappings = (_actionMappings = {}, _defineProperty(_actionMappings, ActionName.CustomAction, {
18
+ component: Action,
19
+ props: {}
20
+ }), _defineProperty(_actionMappings, ActionName.DeleteAction, {
17
21
  component: Action,
18
22
  props: {
19
23
  testId: 'smart-action-delete-action',
@@ -23,7 +27,7 @@ var actionMappings = _defineProperty({}, ActionName.DeleteAction, {
23
27
  }),
24
28
  toolTipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.delete)
25
29
  }
26
- });
30
+ }), _actionMappings);
27
31
 
28
32
  var getContextKey = function getContextKey(name) {
29
33
  // Attempt to predict context prop name in advance to reduce the amount of
@@ -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;
@@ -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,
@@ -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';
@@ -101,7 +101,8 @@ export declare enum ElementName {
101
101
  * Flexible UI action (button)
102
102
  */
103
103
  export declare enum ActionName {
104
- DeleteAction = "DeleteAction"
104
+ DeleteAction = "DeleteAction",
105
+ CustomAction = "CustomAction"
105
106
  }
106
107
  /**
107
108
  * Flexible UI icons - each mapped to AK icons.
@@ -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, PreviewBlock, 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,3 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { ActionProps } from './action/types';
3
3
  export declare const DeleteAction: import("react").FC<ActionProps>;
4
+ export declare const CustomAction: import("react").FC<ActionProps>;
@@ -1,4 +1,5 @@
1
1
  import { ActionName, ElementName, SmartLinkDirection, SmartLinkSize, SmartLinkStatus } from '../../../../constants';
2
+ import { ActionProps } from '../actions/action/types';
2
3
  export declare type BlockProps = {
3
4
  direction?: SmartLinkDirection;
4
5
  size?: SmartLinkSize;
@@ -10,10 +11,23 @@ export declare type ElementItem = {
10
11
  size?: SmartLinkSize;
11
12
  testId?: string;
12
13
  };
13
- export declare type ActionItem = {
14
- name: ActionName;
14
+ export declare type BaseActionItem = {
15
15
  testId?: string;
16
16
  hideContent?: boolean;
17
17
  hideIcon?: boolean;
18
18
  onClick: () => any;
19
19
  };
20
+ /**
21
+ * Customer can define named action item. Icon and label will be provided implicitly.
22
+ */
23
+ export declare type NamedActionItem = BaseActionItem & {
24
+ name: Exclude<ActionName, ActionName.CustomAction>;
25
+ };
26
+ /**
27
+ * Customer can define a custom action item. This will require them to specify
28
+ * either `icon` and `iconPosition` OR `content` OR both BUT not neither of those things.
29
+ */
30
+ export declare type CustomActionItem = BaseActionItem & {
31
+ name: ActionName.CustomAction;
32
+ } & ((Required<Pick<ActionProps, 'icon' | 'iconPosition'>> & Pick<ActionProps, 'content'>) | ((Required<Pick<ActionProps, 'content'>> & Pick<ActionProps, 'icon' | 'iconPosition'>) & Pick<ActionProps, 'tooltipMessage'>));
33
+ export declare type ActionItem = NamedActionItem | CustomActionItem;
@@ -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.3",
3
+ "version": "17.7.1",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -26,23 +26,22 @@
26
26
  "@atlaskit/analytics-next": "^8.2.0",
27
27
  "@atlaskit/avatar": "^20.5.0",
28
28
  "@atlaskit/avatar-group": "^8.5.5",
29
- "@atlaskit/button": "^16.1.4",
30
- "@atlaskit/droplist": "^11.0.0",
29
+ "@atlaskit/button": "^16.2.0",
30
+ "@atlaskit/dropdown-menu": "^11.1.0",
31
31
  "@atlaskit/icon": "^21.10.0",
32
32
  "@atlaskit/icon-file-type": "^6.3.0",
33
33
  "@atlaskit/icon-object": "^6.2.0",
34
34
  "@atlaskit/icon-priority": "^6.3.0",
35
35
  "@atlaskit/in-product-testing": "^0.1.0",
36
- "@atlaskit/item": "^12.0.0",
37
36
  "@atlaskit/logo": "^13.5.0",
38
37
  "@atlaskit/lozenge": "^11.1.0",
39
- "@atlaskit/media-common": "^2.10.0",
40
- "@atlaskit/media-ui": "^19.0.0",
38
+ "@atlaskit/media-common": "^2.11.0",
39
+ "@atlaskit/media-ui": "^20.0.0",
41
40
  "@atlaskit/modal-dialog": "^12.2.0",
42
41
  "@atlaskit/outbound-auth-flow-client": "^3.3.0",
43
42
  "@atlaskit/spinner": "^15.1.0",
44
43
  "@atlaskit/theme": "^12.1.0",
45
- "@atlaskit/tokens": "^0.6.0",
44
+ "@atlaskit/tokens": "^0.7.0",
46
45
  "@atlaskit/tooltip": "^17.5.2",
47
46
  "@atlaskit/ufo": "^0.1.0",
48
47
  "@babel/runtime": "^7.0.0",
@@ -77,9 +76,10 @@
77
76
  "@atlaskit/inline-message": "^11.2.0",
78
77
  "@atlaskit/lozenge": "^11.1.0",
79
78
  "@atlaskit/media-integration-test-helpers": "^2.5.0",
80
- "@atlaskit/media-test-helpers": "^29.1.0",
79
+ "@atlaskit/media-test-helpers": "^29.2.0",
81
80
  "@atlaskit/page": "^12.1.0",
82
81
  "@atlaskit/radio": "^5.3.0",
82
+ "@atlaskit/range": "^6.0.0",
83
83
  "@atlaskit/section-message": "^6.1.5",
84
84
  "@atlaskit/select": "^15.2.0",
85
85
  "@atlaskit/table-tree": "^9.1.0",