source: trip-planner-front/node_modules/@angular/material/icon/icon-registry.d.ts@ 84d0fbb

Last change on this file since 84d0fbb was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 12.3 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { HttpClient } from '@angular/common/http';
9import { ErrorHandler, Optional, OnDestroy } from '@angular/core';
10import { DomSanitizer, SafeResourceUrl, SafeHtml } from '@angular/platform-browser';
11import { Observable } from 'rxjs';
12/**
13 * Returns an exception to be thrown in the case when attempting to
14 * load an icon with a name that cannot be found.
15 * @docs-private
16 */
17import * as ɵngcc0 from '@angular/core';
18export declare function getMatIconNameNotFoundError(iconName: string): Error;
19/**
20 * Returns an exception to be thrown when the consumer attempts to use
21 * `<mat-icon>` without including @angular/common/http.
22 * @docs-private
23 */
24export declare function getMatIconNoHttpProviderError(): Error;
25/**
26 * Returns an exception to be thrown when a URL couldn't be sanitized.
27 * @param url URL that was attempted to be sanitized.
28 * @docs-private
29 */
30export declare function getMatIconFailedToSanitizeUrlError(url: SafeResourceUrl): Error;
31/**
32 * Returns an exception to be thrown when a HTML string couldn't be sanitized.
33 * @param literal HTML that was attempted to be sanitized.
34 * @docs-private
35 */
36export declare function getMatIconFailedToSanitizeLiteralError(literal: SafeHtml): Error;
37/** Options that can be used to configure how an icon or the icons in an icon set are presented. */
38export interface IconOptions {
39 /** View box to set on the icon. */
40 viewBox?: string;
41 /** Whether or not to fetch the icon or icon set using HTTP credentials. */
42 withCredentials?: boolean;
43}
44/**
45 * Function that will be invoked by the icon registry when trying to resolve the
46 * URL from which to fetch an icon. The returned URL will be used to make a request for the icon.
47 */
48export declare type IconResolver = (name: string, namespace: string) => (SafeResourceUrl | SafeResourceUrlWithIconOptions | null);
49/** Object that specifies a URL from which to fetch an icon and the options to use for it. */
50export interface SafeResourceUrlWithIconOptions {
51 url: SafeResourceUrl;
52 options: IconOptions;
53}
54/**
55 * Service to register and display icons used by the `<mat-icon>` component.
56 * - Registers icon URLs by namespace and name.
57 * - Registers icon set URLs by namespace.
58 * - Registers aliases for CSS classes, for use with icon fonts.
59 * - Loads icons from URLs and extracts individual icons from icon sets.
60 */
61export declare class MatIconRegistry implements OnDestroy {
62 private _httpClient;
63 private _sanitizer;
64 private readonly _errorHandler;
65 private _document;
66 /**
67 * URLs and cached SVG elements for individual icons. Keys are of the format "[namespace]:[icon]".
68 */
69 private _svgIconConfigs;
70 /**
71 * SvgIconConfig objects and cached SVG elements for icon sets, keyed by namespace.
72 * Multiple icon sets can be registered under the same namespace.
73 */
74 private _iconSetConfigs;
75 /** Cache for icons loaded by direct URLs. */
76 private _cachedIconsByUrl;
77 /** In-progress icon fetches. Used to coalesce multiple requests to the same URL. */
78 private _inProgressUrlFetches;
79 /** Map from font identifiers to their CSS class names. Used for icon fonts. */
80 private _fontCssClassesByAlias;
81 /** Registered icon resolver functions. */
82 private _resolvers;
83 /**
84 * The CSS class to apply when an `<mat-icon>` component has no icon name, url, or font specified.
85 * The default 'material-icons' value assumes that the material icon font has been loaded as
86 * described at http://google.github.io/material-design-icons/#icon-font-for-the-web
87 */
88 private _defaultFontSetClass;
89 constructor(_httpClient: HttpClient, _sanitizer: DomSanitizer, document: any, _errorHandler: ErrorHandler);
90 /**
91 * Registers an icon by URL in the default namespace.
92 * @param iconName Name under which the icon should be registered.
93 * @param url
94 */
95 addSvgIcon(iconName: string, url: SafeResourceUrl, options?: IconOptions): this;
96 /**
97 * Registers an icon using an HTML string in the default namespace.
98 * @param iconName Name under which the icon should be registered.
99 * @param literal SVG source of the icon.
100 */
101 addSvgIconLiteral(iconName: string, literal: SafeHtml, options?: IconOptions): this;
102 /**
103 * Registers an icon by URL in the specified namespace.
104 * @param namespace Namespace in which the icon should be registered.
105 * @param iconName Name under which the icon should be registered.
106 * @param url
107 */
108 addSvgIconInNamespace(namespace: string, iconName: string, url: SafeResourceUrl, options?: IconOptions): this;
109 /**
110 * Registers an icon resolver function with the registry. The function will be invoked with the
111 * name and namespace of an icon when the registry tries to resolve the URL from which to fetch
112 * the icon. The resolver is expected to return a `SafeResourceUrl` that points to the icon,
113 * an object with the icon URL and icon options, or `null` if the icon is not supported. Resolvers
114 * will be invoked in the order in which they have been registered.
115 * @param resolver Resolver function to be registered.
116 */
117 addSvgIconResolver(resolver: IconResolver): this;
118 /**
119 * Registers an icon using an HTML string in the specified namespace.
120 * @param namespace Namespace in which the icon should be registered.
121 * @param iconName Name under which the icon should be registered.
122 * @param literal SVG source of the icon.
123 */
124 addSvgIconLiteralInNamespace(namespace: string, iconName: string, literal: SafeHtml, options?: IconOptions): this;
125 /**
126 * Registers an icon set by URL in the default namespace.
127 * @param url
128 */
129 addSvgIconSet(url: SafeResourceUrl, options?: IconOptions): this;
130 /**
131 * Registers an icon set using an HTML string in the default namespace.
132 * @param literal SVG source of the icon set.
133 */
134 addSvgIconSetLiteral(literal: SafeHtml, options?: IconOptions): this;
135 /**
136 * Registers an icon set by URL in the specified namespace.
137 * @param namespace Namespace in which to register the icon set.
138 * @param url
139 */
140 addSvgIconSetInNamespace(namespace: string, url: SafeResourceUrl, options?: IconOptions): this;
141 /**
142 * Registers an icon set using an HTML string in the specified namespace.
143 * @param namespace Namespace in which to register the icon set.
144 * @param literal SVG source of the icon set.
145 */
146 addSvgIconSetLiteralInNamespace(namespace: string, literal: SafeHtml, options?: IconOptions): this;
147 /**
148 * Defines an alias for a CSS class name to be used for icon fonts. Creating an matIcon
149 * component with the alias as the fontSet input will cause the class name to be applied
150 * to the `<mat-icon>` element.
151 *
152 * @param alias Alias for the font.
153 * @param className Class name override to be used instead of the alias.
154 */
155 registerFontClassAlias(alias: string, className?: string): this;
156 /**
157 * Returns the CSS class name associated with the alias by a previous call to
158 * registerFontClassAlias. If no CSS class has been associated, returns the alias unmodified.
159 */
160 classNameForFontAlias(alias: string): string;
161 /**
162 * Sets the CSS class name to be used for icon fonts when an `<mat-icon>` component does not
163 * have a fontSet input value, and is not loading an icon by name or URL.
164 *
165 * @param className
166 */
167 setDefaultFontSetClass(className: string): this;
168 /**
169 * Returns the CSS class name to be used for icon fonts when an `<mat-icon>` component does not
170 * have a fontSet input value, and is not loading an icon by name or URL.
171 */
172 getDefaultFontSetClass(): string;
173 /**
174 * Returns an Observable that produces the icon (as an `<svg>` DOM element) from the given URL.
175 * The response from the URL may be cached so this will not always cause an HTTP request, but
176 * the produced element will always be a new copy of the originally fetched icon. (That is,
177 * it will not contain any modifications made to elements previously returned).
178 *
179 * @param safeUrl URL from which to fetch the SVG icon.
180 */
181 getSvgIconFromUrl(safeUrl: SafeResourceUrl): Observable<SVGElement>;
182 /**
183 * Returns an Observable that produces the icon (as an `<svg>` DOM element) with the given name
184 * and namespace. The icon must have been previously registered with addIcon or addIconSet;
185 * if not, the Observable will throw an error.
186 *
187 * @param name Name of the icon to be retrieved.
188 * @param namespace Namespace in which to look for the icon.
189 */
190 getNamedSvgIcon(name: string, namespace?: string): Observable<SVGElement>;
191 ngOnDestroy(): void;
192 /**
193 * Returns the cached icon for a SvgIconConfig if available, or fetches it from its URL if not.
194 */
195 private _getSvgFromConfig;
196 /**
197 * Attempts to find an icon with the specified name in any of the SVG icon sets.
198 * First searches the available cached icons for a nested element with a matching name, and
199 * if found copies the element to a new `<svg>` element. If not found, fetches all icon sets
200 * that have not been cached, and searches again after all fetches are completed.
201 * The returned Observable produces the SVG element if possible, and throws
202 * an error if no icon with the specified name can be found.
203 */
204 private _getSvgFromIconSetConfigs;
205 /**
206 * Searches the cached SVG elements for the given icon sets for a nested icon element whose "id"
207 * tag matches the specified name. If found, copies the nested element to a new SVG element and
208 * returns it. Returns null if no matching element is found.
209 */
210 private _extractIconWithNameFromAnySet;
211 /**
212 * Loads the content of the icon URL specified in the SvgIconConfig and creates an SVG element
213 * from it.
214 */
215 private _loadSvgIconFromConfig;
216 /**
217 * Loads the content of the icon set URL specified in the
218 * SvgIconConfig and attaches it to the config.
219 */
220 private _loadSvgIconSetFromConfig;
221 /**
222 * Searches the cached element of the given SvgIconConfig for a nested icon element whose "id"
223 * tag matches the specified name. If found, copies the nested element to a new SVG element and
224 * returns it. Returns null if no matching element is found.
225 */
226 private _extractSvgIconFromSet;
227 /**
228 * Creates a DOM element from the given SVG string.
229 */
230 private _svgElementFromString;
231 /**
232 * Converts an element into an SVG node by cloning all of its children.
233 */
234 private _toSvgElement;
235 /**
236 * Sets the default attributes for an SVG element to be used as an icon.
237 */
238 private _setSvgAttributes;
239 /**
240 * Returns an Observable which produces the string contents of the given icon. Results may be
241 * cached, so future calls with the same URL may not cause another HTTP request.
242 */
243 private _fetchIcon;
244 /**
245 * Registers an icon config by name in the specified namespace.
246 * @param namespace Namespace in which to register the icon config.
247 * @param iconName Name under which to register the config.
248 * @param config Config to be registered.
249 */
250 private _addSvgIconConfig;
251 /**
252 * Registers an icon set config in the specified namespace.
253 * @param namespace Namespace in which to register the icon config.
254 * @param config Config to be registered.
255 */
256 private _addSvgIconSetConfig;
257 /** Parses a config's text into an SVG element. */
258 private _svgElementFromConfig;
259 /** Tries to create an icon config through the registered resolver functions. */
260 private _getIconConfigFromResolvers;
261 static ɵfac: ɵngcc0.ɵɵFactoryDeclaration<MatIconRegistry, [{ optional: true; }, null, { optional: true; }, null]>;
262}
263/** @docs-private */
264export declare function ICON_REGISTRY_PROVIDER_FACTORY(parentRegistry: MatIconRegistry, httpClient: HttpClient, sanitizer: DomSanitizer, errorHandler: ErrorHandler, document?: any): MatIconRegistry;
265/** @docs-private */
266export declare const ICON_REGISTRY_PROVIDER: {
267 provide: typeof MatIconRegistry;
268 deps: (Optional[] | typeof DomSanitizer | typeof ErrorHandler)[];
269 useFactory: typeof ICON_REGISTRY_PROVIDER_FACTORY;
270};
271
272//# sourceMappingURL=icon-registry.d.ts.map
Note: See TracBrowser for help on using the repository browser.