@skyux/ag-grid 14.0.0-alpha.8 → 14.0.0-alpha.9

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, takeUntilDestroyed, toObservable } 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 { SkyDataManagerService } from '@skyux/data-manager';
10
+ import { SkyDataManagerService, SkyDataManagerState, SkyDataViewState } from '@skyux/data-manager';
11
11
  import { Observable, EMPTY, merge, Subject, map, takeUntil, switchMap, of, filter, Subscription, startWith, scan, BehaviorSubject, take, distinctUntilChanged, fromEvent, first, isObservable } from 'rxjs';
12
12
  import * as i1$5 from '@skyux/theme';
13
13
  import { SkyThemeService, SkyThemeModule } from '@skyux/theme';
@@ -855,7 +855,7 @@ class SkyAgGridDataManagerAdapterDirective {
855
855
  const viewConfig = this.#viewConfig();
856
856
  if (viewConfig && this.#currentDataState) {
857
857
  const row = event.node;
858
- const selectedIds = this.#currentDataState.selectedIds || [];
858
+ const selectedIds = [...(this.#currentDataState.selectedIds || [])];
859
859
  const rowIndex = selectedIds.indexOf(row.data.id);
860
860
  if (row.isSelected() && rowIndex === -1) {
861
861
  selectedIds.push(row.data.id);
@@ -863,8 +863,10 @@ class SkyAgGridDataManagerAdapterDirective {
863
863
  else if (!row.isSelected() && rowIndex !== -1) {
864
864
  selectedIds.splice(rowIndex, 1);
865
865
  }
866
- this.#currentDataState.selectedIds = selectedIds;
867
- this.#dataManagerSvc.updateDataState(this.#currentDataState, viewConfig.id);
866
+ const newState = new SkyDataManagerState(this.#currentDataState.getStateOptions());
867
+ newState.selectedIds = selectedIds;
868
+ this.#currentDataState = newState;
869
+ this.#dataManagerSvc.updateDataState(newState, viewConfig.id);
868
870
  this.#changeDetector.markForCheck();
869
871
  }
870
872
  });
@@ -874,9 +876,10 @@ class SkyAgGridDataManagerAdapterDirective {
874
876
  const activeSortColumnState = gridColumnStates?.find((aGridColumnState) => aGridColumnState.sortIndex === 0) ??
875
877
  gridColumnStates?.find((aGridColumnState) => aGridColumnState.sort);
876
878
  if (viewConfig && this.#currentDataState) {
879
+ const newState = new SkyDataManagerState(this.#currentDataState.getStateOptions());
877
880
  if (activeSortColumnState) {
878
881
  const activeSortColumnDef = agGrid.api.getColumnDef(activeSortColumnState.colId);
879
- this.#currentDataState.activeSortOption = {
882
+ newState.activeSortOption = {
880
883
  descending: activeSortColumnState.sort === 'desc',
881
884
  id: activeSortColumnState.colId,
882
885
  propertyName: activeSortColumnDef?.field || '',
@@ -884,9 +887,10 @@ class SkyAgGridDataManagerAdapterDirective {
884
887
  };
885
888
  }
886
889
  else {
887
- this.#currentDataState.activeSortOption = undefined;
890
+ newState.activeSortOption = undefined;
888
891
  }
889
- this.#dataManagerSvc.updateDataState(this.#currentDataState, viewConfig.id);
892
+ this.#currentDataState = newState;
893
+ this.#dataManagerSvc.updateDataState(newState, viewConfig.id);
890
894
  }
891
895
  });
892
896
  }
@@ -899,8 +903,11 @@ class SkyAgGridDataManagerAdapterDirective {
899
903
  if (viewState &&
900
904
  (viewState.displayedColumnIds.length !== columnOrder.length ||
901
905
  viewState.displayedColumnIds.some((col, i) => col !== columnOrder[i]))) {
902
- viewState.displayedColumnIds = columnOrder;
903
- this.#dataManagerSvc.updateDataState(this.#currentDataState.addOrUpdateView(viewConfig.id, viewState), viewConfig.id);
906
+ const updatedViewState = new SkyDataViewState(viewState.getViewStateOptions());
907
+ updatedViewState.displayedColumnIds = columnOrder;
908
+ const newDataState = this.#currentDataState.addOrUpdateView(viewConfig.id, updatedViewState);
909
+ this.#currentDataState = newDataState;
910
+ this.#dataManagerSvc.updateDataState(newDataState, viewConfig.id);
904
911
  }
905
912
  }
906
913
  }
@@ -954,23 +961,26 @@ class SkyAgGridDataManagerAdapterDirective {
954
961
  const viewId = this.viewId();
955
962
  const viewState = viewId && this.#currentDataState?.getViewStateById(viewId);
956
963
  if (viewState && viewId && this.#currentDataState) {
957
- const currentWidths = viewState?.columnWidths;
958
- currentWidths[toColumnWidthName(breakpoint)][colId] = width;
959
- viewState.columnWidths = currentWidths;
960
- this.#dataManagerSvc.updateDataState(this.#currentDataState.addOrUpdateView(viewId, viewState), viewId);
964
+ const updatedViewState = new SkyDataViewState(viewState.getViewStateOptions());
965
+ updatedViewState.columnWidths[toColumnWidthName(breakpoint)][colId] =
966
+ width;
967
+ const newDataState = this.#currentDataState.addOrUpdateView(viewId, updatedViewState);
968
+ this.#currentDataState = newDataState;
969
+ this.#dataManagerSvc.updateDataState(newDataState, viewId);
961
970
  }
962
971
  }
963
972
  #removeColumnWidths(colIds) {
964
973
  const viewId = this.viewId();
965
974
  const viewState = viewId && this.#currentDataState?.getViewStateById(viewId);
966
975
  if (viewState && viewId && this.#currentDataState) {
967
- const currentWidths = viewState?.columnWidths;
976
+ const updatedViewState = new SkyDataViewState(viewState.getViewStateOptions());
968
977
  for (const colId of colIds) {
969
- delete currentWidths['xs'][colId];
970
- delete currentWidths['sm'][colId];
978
+ delete updatedViewState.columnWidths['xs'][colId];
979
+ delete updatedViewState.columnWidths['sm'][colId];
971
980
  }
972
- viewState.columnWidths = currentWidths;
973
- this.#dataManagerSvc.updateDataState(this.#currentDataState.addOrUpdateView(viewId, viewState), viewId);
981
+ const newDataState = this.#currentDataState.addOrUpdateView(viewId, updatedViewState);
982
+ this.#currentDataState = newDataState;
983
+ this.#dataManagerSvc.updateDataState(newDataState, viewId);
974
984
  }
975
985
  }
976
986
  #applyColumnWidths(breakpoint) {