@skyux/ag-grid 13.6.0 → 13.6.2

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.
@@ -7,7 +7,7 @@ import { SkyLibResourcesService, SkyI18nModule } from '@skyux/i18n';
7
7
  import { toSignal, toObservable, takeUntilDestroyed } from '@angular/core/rxjs-interop';
8
8
  import * as i1 from '@skyux/core';
9
9
  import { SkyMutationObserverService, SkyIdModule, SkyViewkeeperModule, SkyMediaQueryService, SkyResizeObserverService, SkyAffixModule, SkyOverlayService, SkyScrollableHostService, SKY_STACKING_CONTEXT, SkyNumericModule, SkyDynamicComponentService, SkyDynamicComponentLocation, SkyLogService } from '@skyux/core';
10
- import { Subject, BehaviorSubject, ReplaySubject, takeUntil, combineLatest, of, distinctUntilChanged, take, Subscription, switchMap, merge, fromEvent, startWith, map, scan, filter as filter$1, fromEventPattern, isObservable, observeOn, asyncScheduler } from 'rxjs';
10
+ import { Subject, BehaviorSubject, ReplaySubject, takeUntil, combineLatest, of, distinctUntilChanged, take, switchMap, fromEvent, Subscription, merge, startWith, map, scan, filter as filter$1, fromEventPattern, isObservable, observeOn, asyncScheduler } from 'rxjs';
11
11
  import { takeUntil as takeUntil$1, filter, first } from 'rxjs/operators';
12
12
  import * as i2$4 from '@skyux/theme';
13
13
  import { SkyThemeService, SkyThemeModule } from '@skyux/theme';
@@ -742,7 +742,7 @@ class SkyAgGridDataManagerAdapterDirective {
742
742
  }
743
743
  }
744
744
  ngOnDestroy() {
745
- this.#ngUnsubscribe.next();
745
+ this.#unregisterAgGrid();
746
746
  this.#ngUnsubscribe.complete();
747
747
  }
748
748
  #checkForAgGrid(agGridList) {
@@ -769,6 +769,7 @@ class SkyAgGridDataManagerAdapterDirective {
769
769
  }
770
770
  }
771
771
  #unregisterAgGrid() {
772
+ this.#ngUnsubscribe.next();
772
773
  this.#currentAgGrid = undefined;
773
774
  /* istanbul ignore if */
774
775
  if (this.#dataStateSub) {
@@ -791,19 +792,12 @@ class SkyAgGridDataManagerAdapterDirective {
791
792
  this.#unregisterAgGrid();
792
793
  this.#currentAgGrid = agGrid;
793
794
  if (agGrid) {
794
- agGrid.gridReady.pipe(takeUntil$1(this.#ngUnsubscribe)).subscribe(() => {
795
+ this.#dataStateSub = agGrid.gridReady
796
+ .pipe(takeUntil$1(this.#ngUnsubscribe), switchMap(() => {
795
797
  if (this.#viewConfig && this.viewId) {
796
798
  this.#viewConfig.onSelectAllClick = () => agGrid.api.selectAll();
797
799
  this.#viewConfig.onClearAllClick = () => agGrid.api.deselectAll();
798
800
  this.#dataManagerSvc.updateViewConfig(this.#viewConfig);
799
- this.#dataStateSub = this.#dataManagerSvc
800
- .getDataStateUpdates(this.#viewConfig.id)
801
- .pipe(takeUntil$1(this.#ngUnsubscribe))
802
- .subscribe((dataState) => {
803
- this.#currentDataState = dataState;
804
- this.#displayColumns(dataState);
805
- this.#applySort(dataState);
806
- });
807
801
  if (agGrid.gridOptions?.context?.enableTopScroll) {
808
802
  this.#dataManagerSvc.setViewkeeperClasses(this.viewId, [
809
803
  '.ag-header',
@@ -811,7 +805,20 @@ class SkyAgGridDataManagerAdapterDirective {
811
805
  ]);
812
806
  }
813
807
  this.#applyColumnWidths();
808
+ return this.#dataManagerSvc.getDataStateUpdates(this.#viewConfig.id);
814
809
  }
810
+ /* istanbul ignore next */
811
+ return of(undefined);
812
+ }), filter(Boolean))
813
+ .subscribe((dataState) => {
814
+ this.#currentDataState = dataState;
815
+ this.#displayColumns(dataState);
816
+ this.#applySort(dataState);
817
+ });
818
+ agGrid.gridReady
819
+ .pipe(takeUntil$1(this.#ngUnsubscribe), switchMap(() => fromEvent(agGrid.api, 'gridPreDestroyed')))
820
+ .subscribe(() => {
821
+ this.#unregisterAgGrid();
815
822
  });
816
823
  agGrid.columnMoved
817
824
  .pipe(takeUntil$1(this.#ngUnsubscribe), filter((event) => ![
@@ -891,8 +898,8 @@ class SkyAgGridDataManagerAdapterDirective {
891
898
  }
892
899
  }
893
900
  #getColumnOrder(api) {
894
- return api
895
- .getColumnState()
901
+ /* istanbul ignore next */
902
+ return (api?.getColumnState() ?? [])
896
903
  .filter((state) => !state.hide)
897
904
  .map((state) => state.colId);
898
905
  }
@@ -906,8 +913,9 @@ class SkyAgGridDataManagerAdapterDirective {
906
913
  displayedColumnIds = viewState.displayedColumnIds;
907
914
  }
908
915
  const columnOrder = this.#getColumnOrder(agGrid.api);
909
- if (displayedColumnIds.length !== columnOrder.length ||
910
- displayedColumnIds.some((col, i) => col !== columnOrder[i])) {
916
+ if ((displayedColumnIds.length !== columnOrder.length ||
917
+ displayedColumnIds.some((col, i) => col !== columnOrder[i])) &&
918
+ agGrid.api) {
911
919
  const hideColumns = agGrid.api
912
920
  .getColumnState()
913
921
  .map((col) => col.colId)