import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { SoftCallOut } from '../CallOut';
import { SoftI18n } from '../I18n';
export const SoftForm = ({ children, className, isInvalid, error, ...rest }) => {
    const classes = classNames('softForm', className);
    let optionalErrors;
    if (error) {
        const errorTexts = Array.isArray(error) ? error : [error];
        optionalErrors = (React.createElement("ul", null, errorTexts.map(error => (React.createElement("li", { className: "softForm__error", key: error }, error)))));
    }
    let optionalErrorAlert;
    if (isInvalid) {
        optionalErrorAlert = (React.createElement(SoftI18n, { token: "softForm.addressFormErrors", default: "Please address the errors in your form." }, addressFormErrors => (React.createElement(SoftCallOut, { className: "softForm__errors", title: addressFormErrors, color: "danger" }, optionalErrors))));
    }
    return (React.createElement("div", Object.assign({ className: classes }, rest),
        optionalErrorAlert,
        children));
};
// @ts-ignore
SoftForm.propTypes = {
    isInvalid: PropTypes.bool,
    error: PropTypes.oneOfType([PropTypes.node, PropTypes.arrayOf(PropTypes.node)]),
};
//# sourceMappingURL=SoftForm.js.map