@homebound/beam 2.313.1 → 2.313.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.
@@ -68,8 +68,13 @@ export declare class GridTableApiImpl<R extends Kinded> implements GridTableApi<
68
68
  init(persistCollapse: string | undefined, virtuosoRef: MutableRefObject<VirtuosoHandle | null>): void;
69
69
  scrollToIndex(index: number): void;
70
70
  getSelectedRowIds(kind?: string): string[];
71
+ private getSelectedRowIdsImpl;
71
72
  getSelectedRows(kind?: string): any;
73
+ private getSelectedRowsImpl;
72
74
  getVisibleRows(kind?: string): any;
75
+ private getVisibleRowsImpl;
76
+ getVisibleRowIds(kind?: string): any;
77
+ private getVisibleRowIdsImpl;
73
78
  clearSelections(id?: string): void;
74
79
  setActiveRowId(id: string | undefined): void;
75
80
  setActiveCellId(id: string | undefined): void;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GridTableApiImpl = exports.useGridTableApi = void 0;
4
+ const mobx_1 = require("mobx");
5
+ const mobx_utils_1 = require("mobx-utils");
4
6
  const react_1 = require("react");
5
7
  const index_1 = require("../index");
6
8
  const TableState_1 = require("./utils/TableState");
@@ -31,6 +33,12 @@ class GridTableApiImpl {
31
33
  this.virtuosoRef = { current: null };
32
34
  // This instance gets spread into each row's GridRowApi, so bind the methods up-front
33
35
  bindMethods(this);
36
+ // Memoize these so that if the user is creating new `data` instances on every render, they
37
+ // can use `getSelectedRowIds` to observer a stable list of `[pi:1, pi:2]`, etc.
38
+ this.getVisibleRowsImpl = (0, mobx_utils_1.computedFn)(this.getVisibleRowsImpl, { equals: mobx_1.comparer.shallow });
39
+ this.getVisibleRowIdsImpl = (0, mobx_utils_1.computedFn)(this.getVisibleRowIdsImpl, { equals: mobx_1.comparer.shallow });
40
+ this.getSelectedRowsImpl = (0, mobx_utils_1.computedFn)(this.getSelectedRowsImpl, { equals: mobx_1.comparer.shallow });
41
+ this.getSelectedRowIdsImpl = (0, mobx_utils_1.computedFn)(this.getSelectedRowIdsImpl, { equals: mobx_1.comparer.shallow });
34
42
  }
35
43
  /** Called once by the GridTable when it takes ownership of this api instance. */
36
44
  init(persistCollapse, virtuosoRef) {
@@ -44,16 +52,34 @@ class GridTableApiImpl {
44
52
  this.virtuosoRef.current && this.virtuosoRef.current.scrollToIndex(index);
45
53
  }
46
54
  getSelectedRowIds(kind) {
47
- return this.getSelectedRows(kind).map((row) => row.id);
55
+ return this.getSelectedRowIdsImpl(kind !== null && kind !== void 0 ? kind : undefined);
56
+ }
57
+ // impl with required param for computedFn
58
+ getSelectedRowIdsImpl(kind) {
59
+ return this.tableState.selectedRows.filter((rs) => !kind || rs.kind === kind).map((rs) => rs.row.id);
48
60
  }
49
- // The `any` is not great, but getting the overload to handle the optional kind is annoying
50
61
  getSelectedRows(kind) {
62
+ return this.getSelectedRowsImpl(kind !== null && kind !== void 0 ? kind : undefined);
63
+ }
64
+ // impl with required param for computedFn
65
+ getSelectedRowsImpl(kind) {
51
66
  return this.tableState.selectedRows.filter((rs) => !kind || rs.kind === kind).map((rs) => rs.row);
52
67
  }
53
68
  // The `any` is not great, but getting the overload to handle the optional kind is annoying
54
69
  getVisibleRows(kind) {
70
+ return this.getVisibleRowsImpl(kind !== null && kind !== void 0 ? kind : undefined);
71
+ }
72
+ // impl with required param for computedFn
73
+ getVisibleRowsImpl(kind) {
55
74
  return this.tableState.visibleRows.filter((row) => !kind || row.kind === kind).map((rs) => rs.row);
56
75
  }
76
+ getVisibleRowIds(kind) {
77
+ return this.getVisibleRowIdsImpl(kind !== null && kind !== void 0 ? kind : undefined);
78
+ }
79
+ // impl with required param for computedFn
80
+ getVisibleRowIdsImpl(kind) {
81
+ return this.tableState.visibleRows.filter((row) => !kind || row.kind === kind).map((rs) => rs.row.id);
82
+ }
57
83
  clearSelections(id) {
58
84
  this.tableState.selectRow("header", false);
59
85
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.313.1",
3
+ "version": "2.313.3",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -43,6 +43,7 @@
43
43
  "fast-deep-equal": "^3.1.3",
44
44
  "framer-motion": "^9.0.4",
45
45
  "memoize-one": "^5.2.1",
46
+ "mobx-utils": "^6.0.8",
46
47
  "react-aria": "^3.26.0",
47
48
  "react-day-picker": "8.0.7",
48
49
  "react-popper": "^2.3.0",