File size: 979 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import { FormInputValidation } from '@automattic/components';
import clsx from 'clsx';
import debugFactory from 'debug';
import { values } from 'lodash';
import { Component } from 'react';
import FormFieldset from 'calypso/components/forms/form-fieldset';
import './style.scss';
const debug = debugFactory( 'calypso:validate-fieldset' );
export default class ValidationFieldset extends Component {
renderValidationNotice() {
const validationElement = this.props.errorMessages && (
<FormInputValidation
isError
isValid={ false }
text={ values( this.props.errorMessages )[ 0 ] }
/>
);
return <div className="validation-fieldset__validation-message">{ validationElement }</div>;
}
render() {
const classes = clsx( 'validation-fieldset', this.props.className );
debug( 'render validation fieldset' );
return (
<FormFieldset className={ classes }>
{ this.props.children }
{ this.renderValidationNotice() }
</FormFieldset>
);
}
}
|