@xh/hoist 78.0.0-SNAPSHOT.1763606028729 → 78.0.0-SNAPSHOT.1763665705643

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.
package/CHANGELOG.md CHANGED
@@ -2,21 +2,29 @@
2
2
 
3
3
  ## 78.0.0-SNAPSHOT - unreleased
4
4
 
5
+ ### 💥 Breaking Changes
6
+
7
+ * `GridModel.cleanColumnState` is now private (not expected to impact applications).
8
+ * `GridModel.setColumnState` no longer patches existing column state, but instead replaces it
9
+ wholesale. Applications that were relying on the prior patching behavior will need to
10
+ call `GridModel.applyColumnStateChanges` instead.
11
+
5
12
  ### 🎁 New Features
6
13
 
7
- * `FieldFilter` implementation expanded to support `not begins` and `not ends` operators.
14
+ * `FieldFilter` implementation expanded to support `not begins` and `not ends` operators.
8
15
 
9
16
  ### 🐞 Bug Fixes
10
17
 
11
18
  * Fixed `GridModel` not appending children to the parents correctly when loaded data uses a
12
19
  numerical ID.
20
+ * Fixed issue where newly added columns appearing in the Displayed Columns section of the column
21
+ chooser after loading grid state that was persisted before the columns were added to the grid.
13
22
 
14
23
  ### ⚙️ Technical
15
24
 
16
25
  * `FetchService` will recognize variants on the `application/json` content-type when processing
17
26
  failed responses and decoding exceptions - e.g. `application/problem+json`.
18
27
 
19
-
20
28
  ## 77.1.1 - 2025-11-12
21
29
 
22
30
  ### 🎁 New Features
