@atlaskit/smart-card 21.0.0 → 21.0.3

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 (49) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/version.json +1 -1
  3. package/dist/cjs/view/FlexibleCard/components/actions/action/action-button/index.js +87 -0
  4. package/dist/cjs/view/FlexibleCard/components/actions/action/action-button/types.js +5 -0
  5. package/dist/cjs/view/FlexibleCard/components/actions/action/action-dropdown-item/index.js +31 -0
  6. package/dist/cjs/view/FlexibleCard/components/actions/action/action-dropdown-item/types.js +5 -0
  7. package/dist/cjs/view/FlexibleCard/components/actions/action/action-icon/index.js +52 -0
  8. package/dist/cjs/view/FlexibleCard/components/actions/action/action-icon/types.js +5 -0
  9. package/dist/cjs/view/FlexibleCard/components/actions/action/index.js +42 -104
  10. package/dist/cjs/view/FlexibleCard/components/blocks/action-group/index.js +44 -15
  11. package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +12 -1
  12. package/dist/cjs/view/FlexibleCard/components/utils.js +7 -2
  13. package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +21 -20
  14. package/dist/es2019/version.json +1 -1
  15. package/dist/es2019/view/FlexibleCard/components/actions/action/action-button/index.js +88 -0
  16. package/dist/es2019/view/FlexibleCard/components/actions/action/action-button/types.js +1 -0
  17. package/dist/es2019/view/FlexibleCard/components/actions/action/action-dropdown-item/index.js +18 -0
  18. package/dist/es2019/view/FlexibleCard/components/actions/action/action-dropdown-item/types.js +1 -0
  19. package/dist/es2019/view/FlexibleCard/components/actions/action/action-icon/index.js +35 -0
  20. package/dist/es2019/view/FlexibleCard/components/actions/action/action-icon/types.js +1 -0
  21. package/dist/es2019/view/FlexibleCard/components/actions/action/index.js +26 -110
  22. package/dist/es2019/view/FlexibleCard/components/blocks/action-group/index.js +31 -12
  23. package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +12 -2
  24. package/dist/es2019/view/FlexibleCard/components/utils.js +6 -0
  25. package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +21 -20
  26. package/dist/esm/version.json +1 -1
  27. package/dist/esm/view/FlexibleCard/components/actions/action/action-button/index.js +67 -0
  28. package/dist/esm/view/FlexibleCard/components/actions/action/action-button/types.js +1 -0
  29. package/dist/esm/view/FlexibleCard/components/actions/action/action-dropdown-item/index.js +19 -0
  30. package/dist/esm/view/FlexibleCard/components/actions/action/action-dropdown-item/types.js +1 -0
  31. package/dist/esm/view/FlexibleCard/components/actions/action/action-icon/index.js +39 -0
  32. package/dist/esm/view/FlexibleCard/components/actions/action/action-icon/types.js +1 -0
  33. package/dist/esm/view/FlexibleCard/components/actions/action/index.js +41 -99
  34. package/dist/esm/view/FlexibleCard/components/blocks/action-group/index.js +44 -16
  35. package/dist/esm/view/FlexibleCard/components/blocks/utils.js +12 -1
  36. package/dist/esm/view/FlexibleCard/components/utils.js +3 -1
  37. package/dist/esm/view/HoverCard/components/HoverCardComponent.js +21 -20
  38. package/dist/types/view/FlexibleCard/components/actions/action/action-button/index.d.ts +5 -0
  39. package/dist/types/view/FlexibleCard/components/actions/action/action-button/types.d.ts +8 -0
  40. package/dist/types/view/FlexibleCard/components/actions/action/action-dropdown-item/index.d.ts +4 -0
  41. package/dist/types/view/FlexibleCard/components/actions/action/action-dropdown-item/types.d.ts +8 -0
  42. package/dist/types/view/FlexibleCard/components/actions/action/action-icon/index.d.ts +5 -0
  43. package/dist/types/view/FlexibleCard/components/actions/action/action-icon/types.d.ts +7 -0
  44. package/dist/types/view/FlexibleCard/components/actions/action/index.d.ts +0 -3
  45. package/dist/types/view/FlexibleCard/components/actions/action/types.d.ts +0 -16
  46. package/dist/types/view/FlexibleCard/components/blocks/utils.d.ts +1 -1
  47. package/dist/types/view/FlexibleCard/components/utils.d.ts +2 -0
  48. package/package.json +8 -5
  49. package/report.api.md +32 -2
