react-navplus
Version:
A flexible, performance-optimized navigation link component for React with multi-router support, prefetching, and advanced active state detection
30 lines • 1.53 kB
TypeScript
import { MatchMode } from '../types';
/**
* A map of matcher functions that determine if a link is active based on the current URL
* @type {Map<MatchMode, (pathname: string, url: string, pattern?: RegExp) => boolean>}
*/
export declare const matchers: Map<MatchMode, (pathname: string, url: string, pattern?: RegExp) => boolean>;
/**
* Cleans up a URL by ensuring it starts with a forward slash
* @param {string} url - The URL to clean
* @returns {string} - The cleaned URL
*/
export declare const cleanUrl: (url: string) => string;
/**
* Determine if a link is active based on the location, URL, match mode, and optional pattern
* @param {string} pathname - Current pathname
* @param {string} url - URL to match against
* @param {MatchMode} matchMode - How to match the URL
* @param {RegExp} [matchPattern] - Optional regex pattern for matching
* @returns {boolean} - Whether the link is active
*/
export declare const isActive: (pathname: string, url: string, matchMode?: MatchMode, matchPattern?: RegExp) => boolean;
/**
* Determine if a link is active with a custom function
* @param {string} pathname - Current pathname
* @param {string} url - URL to match against
* @param {(pathname: string, url: string) => boolean} isActiveFunc - Custom active detection function
* @returns {boolean} - Whether the link is active
*/
export declare const isActiveWithCustomFn: (pathname: string, url: string, isActiveFunc: (pathname: string, url: string) => boolean) => boolean;
//# sourceMappingURL=matchers.d.ts.map