import * as i0 from '@angular/core'; import { Provider } from '@angular/core'; /** * Renders a registered SVG icon. * * Icons must be registered via {@link provideWrIcons} before use — * either at the application root or on any ancestor component. * * @example * ```html * * ``` * * @see https://ngwr.dev/components/icon */ declare class WrIcon { readonly name: i0.InputSignal; private readonly host; /** * Merged view of every `WR_ICONS` multi-provider visible from this * injector position — element-level first overlay, environment-level * (app/lazy-route bootstrap) as the base. * * Angular's default `inject(WR_ICONS)` only returns the **closest** * injector's contribution; if a component declares its own * `provideWrIcons(...)`, the root registration is **shadowed**, not * appended. That contradicts the docstring's "each call adds to the * registry" promise and silently breaks any page that overrides while * still relying on root-registered icons. * * We work around it by also asking the environment injector directly * (`envInjector.get(WR_ICONS, null, …)`). When no element-level * provider exists both calls return the same array reference and we * skip the redundant pass. Otherwise we lay element on top of env so * a page's local icons can override a root-registered name. * * One known limitation: multiple element-injector levels in between * still shadow each other — but the showcase doesn't nest providers * that deep, and the env+local merge fixes the dominant case. */ private readonly iconSets; private readonly registry; private readonly icon; constructor(); static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } /** * @license * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE */ /** * Any icon name registered via {@link provideWrIcons}. * * Kept as a string alias so consumers can pass any name they've wired * — there are no built-ins shipped by ngwr. Bring an icon set via one * of the adapters under `ngwr/icon/adapters/` or via `svgIcon()`. */ type WrIconName = string; /** * @license * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE */ /** * Shape of an icon registered with the icon registry. * * The library ships a set of built-in icons, but consumers can also * provide their own custom icons with the same shape. * * @example * ```ts * const myIcon: WrIconDef = { * name: 'my-custom-logo', * data: '...', * }; * * provideWrIcons([myIcon]); * ``` */ interface WrIconDef { name: WrIconName; data: string; } /** * @license * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE */ /** * Registers a set of icons for use by ``. * * Can be called multiple times — each call adds to the registry. * Works at both the application root and at the component level, * so a feature module or a single component can bring its own icons * without polluting the global config. * * In dev mode, each icon is validated for common issues (missing * `viewBox`, malformed root). Validation is dropped from production * builds via `isDevMode()` tree-shaking. * * @example * ```ts * // App-level registration * import { home, user, cog, provideWrIcons } from 'ngwr/icon'; * * export const appConfig: ApplicationConfig = { * providers: [ * provideWrIcons([home, user, cog]), * ], * }; * ``` * * @example * ```ts * // Component-level registration * import { logoGithub, logoNpm, provideWrIcons, WrIconDef } from 'ngwr/icon'; * * @Component({ * selector: 'ngwr-header', * imports: [WrIcon], * providers: [provideWrIcons([logoGithub, logoNpm])], * template: ``, * }) * export class HeaderComponent {} * ``` */ declare function provideWrIcons(icons: WrIconDef[]): Provider[]; /** * @license * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE */ /** * Wrap a raw SVG string in the {@link WrIconDef} envelope. Use this when * importing icons from sources that ship full `` files — Tabler, * Phosphor, Heroicons, Iconoir, Radix, Bootstrap Icons, your designer. * * Pair with a bundler's raw-SVG import (Vite's `?raw`, Webpack's * `raw-loader`, esbuild's `--loader:.svg=text`) so the SVG file becomes * a string at build time. * * For sets with a non-SVG shape (Lucide's IconNode tuples, Feather's * inner-only SVG), use the dedicated adapter under * `ngwr/icon/adapters/` instead. * * @example * ```ts * import { svgIcon, provideWrIcons } from 'ngwr/icon'; * // Vite: the `?raw` suffix returns the file as a string. * import plusSvg from '@tabler/icons/icons/plus.svg?raw'; * import phosphorPlusSvg from '@phosphor-icons/core/assets/regular/plus.svg?raw'; * * bootstrapApplication(AppComponent, { * providers: [ * provideWrIcons([ * svgIcon('plus', plusSvg), * svgIcon('plus-phosphor', phosphorPlusSvg), * ]), * ], * }); * ``` */ declare function svgIcon(name: string, svg: string): WrIconDef; export { WrIcon, provideWrIcons, svgIcon }; export type { WrIconDef, WrIconName };