ng-zorro-antd-spin.mjs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. import { __esDecorate, __runInitializers } from 'tslib';
  2. import { NgTemplateOutlet } from '@angular/common';
  3. import * as i0 from '@angular/core';
  4. import { booleanAttribute, numberAttribute, Input, ViewEncapsulation, Component, NgModule } from '@angular/core';
  5. import { Subject, BehaviorSubject, ReplaySubject, timer } from 'rxjs';
  6. import { startWith, distinctUntilChanged, switchMap, debounce, takeUntil } from 'rxjs/operators';
  7. import * as i1 from 'ng-zorro-antd/core/config';
  8. import { WithConfig } from 'ng-zorro-antd/core/config';
  9. import * as i2 from '@angular/cdk/bidi';
  10. const NZ_CONFIG_MODULE_NAME = 'spin';
  11. let NzSpinComponent = (() => {
  12. let _nzIndicator_decorators;
  13. let _nzIndicator_initializers = [];
  14. let _nzIndicator_extraInitializers = [];
  15. return class NzSpinComponent {
  16. static {
  17. const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
  18. _nzIndicator_decorators = [WithConfig()];
  19. __esDecorate(null, null, _nzIndicator_decorators, { kind: "field", name: "nzIndicator", static: false, private: false, access: { has: obj => "nzIndicator" in obj, get: obj => obj.nzIndicator, set: (obj, value) => { obj.nzIndicator = value; } }, metadata: _metadata }, _nzIndicator_initializers, _nzIndicator_extraInitializers);
  20. if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
  21. }
  22. nzConfigService;
  23. cdr;
  24. directionality;
  25. _nzModuleName = NZ_CONFIG_MODULE_NAME;
  26. nzIndicator = __runInitializers(this, _nzIndicator_initializers, null);
  27. nzSize = (__runInitializers(this, _nzIndicator_extraInitializers), 'default');
  28. nzTip = null;
  29. nzDelay = 0;
  30. nzSimple = false;
  31. nzSpinning = true;
  32. destroy$ = new Subject();
  33. spinning$ = new BehaviorSubject(this.nzSpinning);
  34. delay$ = new ReplaySubject(1);
  35. isLoading = false;
  36. dir = 'ltr';
  37. constructor(nzConfigService, cdr, directionality) {
  38. this.nzConfigService = nzConfigService;
  39. this.cdr = cdr;
  40. this.directionality = directionality;
  41. }
  42. ngOnInit() {
  43. const loading$ = this.delay$.pipe(startWith(this.nzDelay), distinctUntilChanged(), switchMap(delay => {
  44. if (delay === 0) {
  45. return this.spinning$;
  46. }
  47. return this.spinning$.pipe(debounce(spinning => timer(spinning ? delay : 0)));
  48. }), takeUntil(this.destroy$));
  49. loading$.subscribe(loading => {
  50. this.isLoading = loading;
  51. this.cdr.markForCheck();
  52. });
  53. this.nzConfigService
  54. .getConfigChangeEventForComponent(NZ_CONFIG_MODULE_NAME)
  55. .pipe(takeUntil(this.destroy$))
  56. .subscribe(() => this.cdr.markForCheck());
  57. this.directionality.change?.pipe(takeUntil(this.destroy$)).subscribe((direction) => {
  58. this.dir = direction;
  59. this.cdr.detectChanges();
  60. });
  61. this.dir = this.directionality.value;
  62. }
  63. ngOnChanges(changes) {
  64. const { nzSpinning, nzDelay } = changes;
  65. if (nzSpinning) {
  66. this.spinning$.next(this.nzSpinning);
  67. }
  68. if (nzDelay) {
  69. this.delay$.next(this.nzDelay);
  70. }
  71. }
  72. ngOnDestroy() {
  73. this.destroy$.next();
  74. this.destroy$.complete();
  75. }
  76. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzSpinComponent, deps: [{ token: i1.NzConfigService }, { token: i0.ChangeDetectorRef }, { token: i2.Directionality }], target: i0.ɵɵFactoryTarget.Component });
  77. static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.2", type: NzSpinComponent, isStandalone: true, selector: "nz-spin", inputs: { nzIndicator: "nzIndicator", nzSize: "nzSize", nzTip: "nzTip", nzDelay: ["nzDelay", "nzDelay", numberAttribute], nzSimple: ["nzSimple", "nzSimple", booleanAttribute], nzSpinning: ["nzSpinning", "nzSpinning", booleanAttribute] }, host: { properties: { "class.ant-spin-nested-loading": "!nzSimple" } }, exportAs: ["nzSpin"], usesOnChanges: true, ngImport: i0, template: `
  78. <ng-template #defaultTemplate>
  79. <span class="ant-spin-dot ant-spin-dot-spin">
  80. <i class="ant-spin-dot-item"></i>
  81. <i class="ant-spin-dot-item"></i>
  82. <i class="ant-spin-dot-item"></i>
  83. <i class="ant-spin-dot-item"></i>
  84. </span>
  85. </ng-template>
  86. @if (isLoading) {
  87. <div>
  88. <div
  89. class="ant-spin"
  90. [class.ant-spin-rtl]="dir === 'rtl'"
  91. [class.ant-spin-spinning]="isLoading"
  92. [class.ant-spin-lg]="nzSize === 'large'"
  93. [class.ant-spin-sm]="nzSize === 'small'"
  94. [class.ant-spin-show-text]="nzTip"
  95. >
  96. <ng-template [ngTemplateOutlet]="nzIndicator || defaultTemplate"></ng-template>
  97. @if (nzTip) {
  98. <div class="ant-spin-text">{{ nzTip }}</div>
  99. }
  100. </div>
  101. </div>
  102. }
  103. @if (!nzSimple) {
  104. <div class="ant-spin-container" [class.ant-spin-blur]="isLoading">
  105. <ng-content></ng-content>
  106. </div>
  107. }
  108. `, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], encapsulation: i0.ViewEncapsulation.None });
  109. };
  110. })();
  111. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzSpinComponent, decorators: [{
  112. type: Component,
  113. args: [{
  114. selector: 'nz-spin',
  115. exportAs: 'nzSpin',
  116. preserveWhitespaces: false,
  117. encapsulation: ViewEncapsulation.None,
  118. template: `
  119. <ng-template #defaultTemplate>
  120. <span class="ant-spin-dot ant-spin-dot-spin">
  121. <i class="ant-spin-dot-item"></i>
  122. <i class="ant-spin-dot-item"></i>
  123. <i class="ant-spin-dot-item"></i>
  124. <i class="ant-spin-dot-item"></i>
  125. </span>
  126. </ng-template>
  127. @if (isLoading) {
  128. <div>
  129. <div
  130. class="ant-spin"
  131. [class.ant-spin-rtl]="dir === 'rtl'"
  132. [class.ant-spin-spinning]="isLoading"
  133. [class.ant-spin-lg]="nzSize === 'large'"
  134. [class.ant-spin-sm]="nzSize === 'small'"
  135. [class.ant-spin-show-text]="nzTip"
  136. >
  137. <ng-template [ngTemplateOutlet]="nzIndicator || defaultTemplate"></ng-template>
  138. @if (nzTip) {
  139. <div class="ant-spin-text">{{ nzTip }}</div>
  140. }
  141. </div>
  142. </div>
  143. }
  144. @if (!nzSimple) {
  145. <div class="ant-spin-container" [class.ant-spin-blur]="isLoading">
  146. <ng-content></ng-content>
  147. </div>
  148. }
  149. `,
  150. host: {
  151. '[class.ant-spin-nested-loading]': '!nzSimple'
  152. },
  153. imports: [NgTemplateOutlet]
  154. }]
  155. }], ctorParameters: () => [{ type: i1.NzConfigService }, { type: i0.ChangeDetectorRef }, { type: i2.Directionality }], propDecorators: { nzIndicator: [{
  156. type: Input
  157. }], nzSize: [{
  158. type: Input
  159. }], nzTip: [{
  160. type: Input
  161. }], nzDelay: [{
  162. type: Input,
  163. args: [{ transform: numberAttribute }]
  164. }], nzSimple: [{
  165. type: Input,
  166. args: [{ transform: booleanAttribute }]
  167. }], nzSpinning: [{
  168. type: Input,
  169. args: [{ transform: booleanAttribute }]
  170. }] } });
  171. /**
  172. * Use of this source code is governed by an MIT-style license that can be
  173. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  174. */
  175. class NzSpinModule {
  176. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzSpinModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
  177. static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.2", ngImport: i0, type: NzSpinModule, imports: [NzSpinComponent], exports: [NzSpinComponent] });
  178. static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzSpinModule });
  179. }
  180. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzSpinModule, decorators: [{
  181. type: NgModule,
  182. args: [{
  183. imports: [NzSpinComponent],
  184. exports: [NzSpinComponent]
  185. }]
  186. }] });
  187. /**
  188. * Use of this source code is governed by an MIT-style license that can be
  189. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  190. */
  191. /**
  192. * Generated bundle index. Do not edit.
  193. */
  194. export { NzSpinComponent, NzSpinModule };
  195. //# sourceMappingURL=ng-zorro-antd-spin.mjs.map