/** @license MIT | @cube-dev/ui-kit v0.135.1 | Cube Dev Team */
import { FormContext } from "./Form.js";
import { Alert } from "../../content/Alert/Alert.js";
import { forwardRef, isValidElement, useContext } from "react";
import { jsx } from "react/jsx-runtime";

//#region src/components/form/Form/SubmitError.tsx
function SubmitError(props, ref) {
	let { submitError } = useContext(FormContext);
	if (!submitError) return null;
	if (!isValidElement(submitError) && typeof submitError !== "string") submitError = "Internal error";
	return /* @__PURE__ */ jsx(Alert, {
		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";

//#endregion
export { _SubmitError };
//# sourceMappingURL=SubmitError.js.map