ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
1 lines • 8.22 kB
Source Map (JSON)
{"version":3,"file":"ng-zorro-antd-spin.mjs","sources":["../../components/spin/spin.component.ts","../../components/spin/spin.module.ts","../../components/spin/public-api.ts","../../components/spin/ng-zorro-antd-spin.ts"],"sourcesContent":["/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nimport { Direction, Directionality } from '@angular/cdk/bidi';\nimport {\n ChangeDetectorRef,\n Component,\n Input,\n OnChanges,\n OnDestroy,\n OnInit,\n Optional,\n SimpleChanges,\n TemplateRef,\n ViewEncapsulation\n} from '@angular/core';\nimport { BehaviorSubject, ReplaySubject, Subject, timer } from 'rxjs';\nimport { debounce, distinctUntilChanged, startWith, switchMap, takeUntil } from 'rxjs/operators';\n\nimport { NzConfigKey, NzConfigService, WithConfig } from 'ng-zorro-antd/core/config';\nimport { BooleanInput, NumberInput, NzSafeAny, NzSizeLDSType } from 'ng-zorro-antd/core/types';\nimport { InputBoolean, InputNumber } from 'ng-zorro-antd/core/util';\n\nconst NZ_CONFIG_MODULE_NAME: NzConfigKey = 'spin';\n\n@Component({\n selector: 'nz-spin',\n exportAs: 'nzSpin',\n preserveWhitespaces: false,\n encapsulation: ViewEncapsulation.None,\n template: `\n <ng-template #defaultTemplate>\n <span class=\"ant-spin-dot ant-spin-dot-spin\">\n <i class=\"ant-spin-dot-item\"></i>\n <i class=\"ant-spin-dot-item\"></i>\n <i class=\"ant-spin-dot-item\"></i>\n <i class=\"ant-spin-dot-item\"></i>\n </span>\n </ng-template>\n <div *ngIf=\"isLoading\">\n <div\n class=\"ant-spin\"\n [class.ant-spin-rtl]=\"dir === 'rtl'\"\n [class.ant-spin-spinning]=\"isLoading\"\n [class.ant-spin-lg]=\"nzSize === 'large'\"\n [class.ant-spin-sm]=\"nzSize === 'small'\"\n [class.ant-spin-show-text]=\"nzTip\"\n >\n <ng-template [ngTemplateOutlet]=\"nzIndicator || defaultTemplate\"></ng-template>\n <div class=\"ant-spin-text\" *ngIf=\"nzTip\">{{ nzTip }}</div>\n </div>\n </div>\n <div *ngIf=\"!nzSimple\" class=\"ant-spin-container\" [class.ant-spin-blur]=\"isLoading\">\n <ng-content></ng-content>\n </div>\n `,\n host: {\n '[class.ant-spin-nested-loading]': '!nzSimple'\n }\n})\nexport class NzSpinComponent implements OnChanges, OnDestroy, OnInit {\n readonly _nzModuleName: NzConfigKey = NZ_CONFIG_MODULE_NAME;\n\n static ngAcceptInputType_nzDelay: NumberInput;\n static ngAcceptInputType_nzSimple: BooleanInput;\n static ngAcceptInputType_nzSpinning: BooleanInput;\n\n @Input() @WithConfig() nzIndicator: TemplateRef<NzSafeAny> | null = null;\n @Input() nzSize: NzSizeLDSType = 'default';\n @Input() nzTip: string | null = null;\n @Input() @InputNumber() nzDelay = 0;\n @Input() @InputBoolean() nzSimple = false;\n @Input() @InputBoolean() nzSpinning = true;\n private destroy$ = new Subject<void>();\n private spinning$ = new BehaviorSubject(this.nzSpinning);\n private delay$ = new ReplaySubject<number>(1);\n isLoading = false;\n dir: Direction = 'ltr';\n\n constructor(\n public nzConfigService: NzConfigService,\n private cdr: ChangeDetectorRef,\n @Optional() private directionality: Directionality\n ) {}\n\n ngOnInit(): void {\n const loading$ = this.delay$.pipe(\n startWith(this.nzDelay),\n distinctUntilChanged(),\n switchMap(delay => {\n if (delay === 0) {\n return this.spinning$;\n }\n\n return this.spinning$.pipe(debounce(spinning => timer(spinning ? delay : 0)));\n }),\n takeUntil(this.destroy$)\n );\n loading$.subscribe(loading => {\n this.isLoading = loading;\n this.cdr.markForCheck();\n });\n this.nzConfigService\n .getConfigChangeEventForComponent(NZ_CONFIG_MODULE_NAME)\n .pipe(takeUntil(this.destroy$))\n .subscribe(() => this.cdr.markForCheck());\n\n this.directionality.change?.pipe(takeUntil(this.destroy$)).subscribe((direction: Direction) => {\n this.dir = direction;\n this.cdr.detectChanges();\n });\n\n this.dir = this.directionality.value;\n }\n\n ngOnChanges(changes: SimpleChanges): void {\n const { nzSpinning, nzDelay } = changes;\n if (nzSpinning) {\n this.spinning$.next(this.nzSpinning);\n }\n if (nzDelay) {\n this.delay$.next(this.nzDelay);\n }\n }\n\n ngOnDestroy(): void {\n this.destroy$.next();\n this.destroy$.complete();\n }\n}\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nimport { BidiModule } from '@angular/cdk/bidi';\nimport { ObserversModule } from '@angular/cdk/observers';\nimport { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\n\nimport { NzSpinComponent } from './spin.component';\n\n@NgModule({\n exports: [NzSpinComponent],\n declarations: [NzSpinComponent],\n imports: [BidiModule, CommonModule, ObserversModule]\n})\nexport class NzSpinModule {}\n","/**\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE\n */\n\nexport * from './spin.component';\nexport * from './spin.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAyBA,MAAM,qBAAqB,GAAgB,MAAM,CAAC;MAqCrC,eAAe;IAmB1B,YACS,eAAgC,EAC/B,GAAsB,EACV,cAA8B;QAF3C,oBAAe,GAAf,eAAe,CAAiB;QAC/B,QAAG,GAAH,GAAG,CAAmB;QACV,mBAAc,GAAd,cAAc,CAAgB;QArB3C,kBAAa,GAAgB,qBAAqB,CAAC;QAMrC,gBAAW,GAAkC,IAAI,CAAC;QAChE,WAAM,GAAkB,SAAS,CAAC;QAClC,UAAK,GAAkB,IAAI,CAAC;QACb,YAAO,GAAG,CAAC,CAAC;QACX,aAAQ,GAAG,KAAK,CAAC;QACjB,eAAU,GAAG,IAAI,CAAC;QACnC,aAAQ,GAAG,IAAI,OAAO,EAAQ,CAAC;QAC/B,cA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