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

import { jsx as _jsx } from "react/jsx-runtime";
import { forwardRef } from 'react';
import { useEvent } from '../../../../_internal/index.js';
import { useProviderProps } from '../../../../provider.js';
import { mergeProps } from '../../../../utils/react/index.js';
import { Button } from '../../../actions/index.js';
import { useFormProps } from '../Form.js';
function ResetButton(props, ref) {
    const providerProps = useProviderProps({});
    props = useFormProps(props);
    const { isDisabled: isContextDisabled } = providerProps;
    const { form, isDisabled, ...otherProps } = props;
    const onPress = useEvent(() => {
        // Use setTimeout to avoid conflict with onBlur handlers
        setTimeout(() => {
            form?.resetFields();
        });
    });
    const isSomethingDisabled = isDisabled || isContextDisabled;
    return (_jsx(Button, { ref: ref, type: "primary", htmlType: "reset", isDisabled: form?.isSubmitting || !form?.isTouched, ...mergeProps({
            onPress,
            isDisabled: isSomethingDisabled
                ? true
                : form?.isSubmitting || !form?.isTouched,
        }, otherProps) }));
}
const _ResetButton = forwardRef(ResetButton);
_ResetButton.displayName = 'ResetButton';
export { _ResetButton as ResetButton };

        