@gridkitjs/react 0.8.0 → 0.9.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.
package/dist/index.d.ts CHANGED
@@ -68,7 +68,12 @@ type CellSelectionChangeEvent<Row> = CellSelectionChangeEvent$1<Row, ReactNode>;
68
68
  interface DataGridApi<Row> {
69
69
  /** The grid's scrollable viewport element. */
70
70
  readonly element: HTMLDivElement | null;
71
- /** The grid's `<table>` element. */
71
+ /**
72
+ * The grid's row-area `<table>` element — the one holding `<tbody>`. The
73
+ * header and, when aggregates are active, footer render as their own
74
+ * sibling `<table>`s outside this one; use `element` to reach the whole
75
+ * scrollable viewport instead.
76
+ */
72
77
  readonly table: HTMLTableElement | null;
73
78
  /** Rows as currently filtered and sorted — what's rendered, ungrouped. */
74
79
  getRows(): readonly ResolvedRow<Row>[];
@@ -193,6 +198,31 @@ interface PagerConfig {
193
198
  /** Replaces the built-in pager entirely when given. `variant` is ignored. */
194
199
  template?: ((context: PagerTemplateContext) => ReactNode) | undefined;
195
200
  }
201
+ /**
202
+ * Loads more rows as the user scrolls near the bottom, in place of paging.
203
+ * Appends only — there is no equivalent of `paginated`'s reset-to-page-0 for
204
+ * a result set that shrinks out from under the current position.
205
+ */
206
+ interface InfiniteScrollConfig {
207
+ /** Whether a further `onLoadMore` could still return more rows. `false` removes the sentinel entirely, so no further scrolling can trigger a load. */
208
+ readonly hasMore: boolean;
209
+ /**
210
+ * Called at most once per genuine threshold-crossing: fires when the
211
+ * sentinel comes within `rootMargin` of the body's viewport, and not again
212
+ * until `isLoadingMore` has gone back to `false`.
213
+ */
214
+ readonly onLoadMore: () => void;
215
+ /** Whether a load triggered by `onLoadMore` is still in flight. Suppresses further calls to it until this goes back to `false`. */
216
+ readonly isLoadingMore?: boolean | undefined;
217
+ /**
218
+ * `IntersectionObserver`'s `rootMargin` — how far from the bottom of the
219
+ * scrollable body `onLoadMore` fires, ahead of the sentinel actually
220
+ * scrolling into view. Defaults to `"200px"`.
221
+ */
222
+ readonly rootMargin?: string | undefined;
223
+ /** Replaces the built-in "Loading more…" row. */
224
+ readonly loadingTemplate?: (() => ReactNode) | undefined;
225
+ }
196
226
  interface DataGridProps<Row> extends SelectionCallbacks<Row> {
197
227
  columns?: readonly ColumnDefinition<Row>[] | undefined;
198
228
  dataSource?: readonly Row[] | undefined;
@@ -330,6 +360,14 @@ interface DataGridProps<Row> extends SelectionCallbacks<Row> {
330
360
  pager?: PagerConfig | undefined;
331
361
  /** Called once when the user changes the page or the page size. */
332
362
  onPaginationChange?: ((event: PaginationChangeEvent) => void) | undefined;
363
+ /**
364
+ * Loads more rows as the user scrolls near the bottom, instead of paging.
365
+ * Mutually exclusive with `paginated` — setting both logs a dev-time
366
+ * `console.error` and only `paginated` takes effect. Recommended (not
367
+ * required) alongside `virtualized` for a dataset that grows without
368
+ * bound, so the mounted row count never grows with it either.
369
+ */
370
+ infiniteScroll?: InfiniteScrollConfig | undefined;
333
371
  /**
334
372
  * Aggregates to compute — a subtotal per group (rendered in that group's
335
373
  * header) plus a grand total over the whole filtered/grouped dataset
@@ -349,6 +387,35 @@ interface DataGridProps<Row> extends SelectionCallbacks<Row> {
349
387
  * effect when `aggregates` is empty or omitted.
350
388
  */
351
389
  groupAggregateDisplay?: GroupAggregateDisplay | undefined;
390
+ /**
391
+ * Bounds the row area's height, independently scrollable — the grid's own
392
+ * chrome (group-by bar, header, footer, pager) stays outside it and
393
+ * always visible. A number is pixels; a string is passed through as a CSS
394
+ * length (e.g. "60vh"). Omitted, the body's height stays content-driven,
395
+ * same as today.
396
+ */
397
+ height?: number | string | undefined;
398
+ /**
399
+ * Renders only the rows near the current scroll position rather than every
400
+ * row at once — for a dataset too large to mount in full. Requires
401
+ * `height` to be set; a grid without a bounded body has no viewport to
402
+ * window rows against (a dev-time console warning fires when it's
403
+ * missing). Off by default, matching every other opt-in behavior here.
404
+ */
405
+ virtualized?: boolean | undefined;
406
+ /**
407
+ * Rows rendered outside the visible range on each side, to reduce
408
+ * blank-frame flashes on fast scrolling. Only meaningful with `virtualized`
409
+ * on.
410
+ */
411
+ overscan?: number | undefined;
412
+ /**
413
+ * Assumed height for a row never yet measured — only matters for the very
414
+ * first paint and for `scrollToRow`'s initial jump before it corrects
415
+ * itself against that row's real, measured height. Only meaningful with
416
+ * `virtualized` on.
417
+ */
418
+ estimatedRowHeight?: number | undefined;
352
419
  /**
353
420
  * The grid's accessible name, announced when it takes focus. A grid without
354
421
  * one is read only as "grid", which says nothing about which grid.
@@ -362,7 +429,7 @@ interface DataGridProps<Row> extends SelectionCallbacks<Row> {
362
429
  /** Imperative handle for reading live grid state and triggering actions. */
363
430
  ref?: Ref<DataGridApi<Row>> | undefined;
364
431
  }
365
- declare function DataGridComponent<Row>({ dataSource, columns, getRowId, borders, hoverable, selectable, defaultRowSelection, defaultColumnSelection, defaultCellSelection, resizableColumns, reorderableColumns, resizeMode, defaultColumnSizing, defaultColumnOrder, columnSizeDefaults, onColumnResize, onColumnOrderChange, sortableColumns, defaultColumnSort, onColumnSortChange, groupableColumns, groupToggleIconColumns, groupByDraggableColumns, groupByBarVisibility, defaultGroupBy, onGroupByChange, defaultGroupExpansion, onGroupExpansionChange, defaultFilter, paginated, defaultPagination, pager, onPaginationChange, aggregates, groupAggregateDisplay, label, labelledBy, ref, ...callbacks }: DataGridProps<Row>): react.JSX.Element;
432
+ declare function DataGridComponent<Row>({ dataSource, columns, getRowId, borders, hoverable, selectable, defaultRowSelection, defaultColumnSelection, defaultCellSelection, resizableColumns, reorderableColumns, resizeMode, defaultColumnSizing, defaultColumnOrder, columnSizeDefaults, onColumnResize, onColumnOrderChange, sortableColumns, defaultColumnSort, onColumnSortChange, groupableColumns, groupToggleIconColumns, groupByDraggableColumns, groupByBarVisibility, defaultGroupBy, onGroupByChange, defaultGroupExpansion, onGroupExpansionChange, defaultFilter, paginated, defaultPagination, pager, onPaginationChange, infiniteScroll, aggregates, groupAggregateDisplay, height, virtualized, overscan, estimatedRowHeight, label, labelledBy, ref, ...callbacks }: DataGridProps<Row>): react.JSX.Element;
366
433
 
367
434
  interface PaginationStateApi {
368
435
  pagination: PaginationState;
@@ -470,4 +537,4 @@ declare function useColumnSizingState<Row>(gridRef: RefObject<DataGridApi<Row> |
470
537
  */
471
538
  declare function useColumnOrderState<Row>(gridRef: RefObject<DataGridApi<Row> | null>): ColumnOrderState;
472
539
 
473
- export { type Borders, type CellSelectEvent, type CellSelectionChangeEvent, type ColumnDefinition, type ColumnSelectEvent, type ColumnSelectionChangeEvent, type ColumnsSelectEvent, type DataGridApi, DataGridComponent, type DataGridProps, type GroupByBarVisibility, type GroupByStateApi, type HoverableConfig, type PagerConfig, type PagerTemplateContext, type PaginationStateApi, type ResizeMode, type ResolvedColumn, type SelectedCell, type SelectedColumn, type SelectionStateApi, useAggregateState, useColumnOrderState, useColumnSizingState, useColumnSortState, useGroupByState, usePaginationState, useSelectionState };
540
+ export { type Borders, type CellSelectEvent, type CellSelectionChangeEvent, type ColumnDefinition, type ColumnSelectEvent, type ColumnSelectionChangeEvent, type ColumnsSelectEvent, type DataGridApi, DataGridComponent, type DataGridProps, type GroupByBarVisibility, type GroupByStateApi, type HoverableConfig, type InfiniteScrollConfig, type PagerConfig, type PagerTemplateContext, type PaginationStateApi, type ResizeMode, type ResolvedColumn, type SelectedCell, type SelectedColumn, type SelectionStateApi, useAggregateState, useColumnOrderState, useColumnSizingState, useColumnSortState, useGroupByState, usePaginationState, useSelectionState };