import { HttpClient } from '@angular/common/http'; import { ErrorHandler, OnDestroy } from '@angular/core'; import { DomSanitizer, SafeHtml, SafeResourceUrl } from '@angular/platform-browser'; import { Observable } from 'rxjs'; import * as i0 from "@angular/core"; /** * Returns an exception to be thrown in the case when attempting to * load an icon with a name that cannot be found. * @docs-private */ export declare function getDashIconNameNotFoundError(iconName: string): Error; /** * Returns an exception to be thrown when the consumer attempts to use * `` without including @angular/common/http. * @docs-private */ export declare function getDashIconNoHttpProviderError(): Error; /** * Returns an exception to be thrown when a URL couldn't be sanitized. * @param url URL that was attempted to be sanitized. * @docs-private */ export declare function getDashIconFailedToSanitizeUrlError(url: SafeResourceUrl): Error; /** * Returns an exception to be thrown when a HTML string couldn't be sanitized. * @param literal HTML that was attempted to be sanitized. * @docs-private */ export declare function getDashIconFailedToSanitizeLiteralError(literal: SafeHtml): Error; /** Options that can be used to configure how an icon or the icons in an icon set are presented. */ export interface IconOptions { /** View box to set on the icon. */ viewBox?: string; /** Whether or not to fetch the icon or icon set using HTTP credentials. */ withCredentials?: boolean; } /** * Function that will be invoked by the icon registry when trying to resolve the * URL from which to fetch an icon. The returned URL will be used to make a request for the icon. */ export declare type IconResolver = (name: string, namespace: string) => SafeResourceUrl | SafeResourceUrlWithIconOptions | null; /** Object that specifies a URL from which to fetch an icon and the options to use for it. */ export interface SafeResourceUrlWithIconOptions { url: SafeResourceUrl; options: IconOptions; } /** * Service to register and display icons used by the `` component. * - Registers icon URLs by namespace and name. * - Registers icon set URLs by namespace. * - Registers aliases for CSS classes, for use with icon fonts. * - Loads icons from URLs and extracts individual icons from icon sets. */ export declare class DashIconRegistry implements OnDestroy { private _httpClient; private _sanitizer; private readonly _errorHandler; private _document; /** * URLs and cached SVG elements for individual icons. Keys are of the format "[namespace]:[icon]". */ private _svgIconConfigs; /** * SvgIconConfig objects and cached SVG elements for icon sets, keyed by namespace. * Multiple icon sets can be registered under the same namespace. */ private _iconSetConfigs; /** Cache for icons loaded by direct URLs. */ private _cachedIconsByUrl; /** In-progress icon fetches. Used to coalesce multiple requests to the same URL. */ private _inProgressUrlFetches; /** Map from font identifiers to their CSS class names. Used for icon fonts. */ /** Registered icon resolver functions. */ private _resolvers; /** * The CSS classes to apply when an `` component has no icon name, url, or font * specified. The default 'material-icons' value assumes that the material icon font has been */ private _defaultFontSetClass; constructor(_httpClient: HttpClient, _sanitizer: DomSanitizer, document: any, _errorHandler: ErrorHandler); /** * Registers an icon by URL in the default namespace. * @param iconName Name under which the icon should be registered. * @param url */ addSvgIcon(iconName: string, url: SafeResourceUrl, options?: IconOptions): this; /** * Registers an icon by URL in the specified namespace. * @param namespace Namespace in which the icon should be registered. * @param iconName Name under which the icon should be registered. * @param url */ addSvgIconInNamespace(namespace: string, iconName: string, url: SafeResourceUrl, options?: IconOptions): this; /** * Sets the CSS classes to be used for icon fonts when an `` component does not * have a fontSet input value, and is not loading an icon by name or URL. */ setDefaultFontSetClass(...classNames: string[]): this; /** * Returns the CSS classes to be used for icon fonts when an `` component does not * have a fontSet input value, and is not loading an icon by name or URL. */ getDefaultFontSetClass(): string[]; /** * Returns an Observable that produces the icon (as an `` DOM element) with the given name * and namespace. The icon must have been previously registered with addIcon or addIconSet; * if not, the Observable will throw an error. * * @param name Name of the icon to be retrieved. * @param namespace Namespace in which to look for the icon. */ getNamedSvgIcon(name: string, namespace?: string): Observable; ngOnDestroy(): void; /** * Returns the cached icon for a SvgIconConfig if available, or fetches it from its URL if not. */ private _getSvgFromConfig; /** * Attempts to find an icon with the specified name in any of the SVG icon sets. * First searches the available cached icons for a nested element with a matching name, and * if found copies the element to a new `` element. If not found, fetches all icon sets * that have not been cached, and searches again after all fetches are completed. * The returned Observable produces the SVG element if possible, and throws * an error if no icon with the specified name can be found. */ private _getSvgFromIconSetConfigs; /** * Searches the cached SVG elements for the given icon sets for a nested icon element whose "id" * tag matches the specified name. If found, copies the nested element to a new SVG element and * returns it. Returns null if no matching element is found. */ private _extractIconWithNameFromAnySet; /** * Loads the content of the icon URL specified in the SvgIconConfig and creates an SVG element * from it. */ private _loadSvgIconFromConfig; /** * Loads the content of the icon set URL specified in the * SvgIconConfig and attaches it to the config. */ private _loadSvgIconSetFromConfig; /** * Searches the cached element of the given SvgIconConfig for a nested icon element whose "id" * tag matches the specified name. If found, copies the nested element to a new SVG element and * returns it. Returns null if no matching element is found. */ private _extractSvgIconFromSet; /** * Creates a DOM element from the given SVG string. */ private _svgElementFromString; /** * Converts an element into an SVG node by cloning all of its children. */ private _toSvgElement; /** * Sets the default attributes for an SVG element to be used as an icon. */ private _setSvgAttributes; /** * Returns an Observable which produces the string contents of the given icon. Results may be * cached, so future calls with the same URL may not cause another HTTP request. */ private _fetchIcon; /** * Registers an icon config by name in the specified namespace. * @param namespace Namespace in which to register the icon config. * @param iconName Name under which to register the config. * @param config Config to be registered. */ private _addSvgIconConfig; /** Parses a config's text into an SVG element. */ private _svgElementFromConfig; /** Tries to create an icon config through the registered resolver functions. */ private _getIconConfigFromResolvers; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; }