@atlaskit/smart-card 21.0.4 → 21.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 21.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`fa7f42de6c0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/fa7f42de6c0) - Flexible UI: Add onActionMenuOpenChange on TitleBlock to detect action dropdown menu open/close
8
+
3
9
  ## 21.0.4
4
10
 
5
11
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "21.0.4",
3
+ "version": "21.1.0",
4
4
  "sideEffects": false
5
5
  }
@@ -33,7 +33,7 @@ var _actionGroup = _interopRequireDefault(require("../action-group"));
33
33
 
34
34
  var _elements = require("../../elements");
35
35
 
36
- var _excluded = ["actions", "anchorTarget", "hideTitleTooltip", "maxLines", "onClick", "overrideCss", "status", "showActionOnHover", "testId", "text", "theme"];
36
+ var _excluded = ["actions", "anchorTarget", "hideTitleTooltip", "maxLines", "onActionMenuOpenChange", "onClick", "overrideCss", "status", "showActionOnHover", "testId", "text", "theme"];
37
37
 
38
38
  var _templateObject, _templateObject2;
39
39
 
@@ -85,6 +85,7 @@ var TitleBlock = function TitleBlock(_ref) {
85
85
  anchorTarget = _ref.anchorTarget,
86
86
  hideTitleTooltip = _ref.hideTitleTooltip,
87
87
  maxLines = _ref.maxLines,
88
+ onActionMenuOpenChange = _ref.onActionMenuOpenChange,
88
89
  onClick = _ref.onClick,
89
90
  overrideCss = _ref.overrideCss,
90
91
  _ref$status = _ref.status,
@@ -101,12 +102,20 @@ var TitleBlock = function TitleBlock(_ref) {
101
102
  actionDropdownOpen = _useState2[0],
102
103
  setActionDropdownOpen = _useState2[1];
103
104
 
105
+ var onDropdownOpenChange = (0, _react.useCallback)(function (isOpen) {
106
+ setActionDropdownOpen(isOpen);
107
+
108
+ if (onActionMenuOpenChange) {
109
+ onActionMenuOpenChange({
110
+ isOpen: isOpen
111
+ });
112
+ }
113
+ }, [onActionMenuOpenChange]);
114
+
104
115
  var actionGroup = actions.length > 0 && /*#__PURE__*/_react.default.createElement(_actionGroup.default, {
105
116
  items: actions,
106
117
  visibleButtonsNum: showActionOnHover ? 1 : 2,
107
- onDropdownOpenChange: function onDropdownOpenChange(isOpen) {
108
- return setActionDropdownOpen(isOpen);
109
- }
118
+ onDropdownOpenChange: onDropdownOpenChange
110
119
  });
111
120
 
112
121
  var actionStyles = getActionStyles(showActionOnHover, actionDropdownOpen);
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "21.0.4",
3
+ "version": "21.1.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,5 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import React, { useState } from 'react';
2
+ import React, { useCallback, useState } from 'react';
3
3
  import { css } from '@emotion/core';
4
4
  import { SmartLinkStatus } from '../../../../../constants';
5
5
  import TitleBlockResolvedView from './resolved';
@@ -60,6 +60,7 @@ const TitleBlock = ({
60
60
  anchorTarget,
61
61
  hideTitleTooltip,
62
62
  maxLines,
63
+ onActionMenuOpenChange,
63
64
  onClick,
64
65
  overrideCss,
65
66
  status = SmartLinkStatus.Fallback,
@@ -70,10 +71,19 @@ const TitleBlock = ({
70
71
  ...props
71
72
  }) => {
72
73
  const [actionDropdownOpen, setActionDropdownOpen] = useState(false);
74
+ const onDropdownOpenChange = useCallback(isOpen => {
75
+ setActionDropdownOpen(isOpen);
76
+
77
+ if (onActionMenuOpenChange) {
78
+ onActionMenuOpenChange({
79
+ isOpen
80
+ });
81
+ }
82
+ }, [onActionMenuOpenChange]);
73
83
  const actionGroup = actions.length > 0 && /*#__PURE__*/React.createElement(ActionGroup, {
74
84
  items: actions,
75
85
  visibleButtonsNum: showActionOnHover ? 1 : 2,
76
- onDropdownOpenChange: isOpen => setActionDropdownOpen(isOpen)
86
+ onDropdownOpenChange: onDropdownOpenChange
77
87
  });
78
88
  const actionStyles = getActionStyles(showActionOnHover, actionDropdownOpen);
79
89
  const combinedCss = css`
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "21.0.4",
3
+ "version": "21.1.0",
4
4
  "sideEffects": false
5
5
  }
@@ -2,11 +2,11 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
4
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
5
- var _excluded = ["actions", "anchorTarget", "hideTitleTooltip", "maxLines", "onClick", "overrideCss", "status", "showActionOnHover", "testId", "text", "theme"];
5
+ var _excluded = ["actions", "anchorTarget", "hideTitleTooltip", "maxLines", "onActionMenuOpenChange", "onClick", "overrideCss", "status", "showActionOnHover", "testId", "text", "theme"];
6
6
 
7
7
  var _templateObject, _templateObject2;
8
8
 
9
- import React, { useState } from 'react';
9
+ import React, { useCallback, useState } from 'react';
10
10
  import { css } from '@emotion/core';
11
11
  import { SmartLinkStatus } from '../../../../../constants';
12
12
  import TitleBlockResolvedView from './resolved';
