@angular/material
Version:
Angular Material
23 lines • 15 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/material/core"),require("tslib"),require("@angular/cdk/coercion"),require("@angular/common"),require("rxjs/operators"),require("@angular/common/http"),require("@angular/platform-browser"),require("rxjs")):"function"==typeof define&&define.amd?define("@angular/material/icon",["exports","@angular/core","@angular/material/core","tslib","@angular/cdk/coercion","@angular/common","rxjs/operators","@angular/common/http","@angular/platform-browser","rxjs"],e):e(((t=t||self).ng=t.ng||{},t.ng.material=t.ng.material||{},t.ng.material.icon={}),t.ng.core,t.ng.material.core,t.tslib,t.ng.cdk.coercion,t.ng.common,t.rxjs.operators,t.ng.common.http,t.ng.platformBrowser,t.rxjs)}(this,(function(t,e,n,r,o,i,a,s,c,l){"use strict";
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/function u(t){return Error('Unable to find icon with the name "'+t+'"')}function p(){return Error("Could not find HttpClient provider for use with Angular Material icons. Please include the HttpClientModule from @angular/common/http in your app imports.")}function f(t){return Error("The URL provided to MatIconRegistry was not trusted as a resource URL via Angular's DomSanitizer. Attempted URL was \""+t+'".')}function h(t){return Error("The literal provided to MatIconRegistry was not trusted as safe HTML by Angular's DomSanitizer. Attempted literal was \""+t+'".')}var g=function g(t,e){this.options=e,t.nodeName?this.svgElement=t:this.url=t},m=function(){function t(t,e,n,r){this._httpClient=t,this._sanitizer=e,this._errorHandler=r,this._svgIconConfigs=new Map,this._iconSetConfigs=new Map,this._cachedIconsByUrl=new Map,this._inProgressUrlFetches=new Map,this._fontCssClassesByAlias=new Map,this._defaultFontSetClass="material-icons",this._document=n}return t.prototype.addSvgIcon=function(t,e,n){return this.addSvgIconInNamespace("",t,e,n)},t.prototype.addSvgIconLiteral=function(t,e,n){return this.addSvgIconLiteralInNamespace("",t,e,n)},t.prototype.addSvgIconInNamespace=function(t,e,n,r){return this._addSvgIconConfig(t,e,new g(n,r))},t.prototype.addSvgIconLiteralInNamespace=function(t,n,r,o){var i=this._sanitizer.sanitize(e.SecurityContext.HTML,r);if(!i)throw h(r);var a=this._createSvgElementForSingleIcon(i,o);return this._addSvgIconConfig(t,n,new g(a,o))},t.prototype.addSvgIconSet=function(t,e){return this.addSvgIconSetInNamespace("",t,e)},t.prototype.addSvgIconSetLiteral=function(t,e){return this.addSvgIconSetLiteralInNamespace("",t,e)},t.prototype.addSvgIconSetInNamespace=function(t,e,n){return this._addSvgIconSetConfig(t,new g(e,n))},t.prototype.addSvgIconSetLiteralInNamespace=function(t,n,r){var o=this._sanitizer.sanitize(e.SecurityContext.HTML,n);if(!o)throw h(n);var i=this._svgElementFromString(o);return this._addSvgIconSetConfig(t,new g(i,r))},t.prototype.registerFontClassAlias=function(t,e){return void 0===e&&(e=t),this._fontCssClassesByAlias.set(t,e),this},t.prototype.classNameForFontAlias=function(t){return this._fontCssClassesByAlias.get(t)||t},t.prototype.setDefaultFontSetClass=function(t){return this._defaultFontSetClass=t,this},t.prototype.getDefaultFontSetClass=function(){return this._defaultFontSetClass},t.prototype.getSvgIconFromUrl=function(t){var n=this,r=this._sanitizer.sanitize(e.SecurityContext.RESOURCE_URL,t);if(!r)throw f(t);var o=this._cachedIconsByUrl.get(r);return o?l.of(_(o)):this._loadSvgIconFromConfig(new g(t)).pipe(a.tap((function(t){return n._cachedIconsByUrl.set(r,t)})),a.map((function(t){return _(t)})))},t.prototype.getNamedSvgIcon=function(t,e){void 0===e&&(e="");var n=y(e,t),r=this._svgIconConfigs.get(n);if(r)return this._getSvgFromConfig(r);var o=this._iconSetConfigs.get(e);return o?this._getSvgFromIconSetConfigs(t,o):l.throwError(u(n))},t.prototype.ngOnDestroy=function(){this._svgIconConfigs.clear(),this._iconSetConfigs.clear(),this._cachedIconsByUrl.clear()},t.prototype._getSvgFromConfig=function(t){return t.svgElement?l.of(_(t.svgElement)):this._loadSvgIconFromConfig(t).pipe(a.tap((function(e){return t.svgElement=e})),a.map((function(t){return _(t)})))},t.prototype._getSvgFromIconSetConfigs=function(t,n){var r=this,o=this._extractIconWithNameFromAnySet(t,n);if(o)return l.of(o);var i=n.filter((function(t){return!t.svgElement})).map((function(t){return r._loadSvgIconSetFromConfig(t).pipe(a.catchError((function(n){var o="Loading icon set URL: "+r._sanitizer.sanitize(e.SecurityContext.RESOURCE_URL,t.url)+" failed: "+n.message;return r._errorHandler?r._errorHandler.handleError(new Error(o)):console.error(o),l.of(null)})))}));return l.forkJoin(i).pipe(a.map((function(){var e=r._extractIconWithNameFromAnySet(t,n);if(!e)throw u(t);return e})))},t.prototype._extractIconWithNameFromAnySet=function(t,e){for(var n=e.length-1;n>=0;n--){var r=e[n];if(r.svgElement){var o=this._extractSvgIconFromSet(r.svgElement,t,r.options);if(o)return o}}return null},t.prototype._loadSvgIconFromConfig=function(t){var e=this;return this._fetchUrl(t.url).pipe(a.map((function(n){return e._createSvgElementForSingleIcon(n,t.options)})))},t.prototype._loadSvgIconSetFromConfig=function(t){var e=this;return t.svgElement?l.of(t.svgElement):this._fetchUrl(t.url).pipe(a.map((function(n){return t.svgElement||(t.svgElement=e._svgElementFromString(n)),t.svgElement})))},t.prototype._createSvgElementForSingleIcon=function(t,e){var n=this._svgElementFromString(t);return this._setSvgAttributes(n,e),n},t.prototype._extractSvgIconFromSet=function(t,e,n){var r=t.querySelector('[id="'+e+'"]');if(!r)return null;var o=r.cloneNode(!0);if(o.removeAttribute("id"),"svg"===o.nodeName.toLowerCase())return this._setSvgAttributes(o,n);if("symbol"===o.nodeName.toLowerCase())return this._setSvgAttributes(this._toSvgElement(o),n);var i=this._svgElementFromString("<svg></svg>");return i.appendChild(o),this._setSvgAttributes(i,n)},t.prototype._svgElementFromString=function(t){var e=this._document.createElement("DIV");e.innerHTML=t;var n=e.querySelector("svg");if(!n)throw Error("<svg> tag not found");return n},t.prototype._toSvgElement=function(t){for(var e=this._svgElementFromString("<svg></svg>"),n=t.attributes,r=0;r<n.length;r++){var o=n[r],i=o.name;"id"!==i&&e.setAttribute(i,o.value)}for(r=0;r<t.childNodes.length;r++)t.childNodes[r].nodeType===this._document.ELEMENT_NODE&&e.appendChild(t.childNodes[r].cloneNode(!0));return e},t.prototype._setSvgAttributes=function(t,e){return t.setAttribute("fit",""),t.setAttribute("height","100%"),t.setAttribute("width","100%"),t.setAttribute("preserveAspectRatio","xMidYMid meet"),t.setAttribute("focusable","false"),e&&e.viewBox&&t.setAttribute("viewBox",e.viewBox),t},t.prototype._fetchUrl=function(t){var n=this;if(!this._httpClient)throw p();if(null==t)throw Error('Cannot fetch icon from URL "'+t+'".');var r=this._sanitizer.sanitize(e.SecurityContext.RESOURCE_URL,t);if(!r)throw f(t);var o=this._inProgressUrlFetches.get(r);if(o)return o;var i=this._httpClient.get(r,{responseType:"text"}).pipe(a.finalize((function(){return n._inProgressUrlFetches.delete(r)})),a.share());return this._inProgressUrlFetches.set(r,i),i},t.prototype._addSvgIconConfig=function(t,e,n){return this._svgIconConfigs.set(y(t,e),n),this},t.prototype._addSvgIconSetConfig=function(t,e){var n=this._iconSetConfigs.get(t);return n?n.push(e):this._iconSetConfigs.set(t,[e]),this},t.decorators=[{type:e.Injectable,args:[{providedIn:"root"}]}],t.ctorParameters=function(){return[{type:s.HttpClient,decorators:[{type:e.Optional}]},{type:c.DomSanitizer},{type:void 0,decorators:[{type:e.Optional},{type:e.Inject,args:[i.DOCUMENT]}]},{type:e.ErrorHandler,decorators:[{type:e.Optional}]}]},t.ɵprov=e.ɵɵdefineInjectable({factory:function n(){return new t(e.ɵɵinject(s.HttpClient,8),e.ɵɵinject(c.DomSanitizer),e.ɵɵinject(i.DOCUMENT,8),e.ɵɵinject(e.ErrorHandler,8))},token:t,providedIn:"root"}),t}();function d(t,e,n,r,o){return t||new m(e,n,r,o)}var v={provide:m,deps:[[new e.Optional,new e.SkipSelf,m],[new e.Optional,s.HttpClient],c.DomSanitizer,[new e.Optional,e.ErrorHandler],[new e.Optional,i.DOCUMENT]],useFactory:d};function _(t){return t.cloneNode(!0)}function y(t,e){return t+":"+e}
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/var S=n.mixinColor((function I(t){this._elementRef=t})),C=new e.InjectionToken("mat-icon-location",{providedIn:"root",factory:E});function E(){var t=e.inject(i.DOCUMENT),n=t?t.location:null;return{getPathname:function(){return n?n.pathname+n.search:""}}}var F=["clip-path","color-profile","src","cursor","fill","filter","marker","marker-start","marker-mid","marker-end","mask","stroke"],w=function(t){return"["+t+"]"},R=F.map(w).join(", "),b=/^url\(['"]?#(.*?)['"]?\)$/,N=function(t){function n(e,n,r,o,i){var a=t.call(this,e)||this;return a._iconRegistry=n,a._location=o,a._errorHandler=i,a._inline=!1,r||e.nativeElement.setAttribute("aria-hidden","true"),a}return r.__extends(n,t),Object.defineProperty(n.prototype,"inline",{get:function(){return this._inline},set:function(t){this._inline=o.coerceBooleanProperty(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"fontSet",{get:function(){return this._fontSet},set:function(t){this._fontSet=this._cleanupFontValue(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"fontIcon",{get:function(){return this._fontIcon},set:function(t){this._fontIcon=this._cleanupFontValue(t)},enumerable:!0,configurable:!0}),n.prototype._splitIconName=function(t){if(!t)return["",""];var e=t.split(":");switch(e.length){case 1:return["",e[0]];case 2:return e;default:throw Error('Invalid icon name: "'+t+'"')}},n.prototype.ngOnChanges=function(t){var e=this,n=t.svgIcon;if(n)if(this.svgIcon){var o=r.__read(this._splitIconName(this.svgIcon),2),i=o[0],s=o[1];this._iconRegistry.getNamedSvgIcon(s,i).pipe(a.take(1)).subscribe((function(t){return e._setSvgElement(t)}),(function(t){var n="Error retrieving icon "+i+":"+s+"! "+t.message;e._errorHandler?e._errorHandler.handleError(new Error(n)):console.error(n)}))}else n.previousValue&&this._clearSvgElement();this._usingFontIcon()&&this._updateFontIconClasses()},n.prototype.ngOnInit=function(){this._usingFontIcon()&&this._updateFontIconClasses()},n.prototype.ngAfterViewChecked=function(){var t=this._elementsWithExternalReferences;if(t&&this._location&&t.size){var e=this._location.getPathname();e!==this._previousPath&&(this._previousPath=e,this._prependPathToReferences(e))}},n.prototype.ngOnDestroy=function(){this._elementsWithExternalReferences&&this._elementsWithExternalReferences.clear()},n.prototype._usingFontIcon=function(){return!this.svgIcon},n.prototype._setSvgElement=function(t){this._clearSvgElement();for(var e=t.querySelectorAll("style"),n=0;n<e.length;n++)e[n].textContent+=" ";if(this._location){var r=this._location.getPathname();this._previousPath=r,this._cacheChildrenWithExternalReferences(t),this._prependPathToReferences(r)}this._elementRef.nativeElement.appendChild(t)},n.prototype._clearSvgElement=function(){var t=this._elementRef.nativeElement,e=t.childNodes.length;for(this._elementsWithExternalReferences&&this._elementsWithExternalReferences.clear();e--;){var n=t.childNodes[e];1===n.nodeType&&"svg"!==n.nodeName.toLowerCase()||t.removeChild(n)}},n.prototype._updateFontIconClasses=function(){if(this._usingFontIcon()){var t=this._elementRef.nativeElement,e=this.fontSet?this._iconRegistry.classNameForFontAlias(this.fontSet):this._iconRegistry.getDefaultFontSetClass();e!=this._previousFontSetClass&&(this._previousFontSetClass&&t.classList.remove(this._previousFontSetClass),e&&t.classList.add(e),this._previousFontSetClass=e),this.fontIcon!=this._previousFontIconClass&&(this._previousFontIconClass&&t.classList.remove(this._previousFontIconClass),this.fontIcon&&t.classList.add(this.fontIcon),this._previousFontIconClass=this.fontIcon)}},n.prototype._cleanupFontValue=function(t){return"string"==typeof t?t.trim().split(" ")[0]:t},n.prototype._prependPathToReferences=function(t){var e=this._elementsWithExternalReferences;e&&e.forEach((function(e,n){e.forEach((function(e){n.setAttribute(e.name,"url('"+t+"#"+e.value+"')")}))}))},n.prototype._cacheChildrenWithExternalReferences=function(t){for(var e=t.querySelectorAll(R),n=this._elementsWithExternalReferences=this._elementsWithExternalReferences||new Map,r=function(t){F.forEach((function(r){var o=e[t],i=o.getAttribute(r),a=i?i.match(b):null;if(a){var s=n.get(o);s||n.set(o,s=[]),s.push({name:r,value:a[1]})}}))},o=0;o<e.length;o++)r(o)},n.decorators=[{type:e.Component,args:[{template:"<ng-content></ng-content>",selector:"mat-icon",exportAs:"matIcon",inputs:["color"],host:{role:"img",class:"mat-icon notranslate","[class.mat-icon-inline]":"inline","[class.mat-icon-no-color]":'color !== "primary" && color !== "accent" && color !== "warn"'},encapsulation:e.ViewEncapsulation.None,changeDetection:e.ChangeDetectionStrategy.OnPush,styles:[".mat-icon{background-repeat:no-repeat;display:inline-block;fill:currentColor;height:24px;width:24px}.mat-icon.mat-icon-inline{font-size:inherit;height:inherit;line-height:inherit;width:inherit}[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}\n"]}]}],n.ctorParameters=function(){return[{type:e.ElementRef},{type:m},{type:String,decorators:[{type:e.Attribute,args:["aria-hidden"]}]},{type:void 0,decorators:[{type:e.Optional},{type:e.Inject,args:[C]}]},{type:e.ErrorHandler,decorators:[{type:e.Optional}]}]},n.propDecorators={inline:[{type:e.Input}],svgIcon:[{type:e.Input}],fontSet:[{type:e.Input}],fontIcon:[{type:e.Input}]},n}(S),x=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{imports:[n.MatCommonModule],exports:[N,n.MatCommonModule],declarations:[N]}]}],t}();
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
t.ICON_REGISTRY_PROVIDER=v,t.ICON_REGISTRY_PROVIDER_FACTORY=d,t.MAT_ICON_LOCATION=C,t.MAT_ICON_LOCATION_FACTORY=E,t.MatIcon=N,t.MatIconModule=x,t.MatIconRegistry=m,t.getMatIconFailedToSanitizeLiteralError=h,t.getMatIconFailedToSanitizeUrlError=f,t.getMatIconNameNotFoundError=u,t.getMatIconNoHttpProviderError=p,t.ɵ0=w,Object.defineProperty(t,"__esModule",{value:!0})}));