@@ -1,62 +1,10 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
3
-
4
- var _templateObject, _templateObject2, _templateObject3, _sizeToSpacing;
5
-
6
1
  /** @jsx jsx */
7
2
  import React from 'react';
8
- import { css, jsx } from '@emotion/core';
9
- import Button from '@atlaskit/button/custom-theme-button';
3
+ import { jsx } from '@emotion/core';
10
4
  import { SmartLinkSize } from '../../../../../constants';
11
- import Tooltip from '@atlaskit/tooltip';
12
- import { DropdownItem } from '@atlaskit/dropdown-menu';
13
- import { getIconSizeStyles } from '../../utils';
14
- import { tokens } from '../../../../../utils/token';
15
- import { handleOnClick } from '../../../../../utils';
16
-
17
- var getIconWidth = function getIconWidth(size) {
18
- switch (size) {
19
- case SmartLinkSize.XLarge:
20
- case SmartLinkSize.Large:
21
- return '1.5rem';
22
-
23
- case SmartLinkSize.Medium:
24
- case SmartLinkSize.Small:
25
- default:
26
- return '1rem';
27
- }
28
- };
29
-
30
- var getIconStyles = function getIconStyles(size) {
31
- return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n ", ";\n"])), tokens.actionIcon, getIconSizeStyles(getIconWidth(size)));
32
- };
33
-
34
- var getButtonStyle = function getButtonStyle(size, iconOnly) {
35
- switch (size) {
36
- case SmartLinkSize.Large:
37
- return iconOnly ? css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n button,\n button:hover,\n button:focus,\n button:active {\n padding: 0;\n > span {\n margin: 0;\n }\n }\n "]))) : '';
38
-
39
- case SmartLinkSize.Small:
40
- return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n font-size: 0.75rem;\n font-weight: 500;\n line-height: 1rem;\n button,\n button:hover,\n button:focus,\n button:active {\n line-height: 1rem;\n ", "\n }\n "])), iconOnly ? "\n padding: 0.125rem;\n " : "\n padding-left: 0.25rem;\n padding-right: 0.25rem;\n ");
41
-
42
- case SmartLinkSize.XLarge:
43
- case SmartLinkSize.Medium:
44
- default:
45
- return '';
46
- }
47
- };
48
-
49
- var ActionIcon = function ActionIcon(_ref) {
50
- var size = _ref.size,
51
- testId = _ref.testId,
52
- icon = _ref.icon;
53
- return jsx("span", {
54
- css: getIconStyles(size),
55
- "data-testid": "".concat(testId, "-icon")
56
- }, icon);
57
- };
58
-
59
- 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);
5
+ import ActionButton from './action-button';
6
+ import ActionDropdownItem from './action-dropdown-item';
7
+ import ActionIcon from './action-icon';
60
8
  /**
61
9
  * A base action that can be triggered with an on click.
62
10
  * @internal
@@ -66,60 +14,54 @@ export var sizeToSpacing = (_sizeToSpacing = {}, _defineProperty(_sizeToSpacing,
66
14
  * @see CustomAction
67
15
  */
68
16
 
