@homebound/beam 2.132.2 → 2.133.0

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) {
@@ -8,7 +8,7 @@ const useTestIds_1 = require("../utils/useTestIds");
8
8
  /** Renders a list of `Chip`s, with wrapping & appropriate margin between each `Chip`. */
9
9
  function ToggleChips(props) {
10
10
  const { values, getLabel, onRemove, xss } = props;
11
- const tid = (0, useTestIds_1.useTestIds)(props, "chip");
12
- return ((0, jsx_runtime_1.jsx)("div", Object.assign({ css: { ...Css_1.Css.df.add({ flexWrap: "wrap" }).my1.$, xss } }, { children: values.map((value, i) => ((0, jsx_runtime_1.jsx)(ToggleChip_1.ToggleChip, Object.assign({ text: getLabel(value), onClick: () => onRemove(value), xss: Css_1.Css.mr1.mb1.$ }, tid), i))) }), void 0));
11
+ const tid = (0, useTestIds_1.useTestIds)(props, "toggleChips");
12
+ return ((0, jsx_runtime_1.jsx)("div", Object.assign({ css: { ...Css_1.Css.df.add("flexWrap", "wrap").gap1.$, ...xss } }, tid, { children: values.map((value) => ((0, jsx_runtime_1.jsx)(ToggleChip_1.ToggleChip, Object.assign({ text: getLabel(value), onClick: () => onRemove(value) }, tid.chip), getLabel(value)))) }), void 0));
13
13
  }
14
14
  exports.ToggleChips = ToggleChips;
@@ -6,5 +6,6 @@ export declare type BoundCheckboxGroupFieldProps = Omit<CheckboxGroupProps, "val
6
6
  onChange?: (values: string[]) => void;
7
7
  label?: string;
8
8
  };
9
- /** Wraps `TextField` and binds it to a form field. */
9
+ /** Wraps `CheckboxGroup` and binds it to a form field.
10
+ * To make the field agnostic to the order of selected values, add `strictOrder: false` to the field's ObjectConfig */
10
11
  export declare function BoundCheckboxGroupField(props: BoundCheckboxGroupFieldProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -6,7 +6,8 @@ const mobx_react_1 = require("mobx-react");
6
6
  const inputs_1 = require("../inputs");
7
7
  const utils_1 = require("../utils");
8
8
  const defaultLabel_1 = require("../utils/defaultLabel");
9
- /** Wraps `TextField` and binds it to a form field. */
9
+ /** Wraps `CheckboxGroup` and binds it to a form field.
10
+ * To make the field agnostic to the order of selected values, add `strictOrder: false` to the field's ObjectConfig */
10
11
  function BoundCheckboxGroupField(props) {
11
12
  const { field, onChange = (value) => field.set(value), label = (0, defaultLabel_1.defaultLabel)(field.key), onBlur, onFocus, ...others } = props;
12
13
  const testId = (0, utils_1.useTestIds)(props, field.key);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.132.2",
3
+ "version": "2.133.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -32,7 +32,7 @@
32
32
  "format": "prettier --loglevel warn --write \"**/*.{ts,tsx,css,md}\""
33
33
  },
34
34
  "dependencies": {
35
- "@homebound/form-state": "2.13.0",
35
+ "@homebound/form-state": "2.14.0",
36
36
  "@internationalized/number": "^3.0.3",
37
37
  "@react-aria/utils": "^3.11.3",
38
38
  "@react-hook/resize-observer": "^1.2.2",
@@ -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",