cozy-ui 84.0.0 → 84.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,28 @@
1
+ ## [84.1.1](https://github.com/cozy/cozy-ui/compare/v84.1.0...v84.1.1) (2023-04-27)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * use includes() not startsWith() in animation ([3c71bc6](https://github.com/cozy/cozy-ui/commit/3c71bc6))
7
+
8
+ # [84.1.0](https://github.com/cozy/cozy-ui/compare/v84.0.0...v84.1.0) (2023-04-27)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **ActionsMenuWrapper:** Use now React.isValidElement on children and... ([68c5b60](https://github.com/cozy/cozy-ui/commit/68c5b60))
14
+ * **ListItem:** LastChild should be undefined in some case without crash ([0686bb3](https://github.com/cozy/cozy-ui/commit/0686bb3))
15
+
16
+
17
+ ### Features
18
+
19
+ * **ActionsItems:** Rename prop `isEnabled` in `disabled` ([f4bcb0f](https://github.com/cozy/cozy-ui/commit/f4bcb0f))
20
+ * **ActionsMenuItem:** Force `ellipsis` [secure] on MenuItem and ListItem ([8a1725e](https://github.com/cozy/cozy-ui/commit/8a1725e))
21
+ * **ActionsMenuItem:** Set `ellipsis` to [secure] for ListItem chlidren ([cacf53c](https://github.com/cozy/cozy-ui/commit/cacf53c))
22
+ * **ListItem:** Add `ellipsis` prop to set ListItemText ellipsis ([135ef2a](https://github.com/cozy/cozy-ui/commit/135ef2a))
23
+ * **MenuItem:** Change maxWidth and whiteSpace ([e845f10](https://github.com/cozy/cozy-ui/commit/e845f10))
24
+ * **MenuItem:** Use ListItem from cozy-ui and not from Mui ([607315f](https://github.com/cozy/cozy-ui/commit/607315f))
25
+
1
26
  # [84.0.0](https://github.com/cozy/cozy-ui/compare/v83.4.0...v84.0.0) (2023-04-26)
2
27
 
3
28
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "84.0.0",
3
+ "version": "84.1.1",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -18,7 +18,7 @@ const ActionsItems = forwardRef(
18
18
  const actionName = getActionName(actionObject)
19
19
  const actionDefinition = Object.values(actionObject)[0]
20
20
 
21
- const { Component: ActionComponent, action, isEnabled } = actionDefinition
21
+ const { Component: ActionComponent, action, disabled } = actionDefinition
22
22
 
23
23
  const handleClick = () => {
24
24
  action && action(doc, { client, t, isLast })
@@ -31,8 +31,8 @@ const ActionsItems = forwardRef(
31
31
  {...props}
32
32
  ref={ref}
33
33
  key={actionName + idx}
34
- isEnabled={isEnabled}
35
34
  doc={doc}
35
+ disabled={disabled}
36
36
  onClick={handleClick}
37
37
  />
38
38
  )
@@ -7,7 +7,7 @@ import ListItem from 'cozy-ui/transpiled/react/MuiCozyTheme/ListItem'
7
7
  const ActionsMenuItem = forwardRef(({ isListItem, ...props }, ref) => {
8
8
  const Component = isListItem ? ListItem : MenuItem
9
9
 
10
- return <Component {...props} ref={ref} button />
10
+ return <Component {...props} ref={ref} button ellipsis={false} />
11
11
  })
12
12
 
13
13
  ActionsMenuItem.propTypes = {
@@ -8,7 +8,13 @@ import isTesting from '../helpers/isTesting'
8
8
  import Paper from '../Paper'
9
9
  import { useActionMenuEffects } from '../ActionMenu/ActionMenuEffects'
10
10
 
11
- const ActionsMenuWrapper = ({ children, autoClose, onClose, ...props }) => {
11
+ const ActionsMenuWrapper = ({
12
+ children,
13
+ autoClose,
14
+ open,
15
+ onClose,
16
+ ...props
17
+ }) => {
12
18
  const { isMobile } = useBreakpoints()
13
19
 
14
20
  useActionMenuEffects()
@@ -18,16 +24,18 @@ const ActionsMenuWrapper = ({ children, autoClose, onClose, ...props }) => {
18
24
  autoClose && onClose?.()
19
25
  }
20
26
 
21
- if (isMobile) {
27
+ if (isMobile && open) {
22
28
  return (
23
29
  <BottomSheet skipAnimation={isTesting()} backdrop onClose={onClose}>
24
30
  <Paper square>
25
31
  {React.Children.map(children, child =>
26
- React.cloneElement(child, {
27
- isListItem: true,
28
- size: 'small',
29
- onClick: overrideClick(child.props)
30
- })
32
+ React.isValidElement(child)
33
+ ? React.cloneElement(child, {
34
+ isListItem: true,
35
+ size: 'small',
36
+ onClick: overrideClick(child.props)
37
+ })
38
+ : null
31
39
  )}
32
40
  </Paper>
33
41
  </BottomSheet>
@@ -35,11 +43,13 @@ const ActionsMenuWrapper = ({ children, autoClose, onClose, ...props }) => {
35
43
  }
36
44
 
37
45
  return (
38
- <Menu {...props} onClose={onClose}>
46
+ <Menu {...props} open={open} onClose={onClose}>
39
47
  {React.Children.map(children, child =>
40
- React.cloneElement(child, {
41
- onClick: overrideClick(child.props)
42
- })
48
+ React.isValidElement(child)
49
+ ? React.cloneElement(child, {
50
+ onClick: overrideClick(child.props)
51
+ })
52
+ : null
43
53
  )}
44
54
  </Menu>
45
55
  )
@@ -6,7 +6,16 @@ A header `ActionsMenuMobileHeader` can be used to provide context on the menu ac
6
6
 
7
7
  ### With an automatic creation of actions
8
8
 
9
- Use `makeActions` method and create (or use the predefined actions) to build the actions to pass to `ActionsMenu` high level component.
9
+ Use `makeActions` method and create (or use the predefined actions) to build the actions to pass to `ActionsMenu` high level component. The method `makeActions` takes `actions` array as first argument, and `options` as second argument. `options` are then passed to the `actions` component as `props`.
10
+
11
+ ```bash
12
+ const action1 = ({ option1, option2 }) => ({
13
+ name: action1,
14
+ Component: props => <SomeComponent {...props} />
15
+ })
16
+
17
+ const actions = makeActions([action1, action2], { option1, option2 })
18
+ ```
10
19
 
11
20
  #### How to create actions
12
21
 
@@ -14,13 +23,14 @@ An action is a simple function that returns an object with specific keys:
14
23
 
15
24
  * **name** : `<string>` – Action's name
16
25
  * **action** : `<func>` – Method triggered when clicking the action
17
- * **isEnabled** : `<bool>` – Used to add `disable` effect (the action is still displayed)
26
+ * **disabled** : `<bool>` – Used to add `disable` effect (the action is still displayed)
18
27
  * **Component** : `<func>` – The returned component that manages the display
19
28
 
20
29
  ```bash
21
- const expl = () => ({
30
+ const expl = makeActionOptions => ({
22
31
  name: 'expl',
23
32
  action: () => {},
33
+ disabled: false,
24
34
  Component: props => {
25
35
  return <SomeComponent {...props} />
26
36
  }
@@ -65,7 +75,7 @@ const customAction = () => ({
65
75
  <ListItemIcon>
66
76
  <Icon icon={FileIcon} />
67
77
  </ListItemIcon>
68
- <ListItemText primary="This is a custom action" />
78
+ <ListItemText primary="This is a custom action, with a very long text to show how it is displayed" />
69
79
  </ActionsMenuItem>
70
80
  )
71
81
  })
@@ -84,27 +94,25 @@ const actions = makeActions([ modify, viewInContacts, divider, call, smsTo, emai
84
94
  >
85
95
  Show action menu
86
96
  </DropdownButton>
87
- {state.showMenu && (
88
- <ActionsMenu
89
- ref={anchorRef}
90
- open={state.showMenu}
91
- doc={doc}
92
- actions={actions}
93
- anchorOrigin={{
94
- vertical: 'bottom',
95
- horizontal: 'left'
96
- }}
97
- autoClose
98
- onClose={hideMenu}
99
- >
100
- <ActionsMenuMobileHeader>
101
- <ListItemIcon>
102
- <Icon icon={FileTypeText} size={32} />
103
- </ListItemIcon>
104
- <ListItemText primary="Title" primaryTypographyProps={{ variant: 'h6' }} />
105
- </ActionsMenuMobileHeader>
106
- </ActionsMenu>
107
- )}
97
+ <ActionsMenu
98
+ ref={anchorRef}
99
+ open={state.showMenu}
100
+ doc={doc}
101
+ actions={actions}
102
+ anchorOrigin={{
103
+ vertical: 'bottom',
104
+ horizontal: 'left'
105
+ }}
106
+ autoClose
107
+ onClose={hideMenu}
108
+ >
109
+ <ActionsMenuMobileHeader>
110
+ <ListItemIcon>
111
+ <Icon icon={FileTypeText} size={32} />
112
+ </ListItemIcon>
113
+ <ListItemText primary="Title" primaryTypographyProps={{ variant: 'h6' }} />
114
+ </ActionsMenuMobileHeader>
115
+ </ActionsMenu>
108
116
  </DemoProvider>
109
117
  ```
110
118
 
@@ -1,3 +1,16 @@
1
+ import React, { forwardRef } from 'react'
1
2
  import MuiMenuItem from '@material-ui/core/MenuItem'
2
3
 
3
- export default MuiMenuItem
4
+ import ListItem, { LitItemPropTypes } from '../MuiCozyTheme/ListItem'
5
+
6
+ const MenuItem = forwardRef((props, ref) => {
7
+ return (
8
+ <MuiMenuItem ref={ref} component={ListItem} gutters="disabled" {...props} />
9
+ )
10
+ })
11
+
12
+ MenuItem.displayName = 'MenuItem'
13
+
14
+ MenuItem.propTypes = LitItemPropTypes
15
+
16
+ export default MenuItem
@@ -30,7 +30,8 @@ const initialVariants = [{
30
30
  smallIcons: false,
31
31
  multipleLeftIcons: false,
32
32
  multipleRightIcons: false,
33
- withActions: false
33
+ withActions: false,
34
+ ellipsis: true
34
35
  }]
35
36
 
36
37
  ;
@@ -39,14 +40,15 @@ const initialVariants = [{
39
40
  {variant => {
40
41
  const gutters = variant.disabledGutters ? 'disabled' : variant.doubleGutters ? 'double' : 'default'
41
42
  const size = variant.small ? 'small' : variant.large ? 'large' : 'medium'
42
- const props = { gutters, size }
43
+ const listItemProps = { gutters, size, ellipsis: variant.ellipsis }
44
+
43
45
  const iconSize = variant.smallIcons ? 8 : variant.bigIcons ? 32 : 16
44
46
  const text = variant.longText ? content.ada.short : "I'm a primary text"
45
47
 
46
48
  return (
47
49
  <>
48
50
  <List dense={variant.dense} subheader={<ListSubheader>Section 1</ListSubheader>}>
49
- <ListItem {...props} button>
51
+ <ListItem {...listItemProps} button>
50
52
  <ListItemIcon>
51
53
  <Icon icon={CommentIcon} size={iconSize} />
52
54
  </ListItemIcon>
@@ -44,9 +44,9 @@ const useGutters = ({ gutters, ...props }) => {
44
44
  const guttersValue = gutters === 'double' ? 32 : 16
45
45
 
46
46
  const lastChild = getLastChild(props)
47
- const isLastChildListItemIcon = getComponentName(lastChild).includes(
48
- 'ListItemIcon'
49
- )
47
+ const isLastChildListItemIcon = lastChild
48
+ ? getComponentName(lastChild).includes('ListItemIcon')
49
+ : false
50
50
 
51
51
  const gutterRight = isLastChildListItemIcon ? guttersValue - 8 : guttersValue
52
52
 
@@ -54,7 +54,8 @@ const useGutters = ({ gutters, ...props }) => {
54
54
  }
55
55
 
56
56
  // Add margin on ListItemSecondaryAction when gutters are double
57
- const useOverridenChildren = ({ gutters, ...props }) => {
57
+ // Propagates ellipsis prop to ListItemText
58
+ const useOverridenChildren = ({ gutters, ellipsis, ...props }) => {
58
59
  const children = getChildren(props)
59
60
  const childrenCount = getChildrenCount(props)
60
61
 
@@ -62,12 +63,18 @@ const useOverridenChildren = ({ gutters, ...props }) => {
62
63
  const isLastChild = index === childrenCount - 1
63
64
  const isSecondaryAction =
64
65
  (isLastChild && isMuiElement(child, ['ListItemSecondaryAction'])) || false
66
+ const isListItemText = getComponentName(child).includes('ListItemText')
65
67
 
66
68
  if (isSecondaryAction && gutters === 'double') {
67
69
  return React.cloneElement(child, {
68
70
  className: `${child.props.className} u-mr-1`
69
71
  })
70
72
  }
73
+
74
+ if (isListItemText) {
75
+ return React.cloneElement(child, { ellipsis })
76
+ }
77
+
71
78
  return child
72
79
  })
73
80
  }
@@ -99,9 +106,12 @@ ListItem.defaultProps = {
99
106
  size: 'medium'
100
107
  }
101
108
 
102
- ListItem.propTypes = {
109
+ export const LitItemPropTypes = {
103
110
  gutters: PropTypes.oneOf(['disabled', 'double', 'default']),
104
- size: PropTypes.oneOf(['small', 'medium', 'large'])
111
+ size: PropTypes.oneOf(['small', 'medium', 'large']),
112
+ ellipsis: PropTypes.bool
105
113
  }
106
114
 
115
+ ListItem.propTypes = LitItemPropTypes
116
+
107
117
  export default ListItem
@@ -561,7 +561,9 @@ const makeOverrides = theme => ({
561
561
  MuiMenuItem: {
562
562
  root: {
563
563
  gap: 8,
564
- minWidth: 256,
564
+ maxWidth: 320,
565
+ whiteSpace: 'normal',
566
+ overflow: 'auto',
565
567
  paddingTop: 4,
566
568
  paddingBottom: 4
567
569
  },
@@ -78,7 +78,7 @@ export const SquareAppIcon = ({
78
78
  const [animationState, setAnimationState] = useState()
79
79
 
80
80
  const handleAnimationEnd = e => {
81
- if (e.animationName.startsWith('end')) setAnimationState()
81
+ if (e.animationName.includes('end')) setAnimationState()
82
82
  }
83
83
 
84
84
  useEffect(() => {
@@ -6,16 +6,20 @@ export const getComponentName = component => {
6
6
  }
7
7
 
8
8
  export const getChildren = props => {
9
- return Children.toArray(props.children)
9
+ const children = Children.toArray(props.children)
10
+ return Children.count(children) > 0 ? children : null
10
11
  }
11
12
 
12
13
  export const getChildrenCount = props => {
13
14
  const children = getChildren(props)
14
- return children.length
15
+ return Children.count(children) || null
15
16
  }
16
17
 
17
18
  export const getLastChild = props => {
18
19
  const children = getChildren(props)
20
+
21
+ if (!children) return null
22
+
19
23
  const lastChild = children[children.length - 1]
20
24
 
21
25
  return lastChild.type === Fragment
@@ -27,7 +27,7 @@ var ActionsItems = /*#__PURE__*/forwardRef(function (_ref, ref) {
27
27
  var actionDefinition = Object.values(actionObject)[0];
28
28
  var ActionComponent = actionDefinition.Component,
29
29
  action = actionDefinition.action,
30
- isEnabled = actionDefinition.isEnabled;
30
+ disabled = actionDefinition.disabled;
31
31
 
32
32
  var handleClick = function handleClick() {
33
33
  action && action(doc, {
@@ -42,8 +42,8 @@ var ActionsItems = /*#__PURE__*/forwardRef(function (_ref, ref) {
42
42
  return /*#__PURE__*/React.createElement(ActionComponent, _extends({}, props, {
43
43
  ref: ref,
44
44
  key: actionName + idx,
45
- isEnabled: isEnabled,
46
45
  doc: doc,
46
+ disabled: disabled,
47
47
  onClick: handleClick
48
48
  }));
49
49
  });
@@ -12,7 +12,8 @@ var ActionsMenuItem = /*#__PURE__*/forwardRef(function (_ref, ref) {
12
12
  var Component = isListItem ? ListItem : MenuItem;
13
13
  return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
14
14
  ref: ref,
15
- button: true
15
+ button: true,
16
+ ellipsis: false
16
17
  }));
17
18
  });
18
19
  ActionsMenuItem.propTypes = {
@@ -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 = ["children", "autoClose", "onClose"];
3
+ var _excluded = ["children", "autoClose", "open", "onClose"];
4
4
  import React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import Menu from "cozy-ui/transpiled/react/MuiCozyTheme/Menu";
@@ -13,6 +13,7 @@ import { useActionMenuEffects } from "cozy-ui/transpiled/react/ActionMenu/Action
13
13
  var ActionsMenuWrapper = function ActionsMenuWrapper(_ref) {
14
14
  var children = _ref.children,
15
15
  autoClose = _ref.autoClose,
16
+ open = _ref.open,
16
17
  onClose = _ref.onClose,
17
18
  props = _objectWithoutProperties(_ref, _excluded);
18
19
 
@@ -30,7 +31,7 @@ var ActionsMenuWrapper = function ActionsMenuWrapper(_ref) {
30
31
  };
31
32
  };
32
33
 
33
- if (isMobile) {
34
+ if (isMobile && open) {
34
35
  return /*#__PURE__*/React.createElement(BottomSheet, {
35
36
  skipAnimation: isTesting(),
36
37
  backdrop: true,
@@ -38,20 +39,21 @@ var ActionsMenuWrapper = function ActionsMenuWrapper(_ref) {
38
39
  }, /*#__PURE__*/React.createElement(Paper, {
39
40
  square: true
40
41
  }, React.Children.map(children, function (child) {
41
- return /*#__PURE__*/React.cloneElement(child, {
42
+ return /*#__PURE__*/React.isValidElement(child) ? /*#__PURE__*/React.cloneElement(child, {
42
43
  isListItem: true,
43
44
  size: 'small',
44
45
  onClick: overrideClick(child.props)
45
- });
46
+ }) : null;
46
47
  })));
47
48
  }
48
49
 
49
50
  return /*#__PURE__*/React.createElement(Menu, _extends({}, props, {
51
+ open: open,
50
52
  onClose: onClose
51
53
  }), React.Children.map(children, function (child) {
52
- return /*#__PURE__*/React.cloneElement(child, {
54
+ return /*#__PURE__*/React.isValidElement(child) ? /*#__PURE__*/React.cloneElement(child, {
53
55
  onClick: overrideClick(child.props)
54
- });
56
+ }) : null;
55
57
  }));
56
58
  };
57
59
 
@@ -1,2 +1,14 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React, { forwardRef } from 'react';
1
3
  import MuiMenuItem from '@material-ui/core/MenuItem';
2
- export default MuiMenuItem;
4
+ import ListItem, { LitItemPropTypes } from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem";
5
+ var MenuItem = /*#__PURE__*/forwardRef(function (props, ref) {
6
+ return /*#__PURE__*/React.createElement(MuiMenuItem, _extends({
7
+ ref: ref,
8
+ component: ListItem,
9
+ gutters: "disabled"
10
+ }, props));
11
+ });
12
+ MenuItem.displayName = 'MenuItem';
13
+ MenuItem.propTypes = LitItemPropTypes;
14
+ export default MenuItem;
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  var _excluded = ["gutters"],
4
4
  _excluded2 = ["gutters"],
5
- _excluded3 = ["gutters"],
5
+ _excluded3 = ["gutters", "ellipsis"],
6
6
  _excluded4 = ["className"];
7
7
  import React, { forwardRef } from 'react';
8
8
  import cx from 'classnames';
@@ -50,17 +50,19 @@ var useGutters = function useGutters(_ref5) {
50
50
 
51
51
  var guttersValue = gutters === 'double' ? 32 : 16;
52
52
  var lastChild = getLastChild(props);
53
- var isLastChildListItemIcon = getComponentName(lastChild).includes('ListItemIcon');
53
+ var isLastChildListItemIcon = lastChild ? getComponentName(lastChild).includes('ListItemIcon') : false;
54
54
  var gutterRight = isLastChildListItemIcon ? guttersValue - 8 : guttersValue;
55
55
  return {
56
56
  left: guttersValue,
57
57
  right: gutterRight
58
58
  };
59
59
  }; // Add margin on ListItemSecondaryAction when gutters are double
60
+ // Propagates ellipsis prop to ListItemText
60
61
 
61
62
 
62
63
  var useOverridenChildren = function useOverridenChildren(_ref6) {
63
64
  var gutters = _ref6.gutters,
65
+ ellipsis = _ref6.ellipsis,
64
66
  props = _objectWithoutProperties(_ref6, _excluded3);
65
67
 
66
68
  var children = getChildren(props);
@@ -68,6 +70,7 @@ var useOverridenChildren = function useOverridenChildren(_ref6) {
68
70
  return React.Children.map(children, function (child, index) {
69
71
  var isLastChild = index === childrenCount - 1;
70
72
  var isSecondaryAction = isLastChild && isMuiElement(child, ['ListItemSecondaryAction']) || false;
73
+ var isListItemText = getComponentName(child).includes('ListItemText');
71
74
 
72
75
  if (isSecondaryAction && gutters === 'double') {
73
76
  return /*#__PURE__*/React.cloneElement(child, {
@@ -75,6 +78,12 @@ var useOverridenChildren = function useOverridenChildren(_ref6) {
75
78
  });
76
79
  }
77
80
 
81
+ if (isListItemText) {
82
+ return /*#__PURE__*/React.cloneElement(child, {
83
+ ellipsis: ellipsis
84
+ });
85
+ }
86
+
78
87
  return child;
79
88
  });
80
89
  };
@@ -102,8 +111,10 @@ ListItem.defaultProps = {
102
111
  gutters: 'default',
103
112
  size: 'medium'
104
113
  };
105
- ListItem.propTypes = {
114
+ export var LitItemPropTypes = {
106
115
  gutters: PropTypes.oneOf(['disabled', 'double', 'default']),
107
- size: PropTypes.oneOf(['small', 'medium', 'large'])
116
+ size: PropTypes.oneOf(['small', 'medium', 'large']),
117
+ ellipsis: PropTypes.bool
108
118
  };
119
+ ListItem.propTypes = LitItemPropTypes;
109
120
  export default ListItem;
@@ -503,7 +503,9 @@ var makeOverrides = function makeOverrides(theme) {
503
503
  MuiMenuItem: {
504
504
  root: {
505
505
  gap: 8,
506
- minWidth: 256,
506
+ maxWidth: 320,
507
+ whiteSpace: 'normal',
508
+ overflow: 'auto',
507
509
  paddingTop: 4,
508
510
  paddingBottom: 4
509
511
  },
@@ -102,7 +102,7 @@ export var SquareAppIcon = function SquareAppIcon(_ref) {
102
102
  setAnimationState = _useState2[1];
103
103
 
104
104
  var handleAnimationEnd = function handleAnimationEnd(e) {
105
- if (e.animationName.startsWith('end')) setAnimationState();
105
+ if (e.animationName.includes('end')) setAnimationState();
106
106
  };
107
107
 
108
108
  useEffect(function () {
@@ -4,14 +4,16 @@ export var getComponentName = function getComponentName(component) {
4
4
  return component.type.displayName || component.type.name || 'Component';
5
5
  };
6
6
  export var getChildren = function getChildren(props) {
7
- return Children.toArray(props.children);
7
+ var children = Children.toArray(props.children);
8
+ return Children.count(children) > 0 ? children : null;
8
9
  };
9
10
  export var getChildrenCount = function getChildrenCount(props) {
10
11
  var children = getChildren(props);
11
- return children.length;
12
+ return Children.count(children) || null;
12
13
  };
13
14
  export var getLastChild = function getLastChild(props) {
14
15
  var children = getChildren(props);
16
+ if (!children) return null;
15
17
  var lastChild = children[children.length - 1];
16
18
  return lastChild.type === Fragment ? getChildren(lastChild.props)[0] : lastChild;
17
19
  };