@atlaskit/smart-card 17.6.0 → 17.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/cjs/constants.js +1 -0
  3. package/dist/cjs/version.json +1 -1
  4. package/dist/cjs/view/BlockCard/components/ActionList.js +33 -30
  5. package/dist/cjs/view/FlexibleCard/components/actions/index.js +4 -2
  6. package/dist/cjs/view/FlexibleCard/components/actions/utils.js +7 -2
  7. package/dist/cjs/view/FlexibleCard/components/blocks/title-block/errored/index.js +7 -3
  8. package/dist/cjs/view/FlexibleCard/components/blocks/title-block/resolved/index.js +7 -3
  9. package/dist/cjs/view/FlexibleCard/components/blocks/title-block/resolving/index.js +7 -3
  10. package/dist/es2019/constants.js +1 -0
  11. package/dist/es2019/version.json +1 -1
  12. package/dist/es2019/view/BlockCard/components/ActionList.js +22 -17
  13. package/dist/es2019/view/FlexibleCard/components/actions/index.js +2 -1
  14. package/dist/es2019/view/FlexibleCard/components/actions/utils.js +4 -0
  15. package/dist/es2019/view/FlexibleCard/components/blocks/title-block/errored/index.js +6 -2
  16. package/dist/es2019/view/FlexibleCard/components/blocks/title-block/resolved/index.js +6 -2
  17. package/dist/es2019/view/FlexibleCard/components/blocks/title-block/resolving/index.js +6 -2
  18. package/dist/esm/constants.js +1 -0
  19. package/dist/esm/version.json +1 -1
  20. package/dist/esm/view/BlockCard/components/ActionList.js +25 -26
  21. package/dist/esm/view/FlexibleCard/components/actions/index.js +2 -1
  22. package/dist/esm/view/FlexibleCard/components/actions/utils.js +7 -3
  23. package/dist/esm/view/FlexibleCard/components/blocks/title-block/errored/index.js +7 -3
  24. package/dist/esm/view/FlexibleCard/components/blocks/title-block/resolved/index.js +7 -3
  25. package/dist/esm/view/FlexibleCard/components/blocks/title-block/resolving/index.js +7 -3
  26. package/dist/types/constants.d.ts +2 -1
  27. package/dist/types/view/FlexibleCard/components/actions/index.d.ts +1 -0
  28. package/dist/types/view/FlexibleCard/components/blocks/title-block/types.d.ts +1 -0
  29. package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +16 -2
  30. package/package.json +6 -8
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 17.7.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`9066a1e8154`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9066a1e8154) - EDM-2926: Add title override for title block
8
+
9
+ ## 17.7.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [`123201c5105`](https://bitbucket.org/atlassian/atlassian-frontend/commits/123201c5105) - Add ability to add custom action item
14
+
15
+ ## 17.7.0
16
+
17
+ ### Minor Changes
18
+
19
+ - [`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
20
+ - [`fb15a8a421c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/fb15a8a421c) - move smart-card views and helpers from media-ui into smart-card
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies
25
+
3
26
  ## 17.6.0
4
27
 
5
28
  ### Minor 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;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "17.6.0",
3
+ "version": "17.7.2",
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;
@@ -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
@@ -31,7 +31,7 @@ var _elementGroup = _interopRequireDefault(require("../../element-group"));
31
31
 
32
32
  var _token = require("../../../../../../utils/token");
33
33
 
34
- var _excluded = ["maxLines", "retry", "position", "testId", "theme"];
34
+ var _excluded = ["maxLines", "retry", "position", "testId", "theme", "text"];
35
35
 
36
36
  var _templateObject, _templateObject2;
37
37
 
