/**
* This Source Code is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright (c) Infonomic Company Limited
*/
/** The result returned by a `UseNavigationGuard` hook. */
export interface NavigationGuardResult {
/** Whether a navigation attempt is currently being blocked (show confirmation UI). */
isBlocked: boolean;
/** Cancel the pending navigation — stay on the current page. */
stay: () => void;
/** Confirm the pending navigation — leave the page. */
proceed: () => void;
}
/**
* A hook that blocks in-app navigation and (optionally) browser unload when
* `shouldBlock` is `true`.
*
* Each framework adapter implements this signature.
*/
export type UseNavigationGuard = (shouldBlock: boolean) => NavigationGuardResult;
/**
* Fallback navigation guard that only handles the browser's native
* `beforeunload` event. In-app (client-side) route changes are **not**
* intercepted — `isBlocked` will never become `true`.
*
* This is used when no framework-specific adapter has been provided.
*/
export declare const useBeforeUnloadGuard: UseNavigationGuard;
/**
* Provide a framework-specific `UseNavigationGuard` hook to all descendant
* `FormRenderer` instances.
*
* ```tsx
* import { NavigationGuardProvider } from './navigation-guard'
* import { useTanStackNavigationGuard } from './tanstack-navigation-guard'
*
* function App() {
* return (
*
*
*
* )
* }
* ```
*/
export declare const NavigationGuardProvider: import("react").Provider;
/**
* Consume the current `UseNavigationGuard` hook from context.
* Falls back to `useBeforeUnloadGuard` when no provider is present.
*/
export declare const useNavigationGuardAdapter: () => UseNavigationGuard;