@homebound/beam 2.371.0 → 2.371.1

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.
@@ -1,6 +1,6 @@
1
1
  import { MutableRefObject } from "react";
2
2
  import { VirtuosoHandle } from "react-virtuoso";
3
- import { GridRowLookup, MaybeFn } from "../index";
3
+ import { GridRowLookup, GridTableScrollOptions, MaybeFn } from "../index";
4
4
  import { GridDataRow } from "./components/Row";
5
5
  import { DiscriminateUnion, Kinded } from "./types";
6
6
  import { TableState } from "./utils/TableState";
@@ -22,8 +22,11 @@ import { TableState } from "./utils/TableState";
22
22
  export declare function useGridTableApi<R extends Kinded>(): GridTableApi<R>;
23
23
  /** Provides an imperative API for an application page to interact with the table. */
24
24
  export type GridTableApi<R extends Kinded> = {
25
- /** Scrolls row `index` into view; only supported with `as=virtual` and after a `useEffect`. */
26
- scrollToIndex(index: number): void;
25
+ /** Scrolls row `index` into view; only supported with `as=virtual` and after a `useEffect`.
26
+ *
27
+ * Defaults "smooth" behavior; Use {index, behavior: "auto"} for instant scroll in cases where grid table has many, many records and the scroll effect is undesirable.
28
+ * */
29
+ scrollToIndex(index: GridTableScrollOptions): void;
27
30
  /** Returns the currently-visible rows. */
28
31
  getVisibleRows(): GridDataRow<R>[];
29
32
  /** Returns the currently-visible rows of the given `kind`. */
@@ -78,7 +81,7 @@ export declare class GridTableApiImpl<R extends Kinded> implements GridTableApi<
78
81
  constructor();
79
82
  /** Called once by the GridTable when it takes ownership of this api instance. */
80
83
  init(persistCollapse: string | undefined, virtuosoRef: MutableRefObject<VirtuosoHandle | null>): void;
81
- scrollToIndex(index: number): void;
84
+ scrollToIndex(index: GridTableScrollOptions): void;
82
85
  getSelectedRowIds(kind?: string): string[];
83
86
  private getSelectedRowIdsImpl;
84
87
  getSelectedRows(kind?: string): any;
@@ -50,7 +50,8 @@ class GridTableApiImpl {
50
50
  this.lookup = (0, index_1.createRowLookup)(this, virtuosoRef);
51
51
  }
52
52
  scrollToIndex(index) {
53
- this.virtuosoRef.current && this.virtuosoRef.current.scrollToIndex(index);
53
+ this.virtuosoRef.current &&
54
+ this.virtuosoRef.current.scrollToIndex(typeof index === "number" ? { index, behavior: "smooth" } : index);
54
55
  }
55
56
  getSelectedRowIds(kind) {
56
57
  return this.getSelectedRowIdsImpl(kind !== null && kind !== void 0 ? kind : undefined);
@@ -11,6 +11,15 @@ export type RenderAs = "div" | "table" | "virtual";
11
11
  export type Direction = "ASC" | "DESC";
12
12
  export type MaybeFn<T> = T | (() => T);
13
13
  export type GridCellAlignment = "left" | "right" | "center";
14
+ export type GridTableScrollOptions = number | {
15
+ /** The index of the row to scroll to */
16
+ index: number;
17
+ behavior?: "auto" | "smooth";
18
+ /**
19
+ * How to position the row in the viewport
20
+ */
21
+ align?: "start" | "center" | "end";
22
+ };
14
23
  /**
15
24
  * Given an ADT of type T, performs a look up and returns the type of kind K.
16
25
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.371.0",
3
+ "version": "2.371.1",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",