var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; import React from 'react'; import { Collapse } from 'react-bootstrap'; import Card from './card'; /** * A simple card component with support for additional content that is * expanded or collapsed on users click */ export default class CollapseCard extends React.Component { constructor(props) { super(props); this.onClick = this.onClick.bind(this); this.state = { collapse: this.props.collapse }; } /** * Called when user clicks on the card * @param {[type]} evt [description] * @return {[type]} [description] */ onClick(evt) { if (!evt.isPropagationStopped()) { this.setState({ collapse: !this.state.collapse }); } } render() { const props = Object.assign({}, this.props); delete props.collapsable; return React.createElement( Card, _extends({}, props, { onClick: this.onClick, className: 'collapse-card' }), React.createElement( 'div', null, this.props.children, React.createElement( Collapse, { 'in': !this.state.collapse }, this.props.collapsable ) ) ); } } CollapseCard.propTypes = { // the title of the card title: React.PropTypes.string, // the header of the card (if title is not informed) header: React.PropTypes.element, padding: React.PropTypes.oneOf(['none', 'small', 'default']), children: React.PropTypes.any, style: React.PropTypes.object, onClick: React.PropTypes.func, collapsable: React.PropTypes.any, collapse: React.PropTypes.bool }; CollapseCard.defaultProps = { collapse: true };