strict Popup proptypes defined

This commit is contained in:
NikolaBorislavovHristov 2019-04-19 12:51:09 +03:00
parent 91aaa860f4
commit bdaeed2736
3 changed files with 24 additions and 3 deletions

View file

@ -1,9 +1,18 @@
const React = require('react');
const PropTypes = require('prop-types');
const Label = React.forwardRef(({ children, ...props }, ref) => {
return React.cloneElement(React.Children.only(children), { ...props, ref });
const Label = React.forwardRef(({ children, onClick }, ref) => {
return React.cloneElement(React.Children.only(children), { ref, onClick });
});
Label.displayName = 'Popup.Label';
Label.propTypes = {
onClick: PropTypes.func,
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),
PropTypes.node
])
};
module.exports = Label;

View file

@ -1,4 +1,5 @@
const React = require('react');
const PropTypes = require('prop-types');
const Menu = React.forwardRef(({ children }, ref) => (
<div ref={ref}>
@ -8,4 +9,11 @@ const Menu = React.forwardRef(({ children }, ref) => (
Menu.displayName = 'Popup.Menu';
Menu.propTypes = {
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),
PropTypes.node
])
};
module.exports = Menu;

View file

@ -290,7 +290,11 @@ Popup.Menu = Menu;
Popup.propTypes = {
modalContainerClassName: PropTypes.string,
onOpen: PropTypes.func,
onClose: PropTypes.func
onClose: PropTypes.func,
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),
PropTypes.node
])
};
module.exports = Popup;