{"version":3,"file":"ng-zorro-antd-spin.mjs","names":[],"sources":["../../components/spin/spin.component.ts","../../components/spin/spin.module.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 { Directionality } from '@angular/cdk/bidi';\nimport { NgTemplateOutlet } from '@angular/common';\nimport {\n  ChangeDetectorRef,\n  Component,\n  Input,\n  OnChanges,\n  OnInit,\n  SimpleChanges,\n  TemplateRef,\n  ViewEncapsulation,\n  booleanAttribute,\n  numberAttribute,\n  inject,\n  DestroyRef,\n  signal\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { BehaviorSubject, Observable, of, ReplaySubject } from 'rxjs';\nimport { distinctUntilChanged, startWith, switchMap } from 'rxjs/operators';\n\nimport { NzConfigKey, onConfigChangeEventForComponent, WithConfig } from 'ng-zorro-antd/core/config';\nimport { NzSafeAny, NzSizeLDSType } from 'ng-zorro-antd/core/types';\n\nconst NZ_CONFIG_MODULE_NAME: NzConfigKey = 'spin';\n\n@Component({\n  selector: 'nz-spin',\n  exportAs: 'nzSpin',\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    @if (isLoading()) {\n      <div>\n        <div\n          class=\"ant-spin ant-spin-spinning\"\n          [class.ant-spin-rtl]=\"dir() === 'rtl'\"\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\" />\n          @if (nzTip) {\n            <div class=\"ant-spin-text\">{{ nzTip }}</div>\n          }\n        </div>\n      </div>\n    }\n    @if (!nzSimple) {\n      <div class=\"ant-spin-container\" [class.ant-spin-blur]=\"isLoading()\">\n        <ng-content />\n      </div>\n    }\n  `,\n  host: {\n    '[class.ant-spin-nested-loading]': '!nzSimple'\n  },\n  imports: [NgTemplateOutlet]\n})\nexport class NzSpinComponent implements OnChanges, OnInit {\n  readonly _nzModuleName: NzConfigKey = NZ_CONFIG_MODULE_NAME;\n\n  private cdr = inject(ChangeDetectorRef);\n  protected readonly dir = inject(Directionality).valueSignal;\n  private destroyRef = inject(DestroyRef);\n\n  @Input() @WithConfig() nzIndicator: TemplateRef<NzSafeAny> | null = null;\n  @Input() nzSize: NzSizeLDSType = 'default';\n  @Input() nzTip: string | null = null;\n  @Input({ transform: numberAttribute }) nzDelay = 0;\n  @Input({ transform: booleanAttribute }) nzSimple = false;\n  @Input({ transform: booleanAttribute }) nzSpinning = true;\n  private spinning$ = new BehaviorSubject(this.nzSpinning);\n  private delay$ = new ReplaySubject<number>(1);\n\n  readonly isLoading = signal(false);\n\n  constructor() {\n    onConfigChangeEventForComponent(NZ_CONFIG_MODULE_NAME, () => this.cdr.markForCheck());\n  }\n\n  ngOnInit(): void {\n    this.delay$\n      .pipe(\n        startWith(this.nzDelay),\n        distinctUntilChanged(),\n        switchMap(delay =>\n          // This construct is used to reduce RxJS dependencies.\n          // It previously used `debounce(() => timer())`, but consumers may not\n          // use these RxJS functions at all, causing them to still be bundled\n          // into the main bundle unnecessarily.\n          this.spinning$.pipe(\n            switchMap(spinning => {\n              if (delay === 0 || !spinning) {\n                return of(spinning);\n              }\n              return new Observable<boolean>(subscriber => {\n                const timeoutId = setTimeout(() => subscriber.next(spinning), delay);\n                return () => clearTimeout(timeoutId);\n              });\n            })\n          )\n        ),\n        takeUntilDestroyed(this.destroyRef)\n      )\n      .subscribe(isLoading => {\n        this.isLoading.set(isLoading);\n      });\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","/**\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 { NgModule } from '@angular/core';\n\nimport { NzSpinComponent } from './spin.component';\n\n@NgModule({\n  imports: [NzSpinComponent],\n  exports: [NzSpinComponent]\n})\nexport class NzSpinModule {}\n"],"mappings":";;;;;;;;;AA6BA,MAAM,wBAAqC;AA0C9B,IAAA,yBAAe;;;;CAAf,OAAA,MAAA,gBAAe;;;GAOhB,0BAAA,CAAA,WAAU,CAAE;GAAC,aAAA,MAAA,MAAA,yBAAA;IAAA,MAAA;IAAA,MAAA;IAAA,QAAA;IAAA,SAAA;IAAA,QAAA;KAAA,MAAA,QAAA,iBAAA;KAAA,MAAA,QAAA,IAAA;KAAW,MAAA,KAAA,UAAA;MAAA,IAAX,cAAW;KAAA;IAAA;IAAA,UAAA;GAAA,GAAA,2BAAA,8BAAA;;;;;;;;EANzB,gBAA6B;EAE9B,MAAM,OAAO,iBAAiB;EACnB,MAAM,OAAO,cAAc,CAAC,CAAC;EACxC,aAAa,OAAO,UAAU;EAEf,cAAW,kBAAA,MAAA,2BAAkC,IAAI;EAC/D,UAAM,kBAAA,MAAA,8BAAA,GAAkB;EACxB,QAAuB;EACO,UAAU;EACT,WAAW;EACX,aAAa;EAC7C,YAAY,IAAI,gBAAgB,KAAK,UAAU;EAC/C,SAAS,IAAI,cAAsB,CAAC;EAEnC,YAAY,OAAO,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;EAElC,cAAA;GACE,gCAAgC,6BAA6B,KAAK,IAAI,aAAY,CAAE;EACtF;EAEA,WAAQ;GACN,KAAK,OACF,KACC,UAAU,KAAK,OAAO,GACtB,qBAAoB,GACpB,WAAU,UA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