ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
16 lines (14 loc) • 9.93 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/cdk/platform"),require("@angular/core"),require("@ant-design/icons-angular"),require("ng-zorro-antd/core/util"),require("@angular/common"),require("@angular/common/http"),require("@angular/platform-browser"),require("ng-zorro-antd/core/config"),require("ng-zorro-antd/core/logger"),require("rxjs"),require("@ant-design/icons-angular/icons")):"function"==typeof define&&define.amd?define("ng-zorro-antd/icon",["exports","@angular/cdk/platform","@angular/core","@ant-design/icons-angular","ng-zorro-antd/core/util","@angular/common","@angular/common/http","@angular/platform-browser","ng-zorro-antd/core/config","ng-zorro-antd/core/logger","rxjs","@ant-design/icons-angular/icons"],t):t(((e=e||self)["ng-zorro-antd"]=e["ng-zorro-antd"]||{},e["ng-zorro-antd"].icon={}),e.ng.cdk.platform,e.ng.core,e.iconsAngular,e["ng-zorro-antd"].core.util,e.ng.common,e.ng.common.http,e.ng.platformBrowser,e["ng-zorro-antd"].core.config,e["ng-zorro-antd"].core.logger,e.rxjs,e.icons)}(this,(function(e,t,n,o,r,i,c,a,l,s,u,p){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */var f=function(e,t){return(f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function h(e,t){function n(){this.constructor=e}f(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function d(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function g(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var o,r,i=n.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(o=i.next()).done;)c.push(o.value)}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return c}var y=[p.BarsOutline,p.CalendarOutline,p.CaretUpFill,p.CaretUpOutline,p.CaretDownFill,p.CaretDownOutline,p.CheckCircleFill,p.CheckCircleOutline,p.CheckOutline,p.ClockCircleOutline,p.CloseCircleOutline,p.CloseCircleFill,p.CloseOutline,p.CopyOutline,p.DoubleLeftOutline,p.DoubleRightOutline,p.DownOutline,p.EditOutline,p.EllipsisOutline,p.ExclamationCircleFill,p.ExclamationCircleOutline,p.EyeOutline,p.FileFill,p.FileOutline,p.FilterFill,p.InfoCircleFill,p.InfoCircleOutline,p.LeftOutline,p.LoadingOutline,p.PaperClipOutline,p.QuestionCircleOutline,p.RightOutline,p.StarFill,p.SearchOutline,p.StarFill,p.UploadOutline,p.UpOutline,p.SwapRightOutline];var m=new n.InjectionToken("nz_icons"),C=new n.InjectionToken("nz_icon_default_twotone_color"),v=function(e){function t(t,n,o,r,i,c){var a=e.call(this,t,r,i,n)||this;return a.nzConfigService=o,a.configUpdated$=new u.Subject,a.iconfontCache=new Set,a.onConfigChange(),a.addIcon.apply(a,function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(g(arguments[t]));return e}(y,c||[])),a.configDefaultTwotoneColor(),a.configDefaultTheme(),a}return h(t,e),t.prototype.normalizeSvgElement=function(e){e.getAttribute("viewBox")||this._renderer.setAttribute(e,"viewBox","0 0 1024 1024"),e.getAttribute("width")&&e.getAttribute("height")||(this._renderer.setAttribute(e,"width","1em"),this._renderer.setAttribute(e,"height","1em")),e.getAttribute("fill")||this._renderer.setAttribute(e,"fill","currentColor")},t.prototype.fetchFromIconfont=function(e){var t=e.scriptUrl;if(this._document&&!this.iconfontCache.has(t)){var n=this._renderer.createElement("script");this._renderer.setAttribute(n,"src",t),this._renderer.setAttribute(n,"data-namespace",t.replace(/^(https?|http):/g,"")),this._renderer.appendChild(this._document.body,n),this.iconfontCache.add(t)}},t.prototype.createIconfontIcon=function(e){return this._createSVGElementFromString('<svg><use xlink:href="'+e+'"></svg>')},t.prototype.onConfigChange=function(){var e=this;this.nzConfigService.getConfigChangeEventForComponent("icon").subscribe((function(){e.configDefaultTwotoneColor(),e.configDefaultTheme(),e.configUpdated$.next()}))},t.prototype.configDefaultTheme=function(){var e=this.getConfig();this.defaultTheme=e.nzTheme||"outline"},t.prototype.configDefaultTwotoneColor=function(){var e=this.getConfig().nzTwotoneColor||"#1890ff",t="#1890ff";e&&(e.startsWith("#")?t=e:s.warn("Twotone color must be a hex color!")),this.twoToneColor={primaryColor:t}},t.prototype.getConfig=function(){return this.nzConfigService.getConfigForComponent("icon")||{}},t.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],t.ctorParameters=function(){return[{type:n.RendererFactory2},{type:a.DomSanitizer},{type:l.NzConfigService},{type:c.HttpBackend,decorators:[{type:n.Optional}]},{type:void 0,decorators:[{type:n.Optional},{type:n.Inject,args:[i.DOCUMENT]}]},{type:Array,decorators:[{type:n.Optional},{type:n.Inject,args:[m]}]}]},t.ɵprov=n.ɵɵdefineInjectable({factory:function(){return new t(n.ɵɵinject(n.RendererFactory2),n.ɵɵinject(a.DomSanitizer),n.ɵɵinject(l.NzConfigService),n.ɵɵinject(c.HttpBackend,8),n.ɵɵinject(i.DOCUMENT,8),n.ɵɵinject(m,8))},token:t,providedIn:"root"}),t}(o.IconService);var O=new n.InjectionToken("nz_icons_patch"),z=function(){function e(e,t){this.extraIcons=e,this.rootIconService=t,this.patched=!1}return e.prototype.doPatch=function(){var e=this;this.patched||(this.extraIcons.forEach((function(t){return e.rootIconService.addIcon(t)})),this.patched=!0)},e.decorators=[{type:n.Injectable}],e.ctorParameters=function(){return[{type:Array,decorators:[{type:n.Self},{type:n.Inject,args:[O]}]},{type:v}]},e}();var b=function(e){function t(t,n,o,r){var i=e.call(this,n,t,o)||this;return i.iconService=n,i.renderer=o,i.cacheClassName=null,i.nzRotate=0,i.spin=!1,r&&r.doPatch(),i.el=t.nativeElement,i}return h(t,e),Object.defineProperty(t.prototype,"nzSpin",{set:function(e){this.spin=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"nzType",{set:function(e){this.type=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"nzTheme",{set:function(e){this.theme=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"nzTwotoneColor",{set:function(e){this.twoToneColor=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"nzIconfont",{set:function(e){this.iconfont=e},enumerable:!0,configurable:!0}),t.prototype.ngOnChanges=function(e){var t=e.nzType,n=e.nzTwotoneColor,o=e.nzSpin,r=e.nzTheme,i=e.nzRotate;t||n||o||r?this.changeIcon2():i?this.handleRotate(this.el.firstChild):this._setSVGElement(this.iconService.createIconfontIcon("#"+this.iconfont))},t.prototype.ngOnInit=function(){this.renderer.setAttribute(this.el,"class",("anticon "+this.el.className).trim())},t.prototype.ngAfterContentChecked=function(){if(!this.type){var e=this.el.children,t=e.length;if(!this.type&&e.length)for(;t--;){var n=e[t];"svg"===n.tagName.toLowerCase()&&this.iconService.normalizeSvgElement(n)}}},t.prototype.changeIcon2=function(){var e=this;this.setClassName(),this._changeIcon().then((function(t){t&&(e.setSVGData(t),e.handleSpin(t),e.handleRotate(t))}))},t.prototype.handleSpin=function(e){this.spin||"loading"===this.type?this.renderer.addClass(e,"anticon-spin"):this.renderer.removeClass(e,"anticon-spin")},t.prototype.handleRotate=function(e){this.nzRotate?this.renderer.setAttribute(e,"style","transform: rotate("+this.nzRotate+"deg)"):this.renderer.removeAttribute(e,"style")},t.prototype.setClassName=function(){this.cacheClassName&&this.renderer.removeClass(this.el,this.cacheClassName),this.cacheClassName="anticon-"+this.type,this.renderer.addClass(this.el,this.cacheClassName)},t.prototype.setSVGData=function(e){this.renderer.setAttribute(e,"data-icon",this.type),this.renderer.setAttribute(e,"aria-hidden","true")},t.decorators=[{type:n.Directive,args:[{selector:"[nz-icon]",exportAs:"nzIcon",host:{"[class.anticon]":"true"}}]}],t.ctorParameters=function(){return[{type:n.ElementRef},{type:v},{type:n.Renderer2},{type:z,decorators:[{type:n.Optional}]}]},t.propDecorators={nzSpin:[{type:n.Input}],nzRotate:[{type:n.Input}],nzType:[{type:n.Input}],nzTheme:[{type:n.Input}],nzTwotoneColor:[{type:n.Input}],nzIconfont:[{type:n.Input}]},function(e,t,n,o){var r,i=arguments.length,c=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(c=(i<3?r(c):i>3?r(t,n,c):r(t,n))||c);i>3&&c&&Object.defineProperty(t,n,c)}([r.InputBoolean(),d("design:type",Boolean),d("design:paramtypes",[Boolean])],t.prototype,"nzSpin",null),t}(o.IconDirective);var I=function(){function e(){}return e.forRoot=function(t){return{ngModule:e,providers:[{provide:m,useValue:t}]}},e.forChild=function(t){return{ngModule:e,providers:[z,{provide:O,useValue:t}]}},e.decorators=[{type:n.NgModule,args:[{exports:[b],declarations:[b],imports:[t.PlatformModule]}]}],e}();e.DEFAULT_TWOTONE_COLOR="#1890ff",e.NZ_ICONS=m,e.NZ_ICONS_PATCH=O,e.NZ_ICON_DEFAULT_TWOTONE_COLOR=C,e.NzIconDirective=b,e.NzIconModule=I,e.NzIconPatchService=z,e.NzIconService=v,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=ng-zorro-antd-icon.umd.min.js.map