import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import { Components } from 'meteor/vulcan:core'; import classNames from 'classnames'; import { registerComponent } from 'meteor/vulcan:core'; class FormGroup extends PureComponent { constructor(props) { super(props); this.toggle = this.toggle.bind(this); this.renderHeading = this.renderHeading.bind(this); this.state = { collapsed: props.startCollapsed || false, }; } toggle() { this.setState({ collapsed: !this.state.collapsed, }); } renderHeading() { return (

{this.props.label}

{this.state.collapsed ? : }
); } render() { // if at least one of the fields in the group has an error, the group as a whole has an error const hasErrors = _.some(this.props.fields, field => { return !!this.props.errors.filter(error => error.data && error.data.name && error.data.name === field.path).length }); return (
{this.props.name === 'default' ? null : this.renderHeading()}
{this.props.fields.map(field => ( ))}
); } } FormGroup.propTypes = { name: PropTypes.string, label: PropTypes.string, order: PropTypes.number, fields: PropTypes.array, updateCurrentValues: PropTypes.func, }; registerComponent('FormGroup', FormGroup); const IconRight = ({ width = 24, height = 24 }) => ( ); registerComponent('IconRight', IconRight); const IconDown = ({ width = 24, height = 24 }) => ( ); registerComponent('IconDown', IconDown);