@@ -59,6 +59,7 @@ var TitleBlock = function TitleBlock(_ref) {
59
59
  anchorTarget = _ref.anchorTarget,
60
60
  hideTitleTooltip = _ref.hideTitleTooltip,
61
61
  maxLines = _ref.maxLines,
62
+ onActionMenuOpenChange = _ref.onActionMenuOpenChange,
62
63
  onClick = _ref.onClick,
63
64
  overrideCss = _ref.overrideCss,
64
65
  _ref$status = _ref.status,
@@ -75,12 +76,19 @@ var TitleBlock = function TitleBlock(_ref) {
75
76
  actionDropdownOpen = _useState2[0],
76
77
  setActionDropdownOpen = _useState2[1];
77
78
 
79
+ var onDropdownOpenChange = useCallback(function (isOpen) {
80
+ setActionDropdownOpen(isOpen);
81
+
82
+ if (onActionMenuOpenChange) {
83
+ onActionMenuOpenChange({
84
+ isOpen: isOpen
85
+ });
86
+ }
87
+ }, [onActionMenuOpenChange]);
78
88
  var actionGroup = actions.length > 0 && /*#__PURE__*/React.createElement(ActionGroup, {
79
89
  items: actions,
80
90
  visibleButtonsNum: showActionOnHover ? 1 : 2,
81
- onDropdownOpenChange: function onDropdownOpenChange(isOpen) {
82
- return setActionDropdownOpen(isOpen);
83
- }
91
+ onDropdownOpenChange: onDropdownOpenChange
84
92
  });
85
93
  var actionStyles = getActionStyles(showActionOnHover, actionDropdownOpen);
86
94
  var combinedCss = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", " ", "\n "])), actionStyles, overrideCss);
@@ -18,5 +18,5 @@ export { contentFooterClassName, metadataListClassName, blockCardResolvingViewCl
18
18
  export { loadingPlaceholderClassName } from './view/CardWithUrl/component-lazy/LazyFallback';
19
19
  export { ActionName, ElementName, SmartLinkDirection, SmartLinkPosition, SmartLinkSize, SmartLinkTheme, } from './constants';
20
20
  export { MetadataBlock, PreviewBlock, SnippetBlock, TitleBlock, FooterBlock, } from './view/FlexibleCard/components/blocks';
21
- export type { ActionItem, ElementItem, } from './view/FlexibleCard/components/blocks/types';
21
+ export type { ActionItem, ElementItem, OnActionMenuOpenChangeOptions, } from './view/FlexibleCard/components/blocks/types';
22
22
  export type { AnalyticsAction, AnalyticsActionSubject, AnalyticsPayload, AnalyticsHandler, } from './utils/types';
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { ActionItem, BlockProps, ElementItem } from '../types';
2
+ import { ActionItem, BlockProps, ElementItem, OnActionMenuOpenChangeOptions } from '../types';
3
3
  import { SmartLinkPosition, SmartLinkTheme } from '../../../../../constants';
4
4
  import { RetryOptions } from '../../../types';
5
5
  import { AnchorTarget } from '../../types';
@@ -34,6 +34,11 @@ export declare type TitleBlockProps = {
34
34
  * @see ElementItem
35
35
  */
36
36
  metadata?: ElementItem[];
37
+ /**
38
+ * Called when the action dropdown menu (if present) is open/closed.
39
+ * Receives an object with `isOpen` state.
40
+ */
41
+ onActionMenuOpenChange?: (options: OnActionMenuOpenChangeOptions) => void;
37
42
  /**
38
43
  * Determines the position of the link icon in relative to the vertical
39
44
  * height of the TitleBlock. It can either be centred or placed on “top”.
@@ -100,6 +100,9 @@ export declare type CustomActionItem = BaseActionItem & {
100
100
  name: ActionName.CustomAction;
101
101
  } & ((Required<Pick<ActionProps, 'icon' | 'iconPosition'>> & Pick<ActionProps, 'content'>) | ((Required<Pick<ActionProps, 'content'>> & Pick<ActionProps, 'icon' | 'iconPosition'>) & Pick<ActionProps, 'tooltipMessage'>));
102
102
  export declare type ActionItem = NamedActionItem | CustomActionItem;
103
+ export declare type OnActionMenuOpenChangeOptions = {
104
+ isOpen: boolean;
105
+ };
103
106
  /**
104
107
  * A type that contains all the possible combinations of elements with their corresponding props.
105
108
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "21.0.4",
3
+ "version": "21.1.0",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -79,7 +79,7 @@
79
79
  "@atlaskit/radio": "^5.3.0",
80
80
  "@atlaskit/range": "^6.0.0",
81
81
  "@atlaskit/section-message": "^6.1.5",
82
- "@atlaskit/select": "^15.5.0",
82
+ "@atlaskit/select": "^15.6.0",
83
83
  "@atlaskit/table-tree": "^9.1.0",
84
84
  "@atlaskit/tabs": "^13.2.10",
85
85
  "@atlaskit/textarea": "^4.3.0",
package/report.api.md CHANGED
@@ -641,6 +641,10 @@ declare type NamedActionItem = BaseActionItem & {
641
641
  name: Exclude<ActionName, ActionName.CustomAction>;
642
642
  };
643
643
 
644
+ export declare type OnActionMenuOpenChangeOptions = {
645
+ isOpen: boolean;
646
+ };
647
+
644
648
  declare type OnErrorCallback = (data: {
645
649
  status: Extract<CardType, ErrorCardType>;
646
650
  url: string;
@@ -911,6 +915,11 @@ declare type TitleBlockProps = {
911
915
  * @see ElementItem
912
916
  */
913
917
  metadata?: ElementItem[];
918
+ /**
919
+ * Called when the action dropdown menu (if present) is open/closed.
920
+ * Receives an object with `isOpen` state.
921
+ */
922
+ onActionMenuOpenChange?: (options: OnActionMenuOpenChangeOptions) => void;
914
923
  /**
915
924
  * Determines the position of the link icon in relative to the vertical
916
925
  * height of the TitleBlock. It can either be centred or placed on “top”.