@homebound/beam 2.116.1 → 2.117.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.
@@ -188,8 +188,10 @@ export declare type GridTableApi<R extends Kinded> = {
188
188
  scrollToIndex: (index: number) => void;
189
189
  /** Returns the ids of currently-selected rows. */
190
190
  getSelectedRowIds(): string[];
191
+ getSelectedRowIds<K extends R["kind"]>(kind: K): string[];
191
192
  /** Returns the currently-selected rows. */
192
193
  getSelectedRows(): GridDataRow<R>[];
194
+ getSelectedRows<K extends R["kind"]>(kind: K): GridDataRow<DiscriminateUnion<R, "kind", K>>[];
193
195
  /** Sets the internal state of 'activeRowId' */
194
196
  setActiveRowId: (id: string | undefined) => void;
195
197
  };
@@ -95,12 +95,20 @@ function GridTable(props) {
95
95
  const tableRef = (0, react_1.useRef)(null);
96
96
  const api = (0, react_1.useRef)({
97
97
  scrollToIndex: (index) => virtuosoRef.current && virtuosoRef.current.scrollToIndex(index),
98
- getSelectedRowIds: () => rowState.selectedIds,
99
- getSelectedRows() {
98
+ getSelectedRowIds(kind) {
99
+ if (kind === undefined) {
100
+ return rowState.selectedIds;
101
+ }
102
+ else {
103
+ return this.getSelectedRows(kind).map((row) => row.id);
104
+ }
105
+ },
106
+ // The any is not great, but getting the overload to handle the optional kind is annoying
107
+ getSelectedRows(kind) {
100
108
  const ids = rowState.selectedIds;
101
109
  const selected = [];
102
110
  (0, visitor_1.visit)(rows, (row) => {
103
- if (ids.includes(row.id)) {
111
+ if (ids.includes(row.id) && (!kind || row.kind === kind)) {
104
112
  selected.push(row);
105
113
  }
106
114
  });
@@ -113,7 +121,7 @@ function GridTable(props) {
113
121
  }
114
122
  (0, react_1.useEffect)(() => {
115
123
  rowState.activeRowId = activeRowId;
116
- }, [activeRowId]);
124
+ }, [rowState, activeRowId]);
117
125
  // We track render count at the table level, which seems odd (we should be able to track this
118
126
  // internally within each GridRow using a useRef), but we have suspicions that react-virtuoso
119
127
  // (or us) is resetting component state more than necessary, so we track render counts from
@@ -209,6 +217,7 @@ function GridTable(props) {
209
217
  observeRows,
210
218
  columnSizes,
211
219
  collapsedIds,
220
+ getCount,
212
221
  ]);
213
222
  let tooManyClientSideRows = false;
214
223
  if (filterMaxRows && filteredRows.length > filterMaxRows) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.116.1",
3
+ "version": "2.117.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",