@recursyve/nice-ui-kit.v2 14.0.0-beta.109 → 14.0.0-beta.110

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@ import * as i0 from '@angular/core';
5
5
  import { Injectable, NgModule, EventEmitter, Component, ViewEncapsulation, ChangeDetectionStrategy, Input, Output, HostBinding, InjectionToken, Directive, HostListener, forwardRef, TemplateRef, Optional, Inject, ViewChild, ContentChild, ViewChildren, Self, Pipe, ElementRef, PLATFORM_ID, ContentChildren, SimpleChange, SkipSelf } from '@angular/core';
6
6
  import { plainToInstance } from 'class-transformer';
7
7
  import { map, filter, takeUntil, tap, take, debounceTime as debounceTime$1, delay, switchMap } from 'rxjs/operators';
8
- import { catchError, ReplaySubject, Subject, BehaviorSubject, mergeMap, from, isObservable, firstValueFrom, debounceTime, distinctUntilChanged, startWith, tap as tap$1, Observable, combineLatest, of, fromEvent, merge as merge$1 } from 'rxjs';
8
+ import { catchError, ReplaySubject, Subject, BehaviorSubject, mergeMap, from, isObservable, firstValueFrom, debounceTime, distinctUntilChanged, startWith, tap as tap$1, Observable, combineLatest, of, fromEvent, merge as merge$1, pairwise } from 'rxjs';
9
9
  import { coerceBooleanProperty } from '@angular/cdk/coercion';
10
10
  import * as i2 from '@angular/common';
11
11
  import { CommonModule, DatePipe, CurrencyPipe, DOCUMENT, isPlatformServer } from '@angular/common';
@@ -10429,13 +10429,23 @@ class NiceDraggableListDirective {
10429
10429
  this.itemsUpdated = new EventEmitter();
10430
10430
  this.itemRankUpdated = new EventEmitter();
10431
10431
  this.sortedItems = [];
10432
+ this.unsubscribeAll$ = new Subject();
10432
10433
  }
10433
10434
  ngOnInit() {
10434
10435
  if (this.formArrayName) {
10435
10436
  this.formArray = this.formArrayName.control;
10437
+ this.formArray.valueChanges.pipe(takeUntil(this.unsubscribeAll$), startWith(this.formArray.getRawValue()), map(() => this.formArray.getRawValue()), pairwise()).subscribe(([previous, current]) => {
10438
+ if (previous.length !== current.length) {
10439
+ this.sortItems(current);
10440
+ }
10441
+ });
10436
10442
  this.sortItems(this.formArray.getRawValue());
10437
10443
  }
10438
- this.cdkDropList.dropped.subscribe((event) => this.drop(event));
10444
+ this.cdkDropList.dropped.pipe(takeUntil(this.unsubscribeAll$)).subscribe((event) => this.drop(event));
10445
+ }
10446
+ ngOnDestroy() {
10447
+ this.unsubscribeAll$.next();
10448
+ this.unsubscribeAll$.complete();
10439
10449
  }
10440
10450
  ngOnChanges(changes) {
10441
10451
  if ("items" in changes && this.items) {