@gridkitjs/react 0.9.0 → 0.11.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/README.md +8 -3
- package/dist/index.d.ts +196 -281
- package/dist/index.js +2439 -1588
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ pnpm add @gridkitjs/react
|
|
|
12
12
|
|
|
13
13
|
```tsx
|
|
14
14
|
import { defineColumnsFromRows } from "@gridkitjs/core";
|
|
15
|
-
import {
|
|
15
|
+
import { DataGrid, type ColumnDefinition } from "@gridkitjs/react";
|
|
16
16
|
|
|
17
17
|
const rows = [
|
|
18
18
|
{ Id: 1, Application: { Id: 9, Name: "Portal" }, Cost: 1250.5 },
|
|
@@ -23,10 +23,15 @@ type Row = (typeof rows)[number];
|
|
|
23
23
|
|
|
24
24
|
const columns: readonly ColumnDefinition<Row>[] = [
|
|
25
25
|
...defineColumnsFromRows(rows),
|
|
26
|
-
{
|
|
26
|
+
{
|
|
27
|
+
field: "Cost",
|
|
28
|
+
id: "Cost.currency",
|
|
29
|
+
type: "currency",
|
|
30
|
+
header: "Cost",
|
|
31
|
+
},
|
|
27
32
|
];
|
|
28
33
|
|
|
29
|
-
<
|
|
34
|
+
<DataGrid
|
|
30
35
|
dataSource={rows}
|
|
31
36
|
columns={columns}
|
|
32
37
|
getRowId={(row) => String(row.Id)}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,34 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, Ref, RefObject } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
export { CellSelectionMode, CellSelectionState, CellTemplateContext, ColumnResizeEvent, ColumnSizeDefaults, ColumnSizingState, ResolvedRow, RowSelectEvent, RowSelectionChangeEvent, RowsSelectEvent, SelectableConfig, SelectedCellRef, SelectionMode, SelectionState } from '@gridkitjs/core';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Reported as the user selects. Every one of these is fanned out from a single
|
|
8
|
-
* diff of the transition it describes, so no two can disagree about what one
|
|
9
|
-
* interaction did.
|
|
10
|
-
*/
|
|
11
|
-
interface SelectionCallbacks<Row> {
|
|
12
|
-
/** Called once per row newly selected. The last call names the last row. */
|
|
13
|
-
onRowSelect?: ((event: RowSelectEvent<Row>) => void) | undefined;
|
|
14
|
-
/** Called once with every row one interaction selected. */
|
|
15
|
-
onRowsSelect?: ((event: RowsSelectEvent<Row>) => void) | undefined;
|
|
16
|
-
onRowDeselect?: ((event: RowSelectEvent<Row>) => void) | undefined;
|
|
17
|
-
onRowsDeselect?: ((event: RowsSelectEvent<Row>) => void) | undefined;
|
|
18
|
-
/**
|
|
19
|
-
* Called once per change with what it added, what it removed and everything
|
|
20
|
-
* selected after it — the one to persist from.
|
|
21
|
-
*/
|
|
22
|
-
onRowSelectionChange?: ((event: RowSelectionChangeEvent<Row>) => void) | undefined;
|
|
23
|
-
onColumnSelect?: ((event: ColumnSelectEvent<Row>) => void) | undefined;
|
|
24
|
-
onColumnsSelect?: ((event: ColumnsSelectEvent<Row>) => void) | undefined;
|
|
25
|
-
onColumnDeselect?: ((event: ColumnSelectEvent<Row>) => void) | undefined;
|
|
26
|
-
onColumnsDeselect?: ((event: ColumnsSelectEvent<Row>) => void) | undefined;
|
|
27
|
-
onColumnSelectionChange?: ((event: ColumnSelectionChangeEvent<Row>) => void) | undefined;
|
|
28
|
-
onCellSelect?: ((event: CellSelectEvent<Row>) => void) | undefined;
|
|
29
|
-
onCellDeselect?: ((event: CellSelectEvent<Row>) => void) | undefined;
|
|
30
|
-
onCellSelectionChange?: ((event: CellSelectionChangeEvent<Row>) => void) | undefined;
|
|
31
|
-
}
|
|
3
|
+
import { 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, FilterChangeEvent, FilterEntry, FilterState, GridCommand, GridCommandEvent, GridCommandTarget, GridContextMenuOptions, GridContextMenuRequest, GridContextMenuTarget, GridMessages, GridOptions, GridState, GridToolbarOptions, GroupByBarVisibility, HoverableConfig, MenuEntry, ResizeMode, ResolvedRow, RowPointerEvent, RowProps, RowSelectEvent, RowSelectionChangeEvent, RowsSelectEvent, SelectableConfig, SelectedCellRef, SelectionMode, SelectionState, SerializedGridState, ToolbarEntry, serializeGridState } from '@gridkitjs/core';
|
|
32
5
|
|
|
33
6
|
/**
|
|
34
7
|
* A column whose header and cells may render arbitrary React content.
|
|
@@ -38,6 +11,8 @@ interface SelectionCallbacks<Row> {
|
|
|
38
11
|
type ColumnDefinition<Row> = ColumnDefinition$1<Row, ReactNode>;
|
|
39
12
|
/** A column paired with the width it renders at. */
|
|
40
13
|
type ResolvedColumn<Row> = ResolvedColumn$1<Row, ReactNode>;
|
|
14
|
+
/** A column paired with its id, hidden or not — what `getDataColumns()` lists. */
|
|
15
|
+
type DataColumn<Row> = DataColumn$1<Row, ReactNode>;
|
|
41
16
|
/**
|
|
42
17
|
* The selection payloads, bound to React's node type for the same reason
|
|
43
18
|
* `ColumnDefinition` is: they carry a resolved column, whose label is whatever
|
|
@@ -53,17 +28,19 @@ type ColumnsSelectEvent<Row> = ColumnsSelectEvent$1<Row, ReactNode>;
|
|
|
53
28
|
type ColumnSelectionChangeEvent<Row> = ColumnSelectionChangeEvent$1<Row, ReactNode>;
|
|
54
29
|
type CellSelectEvent<Row> = CellSelectEvent$1<Row, ReactNode>;
|
|
55
30
|
type CellSelectionChangeEvent<Row> = CellSelectionChangeEvent$1<Row, ReactNode>;
|
|
31
|
+
type SelectionCallbacks<Row> = SelectionCallbacks$1<Row, ReactNode>;
|
|
56
32
|
/**
|
|
57
|
-
* Imperative handle for a mounted `
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
33
|
+
* Imperative handle for a mounted `DataGrid`, reached via its `ref` prop:
|
|
34
|
+
* the grid's DOM nodes, getters for its live state, the actions every grid
|
|
35
|
+
* ref carries (focus, select all, scroll-to), and a setter for every slice of
|
|
36
|
+
* state, for a toolbar, a saved layout or a test to drive it from outside.
|
|
37
|
+
*
|
|
38
|
+
* Every getter reads the grid's state at call time, so a read straight after
|
|
39
|
+
* an action sees its result. Every setter changes the grid as the user's own
|
|
40
|
+
* interaction would: it fires the slice's `on*Change` callback, and, for a
|
|
41
|
+
* slice held through a controlled prop, only asks. `subscribe` is the
|
|
42
|
+
* notify channel for state that changes; see
|
|
43
|
+
* `packages/react/src/DataGrid/hooks/` for the public hooks built on it.
|
|
67
44
|
*/
|
|
68
45
|
interface DataGridApi<Row> {
|
|
69
46
|
/** The grid's scrollable viewport element. */
|
|
@@ -83,11 +60,22 @@ interface DataGridApi<Row> {
|
|
|
83
60
|
* when `groupBy` is empty.
|
|
84
61
|
*/
|
|
85
62
|
getDisplayRows(): readonly DisplayRow<Row>[];
|
|
86
|
-
/**
|
|
63
|
+
/**
|
|
64
|
+
* The current page of `getDisplayRows()` — exactly the rows the body
|
|
65
|
+
* renders. All of `getDisplayRows()` when `paginated` is off.
|
|
66
|
+
*/
|
|
67
|
+
getPageRows(): readonly DisplayRow<Row>[];
|
|
68
|
+
/** Columns as currently sized and ordered — what's rendered, so hidden columns are left out. */
|
|
87
69
|
getColumns(): readonly ResolvedColumn<Row>[];
|
|
70
|
+
/** Every column in its current order, hidden ones included — what sorting, filtering and grouping read. */
|
|
71
|
+
getDataColumns(): readonly DataColumn<Row>[];
|
|
88
72
|
getColumnSizing(): ColumnSizingState;
|
|
89
73
|
getColumnOrder(): ColumnOrderState;
|
|
74
|
+
/** Columns shown or hidden since the grid mounted. A column absent from it follows its definition's `hidden`. */
|
|
75
|
+
getColumnVisibility(): ColumnVisibilityState;
|
|
90
76
|
getColumnSort(): ColumnSortState;
|
|
77
|
+
/** The filter the rows are shown through — every entry, ANDed together. */
|
|
78
|
+
getFilter(): FilterState<Row>;
|
|
91
79
|
getGroupBy(): GroupByState;
|
|
92
80
|
getGroupExpansion(): GroupExpansionState;
|
|
93
81
|
/** The active page and page size. Meaningful even when `paginated` is off — it stays at page 0 over the grid's whole (single) page. */
|
|
@@ -102,6 +90,12 @@ interface DataGridApi<Row> {
|
|
|
102
90
|
*/
|
|
103
91
|
getAggregates(): AggregateResults;
|
|
104
92
|
getRowSelection(): SelectionState;
|
|
93
|
+
/**
|
|
94
|
+
* The selected rows themselves, in the order they were selected — among
|
|
95
|
+
* every row the filter lets through, on any page or in any group, so a row
|
|
96
|
+
* filtered out while selected is left out until it is back.
|
|
97
|
+
*/
|
|
98
|
+
getSelectedRows(): readonly ResolvedRow<Row>[];
|
|
105
99
|
getColumnSelection(): SelectionState;
|
|
106
100
|
getCellSelection(): CellSelectionState;
|
|
107
101
|
/** The cell currently holding the grid's single tab stop. */
|
|
@@ -109,9 +103,29 @@ interface DataGridApi<Row> {
|
|
|
109
103
|
rowIndex: number;
|
|
110
104
|
columnIndex: number;
|
|
111
105
|
};
|
|
106
|
+
/**
|
|
107
|
+
* Every slice of state as the grid applies it, in one object — what
|
|
108
|
+
* `restoreState` takes back. Pass it through `serializeGridState` before
|
|
109
|
+
* saving it as JSON.
|
|
110
|
+
*/
|
|
111
|
+
getState(): GridState<Row>;
|
|
112
|
+
/**
|
|
113
|
+
* Puts back state saved earlier, whole or in part — from `getState()`, or
|
|
114
|
+
* from `serializeGridState` and back through JSON. Each slice given is set
|
|
115
|
+
* as its setter would set it, firing its callback when it changes; the
|
|
116
|
+
* grid re-renders once.
|
|
117
|
+
*/
|
|
118
|
+
restoreState(saved: Partial<GridState<Row>> | Partial<SerializedGridState<Row>>): void;
|
|
112
119
|
focusCell(rowIndex: number, columnIndex: number): void;
|
|
113
120
|
clearSelection(): void;
|
|
114
121
|
selectAllRows(): void;
|
|
122
|
+
/**
|
|
123
|
+
* Selects rows by id, as far as `selectable.rows` allows: `"replace"` (the
|
|
124
|
+
* default) selects exactly these — only the last of them under
|
|
125
|
+
* `"single"` — and `"toggle"` flips each one. Fires the row selection
|
|
126
|
+
* callbacks once for the whole call, and none when nothing changed.
|
|
127
|
+
*/
|
|
128
|
+
selectRows(rowIds: readonly string[], intent?: "replace" | "toggle"): void;
|
|
115
129
|
/** Expands every group at once — there is no dedicated UI control for it. */
|
|
116
130
|
expandAllGroups(): void;
|
|
117
131
|
/** 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. */
|
|
@@ -124,6 +138,84 @@ interface DataGridApi<Row> {
|
|
|
124
138
|
previousPage(): void;
|
|
125
139
|
/** Changes the page size, resetting to the first page. */
|
|
126
140
|
setPageSize(pageSize: number): void;
|
|
141
|
+
/**
|
|
142
|
+
* Shows the columns with the given ids, each in the place it held when
|
|
143
|
+
* hidden. Reports one `onColumnVisibilityChange` for the whole call, and
|
|
144
|
+
* none if every column was already showing.
|
|
145
|
+
*/
|
|
146
|
+
showColumns(columnIds: readonly string[]): void;
|
|
147
|
+
/**
|
|
148
|
+
* Hides the columns with the given ids. A hidden column still sorts,
|
|
149
|
+
* filters and groups, and keeps its place in the column order.
|
|
150
|
+
*/
|
|
151
|
+
hideColumns(columnIds: readonly string[]): void;
|
|
152
|
+
/**
|
|
153
|
+
* Replaces the filter, the way a filter UI would, and sends an uncontrolled
|
|
154
|
+
* grid back to its first page. Reports one `onFilterChange`, and none when
|
|
155
|
+
* `filter` is equal to the current one. With a controlled `filter` prop it
|
|
156
|
+
* only asks, as any change does.
|
|
157
|
+
*/
|
|
158
|
+
setFilter(filter: FilterState<Row>): void;
|
|
159
|
+
/**
|
|
160
|
+
* Replaces the sort. Reports one `onColumnSortChange`, naming the first
|
|
161
|
+
* column whose place or direction changed, and none for an equal sort —
|
|
162
|
+
* the rule every setter below follows for its own slice and callback.
|
|
163
|
+
*/
|
|
164
|
+
setColumnSort(sort: ColumnSortState): void;
|
|
165
|
+
/** Replaces the group-by stack. Reports through `onGroupByChange`. */
|
|
166
|
+
setGroupBy(groupBy: GroupByState): void;
|
|
167
|
+
/** Replaces the collapsed groups. Reports through `onGroupExpansionChange` with `groupId: null`. */
|
|
168
|
+
setGroupExpansion(expansion: GroupExpansionState): void;
|
|
169
|
+
/** Replaces the page and page size as given. Reports through `onPaginationChange`. */
|
|
170
|
+
setPagination(pagination: PaginationState): void;
|
|
171
|
+
/** Replaces the column widths. Reports through `onColumnResize`, as the `"end"` of a resize. */
|
|
172
|
+
setColumnSizing(sizing: ColumnSizingState): void;
|
|
173
|
+
/** Replaces the column order. Reports through `onColumnOrderChange`. */
|
|
174
|
+
setColumnOrder(order: ColumnOrderState): void;
|
|
175
|
+
/** Replaces the column visibility state. Reports through `onColumnVisibilityChange`. */
|
|
176
|
+
setColumnVisibility(visibility: ColumnVisibilityState): void;
|
|
177
|
+
/** Replaces the selected row ids as given, whatever `selectable` allows. Fires the row selection callbacks. */
|
|
178
|
+
setRowSelection(selection: SelectionState): void;
|
|
179
|
+
/** Replaces the selected column ids as given. Fires the column selection callbacks. */
|
|
180
|
+
setColumnSelection(selection: SelectionState): void;
|
|
181
|
+
/** Replaces the selected cell as given, `null` for none. Fires the cell selection callbacks. */
|
|
182
|
+
setCellSelection(selection: CellSelectionState): void;
|
|
183
|
+
/**
|
|
184
|
+
* Sizes a shown column to fit its content, as double-clicking its resize
|
|
185
|
+
* handle does, reporting through `onColumnResize`. A hidden column, or one
|
|
186
|
+
* with no rows to measure, is left as it is.
|
|
187
|
+
*/
|
|
188
|
+
autoFitColumn(columnId: string): void;
|
|
189
|
+
/**
|
|
190
|
+
* `autoFitColumn` for each of the given columns, or for every column shown
|
|
191
|
+
* when given none.
|
|
192
|
+
*/
|
|
193
|
+
autoFitColumns(columnIds?: readonly string[]): void;
|
|
194
|
+
/**
|
|
195
|
+
* Opens the context menu `target` has, as a right-click there would —
|
|
196
|
+
* selecting it and focusing its cell first — beside `anchor`, a point in
|
|
197
|
+
* viewport coordinates or an element, or else below its cell. Says whether
|
|
198
|
+
* it opened: not for a target not on screen, nor where `contextMenu`
|
|
199
|
+
* gives no menu.
|
|
200
|
+
*/
|
|
201
|
+
openContextMenu(target: GridContextMenuTarget, anchor?: {
|
|
202
|
+
readonly x: number;
|
|
203
|
+
readonly y: number;
|
|
204
|
+
} | Element): boolean;
|
|
205
|
+
/** Closes the context menu, if one is open. */
|
|
206
|
+
closeContextMenu(): void;
|
|
207
|
+
/**
|
|
208
|
+
* Opens the column chooser at the grid's top-end corner, in place of any
|
|
209
|
+
* panel open; it gives focus back to what had it when it closes.
|
|
210
|
+
*/
|
|
211
|
+
openColumnChooser(): void;
|
|
212
|
+
/**
|
|
213
|
+
* Runs a command by id — a built-in or one of `commands` — on `target`,
|
|
214
|
+
* `{ area: "grid" }` when left out, when it is visible and enabled there.
|
|
215
|
+
* Reports it through `onCommand` with `source: "api"`, and says whether it
|
|
216
|
+
* ran.
|
|
217
|
+
*/
|
|
218
|
+
runCommand(commandId: string, target?: GridCommandTarget): boolean;
|
|
127
219
|
/** Scrolls the row with the given id into view, if it is currently shown. */
|
|
128
220
|
scrollToRow(rowId: string, options?: ScrollIntoViewOptions): void;
|
|
129
221
|
/** Scrolls the column with the given id into view. */
|
|
@@ -138,32 +230,7 @@ interface DataGridApi<Row> {
|
|
|
138
230
|
*/
|
|
139
231
|
subscribe(listener: () => void): () => void;
|
|
140
232
|
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* How a column's width relates to the grid's.
|
|
144
|
-
*
|
|
145
|
-
* `"fit"` keeps the columns filling the grid: the space a column gives up is
|
|
146
|
-
* handed to the others, and the space it takes comes out of them. `"fixed"`
|
|
147
|
-
* lets every column keep its own width, so a resize moves one column and
|
|
148
|
-
* nothing else, and the grid scrolls or leaves a gap accordingly.
|
|
149
|
-
*/
|
|
150
|
-
type ResizeMode = "fit" | "fixed";
|
|
151
|
-
/**
|
|
152
|
-
* How the group-by bar's visibility follows the active grouping. `"always"`
|
|
153
|
-
* renders it even with an empty `groupBy` — a fixed drop target and a
|
|
154
|
-
* constant reminder grouping exists. `"never"` never renders it, for a grid
|
|
155
|
-
* driving `groupBy` entirely by its own UI (a header toggle, `Alt+ArrowDown`)
|
|
156
|
-
* or programmatically. `"auto"` renders it once `groupBy` is non-empty, or
|
|
157
|
-
* while a header drag eligible to drop into it is in progress — so there is
|
|
158
|
-
* always somewhere to drop the very first column, even from a fully empty
|
|
159
|
-
* grouping.
|
|
160
|
-
*/
|
|
161
|
-
type GroupByBarVisibility = "always" | "auto" | "never";
|
|
162
|
-
interface HoverableConfig {
|
|
163
|
-
rows?: boolean;
|
|
164
|
-
columns?: boolean;
|
|
165
|
-
cells?: boolean;
|
|
166
|
-
}
|
|
233
|
+
|
|
167
234
|
/**
|
|
168
235
|
* Everything a `pager.template` render prop needs to rebuild the built-in
|
|
169
236
|
* pager's UI itself. Passed fresh on every render where pagination-relevant
|
|
@@ -215,151 +282,24 @@ interface InfiniteScrollConfig {
|
|
|
215
282
|
/** Whether a load triggered by `onLoadMore` is still in flight. Suppresses further calls to it until this goes back to `false`. */
|
|
216
283
|
readonly isLoadingMore?: boolean | undefined;
|
|
217
284
|
/**
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
285
|
+
* How far from the bottom of the scrollable body `onLoadMore` fires, ahead
|
|
286
|
+
* of the sentinel actually scrolling into view, as CSS margins — an
|
|
287
|
+
* intersection observer's `rootMargin`. Defaults to `"200px"`.
|
|
221
288
|
*/
|
|
222
289
|
readonly rootMargin?: string | undefined;
|
|
223
|
-
/** Replaces the built-in "Loading more…" row. */
|
|
290
|
+
/** Replaces the built-in "Loading more…" row (`messages.loadingMore`). */
|
|
224
291
|
readonly loadingTemplate?: (() => ReactNode) | undefined;
|
|
225
292
|
}
|
|
226
|
-
|
|
293
|
+
/**
|
|
294
|
+
* The props that name a React type, and so have no place in the
|
|
295
|
+
* framework-free `GridOptions`: columns whose templates return `ReactNode`,
|
|
296
|
+
* the pager and infinite-scroll configs whose templates do too, and the
|
|
297
|
+
* toolbar's custom entries.
|
|
298
|
+
*/
|
|
299
|
+
interface ReactRenderSlots<Row> {
|
|
227
300
|
columns?: readonly ColumnDefinition<Row>[] | undefined;
|
|
228
|
-
dataSource?: readonly Row[] | undefined;
|
|
229
|
-
/**
|
|
230
|
-
* A row's stable identity, for state keyed by it. Defaults to the row's
|
|
231
|
-
* position, which is enough for a static grid but ties that state to where a
|
|
232
|
-
* row sits rather than to the row — so anything sorting, filtering or paging
|
|
233
|
-
* its data should give one.
|
|
234
|
-
*
|
|
235
|
-
* Called for every row on every change to `dataSource`, so it should be
|
|
236
|
-
* cheap and stable; an inline arrow is fine, one that re-reads the data is
|
|
237
|
-
* not.
|
|
238
|
-
*/
|
|
239
|
-
getRowId?: ((row: Row, index: number) => string) | undefined;
|
|
240
|
-
borders?: Borders | undefined;
|
|
241
|
-
hoverable?: HoverableConfig | undefined;
|
|
242
|
-
/**
|
|
243
|
-
* Which parts of the grid the user may select, and how many of each —
|
|
244
|
-
* `{ rows: "multiple", cells: "single" }`. A cell addresses one value, so it
|
|
245
|
-
* has no `"multiple"`.
|
|
246
|
-
*
|
|
247
|
-
* Off by default, unlike `hoverable`: selection claims the click, which a
|
|
248
|
-
* grid that only displays data should not do. Give `getRowId` alongside it
|
|
249
|
-
* for data that sorts, filters or pages, or a selection follows the position
|
|
250
|
-
* rather than the row.
|
|
251
|
-
*/
|
|
252
|
-
selectable?: SelectableConfig | undefined;
|
|
253
|
-
/** Row ids selected to start with, keyed as `getRowId` resolves them. Uncontrolled. */
|
|
254
|
-
defaultRowSelection?: SelectionState | undefined;
|
|
255
|
-
/** Column ids selected to start with. Uncontrolled. */
|
|
256
|
-
defaultColumnSelection?: SelectionState | undefined;
|
|
257
|
-
/** The cell selected to start with. Uncontrolled. */
|
|
258
|
-
defaultCellSelection?: CellSelectionState | undefined;
|
|
259
|
-
/** Whether columns can be dragged wider, unless a column says otherwise. */
|
|
260
|
-
resizableColumns?: boolean | undefined;
|
|
261
|
-
/**
|
|
262
|
-
* Whether columns can be dragged into a new position, unless a column says
|
|
263
|
-
* otherwise. Turning it off leaves an order the user already made in place.
|
|
264
|
-
*/
|
|
265
|
-
reorderableColumns?: boolean | undefined;
|
|
266
|
-
/**
|
|
267
|
-
* Whether columns fill the grid's width or sit at their own. Defaults to
|
|
268
|
-
* `"fit"`, under which columns the user has sized keep their width and the
|
|
269
|
-
* rest share what is left.
|
|
270
|
-
*/
|
|
271
|
-
resizeMode?: ResizeMode | undefined;
|
|
272
|
-
/** Column widths to start from, keyed by column id. Uncontrolled. */
|
|
273
|
-
defaultColumnSizing?: ColumnSizingState | undefined;
|
|
274
|
-
/**
|
|
275
|
-
* Column ids in the order to start in. Uncontrolled, and partial: ids it
|
|
276
|
-
* omits keep their position among `columns` and follow those it lists.
|
|
277
|
-
*/
|
|
278
|
-
defaultColumnOrder?: ColumnOrderState | undefined;
|
|
279
|
-
/**
|
|
280
|
-
* Sizes applied to columns that do not set their own — the width they start
|
|
281
|
-
* at and the bounds they may be resized between. Distinct from
|
|
282
|
-
* `defaultColumnSizing`, which sets specific columns' starting widths.
|
|
283
|
-
*/
|
|
284
|
-
columnSizeDefaults?: Partial<ColumnSizeDefaults> | undefined;
|
|
285
|
-
/**
|
|
286
|
-
* Called as the user resizes a column. Fires continuously with
|
|
287
|
-
* `phase: "move"` and once on release with `phase: "end"` — the latter being
|
|
288
|
-
* the one to persist. Auto-fit does not call it; it reports user intent only.
|
|
289
|
-
*/
|
|
290
|
-
onColumnResize?: ((event: ColumnResizeEvent) => void) | undefined;
|
|
291
|
-
/**
|
|
292
|
-
* Called once when the user drops a column somewhere new. A drop that leaves
|
|
293
|
-
* the order as it was does not call it.
|
|
294
|
-
*/
|
|
295
|
-
onColumnOrderChange?: ((event: ColumnOrderEvent) => void) | undefined;
|
|
296
|
-
/**
|
|
297
|
-
* Whether columns can be sorted by clicking their header toggle, unless a
|
|
298
|
-
* column says otherwise. Shift-click stacks a column into the sort instead
|
|
299
|
-
* of replacing it.
|
|
300
|
-
*/
|
|
301
|
-
sortableColumns?: boolean | undefined;
|
|
302
|
-
/** The sort to start with, in priority order. Uncontrolled. */
|
|
303
|
-
defaultColumnSort?: ColumnSortState | undefined;
|
|
304
|
-
/**
|
|
305
|
-
* Called once when the user changes the sort — a toggle, a stack, or a
|
|
306
|
-
* clear back to "none".
|
|
307
|
-
*/
|
|
308
|
-
onColumnSortChange?: ((event: ColumnSortEvent) => void) | undefined;
|
|
309
|
-
/**
|
|
310
|
-
* Whether columns can be grouped by — a header's click/`Alt+ArrowDown`
|
|
311
|
-
* toggle — unless a column says otherwise. The grouping itself still
|
|
312
|
-
* applies when this is off, via `defaultGroupBy` or the imperative API;
|
|
313
|
-
* this only gates that one interaction, the same way `sortableColumns`
|
|
314
|
-
* gates the sort toggle without disabling `defaultColumnSort`. Independent
|
|
315
|
-
* of `groupByBarVisibility` and `groupByDraggableColumns`, which gate the
|
|
316
|
-
* bar and the drag-in gesture respectively.
|
|
317
|
-
*/
|
|
318
|
-
groupableColumns?: boolean | undefined;
|
|
319
|
-
/**
|
|
320
|
-
* Whether a groupable header shows its group-toggle icon, unless a column
|
|
321
|
-
* says otherwise. Purely a rendering choice: `Alt+ArrowDown` keeps working
|
|
322
|
-
* on a groupable header with the icon hidden.
|
|
323
|
-
*/
|
|
324
|
-
groupToggleIconColumns?: boolean | undefined;
|
|
325
|
-
/**
|
|
326
|
-
* Whether a column's header may be dragged into the group-by bar to add
|
|
327
|
-
* it to the grouping, unless a column says otherwise. Independent of
|
|
328
|
-
* `groupableColumns`: a column can be groupable via its header's
|
|
329
|
-
* click/keyboard toggle, via this drag, both, or neither.
|
|
330
|
-
*/
|
|
331
|
-
groupByDraggableColumns?: boolean | undefined;
|
|
332
|
-
/** How the group-by bar's visibility follows the active grouping. */
|
|
333
|
-
groupByBarVisibility?: GroupByBarVisibility | undefined;
|
|
334
|
-
/** The group-by stack to start with, outer to inner. Uncontrolled. */
|
|
335
|
-
defaultGroupBy?: GroupByState | undefined;
|
|
336
|
-
/**
|
|
337
|
-
* Called once when the user changes the group-by stack — adding, removing,
|
|
338
|
-
* or reordering a level.
|
|
339
|
-
*/
|
|
340
|
-
onGroupByChange?: ((event: GroupByEvent) => void) | undefined;
|
|
341
|
-
/** Group keys collapsed to start with — every other group starts expanded. Uncontrolled. */
|
|
342
|
-
defaultGroupExpansion?: GroupExpansionState | undefined;
|
|
343
|
-
/** Called once when the user expands or collapses a group, or every group at once. */
|
|
344
|
-
onGroupExpansionChange?: ((event: GroupExpansionEvent) => void) | undefined;
|
|
345
|
-
/** The filter to start with — every applied entry, ANDed together. Uncontrolled. */
|
|
346
|
-
defaultFilter?: FilterState<Row> | undefined;
|
|
347
|
-
/**
|
|
348
|
-
* Whether the grid's rows are split into pages. A page's unit is a
|
|
349
|
-
* top-level group or a bare data row, never a leaf row — a group is never
|
|
350
|
-
* split across a page boundary. Off by default, matching `sortableColumns`.
|
|
351
|
-
*/
|
|
352
|
-
paginated?: boolean | undefined;
|
|
353
|
-
/**
|
|
354
|
-
* The page and page size to start on. Uncontrolled. Defaults to
|
|
355
|
-
* `{ pageIndex: 0, pageSize: 25 }` when `paginated` is on and this is
|
|
356
|
-
* omitted.
|
|
357
|
-
*/
|
|
358
|
-
defaultPagination?: PaginationState | undefined;
|
|
359
301
|
/** Presentation options for the built-in pager. */
|
|
360
302
|
pager?: PagerConfig | undefined;
|
|
361
|
-
/** Called once when the user changes the page or the page size. */
|
|
362
|
-
onPaginationChange?: ((event: PaginationChangeEvent) => void) | undefined;
|
|
363
303
|
/**
|
|
364
304
|
* Loads more rows as the user scrolls near the bottom, instead of paging.
|
|
365
305
|
* Mutually exclusive with `paginated` — setting both logs a dev-time
|
|
@@ -368,68 +308,19 @@ interface DataGridProps<Row> extends SelectionCallbacks<Row> {
|
|
|
368
308
|
* bound, so the mounted row count never grows with it either.
|
|
369
309
|
*/
|
|
370
310
|
infiniteScroll?: InfiniteScrollConfig | undefined;
|
|
371
|
-
/**
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
aggregates?: AggregateState<Row> | undefined;
|
|
381
|
-
/**
|
|
382
|
-
* Where a group's own aggregate results render. `"inline"` (the default)
|
|
383
|
-
* keeps them as text in the group header, next to its leaf-row count.
|
|
384
|
-
* `"row"` instead renders a dedicated row after that group's last visible
|
|
385
|
-
* entry, with each aggregate's value in the `<td>` for its own column —
|
|
386
|
-
* the same alignment the grand-total footer's own cells have. Has no
|
|
387
|
-
* effect when `aggregates` is empty or omitted.
|
|
388
|
-
*/
|
|
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;
|
|
419
|
-
/**
|
|
420
|
-
* The grid's accessible name, announced when it takes focus. A grid without
|
|
421
|
-
* one is read only as "grid", which says nothing about which grid.
|
|
422
|
-
*/
|
|
423
|
-
label?: string | undefined;
|
|
424
|
-
/**
|
|
425
|
-
* The id of an element naming the grid, for a heading already on the page.
|
|
426
|
-
* Takes precedence over `label`, as `aria-labelledby` does.
|
|
427
|
-
*/
|
|
428
|
-
labelledBy?: string | undefined;
|
|
311
|
+
/** Draws the toolbar's custom entries — `{ type: "custom", id }` — by id. */
|
|
312
|
+
renderToolbarItem?: ((id: string) => ReactNode) | undefined;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Every grid setting in `@gridkitjs/core`'s `GridOptions`, plus what only
|
|
316
|
+
* React can express: render slots, selection callbacks carrying React-bound
|
|
317
|
+
* columns, and the `ref`.
|
|
318
|
+
*/
|
|
319
|
+
interface DataGridProps<Row> extends GridOptions<Row>, ReactRenderSlots<Row>, SelectionCallbacks<Row> {
|
|
429
320
|
/** Imperative handle for reading live grid state and triggering actions. */
|
|
430
321
|
ref?: Ref<DataGridApi<Row>> | undefined;
|
|
431
322
|
}
|
|
432
|
-
declare function
|
|
323
|
+
declare function DataGrid<Row>(props: DataGridProps<Row>): react.JSX.Element;
|
|
433
324
|
|
|
434
325
|
interface PaginationStateApi {
|
|
435
326
|
pagination: PaginationState;
|
|
@@ -440,7 +331,7 @@ interface PaginationStateApi {
|
|
|
440
331
|
setPageSize: (pageSize: number) => void;
|
|
441
332
|
}
|
|
442
333
|
/**
|
|
443
|
-
* Reactive pagination state read off a mounted `
|
|
334
|
+
* Reactive pagination state read off a mounted `DataGrid`'s `ref`,
|
|
444
335
|
* for building a pager entirely outside the grid's own DOM — a toolbar or
|
|
445
336
|
* sidebar `pager.template` can't reach. Updates on every pagination change,
|
|
446
337
|
* including the silent page-0 reset a filter/sort/group change triggers,
|
|
@@ -459,12 +350,12 @@ interface GroupByStateApi {
|
|
|
459
350
|
}
|
|
460
351
|
/**
|
|
461
352
|
* Reactive group-by and group-expansion state read off a mounted
|
|
462
|
-
* `
|
|
353
|
+
* `DataGrid`'s `ref`, for a group-by bar or summary sidebar living
|
|
463
354
|
* outside the grid's own DOM.
|
|
464
355
|
*
|
|
465
|
-
* `
|
|
466
|
-
*
|
|
467
|
-
*
|
|
356
|
+
* The ref's `setGroupBy` and `setGroupExpansion` change the grouping and the
|
|
357
|
+
* collapsed groups for a custom group-by UI; this hook carries only the
|
|
358
|
+
* all-at-once expansion actions. A specific
|
|
468
359
|
* group's own computed aggregates are read off `getDisplayRows()`'s
|
|
469
360
|
* per-header `aggregates` field instead of a getter here — see
|
|
470
361
|
* `useAggregateState` for the grand-total equivalent.
|
|
@@ -475,12 +366,11 @@ interface GroupByStateApi {
|
|
|
475
366
|
declare function useGroupByState<Row>(gridRef: RefObject<DataGridApi<Row> | null>): GroupByStateApi;
|
|
476
367
|
|
|
477
368
|
/**
|
|
478
|
-
* Reactive column-sort state read off a mounted `
|
|
369
|
+
* Reactive column-sort state read off a mounted `DataGrid`'s `ref`,
|
|
479
370
|
* for a sort indicator living outside the grid's own DOM.
|
|
480
371
|
*
|
|
481
|
-
*
|
|
482
|
-
*
|
|
483
|
-
* `useGroupByState` has for group-by. Reads only.
|
|
372
|
+
* Reads only; change the sort through the ref's `setColumnSort`, or hold it
|
|
373
|
+
* yourself with the controlled `columnSort` prop.
|
|
484
374
|
*
|
|
485
375
|
* Before the grid mounts, reads as an empty array.
|
|
486
376
|
*/
|
|
@@ -495,7 +385,7 @@ interface SelectionStateApi {
|
|
|
495
385
|
}
|
|
496
386
|
/**
|
|
497
387
|
* Reactive row/column/cell selection state read off a mounted
|
|
498
|
-
* `
|
|
388
|
+
* `DataGrid`'s `ref`, for a "N rows selected" toolbar living
|
|
499
389
|
* outside the grid's own DOM. One combined hook rather than three, matching
|
|
500
390
|
* how `useGridSelection` already treats all three as one concern
|
|
501
391
|
* internally.
|
|
@@ -507,7 +397,7 @@ declare function useSelectionState<Row>(gridRef: RefObject<DataGridApi<Row> | nu
|
|
|
507
397
|
|
|
508
398
|
/**
|
|
509
399
|
* Reactive grand-total aggregate results read off a mounted
|
|
510
|
-
* `
|
|
400
|
+
* `DataGrid`'s `ref`, for a summary footer or bar living outside
|
|
511
401
|
* the grid's own DOM — mirroring the built-in one the grid renders itself.
|
|
512
402
|
*
|
|
513
403
|
* Read-only: `getAggregates` is already read-only on `DataGridApi`, computed
|
|
@@ -520,21 +410,46 @@ declare function useSelectionState<Row>(gridRef: RefObject<DataGridApi<Row> | nu
|
|
|
520
410
|
declare function useAggregateState<Row>(gridRef: RefObject<DataGridApi<Row> | null>): AggregateResults;
|
|
521
411
|
|
|
522
412
|
/**
|
|
523
|
-
* Reactive column-sizing state read off a mounted `
|
|
524
|
-
* `ref`.
|
|
525
|
-
*
|
|
413
|
+
* Reactive column-sizing state read off a mounted `DataGrid`'s
|
|
414
|
+
* `ref`. Reads only; change the widths through the ref's `setColumnSizing`,
|
|
415
|
+
* or hold them yourself with the controlled `columnSizing` prop.
|
|
526
416
|
*
|
|
527
417
|
* Before the grid mounts, reads as an empty object.
|
|
528
418
|
*/
|
|
529
419
|
declare function useColumnSizingState<Row>(gridRef: RefObject<DataGridApi<Row> | null>): ColumnSizingState;
|
|
530
420
|
|
|
531
421
|
/**
|
|
532
|
-
* Reactive column-order state read off a mounted `
|
|
533
|
-
* `ref`.
|
|
534
|
-
*
|
|
422
|
+
* Reactive column-order state read off a mounted `DataGrid`'s
|
|
423
|
+
* `ref`. Reads only; change the order through the ref's `setColumnOrder`,
|
|
424
|
+
* or hold it yourself with the controlled `columnOrder` prop.
|
|
535
425
|
*
|
|
536
426
|
* Before the grid mounts, reads as an empty array.
|
|
537
427
|
*/
|
|
538
428
|
declare function useColumnOrderState<Row>(gridRef: RefObject<DataGridApi<Row> | null>): ColumnOrderState;
|
|
539
429
|
|
|
540
|
-
|
|
430
|
+
/**
|
|
431
|
+
* Reactive column-visibility state read off a mounted `DataGrid`'s `ref` —
|
|
432
|
+
* the columns shown or hidden since it mounted, keyed by id. Read-only:
|
|
433
|
+
* change it through the ref's `showColumns`/`hideColumns`. A column absent
|
|
434
|
+
* from it follows its definition's `hidden`.
|
|
435
|
+
*
|
|
436
|
+
* Before the grid mounts, reads as an empty object.
|
|
437
|
+
*/
|
|
438
|
+
declare function useColumnVisibilityState<Row>(gridRef: RefObject<DataGridApi<Row> | null>): ColumnVisibilityState;
|
|
439
|
+
|
|
440
|
+
interface FilterStateApi<Row> {
|
|
441
|
+
filter: FilterState<Row>;
|
|
442
|
+
setFilter: (filter: FilterState<Row>) => void;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Reactive filter state read off a mounted `DataGrid`'s `ref`, for a filter
|
|
446
|
+
* bar or search box living outside the grid's own DOM — which, while the grid
|
|
447
|
+
* has no filter UI of its own, is where filtering happens. `setFilter`
|
|
448
|
+
* replaces the whole filter and sends the grid back to its first page.
|
|
449
|
+
*
|
|
450
|
+
* Before the grid mounts, `filter` reads as an empty array and `setFilter`
|
|
451
|
+
* is a no-op.
|
|
452
|
+
*/
|
|
453
|
+
declare function useFilterState<Row>(gridRef: RefObject<DataGridApi<Row> | null>): FilterStateApi<Row>;
|
|
454
|
+
|
|
455
|
+
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 };
|