cozy-ui 68.1.0 → 68.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [68.1.1](https://github.com/cozy/cozy-ui/compare/v68.1.0...v68.1.1) (2022-05-25)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Do not crash if the component does not find the child ([57f296b](https://github.com/cozy/cozy-ui/commit/57f296b))
7
+ * The name "FooterActionButtons" does not exist in the build version ([2d13777](https://github.com/cozy/cozy-ui/commit/2d13777))
8
+
1
9
  # [68.1.0](https://github.com/cozy/cozy-ui/compare/v68.0.1...v68.1.0) (2022-05-24)
2
10
 
3
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "68.1.0",
3
+ "version": "68.1.1",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -9,6 +9,8 @@ const FooterActionButtons = ({ children, file }) => {
9
9
  return mapToAllChildren(children, child => cloneElement(child, { file }))
10
10
  }
11
11
 
12
+ FooterActionButtons.displayName = 'FooterActionButtons'
13
+
12
14
  FooterActionButtons.propTypes = {
13
15
  children: PropTypes.oneOfType([
14
16
  PropTypes.node,
@@ -1,4 +1,4 @@
1
- import React, { useMemo, Children, cloneElement } from 'react'
1
+ import React, { useMemo, Children, cloneElement, isValidElement } from 'react'
2
2
  import PropTypes from 'prop-types'
3
3
  import { makeStyles } from '@material-ui/core/styles'
4
4
 
@@ -27,16 +27,19 @@ const FooterContent = ({ file, toolbarRef, children }) => {
27
27
 
28
28
  const { contactName, isLoadingContacts } = useReferencedContactName(file)
29
29
 
30
- const FooterActionButtons = Children.toArray(children).find(child => {
31
- return (
32
- child.type.name === 'FooterActionButtons' ||
33
- child.type.displayName === 'FooterActionButtons'
34
- )
35
- })
30
+ const FooterActionButtons =
31
+ Children.toArray(children).find(child => {
32
+ return (
33
+ child.type.name === 'FooterActionButtons' ||
34
+ child.type.displayName === 'FooterActionButtons'
35
+ )
36
+ }) || null
36
37
 
37
- const FooterActionButtonsWithFile = cloneElement(FooterActionButtons, {
38
- file
39
- })
38
+ const FooterActionButtonsWithFile = isValidElement(FooterActionButtons)
39
+ ? cloneElement(FooterActionButtons, {
40
+ file
41
+ })
42
+ : null
40
43
 
41
44
  // We have to wait for the Contact request to finish before rendering `BottomSheet`, because it doesn't handle async well.
42
45
  if (isValidForPanel({ file }) && !isLoadingContacts) {
@@ -13,6 +13,7 @@ var FooterActionButtons = function FooterActionButtons(_ref) {
13
13
  });
14
14
  };
15
15
 
16
+ FooterActionButtons.displayName = 'FooterActionButtons';
16
17
  FooterActionButtons.propTypes = {
17
18
  children: PropTypes.oneOfType([PropTypes.node, PropTypes.arrayOf(PropTypes.node)]),
18
19
  file: PropTypes.object
@@ -1,4 +1,4 @@
1
- import React, { useMemo, Children, cloneElement } from 'react';
1
+ import React, { useMemo, Children, cloneElement, isValidElement } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { makeStyles } from '@material-ui/core/styles';
4
4
  import BottomSheet, { BottomSheetHeader } from "cozy-ui/transpiled/react/BottomSheet";
@@ -36,10 +36,10 @@ var FooterContent = function FooterContent(_ref) {
36
36
 
37
37
  var FooterActionButtons = Children.toArray(children).find(function (child) {
38
38
  return child.type.name === 'FooterActionButtons' || child.type.displayName === 'FooterActionButtons';
39
- });
40
- var FooterActionButtonsWithFile = /*#__PURE__*/cloneElement(FooterActionButtons, {
39
+ }) || null;
40
+ var FooterActionButtonsWithFile = /*#__PURE__*/isValidElement(FooterActionButtons) ? /*#__PURE__*/cloneElement(FooterActionButtons, {
41
41
  file: file
42
- }); // We have to wait for the Contact request to finish before rendering `BottomSheet`, because it doesn't handle async well.
42
+ }) : null; // We have to wait for the Contact request to finish before rendering `BottomSheet`, because it doesn't handle async well.
43
43
 
44
44
  if (isValidForPanel({
45
45
  file: file