import type { ReactiveController, ReactiveControllerHost } from 'lit'; /** * Base configuration shared by all route types. * * @public */ export interface IBaseRouteConfig { name?: string | undefined; render?: (params: Record) => unknown; enter?: (params: Record) => Promise | boolean; } /** * A route config that matches against a `path` string. * `path` must be a `URLPattern`-compatible pathname pattern. * * @public */ export interface IPathRouteConfig extends IBaseRouteConfig { path: string; } /** * A route config that matches against a given `URLPattern`. * * @public */ export interface IURLPatternRouteConfig extends IBaseRouteConfig { pattern: URLPattern; } /** * A union of all supported route configuration shapes. * * @public */ export type RouteConfig = IPathRouteConfig | IURLPatternRouteConfig; /** * A reactive controller that performs location-based routing using a * configuration of URL patterns and associated render callbacks. * * @public */ export declare class Routes implements ReactiveController { private readonly _host; private readonly _childRoutes; private _routes; private _fallback; private _parentRoutes; private _currentPathname; private _currentRoute; private _currentParams; private _onDisconnect; private _hostRoutesConnectedSubscription; /** * Creates a new `Routes` reactive controller. * * @param host - The host element that owns this controller. * @param routes - Initial set of route configurations. * @param options - Optional settings such as a fallback route. * * @public */ constructor(host: ReactiveControllerHost & HTMLElement, routes: Array, options?: { fallback?: IBaseRouteConfig; }); /** * The currently installed set of routes in precedence order. * * This array is mutable. To dynamically add a new route: * * ```ts * this._routes.routes.push({ * path: '/foo', * render: () => html`

Foo

`, * }); * ``` * * Mutating this property does not trigger a route transition. * Call `goto()` to re-evaluate. * * @public */ get routes(): Array; set routes(value: Array); /** * A default fallback route matched when none of the `routes` match. * Implicitly matches `/*`. * * @public */ get fallback(): IBaseRouteConfig | undefined; set fallback(value: IBaseRouteConfig | undefined); /** * The current parsed route parameters. * * @public * @readonly */ get params(): Record; /** * Returns a URL string of the current route, including parent routes, * optionally replacing the local path with `pathname`. * * @param pathname - Optional local pathname override. * @returns The composed URL path. * * @public */ link(pathname?: string): string; /** * Navigates this controller to the given `pathname`. * * Child routes are navigated automatically when the path matches a * tail wildcard pattern (`/*`). * * @param pathname - The target path. * * @public */ goto(pathname: string): Promise; /** * The result of calling the current route's `render()` callback. * * @returns The rendered template or `undefined`. * * @public */ outlet(): unknown; /** * @public */ hostConnected(): void; /** * @public */ hostDisconnected(): void; /** * Matches `pathname` against installed routes and returns the first match. * * @param pathname - The path to match. * @returns The matching `RouteConfig` or `undefined`. * * @private */ private getRoute; /** * Handles connection of a child `Routes` controller. * * @private */ private onRoutesConnected; } //# sourceMappingURL=Routes.d.ts.map