UNPKG

@zapstra/core-router

Version:

Query-preserving router for Zapstra platform apps

67 lines (62 loc) 2.32 kB
import { NavigateFunction } from '@remix-run/react'; import * as react_jsx_runtime from 'react/jsx-runtime'; import React from 'react'; /** * Navigate while preserving existing query parameters */ declare function navigateWithQuery(navigate: NavigateFunction, path: string, search: string): void; /** * Hook to get navigation function that preserves query parameters * Commonly used to preserve ?host and ?shop parameters in Shopify apps */ declare function useNavigateWithQuery(): (path: string) => void; /** * Get current query parameters as an object */ declare function useQueryParams(): Record<string, string>; /** * Check if a given path is active (matches current location) */ declare function useIsPathActive(): (path: string, exact?: boolean) => boolean; interface GradientProgressSpinnerProps { isLoading: boolean; size?: number; strokeWidth?: number; } /** * Gradient progress spinner with animated progress counter */ declare function GradientProgressSpinner({ isLoading, size, strokeWidth }: GradientProgressSpinnerProps): react_jsx_runtime.JSX.Element | null; interface RouterContext { route: (path: string) => void; isNavigating: boolean; } interface AppRouterProviderProps { children: React.ReactNode; showLoadingSpinner?: boolean; spinnerProps?: { size?: number; strokeWidth?: number; }; } /** * App Router Provider that manages navigation state and query preservation * Automatically shows loading spinner during navigation */ declare function AppRouterProvider({ children, showLoadingSpinner, spinnerProps }: AppRouterProviderProps): react_jsx_runtime.JSX.Element; /** * Hook to access the app router context * Provides navigation function that preserves query params and loading state */ declare function useAppRouter(): RouterContext; /** * Higher-order component to wrap an app with AppRouterProvider */ declare function withAppRouter<P extends object>(Component: React.ComponentType<P>, options?: { showLoadingSpinner?: boolean; spinnerProps?: { size?: number; strokeWidth?: number; }; }): (props: P) => react_jsx_runtime.JSX.Element; export { AppRouterProvider, GradientProgressSpinner, navigateWithQuery, useAppRouter, useIsPathActive, useNavigateWithQuery, useQueryParams, withAppRouter };