@pepperi-addons/ngx-lib-react 0.5.6 → 0.5.8

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/pep-dialog.js CHANGED
@@ -59,23 +59,16 @@ export const PepDialog = ({ title, showClose, showHeader, showFooter, onClose, c
59
59
  handlers.forEach(([n, h]) => el.addEventListener(n, h));
60
60
  return () => handlers.forEach(([n, h]) => el.removeEventListener(n, h));
61
61
  }, [onClose]);
62
- const allChildren = React.Children.toArray(children);
63
- const contentChildren = allChildren.filter((child) => {
64
- if (!React.isValidElement(child)) {
65
- return true;
66
- }
67
- const props = child.props || {};
68
- const hasContentAttr = Object.prototype.hasOwnProperty.call(props, 'pep-dialog-content');
69
- const hasActionsAttr = Object.prototype.hasOwnProperty.call(props, 'pep-dialog-actions');
70
- return hasContentAttr || !hasActionsAttr;
71
- });
72
- const actionsChildren = allChildren.filter((child) => {
73
- if (!React.isValidElement(child)) {
74
- return false;
75
- }
76
- const props = child.props || {};
77
- return Object.prototype.hasOwnProperty.call(props, 'pep-dialog-actions');
78
- });
62
+ let primaryChildren = [];
63
+ if (React.isValidElement(children) && children.type === React.Fragment) {
64
+ primaryChildren = React.Children.toArray(children.props && children.props.children);
65
+ }
66
+ else {
67
+ primaryChildren = React.Children.toArray(children);
68
+ }
69
+ const flatChildren = primaryChildren.filter((child) => React.isValidElement(child));
70
+ const contentChildren = flatChildren[0] ? [flatChildren[0]] : [];
71
+ const actionsChildren = flatChildren[1] ? [flatChildren[1]] : [];
79
72
  return (_jsxs(_Fragment, { children: [_jsx("pep-dialog-element", { ref: ref, ...rest }), contentHost && contentChildren.length > 0 &&
80
73
  ReactDOM.createPortal(contentChildren, contentHost), actionsHost && actionsChildren.length > 0 &&
81
74
  ReactDOM.createPortal(actionsChildren, actionsHost)] }));