UNPKG

@ohayojp.com/components

Version:

Common business components of ohayojp.

7 lines 4.4 kB
/** * @license ohayojp(cipchk@qq.com) v1.0.0 * (c) 2020 cipchk https://ohayojp.com/ * License: MIT */ !function (e, o) { "object" == typeof exports && "undefined" != typeof module ? o(exports, require("@angular/core"), require("@angular/cdk/overlay"), require("@angular/cdk/portal"), require("@ohayojp.com/util"), require("rxjs"), require("rxjs/operators"), require("@angular/common"), require("ng-zorro-antd/icon"), require("ng-zorro-antd/spin")) : "function" == typeof define && define.amd ? define("@ohayojp.com/components/loading", ["exports", "@angular/core", "@angular/cdk/overlay", "@angular/cdk/portal", "@ohayojp.com/util", "rxjs", "rxjs/operators", "@angular/common", "ng-zorro-antd/icon", "ng-zorro-antd/spin"], o) : o(((e = "undefined" != typeof globalThis ? globalThis : e || self).ohayo = e.ohayo || {}, e.ohayo.components = e.ohayo.components || {}, e.ohayo.components.loading = {}), e.ng.core, e.ng.cdk.overlay, e.ng.cdk.portal, e.ohayo.util, e.rxjs, e.rxjs.operators, e.ng.common, e["ng-zorro-antd/icon"], e["ng-zorro-antd/spin"]) }(this, (function (e, o, n, t, i, r, a, s, c, l) { "use strict"; var p = function () { function e() { } return Object.defineProperty(e.prototype, "icon", { get: function () { return this.options.icon }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "custom", { get: function () { return this.options.custom }, enumerable: !1, configurable: !0 }), e }(); p.decorators = [{ type: o.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: o.ChangeDetectionStrategy.OnPush, encapsulation: o.ViewEncapsulation.None }] }]; var u = function () { function e(e, o) { var n = this; this.overlay = e, this.compRef = null, this.opt = null, this.n$ = new r.Subject, this.cog = o.merge("loading", { type: "spin", text: "加载中...", icon: { type: "loading", theme: "outline", spin: !0 }, delay: 0 }), this.loading$ = this.n$.asObservable().pipe(a.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: !1, configurable: !0 }), e.prototype.create = function () { 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" }), this.compRef = this._overlayRef.attach(new t.ComponentPortal(p)), Object.assign(this.instance, { options: this.opt }), this.compRef.changeDetectorRef.markForCheck()) }, e.prototype.open = function (e) { this.opt = Object.assign(Object.assign({}, 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 }(); u.decorators = [{ type: o.Injectable, args: [{ providedIn: "root" }] }], u.ctorParameters = function () { return [{ type: n.Overlay }, { type: i.OhayoConfigService }] }, u.ɵprov = o.ɵɵdefineInjectable({ factory: function () { return new u(o.ɵɵinject(n.Overlay), o.ɵɵinject(i.OhayoConfigService)) }, token: u, providedIn: "root" }); var d = [p], g = function () { }; g.decorators = [{ type: o.NgModule, args: [{ imports: [s.CommonModule, n.OverlayModule, t.PortalModule, c.NzIconModule, l.NzSpinModule], declarations: d, entryComponents: d, exports: d }] }], e.LoadingDefaultComponent = p, e.LoadingModule = g, e.LoadingService = u, Object.defineProperty(e, "__esModule", { value: !0 }) })); //# sourceMappingURL=loading.umd.min.js.map