@homebound/beam 2.132.2 → 2.132.3

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.
@@ -126,19 +126,19 @@ class RowState {
126
126
  }
127
127
  // Should be called in an Observer/useComputed to trigger re-renders
128
128
  isCollapsed(id) {
129
- return this.collapsedRows.has(id) || this.collapsedRows.has("header");
129
+ return this.collapsedRows.has(id);
130
130
  }
131
131
  toggleCollapsed(id) {
132
132
  const collapsedIds = [...this.collapsedRows.values()];
133
133
  // We have different behavior when going from expand/collapse all.
134
134
  if (id === "header") {
135
- const isAllCollapsed = collapsedIds[0] === "header";
135
+ const isAllCollapsed = collapsedIds.includes("header");
136
136
  if (isAllCollapsed) {
137
137
  // Expand all means keep `collapsedIds` empty
138
138
  collapsedIds.splice(0, collapsedIds.length);
139
139
  }
140
140
  else {
141
- // Otherwise push `header` on the list as a hint that we're in the collapsed-all state
141
+ // Otherwise push `header` to the list as a hint that we're in the collapsed-all state
142
142
  collapsedIds.push("header");
143
143
  // Find all non-leaf rows so that toggling "all collapsed" -> "all not collapsed" opens
144
144
  // the parent rows of any level.
@@ -164,6 +164,16 @@ class RowState {
164
164
  else {
165
165
  collapsedIds.splice(i, 1);
166
166
  }
167
+ // If all rows have been expanded individually, but the 'header' was collapsed, then remove the header from the collapsedIds so it reverts to the expanded state
168
+ if (collapsedIds.length === 1 && collapsedIds[0] === "header") {
169
+ collapsedIds.splice(0, 1);
170
+ }
171
+ else {
172
+ // If every top level child has been collapsed, then push "header" into the array to be considered collapsed as well.
173
+ if (this.rows.every((maybeParent) => (maybeParent.children ? collapsedIds.includes(maybeParent.id) : true))) {
174
+ collapsedIds.push("header");
175
+ }
176
+ }
167
177
  }
168
178
  this.collapsedRows.replace(collapsedIds);
169
179
  if (this.persistCollapse) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.132.2",
3
+ "version": "2.132.3",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -116,6 +116,7 @@
116
116
  "identity-obj-proxy": "^3.0.0",
117
117
  "jest": "^26.6.3",
118
118
  "jest-chain": "^1.1.5",
119
+ "jest-watch-typeahead": "^0.6.5",
119
120
  "mobx": "^6.3.2",
120
121
  "mobx-react": "^7.2.0",
121
122
  "prettier": "^2.2.1",