@gridkitjs/react 0.0.0-dev-20261106222533

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Blagoja Blazhevski
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # @gridkitjs/react
2
+
3
+ React data-grid components built on
4
+ [`@gridkitjs/core`](https://www.npmjs.com/package/@gridkitjs/core) for the
5
+ grid's logic and [`@gridkitjs/dom`](https://www.npmjs.com/package/@gridkitjs/dom)
6
+ for its browser behaviours. Both are installed with it.
7
+
8
+ > **Early development.** The API is still moving and may break between minor
9
+ > versions.
10
+
11
+ ```bash
12
+ pnpm add @gridkitjs/react
13
+ ```
14
+
15
+ ```tsx
16
+ import { defineColumnsFromRows } from "@gridkitjs/core";
17
+ import { DataGrid, type ColumnDefinition } from "@gridkitjs/react";
18
+
19
+ const rows = [
20
+ { Id: 1, Application: { Id: 9, Name: "Portal" }, Cost: 1250.5 },
21
+ { Id: 2, Application: { Id: 4, Name: "Admin" }, Cost: 87.25 },
22
+ ];
23
+
24
+ type Row = (typeof rows)[number];
25
+
26
+ const columns: readonly ColumnDefinition<Row>[] = [
27
+ ...defineColumnsFromRows(rows),
28
+ {
29
+ field: "Cost",
30
+ id: "Cost.currency",
31
+ type: "currency",
32
+ header: "Cost",
33
+ },
34
+ ];
35
+
36
+ <DataGrid
37
+ dataSource={rows}
38
+ columns={columns}
39
+ getRowId={(row) => String(row.Id)}
40
+ label="Application costs"
41
+ resizableColumns
42
+ resizeMode="fit"
43
+ selectable={{ rows: "multiple", cells: "single" }}
44
+ onRowSelectionChange={({ selected }) => persist(selected)}
45
+ />;
46
+ ```
47
+
48
+ Columns can be inferred from the data or declared outright — a column's `type`
49
+ drives its default alignment. With `resizableColumns`, a column edge can be
50
+ dragged to resize or double-clicked to fit its content. `resizeMode="fit"`
51
+ keeps columns filling the grid; `"fixed"` lets each keep its own width.
52
+
53
+ `selectable` says which parts of the grid the user may select and how many of
54
+ each — `false`, `"single"` or `"multiple"` per member, off by default. Click
55
+ replaces, Ctrl-click toggles, Shift-click takes a range, and thirteen callbacks
56
+ report it with the resolved row, column or cell value rather than a bare id.
57
+ Give `getRowId` alongside it for data that sorts, filters or pages.
58
+
59
+ The grid is an ARIA grid: one tab stop, with the arrow keys moving cell to cell
60
+ within it, `Ctrl+Arrow` reordering a column and `Alt+Arrow` resizing one. Name
61
+ it with `label`, or a screen reader announces only "grid".
62
+
63
+ `contextMenu` gives headers, cells and group rows a menu of their own — sort,
64
+ group, autofit, hide and choose columns, select and clear, expand and collapse
65
+ — and `toolbar` puts a toolbar above the grid, with a search box, "Clear
66
+ filters" and "Choose columns" by default. Both list built-in commands by id,
67
+ and `commands` adds your own beside them; the column chooser shows and hides
68
+ columns from either. `messages` translates every string the grid shows or
69
+ announces, and `locale` formats dates and numbers.
70
+
71
+ Requires React 19.
72
+
73
+ Full documentation: [github.com/gridkitjs/gridkitjs](https://github.com/gridkitjs/gridkitjs#readme)
74
+
75
+ ## License
76
+
77
+ MIT © Blagoja Blazhevski
@@ -0,0 +1,495 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, Ref, RefObject } from 'react';
3
+ import { ExportWriter, GridExportOptions, PrintOptions, CellSelectEvent as CellSelectEvent$1, CellSelectionChangeEvent as CellSelectionChangeEvent$1, ColumnDefinition as ColumnDefinition$1, ColumnSelectEvent as ColumnSelectEvent$1, ColumnSelectionChangeEvent as ColumnSelectionChangeEvent$1, ColumnsSelectEvent as ColumnsSelectEvent$1, DataColumn as DataColumn$1, GridOptions, PaginationState, SelectionCallbacks as SelectionCallbacks$1, ResolvedRow, DisplayRow, ResolvedColumn as ResolvedColumn$1, ColumnSizingState, ColumnOrderState, ColumnVisibilityState, ColumnSortState, FilterState, GroupByState, GroupExpansionState, AggregateResults, SelectionState, CellSelectionState, GridState, SerializedGridState, GridContextMenuTarget, GridCommandTarget, SelectedCell as SelectedCell$1, SelectedColumn as SelectedColumn$1 } from '@gridkitjs/core';
4
+ export { Borders, CellSelectionMode, CellSelectionState, CellTemplateContext, ColumnResizeEvent, ColumnSizeDefaults, ColumnSizingState, ColumnVisibilityEvent, ColumnVisibilityState, ContextMenuOpenChangeEvent, ExportFile, ExportOptions, ExportWriter, FilterChangeEvent, FilterEntry, FilterState, GridCommand, GridCommandEvent, GridCommandTarget, GridContextMenuOptions, GridContextMenuRequest, GridContextMenuTarget, GridExportOptions, GridMessages, GridOptions, GridState, GridToolbarOptions, GroupByBarVisibility, HoverableConfig, MenuEntry, PrintOptions, ResizeMode, ResolvedRow, RowPointerEvent, RowProps, RowSelectEvent, RowSelectionChangeEvent, RowsSelectEvent, SelectableConfig, SelectedCellRef, SelectionMode, SelectionState, SerializedGridState, ToolbarEntry, excelFilter, serializeGridState } from '@gridkitjs/core';
5
+
6
+ /** What `DataGridApi` carries for exporting. */
7
+ interface GridExportApi {
8
+ /**
9
+ * The grid's view exported as `format` — `"csv"`, `"json"`, a format
10
+ * registered through `exportWriters`, or a writer passed as it is — and
11
+ * handed back as a `Blob`, under the grid's `export` option with
12
+ * `options` over it, field by field. Nothing is downloaded:
13
+ * `runCommand("export.csv")` downloads.
14
+ *
15
+ * Rejects for a format no writer is registered for, and when the writer
16
+ * fails.
17
+ */
18
+ exportData(format: string | ExportWriter, options?: GridExportOptions): Promise<Blob>;
19
+ }
20
+
21
+ /** What `DataGridApi` carries for the grid's panels. */
22
+ interface GridPanelApi {
23
+ /**
24
+ * Opens the column chooser at the grid's top-end corner, in place of any
25
+ * panel open; it gives focus back to what had it when it closes.
26
+ */
27
+ openColumnChooser(): void;
28
+ /**
29
+ * Opens the filter menu of the column `columnId` below its header, in
30
+ * place of any panel open, and says whether it opened: not for a column
31
+ * with no filter menu, nor one not shown. It gives focus back to the
32
+ * header when it closes.
33
+ */
34
+ openFilterMenu(columnId: string): boolean;
35
+ /** Closes the filter menu, if one is open, leaving any other panel open. */
36
+ closeFilterMenu(): void;
37
+ }
38
+
39
+ /** What `DataGridApi` carries for printing. */
40
+ interface GridPrintApi {
41
+ /**
42
+ * Prints the grid's view through the browser's print dialog — every row
43
+ * the filter leaves, across pages and collapsed groups, not only those
44
+ * drawn — under the grid's `print` option with `options` over it, field
45
+ * by field. Resolves once the dialog has closed, or at once while another
46
+ * print is open.
47
+ */
48
+ print(options?: PrintOptions): Promise<void>;
49
+ }
50
+
51
+ /**
52
+ * A column whose header and cells may render arbitrary React content.
53
+ * @gridkitjs/core stays framework-agnostic and so leaves that output type open;
54
+ * this is the binding React consumers want, and the one they should import.
55
+ */
56
+ type ColumnDefinition<Row> = ColumnDefinition$1<Row, ReactNode>;
57
+ /** A column paired with the width it renders at. */
58
+ type ResolvedColumn<Row> = ResolvedColumn$1<Row, ReactNode>;
59
+ /** A column paired with its id, hidden or not — what `getDataColumns()` lists. */
60
+ type DataColumn<Row> = DataColumn$1<Row, ReactNode>;
61
+ /**
62
+ * The selection payloads, bound to React's node type for the same reason
63
+ * `ColumnDefinition` is: they carry a resolved column, whose label is whatever
64
+ * a `headerTemplate` returned.
65
+ *
66
+ * The row payloads name no node type at all and so are re-exported from
67
+ * `@gridkitjs/core` as they are.
68
+ */
69
+ type SelectedColumn<Row> = SelectedColumn$1<Row, ReactNode>;
70
+ type SelectedCell<Row> = SelectedCell$1<Row, ReactNode>;
71
+ type ColumnSelectEvent<Row> = ColumnSelectEvent$1<Row, ReactNode>;
72
+ type ColumnsSelectEvent<Row> = ColumnsSelectEvent$1<Row, ReactNode>;
73
+ type ColumnSelectionChangeEvent<Row> = ColumnSelectionChangeEvent$1<Row, ReactNode>;
74
+ type CellSelectEvent<Row> = CellSelectEvent$1<Row, ReactNode>;
75
+ type CellSelectionChangeEvent<Row> = CellSelectionChangeEvent$1<Row, ReactNode>;
76
+ type SelectionCallbacks<Row> = SelectionCallbacks$1<Row, ReactNode>;
77
+ /**
78
+ * Imperative handle for a mounted `DataGrid`, reached via its `ref` prop:
79
+ * the grid's DOM nodes, getters for its live state, the actions every grid
80
+ * ref carries (focus, select all, scroll-to), and a setter for every slice of
81
+ * state, for a toolbar, a saved layout or a test to drive it from outside.
82
+ *
83
+ * Every getter reads the grid's state at call time, so a read straight after
84
+ * an action sees its result. Every setter changes the grid as the user's own
85
+ * interaction would: it fires the slice's `on*Change` callback, and, for a
86
+ * slice held through a controlled prop, only asks. `subscribe` is the
87
+ * notify channel for state that changes; see
88
+ * `packages/react/src/DataGrid/hooks/` for the public hooks built on it.
89
+ */
90
+ interface DataGridApi<Row> extends GridExportApi, GridPrintApi, GridPanelApi {
91
+ /** The grid's scrollable viewport element. */
92
+ readonly element: HTMLDivElement | null;
93
+ /**
94
+ * The grid's row-area `<table>` element — the one holding `<tbody>`. The
95
+ * header and, when aggregates are active, footer render as their own
96
+ * sibling `<table>`s outside this one; use `element` to reach the whole
97
+ * scrollable viewport instead.
98
+ */
99
+ readonly table: HTMLTableElement | null;
100
+ /** Rows as currently filtered and sorted — what's rendered, ungrouped. */
101
+ getRows(): readonly ResolvedRow<Row>[];
102
+ /**
103
+ * `getRows()` regrouped into the active `groupBy` — group headers
104
+ * interleaved with data rows, in render order. Identical to `getRows()`
105
+ * when `groupBy` is empty.
106
+ */
107
+ getDisplayRows(): readonly DisplayRow<Row>[];
108
+ /**
109
+ * The current page of `getDisplayRows()` — exactly the rows the body
110
+ * renders. All of `getDisplayRows()` when `paginated` is off.
111
+ */
112
+ getPageRows(): readonly DisplayRow<Row>[];
113
+ /** Columns as currently sized and ordered — what's rendered, so hidden columns are left out. */
114
+ getColumns(): readonly ResolvedColumn<Row>[];
115
+ /** Every column in its current order, hidden ones included — what sorting, filtering and grouping read. */
116
+ getDataColumns(): readonly DataColumn<Row>[];
117
+ getColumnSizing(): ColumnSizingState;
118
+ getColumnOrder(): ColumnOrderState;
119
+ /** Columns shown or hidden since the grid mounted. A column absent from it follows its definition's `hidden`. */
120
+ getColumnVisibility(): ColumnVisibilityState;
121
+ getColumnSort(): ColumnSortState;
122
+ /** The filter the rows are shown through — every entry, ANDed together. */
123
+ getFilter(): FilterState<Row>;
124
+ getGroupBy(): GroupByState;
125
+ getGroupExpansion(): GroupExpansionState;
126
+ /** The active page and page size. Meaningful even when `paginated` is off — it stays at page 0 over the grid's whole (single) page. */
127
+ getPagination(): PaginationState;
128
+ /** How many pages the current `pagination.pageSize` splits the grid's rows into — `1` whenever `paginated` is off. */
129
+ getPageCount(): number;
130
+ /**
131
+ * The grand-total aggregate results — every active aggregate computed over
132
+ * the whole filtered/sorted dataset, ungrouped and unpaginated. A specific
133
+ * group's own results are read off `getDisplayRows()` instead, on that
134
+ * group header's `aggregates` field.
135
+ */
136
+ getAggregates(): AggregateResults;
137
+ getRowSelection(): SelectionState;
138
+ /**
139
+ * The selected rows themselves, in the order they were selected — among
140
+ * every row the filter lets through, on any page or in any group, so a row
141
+ * filtered out while selected is left out until it is back.
142
+ */
143
+ getSelectedRows(): readonly ResolvedRow<Row>[];
144
+ getColumnSelection(): SelectionState;
145
+ getCellSelection(): CellSelectionState;
146
+ /** The cell currently holding the grid's single tab stop. */
147
+ getFocusedCell(): {
148
+ rowIndex: number;
149
+ columnIndex: number;
150
+ };
151
+ /**
152
+ * Every slice of state as the grid applies it, in one object — what
153
+ * `restoreState` takes back. Pass it through `serializeGridState` before
154
+ * saving it as JSON.
155
+ */
156
+ getState(): GridState<Row>;
157
+ /**
158
+ * Puts back state saved earlier, whole or in part — from `getState()`, or
159
+ * from `serializeGridState` and back through JSON. Each slice given is set
160
+ * as its setter would set it, firing its callback when it changes; the
161
+ * grid re-renders once.
162
+ */
163
+ restoreState(saved: Partial<GridState<Row>> | Partial<SerializedGridState<Row>>): void;
164
+ focusCell(rowIndex: number, columnIndex: number): void;
165
+ clearSelection(): void;
166
+ selectAllRows(): void;
167
+ /**
168
+ * Selects rows by id, as far as `selectable.rows` allows: `"replace"` (the
169
+ * default) selects exactly these — only the last of them under
170
+ * `"single"` — and `"toggle"` flips each one. Fires the row selection
171
+ * callbacks once for the whole call, and none when nothing changed.
172
+ */
173
+ selectRows(rowIds: readonly string[], intent?: "replace" | "toggle"): void;
174
+ /** Expands every group at once, as the `group.expandAll` command does. */
175
+ expandAllGroups(): void;
176
+ /** Collapses every group currently shown at once — see `collapseAllGroups` in `@gridkitjs/core` for what "currently shown" means for a group already nested under a collapsed one. */
177
+ collapseAllGroups(): void;
178
+ /** Moves to the given page, clamped into range. */
179
+ goToPage(pageIndex: number): void;
180
+ /** Moves to the next page. A no-op on the last page. */
181
+ nextPage(): void;
182
+ /** Moves to the previous page. A no-op on the first page. */
183
+ previousPage(): void;
184
+ /** Changes the page size, resetting to the first page. */
185
+ setPageSize(pageSize: number): void;
186
+ /**
187
+ * Shows the columns with the given ids, each in the place it held when
188
+ * hidden. Reports one `onColumnVisibilityChange` for the whole call, and
189
+ * none if every column was already showing.
190
+ */
191
+ showColumns(columnIds: readonly string[]): void;
192
+ /**
193
+ * Hides the columns with the given ids. A hidden column still sorts,
194
+ * filters and groups, and keeps its place in the column order.
195
+ */
196
+ hideColumns(columnIds: readonly string[]): void;
197
+ /**
198
+ * Replaces the filter, the way a filter UI would, and sends an uncontrolled
199
+ * grid back to its first page. Reports one `onFilterChange`, and none when
200
+ * `filter` is equal to the current one. With a controlled `filter` prop it
201
+ * only asks, as any change does.
202
+ */
203
+ setFilter(filter: FilterState<Row>): void;
204
+ /**
205
+ * Replaces the sort. Reports one `onColumnSortChange`, naming the first
206
+ * column whose place or direction changed, and none for an equal sort —
207
+ * the rule every setter below follows for its own slice and callback.
208
+ */
209
+ setColumnSort(sort: ColumnSortState): void;
210
+ /** Replaces the group-by stack. Reports through `onGroupByChange`. */
211
+ setGroupBy(groupBy: GroupByState): void;
212
+ /** Replaces the collapsed groups. Reports through `onGroupExpansionChange` with `groupId: null`. */
213
+ setGroupExpansion(expansion: GroupExpansionState): void;
214
+ /** Replaces the page and page size as given. Reports through `onPaginationChange`. */
215
+ setPagination(pagination: PaginationState): void;
216
+ /** Replaces the column widths. Reports through `onColumnResize`, as the `"end"` of a resize. */
217
+ setColumnSizing(sizing: ColumnSizingState): void;
218
+ /** Replaces the column order. Reports through `onColumnOrderChange`. */
219
+ setColumnOrder(order: ColumnOrderState): void;
220
+ /** Replaces the column visibility state. Reports through `onColumnVisibilityChange`. */
221
+ setColumnVisibility(visibility: ColumnVisibilityState): void;
222
+ /** Replaces the selected row ids as given, whatever `selectable` allows. Fires the row selection callbacks. */
223
+ setRowSelection(selection: SelectionState): void;
224
+ /** Replaces the selected column ids as given. Fires the column selection callbacks. */
225
+ setColumnSelection(selection: SelectionState): void;
226
+ /** Replaces the selected cell as given, `null` for none. Fires the cell selection callbacks. */
227
+ setCellSelection(selection: CellSelectionState): void;
228
+ /**
229
+ * Sizes a shown column to fit its content, as double-clicking its resize
230
+ * handle does, reporting through `onColumnResize`. A hidden column, or one
231
+ * with no rows to measure, is left as it is.
232
+ */
233
+ autoFitColumn(columnId: string): void;
234
+ /**
235
+ * `autoFitColumn` for each of the given columns, or for every column shown
236
+ * when given none.
237
+ */
238
+ autoFitColumns(columnIds?: readonly string[]): void;
239
+ /**
240
+ * Opens the context menu `target` has, as a right-click there would —
241
+ * selecting it and focusing its cell first — beside `anchor`, a point in
242
+ * viewport coordinates or an element, or else below its cell. Says whether
243
+ * it opened: not for a target not on screen, nor where `contextMenu`
244
+ * gives no menu.
245
+ */
246
+ openContextMenu(target: GridContextMenuTarget, anchor?: {
247
+ readonly x: number;
248
+ readonly y: number;
249
+ } | Element): boolean;
250
+ /** Closes the context menu, if one is open. */
251
+ closeContextMenu(): void;
252
+ /**
253
+ * Runs a command by id — a built-in or one of `commands` — on `target`,
254
+ * `{ area: "grid" }` when left out, when it is visible and enabled there.
255
+ * Reports it through `onCommand` with `source: "api"`, and says whether it
256
+ * ran.
257
+ */
258
+ runCommand(commandId: string, target?: GridCommandTarget): boolean;
259
+ /** Scrolls the row with the given id into view, if it is currently shown. */
260
+ scrollToRow(rowId: string, options?: ScrollIntoViewOptions): void;
261
+ /** Scrolls the column with the given id into view. */
262
+ scrollToColumn(columnId: string, options?: ScrollIntoViewOptions): void;
263
+ /**
264
+ * Registers `listener` to be called after any render in which the grid's
265
+ * internal state may have changed — every getter above may return a
266
+ * different value once `listener` fires, not just one. Returns an
267
+ * unsubscribe function. The primitive the `use*State` hooks under
268
+ * `packages/react/src/DataGrid/hooks/` build on; most consumers should
269
+ * reach for one of those instead of calling `subscribe` directly.
270
+ */
271
+ subscribe(listener: () => void): () => void;
272
+ }
273
+
274
+ /**
275
+ * Everything a `pager.template` render prop needs to rebuild the built-in
276
+ * pager's UI itself. Passed fresh on every render where pagination-relevant
277
+ * state changed, so it's current by construction — unlike `DataGridApi`'s
278
+ * imperative methods and snapshot getters, which carry no "something
279
+ * changed, re-render" signal of their own.
280
+ */
281
+ interface PagerTemplateContext {
282
+ /** Same shape as `DataGridApi.getPagination()` — 0-based `pageIndex`. */
283
+ pagination: PaginationState;
284
+ /** `pagination.pageIndex + 1`, clamped — the display-ready page number. */
285
+ currentPage: number;
286
+ pageCount: number;
287
+ /** Passthrough of `pager.sizeOptions`, undefined when not given. */
288
+ pageSizeOptions: readonly number[] | undefined;
289
+ /** 0-based, same as `DataGridApi.goToPage` — not `currentPage`'s numbering. */
290
+ goToPage: (pageIndex: number) => void;
291
+ nextPage: () => void;
292
+ previousPage: () => void;
293
+ setPageSize: (pageSize: number) => void;
294
+ }
295
+ /** Presentation options for the grid's built-in pager. */
296
+ interface PagerConfig {
297
+ /** Page sizes offered by the built-in pager's page-size control. */
298
+ sizeOptions?: readonly number[] | undefined;
299
+ /** Defaults to `"compact"` — today's Prev/status/Next. */
300
+ variant?: "compact" | "numbered" | undefined;
301
+ /** Numbered variant only. How many pages to always show at each end. Defaults to 1. */
302
+ boundaryCount?: number | undefined;
303
+ /** Numbered variant only. How many pages to show on each side of the current page. Defaults to 1. */
304
+ siblingCount?: number | undefined;
305
+ /** Replaces the built-in pager entirely when given. `variant` is ignored. */
306
+ template?: ((context: PagerTemplateContext) => ReactNode) | undefined;
307
+ }
308
+ /**
309
+ * Loads more rows as the user scrolls near the bottom, in place of paging.
310
+ * Appends only — there is no equivalent of `paginated`'s reset-to-page-0 for
311
+ * a result set that shrinks out from under the current position.
312
+ */
313
+ interface InfiniteScrollConfig {
314
+ /** Whether a further `onLoadMore` could still return more rows. `false` removes the sentinel entirely, so no further scrolling can trigger a load. */
315
+ readonly hasMore: boolean;
316
+ /**
317
+ * Called at most once per genuine threshold-crossing: fires when the
318
+ * sentinel comes within `rootMargin` of the body's viewport, and not again
319
+ * until `isLoadingMore` has gone back to `false`.
320
+ */
321
+ readonly onLoadMore: () => void;
322
+ /** Whether a load triggered by `onLoadMore` is still in flight. Suppresses further calls to it until this goes back to `false`. */
323
+ readonly isLoadingMore?: boolean | undefined;
324
+ /**
325
+ * How far from the bottom of the scrollable body `onLoadMore` fires, ahead
326
+ * of the sentinel actually scrolling into view, as CSS margins — an
327
+ * intersection observer's `rootMargin`. Defaults to `"200px"`.
328
+ */
329
+ readonly rootMargin?: string | undefined;
330
+ /** Replaces the built-in "Loading more…" row (`messages.loadingMore`). */
331
+ readonly loadingTemplate?: (() => ReactNode) | undefined;
332
+ }
333
+ /**
334
+ * The props that name a React type, and so have no place in the
335
+ * framework-free `GridOptions`: columns whose templates return `ReactNode`,
336
+ * the pager and infinite-scroll configs whose templates do too, and the
337
+ * toolbar's custom entries.
338
+ */
339
+ interface ReactRenderSlots<Row> {
340
+ columns?: readonly ColumnDefinition<Row>[] | undefined;
341
+ /** Presentation options for the built-in pager. */
342
+ pager?: PagerConfig | undefined;
343
+ /**
344
+ * Loads more rows as the user scrolls near the bottom, instead of paging.
345
+ * Mutually exclusive with `paginated` — setting both logs a dev-time
346
+ * `console.error` and only `paginated` takes effect. Recommended (not
347
+ * required) alongside `virtualized` for a dataset that grows without
348
+ * bound, so the mounted row count never grows with it either.
349
+ */
350
+ infiniteScroll?: InfiniteScrollConfig | undefined;
351
+ /** Draws the toolbar's custom entries — `{ type: "custom", id }` — by id. */
352
+ renderToolbarItem?: ((id: string) => ReactNode) | undefined;
353
+ }
354
+ /**
355
+ * Every grid setting in `@gridkitjs/core`'s `GridOptions`, plus what only
356
+ * React can express: render slots, selection callbacks carrying React-bound
357
+ * columns, and the `ref`.
358
+ */
359
+ interface DataGridProps<Row> extends GridOptions<Row>, ReactRenderSlots<Row>, SelectionCallbacks<Row> {
360
+ /** Imperative handle for reading live grid state and triggering actions. */
361
+ ref?: Ref<DataGridApi<Row>> | undefined;
362
+ }
363
+ declare function DataGrid<Row>(props: DataGridProps<Row>): react.JSX.Element;
364
+
365
+ interface PaginationStateApi {
366
+ pagination: PaginationState;
367
+ pageCount: number;
368
+ goToPage: (pageIndex: number) => void;
369
+ nextPage: () => void;
370
+ previousPage: () => void;
371
+ setPageSize: (pageSize: number) => void;
372
+ }
373
+ /**
374
+ * Reactive pagination state read off a mounted `DataGrid`'s `ref`,
375
+ * for building a pager entirely outside the grid's own DOM — a toolbar or
376
+ * sidebar `pager.template` can't reach. Updates on every pagination change,
377
+ * including the silent page-0 reset a filter/sort/group change triggers,
378
+ * which carries no `onPaginationChange` of its own.
379
+ *
380
+ * Before the grid mounts, `pagination` reads `{ pageIndex: 0, pageSize: 0 }`
381
+ * and `pageCount` reads `0`; the actions are no-ops until then.
382
+ */
383
+ declare function usePaginationState<Row>(gridRef: RefObject<DataGridApi<Row> | null>): PaginationStateApi;
384
+
385
+ interface GroupByStateApi {
386
+ groupBy: GroupByState;
387
+ groupExpansion: GroupExpansionState;
388
+ expandAllGroups: () => void;
389
+ collapseAllGroups: () => void;
390
+ }
391
+ /**
392
+ * Reactive group-by and group-expansion state read off a mounted
393
+ * `DataGrid`'s `ref`, for a group-by bar or summary sidebar living
394
+ * outside the grid's own DOM.
395
+ *
396
+ * The ref's `setGroupBy` and `setGroupExpansion` change the grouping and the
397
+ * collapsed groups for a custom group-by UI; this hook carries only the
398
+ * all-at-once expansion actions. A specific
399
+ * group's own computed aggregates are read off `getDisplayRows()`'s
400
+ * per-header `aggregates` field instead of a getter here — see
401
+ * `useAggregateState` for the grand-total equivalent.
402
+ *
403
+ * Before the grid mounts, both fields read as empty and the actions are
404
+ * no-ops.
405
+ */
406
+ declare function useGroupByState<Row>(gridRef: RefObject<DataGridApi<Row> | null>): GroupByStateApi;
407
+
408
+ /**
409
+ * Reactive column-sort state read off a mounted `DataGrid`'s `ref`,
410
+ * for a sort indicator living outside the grid's own DOM.
411
+ *
412
+ * Reads only; change the sort through the ref's `setColumnSort`, or hold it
413
+ * yourself with the controlled `columnSort` prop.
414
+ *
415
+ * Before the grid mounts, reads as an empty array.
416
+ */
417
+ declare function useColumnSortState<Row>(gridRef: RefObject<DataGridApi<Row> | null>): ColumnSortState;
418
+
419
+ interface SelectionStateApi {
420
+ rowSelection: SelectionState;
421
+ columnSelection: SelectionState;
422
+ cellSelection: CellSelectionState;
423
+ clearSelection: () => void;
424
+ selectAllRows: () => void;
425
+ }
426
+ /**
427
+ * Reactive row/column/cell selection state read off a mounted
428
+ * `DataGrid`'s `ref`, for a "N rows selected" toolbar living
429
+ * outside the grid's own DOM. One combined hook rather than three, matching
430
+ * how `useGridSelection` already treats all three as one concern
431
+ * internally.
432
+ *
433
+ * Before the grid mounts, the row/column fields read as empty arrays and
434
+ * the cell field reads `null`; the actions are no-ops.
435
+ */
436
+ declare function useSelectionState<Row>(gridRef: RefObject<DataGridApi<Row> | null>): SelectionStateApi;
437
+
438
+ /**
439
+ * Reactive grand-total aggregate results read off a mounted
440
+ * `DataGrid`'s `ref`, for a summary footer or bar living outside
441
+ * the grid's own DOM — mirroring the built-in one the grid renders itself.
442
+ *
443
+ * Read-only: `getAggregates` is already read-only on `DataGridApi`, computed
444
+ * over the whole filtered/sorted dataset rather than driven by any action.
445
+ * A specific group's own subtotal is read off `getDisplayRows()`'s
446
+ * per-header `aggregates` field instead — see `useGroupByState`.
447
+ *
448
+ * Before the grid mounts, reads as an empty map.
449
+ */
450
+ declare function useAggregateState<Row>(gridRef: RefObject<DataGridApi<Row> | null>): AggregateResults;
451
+
452
+ /**
453
+ * Reactive column-sizing state read off a mounted `DataGrid`'s
454
+ * `ref`. Reads only; change the widths through the ref's `setColumnSizing`,
455
+ * or hold them yourself with the controlled `columnSizing` prop.
456
+ *
457
+ * Before the grid mounts, reads as an empty object.
458
+ */
459
+ declare function useColumnSizingState<Row>(gridRef: RefObject<DataGridApi<Row> | null>): ColumnSizingState;
460
+
461
+ /**
462
+ * Reactive column-order state read off a mounted `DataGrid`'s
463
+ * `ref`. Reads only; change the order through the ref's `setColumnOrder`,
464
+ * or hold it yourself with the controlled `columnOrder` prop.
465
+ *
466
+ * Before the grid mounts, reads as an empty array.
467
+ */
468
+ declare function useColumnOrderState<Row>(gridRef: RefObject<DataGridApi<Row> | null>): ColumnOrderState;
469
+
470
+ /**
471
+ * Reactive column-visibility state read off a mounted `DataGrid`'s `ref` —
472
+ * the columns shown or hidden since it mounted, keyed by id. Read-only:
473
+ * change it through the ref's `showColumns`/`hideColumns`. A column absent
474
+ * from it follows its definition's `hidden`.
475
+ *
476
+ * Before the grid mounts, reads as an empty object.
477
+ */
478
+ declare function useColumnVisibilityState<Row>(gridRef: RefObject<DataGridApi<Row> | null>): ColumnVisibilityState;
479
+
480
+ interface FilterStateApi<Row> {
481
+ filter: FilterState<Row>;
482
+ setFilter: (filter: FilterState<Row>) => void;
483
+ }
484
+ /**
485
+ * Reactive filter state read off a mounted `DataGrid`'s `ref`, for a filter
486
+ * bar or search box living outside the grid's own DOM, which sees every change
487
+ * however it was made — the toolbar's search box included. `setFilter`
488
+ * replaces the whole filter and sends the grid back to its first page.
489
+ *
490
+ * Before the grid mounts, `filter` reads as an empty array and `setFilter`
491
+ * is a no-op.
492
+ */
493
+ declare function useFilterState<Row>(gridRef: RefObject<DataGridApi<Row> | null>): FilterStateApi<Row>;
494
+
495
+ export { type CellSelectEvent, type CellSelectionChangeEvent, type ColumnDefinition, type ColumnSelectEvent, type ColumnSelectionChangeEvent, type ColumnsSelectEvent, type DataColumn, DataGrid, type DataGridApi, type DataGridProps, type FilterStateApi, type GroupByStateApi, type InfiniteScrollConfig, type PagerConfig, type PagerTemplateContext, type PaginationStateApi, type ReactRenderSlots, type ResolvedColumn, type SelectedCell, type SelectedColumn, type SelectionStateApi, useAggregateState, useColumnOrderState, useColumnSizingState, useColumnSortState, useColumnVisibilityState, useFilterState, useGroupByState, usePaginationState, useSelectionState };