@atlaskit/smart-card 35.2.6 → 35.2.7

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,13 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 35.2.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [#124162](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/124162)
8
+ [`92012b0d9a1f2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/92012b0d9a1f2) -
9
+ Add new recursive title block finder function for compiled css tests
10
+
3
11
  ## 35.2.6
4
12
 
5
13
  ### Patch Changes
@@ -11,7 +11,7 @@ var ANALYTICS_CHANNEL = exports.ANALYTICS_CHANNEL = 'media';
11
11
  var context = exports.context = {
12
12
  componentName: 'smart-cards',
13
13
  packageName: "@atlaskit/smart-card",
14
- packageVersion: "35.2.6"
14
+ packageVersion: "35.2.7"
15
15
  };
16
16
  var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
17
17
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -13,6 +13,7 @@ Object.defineProperty(exports, "getContainerStyles", {
13
13
  return _indexOld.getContainerStyles;
14
14
  }
15
15
  });
16
+ exports.getFlexibleUiBlock = void 0;
16
17
  require("./index.compiled.css");
17
18
  var _runtime = require("@compiled/react/runtime");
18
19
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
@@ -25,6 +26,7 @@ var _constants = require("../../../../constants");
25
26
  var _flexibleUiContext = require("../../../../state/flexible-ui-context");
26
27
  var _utils = require("../../../../state/flexible-ui-context/utils");
27
28
  var _flexible = require("../../../../utils/flexible");
29
+ var _blocks = require("../blocks");
28
30
  var _hoverCardControl = _interopRequireDefault(require("./hover-card-control"));
29
31
  var _indexOld = _interopRequireWildcard(require("./indexOld"));
30
32
  var _layeredLink = _interopRequireDefault(require("./layered-link"));
@@ -112,10 +114,39 @@ var updateChildren = function updateChildren(node, _ref) {
112
114
  children: updatedChildren
113
115
  });
114
116
  };
117
+
118
+ /**
119
+ * Note: This function is only necessary for CompiledCSS within Jest tests due to the way it handles Styles.
120
+ * CompiledCSS will inject a StyleCacheProvider around the component tree, which
121
+ * causes the children to be wrapped in a StyleCacheProvider as well. This function recursively
122
+ * searches for the first valid TitleBlock within the children of the StyleCacheProvider.
123
+ */
124
+ var _getFlexibleUiBlock = exports.getFlexibleUiBlock = function getFlexibleUiBlock(node) {
125
+ if (! /*#__PURE__*/_react.default.isValidElement(node)) {
126
+ return undefined;
127
+ }
128
+ if (node.type === _blocks.TitleBlock) {
129
+ return node;
130
+ }
131
+ if ((0, _flexible.isStyleCacheProvider)(node)) {
132
+ // Component wrapped with compiled at runtime, check for children
133
+ var isChildrenValid;
134
+ _react.default.Children.map(node.props.children, function (child) {
135
+ var _child$type;
136
+ if (typeof child.type !== 'string' && ((_child$type = child.type) === null || _child$type === void 0 ? void 0 : _child$type.name) !== 'Style') {
137
+ isChildrenValid = _getFlexibleUiBlock(child);
138
+ }
139
+ });
140
+ return isChildrenValid;
141
+ }
142
+ return undefined;
143
+ };
115
144
  var getTitleBlockProps = function getTitleBlockProps(children) {
116
- var block = _react.default.Children.toArray(children).find(function (child) {
117
- return (0, _flexible.isFlexibleUiTitleBlock)(child);
118
- });
145
+ var block = _react.default.Children.toArray(children).map(function (child) {
146
+ return _getFlexibleUiBlock(child);
147
+ }).filter(function (x) {
148
+ return x !== undefined;
149
+ }).at(0);
119
150
  if ( /*#__PURE__*/_react.default.isValidElement(block)) {
120
151
  return block.props;
121
152
  }
@@ -20,7 +20,7 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId", "isLink
20
20
  _excluded2 = ["isLinkSafe", "showSafetyWarningModal"];
21
21
  var PACKAGE_DATA = {
22
22
  packageName: "@atlaskit/smart-card",
23
- packageVersion: "35.2.6",
23
+ packageVersion: "35.2.7",
24
24
  componentName: 'linkUrl'
25
25
  };
26
26
  var Anchor = (0, _click.withLinkClickedEvent)('a');
@@ -2,7 +2,7 @@ export const ANALYTICS_CHANNEL = 'media';
2
2
  export const context = {
3
3
  componentName: 'smart-cards',
4
4
  packageName: "@atlaskit/smart-card",
5
- packageVersion: "35.2.6"
5
+ packageVersion: "35.2.7"
6
6
  };
7
7
  export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
8
8
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -11,6 +11,7 @@ import { MediaPlacement, SmartLinkSize, SmartLinkTheme } from '../../../../const
11
11
  import { FlexibleUiContext } from '../../../../state/flexible-ui-context';
12
12
  import { isFlexUiPreviewPresent } from '../../../../state/flexible-ui-context/utils';
13
13
  import { isFlexibleUiBlock, isFlexibleUiPreviewBlock, isFlexibleUiTitleBlock, isStyleCacheProvider } from '../../../../utils/flexible';
14
+ import { TitleBlock } from '../blocks';
14
15
  import HoverCardControl from './hover-card-control';
15
16
  import ContainerOld from './indexOld';
16
17
  import LayeredLink from './layered-link';
@@ -101,8 +102,35 @@ const updateChildren = (node, {
101
102
  children: updatedChildren
102
103
  });
103
104
  };
105
+
106
+ /**
107
+ * Note: This function is only necessary for CompiledCSS within Jest tests due to the way it handles Styles.
108
+ * CompiledCSS will inject a StyleCacheProvider around the component tree, which
109
+ * causes the children to be wrapped in a StyleCacheProvider as well. This function recursively
110
+ * searches for the first valid TitleBlock within the children of the StyleCacheProvider.
111
+ */
112
+ export const getFlexibleUiBlock = node => {
113
+ if (! /*#__PURE__*/React.isValidElement(node)) {
114
+ return undefined;
115
+ }
116
+ if (node.type === TitleBlock) {
117
+ return node;
118
+ }
119
+ if (isStyleCacheProvider(node)) {
120
+ // Component wrapped with compiled at runtime, check for children
121
+ let isChildrenValid;
122
+ React.Children.map(node.props.children, child => {
123
+ var _child$type;
124
+ if (typeof child.type !== 'string' && ((_child$type = child.type) === null || _child$type === void 0 ? void 0 : _child$type.name) !== 'Style') {
125
+ isChildrenValid = getFlexibleUiBlock(child);
126
+ }
127
+ });
128
+ return isChildrenValid;
129
+ }
130
+ return undefined;
131
+ };
104
132
  const getTitleBlockProps = children => {
105
- const block = React.Children.toArray(children).find(child => isFlexibleUiTitleBlock(child));
133
+ const block = React.Children.toArray(children).map(child => getFlexibleUiBlock(child)).filter(x => x !== undefined).at(0);
106
134
  if ( /*#__PURE__*/React.isValidElement(block)) {
107
135
  return block.props;
108
136
  }
@@ -10,7 +10,7 @@ import LinkWarningModal from './LinkWarningModal';
10
10
  import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
11
11
  const PACKAGE_DATA = {
12
12
  packageName: "@atlaskit/smart-card",
13
- packageVersion: "35.2.6",
13
+ packageVersion: "35.2.7",
14
14
  componentName: 'linkUrl'
15
15
  };
16
16
  const Anchor = withLinkClickedEvent('a');
@@ -4,7 +4,7 @@ export var ANALYTICS_CHANNEL = 'media';
4
4
  export var context = {
5
5
  componentName: 'smart-cards',
6
6
  packageName: "@atlaskit/smart-card",
7
- packageVersion: "35.2.6"
7
+ packageVersion: "35.2.7"
8
8
  };
9
9
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
10
10
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -17,6 +17,7 @@ import { MediaPlacement, SmartLinkSize, SmartLinkTheme } from '../../../../const
17
17
  import { FlexibleUiContext } from '../../../../state/flexible-ui-context';
18
18
  import { isFlexUiPreviewPresent } from '../../../../state/flexible-ui-context/utils';
19
19
  import { isFlexibleUiBlock, isFlexibleUiPreviewBlock, isFlexibleUiTitleBlock, isStyleCacheProvider } from '../../../../utils/flexible';
20
+ import { TitleBlock } from '../blocks';
20
21
  import HoverCardControl from './hover-card-control';
21
22
  import ContainerOld from './indexOld';
22
23
  import LayeredLink from './layered-link';
@@ -98,10 +99,40 @@ var updateChildren = function updateChildren(node, _ref) {
98
99
  children: updatedChildren
99
100
  });
100
101
  };
102
+
103
+ /**
104
+ * Note: This function is only necessary for CompiledCSS within Jest tests due to the way it handles Styles.
105
+ * CompiledCSS will inject a StyleCacheProvider around the component tree, which
106
+ * causes the children to be wrapped in a StyleCacheProvider as well. This function recursively
107
+ * searches for the first valid TitleBlock within the children of the StyleCacheProvider.
108
+ */
109
+ var _getFlexibleUiBlock = function getFlexibleUiBlock(node) {
110
+ if (! /*#__PURE__*/React.isValidElement(node)) {
111
+ return undefined;
112
+ }
113
+ if (node.type === TitleBlock) {
114
+ return node;
115
+ }
116
+ if (isStyleCacheProvider(node)) {
117
+ // Component wrapped with compiled at runtime, check for children
118
+ var isChildrenValid;
119
+ React.Children.map(node.props.children, function (child) {
120
+ var _child$type;
121
+ if (typeof child.type !== 'string' && ((_child$type = child.type) === null || _child$type === void 0 ? void 0 : _child$type.name) !== 'Style') {
122
+ isChildrenValid = _getFlexibleUiBlock(child);
123
+ }
124
+ });
125
+ return isChildrenValid;
126
+ }
127
+ return undefined;
128
+ };
129
+ export { _getFlexibleUiBlock as getFlexibleUiBlock };
101
130
  var getTitleBlockProps = function getTitleBlockProps(children) {
102
- var block = React.Children.toArray(children).find(function (child) {
103
- return isFlexibleUiTitleBlock(child);
104
- });
131
+ var block = React.Children.toArray(children).map(function (child) {
132
+ return _getFlexibleUiBlock(child);
133
+ }).filter(function (x) {
134
+ return x !== undefined;
135
+ }).at(0);
105
136
  if ( /*#__PURE__*/React.isValidElement(block)) {
106
137
  return block.props;
107
138
  }
@@ -13,7 +13,7 @@ import LinkWarningModal from './LinkWarningModal';
13
13
  import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
14
14
  var PACKAGE_DATA = {
15
15
  packageName: "@atlaskit/smart-card",
16
- packageVersion: "35.2.6",
16
+ packageVersion: "35.2.7",
17
17
  componentName: 'linkUrl'
18
18
  };
19
19
  var Anchor = withLinkClickedEvent('a');
@@ -10,5 +10,12 @@ import { type ChildrenOptions, type ContainerProps } from './types';
10
10
  */
11
11
  export { getContainerStyles } from './indexOld';
12
12
  export declare const getChildrenOptions: (children: React.ReactNode, context?: FlexibleUiDataContext) => ChildrenOptions;
13
+ /**
14
+ * Note: This function is only necessary for CompiledCSS within Jest tests due to the way it handles Styles.
15
+ * CompiledCSS will inject a StyleCacheProvider around the component tree, which
16
+ * causes the children to be wrapped in a StyleCacheProvider as well. This function recursively
17
+ * searches for the first valid TitleBlock within the children of the StyleCacheProvider.
18
+ */
19
+ export declare const getFlexibleUiBlock: (node: React.ReactNode) => React.ReactNode | undefined;
13
20
  declare const Container: (props: ContainerProps) => JSX.Element;
14
21
  export default Container;
@@ -10,5 +10,12 @@ import { type ChildrenOptions, type ContainerProps } from './types';
10
10
  */
11
11
  export { getContainerStyles } from './indexOld';
12
12
  export declare const getChildrenOptions: (children: React.ReactNode, context?: FlexibleUiDataContext) => ChildrenOptions;
13
+ /**
14
+ * Note: This function is only necessary for CompiledCSS within Jest tests due to the way it handles Styles.
15
+ * CompiledCSS will inject a StyleCacheProvider around the component tree, which
16
+ * causes the children to be wrapped in a StyleCacheProvider as well. This function recursively
17
+ * searches for the first valid TitleBlock within the children of the StyleCacheProvider.
18
+ */
19
+ export declare const getFlexibleUiBlock: (node: React.ReactNode) => React.ReactNode | undefined;
13
20
  declare const Container: (props: ContainerProps) => JSX.Element;
14
21
  export default Container;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "35.2.6",
3
+ "version": "35.2.7",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"