@homebound/beam 4.39.0 → 4.40.1

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/dist/index.js CHANGED
@@ -6283,7 +6283,7 @@ var ColumnState = class {
6283
6283
  constructor(states, storage, column2) {
6284
6284
  this.states = states;
6285
6285
  this.column = column2;
6286
- this.visible = storage.wasVisible(column2.id) ?? (column2.canHide ? !(column2.initHidden ?? true) : true);
6286
+ this.visible = !column2.canHide || (storage.wasVisible(column2.id) ?? !(column2.initHidden ?? true));
6287
6287
  if (this.visible && (storage.wasExpanded(column2.id) ?? column2.initExpanded)) {
6288
6288
  this.expanded = true;
6289
6289
  this.doExpand();
@@ -6294,10 +6294,17 @@ var ColumnState = class {
6294
6294
  children = void 0;
6295
6295
  visible = true;
6296
6296
  expanded = false;
6297
+ /**
6298
+ * Whether this column is shown. We check `canHide` here too b/c when `props.columns` changes,
6299
+ * `addColumn` can replace a hidden column's definition with one that can't be hidden.
6300
+ */
6301
+ get isVisible() {
6302
+ return this.visible || !this.column.canHide;
6303
+ }
6297
6304
  setVisible(visible) {
6298
- const wasVisible = this.visible;
6299
- this.visible = visible;
6300
- if (!wasVisible && visible && this.column.initExpanded && this.children === void 0) {
6305
+ const wasVisible = this.isVisible;
6306
+ this.visible = visible || !this.column.canHide;
6307
+ if (!wasVisible && this.visible && this.column.initExpanded && this.children === void 0) {
6301
6308
  this.expanded = true;
6302
6309
  this.doExpand();
6303
6310
  }
@@ -6321,9 +6328,13 @@ var ColumnState = class {
6321
6328
  this.children = expandColumns.map((ec) => this.states.addColumn(ec));
6322
6329
  }
6323
6330
  }
6331
+ /** Returns this column and all of its loaded children, whether visible and expanded or not. */
6332
+ get selfAndChildren() {
6333
+ return [this, ...(this.children ?? []).flatMap((c) => c.selfAndChildren)];
6334
+ }
6324
6335
  /** Returns this column, if visible, and its children, if expanded. */
6325
6336
  get maybeSelfAndChildren() {
6326
- if (!this.visible) {
6337
+ if (!this.isVisible) {
6327
6338
  return [];
6328
6339
  } else if (this.expanded && this.children) {
6329
6340
  return [this, ...this.children.flatMap((c) => c.maybeSelfAndChildren)];
@@ -7573,9 +7584,13 @@ var ColumnStates = class {
7573
7584
  allVisibleColumns(showIn) {
7574
7585
  return this.columns.flatMap((cs) => cs.maybeSelfAndChildren).filter((cs) => !cs.column.showIn || cs.column.showIn === showIn).filter((cs) => showIn === "csv" ? isContentColumn(cs.column) : true);
7575
7586
  }
7587
+ /**
7588
+ * Shows the current columns in `ids` and hides the others. Columns that can't be hidden, like layout gutters, stay shown.
7589
+ * Columns not currently in the table keep their visibility, so a column that's temporarily removed comes back as it was.
7590
+ */
7576
7591
  setVisibleColumns(ids) {
7577
- for (const cs of this.map.values()) {
7578
- cs.setVisible(cs.column.isLayoutGutter ? true : ids.includes(cs.column.id));
7592
+ for (const cs of this.columns.flatMap((c) => c.selfAndChildren)) {
7593
+ cs.setVisible(ids.includes(cs.column.id));
7579
7594
  }
7580
7595
  }
7581
7596
  loadExpanded(storageKey) {