import { RawParams, TransitionOptions, TargetState } from "@uirouter/core"; import { noChange, ElementPart } from "lit"; import { PartInfo } from "lit/directive.js"; import type { DirectiveResult } from "lit/directive.js"; import { AsyncDirective } from "lit/async-directive.js"; import { UIRouterLit } from "./core.js"; import { UiView } from "./ui-view.js"; /** * Event name dispatched when a uiSref target state changes. * @internal */ export declare const UI_SREF_TARGET_EVENT = "uiSrefTarget"; /** * Interface for elements that have been enhanced with uiSref. * @internal */ export interface UiSrefElement extends Element { /** The href attribute value for the link */ href: string; /** The target state for the link */ targetState: TargetState; } /** * Custom event dispatched when a uiSref target state changes. * Used internally by uiSrefActive to track which states are being linked to. * @internal */ export interface UiSrefTargetEvent extends CustomEvent<{ targetState: TargetState; }> { target: UiSrefElement; } /** * Create a uiSrefTarget event with the given target state. * @param targetState - The target state for the event * @returns A custom event with the target state in the detail * @internal */ export declare function uiSrefTargetEvent(targetState: TargetState): UiSrefTargetEvent; /** * Directive options for {@link uiSref}, passed alongside the transition * options in its third argument. These never reach `@uirouter/core`. * * @category types */ export interface UiSrefOptions { /** * Where the generated `href` is written. * * - `true` *(default in 1.x)* — always write it, whatever the element is. * This is the historical behaviour and the standing answer for a custom * element that declares its own `href`. * - `'auto'` — write it only to elements the HTML spec gives an `href`: * ``, ``, and SVG ``. This is the correct behaviour and * becomes the default in 2.0. * - `false` — never write it; the app manages the attribute itself. * * Under `true`, a non-link that receives an `href` warns once and names * `'auto'` as the fix. * * This option governs the `href` attribute **only**. Whether the click * handler defers to native browser behaviour is decided by the element * itself, never by this setting — see {@link isNativeLink}. */ assignHref?: boolean | "auto"; } /** * The third argument to {@link uiSref}: core's transition options plus this * directive's own. * * @category types */ export type UiSrefTransitionOptions = TransitionOptions & UiSrefOptions; /** * Whether lit resolved to its development build. `enableWarning` is inherited * from `ReactiveElement`, which declares it optional precisely because it * exists only in development — lit's own docs prescribe guarding on it. Same * shape in lit 2 and 3, and typed optional in both builds' `.d.ts`, so this * needs no cast. Read per call, so import order cannot matter. * @internal */ export declare function inLitDevMode(): boolean; /** * Whether the element navigates on its own. `localName` is lowercase for HTML * and SVG alike, so SVG `` needs no namespace check. * * **Tag-based on purpose.** This decides where an `href` may be written, and * `href` is a property of the tag, not of the role: `
` * is inert noise. `uiSrefActive`'s `isLinkElement` asks the neighbouring * *role*-based question for `aria-current`, which `
` * legitimately takes. The two overlap on ``/`` and nowhere else — do * not unify them. * * @internal */ export declare function isNativeLink(element: Element): boolean; /** * Directive class that creates state-based navigation links. * * This directive is used internally by the {@link uiSref} directive function. * It transforms elements (typically `` tags) into UI-Router navigation links * by setting the `href` attribute and handling click events. * * @see {@link uiSref} for the public API * @see [[AsyncDirective]] * @see [[StateService.go]] * * @category directives */ export declare class UiSrefDirective extends AsyncDirective { state: string | null; params: RawParams; options: TransitionOptions; element: UiSrefElement | null; uiRouter: UIRouterLit | undefined; parentView: UiView | null; /** this directive's own options, stripped from the transition options */ uiSrefOptions: UiSrefOptions; href: string | null; targetState: TargetState | null; /** whether the href currently on the element was written by us */ private _ownsHref; /** @internal */ unsubscribe: (() => void) | undefined; /** @internal */ constructor(partInfo: PartInfo); getOptions(opts?: TransitionOptions): TransitionOptions; render(state: string, params?: RawParams, options?: TransitionOptions): typeof noChange; /** * Whether this render writes the `href`, warning once per element under lit's * dev build when the 1.x default puts one on something that cannot use it. * @internal */ shouldAssignHref(): boolean; /** @internal */ seekRouter(): void; /** @internal */ seekParentView(): void; /** @internal */ disconnected(): void; onClick: (event: MouseEvent) => void; update(part: ElementPart, [state, params, options]: [string, RawParams?, UiSrefTransitionOptions?]): typeof noChange; doRender: () => typeof noChange; private _firstUpdated; /** * @internal */ firstUpdated(): void; } /** * Directive that creates state-based navigation links. * * The `uiSref` directive transforms elements (typically `` tags) into * UI-Router navigation links. It automatically generates the `href` attribute * based on the target state and handles click events to perform state transitions. * * **Arguments:** * - `state` - The target state name (can be relative like `.child` or `^.sibling`) * - `params` - Optional state parameters (see [[RawParams]]) * - `options` - Optional transition options (see [[TransitionOptions]]), plus * this directive's own (see {@link UiSrefOptions}) * * @example Basic usage * ```ts * import { uiSref } from 'lit-ui-router'; * import { html } from 'lit'; * * html`Go Home` * ``` * * @example With parameters * ```ts * html`View User` * ``` * * @example With transition options * ```ts * html`Reload Dashboard` * ``` * * @example Relative state references * ```ts * // Navigate to child state * html`Go to Child` * * // Navigate to sibling state * html`Go to Sibling` * ``` * * @example On an element that is not a link * ```ts * // `` * ``` * * @see [[RawParams]] * @see [[TransitionOptions]] * @see {@link UiSrefOptions} * @see [[DirectiveResult]] * * @category directives */ export declare const uiSref: (state: string, params?: RawParams, options?: UiSrefTransitionOptions) => DirectiveResult; //# sourceMappingURL=ui-sref.d.ts.map