ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
2 lines • 11.3 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"),require("rxjs"),require("rxjs/operators"),require("@angular/common"),require("@angular/common/http"),require("@angular/platform-browser"),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","rxjs","rxjs/operators","@angular/common","@angular/common/http","@angular/platform-browser","@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,e.rxjs,e.rxjs.operators,e.ng.common,e.ng.common.http,e.ng.platformBrowser,e.icons)}(this,function(e,t,n,r,o,i,a,c,s,l,p){"use strict";var u=function(e,t){return(u=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 f(e,t){function n(){this.constructor=e}u(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function h(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function d(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}var y=new n.InjectionToken("nz_icons"),g=new n.InjectionToken("nz_icon_default_twotone_color"),m=[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],v=function(e){function t(t,n,r,a,c,s,l){var p=e.call(this,t,a,c,n)||this;return p.nzConfigService=r,p.legacyDefaultTwotoneColor=l,p.configUpdated$=new i.Subject,p.iconfontCache=new Set,p.onConfigChange(),p.addIcon.apply(p,function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(d(arguments[t]));return e}(m,s||[])),l&&o.warnDeprecation("'NZ_ICON_DEFAULT_TWOTONE_COLOR' is deprecated and will be removed in 9.0.0. Please use 'NZ_CONFIG' instead!"),p.configDefaultTwotoneColor(),p.configDefaultTheme(),p}return f(t,e),t.prototype.warnAPI=function(e){"old"===e&&o.warnDeprecation("'<i class=\"anticon\"></i>' would be deprecated in 9.0.0. Please use '<i nz-icon nzType=\"\"></i>' API. Please refer https://ng.ant.design/components/icon/en."),"cross"===e&&o.warnDeprecation("'cross' icon is replaced by 'close' icon. This auto correction would be removed in 9.0.0."),"vertical"===e&&o.warnDeprecation("'verticle' is misspelled. Please use 'vertical'. This misspell would be fixed in 9.0.0.")},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(o.trimComponentName(this.constructor.name)).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||this.legacyDefaultTwotoneColor,t="#1890ff";e&&(e.startsWith("#")?t=e:o.warn("Twotone color must be a hex color!")),this.twoToneColor={primaryColor:t}},t.prototype.getConfig=function(){return this.nzConfigService.getConfigForComponent(o.trimComponentName(this.constructor.name))||{}},t.decorators=[{type:n.Injectable,args:[{providedIn:"root"}]}],t.ctorParameters=function(){return[{type:n.RendererFactory2},{type:l.DomSanitizer},{type:o.NzConfigService},{type:s.HttpBackend,decorators:[{type:n.Optional}]},{type:void 0,decorators:[{type:n.Optional},{type:n.Inject,args:[c.DOCUMENT]}]},{type:Array,decorators:[{type:n.Optional},{type:n.Inject,args:[y]}]},{type:String,decorators:[{type:n.Optional},{type:n.Inject,args:[g]}]}]},t.ngInjectableDef=n.ɵɵdefineInjectable({factory:function(){return new t(n.ɵɵinject(n.RendererFactory2),n.ɵɵinject(l.DomSanitizer),n.ɵɵinject(o.NzConfigService),n.ɵɵinject(s.HttpBackend,8),n.ɵɵinject(c.DOCUMENT,8),n.ɵɵinject(y,8),n.ɵɵinject(g,8))},token:t,providedIn:"root"}),t}(r.IconService);var C=/^anticon\-\w/,b=function(e){if(e){var t=e.split(/\s/),n=t.findIndex(function(e){return"anticon"!==e&&"anticon-spin"!==e&&!!e.match(C)});return-1===n?void 0:{name:t[n],index:n}}},O=function(e){var t={type:e,crossError:!1,verticalError:!1};return t.type=e?e.replace("anticon-",""):"",t.type.includes("verticle")&&(t.type="up",t.verticalError=!0),t.type.startsWith("cross")&&(t.type="close",t.crossError=!0),t},w=function(e){function r(t,n,r,o){var a=e.call(this,t,n,r)||this;return a.iconService=t,a.elementRef=n,a.renderer=r,a.platform=o,a.nzRotate=0,a.spin=!1,a.el=a.elementRef.nativeElement,a.destroy$=new i.Subject,a}return f(r,e),Object.defineProperty(r.prototype,"nzSpin",{set:function(e){this.spin=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"nzType",{set:function(e){this.type=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"nzTheme",{set:function(e){this.theme=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"nzTwotoneColor",{set:function(e){this.twoToneColor=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"nzIconfont",{set:function(e){this.iconfont=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){if(e&&e.startsWith("anticon")){var t=b(e),n=t?O(t.name).type:"";n&&this.type!==n&&(this._type=n)}else this._type=e},enumerable:!0,configurable:!0}),r.prototype.changeIcon2=function(e){var t=this;void 0===e&&(e=!1),e||this.setClassName(),this._changeIcon().then(function(n){t.setSVGData(n),!e&&n&&(t.handleSpin(n),t.handleRotate(n))})},r.prototype.classChangeHandler=function(e){var t=b(e);if(t){var n=O(t.name),r=n.type,o=n.crossError,i=n.verticalError;o&&this.iconService.warnAPI("cross"),i&&this.iconService.warnAPI("vertical"),this.type!==r&&(this._type=r,this.changeIcon2(!0))}},r.prototype.handleSpin=function(e){!this.spin&&"loading"!==this.type||this.elementRef.nativeElement.classList.contains("anticon-spin")?this.renderer.removeClass(e,"anticon-spin"):this.renderer.addClass(e,"anticon-spin")},r.prototype.handleRotate=function(e){this.nzRotate?this.renderer.setAttribute(e,"style","transform: rotate("+this.nzRotate+"deg)"):this.renderer.removeAttribute(e,"style")},r.prototype.setClassName=function(){if("string"==typeof this.type){var e=this.el.className.split(/\s/),t=b(this.el.className);t?(e.splice(t.index,1,"anticon-"+this.type),this.renderer.setAttribute(this.el,"class",e.join(" "))):this.renderer.addClass(this.el,"anticon-"+this.type)}},r.prototype.setSVGData=function(e){"string"==typeof this.type&&e&&(this.renderer.setAttribute(e,"data-icon",this.type),this.renderer.setAttribute(e,"aria-hidden","true"))},r.prototype.ngOnChanges=function(e){var t=e.type,n=e.nzType,r=e.nzTwotoneColor,i=e.twoToneColor,a=e.spin,c=e.nzSpin,s=e.theme,l=e.nzTheme,p=e.nzRotate;t&&!n&&o.warnDeprecation("APIs for Icon without 'nz' prefix are deprecated and will be removed in 9.0.0! Please check icons with this type: '"+t.currentValue+"'."),t||n||r||i||a||c||s||l?this.changeIcon2():p?this.handleRotate(this.el.firstChild):this._setSVGElement(this.iconService.createIconfontIcon("#"+this.iconfont)),t&&!n&&o.warnDeprecation("APIs for Icon without 'nz' prefix are deprecated and will be removed in 9.0.0! Please check icons with this type: '"+this.type+"'.")},r.prototype.ngOnInit=function(){var e=this;!this.type&&this.el.classList.contains("anticon")&&(this.iconService.warnAPI("old"),this.classChangeHandler(this.el.className),this.platform.isBrowser&&(this.classNameObserver=new MutationObserver(function(t){t.filter(function(e){return"class"===e.attributeName}).forEach(function(t){return e.classChangeHandler(t.target.className)})}),this.classNameObserver.observe(this.el,{attributes:!0}))),this.el.classList.contains("anticon")||this.renderer.setAttribute(this.el,"class",("anticon "+this.el.className).trim()),this.iconService.configUpdated$.asObservable().pipe(a.takeUntil(this.destroy$)).subscribe(function(){e.type&&e.changeIcon2()})},r.prototype.ngOnDestroy=function(){this.classNameObserver&&this.classNameObserver.disconnect(),this.destroy$.next(),this.destroy$.complete()},r.prototype.ngAfterContentChecked=function(){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)}},r.decorators=[{type:n.Directive,args:[{selector:"i.anticon, [nz-icon]",exportAs:"nzIcon"}]}],r.ctorParameters=function(){return[{type:v},{type:n.ElementRef},{type:n.Renderer2},{type:t.Platform}]},r.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}],spin:[{type:n.Input}],iconfont:[{type:n.Input}],type:[{type:n.Input}]},function(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);i>3&&a&&Object.defineProperty(t,n,a)}([o.InputBoolean(),h("design:type",Boolean),h("design:paramtypes",[Boolean])],r.prototype,"nzSpin",null),r}(r.IconDirective);var I=function(){function e(){}return e.decorators=[{type:n.NgModule,args:[{exports:[w],declarations:[w],imports:[t.PlatformModule]}]}],e}();e.DEFAULT_TWOTONE_COLOR="#1890ff",e.NZ_ICONS=y,e.NZ_ICONS_USED_BY_ZORRO=m,e.NZ_ICON_DEFAULT_TWOTONE_COLOR=g,e.NzIconDirective=w,e.NzIconModule=I,e.NzIconService=v,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=ng-zorro-antd-icon.umd.min.js.map