/**
 * @license MIT
 * author: Cube Dev Team
 * @cube-dev/ui-kit v0.0.0-canary-c2a807a
 * Released under the MIT license.
 */

import { jsx as _jsx } from "react/jsx-runtime";
import { forwardRef, isValidElement, useContext, } from 'react';
import { Alert } from '../../content/Alert/index.js';
import { FormContext } from './Form.js';
function SubmitError(props, ref) {
    let { submitError } = useContext(FormContext);
    if (!submitError) {
        return null;
    }
    if (!isValidElement(submitError) &&
        typeof submitError !== 'string') {
        submitError = 'Internal error';
    }
    return (_jsx(Alert, { ref: ref, theme: "danger", ...props, children: submitError }));
}
/**
 * An alert that shows a form error message received from the onSubmit callback.
 */
const _SubmitError = forwardRef(SubmitError);
_SubmitError.displayName = 'SubmitError';
export { _SubmitError as SubmitError };

        