@homebound/beam 2.231.0 → 2.232.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.
@@ -4,6 +4,7 @@ export type NumberRangeFilterProps<DV extends NumberRangeFilterValue> = {
4
4
  label: string;
5
5
  numberFieldType?: NumberFieldType;
6
6
  defaultValue?: DV;
7
+ numberFormatOptions?: Intl.NumberFormatOptions;
7
8
  };
8
9
  export type NumberRangeFilterValue = {
9
10
  min: number;
@@ -15,21 +15,21 @@ exports.numberRangeFilter = numberRangeFilter;
15
15
  class NumberRangeFilter extends BaseFilter_1.BaseFilter {
16
16
  render(value, setValue, tid, inModal, vertical) {
17
17
  var _a, _b;
18
- const { label, numberFieldType } = this.props;
18
+ const { label, numberFieldType, numberFormatOptions } = this.props;
19
19
  const min = (_a = value === null || value === void 0 ? void 0 : value.min) !== null && _a !== void 0 ? _a : undefined;
20
20
  const max = (_b = value === null || value === void 0 ? void 0 : value.max) !== null && _b !== void 0 ? _b : undefined;
21
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [vertical && ((0, jsx_runtime_1.jsxs)("div", { ...tid, children: [(0, jsx_runtime_1.jsx)(Label_1.Label, { label: label }), (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.pb1.$, children: (0, jsx_runtime_1.jsx)(NumberField_1.NumberField, { labelStyle: "inline", clearable: true, label: "Min", value: min, type: numberFieldType, onChange: (minVal) => {
21
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [vertical && ((0, jsx_runtime_1.jsxs)("div", { ...tid, children: [(0, jsx_runtime_1.jsx)(Label_1.Label, { label: label }), (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.pb1.$, children: (0, jsx_runtime_1.jsx)(NumberField_1.NumberField, { labelStyle: "inline", clearable: true, label: "Min", value: min, type: numberFieldType, numberFormatOptions: numberFormatOptions, onChange: (minVal) => {
22
22
  const maxValue = max ? { max } : {};
23
23
  setValue(minVal || max ? { min: minVal, ...maxValue } : undefined);
24
- }, ...tid[`${(0, defaultTestId_1.defaultTestId)(label)}_min_vertical`] }) }), (0, jsx_runtime_1.jsx)(NumberField_1.NumberField, { labelStyle: "inline", clearable: true, label: "Max", value: max, type: numberFieldType, onChange: (maxVal) => {
24
+ }, ...tid[`${(0, defaultTestId_1.defaultTestId)(label)}_min_vertical`] }) }), (0, jsx_runtime_1.jsx)(NumberField_1.NumberField, { labelStyle: "inline", clearable: true, label: "Max", value: max, type: numberFieldType, numberFormatOptions: numberFormatOptions, onChange: (maxVal) => {
25
25
  const minValue = min ? { min } : {};
26
26
  setValue(maxVal || min ? { max: maxVal, ...minValue } : undefined);
27
27
  }, ...tid[`${(0, defaultTestId_1.defaultTestId)(label)}_max_vertical`] })] })), !vertical && ((0, jsx_runtime_1.jsxs)(CompoundField_1.CompoundField, { ...tid, children: [(0, jsx_runtime_1.jsx)(NumberField_1.NumberField, { compact: true, sizeToContent: !inModal, labelStyle: "inline", clearable: true,
28
28
  // When in horizontal view, we combine the filter label with the min / max labels as all filter labels are displayed inline
29
- label: !inModal ? `${label} Min` : "Min", value: min, type: numberFieldType, onChange: (minVal) => {
29
+ label: !inModal ? `${label} Min` : "Min", value: min, type: numberFieldType, numberFormatOptions: numberFormatOptions, onChange: (minVal) => {
30
30
  const maxValue = max ? { max } : {};
31
31
  setValue(minVal || max ? { min: minVal, ...maxValue } : undefined);
32
- }, ...tid[`${(0, defaultTestId_1.defaultTestId)(label)}_min`] }), (0, jsx_runtime_1.jsx)(NumberField_1.NumberField, { compact: true, sizeToContent: !inModal, labelStyle: "inline", clearable: true, label: !inModal ? `${label} Max` : "Max", value: max, type: numberFieldType, onChange: (maxVal) => {
32
+ }, ...tid[`${(0, defaultTestId_1.defaultTestId)(label)}_min`] }), (0, jsx_runtime_1.jsx)(NumberField_1.NumberField, { compact: true, sizeToContent: !inModal, labelStyle: "inline", clearable: true, label: !inModal ? `${label} Max` : "Max", value: max, type: numberFieldType, numberFormatOptions: numberFormatOptions, onChange: (maxVal) => {
33
33
  const minValue = min ? { min } : {};
34
34
  setValue(maxVal || min ? { max: maxVal, ...minValue } : undefined);
35
35
  }, ...tid[`${(0, defaultTestId_1.defaultTestId)(label)}_max`] })] }))] }));
@@ -65,5 +65,7 @@ export type GridDataRow<R extends Kinded> = {
65
65
  initSelected?: boolean;
66
66
  /** Whether row can be selected */
67
67
  selectable?: false;
68
+ /** Whether this row should infer its selected state based on its children's selected state */
69
+ inferSelectedState?: false;
68
70
  } & IfAny<R, {}, DiscriminateUnion<R, "kind", R["kind"]>>;
69
71
  export {};
@@ -258,7 +258,8 @@ class TableState {
258
258
  (0, visitor_1.visit)([curr.row], (row) => this.matchedRows.has(row.id) && map.set(row.id, selected ? "checked" : "unchecked"));
259
259
  // Now walk up the parents and see if they are now-all-checked/now-all-unchecked/some-of-each
260
260
  for (const parent of [...curr.parents].reverse()) {
261
- if (parent.children) {
261
+ // Only derive selected state of the parent row if `inferSelectedState` is not `false`
262
+ if (parent.children && parent.inferSelectedState !== false) {
262
263
  map.set(parent.id, deriveParentSelected(this.getMatchedChildrenStates(parent.children, map)));
263
264
  }
264
265
  }
@@ -327,14 +328,16 @@ class TableState {
327
328
  }
328
329
  }
329
330
  getMatchedChildrenStates(children, map) {
330
- return children
331
+ const respectedChildren = children.flatMap(getChildrenForDerivingSelectState);
332
+ return respectedChildren
331
333
  .filter((row) => row.id !== "header" && this.matchedRows.has(row.id))
332
334
  .map((row) => map.get(row.id) || this.getSelected(row.id));
333
335
  }
334
336
  // Recursively traverse through rows to determine selected state of parent rows based on children
335
337
  setNestedSelectedStates(row, map) {
336
338
  if (this.matchedRows.has(row.id)) {
337
- if (!row.children) {
339
+ // do not derive selected state if there are no children, or if `inferSelectedState` is set to false
340
+ if (!row.children || row.inferSelectedState === false) {
338
341
  return [this.getSelected(row.id)];
339
342
  }
340
343
  const childrenSelectedStates = row.children.flatMap((rc) => this.setNestedSelectedStates(rc, map));
@@ -346,6 +349,13 @@ class TableState {
346
349
  }
347
350
  }
348
351
  exports.TableState = TableState;
352
+ /** Returns the child rows needed for deriving the selected state of a parent/group row */
353
+ function getChildrenForDerivingSelectState(row) {
354
+ if (row.children && row.inferSelectedState === false) {
355
+ return [row, ...row.children.flatMap(getChildrenForDerivingSelectState)];
356
+ }
357
+ return [row];
358
+ }
349
359
  /** Provides a context for rows to access their table's `TableState`. */
350
360
  exports.TableStateContext = react_1.default.createContext({
351
361
  get tableState() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.231.0",
3
+ "version": "2.232.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",