ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
2 lines • 9.94 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/cdk/platform"),require("ng-zorro-antd/core"),require("@angular/common"),require("@angular/common/http"),require("@angular/core"),require("@angular/platform-browser"),require("@ant-design/icons-angular"),require("@ant-design/icons-angular/icons")):"function"==typeof define&&define.amd?define("ng-zorro-antd/icon",["exports","@angular/cdk/platform","ng-zorro-antd/core","@angular/common","@angular/common/http","@angular/core","@angular/platform-browser","@ant-design/icons-angular","@ant-design/icons-angular/icons"],t):t((e["ng-zorro-antd"]=e["ng-zorro-antd"]||{},e["ng-zorro-antd"].icon={}),e.ng.cdk.platform,e["ng-zorro-antd"].core,e.ng.common,e.ng.common.http,e.ng.core,e.ng.platformBrowser,e.iconsAngular,e.icons)}(this,function(e,t,n,r,o,a,i,c,s){"use strict";var l=function(e,t){return(l=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 p(e,t){function n(){this.constructor=e}l(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function u(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function f(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||0<t--)&&!(r=i.next()).done;)a.push(r.value)}catch(c){o={error:c}}finally{try{r&&!r.done&&(n=i["return"])&&n.call(i)}finally{if(o)throw o.error}}return a}var h=new a.InjectionToken("nz_icons"),d=new a.InjectionToken("nz_icon_default_twotone_color"),y="#1890ff",m=[s.BarsOutline,s.CalendarOutline,s.CaretUpFill,s.CaretUpOutline,s.CaretDownFill,s.CaretDownOutline,s.CheckCircleFill,s.CheckCircleOutline,s.CheckOutline,s.ClockCircleOutline,s.CloseCircleOutline,s.CloseCircleFill,s.CloseOutline,s.DoubleLeftOutline,s.DoubleRightOutline,s.DownOutline,s.EllipsisOutline,s.ExclamationCircleFill,s.ExclamationCircleOutline,s.EyeOutline,s.FileFill,s.FileOutline,s.FilterFill,s.InfoCircleFill,s.InfoCircleOutline,s.LeftOutline,s.LoadingOutline,s.PaperClipOutline,s.QuestionCircleOutline,s.RightOutline,s.StarFill,s.SearchOutline,s.StarFill,s.UploadOutline,s.UpOutline],g=function(l){function e(e,t,n,r,o,i){var a=l.call(this,e,n,r,t)||this;a.rendererFactory=e,a.sanitizer=t,a.handler=n,a.document=r,a.icons=o,a.defaultColor=i,a.iconfontCache=new Set,a.warnedAboutAPI=!1,a.warnedAboutCross=!1,a.warnedAboutVertical=!1,a.addIcon.apply(a,function s(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(f(arguments[t]));return e}(m,a.icons||[]));var c=y;return a.defaultColor&&(a.defaultColor.startsWith("#")?c=a.defaultColor:console.warn("[NG-ZORRO]: twotone color must be a hex color!")),a.twoToneColor={primaryColor:c},a}return p(e,l),e.prototype.warnAPI=function(e){"old"!==e||this.warnedAboutAPI||(console.warn('<i class="anticon"></i> would be deprecated soon. Please use <i nz-icon type=""></i> API.'),this.warnedAboutAPI=!0),"cross"!==e||this.warnedAboutCross||(console.warn("'cross' icon is replaced by 'close' icon."),this.warnedAboutCross=!0),"vertical"!==e||this.warnedAboutVertical||(console.warn("'verticle' is misspelled, would be corrected in the next major version."),this.warnedAboutVertical=!0)},e.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")},e.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)}},e.prototype.createIconfontIcon=function(e){return this._createSVGElementFromString('<svg><use xlink:href="'+e+'"></svg>')},e.decorators=[{type:a.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[{type:a.RendererFactory2},{type:i.DomSanitizer},{type:o.HttpBackend,decorators:[{type:a.Optional}]},{type:undefined,decorators:[{type:a.Optional},{type:a.Inject,args:[r.DOCUMENT]}]},{type:Array,decorators:[{type:a.Optional},{type:a.Inject,args:[h]}]},{type:String,decorators:[{type:a.Optional},{type:a.Inject,args:[d]}]}]},e.ngInjectableDef=a.defineInjectable({factory:function(){return new e(a.inject(a.RendererFactory2),a.inject(i.DomSanitizer),a.inject(o.HttpBackend,8),a.inject(r.DOCUMENT,8),a.inject(h,8),a.inject(d,8))},token:e,providedIn:"root"}),e}(c.IconService),b=/^anticon\-\w/,O=function(e){if(e){var t=e.split(/\s/),n=t.findIndex(function(e){return"anticon"!==e&&"anticon-spin"!==e&&!!e.match(b)});return-1===n?undefined:{name:t[n],index:n}}return undefined},v=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},C=function(i){function e(e,t,n,r){var o=i.call(this,e,t,n)||this;return o.iconService=e,o.elementRef=t,o.renderer=n,o.platform=r,o.nzRotate=0,o.spin=!1,o.el=o.elementRef.nativeElement,o}return p(e,i),Object.defineProperty(e.prototype,"nzSpin",{set:function(e){this.spin=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nzType",{set:function(e){this.type=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nzTheme",{set:function(e){this.theme=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nzTwotoneColor",{set:function(e){this.twoToneColor=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nzIconfont",{set:function(e){this.iconfont=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"type",{get:function(){return this._type},set:function(e){if(e&&e.startsWith("anticon")){var t=O(e),n=t?v(t.name).type:"";n&&this.type!==n&&(this._type=n)}else this._type=e},enumerable:!0,configurable:!0}),e.prototype.changeIcon2=function(t){var n=this;void 0===t&&(t=!1),t||this.setClassName(),this._changeIcon().then(function(e){n.setSVGData(e),!t&&e&&(n.handleSpin(e),n.handleRotate(e))})},e.prototype.classChangeHandler=function(e){var t=O(e);if(t){var n=v(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))}},e.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")},e.prototype.handleRotate=function(e){this.nzRotate?this.renderer.setAttribute(e,"style","transform: rotate("+this.nzRotate+"deg)"):this.renderer.removeAttribute(e,"style")},e.prototype.setClassName=function(){if("string"==typeof this.type){var e=this.el.className.split(/\s/),t=O(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)}},e.prototype.setSVGData=function(e){"string"==typeof this.type&&e&&(this.renderer.setAttribute(e,"data-icon",this.type),this.renderer.setAttribute(e,"aria-hidden","true"))},e.prototype.ngOnChanges=function(e){var t=e.type,n=e.nzType,r=e.nzTwotoneColor,o=e.twoToneColor,i=e.spin,a=e.nzSpin,c=e.theme,s=e.nzTheme,l=e.nzRotate;t||n||r||o||i||a||c||s?this.changeIcon2():l?this.handleRotate(this.el.firstChild):this._setSVGElement(this.iconService.createIconfontIcon("#"+this.iconfont))},e.prototype.ngOnInit=function(){var t=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(e){e.filter(function(e){return"class"===e.attributeName}).forEach(function(e){return t.classChangeHandler(e.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())},e.prototype.ngOnDestroy=function(){this.classNameObserver&&this.classNameObserver.disconnect()},e.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)}},e.decorators=[{type:a.Directive,args:[{selector:"i.anticon, [nz-icon]",exportAs:"nzIcon"}]}],e.ctorParameters=function(){return[{type:g},{type:a.ElementRef},{type:a.Renderer2},{type:t.Platform}]},e.propDecorators={nzSpin:[{type:a.Input}],nzRotate:[{type:a.Input}],nzType:[{type:a.Input}],nzTheme:[{type:a.Input}],nzTwotoneColor:[{type:a.Input}],nzIconfont:[{type:a.Input}],spin:[{type:a.Input}],iconfont:[{type:a.Input}],type:[{type:a.Input}]},function s(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;0<=c;c--)(o=e[c])&&(a=(i<3?o(a):3<i?o(t,n,a):o(t,n))||a);return 3<i&&a&&Object.defineProperty(t,n,a),a}([n.InputBoolean(),u("design:type",Boolean),u("design:paramtypes",[Boolean])],e.prototype,"nzSpin",null),e}(c.IconDirective),I=function(){function e(){}return e.decorators=[{type:a.NgModule,args:[{exports:[C],declarations:[C]}]}],e}();e.NzIconModule=I,e.NzIconDirective=C,e.NZ_ICONS=h,e.NZ_ICON_DEFAULT_TWOTONE_COLOR=d,e.DEFAULT_TWOTONE_COLOR=y,e.NZ_ICONS_USED_BY_ZORRO=m,e.NzIconService=g,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=ng-zorro-antd-icon.umd.min.js.map