2017-06-04 10:40:14 +08:00
|
|
|
import React, { Component, Children, cloneElement } from 'react';
|
2021-11-10 01:24:42 +08:00
|
|
|
import Styled from './styles';
|
2016-09-07 03:10:18 +08:00
|
|
|
|
|
|
|
const defaultProps = {
|
|
|
|
'aria-expanded': false,
|
|
|
|
};
|
|
|
|
|
2016-08-25 22:34:27 +08:00
|
|
|
export default class DropdownContent extends Component {
|
|
|
|
render() {
|
2017-11-04 15:38:44 +08:00
|
|
|
const {
|
2020-03-31 03:41:36 +08:00
|
|
|
children,
|
|
|
|
dropdownToggle,
|
|
|
|
dropdownShow,
|
|
|
|
dropdownHide,
|
|
|
|
dropdownIsOpen,
|
|
|
|
keepOpen,
|
2018-04-16 22:06:29 +08:00
|
|
|
...restProps
|
2017-11-04 15:38:44 +08:00
|
|
|
} = this.props;
|
2016-09-07 03:10:18 +08:00
|
|
|
|
|
|
|
const boundChildren = Children.map(children, child => cloneElement(child, {
|
2018-04-16 22:06:29 +08:00
|
|
|
dropdownIsOpen,
|
2017-06-03 03:25:02 +08:00
|
|
|
dropdownToggle,
|
|
|
|
dropdownShow,
|
|
|
|
dropdownHide,
|
2020-03-31 03:41:36 +08:00
|
|
|
keepOpen,
|
2016-09-07 03:10:18 +08:00
|
|
|
}));
|
|
|
|
|
|
|
|
return (
|
2021-11-10 01:24:42 +08:00
|
|
|
<Styled.Content
|
2017-11-04 15:38:44 +08:00
|
|
|
data-test="dropdownContent"
|
2018-04-16 22:06:29 +08:00
|
|
|
{...restProps}
|
2017-06-03 03:25:02 +08:00
|
|
|
>
|
2021-11-10 01:24:42 +08:00
|
|
|
<Styled.Scrollable>
|
2017-03-16 22:34:03 +08:00
|
|
|
{boundChildren}
|
2021-11-10 01:24:42 +08:00
|
|
|
</Styled.Scrollable>
|
|
|
|
</Styled.Content>
|
2016-09-07 03:10:18 +08:00
|
|
|
);
|
2016-08-25 22:34:27 +08:00
|
|
|
}
|
|
|
|
}
|
2016-09-07 03:10:18 +08:00
|
|
|
|
|
|
|
DropdownContent.defaultProps = defaultProps;
|