69
- var Action = function Action(_ref2) {
70
- var _ref2$appearance = _ref2.appearance,
71
- appearance = _ref2$appearance === void 0 ? 'subtle' : _ref2$appearance,
72
- content = _ref2.content,
73
- onClick = _ref2.onClick,
74
- _ref2$size = _ref2.size,
75
- size = _ref2$size === void 0 ? SmartLinkSize.Medium : _ref2$size,
76
- _ref2$testId = _ref2.testId,
77
- testId = _ref2$testId === void 0 ? 'smart-action' : _ref2$testId,
78
- icon = _ref2.icon,
79
- _ref2$iconPosition = _ref2.iconPosition,
80
- iconPosition = _ref2$iconPosition === void 0 ? 'before' : _ref2$iconPosition,
81
- tooltipMessage = _ref2.tooltipMessage,
82
- asDropDownItem = _ref2.asDropDownItem,
83
- overrideCss = _ref2.overrideCss;
17
+ var Action = function Action(_ref) {
18
+ var _ref$appearance = _ref.appearance,
19
+ appearance = _ref$appearance === void 0 ? 'subtle' : _ref$appearance,
20
+ content = _ref.content,
21
+ onClick = _ref.onClick,
22
+ _ref$size = _ref.size,
23
+ size = _ref$size === void 0 ? SmartLinkSize.Medium : _ref$size,
24
+ _ref$testId = _ref.testId,
25
+ testId = _ref$testId === void 0 ? 'smart-action' : _ref$testId,
26
+ icon = _ref.icon,
27
+ _ref$iconPosition = _ref.iconPosition,
28
+ iconPosition = _ref$iconPosition === void 0 ? 'before' : _ref$iconPosition,
29
+ tooltipMessage = _ref.tooltipMessage,
30
+ asDropDownItem = _ref.asDropDownItem,
31
+ overrideCss = _ref.overrideCss;
84
32
 
85
33
  if (!onClick) {
86
34
  return null;
87
35
  }
88
36
 
89
- var iconBefore = icon && iconPosition === 'before' ? jsx(ActionIcon, {
37
+ var actionIcon = icon && jsx(ActionIcon, {
38
+ icon: icon,
90
39
  size: size,
91
- testId: testId,
92
- icon: icon
93
- }) : undefined;
94
- var iconAfter = icon && iconPosition === 'after' ? jsx(ActionIcon, {
95
- size: size,
96
- testId: testId,
97
- icon: icon
98
- }) : undefined;
99
- var iconOnly = !content;
40
+ testId: testId
41
+ });
42
+ var iconBefore = icon && iconPosition === 'before' ? actionIcon : undefined;
43
+ var iconAfter = icon && iconPosition === 'after' ? actionIcon : undefined;
100
44
 
101
45
  if (asDropDownItem) {
102
- return jsx(DropdownItem, {
103
- elemBefore: iconBefore,
104
- elemAfter: iconAfter,
105
- testId: testId,
106
- onClick: handleOnClick(onClick)
107
- }, content);
46
+ return jsx(ActionDropdownItem, {
47
+ content: content,
48
+ iconAfter: iconAfter,
49
+ iconBefore: iconBefore,
50
+ onClick: onClick,
51
+ testId: testId
52
+ });
108
53
  } else {
109
- return jsx(Tooltip, {
110
- content: tooltipMessage,
111
- testId: "".concat(testId, "-tooltip")
112
- }, jsx("div", {
113
- css: [getButtonStyle(size, iconOnly), overrideCss],
114
- "data-testid": "".concat(testId, "-button-wrapper")
115
- }, jsx(Button, {
116
- spacing: sizeToSpacing[size],
54
+ return jsx(ActionButton, {
117
55
  appearance: appearance,
118
- testId: testId,
119
- onClick: handleOnClick(onClick),
56
+ content: content,
57
+ iconAfter: iconAfter,
120
58
  iconBefore: iconBefore,
121
- iconAfter: iconAfter
122
- }, content)));
59
+ onClick: onClick,
60
+ overrideCss: overrideCss,
61
+ size: size,
62
+ testId: testId,
63
+ tooltipMessage: tooltipMessage
64
+ });
123
65
  }
124
66
  };
125
67
 
@@ -1,12 +1,13 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
4
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
4
5
  var _excluded = ["triggerRef"];
5
6
 
6
7
  var _templateObject;
7
8
 
8
9
  /** @jsx jsx */
9
- import { useCallback } from 'react';
10
+ import { useCallback, useMemo, useState } from 'react';
10
11
  import { FormattedMessage } from 'react-intl-next';
11
12
  import { css, jsx } from '@emotion/core';
12
13
  import ButtonGroup from '@atlaskit/button/button-group';
@@ -16,7 +17,7 @@ import DropdownMenu from '@atlaskit/dropdown-menu';
16
17
  import { SmartLinkSize } from '../../../../../constants';
17
18
  import Button from '@atlaskit/button/standard-button';
18
19
  import MoreIcon from '@atlaskit/icon/glyph/more';
19
- import { sizeToSpacing } from '../../actions/action';
20
+ import { sizeToButtonSpacing } from '../../utils';
20
21
  import { tokens } from '../../../../../utils/token';
21
22
  import { messages } from '../../../../../messages';
22
23
  var styles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline-flex;\n line-height: 1rem;\n > div {\n align-items: center;\n button:focus {\n // AK button removes the default browser outline on focus and apply\n // box-shadow styling to create the outline appearance.\n // Due to our container elements (Container/Block/ElementGroup) has\n // overflow hidden to prevent the metadata element from leaking outside\n // of its container, the box-shadow doesn't show properly.\n // Invert the AK box-shadow styling.\n box-shadow: inset 0 0 0 2px ", ";\n }\n }\n"])), tokens.focus);
@@ -38,40 +39,67 @@ var ActionGroup = function ActionGroup(_ref) {
38
39
  visibleButtonsNum = _ref$visibleButtonsNu === void 0 ? 2 : _ref$visibleButtonsNu,
39
40
  onDropdownOpenChange = _ref.onDropdownOpenChange,
40
41
  testId = _ref.testId;
41
- var isMoreThenTwoItems = items.length > visibleButtonsNum;
42
- var firstActions = isMoreThenTwoItems ? items.slice(0, visibleButtonsNum - 1) : items;
43
- var restActions = isMoreThenTwoItems ? items.slice(visibleButtonsNum - 1) : []; // Stop AK dropdown menu to propagate event on click.
42
+
43
+ var _useState = useState(false),
44
+ _useState2 = _slicedToArray(_useState, 2),
45
+ isOpen = _useState2[0],
46
+ setIsOpen = _useState2[1];
47
+
48
+ var _useMemo = useMemo(function () {
49
+ var isMoreThenTwoItems = items.length > visibleButtonsNum;
50
+ var buttons = isMoreThenTwoItems ? items.slice(0, visibleButtonsNum - 1) : items;
51
+ var dropdownItems = isMoreThenTwoItems ? items.slice(visibleButtonsNum - 1) : [];
52
+ return [buttons, dropdownItems];
53
+ }, [items, visibleButtonsNum]),
54
+ _useMemo2 = _slicedToArray(_useMemo, 2),
55
+ buttonActions = _useMemo2[0],
56
+ dropdownItemActions = _useMemo2[1]; // Stop AK dropdown menu to propagate event on click.
57
+
44
58
 
45
59
  var onClick = useCallback(function (e) {
46
60
  return e.stopPropagation();
47
61
  }, []);
62
+ var onOpenChange = useCallback(function (attrs) {
63
+ setIsOpen(attrs.isOpen);
64
+
65
+ if (onDropdownOpenChange) {
66
+ onDropdownOpenChange(attrs.isOpen);
67
+ }
68
+ }, [onDropdownOpenChange]);
69
+ var onActionClick = useCallback(function () {
70
+ if (isOpen) {
71
+ onOpenChange({
72
+ isOpen: false
73
+ });
74
+ }
75
+ }, [isOpen, onOpenChange]);
48
76
  return jsx("div", {
49
77
  css: styles,
50
78
  className: "actions-button-group",
51
79
  onClick: onClick
52
- }, jsx(ButtonGroup, null, renderActionItems(firstActions, size, appearance), restActions.length > 0 ? jsx(DropdownMenu, {
53
- onOpenChange: function onOpenChange(_ref2) {
54
- var isOpen = _ref2.isOpen;
55
- return onDropdownOpenChange && onDropdownOpenChange(isOpen);
56
- },
57
- trigger: function trigger(_ref3) {
58
- var triggerRef = _ref3.triggerRef,
59
- props = _objectWithoutProperties(_ref3, _excluded);
80
+ }, jsx(ButtonGroup, null, renderActionItems(buttonActions, size, appearance, false, onActionClick), dropdownItemActions.length > 0 ? jsx(DropdownMenu, {
81
+ isOpen: isOpen,
82
+ onOpenChange: onOpenChange,
83
+ trigger: function trigger(_ref2) {
84
+ var triggerRef = _ref2.triggerRef,
85
+ props = _objectWithoutProperties(_ref2, _excluded);
60
86
 
61
87
  return jsx(Tooltip, {
62
88
  content: jsx(FormattedMessage, messages.more_actions),
89
+ hideTooltipOnClick: true,
63
90
  testId: "action-group-more-button-tooltip",
64
91
  tag: "span"
65
92
  }, jsx(Button, _extends({}, props, {
66
- spacing: sizeToSpacing[size],
93
+ spacing: sizeToButtonSpacing[size],
67
94
  testId: "action-group-more-button",
68
95
  iconBefore: jsx(MoreIcon, {
69
96
  label: "more"
70
97
  }),
71
98
  ref: triggerRef
72
99
  })));
73
- }
74
- }, renderActionItems(restActions, size, appearance, true)) : null));
100
+ },
101
+ testId: "action-group-dropdown"
102
+ }, renderActionItems(dropdownItemActions, size, appearance, true, onActionClick)) : null));
75
103
  };
76
104
 
77
105
  export default ActionGroup;
@@ -116,6 +116,7 @@ export var renderActionItems = function renderActionItems() {
116
116
  var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : SmartLinkSize.Medium;
117
117
  var appearance = arguments.length > 2 ? arguments[2] : undefined;
118
118
  var asDropDownItems = arguments.length > 3 ? arguments[3] : undefined;
119
+ var onActionItemClick = arguments.length > 4 ? arguments[4] : undefined;
119
120
  var actions = items.reduce(function (acc, curr, idx) {
120
121
  var name = curr.name,
121
122
  hideContent = curr.hideContent,
@@ -136,12 +137,22 @@ export var renderActionItems = function renderActionItems() {
136
137
  }
137
138
 
138
139
  if (Action) {
140
+ var handleOnClick = function handleOnClick() {
141
+ if (onActionItemClick) {
142
+ onActionItemClick();
143
+ }
144
+
145
+ if (onClick) {
146
+ onClick();
147
+ }
148
+ };
149
+
139
150
  return [].concat(_toConsumableArray(acc), [/*#__PURE__*/React.createElement(Action, _extends({
140
151
  asDropDownItem: asDropDownItems,
141
152
  size: size,
142
153
  key: idx,
143
154
  appearance: appearance,
144
- onClick: onClick
155
+ onClick: handleOnClick
145
156
  }, actionProps))]);
146
157
  }
147
158
 
@@ -1,12 +1,14 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
4
 
4
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
5
+ var _sizeToButtonSpacing, _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
5
6
 
6
7
  import React from 'react';
7
8
  import { css } from '@emotion/core';
8
9
  import { FormattedMessage } from 'react-intl-next';
9
10
  import { SmartLinkSize } from '../../../constants';
11
+ export var sizeToButtonSpacing = (_sizeToButtonSpacing = {}, _defineProperty(_sizeToButtonSpacing, SmartLinkSize.Small, 'none'), _defineProperty(_sizeToButtonSpacing, SmartLinkSize.Medium, 'compact'), _defineProperty(_sizeToButtonSpacing, SmartLinkSize.Large, 'compact'), _defineProperty(_sizeToButtonSpacing, SmartLinkSize.XLarge, 'default'), _sizeToButtonSpacing);
10
12
  export var getFormattedMessage = function getFormattedMessage(message) {
11
13
  if (message) {
12
14
  var descriptor = message.descriptor,
@@ -27,16 +27,23 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
27
27
  var fadeOutTimeoutId = useRef();
28
28
  var fadeInTimeoutId = useRef();
29
29
  var cardOpenTime = useRef();
30
- var mousePos = useRef({
31
- x: 0,
32
- y: 0
33
- });
30
+ var mousePos = useRef();
34
31
  var popupOffset = useRef();
35
32
  var parentSpan = useRef(null);
36
33
  var renderers = useSmartLinkRenderers();
37
34
  var linkState = useLinkState(url);
38
35
  var hoverDisplay = 'card';
39
36
  var invokeMethod = 'mouse_hover';
37
+ var setMousePosition = useCallback(function (event) {
38
+ if (isOpen) {
39
+ return;
40
+ }
41
+
42
+ mousePos.current = {
43
+ x: event.clientX,
44
+ y: event.clientY
45
+ };
46
+ }, [isOpen]);
40
47
  var hideCard = useCallback(function () {
41
48
  //Check its previously open to avoid firing events when moving between the child and hover card components
42
49
  if (isOpen === true && cardOpenTime.current) {
@@ -55,19 +62,22 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
55
62
  return hideCard();
56
63
  }, delay);
57
64
  }, [hideCard]);
58
- var initShowCard = useCallback(function () {
65
+ var initShowCard = useCallback(function (event) {
59
66
  if (fadeOutTimeoutId.current) {
60
67
  clearTimeout(fadeOutTimeoutId.current);
61
- }
68
+ } //Set mouse position in the case it's not already set by onMouseMove, as in the case of scrolling
69
+
62
70
 
71
+ setMousePosition(event);
63
72
  fadeInTimeoutId.current = setTimeout(function () {
64
73
  //Check if its previously closed to avoid firing events when moving between the child and hover card components
65
74
  if (isOpen === false) {
66
75
  cardOpenTime.current = Date.now();
67
76
  analytics.ui.hoverCardViewedEvent(hoverDisplay, invokeMethod);
68
- }
77
+ } //If these are undefined then popupOffset is undefined and we fallback to default bottom-start placement
78
+
69
79
 
70
- if (parentSpan.current) {
80
+ if (parentSpan.current && mousePos.current) {
71
81
  var _parentSpan$current$g = parentSpan.current.getBoundingClientRect(),
72
82
  bottom = _parentSpan$current$g.bottom,
73
83
  left = _parentSpan$current$g.left;
@@ -77,7 +87,7 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
77
87
 
78
88
  setIsOpen(true);
79
89
  }, delay);
80
- }, [delay, isOpen, analytics.ui]);
90
+ }, [isOpen, setMousePosition, analytics.ui]);
81
91
  var linkActions = useSmartLinkActions({
82
92
  url: url,
83
93
  appearance: SMART_CARD_ANALYTICS_DISPLAY,
@@ -87,17 +97,7 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
87
97
  if (actionId === 'preview-content') {
88
98
  hideCard();
89
99
  }
90
- }, [hideCard]);
91
- var setMousePosition = useCallback(function (event) {
92
- if (isOpen) {
93
- return;
94
- }
95
-
96
- mousePos.current = {
97
- x: event.clientX,
98
- y: event.clientY
99
- };
100
- }, [isOpen]); // Stop hover preview content to propagate event to parent.
100
+ }, [hideCard]); // Stop hover preview content to propagate event to parent.
101
101
 
102
102
  var onClick = useCallback(function (e) {
103
103
  return e.stopPropagation();
@@ -108,6 +108,7 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
108
108
  onClose: hideCard,
109
109
  placement: "bottom-start",
110
110
  offset: popupOffset.current,
111
+ autoFocus: false,
111
112
  content: function content(_ref2) {
112
113
  var update = _ref2.update;
113
114
  return jsx("div", {
@@ -0,0 +1,5 @@
1
+ /** @jsx jsx */
2
+ import React from 'react';
3
+ import { ActionButtonProps } from './types';
4
+ declare const ActionButton: React.FC<ActionButtonProps>;
5
+ export default ActionButton;
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { SmartLinkSize } from '../../../../../../constants';
3
+ import { ActionProps } from '../types';
4
+ export declare type ActionButtonProps = ActionProps & {
5
+ iconAfter?: React.ReactChild;
6
+ iconBefore?: React.ReactChild;
7
+ size: SmartLinkSize;
8
+ };
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { ActionDropdownItemProps } from './types';
3
+ declare const ActionDropdownItem: React.FC<ActionDropdownItemProps>;
4
+ export default ActionDropdownItem;
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ export declare type ActionDropdownItemProps = {
3
+ content?: React.ReactNode;
4
+ iconAfter?: React.ReactNode;
5
+ iconBefore?: React.ReactNode;
6
+ onClick: () => any;
7
+ testId?: string;
8
+ };
@@ -0,0 +1,5 @@
1
+ /** @jsx jsx */
2
+ import React from 'react';
3
+ import { ActionIconProps } from './types';
4
+ declare const ActionIcon: React.FC<ActionIconProps>;
5
+ export default ActionIcon;
@@ -0,0 +1,7 @@
1
+ import { ReactChild } from 'react';
2
+ import { SmartLinkSize } from '../../../../../../constants';
3
+ export declare type ActionIconProps = {
4
+ size?: SmartLinkSize;
5
+ icon?: ReactChild;
6
+ testId?: string;
7
+ };
@@ -1,9 +1,6 @@
1
1
  /** @jsx jsx */
2
2
  import React from 'react';
3
- import { Spacing } from '@atlaskit/button';
4
- import { SmartLinkSize } from '../../../../../constants';
5
3
  import { ActionProps } from './types';
6
- export declare const sizeToSpacing: Record<SmartLinkSize, Spacing>;
7
4
  /**
8
5
  * A base action that can be triggered with an on click.
9
6
  * @internal
@@ -46,19 +46,3 @@ export declare type ActionProps = {
46
46
  */
47
47
  testId?: string;
48
48
  };
49
- export declare type ActionIconProps = {
50
- /**
51
- * Determines the size of the Icon within the Action.
52
- */
53
- size?: SmartLinkSize;
54
- /**
55
- * Determines the icon within the Action.
56
- */
57
- icon?: ReactChild;
58
- /**
59
- * A `testId` prop is provided for specified elements, which is a unique
60
- * string that appears as a data attribute `data-testid` in the rendered code,
61
- * serving as a hook for automated tests
62
- */
63
- testId?: string;
64
- };
@@ -9,4 +9,4 @@ export declare const getGapSize: (size: SmartLinkSize) => number;
9
9
  export declare const getBaseStyles: (direction: SmartLinkDirection, size: SmartLinkSize) => SerializedStyles;
10
10
  export declare const renderChildren: (children: React.ReactNode, size: SmartLinkSize) => React.ReactNode;
11
11
  export declare const renderElementItems: (items?: ElementItem[], display?: ElementDisplaySchemaType) => React.ReactNode | undefined;
12
- export declare const renderActionItems: (items?: ActionItem[], size?: SmartLinkSize, appearance?: Appearance | undefined, asDropDownItems?: boolean | undefined) => React.ReactNode | undefined;
12
+ export declare const renderActionItems: (items?: ActionItem[], size?: SmartLinkSize, appearance?: Appearance | undefined, asDropDownItems?: boolean | undefined, onActionItemClick?: (() => void) | undefined) => React.ReactNode | undefined;
@@ -1,7 +1,9 @@
1
1
  /// <reference types="react" />
2
2
  import { SerializedStyles } from '@emotion/core';
3
+ import { Spacing } from '@atlaskit/button';
3
4
  import { SmartLinkSize } from '../../../constants';
4
5
  import { MessageProps } from './types';
6
+ export declare const sizeToButtonSpacing: Record<SmartLinkSize, Spacing>;
5
7
  export declare const getFormattedMessage: (message?: MessageProps | undefined) => JSX.Element | undefined;
6
8
  export declare const getIconSizeStyles: (width: string) => SerializedStyles;
7
9
  export declare const getIconWidth: (size?: SmartLinkSize | undefined) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "21.0.0",
3
+ "version": "21.0.3",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -27,7 +27,7 @@
27
27
  "@atlaskit/avatar": "^21.0.0",
28
28
  "@atlaskit/avatar-group": "^9.0.0",
29
29
  "@atlaskit/button": "^16.3.0",
30
- "@atlaskit/dropdown-menu": "^11.2.0",
30
+ "@atlaskit/dropdown-menu": "^11.3.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",
@@ -36,10 +36,10 @@
36
36
  "@atlaskit/linking-common": "^1.5.0",
37
37
  "@atlaskit/logo": "^13.8.0",
38
38
  "@atlaskit/lozenge": "^11.1.0",
39
- "@atlaskit/media-common": "^2.15.0",
39
+ "@atlaskit/media-common": "^2.16.0",
40
40
  "@atlaskit/modal-dialog": "^12.2.0",
41
41
  "@atlaskit/outbound-auth-flow-client": "^3.3.0",
42
- "@atlaskit/popup": "^1.3.0",
42
+ "@atlaskit/popup": "^1.4.0",
43
43
  "@atlaskit/spinner": "^15.1.0",
44
44
  "@atlaskit/theme": "^12.1.0",
45
45
  "@atlaskit/tokens": "^0.10.0",
@@ -66,6 +66,7 @@
66
66
  "devDependencies": {
67
67
  "@atlaskit/avatar": "^21.0.0",
68
68
  "@atlaskit/checkbox": "^12.3.0",
69
+ "@atlaskit/code": "^14.3.0",
69
70
  "@atlaskit/css-reset": "^6.3.0",
70
71
  "@atlaskit/docs": "*",
71
72
  "@atlaskit/field-base": "^15.0.6",
@@ -78,11 +79,12 @@
78
79
  "@atlaskit/radio": "^5.3.0",
79
80
  "@atlaskit/range": "^6.0.0",
80
81
  "@atlaskit/section-message": "^6.1.5",
81
- "@atlaskit/select": "^15.4.0",
82
+ "@atlaskit/select": "^15.5.0",
82
83
  "@atlaskit/table-tree": "^9.1.0",
83
84
  "@atlaskit/tabs": "^13.2.10",
84
85
  "@atlaskit/textarea": "^4.3.0",
85
86
  "@atlaskit/textfield": "^5.1.0",
87
+ "@atlaskit/toggle": "^12.4.0",
86
88
  "@atlaskit/visual-regression": "*",
87
89
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
88
90
  "@testing-library/jest-dom": "^4.1.0",
@@ -103,6 +105,7 @@
103
105
  "mockdate": "^3.0.2",
104
106
  "react": "^16.8.0",
105
107
  "react-ace": "^6.1.0",
108
+ "react-beautiful-dnd": "^12.1.1",
106
109
  "react-dom": "^16.8.0",
107
110
  "react-intl-next": "npm:react-intl@^5.18.1",
108
111
  "react-test-renderer": "^16.8.0",
package/report.api.md CHANGED
@@ -1,6 +1,8 @@
1
- ## API Report File for "@atlaskit/smart-card"
1
+ ## API Report File for "@atlaskit/smart-card".
2
2
 
3
- > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
3
+ > Do not edit this file. This report is auto-generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ [Learn more about API reports](https://hello.atlassian.net/wiki/spaces/UR/pages/1825484529/Package+API+Reports)
4
6
 
5
7
  ```ts
6
8
  /// <reference types="react" />
@@ -18,6 +20,7 @@ import { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
18
20
  import { EditorCardProvider } from '@atlaskit/link-provider';
19
21
  import { editorCardProvider } from '@atlaskit/link-provider';
20
22
  import { EmbedCardAdf } from '@atlaskit/linking-common';
23
+ import { ErrorInfo } from 'react';
21
24
  import { GasPayload } from '@atlaskit/analytics-gas-types';
22
25
  import { InlineCardAdf } from '@atlaskit/linking-common';
23
26
  import { JsonLd } from 'json-ld-types';
@@ -254,6 +257,7 @@ export declare const Card: React_2.ForwardRefExoticComponent<
254
257
  | 'inheritDimensions'
255
258
  | 'id'
256
259
  | 'placeholder'
260
+ | 'onError'
257
261
  | 'onClick'
258
262
  | 'analyticsContext'
259
263
  | 'key'
@@ -298,6 +302,7 @@ export declare interface CardProps extends WithAnalyticsEventsProps {
298
302
  testId?: string;
299
303
  showActions?: boolean;
300
304
  onResolve?: OnResolveCallback;
305
+ onError?: OnErrorCallback;
301
306
  inheritDimensions?: boolean;
302
307
  embedIframeRef?: React.Ref<HTMLIFrameElement>;
303
308
  inlinePreloaderStyle?: InlinePreloaderStyle;
@@ -488,6 +493,13 @@ export declare class EmbedResizeMessageListener extends React_2.Component<
488
493
  render(): React_2.ReactNode;
489
494
  }
490
495
 
496
+ declare type ErrorCardType =
497
+ | 'errored'
498
+ | 'fallback'
499
+ | 'forbidden'
500
+ | 'not_found'
501
+ | 'unauthorized';
502
+
491
503
  declare type FlexibleUiOptions = {
492
504
  /**
493
505
  * Determines whether the entire Smart Link container should be clickable.
@@ -629,6 +641,11 @@ declare type NamedActionItem = BaseActionItem & {
629
641
  name: Exclude<ActionName, ActionName.CustomAction>;
630
642
  };
631
643
 
644
+ declare type OnErrorCallback = (data: {
645
+ status: Extract<CardType, ErrorCardType>;
646
+ url: string;
647
+ }) => void;
648
+
632
649
  declare type OnResolveCallback = (data: {
633
650
  url?: string;
634
651
  title?: string;
@@ -1060,6 +1077,19 @@ export declare const useSmartLinkAnalytics: (
1060
1077
  definitionId?: string | undefined,
1061
1078
  extensionKey?: string | undefined,
1062
1079
  ) => void;
1080
+ /**
1081
+ * This fires an event that represents when a Smart Link renders unsuccessfuly.
1082
+ * @param display Whether the card was an Inline, Block, Embed or Flexible UI.
1083
+ * @param id The unique ID for this Smart Link.
1084
+ * @param error: An error representing why the Smart Link render failed.
1085
+ * @param errorInfo: Additional details about the error including the stack trace.
1086
+ */
1087
+ renderFailedEvent: (
1088
+ display: CardInnerAppearance,
1089
+ id: string | undefined,
1090
+ error: Error,
1091
+ errorInfo: ErrorInfo,
1092
+ ) => void;
1063
1093
  /**
1064
1094
  * This fires an event that represents a hover preview being opened.
1065
1095
  * @param hoverDisplay Whether the hover preview was displayed as a card or embed.