/** @license MIT | @cube-dev/ui-kit v0.127.1 | Cube Dev Team */
import { mergeProps } from "../../../../utils/react/mergeProps.js";
import { useEvent } from "../../../../_internal/hooks/use-event.js";
import { useProviderProps } from "../../../../provider.js";
import { Button } from "../../../actions/Button/Button.js";
import { useFormProps } from "../Form.js";
import { forwardRef } from "react";
import { jsx } from "react/jsx-runtime";

//#region src/components/form/Form/ResetButton/ResetButton.tsx
function ResetButton(props, ref) {
	const providerProps = useProviderProps({});
	props = useFormProps(props);
	const { isDisabled: isContextDisabled } = providerProps;
	const { form, isDisabled, ...otherProps } = props;
	const onPress = useEvent(() => {
		setTimeout(() => {
			form?.resetFields();
		});
	});
	const isSomethingDisabled = isDisabled || isContextDisabled;
	return /* @__PURE__ */ jsx(Button, {
		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";

//#endregion
export { _ResetButton };
//# sourceMappingURL=ResetButton.js.map