@xh/hoist 75.0.0-SNAPSHOT.1753458616250 → 75.0.0-SNAPSHOT.1753468710177

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.
@@ -119,7 +119,7 @@ export declare class GridLocalModel extends HoistModel {
119
119
  nodeA: any;
120
120
  nodeB: any;
121
121
  }) => number;
122
- doWithPreservedState({ expansion, filters }: PlainObject, fn: any): void;
122
+ doWithPreservedState({ filters }: PlainObject, fn: any): void;
123
123
  readFilterState(): import("@ag-grid-community/core").FilterModel;
124
124
  writeFilterState(filterState: any): void;
125
125
  processCellForClipboard: ({ value, node, column }: ProcessCellForExportParams) => any;
package/cmp/grid/Grid.ts CHANGED
@@ -767,12 +767,9 @@ export class GridLocalModel extends HoistModel {
767
767
  return gridModel.groupSortFn(nodeA.key, nodeB.key, nodeA.field, {gridModel, nodeA, nodeB});
768
768
  };
769
769
 
770
- doWithPreservedState({expansion, filters}: PlainObject, fn) {
771
- const {agGridModel} = this.model,
772
- expandState = expansion ? agGridModel.getExpandState() : null,
773
- filterState = filters ? this.readFilterState() : null;
770
+ doWithPreservedState({filters}: PlainObject, fn) {
771
+ const filterState = filters ? this.readFilterState() : null;
774
772
  fn();
775
- if (expandState) agGridModel.setExpandState(expandState);
776
773
  if (filterState) this.writeFilterState(filterState);
777
774
  }
778
775
 
@@ -645,13 +645,6 @@ export class GridModel extends HoistModel {
645
645
  debounce: 500
646
646
  });
647
647
 
648
- this.addReaction({
649
- track: () => [this.expandLevel, this.isReady],
650
- run: () => {
651
- this.agApi?.setGridOption('groupDefaultExpanded', this.expandLevel);
652
- }
653
- });
654
-
655
648
  if (!isEmpty(rest)) {
656
649
  const keys = keysIn(rest);
657
650
  throw XH.exception(
@@ -1043,6 +1036,28 @@ export class GridModel extends HoistModel {
1043
1036
  @action
1044
1037
  expandToLevel(level: number) {
1045
1038
  this.expandLevel = level;
1039
+
1040
+ // 0) Not rendered, we are done.
1041
+ const {agApi} = this;
1042
+ if (!agApi) return;
1043
+
1044
+ // 1) Update rendered grid.
1045
+ if (agApi.getGridOption('groupDefaultExpanded') != level) {
1046
+ // If the ag default is *not* set to this level just set it. This somewhat
1047
+ // mysteriously (but efficiently) changes the currently rendered rows as well.
1048
+ agApi.setGridOption('groupDefaultExpanded', level);
1049
+ } else if (level == 0 || level >= this.maxDepth) {
1050
+ // otherwise api methods available.
1051
+ level == 0 ? agApi.collapseAll() : agApi.expandAll();
1052
+ } else {
1053
+ // Otherwise, *toggle* the default.
1054
+ // Surprisingly, this appears to be the only efficient way to do the bulk operation.
1055
+ agApi.setGridOption('groupDefaultExpanded', 0);
1056
+ agApi.setGridOption('groupDefaultExpanded', level);
1057
+ }
1058
+
1059
+ // 2) Finally, be sure to update our state snapshot.
1060
+ this.noteAgExpandStateChange();
1046
1061
  }
1047
1062
 
1048
1063
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "75.0.0-SNAPSHOT.1753458616250",
3
+ "version": "75.0.0-SNAPSHOT.1753468710177",
4
4
  "description": "Hoist add-on for building and deploying React Applications.",
5
5
  "repository": "github:xh/hoist-react",
6
6
  "homepage": "https://xh.io",