@@ -122,8 +122,9 @@ export declare class AgGridModel extends HoistModel {
122
122
  applySortBy(value: Some<GridSorterLike>): void;
123
123
  /**
124
124
  * @returns the current row expansion state of the grid in a serializable form.
125
- * Returned object has keys for StoreRecordIds of top-level, expanded records and values
126
- * of either `true` or an object with keys of StoreRecordIds of expanded child records.
125
+ * Returned object has keys for (stringified!) StoreRecordIds of all top-level
126
+ * expanded rows and values of either `true` (if the row does not have any children, or
127
+ * none are expanded) or a recursive object of the same shape (if children are expanded).
127
128
  */
128
129
  getExpandState(): PlainObject;
129
130
  /**
@@ -464,7 +464,7 @@ export declare class GridModel extends HoistModel {
464
464
  /** Clear the underlying store, removing all rows. */
465
465
  clear(): void;
466
466
  setColumns(colConfigs: Array<ColumnSpec | ColumnGroupSpec>): void;
467
- setColumnState(colState: Partial<ColumnState>[]): void;
467
+ setColumnState(colState: ColumnState[]): void;
468
468
  showColChooser(): void;
469
469
  noteAgColumnStateChanged(agColState: AgColumnState[]): void;
470
470
  setExpandState(expandState: any): void;
@@ -583,7 +583,7 @@ export declare class GridModel extends HoistModel {
583
583
  private validateStoreConfig;
584
584
  private validateColConfigs;
585
585
  private validateColumns;
586
- cleanColumnState(columnState: any): any;
586
+ private cleanColumnState;
587
587
  private enhanceColConfigsFromStore;
588
588
  private enhanceStoreConfigFromColumns;
589
589
  private leafColsByFieldName;
@@ -597,4 +597,5 @@ export declare class GridModel extends HoistModel {
597
597
  private readonly RIGHT_BORDER_CLASS;
598
598
  private enhanceConfigWithGroupBorders;
599
599
  private createGroupBorderFn;
600
+ private getDefaultStateForColumn;
600
601
  }
@@ -408,8 +408,9 @@ export class AgGridModel extends HoistModel {
408
408
 
409
409
  /**
410
410
  * @returns the current row expansion state of the grid in a serializable form.
411
- * Returned object has keys for StoreRecordIds of top-level, expanded records and values
412
- * of either `true` or an object with keys of StoreRecordIds of expanded child records.
411
+ * Returned object has keys for (stringified!) StoreRecordIds of all top-level
412
+ * expanded rows and values of either `true` (if the row does not have any children, or
413
+ * none are expanded) or a recursive object of the same shape (if children are expanded).
413
414
  */
414
415
  getExpandState(): PlainObject {
415
416
  this.throwIfNotReady();
@@ -98,6 +98,7 @@ import {
98
98
  pull,
99
99
  take
100
100
  } from 'lodash';
101
+ import {computed} from 'mobx';
101
102
  import {createRef, ReactNode, RefObject} from 'react';
102
103
  import {GridAutosizeOptions} from './GridAutosizeOptions';
103
104
  import {GridContextMenuSpec} from './GridContextMenu';
@@ -442,6 +443,7 @@ export class GridModel extends HoistModel {
442
443
  @observable.ref groupBy: string[] = null;
443
444
  @observable expandLevel: number = 0;
444
445
 
446
+ @computed.struct
445
447
  get persistableColumnState(): ColumnState[] {
446
448
  return this.cleanColumnState(this.columnState);
447
449
  }
@@ -1147,19 +1149,11 @@ export class GridModel extends HoistModel {
1147
1149
  this.validateColumns(columns);
1148
1150
 
1149
1151
  this.columns = columns;
1150
- this.columnState = this.getLeafColumns().map(it => ({
1151
- ...pick(it, ['colId', 'width', 'hidden', 'pinned']),
1152
- // If not in managed auto-size mode, treat in-code column widths as manuallySized so
1153
- // widths are not omitted from persistableColumnState. This is important because
1154
- // PersistanceProvider.getPersistableState() expects a complete snapshot of initial
1155
- // state in order to detect changes and restore initial state correctly.
1156
- // See https://github.com/xh/hoist-react/issues/4102.
1157
- manuallySized: !!(it.width && this.autosizeOptions.mode !== 'managed')
1158
- }));
1152
+ this.columnState = this.getLeafColumns().map(it => this.getDefaultStateForColumn(it));
1159
1153
  }
1160
1154
 
1161
- setColumnState(colState: Partial<ColumnState>[]) {
1162
- this.applyColumnStateChanges(this.cleanColumnState(colState));
1155
+ setColumnState(colState: ColumnState[]) {
1156
+ this.columnState = this.cleanColumnState(colState);
1163
1157
  }
1164
1158
 
1165
1159
  showColChooser() {
@@ -1706,7 +1700,7 @@ export class GridModel extends HoistModel {
1706
1700
  );
1707
1701
  }
1708
1702
 
1709
- cleanColumnState(columnState) {
1703
+ private cleanColumnState(columnState) {
1710
1704
  const gridCols = this.getLeafColumns();
1711
1705
 
1712
1706
  // REMOVE any state columns that are no longer found in the grid. These were likely saved
@@ -1715,9 +1709,9 @@ export class GridModel extends HoistModel {
1715
1709
 
1716
1710
  // ADD any grid columns that are not found in state. These are newly added to the code.
1717
1711
  // Insert these columns in position based on the index at which they are defined.
1718
- gridCols.forEach(({colId}, idx) => {
1719
- if (!find(ret, {colId})) {
1720
- ret.splice(idx, 0, {colId});
1712
+ gridCols.forEach((col, idx) => {
1713
+ if (!find(ret, {colId: col.colId})) {
1714
+ ret.splice(idx, 0, this.getDefaultStateForColumn(col));
1721
1715
  }
1722
1716
  });
1723
1717
 
@@ -1958,4 +1952,16 @@ export class GridModel extends HoistModel {
1958
1952
  }
1959
1953
  };
1960
1954
  }
1955
+
1956
+ private getDefaultStateForColumn(column: Column): ColumnState {
1957
+ return {
1958
+ ...pick(column, ['colId', 'width', 'hidden', 'pinned']),
1959
+ // If not in managed auto-size mode, treat in-code column widths as manuallySized so
1960
+ // widths are not omitted from persistableColumnState. This is important because
1961
+ // PersistanceProvider.getPersistableState() expects a complete snapshot of initial
1962
+ // state in order to detect changes and restore initial state correctly.
1963
+ // See https://github.com/xh/hoist-react/issues/4102.
1964
+ manuallySized: !!(column.width && this.autosizeOptions.mode !== 'managed')
1965
+ };
1966
+ }
1961
1967
  }
@@ -39,9 +39,7 @@ export function initPersist(
39
39
  new PersistableColumnState(gridModel.persistableColumnState),
40
40
  setPersistableState: ({value}) =>
41
41
  runInAction(() => {
42
- // Set columnState directly since GridModel.setColumnState will merge the
43
- // provided state with the current state, which is not what we want here.
44
- gridModel.columnState = gridModel.cleanColumnState(value);
42
+ gridModel.setColumnState(value);
45
43
  if (gridModel.autosizeOptions.mode === 'managed') {
46
44
  const columns = gridModel.columnState
47
45
  .filter(it => !it.manuallySized)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "78.0.0-SNAPSHOT.1763606028729",
3
+ "version": "78.0.0-SNAPSHOT.1763665705643",
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",