icon.mjs 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005
  1. import * as i0 from '@angular/core';
  2. import { SecurityContext, Injectable, Optional, Inject, SkipSelf, ErrorHandler, InjectionToken, inject, Component, ViewEncapsulation, ChangeDetectionStrategy, Attribute, Input, NgModule } from '@angular/core';
  3. import { mixinColor, MatCommonModule } from '@angular/material/core';
  4. import { coerceBooleanProperty } from '@angular/cdk/coercion';
  5. import { DOCUMENT } from '@angular/common';
  6. import { of, throwError, forkJoin, Subscription } from 'rxjs';
  7. import { tap, map, catchError, finalize, share, take } from 'rxjs/operators';
  8. import * as i1 from '@angular/common/http';
  9. import { HttpClient } from '@angular/common/http';
  10. import * as i2 from '@angular/platform-browser';
  11. import { DomSanitizer } from '@angular/platform-browser';
  12. /**
  13. * The Trusted Types policy, or null if Trusted Types are not
  14. * enabled/supported, or undefined if the policy has not been created yet.
  15. */
  16. let policy;
  17. /**
  18. * Returns the Trusted Types policy, or null if Trusted Types are not
  19. * enabled/supported. The first call to this function will create the policy.
  20. */
  21. function getPolicy() {
  22. if (policy === undefined) {
  23. policy = null;
  24. if (typeof window !== 'undefined') {
  25. const ttWindow = window;
  26. if (ttWindow.trustedTypes !== undefined) {
  27. policy = ttWindow.trustedTypes.createPolicy('angular#components', {
  28. createHTML: (s) => s,
  29. });
  30. }
  31. }
  32. }
  33. return policy;
  34. }
  35. /**
  36. * Unsafely promote a string to a TrustedHTML, falling back to strings when
  37. * Trusted Types are not available.
  38. * @security This is a security-sensitive function; any use of this function
  39. * must go through security review. In particular, it must be assured that the
  40. * provided string will never cause an XSS vulnerability if used in a context
  41. * that will be interpreted as HTML by a browser, e.g. when assigning to
  42. * element.innerHTML.
  43. */
  44. function trustedHTMLFromString(html) {
  45. return getPolicy()?.createHTML(html) || html;
  46. }
  47. /**
  48. * Returns an exception to be thrown in the case when attempting to
  49. * load an icon with a name that cannot be found.
  50. * @docs-private
  51. */
  52. function getMatIconNameNotFoundError(iconName) {
  53. return Error(`Unable to find icon with the name "${iconName}"`);
  54. }
  55. /**
  56. * Returns an exception to be thrown when the consumer attempts to use
  57. * `<mat-icon>` without including @angular/common/http.
  58. * @docs-private
  59. */
  60. function getMatIconNoHttpProviderError() {
  61. return Error('Could not find HttpClient provider for use with Angular Material icons. ' +
  62. 'Please include the HttpClientModule from @angular/common/http in your ' +
  63. 'app imports.');
  64. }
  65. /**
  66. * Returns an exception to be thrown when a URL couldn't be sanitized.
  67. * @param url URL that was attempted to be sanitized.
  68. * @docs-private
  69. */
  70. function getMatIconFailedToSanitizeUrlError(url) {
  71. return Error(`The URL provided to MatIconRegistry was not trusted as a resource URL ` +
  72. `via Angular's DomSanitizer. Attempted URL was "${url}".`);
  73. }
  74. /**
  75. * Returns an exception to be thrown when a HTML string couldn't be sanitized.
  76. * @param literal HTML that was attempted to be sanitized.
  77. * @docs-private
  78. */
  79. function getMatIconFailedToSanitizeLiteralError(literal) {
  80. return Error(`The literal provided to MatIconRegistry was not trusted as safe HTML by ` +
  81. `Angular's DomSanitizer. Attempted literal was "${literal}".`);
  82. }
  83. /**
  84. * Configuration for an icon, including the URL and possibly the cached SVG element.
  85. * @docs-private
  86. */
  87. class SvgIconConfig {
  88. constructor(url, svgText, options) {
  89. this.url = url;
  90. this.svgText = svgText;
  91. this.options = options;
  92. }
  93. }
  94. /**
  95. * Service to register and display icons used by the `<mat-icon>` component.
  96. * - Registers icon URLs by namespace and name.
  97. * - Registers icon set URLs by namespace.
  98. * - Registers aliases for CSS classes, for use with icon fonts.
  99. * - Loads icons from URLs and extracts individual icons from icon sets.
  100. */
  101. class MatIconRegistry {
  102. constructor(_httpClient, _sanitizer, document, _errorHandler) {
  103. this._httpClient = _httpClient;
  104. this._sanitizer = _sanitizer;
  105. this._errorHandler = _errorHandler;
  106. /**
  107. * URLs and cached SVG elements for individual icons. Keys are of the format "[namespace]:[icon]".
  108. */
  109. this._svgIconConfigs = new Map();
  110. /**
  111. * SvgIconConfig objects and cached SVG elements for icon sets, keyed by namespace.
  112. * Multiple icon sets can be registered under the same namespace.
  113. */
  114. this._iconSetConfigs = new Map();
  115. /** Cache for icons loaded by direct URLs. */
  116. this._cachedIconsByUrl = new Map();
  117. /** In-progress icon fetches. Used to coalesce multiple requests to the same URL. */
  118. this._inProgressUrlFetches = new Map();
  119. /** Map from font identifiers to their CSS class names. Used for icon fonts. */
  120. this._fontCssClassesByAlias = new Map();
  121. /** Registered icon resolver functions. */
  122. this._resolvers = [];
  123. /**
  124. * The CSS classes to apply when an `<mat-icon>` component has no icon name, url, or font
  125. * specified. The default 'material-icons' value assumes that the material icon font has been
  126. * loaded as described at http://google.github.io/material-design-icons/#icon-font-for-the-web
  127. */
  128. this._defaultFontSetClass = ['material-icons', 'mat-ligature-font'];
  129. this._document = document;
  130. }
  131. /**
  132. * Registers an icon by URL in the default namespace.
  133. * @param iconName Name under which the icon should be registered.
  134. * @param url
  135. */
  136. addSvgIcon(iconName, url, options) {
  137. return this.addSvgIconInNamespace('', iconName, url, options);
  138. }
  139. /**
  140. * Registers an icon using an HTML string in the default namespace.
  141. * @param iconName Name under which the icon should be registered.
  142. * @param literal SVG source of the icon.
  143. */
  144. addSvgIconLiteral(iconName, literal, options) {
  145. return this.addSvgIconLiteralInNamespace('', iconName, literal, options);
  146. }
  147. /**
  148. * Registers an icon by URL in the specified namespace.
  149. * @param namespace Namespace in which the icon should be registered.
  150. * @param iconName Name under which the icon should be registered.
  151. * @param url
  152. */
  153. addSvgIconInNamespace(namespace, iconName, url, options) {
  154. return this._addSvgIconConfig(namespace, iconName, new SvgIconConfig(url, null, options));
  155. }
  156. /**
  157. * Registers an icon resolver function with the registry. The function will be invoked with the
  158. * name and namespace of an icon when the registry tries to resolve the URL from which to fetch
  159. * the icon. The resolver is expected to return a `SafeResourceUrl` that points to the icon,
  160. * an object with the icon URL and icon options, or `null` if the icon is not supported. Resolvers
  161. * will be invoked in the order in which they have been registered.
  162. * @param resolver Resolver function to be registered.
  163. */
  164. addSvgIconResolver(resolver) {
  165. this._resolvers.push(resolver);
  166. return this;
  167. }
  168. /**
  169. * Registers an icon using an HTML string in the specified namespace.
  170. * @param namespace Namespace in which the icon should be registered.
  171. * @param iconName Name under which the icon should be registered.
  172. * @param literal SVG source of the icon.
  173. */
  174. addSvgIconLiteralInNamespace(namespace, iconName, literal, options) {
  175. const cleanLiteral = this._sanitizer.sanitize(SecurityContext.HTML, literal);
  176. // TODO: add an ngDevMode check
  177. if (!cleanLiteral) {
  178. throw getMatIconFailedToSanitizeLiteralError(literal);
  179. }
  180. // Security: The literal is passed in as SafeHtml, and is thus trusted.
  181. const trustedLiteral = trustedHTMLFromString(cleanLiteral);
  182. return this._addSvgIconConfig(namespace, iconName, new SvgIconConfig('', trustedLiteral, options));
  183. }
  184. /**
  185. * Registers an icon set by URL in the default namespace.
  186. * @param url
  187. */
  188. addSvgIconSet(url, options) {
  189. return this.addSvgIconSetInNamespace('', url, options);
  190. }
  191. /**
  192. * Registers an icon set using an HTML string in the default namespace.
  193. * @param literal SVG source of the icon set.
  194. */
  195. addSvgIconSetLiteral(literal, options) {
  196. return this.addSvgIconSetLiteralInNamespace('', literal, options);
  197. }
  198. /**
  199. * Registers an icon set by URL in the specified namespace.
  200. * @param namespace Namespace in which to register the icon set.
  201. * @param url
  202. */
  203. addSvgIconSetInNamespace(namespace, url, options) {
  204. return this._addSvgIconSetConfig(namespace, new SvgIconConfig(url, null, options));
  205. }
  206. /**
  207. * Registers an icon set using an HTML string in the specified namespace.
  208. * @param namespace Namespace in which to register the icon set.
  209. * @param literal SVG source of the icon set.
  210. */
  211. addSvgIconSetLiteralInNamespace(namespace, literal, options) {
  212. const cleanLiteral = this._sanitizer.sanitize(SecurityContext.HTML, literal);
  213. if (!cleanLiteral) {
  214. throw getMatIconFailedToSanitizeLiteralError(literal);
  215. }
  216. // Security: The literal is passed in as SafeHtml, and is thus trusted.
  217. const trustedLiteral = trustedHTMLFromString(cleanLiteral);
  218. return this._addSvgIconSetConfig(namespace, new SvgIconConfig('', trustedLiteral, options));
  219. }
  220. /**
  221. * Defines an alias for CSS class names to be used for icon fonts. Creating an matIcon
  222. * component with the alias as the fontSet input will cause the class name to be applied
  223. * to the `<mat-icon>` element.
  224. *
  225. * If the registered font is a ligature font, then don't forget to also include the special
  226. * class `mat-ligature-font` to allow the usage via attribute. So register like this:
  227. *
  228. * ```ts
  229. * iconRegistry.registerFontClassAlias('f1', 'font1 mat-ligature-font');
  230. * ```
  231. *
  232. * And use like this:
  233. *
  234. * ```html
  235. * <mat-icon fontSet="f1" fontIcon="home"></mat-icon>
  236. * ```
  237. *
  238. * @param alias Alias for the font.
  239. * @param classNames Class names override to be used instead of the alias.
  240. */
  241. registerFontClassAlias(alias, classNames = alias) {
  242. this._fontCssClassesByAlias.set(alias, classNames);
  243. return this;
  244. }
  245. /**
  246. * Returns the CSS class name associated with the alias by a previous call to
  247. * registerFontClassAlias. If no CSS class has been associated, returns the alias unmodified.
  248. */
  249. classNameForFontAlias(alias) {
  250. return this._fontCssClassesByAlias.get(alias) || alias;
  251. }
  252. /**
  253. * Sets the CSS classes to be used for icon fonts when an `<mat-icon>` component does not
  254. * have a fontSet input value, and is not loading an icon by name or URL.
  255. */
  256. setDefaultFontSetClass(...classNames) {
  257. this._defaultFontSetClass = classNames;
  258. return this;
  259. }
  260. /**
  261. * Returns the CSS classes to be used for icon fonts when an `<mat-icon>` component does not
  262. * have a fontSet input value, and is not loading an icon by name or URL.
  263. */
  264. getDefaultFontSetClass() {
  265. return this._defaultFontSetClass;
  266. }
  267. /**
  268. * Returns an Observable that produces the icon (as an `<svg>` DOM element) from the given URL.
  269. * The response from the URL may be cached so this will not always cause an HTTP request, but
  270. * the produced element will always be a new copy of the originally fetched icon. (That is,
  271. * it will not contain any modifications made to elements previously returned).
  272. *
  273. * @param safeUrl URL from which to fetch the SVG icon.
  274. */
  275. getSvgIconFromUrl(safeUrl) {
  276. const url = this._sanitizer.sanitize(SecurityContext.RESOURCE_URL, safeUrl);
  277. if (!url) {
  278. throw getMatIconFailedToSanitizeUrlError(safeUrl);
  279. }
  280. const cachedIcon = this._cachedIconsByUrl.get(url);
  281. if (cachedIcon) {
  282. return of(cloneSvg(cachedIcon));
  283. }
  284. return this._loadSvgIconFromConfig(new SvgIconConfig(safeUrl, null)).pipe(tap(svg => this._cachedIconsByUrl.set(url, svg)), map(svg => cloneSvg(svg)));
  285. }
  286. /**
  287. * Returns an Observable that produces the icon (as an `<svg>` DOM element) with the given name
  288. * and namespace. The icon must have been previously registered with addIcon or addIconSet;
  289. * if not, the Observable will throw an error.
  290. *
  291. * @param name Name of the icon to be retrieved.
  292. * @param namespace Namespace in which to look for the icon.
  293. */
  294. getNamedSvgIcon(name, namespace = '') {
  295. const key = iconKey(namespace, name);
  296. let config = this._svgIconConfigs.get(key);
  297. // Return (copy of) cached icon if possible.
  298. if (config) {
  299. return this._getSvgFromConfig(config);
  300. }
  301. // Otherwise try to resolve the config from one of the resolver functions.
  302. config = this._getIconConfigFromResolvers(namespace, name);
  303. if (config) {
  304. this._svgIconConfigs.set(key, config);
  305. return this._getSvgFromConfig(config);
  306. }
  307. // See if we have any icon sets registered for the namespace.
  308. const iconSetConfigs = this._iconSetConfigs.get(namespace);
  309. if (iconSetConfigs) {
  310. return this._getSvgFromIconSetConfigs(name, iconSetConfigs);
  311. }
  312. return throwError(getMatIconNameNotFoundError(key));
  313. }
  314. ngOnDestroy() {
  315. this._resolvers = [];
  316. this._svgIconConfigs.clear();
  317. this._iconSetConfigs.clear();
  318. this._cachedIconsByUrl.clear();
  319. }
  320. /**
  321. * Returns the cached icon for a SvgIconConfig if available, or fetches it from its URL if not.
  322. */
  323. _getSvgFromConfig(config) {
  324. if (config.svgText) {
  325. // We already have the SVG element for this icon, return a copy.
  326. return of(cloneSvg(this._svgElementFromConfig(config)));
  327. }
  328. else {
  329. // Fetch the icon from the config's URL, cache it, and return a copy.
  330. return this._loadSvgIconFromConfig(config).pipe(map(svg => cloneSvg(svg)));
  331. }
  332. }
  333. /**
  334. * Attempts to find an icon with the specified name in any of the SVG icon sets.
  335. * First searches the available cached icons for a nested element with a matching name, and
  336. * if found copies the element to a new `<svg>` element. If not found, fetches all icon sets
  337. * that have not been cached, and searches again after all fetches are completed.
  338. * The returned Observable produces the SVG element if possible, and throws
  339. * an error if no icon with the specified name can be found.
  340. */
  341. _getSvgFromIconSetConfigs(name, iconSetConfigs) {
  342. // For all the icon set SVG elements we've fetched, see if any contain an icon with the
  343. // requested name.
  344. const namedIcon = this._extractIconWithNameFromAnySet(name, iconSetConfigs);
  345. if (namedIcon) {
  346. // We could cache namedIcon in _svgIconConfigs, but since we have to make a copy every
  347. // time anyway, there's probably not much advantage compared to just always extracting
  348. // it from the icon set.
  349. return of(namedIcon);
  350. }
  351. // Not found in any cached icon sets. If there are icon sets with URLs that we haven't
  352. // fetched, fetch them now and look for iconName in the results.
  353. const iconSetFetchRequests = iconSetConfigs
  354. .filter(iconSetConfig => !iconSetConfig.svgText)
  355. .map(iconSetConfig => {
  356. return this._loadSvgIconSetFromConfig(iconSetConfig).pipe(catchError((err) => {
  357. const url = this._sanitizer.sanitize(SecurityContext.RESOURCE_URL, iconSetConfig.url);
  358. // Swallow errors fetching individual URLs so the
  359. // combined Observable won't necessarily fail.
  360. const errorMessage = `Loading icon set URL: ${url} failed: ${err.message}`;
  361. this._errorHandler.handleError(new Error(errorMessage));
  362. return of(null);
  363. }));
  364. });
  365. // Fetch all the icon set URLs. When the requests complete, every IconSet should have a
  366. // cached SVG element (unless the request failed), and we can check again for the icon.
  367. return forkJoin(iconSetFetchRequests).pipe(map(() => {
  368. const foundIcon = this._extractIconWithNameFromAnySet(name, iconSetConfigs);
  369. // TODO: add an ngDevMode check
  370. if (!foundIcon) {
  371. throw getMatIconNameNotFoundError(name);
  372. }
  373. return foundIcon;
  374. }));
  375. }
  376. /**
  377. * Searches the cached SVG elements for the given icon sets for a nested icon element whose "id"
  378. * tag matches the specified name. If found, copies the nested element to a new SVG element and
  379. * returns it. Returns null if no matching element is found.
  380. */
  381. _extractIconWithNameFromAnySet(iconName, iconSetConfigs) {
  382. // Iterate backwards, so icon sets added later have precedence.
  383. for (let i = iconSetConfigs.length - 1; i >= 0; i--) {
  384. const config = iconSetConfigs[i];
  385. // Parsing the icon set's text into an SVG element can be expensive. We can avoid some of
  386. // the parsing by doing a quick check using `indexOf` to see if there's any chance for the
  387. // icon to be in the set. This won't be 100% accurate, but it should help us avoid at least
  388. // some of the parsing.
  389. if (config.svgText && config.svgText.toString().indexOf(iconName) > -1) {
  390. const svg = this._svgElementFromConfig(config);
  391. const foundIcon = this._extractSvgIconFromSet(svg, iconName, config.options);
  392. if (foundIcon) {
  393. return foundIcon;
  394. }
  395. }
  396. }
  397. return null;
  398. }
  399. /**
  400. * Loads the content of the icon URL specified in the SvgIconConfig and creates an SVG element
  401. * from it.
  402. */
  403. _loadSvgIconFromConfig(config) {
  404. return this._fetchIcon(config).pipe(tap(svgText => (config.svgText = svgText)), map(() => this._svgElementFromConfig(config)));
  405. }
  406. /**
  407. * Loads the content of the icon set URL specified in the
  408. * SvgIconConfig and attaches it to the config.
  409. */
  410. _loadSvgIconSetFromConfig(config) {
  411. if (config.svgText) {
  412. return of(null);
  413. }
  414. return this._fetchIcon(config).pipe(tap(svgText => (config.svgText = svgText)));
  415. }
  416. /**
  417. * Searches the cached element of the given SvgIconConfig for a nested icon element whose "id"
  418. * tag matches the specified name. If found, copies the nested element to a new SVG element and
  419. * returns it. Returns null if no matching element is found.
  420. */
  421. _extractSvgIconFromSet(iconSet, iconName, options) {
  422. // Use the `id="iconName"` syntax in order to escape special
  423. // characters in the ID (versus using the #iconName syntax).
  424. const iconSource = iconSet.querySelector(`[id="${iconName}"]`);
  425. if (!iconSource) {
  426. return null;
  427. }
  428. // Clone the element and remove the ID to prevent multiple elements from being added
  429. // to the page with the same ID.
  430. const iconElement = iconSource.cloneNode(true);
  431. iconElement.removeAttribute('id');
  432. // If the icon node is itself an <svg> node, clone and return it directly. If not, set it as
  433. // the content of a new <svg> node.
  434. if (iconElement.nodeName.toLowerCase() === 'svg') {
  435. return this._setSvgAttributes(iconElement, options);
  436. }
  437. // If the node is a <symbol>, it won't be rendered so we have to convert it into <svg>. Note
  438. // that the same could be achieved by referring to it via <use href="#id">, however the <use>
  439. // tag is problematic on Firefox, because it needs to include the current page path.
  440. if (iconElement.nodeName.toLowerCase() === 'symbol') {
  441. return this._setSvgAttributes(this._toSvgElement(iconElement), options);
  442. }
  443. // createElement('SVG') doesn't work as expected; the DOM ends up with
  444. // the correct nodes, but the SVG content doesn't render. Instead we
  445. // have to create an empty SVG node using innerHTML and append its content.
  446. // Elements created using DOMParser.parseFromString have the same problem.
  447. // http://stackoverflow.com/questions/23003278/svg-innerhtml-in-firefox-can-not-display
  448. const svg = this._svgElementFromString(trustedHTMLFromString('<svg></svg>'));
  449. // Clone the node so we don't remove it from the parent icon set element.
  450. svg.appendChild(iconElement);
  451. return this._setSvgAttributes(svg, options);
  452. }
  453. /**
  454. * Creates a DOM element from the given SVG string.
  455. */
  456. _svgElementFromString(str) {
  457. const div = this._document.createElement('DIV');
  458. div.innerHTML = str;
  459. const svg = div.querySelector('svg');
  460. // TODO: add an ngDevMode check
  461. if (!svg) {
  462. throw Error('<svg> tag not found');
  463. }
  464. return svg;
  465. }
  466. /**
  467. * Converts an element into an SVG node by cloning all of its children.
  468. */
  469. _toSvgElement(element) {
  470. const svg = this._svgElementFromString(trustedHTMLFromString('<svg></svg>'));
  471. const attributes = element.attributes;
  472. // Copy over all the attributes from the `symbol` to the new SVG, except the id.
  473. for (let i = 0; i < attributes.length; i++) {
  474. const { name, value } = attributes[i];
  475. if (name !== 'id') {
  476. svg.setAttribute(name, value);
  477. }
  478. }
  479. for (let i = 0; i < element.childNodes.length; i++) {
  480. if (element.childNodes[i].nodeType === this._document.ELEMENT_NODE) {
  481. svg.appendChild(element.childNodes[i].cloneNode(true));
  482. }
  483. }
  484. return svg;
  485. }
  486. /**
  487. * Sets the default attributes for an SVG element to be used as an icon.
  488. */
  489. _setSvgAttributes(svg, options) {
  490. svg.setAttribute('fit', '');
  491. svg.setAttribute('height', '100%');
  492. svg.setAttribute('width', '100%');
  493. svg.setAttribute('preserveAspectRatio', 'xMidYMid meet');
  494. svg.setAttribute('focusable', 'false'); // Disable IE11 default behavior to make SVGs focusable.
  495. if (options && options.viewBox) {
  496. svg.setAttribute('viewBox', options.viewBox);
  497. }
  498. return svg;
  499. }
  500. /**
  501. * Returns an Observable which produces the string contents of the given icon. Results may be
  502. * cached, so future calls with the same URL may not cause another HTTP request.
  503. */
  504. _fetchIcon(iconConfig) {
  505. const { url: safeUrl, options } = iconConfig;
  506. const withCredentials = options?.withCredentials ?? false;
  507. if (!this._httpClient) {
  508. throw getMatIconNoHttpProviderError();
  509. }
  510. // TODO: add an ngDevMode check
  511. if (safeUrl == null) {
  512. throw Error(`Cannot fetch icon from URL "${safeUrl}".`);
  513. }
  514. const url = this._sanitizer.sanitize(SecurityContext.RESOURCE_URL, safeUrl);
  515. // TODO: add an ngDevMode check
  516. if (!url) {
  517. throw getMatIconFailedToSanitizeUrlError(safeUrl);
  518. }
  519. // Store in-progress fetches to avoid sending a duplicate request for a URL when there is
  520. // already a request in progress for that URL. It's necessary to call share() on the
  521. // Observable returned by http.get() so that multiple subscribers don't cause multiple XHRs.
  522. const inProgressFetch = this._inProgressUrlFetches.get(url);
  523. if (inProgressFetch) {
  524. return inProgressFetch;
  525. }
  526. const req = this._httpClient.get(url, { responseType: 'text', withCredentials }).pipe(map(svg => {
  527. // Security: This SVG is fetched from a SafeResourceUrl, and is thus
  528. // trusted HTML.
  529. return trustedHTMLFromString(svg);
  530. }), finalize(() => this._inProgressUrlFetches.delete(url)), share());
  531. this._inProgressUrlFetches.set(url, req);
  532. return req;
  533. }
  534. /**
  535. * Registers an icon config by name in the specified namespace.
  536. * @param namespace Namespace in which to register the icon config.
  537. * @param iconName Name under which to register the config.
  538. * @param config Config to be registered.
  539. */
  540. _addSvgIconConfig(namespace, iconName, config) {
  541. this._svgIconConfigs.set(iconKey(namespace, iconName), config);
  542. return this;
  543. }
  544. /**
  545. * Registers an icon set config in the specified namespace.
  546. * @param namespace Namespace in which to register the icon config.
  547. * @param config Config to be registered.
  548. */
  549. _addSvgIconSetConfig(namespace, config) {
  550. const configNamespace = this._iconSetConfigs.get(namespace);
  551. if (configNamespace) {
  552. configNamespace.push(config);
  553. }
  554. else {
  555. this._iconSetConfigs.set(namespace, [config]);
  556. }
  557. return this;
  558. }
  559. /** Parses a config's text into an SVG element. */
  560. _svgElementFromConfig(config) {
  561. if (!config.svgElement) {
  562. const svg = this._svgElementFromString(config.svgText);
  563. this._setSvgAttributes(svg, config.options);
  564. config.svgElement = svg;
  565. }
  566. return config.svgElement;
  567. }
  568. /** Tries to create an icon config through the registered resolver functions. */
  569. _getIconConfigFromResolvers(namespace, name) {
  570. for (let i = 0; i < this._resolvers.length; i++) {
  571. const result = this._resolvers[i](name, namespace);
  572. if (result) {
  573. return isSafeUrlWithOptions(result)
  574. ? new SvgIconConfig(result.url, null, result.options)
  575. : new SvgIconConfig(result, null);
  576. }
  577. }
  578. return undefined;
  579. }
  580. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatIconRegistry, deps: [{ token: i1.HttpClient, optional: true }, { token: i2.DomSanitizer }, { token: DOCUMENT, optional: true }, { token: i0.ErrorHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
  581. static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatIconRegistry, providedIn: 'root' }); }
  582. }
  583. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatIconRegistry, decorators: [{
  584. type: Injectable,
  585. args: [{ providedIn: 'root' }]
  586. }], ctorParameters: function () { return [{ type: i1.HttpClient, decorators: [{
  587. type: Optional
  588. }] }, { type: i2.DomSanitizer }, { type: undefined, decorators: [{
  589. type: Optional
  590. }, {
  591. type: Inject,
  592. args: [DOCUMENT]
  593. }] }, { type: i0.ErrorHandler }]; } });
  594. /** @docs-private */
  595. function ICON_REGISTRY_PROVIDER_FACTORY(parentRegistry, httpClient, sanitizer, errorHandler, document) {
  596. return parentRegistry || new MatIconRegistry(httpClient, sanitizer, document, errorHandler);
  597. }
  598. /** @docs-private */
  599. const ICON_REGISTRY_PROVIDER = {
  600. // If there is already an MatIconRegistry available, use that. Otherwise, provide a new one.
  601. provide: MatIconRegistry,
  602. deps: [
  603. [new Optional(), new SkipSelf(), MatIconRegistry],
  604. [new Optional(), HttpClient],
  605. DomSanitizer,
  606. ErrorHandler,
  607. [new Optional(), DOCUMENT],
  608. ],
  609. useFactory: ICON_REGISTRY_PROVIDER_FACTORY,
  610. };
  611. /** Clones an SVGElement while preserving type information. */
  612. function cloneSvg(svg) {
  613. return svg.cloneNode(true);
  614. }
  615. /** Returns the cache key to use for an icon namespace and name. */
  616. function iconKey(namespace, name) {
  617. return namespace + ':' + name;
  618. }
  619. function isSafeUrlWithOptions(value) {
  620. return !!(value.url && value.options);
  621. }
  622. // Boilerplate for applying mixins to MatIcon.
  623. /** @docs-private */
  624. const _MatIconBase = mixinColor(class {
  625. constructor(_elementRef) {
  626. this._elementRef = _elementRef;
  627. }
  628. });
  629. /** Injection token to be used to override the default options for `mat-icon`. */
  630. const MAT_ICON_DEFAULT_OPTIONS = new InjectionToken('MAT_ICON_DEFAULT_OPTIONS');
  631. /**
  632. * Injection token used to provide the current location to `MatIcon`.
  633. * Used to handle server-side rendering and to stub out during unit tests.
  634. * @docs-private
  635. */
  636. const MAT_ICON_LOCATION = new InjectionToken('mat-icon-location', {
  637. providedIn: 'root',
  638. factory: MAT_ICON_LOCATION_FACTORY,
  639. });
  640. /** @docs-private */
  641. function MAT_ICON_LOCATION_FACTORY() {
  642. const _document = inject(DOCUMENT);
  643. const _location = _document ? _document.location : null;
  644. return {
  645. // Note that this needs to be a function, rather than a property, because Angular
  646. // will only resolve it once, but we want the current path on each call.
  647. getPathname: () => (_location ? _location.pathname + _location.search : ''),
  648. };
  649. }
  650. /** SVG attributes that accept a FuncIRI (e.g. `url(<something>)`). */
  651. const funcIriAttributes = [
  652. 'clip-path',
  653. 'color-profile',
  654. 'src',
  655. 'cursor',
  656. 'fill',
  657. 'filter',
  658. 'marker',
  659. 'marker-start',
  660. 'marker-mid',
  661. 'marker-end',
  662. 'mask',
  663. 'stroke',
  664. ];
  665. /** Selector that can be used to find all elements that are using a `FuncIRI`. */
  666. const funcIriAttributeSelector = funcIriAttributes.map(attr => `[${attr}]`).join(', ');
  667. /** Regex that can be used to extract the id out of a FuncIRI. */
  668. const funcIriPattern = /^url\(['"]?#(.*?)['"]?\)$/;
  669. /**
  670. * Component to display an icon. It can be used in the following ways:
  671. *
  672. * - Specify the svgIcon input to load an SVG icon from a URL previously registered with the
  673. * addSvgIcon, addSvgIconInNamespace, addSvgIconSet, or addSvgIconSetInNamespace methods of
  674. * MatIconRegistry. If the svgIcon value contains a colon it is assumed to be in the format
  675. * "[namespace]:[name]", if not the value will be the name of an icon in the default namespace.
  676. * Examples:
  677. * `<mat-icon svgIcon="left-arrow"></mat-icon>
  678. * <mat-icon svgIcon="animals:cat"></mat-icon>`
  679. *
  680. * - Use a font ligature as an icon by putting the ligature text in the `fontIcon` attribute or the
  681. * content of the `<mat-icon>` component. If you register a custom font class, don't forget to also
  682. * include the special class `mat-ligature-font`. It is recommended to use the attribute alternative
  683. * to prevent the ligature text to be selectable and to appear in search engine results.
  684. * By default, the Material icons font is used as described at
  685. * http://google.github.io/material-design-icons/#icon-font-for-the-web. You can specify an
  686. * alternate font by setting the fontSet input to either the CSS class to apply to use the
  687. * desired font, or to an alias previously registered with MatIconRegistry.registerFontClassAlias.
  688. * Examples:
  689. * `<mat-icon fontIcon="home"></mat-icon>
  690. * <mat-icon>home</mat-icon>
  691. * <mat-icon fontSet="myfont" fontIcon="sun"></mat-icon>
  692. * <mat-icon fontSet="myfont">sun</mat-icon>`
  693. *
  694. * - Specify a font glyph to be included via CSS rules by setting the fontSet input to specify the
  695. * font, and the fontIcon input to specify the icon. Typically the fontIcon will specify a
  696. * CSS class which causes the glyph to be displayed via a :before selector, as in
  697. * https://fortawesome.github.io/Font-Awesome/examples/
  698. * Example:
  699. * `<mat-icon fontSet="fa" fontIcon="alarm"></mat-icon>`
  700. */
  701. class MatIcon extends _MatIconBase {
  702. /**
  703. * Whether the icon should be inlined, automatically sizing the icon to match the font size of
  704. * the element the icon is contained in.
  705. */
  706. get inline() {
  707. return this._inline;
  708. }
  709. set inline(inline) {
  710. this._inline = coerceBooleanProperty(inline);
  711. }
  712. /** Name of the icon in the SVG icon set. */
  713. get svgIcon() {
  714. return this._svgIcon;
  715. }
  716. set svgIcon(value) {
  717. if (value !== this._svgIcon) {
  718. if (value) {
  719. this._updateSvgIcon(value);
  720. }
  721. else if (this._svgIcon) {
  722. this._clearSvgElement();
  723. }
  724. this._svgIcon = value;
  725. }
  726. }
  727. /** Font set that the icon is a part of. */
  728. get fontSet() {
  729. return this._fontSet;
  730. }
  731. set fontSet(value) {
  732. const newValue = this._cleanupFontValue(value);
  733. if (newValue !== this._fontSet) {
  734. this._fontSet = newValue;
  735. this._updateFontIconClasses();
  736. }
  737. }
  738. /** Name of an icon within a font set. */
  739. get fontIcon() {
  740. return this._fontIcon;
  741. }
  742. set fontIcon(value) {
  743. const newValue = this._cleanupFontValue(value);
  744. if (newValue !== this._fontIcon) {
  745. this._fontIcon = newValue;
  746. this._updateFontIconClasses();
  747. }
  748. }
  749. constructor(elementRef, _iconRegistry, ariaHidden, _location, _errorHandler, defaults) {
  750. super(elementRef);
  751. this._iconRegistry = _iconRegistry;
  752. this._location = _location;
  753. this._errorHandler = _errorHandler;
  754. this._inline = false;
  755. this._previousFontSetClass = [];
  756. /** Subscription to the current in-progress SVG icon request. */
  757. this._currentIconFetch = Subscription.EMPTY;
  758. if (defaults) {
  759. if (defaults.color) {
  760. this.color = this.defaultColor = defaults.color;
  761. }
  762. if (defaults.fontSet) {
  763. this.fontSet = defaults.fontSet;
  764. }
  765. }
  766. // If the user has not explicitly set aria-hidden, mark the icon as hidden, as this is
  767. // the right thing to do for the majority of icon use-cases.
  768. if (!ariaHidden) {
  769. elementRef.nativeElement.setAttribute('aria-hidden', 'true');
  770. }
  771. }
  772. /**
  773. * Splits an svgIcon binding value into its icon set and icon name components.
  774. * Returns a 2-element array of [(icon set), (icon name)].
  775. * The separator for the two fields is ':'. If there is no separator, an empty
  776. * string is returned for the icon set and the entire value is returned for
  777. * the icon name. If the argument is falsy, returns an array of two empty strings.
  778. * Throws an error if the name contains two or more ':' separators.
  779. * Examples:
  780. * `'social:cake' -> ['social', 'cake']
  781. * 'penguin' -> ['', 'penguin']
  782. * null -> ['', '']
  783. * 'a:b:c' -> (throws Error)`
  784. */
  785. _splitIconName(iconName) {
  786. if (!iconName) {
  787. return ['', ''];
  788. }
  789. const parts = iconName.split(':');
  790. switch (parts.length) {
  791. case 1:
  792. return ['', parts[0]]; // Use default namespace.
  793. case 2:
  794. return parts;
  795. default:
  796. throw Error(`Invalid icon name: "${iconName}"`); // TODO: add an ngDevMode check
  797. }
  798. }
  799. ngOnInit() {
  800. // Update font classes because ngOnChanges won't be called if none of the inputs are present,
  801. // e.g. <mat-icon>arrow</mat-icon> In this case we need to add a CSS class for the default font.
  802. this._updateFontIconClasses();
  803. }
  804. ngAfterViewChecked() {
  805. const cachedElements = this._elementsWithExternalReferences;
  806. if (cachedElements && cachedElements.size) {
  807. const newPath = this._location.getPathname();
  808. // We need to check whether the URL has changed on each change detection since
  809. // the browser doesn't have an API that will let us react on link clicks and
  810. // we can't depend on the Angular router. The references need to be updated,
  811. // because while most browsers don't care whether the URL is correct after
  812. // the first render, Safari will break if the user navigates to a different
  813. // page and the SVG isn't re-rendered.
  814. if (newPath !== this._previousPath) {
  815. this._previousPath = newPath;
  816. this._prependPathToReferences(newPath);
  817. }
  818. }
  819. }
  820. ngOnDestroy() {
  821. this._currentIconFetch.unsubscribe();
  822. if (this._elementsWithExternalReferences) {
  823. this._elementsWithExternalReferences.clear();
  824. }
  825. }
  826. _usingFontIcon() {
  827. return !this.svgIcon;
  828. }
  829. _setSvgElement(svg) {
  830. this._clearSvgElement();
  831. // Note: we do this fix here, rather than the icon registry, because the
  832. // references have to point to the URL at the time that the icon was created.
  833. const path = this._location.getPathname();
  834. this._previousPath = path;
  835. this._cacheChildrenWithExternalReferences(svg);
  836. this._prependPathToReferences(path);
  837. this._elementRef.nativeElement.appendChild(svg);
  838. }
  839. _clearSvgElement() {
  840. const layoutElement = this._elementRef.nativeElement;
  841. let childCount = layoutElement.childNodes.length;
  842. if (this._elementsWithExternalReferences) {
  843. this._elementsWithExternalReferences.clear();
  844. }
  845. // Remove existing non-element child nodes and SVGs, and add the new SVG element. Note that
  846. // we can't use innerHTML, because IE will throw if the element has a data binding.
  847. while (childCount--) {
  848. const child = layoutElement.childNodes[childCount];
  849. // 1 corresponds to Node.ELEMENT_NODE. We remove all non-element nodes in order to get rid
  850. // of any loose text nodes, as well as any SVG elements in order to remove any old icons.
  851. if (child.nodeType !== 1 || child.nodeName.toLowerCase() === 'svg') {
  852. child.remove();
  853. }
  854. }
  855. }
  856. _updateFontIconClasses() {
  857. if (!this._usingFontIcon()) {
  858. return;
  859. }
  860. const elem = this._elementRef.nativeElement;
  861. const fontSetClasses = (this.fontSet
  862. ? this._iconRegistry.classNameForFontAlias(this.fontSet).split(/ +/)
  863. : this._iconRegistry.getDefaultFontSetClass()).filter(className => className.length > 0);
  864. this._previousFontSetClass.forEach(className => elem.classList.remove(className));
  865. fontSetClasses.forEach(className => elem.classList.add(className));
  866. this._previousFontSetClass = fontSetClasses;
  867. if (this.fontIcon !== this._previousFontIconClass &&
  868. !fontSetClasses.includes('mat-ligature-font')) {
  869. if (this._previousFontIconClass) {
  870. elem.classList.remove(this._previousFontIconClass);
  871. }
  872. if (this.fontIcon) {
  873. elem.classList.add(this.fontIcon);
  874. }
  875. this._previousFontIconClass = this.fontIcon;
  876. }
  877. }
  878. /**
  879. * Cleans up a value to be used as a fontIcon or fontSet.
  880. * Since the value ends up being assigned as a CSS class, we
  881. * have to trim the value and omit space-separated values.
  882. */
  883. _cleanupFontValue(value) {
  884. return typeof value === 'string' ? value.trim().split(' ')[0] : value;
  885. }
  886. /**
  887. * Prepends the current path to all elements that have an attribute pointing to a `FuncIRI`
  888. * reference. This is required because WebKit browsers require references to be prefixed with
  889. * the current path, if the page has a `base` tag.
  890. */
  891. _prependPathToReferences(path) {
  892. const elements = this._elementsWithExternalReferences;
  893. if (elements) {
  894. elements.forEach((attrs, element) => {
  895. attrs.forEach(attr => {
  896. element.setAttribute(attr.name, `url('${path}#${attr.value}')`);
  897. });
  898. });
  899. }
  900. }
  901. /**
  902. * Caches the children of an SVG element that have `url()`
  903. * references that we need to prefix with the current path.
  904. */
  905. _cacheChildrenWithExternalReferences(element) {
  906. const elementsWithFuncIri = element.querySelectorAll(funcIriAttributeSelector);
  907. const elements = (this._elementsWithExternalReferences =
  908. this._elementsWithExternalReferences || new Map());
  909. for (let i = 0; i < elementsWithFuncIri.length; i++) {
  910. funcIriAttributes.forEach(attr => {
  911. const elementWithReference = elementsWithFuncIri[i];
  912. const value = elementWithReference.getAttribute(attr);
  913. const match = value ? value.match(funcIriPattern) : null;
  914. if (match) {
  915. let attributes = elements.get(elementWithReference);
  916. if (!attributes) {
  917. attributes = [];
  918. elements.set(elementWithReference, attributes);
  919. }
  920. attributes.push({ name: attr, value: match[1] });
  921. }
  922. });
  923. }
  924. }
  925. /** Sets a new SVG icon with a particular name. */
  926. _updateSvgIcon(rawName) {
  927. this._svgNamespace = null;
  928. this._svgName = null;
  929. this._currentIconFetch.unsubscribe();
  930. if (rawName) {
  931. const [namespace, iconName] = this._splitIconName(rawName);
  932. if (namespace) {
  933. this._svgNamespace = namespace;
  934. }
  935. if (iconName) {
  936. this._svgName = iconName;
  937. }
  938. this._currentIconFetch = this._iconRegistry
  939. .getNamedSvgIcon(iconName, namespace)
  940. .pipe(take(1))
  941. .subscribe(svg => this._setSvgElement(svg), (err) => {
  942. const errorMessage = `Error retrieving icon ${namespace}:${iconName}! ${err.message}`;
  943. this._errorHandler.handleError(new Error(errorMessage));
  944. });
  945. }
  946. }
  947. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatIcon, deps: [{ token: i0.ElementRef }, { token: MatIconRegistry }, { token: 'aria-hidden', attribute: true }, { token: MAT_ICON_LOCATION }, { token: i0.ErrorHandler }, { token: MAT_ICON_DEFAULT_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.Component }); }
  948. static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.0", type: MatIcon, selector: "mat-icon", inputs: { color: "color", inline: "inline", svgIcon: "svgIcon", fontSet: "fontSet", fontIcon: "fontIcon" }, host: { attributes: { "role": "img" }, properties: { "attr.data-mat-icon-type": "_usingFontIcon() ? \"font\" : \"svg\"", "attr.data-mat-icon-name": "_svgName || fontIcon", "attr.data-mat-icon-namespace": "_svgNamespace || fontSet", "attr.fontIcon": "_usingFontIcon() ? fontIcon : null", "class.mat-icon-inline": "inline", "class.mat-icon-no-color": "color !== \"primary\" && color !== \"accent\" && color !== \"warn\"" }, classAttribute: "mat-icon notranslate" }, exportAs: ["matIcon"], usesInheritance: true, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, styles: [".mat-icon{-webkit-user-select:none;user-select:none;background-repeat:no-repeat;display:inline-block;fill:currentColor;height:24px;width:24px;overflow:hidden}.mat-icon.mat-icon-inline{font-size:inherit;height:inherit;line-height:inherit;width:inherit}.mat-icon.mat-ligature-font[fontIcon]::before{content:attr(fontIcon)}[dir=rtl] .mat-icon-rtl-mirror{transform:scale(-1, 1)}.mat-form-field:not(.mat-form-field-appearance-legacy) .mat-form-field-prefix .mat-icon,.mat-form-field:not(.mat-form-field-appearance-legacy) .mat-form-field-suffix .mat-icon{display:block}.mat-form-field:not(.mat-form-field-appearance-legacy) .mat-form-field-prefix .mat-icon-button .mat-icon,.mat-form-field:not(.mat-form-field-appearance-legacy) .mat-form-field-suffix .mat-icon-button .mat-icon{margin:auto}"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
  949. }
  950. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatIcon, decorators: [{
  951. type: Component,
  952. args: [{ template: '<ng-content></ng-content>', selector: 'mat-icon', exportAs: 'matIcon', inputs: ['color'], host: {
  953. 'role': 'img',
  954. 'class': 'mat-icon notranslate',
  955. '[attr.data-mat-icon-type]': '_usingFontIcon() ? "font" : "svg"',
  956. '[attr.data-mat-icon-name]': '_svgName || fontIcon',
  957. '[attr.data-mat-icon-namespace]': '_svgNamespace || fontSet',
  958. '[attr.fontIcon]': '_usingFontIcon() ? fontIcon : null',
  959. '[class.mat-icon-inline]': 'inline',
  960. '[class.mat-icon-no-color]': 'color !== "primary" && color !== "accent" && color !== "warn"',
  961. }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".mat-icon{-webkit-user-select:none;user-select:none;background-repeat:no-repeat;display:inline-block;fill:currentColor;height:24px;width:24px;overflow:hidden}.mat-icon.mat-icon-inline{font-size:inherit;height:inherit;line-height:inherit;width:inherit}.mat-icon.mat-ligature-font[fontIcon]::before{content:attr(fontIcon)}[dir=rtl] .mat-icon-rtl-mirror{transform:scale(-1, 1)}.mat-form-field:not(.mat-form-field-appearance-legacy) .mat-form-field-prefix .mat-icon,.mat-form-field:not(.mat-form-field-appearance-legacy) .mat-form-field-suffix .mat-icon{display:block}.mat-form-field:not(.mat-form-field-appearance-legacy) .mat-form-field-prefix .mat-icon-button .mat-icon,.mat-form-field:not(.mat-form-field-appearance-legacy) .mat-form-field-suffix .mat-icon-button .mat-icon{margin:auto}"] }]
  962. }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MatIconRegistry }, { type: undefined, decorators: [{
  963. type: Attribute,
  964. args: ['aria-hidden']
  965. }] }, { type: undefined, decorators: [{
  966. type: Inject,
  967. args: [MAT_ICON_LOCATION]
  968. }] }, { type: i0.ErrorHandler }, { type: undefined, decorators: [{
  969. type: Optional
  970. }, {
  971. type: Inject,
  972. args: [MAT_ICON_DEFAULT_OPTIONS]
  973. }] }]; }, propDecorators: { inline: [{
  974. type: Input
  975. }], svgIcon: [{
  976. type: Input
  977. }], fontSet: [{
  978. type: Input
  979. }], fontIcon: [{
  980. type: Input
  981. }] } });
  982. class MatIconModule {
  983. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatIconModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
  984. static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0", ngImport: i0, type: MatIconModule, declarations: [MatIcon], imports: [MatCommonModule], exports: [MatIcon, MatCommonModule] }); }
  985. static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatIconModule, imports: [MatCommonModule, MatCommonModule] }); }
  986. }
  987. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatIconModule, decorators: [{
  988. type: NgModule,
  989. args: [{
  990. imports: [MatCommonModule],
  991. exports: [MatIcon, MatCommonModule],
  992. declarations: [MatIcon],
  993. }]
  994. }] });
  995. /**
  996. * Generated bundle index. Do not edit.
  997. */
  998. export { ICON_REGISTRY_PROVIDER, ICON_REGISTRY_PROVIDER_FACTORY, MAT_ICON_DEFAULT_OPTIONS, MAT_ICON_LOCATION, MAT_ICON_LOCATION_FACTORY, MatIcon, MatIconModule, MatIconRegistry, getMatIconFailedToSanitizeLiteralError, getMatIconFailedToSanitizeUrlError, getMatIconNameNotFoundError, getMatIconNoHttpProviderError };
  999. //# sourceMappingURL=icon.mjs.map