@@ -48,6 +48,7 @@ var TitleBlockErroredView = function TitleBlockErroredView(_ref) {
48
48
  position = _ref.position,
49
49
  testId = _ref.testId,
50
50
  theme = _ref.theme,
51
+ text = _ref.text,
51
52
  blockProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
52
53
 
53
54
  var _ref2 = retry || {},
@@ -58,14 +59,17 @@ var TitleBlockErroredView = function TitleBlockErroredView(_ref) {
58
59
  var _blockProps$size = blockProps.size,
59
60
  size = _blockProps$size === void 0 ? _constants.SmartLinkSize.Medium : _blockProps$size;
60
61
  var hasAction = onClick !== undefined;
62
+ var overrideText = !!text ? {
63
+ text: text
64
+ } : {};
61
65
  return (0, _core.jsx)(_block.default, (0, _extends2.default)({}, blockProps, {
62
66
  testId: "".concat(testId, "-errored-view")
63
67
  }), (0, _core.jsx)(_elements.LinkIcon, {
64
68
  position: position
65
- }), (0, _core.jsx)(_elements.Title, {
69
+ }), (0, _core.jsx)(_elements.Title, (0, _extends2.default)({}, overrideText, {
66
70
  maxLines: maxLines,
67
71
  theme: theme
68
- }), descriptor && (0, _core.jsx)(_elementGroup.default, {
72
+ })), descriptor && (0, _core.jsx)(_elementGroup.default, {
69
73
  direction: _constants.SmartLinkDirection.Horizontal,
70
74
  align: _constants.SmartLinkAlignment.Right
71
75
  }, (0, _core.jsx)("span", {
@@ -25,7 +25,7 @@ var _utils = require("../../utils");
25
25
 
26
26
  var _actionGroup = _interopRequireDefault(require("../../action-group"));
27
27
 
28
- var _excluded = ["maxLines", "metadata", "position", "subtitle", "actions", "testId", "theme"];
28
+ var _excluded = ["maxLines", "metadata", "position", "subtitle", "actions", "testId", "theme", "text"];
29
29
 
30
30
  var TitleBlockResolvedView = function TitleBlockResolvedView(_ref) {
31
31
  var maxLines = _ref.maxLines,
@@ -38,9 +38,13 @@ var TitleBlockResolvedView = function TitleBlockResolvedView(_ref) {
38
38
  actions = _ref$actions === void 0 ? [] : _ref$actions,
39
39
  testId = _ref.testId,
40
40
  theme = _ref.theme,
41
+ text = _ref.text,
41
42
  blockProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
42
43
  var metadataElements = (0, _utils.renderElementItems)(metadata);
43
44
  var subtitleElements = (0, _utils.renderElementItems)(subtitle);
45
+ var overrideText = !!text ? {
46
+ text: text
47
+ } : {};
44
48
  return /*#__PURE__*/_react.default.createElement(_block.default, (0, _extends2.default)({}, blockProps, {
45
49
  testId: "".concat(testId, "-resolved-view")
46
50
  }), /*#__PURE__*/_react.default.createElement(_elements.LinkIcon, {
@@ -48,10 +52,10 @@ var TitleBlockResolvedView = function TitleBlockResolvedView(_ref) {
48
52
  }), /*#__PURE__*/_react.default.createElement(_elementGroup.default, {
49
53
  direction: _constants.SmartLinkDirection.Vertical,
50
54
  width: _constants.SmartLinkWidth.Flexible
51
- }, /*#__PURE__*/_react.default.createElement(_elements.Title, {
55
+ }, /*#__PURE__*/_react.default.createElement(_elements.Title, (0, _extends2.default)({
52
56
  maxLines: maxLines,
53
57
  theme: theme
54
- }), subtitleElements && /*#__PURE__*/_react.default.createElement(_elementGroup.default, {
58
+ }, overrideText)), subtitleElements && /*#__PURE__*/_react.default.createElement(_elementGroup.default, {
55
59
  direction: _constants.SmartLinkDirection.Horizontal
56
60
  }, subtitleElements)), metadataElements && /*#__PURE__*/_react.default.createElement(_elementGroup.default, {
57
61
  direction: _constants.SmartLinkDirection.Horizontal,
@@ -23,7 +23,7 @@ var _block = _interopRequireDefault(require("../../block"));
23
23
 
24
24
  var _constants = require("../../../../../../constants");
25
25
 
26
- var _excluded = ["maxLines", "retry", "position", "testId", "theme"];
26
+ var _excluded = ["maxLines", "retry", "position", "testId", "theme", "text"];
27
27
 
28
28
  var getSpinnerSize = function getSpinnerSize(size) {
29
29
  // Spinner sizes should be equivalent or smaller than Icon size
@@ -50,18 +50,22 @@ var TitleBlockResolvingView = function TitleBlockResolvingView(_ref) {
50
50
  position = _ref.position,
51
51
  testId = _ref.testId,
52
52
  theme = _ref.theme,
53
+ text = _ref.text,
53
54
  blockProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
54
55
  var _blockProps$size = blockProps.size,
55
56
  size = _blockProps$size === void 0 ? _constants.SmartLinkSize.Medium : _blockProps$size;
57
+ var overrideText = !!text ? {
58
+ text: text
59
+ } : {};
56
60
  return (0, _core.jsx)(_block.default, (0, _extends2.default)({}, blockProps, {
57
61
  testId: "".concat(testId, "-resolving-view")
58
62
  }), (0, _core.jsx)(_spinner.default, {
59
63
  size: getSpinnerSize(size),
60
64
  testId: "".concat(testId, "-resolving-spinner")
61
- }), (0, _core.jsx)(_elements.Title, {
65
+ }), (0, _core.jsx)(_elements.Title, (0, _extends2.default)({}, overrideText, {
62
66
  maxLines: maxLines,
63
67
  theme: theme
64
- }));
68
+ })));
65
69
  };
66
70
 
67
71
  var _default = TitleBlockResolvingView;
@@ -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;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "17.6.0",
3
+ "version": "17.7.2",
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
  };
@@ -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: {
@@ -36,6 +36,7 @@ const TitleBlockErroredView = ({
36
36
  position,
37
37
  testId,
38
38
  theme,
39
+ text,
39
40
  ...blockProps
40
41
  }) => {
41
42
  const {
@@ -47,14 +48,17 @@ const TitleBlockErroredView = ({
47
48
  size = SmartLinkSize.Medium
48
49
  } = blockProps;
49
50
  const hasAction = onClick !== undefined;
51
+ const overrideText = !!text ? {
52
+ text
53
+ } : {};
50
54
  return jsx(Block, _extends({}, blockProps, {
51
55
  testId: `${testId}-errored-view`
52
56
  }), jsx(LinkIcon, {
53
57
  position: position
54
- }), jsx(Title, {
58
+ }), jsx(Title, _extends({}, overrideText, {
55
59
  maxLines: maxLines,
56
60
  theme: theme
57
- }), descriptor && jsx(ElementGroup, {
61
+ })), descriptor && jsx(ElementGroup, {
58
62
  direction: SmartLinkDirection.Horizontal,
59
63
  align: SmartLinkAlignment.Right
60
64
  }, jsx("span", {
@@ -15,10 +15,14 @@ const TitleBlockResolvedView = ({
15
15
  actions = [],
16
16
  testId,
17
17
  theme,
18
+ text,
18
19
  ...blockProps
19
20
  }) => {
20
21
  const metadataElements = renderElementItems(metadata);
21
22
  const subtitleElements = renderElementItems(subtitle);
23
+ const overrideText = !!text ? {
24
+ text
25
+ } : {};
22
26
  return /*#__PURE__*/React.createElement(Block, _extends({}, blockProps, {
23
27
  testId: `${testId}-resolved-view`
24
28
  }), /*#__PURE__*/React.createElement(LinkIcon, {
@@ -26,10 +30,10 @@ const TitleBlockResolvedView = ({
26
30
  }), /*#__PURE__*/React.createElement(ElementGroup, {
27
31
  direction: SmartLinkDirection.Vertical,
28
32
  width: SmartLinkWidth.Flexible
29
- }, /*#__PURE__*/React.createElement(Title, {
33
+ }, /*#__PURE__*/React.createElement(Title, _extends({
30
34
  maxLines: maxLines,
31
35
  theme: theme
32
- }), subtitleElements && /*#__PURE__*/React.createElement(ElementGroup, {
36
+ }, overrideText)), subtitleElements && /*#__PURE__*/React.createElement(ElementGroup, {
33
37
  direction: SmartLinkDirection.Horizontal
34
38
  }, subtitleElements)), metadataElements && /*#__PURE__*/React.createElement(ElementGroup, {
35
39
  direction: SmartLinkDirection.Horizontal,
@@ -33,20 +33,24 @@ const TitleBlockResolvingView = ({
33
33
  position,
34
34
  testId,
35
35
  theme,
36
+ text,
36
37
  ...blockProps
37
38
  }) => {
38
39
  const {
39
40
  size = SmartLinkSize.Medium
40
41
  } = blockProps;
42
+ const overrideText = !!text ? {
43
+ text
44
+ } : {};
41
45
  return jsx(Block, _extends({}, blockProps, {
42
46
  testId: `${testId}-resolving-view`
43
47
  }), jsx(Spinner, {
44
48
  size: getSpinnerSize(size),
45
49
  testId: `${testId}-resolving-spinner`
46
- }), jsx(Title, {
50
+ }), jsx(Title, _extends({}, overrideText, {
47
51
  maxLines: maxLines,
48
52
  theme: theme
49
- }));
53
+ })));
50
54
  };
51
55
 
52
56
  export default TitleBlockResolvingView;
@@ -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;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "17.6.0",
3
+ "version": "17.7.2",
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
  };
@@ -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,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
4
- var _excluded = ["maxLines", "retry", "position", "testId", "theme"];
4
+ var _excluded = ["maxLines", "retry", "position", "testId", "theme", "text"];
5
5
 
6
6
  var _templateObject, _templateObject2;
7
7
 
@@ -28,6 +28,7 @@ var TitleBlockErroredView = function TitleBlockErroredView(_ref) {
28
28
  position = _ref.position,
29
29
  testId = _ref.testId,
30
30
  theme = _ref.theme,
31
+ text = _ref.text,
31
32
  blockProps = _objectWithoutProperties(_ref, _excluded);
32
33
 
33
34
  var _ref2 = retry || {},
@@ -38,14 +39,17 @@ var TitleBlockErroredView = function TitleBlockErroredView(_ref) {
38
39
  var _blockProps$size = blockProps.size,
39
40
  size = _blockProps$size === void 0 ? SmartLinkSize.Medium : _blockProps$size;
40
41
  var hasAction = onClick !== undefined;
42
+ var overrideText = !!text ? {
43
+ text: text
44
+ } : {};
41
45
  return jsx(Block, _extends({}, blockProps, {
42
46
  testId: "".concat(testId, "-errored-view")
43
47
  }), jsx(LinkIcon, {
44
48
  position: position
45
- }), jsx(Title, {
49
+ }), jsx(Title, _extends({}, overrideText, {
46
50
  maxLines: maxLines,
47
51
  theme: theme
48
- }), descriptor && jsx(ElementGroup, {
52
+ })), descriptor && jsx(ElementGroup, {
49
53
  direction: SmartLinkDirection.Horizontal,
50
54
  align: SmartLinkAlignment.Right
51
55
  }, jsx("span", {
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["maxLines", "metadata", "position", "subtitle", "actions", "testId", "theme"];
3
+ var _excluded = ["maxLines", "metadata", "position", "subtitle", "actions", "testId", "theme", "text"];
4
4
  import React from 'react';
5
5
  import { LinkIcon, Title } from '../../../elements';
6
6
  import Block from '../../block';
@@ -20,10 +20,14 @@ var TitleBlockResolvedView = function TitleBlockResolvedView(_ref) {
20
20
  actions = _ref$actions === void 0 ? [] : _ref$actions,
21
21
  testId = _ref.testId,
22
22
  theme = _ref.theme,
23
+ text = _ref.text,
23
24
  blockProps = _objectWithoutProperties(_ref, _excluded);
24
25
 
25
26
  var metadataElements = renderElementItems(metadata);
26
27
  var subtitleElements = renderElementItems(subtitle);
28
+ var overrideText = !!text ? {
29
+ text: text
30
+ } : {};
27
31
  return /*#__PURE__*/React.createElement(Block, _extends({}, blockProps, {
28
32
  testId: "".concat(testId, "-resolved-view")
29
33
  }), /*#__PURE__*/React.createElement(LinkIcon, {
@@ -31,10 +35,10 @@ var TitleBlockResolvedView = function TitleBlockResolvedView(_ref) {
31
35
  }), /*#__PURE__*/React.createElement(ElementGroup, {
32
36
  direction: SmartLinkDirection.Vertical,
33
37
  width: SmartLinkWidth.Flexible
34
- }, /*#__PURE__*/React.createElement(Title, {
38
+ }, /*#__PURE__*/React.createElement(Title, _extends({
35
39
  maxLines: maxLines,
36
40
  theme: theme
37
- }), subtitleElements && /*#__PURE__*/React.createElement(ElementGroup, {
41
+ }, overrideText)), subtitleElements && /*#__PURE__*/React.createElement(ElementGroup, {
38
42
  direction: SmartLinkDirection.Horizontal
39
43
  }, subtitleElements)), metadataElements && /*#__PURE__*/React.createElement(ElementGroup, {
40
44
  direction: SmartLinkDirection.Horizontal,
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["maxLines", "retry", "position", "testId", "theme"];
3
+ var _excluded = ["maxLines", "retry", "position", "testId", "theme", "text"];
4
4
 
5
5
  /** @jsx jsx */
6
6
  import React from 'react';
@@ -35,19 +35,23 @@ var TitleBlockResolvingView = function TitleBlockResolvingView(_ref) {
35
35
  position = _ref.position,
36
36
  testId = _ref.testId,
37
37
  theme = _ref.theme,
38
+ text = _ref.text,
38
39
  blockProps = _objectWithoutProperties(_ref, _excluded);
39
40
 
40
41
  var _blockProps$size = blockProps.size,
41
42
  size = _blockProps$size === void 0 ? SmartLinkSize.Medium : _blockProps$size;
43
+ var overrideText = !!text ? {
44
+ text: text
45
+ } : {};
42
46
  return jsx(Block, _extends({}, blockProps, {
43
47
  testId: "".concat(testId, "-resolving-view")
44
48
  }), jsx(Spinner, {
45
49
  size: getSpinnerSize(size),
46
50
  testId: "".concat(testId, "-resolving-spinner")
47
- }), jsx(Title, {
51
+ }), jsx(Title, _extends({}, overrideText, {
48
52
  maxLines: maxLines,
49
53
  theme: theme
50
- }));
54
+ })));
51
55
  };
52
56
 
53
57
  export default TitleBlockResolvingView;
@@ -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.
@@ -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>;
@@ -9,4 +9,5 @@ export declare type TitleBlockProps = BlockProps & {
9
9
  subtitle?: ElementItem[];
10
10
  actions?: ActionItem[];
11
11
  theme?: SmartLinkTheme;
12
+ text?: string;
12
13
  };
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "17.6.0",
3
+ "version": "17.7.2",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -26,24 +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",
29
+ "@atlaskit/button": "^16.2.0",
30
30
  "@atlaskit/dropdown-menu": "^11.1.0",
31
- "@atlaskit/droplist": "^11.0.0",
32
31
  "@atlaskit/icon": "^21.10.0",
33
32
  "@atlaskit/icon-file-type": "^6.3.0",
34
33
  "@atlaskit/icon-object": "^6.2.0",
35
34
  "@atlaskit/icon-priority": "^6.3.0",
36
35
  "@atlaskit/in-product-testing": "^0.1.0",
37
- "@atlaskit/item": "^12.0.0",
38
36
  "@atlaskit/logo": "^13.5.0",
39
37
  "@atlaskit/lozenge": "^11.1.0",
40
- "@atlaskit/media-common": "^2.10.0",
41
- "@atlaskit/media-ui": "^19.0.0",
38
+ "@atlaskit/media-common": "^2.11.0",
39
+ "@atlaskit/media-ui": "^20.0.0",
42
40
  "@atlaskit/modal-dialog": "^12.2.0",
43
41
  "@atlaskit/outbound-auth-flow-client": "^3.3.0",
44
42
  "@atlaskit/spinner": "^15.1.0",
45
43
  "@atlaskit/theme": "^12.1.0",
46
- "@atlaskit/tokens": "^0.6.0",
44
+ "@atlaskit/tokens": "^0.7.0",
47
45
  "@atlaskit/tooltip": "^17.5.2",
48
46
  "@atlaskit/ufo": "^0.1.0",
49
47
  "@babel/runtime": "^7.0.0",
@@ -78,7 +76,7 @@
78
76
  "@atlaskit/inline-message": "^11.2.0",
79
77
  "@atlaskit/lozenge": "^11.1.0",
80
78
  "@atlaskit/media-integration-test-helpers": "^2.5.0",
81
- "@atlaskit/media-test-helpers": "^29.1.0",
79
+ "@atlaskit/media-test-helpers": "^29.2.0",
82
80
  "@atlaskit/page": "^12.1.0",
83
81
  "@atlaskit/radio": "^5.3.0",
84
82
  "@atlaskit/range": "^6.0.0",