UNPKG

ng-zorro-antd

Version:

An enterprise-class UI components based on Ant Design and Angular

2 lines 9.89 kB
!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,i,a,s,c){"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(s){o={error:s}}finally{try{r&&!r.done&&(n=i["return"])&&n.call(i)}finally{if(o)throw o.error}}return a}var h,d=new i.InjectionToken("nz_icons"),y=new i.InjectionToken("nz_icon_default_twotone_color"),m="#1890ff",g=[c.BarsOutline,c.CalendarOutline,c.CaretUpFill,c.CaretUpOutline,c.CaretDownFill,c.CaretDownOutline,c.CheckCircleFill,c.CheckCircleOutline,c.CheckOutline,c.ClockCircleOutline,c.CloseCircleOutline,c.CloseCircleFill,c.CloseOutline,c.DoubleLeftOutline,c.DoubleRightOutline,c.DownOutline,c.EllipsisOutline,c.ExclamationCircleFill,c.ExclamationCircleOutline,c.EyeOutline,c.FileFill,c.FileOutline,c.FilterFill,c.InfoCircleFill,c.InfoCircleOutline,c.LeftOutline,c.LoadingOutline,c.PaperClipOutline,c.QuestionCircleOutline,c.RightOutline,c.StarFill,c.SearchOutline,c.StarFill,c.UploadOutline,c.UpOutline],b=(p(v,h=s.IconService),v.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)},v.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")},v.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)}},v.prototype.createIconfontIcon=function(e){return this._createSVGElementFromString('<svg><use xlink:href="'+e+'"></svg>')},v.decorators=[{type:i.Injectable,args:[{providedIn:"root"}]}],v.ctorParameters=function(){return[{type:i.RendererFactory2},{type:a.DomSanitizer},{type:o.HttpBackend,decorators:[{type:i.Optional}]},{type:undefined,decorators:[{type:i.Optional},{type:i.Inject,args:[r.DOCUMENT]}]},{type:Array,decorators:[{type:i.Optional},{type:i.Inject,args:[d]}]},{type:String,decorators:[{type:i.Optional},{type:i.Inject,args:[y]}]}]},v.ngInjectableDef=i.defineInjectable({factory:function(){return new v(i.inject(i.RendererFactory2),i.inject(a.DomSanitizer),i.inject(o.HttpBackend,8),i.inject(r.DOCUMENT,8),i.inject(d,8),i.inject(y,8))},token:v,providedIn:"root"}),v);function v(e,t,n,r,o,i){var a=h.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 c(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(f(arguments[t]));return e}(g,a.icons||[]));var s=m;return a.defaultColor&&(a.defaultColor.startsWith("#")?s=a.defaultColor:console.warn("[NG-ZORRO]: twotone color must be a hex color!")),a.twoToneColor={primaryColor:s},a}function O(e){if(e){var t=e.split(/\s/),n=t.findIndex(function(e){return"anticon"!==e&&"anticon-spin"!==e&&!!e.match(w)});return-1===n?undefined:{name:t[n],index:n}}return undefined}function C(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}var I,w=/^anticon\-\w/,_=(p(z,I=s.IconDirective),Object.defineProperty(z.prototype,"nzSpin",{set:function(e){this.spin=e},enumerable:!0,configurable:!0}),Object.defineProperty(z.prototype,"nzType",{set:function(e){this.type=e},enumerable:!0,configurable:!0}),Object.defineProperty(z.prototype,"nzTheme",{set:function(e){this.theme=e},enumerable:!0,configurable:!0}),Object.defineProperty(z.prototype,"nzTwotoneColor",{set:function(e){this.twoToneColor=e},enumerable:!0,configurable:!0}),Object.defineProperty(z.prototype,"nzIconfont",{set:function(e){this.iconfont=e},enumerable:!0,configurable:!0}),Object.defineProperty(z.prototype,"type",{get:function(){return this._type},set:function(e){if(e&&e.startsWith("anticon")){var t=O(e),n=t?C(t.name).type:"";n&&this.type!==n&&(this._type=n)}else this._type=e},enumerable:!0,configurable:!0}),z.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))})},z.prototype.classChangeHandler=function(e){var t=O(e);if(t){var n=C(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))}},z.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")},z.prototype.handleRotate=function(e){this.nzRotate?this.renderer.setAttribute(e,"style","transform: rotate("+this.nzRotate+"deg)"):this.renderer.removeAttribute(e,"style")},z.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)}},z.prototype.setSVGData=function(e){"string"==typeof this.type&&e&&(this.renderer.setAttribute(e,"data-icon",this.type),this.renderer.setAttribute(e,"aria-hidden","true"))},z.prototype.ngOnChanges=function(e){var t=e.type,n=e.nzType,r=e.nzTwotoneColor,o=e.twoToneColor,i=e.spin,a=e.nzSpin,s=e.theme,c=e.nzTheme,l=e.nzRotate;t||n||r||o||i||a||s||c?this.changeIcon2():l?this.handleRotate(this.el.firstChild):this._setSVGElement(this.iconService.createIconfontIcon("#"+this.iconfont))},z.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())},z.prototype.ngOnDestroy=function(){this.classNameObserver&&this.classNameObserver.disconnect()},z.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)}},z.decorators=[{type:i.Directive,args:[{selector:"i.anticon, [nz-icon]",exportAs:"nzIcon"}]}],z.ctorParameters=function(){return[{type:b},{type:i.ElementRef},{type:i.Renderer2},{type:t.Platform}]},z.propDecorators={nzSpin:[{type:i.Input}],nzRotate:[{type:i.Input}],nzType:[{type:i.Input}],nzTheme:[{type:i.Input}],nzTwotoneColor:[{type:i.Input}],nzIconfont:[{type:i.Input}],spin:[{type:i.Input}],iconfont:[{type:i.Input}],type:[{type:i.Input}]},function j(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 s=e.length-1;0<=s;s--)(o=e[s])&&(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])],z.prototype,"nzSpin",null),z);function z(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}var A=(S.decorators=[{type:i.NgModule,args:[{exports:[_],declarations:[_]}]}],S);function S(){}e.NzIconModule=A,e.NzIconDirective=_,e.NZ_ICONS=d,e.NZ_ICON_DEFAULT_TWOTONE_COLOR=y,e.DEFAULT_TWOTONE_COLOR=m,e.NZ_ICONS_USED_BY_ZORRO=g,e.NzIconService=b,Object.defineProperty(e,"__esModule",{value:!0})}); //# sourceMappingURL=ng-zorro-antd-icon.umd.min.js.map