'use client';
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
import React from 'react';
import { Button } from '../../elements/Button/index.js';
import { useForm, useFormBackgroundProcessing, useFormInitializing, useFormProcessing } from '../Form/context.js';
import './index.scss';
const baseClass = 'form-submit';
export const FormSubmit = (props)=>{
    const { type = 'submit', buttonId: id, children, disabled: disabledFromProps, onClick, programmaticSubmit, ref } = props;
    const processing = useFormProcessing();
    const backgroundProcessing = useFormBackgroundProcessing();
    const initializing = useFormInitializing();
    const { disabled, submit } = useForm();
    const canSave = !(disabledFromProps || initializing || processing || backgroundProcessing || disabled);
    const handleClick = onClick ?? (programmaticSubmit ? ()=>{
        void submit();
    } : undefined);
    return /*#__PURE__*/ _jsxDEV("div", {
        className: baseClass,
        children: /*#__PURE__*/ _jsxDEV(Button, {
            ref: ref,
            ...props,
            disabled: canSave ? undefined : true,
            id: id,
            onClick: handleClick,
            type: type,
            children: children
        }, void 0, false, {
            fileName: "src/forms/Submit/index.tsx",
            lineNumber: 51,
            columnNumber: 7
        }, this)
    }, void 0, false, {
        fileName: "src/forms/Submit/index.tsx",
        lineNumber: 50,
        columnNumber: 5
    }, this);
};

//# sourceMappingURL=index.js.map