UNPKG

@lxlib/seed

Version:

This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.1.

16 lines (14 loc) 5.02 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/cdk/overlay"),require("@angular/cdk/portal"),require("rxjs"),require("rxjs/operators"),require("@angular/common"),require("ng-zorro-antd/icon"),require("ng-zorro-antd/spin")):"function"==typeof define&&define.amd?define("@lxlib/seed/loading",["exports","@angular/core","@angular/cdk/overlay","@angular/cdk/portal","rxjs","rxjs/operators","@angular/common","ng-zorro-antd/icon","ng-zorro-antd/spin"],t):t(((e=e||self).lxlib=e.lxlib||{},e.lxlib.seed=e.lxlib.seed||{},e.lxlib.seed.loading={}),e.ng.core,e.ng.cdk.overlay,e.ng.cdk.portal,e.rxjs,e.rxjs.operators,e.ng.common,e["ng-zorro-antd/icon"],e["ng-zorro-antd/spin"])}(this,(function(e,t,n,o,r,i,a,s,c){"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 l=function(){return(l=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};var p=function(){function e(){this.type="spin",this.text="加载中...",this.icon={type:"loading",theme:"outline",spin:!0},this.delay=0}return e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e}();var u=function(){function e(){}return Object.defineProperty(e.prototype,"icon",{get:function(){return this.options.icon},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"custom",{get:function(){return this.options.custom},enumerable:!0,configurable:!0}),e.decorators=[{type:t.Component,args:[{selector:"loading-default",template:'<div class="loading-default__icon" *ngIf="options.type !== \'text\'">\n <ng-container [ngSwitch]="options.type">\n <nz-spin *ngSwitchCase="\'spin\'" nzSimple></nz-spin>\n <i *ngSwitchCase="\'icon\'" nz-icon [nzType]="icon.type" [nzTheme]="icon.theme" [nzSpin]="icon.spin"></i>\n <div *ngSwitchDefault class="loading-default__custom" [ngStyle]="custom.style" [innerHTML]="custom.html"></div>\n </ng-container>\n</div>\n<div *ngIf="options.text" class="loading-default__text">{{ options.text }}</div>\n',host:{"[class.loading-default]":"true"},preserveWhitespaces:!1,changeDetection:t.ChangeDetectionStrategy.OnPush,encapsulation:t.ViewEncapsulation.None}]}],e}();var d=function(){function e(e,t){var n=this;this.cog=e,this.overlay=t,this.compRef=null,this.opt=null,this.n$=new r.Subject,this.loading$=this.n$.asObservable().pipe(i.debounce((function(){return r.timer(n.opt.delay)}))).subscribe((function(){return n.create()}))}return Object.defineProperty(e.prototype,"instance",{get:function(){return null!=this.compRef?this.compRef.instance:null},enumerable:!0,configurable:!0}),e.prototype.create=function(){if(null!=this.opt){this._close(!1),this._overlayRef=this.overlay.create({positionStrategy:this.overlay.position().global().centerHorizontally().centerVertically(),scrollStrategy:this.overlay.scrollStrategies.block(),hasBackdrop:!0,backdropClass:"loading-backdrop"});var e=new o.ComponentPortal(u);this.compRef=this._overlayRef.attach(e),Object.assign(this.instance,{options:this.opt}),this.compRef.changeDetectorRef.markForCheck()}},e.prototype.open=function(e){this.opt=l(l({},this.cog),e),this.n$.next()},e.prototype._close=function(e){e&&(this.opt=null),this._overlayRef&&(this._overlayRef.detach(),this.compRef=null)},e.prototype.close=function(){this._close(!0)},e.prototype.ngOnDestroy=function(){this.loading$.unsubscribe()},e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[{type:p},{type:n.Overlay}]},e.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e(t.ɵɵinject(p),t.ɵɵinject(n.Overlay))},token:e,providedIn:"root"}),e}();var f=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{imports:[a.CommonModule,n.OverlayModule,o.PortalModule,s.NzIconModule,c.NzSpinModule],declarations:[u],entryComponents:[u],exports:[u]}]}],e}();e.LoadingConfig=p,e.LoadingDefaultComponent=u,e.LoadingModule=f,e.LoadingService=d,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=loading.umd.min.js.map