@gridkitjs/react 0.8.0 → 0.10.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 +193 -244
- package/dist/index.js +1149 -1290
- 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, SelectedCell as SelectedCell$1, SelectedColumn as SelectedColumn$1 } from '@gridkitjs/core';
|
|
4
|
+
export { Borders, CellSelectionMode, CellSelectionState, CellTemplateContext, ColumnResizeEvent, ColumnSizeDefaults, ColumnSizingState, ColumnVisibilityEvent, ColumnVisibilityState, FilterChangeEvent, FilterEntry, FilterState, GridMessages, GridOptions, GridState, GroupByBarVisibility, HoverableConfig, ResizeMode, ResolvedRow, RowPointerEvent, RowProps, RowSelectEvent, RowSelectionChangeEvent, RowsSelectEvent, SelectableConfig, SelectedCellRef, SelectionMode, SelectionState, SerializedGridState, 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,22 +28,29 @@ 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. */
|
|
70
47
|
readonly element: HTMLDivElement | null;
|
|
71
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* The grid's row-area `<table>` element — the one holding `<tbody>`. The
|
|
50
|
+
* header and, when aggregates are active, footer render as their own
|
|
51
|
+
* sibling `<table>`s outside this one; use `element` to reach the whole
|
|
52
|
+
* scrollable viewport instead.
|
|
53
|
+
*/
|
|
72
54
|
readonly table: HTMLTableElement | null;
|
|
73
55
|
/** Rows as currently filtered and sorted — what's rendered, ungrouped. */
|
|
74
56
|
getRows(): readonly ResolvedRow<Row>[];
|
|
@@ -78,11 +60,22 @@ interface DataGridApi<Row> {
|
|
|
78
60
|
* when `groupBy` is empty.
|
|
79
61
|
*/
|
|
80
62
|
getDisplayRows(): readonly DisplayRow<Row>[];
|
|
81
|
-
/**
|
|
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. */
|
|
82
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>[];
|
|
83
72
|
getColumnSizing(): ColumnSizingState;
|
|
84
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;
|
|
85
76
|
getColumnSort(): ColumnSortState;
|
|
77
|
+
/** The filter the rows are shown through — every entry, ANDed together. */
|
|
78
|
+
getFilter(): FilterState<Row>;
|
|
86
79
|
getGroupBy(): GroupByState;
|
|
87
80
|
getGroupExpansion(): GroupExpansionState;
|
|
88
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. */
|
|
@@ -97,6 +90,12 @@ interface DataGridApi<Row> {
|
|
|
97
90
|
*/
|
|
98
91
|
getAggregates(): AggregateResults;
|
|
99
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>[];
|
|
100
99
|
getColumnSelection(): SelectionState;
|
|
101
100
|
getCellSelection(): CellSelectionState;
|
|
102
101
|
/** The cell currently holding the grid's single tab stop. */
|
|
@@ -104,9 +103,29 @@ interface DataGridApi<Row> {
|
|
|
104
103
|
rowIndex: number;
|
|
105
104
|
columnIndex: number;
|
|
106
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;
|
|
107
119
|
focusCell(rowIndex: number, columnIndex: number): void;
|
|
108
120
|
clearSelection(): void;
|
|
109
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;
|
|
110
129
|
/** Expands every group at once — there is no dedicated UI control for it. */
|
|
111
130
|
expandAllGroups(): void;
|
|
112
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. */
|
|
@@ -119,6 +138,54 @@ interface DataGridApi<Row> {
|
|
|
119
138
|
previousPage(): void;
|
|
120
139
|
/** Changes the page size, resetting to the first page. */
|
|
121
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;
|
|
122
189
|
/** Scrolls the row with the given id into view, if it is currently shown. */
|
|
123
190
|
scrollToRow(rowId: string, options?: ScrollIntoViewOptions): void;
|
|
124
191
|
/** Scrolls the column with the given id into view. */
|
|
@@ -133,32 +200,7 @@ interface DataGridApi<Row> {
|
|
|
133
200
|
*/
|
|
134
201
|
subscribe(listener: () => void): () => void;
|
|
135
202
|
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* How a column's width relates to the grid's.
|
|
139
|
-
*
|
|
140
|
-
* `"fit"` keeps the columns filling the grid: the space a column gives up is
|
|
141
|
-
* handed to the others, and the space it takes comes out of them. `"fixed"`
|
|
142
|
-
* lets every column keep its own width, so a resize moves one column and
|
|
143
|
-
* nothing else, and the grid scrolls or leaves a gap accordingly.
|
|
144
|
-
*/
|
|
145
|
-
type ResizeMode = "fit" | "fixed";
|
|
146
|
-
/**
|
|
147
|
-
* How the group-by bar's visibility follows the active grouping. `"always"`
|
|
148
|
-
* renders it even with an empty `groupBy` — a fixed drop target and a
|
|
149
|
-
* constant reminder grouping exists. `"never"` never renders it, for a grid
|
|
150
|
-
* driving `groupBy` entirely by its own UI (a header toggle, `Alt+ArrowDown`)
|
|
151
|
-
* or programmatically. `"auto"` renders it once `groupBy` is non-empty, or
|
|
152
|
-
* while a header drag eligible to drop into it is in progress — so there is
|
|
153
|
-
* always somewhere to drop the very first column, even from a fully empty
|
|
154
|
-
* grouping.
|
|
155
|
-
*/
|
|
156
|
-
type GroupByBarVisibility = "always" | "auto" | "never";
|
|
157
|
-
interface HoverableConfig {
|
|
158
|
-
rows?: boolean;
|
|
159
|
-
columns?: boolean;
|
|
160
|
-
cells?: boolean;
|
|
161
|
-
}
|
|
203
|
+
|
|
162
204
|
/**
|
|
163
205
|
* Everything a `pager.template` render prop needs to rebuild the built-in
|
|
164
206
|
* pager's UI itself. Passed fresh on every render where pagination-relevant
|
|
@@ -193,176 +235,59 @@ interface PagerConfig {
|
|
|
193
235
|
/** Replaces the built-in pager entirely when given. `variant` is ignored. */
|
|
194
236
|
template?: ((context: PagerTemplateContext) => ReactNode) | undefined;
|
|
195
237
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
*
|
|
205
|
-
* Called for every row on every change to `dataSource`, so it should be
|
|
206
|
-
* cheap and stable; an inline arrow is fine, one that re-reads the data is
|
|
207
|
-
* not.
|
|
208
|
-
*/
|
|
209
|
-
getRowId?: ((row: Row, index: number) => string) | undefined;
|
|
210
|
-
borders?: Borders | undefined;
|
|
211
|
-
hoverable?: HoverableConfig | undefined;
|
|
212
|
-
/**
|
|
213
|
-
* Which parts of the grid the user may select, and how many of each —
|
|
214
|
-
* `{ rows: "multiple", cells: "single" }`. A cell addresses one value, so it
|
|
215
|
-
* has no `"multiple"`.
|
|
216
|
-
*
|
|
217
|
-
* Off by default, unlike `hoverable`: selection claims the click, which a
|
|
218
|
-
* grid that only displays data should not do. Give `getRowId` alongside it
|
|
219
|
-
* for data that sorts, filters or pages, or a selection follows the position
|
|
220
|
-
* rather than the row.
|
|
221
|
-
*/
|
|
222
|
-
selectable?: SelectableConfig | undefined;
|
|
223
|
-
/** Row ids selected to start with, keyed as `getRowId` resolves them. Uncontrolled. */
|
|
224
|
-
defaultRowSelection?: SelectionState | undefined;
|
|
225
|
-
/** Column ids selected to start with. Uncontrolled. */
|
|
226
|
-
defaultColumnSelection?: SelectionState | undefined;
|
|
227
|
-
/** The cell selected to start with. Uncontrolled. */
|
|
228
|
-
defaultCellSelection?: CellSelectionState | undefined;
|
|
229
|
-
/** Whether columns can be dragged wider, unless a column says otherwise. */
|
|
230
|
-
resizableColumns?: boolean | undefined;
|
|
231
|
-
/**
|
|
232
|
-
* Whether columns can be dragged into a new position, unless a column says
|
|
233
|
-
* otherwise. Turning it off leaves an order the user already made in place.
|
|
234
|
-
*/
|
|
235
|
-
reorderableColumns?: boolean | undefined;
|
|
236
|
-
/**
|
|
237
|
-
* Whether columns fill the grid's width or sit at their own. Defaults to
|
|
238
|
-
* `"fit"`, under which columns the user has sized keep their width and the
|
|
239
|
-
* rest share what is left.
|
|
240
|
-
*/
|
|
241
|
-
resizeMode?: ResizeMode | undefined;
|
|
242
|
-
/** Column widths to start from, keyed by column id. Uncontrolled. */
|
|
243
|
-
defaultColumnSizing?: ColumnSizingState | undefined;
|
|
244
|
-
/**
|
|
245
|
-
* Column ids in the order to start in. Uncontrolled, and partial: ids it
|
|
246
|
-
* omits keep their position among `columns` and follow those it lists.
|
|
247
|
-
*/
|
|
248
|
-
defaultColumnOrder?: ColumnOrderState | undefined;
|
|
249
|
-
/**
|
|
250
|
-
* Sizes applied to columns that do not set their own — the width they start
|
|
251
|
-
* at and the bounds they may be resized between. Distinct from
|
|
252
|
-
* `defaultColumnSizing`, which sets specific columns' starting widths.
|
|
253
|
-
*/
|
|
254
|
-
columnSizeDefaults?: Partial<ColumnSizeDefaults> | undefined;
|
|
255
|
-
/**
|
|
256
|
-
* Called as the user resizes a column. Fires continuously with
|
|
257
|
-
* `phase: "move"` and once on release with `phase: "end"` — the latter being
|
|
258
|
-
* the one to persist. Auto-fit does not call it; it reports user intent only.
|
|
259
|
-
*/
|
|
260
|
-
onColumnResize?: ((event: ColumnResizeEvent) => void) | undefined;
|
|
261
|
-
/**
|
|
262
|
-
* Called once when the user drops a column somewhere new. A drop that leaves
|
|
263
|
-
* the order as it was does not call it.
|
|
264
|
-
*/
|
|
265
|
-
onColumnOrderChange?: ((event: ColumnOrderEvent) => void) | undefined;
|
|
266
|
-
/**
|
|
267
|
-
* Whether columns can be sorted by clicking their header toggle, unless a
|
|
268
|
-
* column says otherwise. Shift-click stacks a column into the sort instead
|
|
269
|
-
* of replacing it.
|
|
270
|
-
*/
|
|
271
|
-
sortableColumns?: boolean | undefined;
|
|
272
|
-
/** The sort to start with, in priority order. Uncontrolled. */
|
|
273
|
-
defaultColumnSort?: ColumnSortState | undefined;
|
|
274
|
-
/**
|
|
275
|
-
* Called once when the user changes the sort — a toggle, a stack, or a
|
|
276
|
-
* clear back to "none".
|
|
277
|
-
*/
|
|
278
|
-
onColumnSortChange?: ((event: ColumnSortEvent) => void) | undefined;
|
|
279
|
-
/**
|
|
280
|
-
* Whether columns can be grouped by — a header's click/`Alt+ArrowDown`
|
|
281
|
-
* toggle — unless a column says otherwise. The grouping itself still
|
|
282
|
-
* applies when this is off, via `defaultGroupBy` or the imperative API;
|
|
283
|
-
* this only gates that one interaction, the same way `sortableColumns`
|
|
284
|
-
* gates the sort toggle without disabling `defaultColumnSort`. Independent
|
|
285
|
-
* of `groupByBarVisibility` and `groupByDraggableColumns`, which gate the
|
|
286
|
-
* bar and the drag-in gesture respectively.
|
|
287
|
-
*/
|
|
288
|
-
groupableColumns?: boolean | undefined;
|
|
289
|
-
/**
|
|
290
|
-
* Whether a groupable header shows its group-toggle icon, unless a column
|
|
291
|
-
* says otherwise. Purely a rendering choice: `Alt+ArrowDown` keeps working
|
|
292
|
-
* on a groupable header with the icon hidden.
|
|
293
|
-
*/
|
|
294
|
-
groupToggleIconColumns?: boolean | undefined;
|
|
295
|
-
/**
|
|
296
|
-
* Whether a column's header may be dragged into the group-by bar to add
|
|
297
|
-
* it to the grouping, unless a column says otherwise. Independent of
|
|
298
|
-
* `groupableColumns`: a column can be groupable via its header's
|
|
299
|
-
* click/keyboard toggle, via this drag, both, or neither.
|
|
300
|
-
*/
|
|
301
|
-
groupByDraggableColumns?: boolean | undefined;
|
|
302
|
-
/** How the group-by bar's visibility follows the active grouping. */
|
|
303
|
-
groupByBarVisibility?: GroupByBarVisibility | undefined;
|
|
304
|
-
/** The group-by stack to start with, outer to inner. Uncontrolled. */
|
|
305
|
-
defaultGroupBy?: GroupByState | undefined;
|
|
306
|
-
/**
|
|
307
|
-
* Called once when the user changes the group-by stack — adding, removing,
|
|
308
|
-
* or reordering a level.
|
|
309
|
-
*/
|
|
310
|
-
onGroupByChange?: ((event: GroupByEvent) => void) | undefined;
|
|
311
|
-
/** Group keys collapsed to start with — every other group starts expanded. Uncontrolled. */
|
|
312
|
-
defaultGroupExpansion?: GroupExpansionState | undefined;
|
|
313
|
-
/** Called once when the user expands or collapses a group, or every group at once. */
|
|
314
|
-
onGroupExpansionChange?: ((event: GroupExpansionEvent) => void) | undefined;
|
|
315
|
-
/** The filter to start with — every applied entry, ANDed together. Uncontrolled. */
|
|
316
|
-
defaultFilter?: FilterState<Row> | undefined;
|
|
238
|
+
/**
|
|
239
|
+
* Loads more rows as the user scrolls near the bottom, in place of paging.
|
|
240
|
+
* Appends only — there is no equivalent of `paginated`'s reset-to-page-0 for
|
|
241
|
+
* a result set that shrinks out from under the current position.
|
|
242
|
+
*/
|
|
243
|
+
interface InfiniteScrollConfig {
|
|
244
|
+
/** Whether a further `onLoadMore` could still return more rows. `false` removes the sentinel entirely, so no further scrolling can trigger a load. */
|
|
245
|
+
readonly hasMore: boolean;
|
|
317
246
|
/**
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
*
|
|
247
|
+
* Called at most once per genuine threshold-crossing: fires when the
|
|
248
|
+
* sentinel comes within `rootMargin` of the body's viewport, and not again
|
|
249
|
+
* until `isLoadingMore` has gone back to `false`.
|
|
321
250
|
*/
|
|
322
|
-
|
|
251
|
+
readonly onLoadMore: () => void;
|
|
252
|
+
/** Whether a load triggered by `onLoadMore` is still in flight. Suppresses further calls to it until this goes back to `false`. */
|
|
253
|
+
readonly isLoadingMore?: boolean | undefined;
|
|
323
254
|
/**
|
|
324
|
-
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
255
|
+
* How far from the bottom of the scrollable body `onLoadMore` fires, ahead
|
|
256
|
+
* of the sentinel actually scrolling into view, as CSS margins — an
|
|
257
|
+
* intersection observer's `rootMargin`. Defaults to `"200px"`.
|
|
327
258
|
*/
|
|
328
|
-
|
|
259
|
+
readonly rootMargin?: string | undefined;
|
|
260
|
+
/** Replaces the built-in "Loading more…" row (`messages.loadingMore`). */
|
|
261
|
+
readonly loadingTemplate?: (() => ReactNode) | undefined;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* The props that name a React type, and so have no place in the
|
|
265
|
+
* framework-free `GridOptions`: columns whose templates return `ReactNode`,
|
|
266
|
+
* and the pager and infinite-scroll configs whose templates do too.
|
|
267
|
+
*/
|
|
268
|
+
interface ReactRenderSlots<Row> {
|
|
269
|
+
columns?: readonly ColumnDefinition<Row>[] | undefined;
|
|
329
270
|
/** Presentation options for the built-in pager. */
|
|
330
271
|
pager?: PagerConfig | undefined;
|
|
331
|
-
/** Called once when the user changes the page or the page size. */
|
|
332
|
-
onPaginationChange?: ((event: PaginationChangeEvent) => void) | undefined;
|
|
333
272
|
/**
|
|
334
|
-
*
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
*
|
|
339
|
-
* remove an aggregate interactively, so there is no `defaultAggregates`/
|
|
340
|
-
* `onAggregatesChange` pair to go with it.
|
|
273
|
+
* Loads more rows as the user scrolls near the bottom, instead of paging.
|
|
274
|
+
* Mutually exclusive with `paginated` — setting both logs a dev-time
|
|
275
|
+
* `console.error` and only `paginated` takes effect. Recommended (not
|
|
276
|
+
* required) alongside `virtualized` for a dataset that grows without
|
|
277
|
+
* bound, so the mounted row count never grows with it either.
|
|
341
278
|
*/
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
*/
|
|
351
|
-
groupAggregateDisplay?: GroupAggregateDisplay | undefined;
|
|
352
|
-
/**
|
|
353
|
-
* The grid's accessible name, announced when it takes focus. A grid without
|
|
354
|
-
* one is read only as "grid", which says nothing about which grid.
|
|
355
|
-
*/
|
|
356
|
-
label?: string | undefined;
|
|
357
|
-
/**
|
|
358
|
-
* The id of an element naming the grid, for a heading already on the page.
|
|
359
|
-
* Takes precedence over `label`, as `aria-labelledby` does.
|
|
360
|
-
*/
|
|
361
|
-
labelledBy?: string | undefined;
|
|
279
|
+
infiniteScroll?: InfiniteScrollConfig | undefined;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Every grid setting in `@gridkitjs/core`'s `GridOptions`, plus what only
|
|
283
|
+
* React can express: render slots, selection callbacks carrying React-bound
|
|
284
|
+
* columns, and the `ref`.
|
|
285
|
+
*/
|
|
286
|
+
interface DataGridProps<Row> extends GridOptions<Row>, ReactRenderSlots<Row>, SelectionCallbacks<Row> {
|
|
362
287
|
/** Imperative handle for reading live grid state and triggering actions. */
|
|
363
288
|
ref?: Ref<DataGridApi<Row>> | undefined;
|
|
364
289
|
}
|
|
365
|
-
declare function
|
|
290
|
+
declare function DataGrid<Row>(props: DataGridProps<Row>): react.JSX.Element;
|
|
366
291
|
|
|
367
292
|
interface PaginationStateApi {
|
|
368
293
|
pagination: PaginationState;
|
|
@@ -373,7 +298,7 @@ interface PaginationStateApi {
|
|
|
373
298
|
setPageSize: (pageSize: number) => void;
|
|
374
299
|
}
|
|
375
300
|
/**
|
|
376
|
-
* Reactive pagination state read off a mounted `
|
|
301
|
+
* Reactive pagination state read off a mounted `DataGrid`'s `ref`,
|
|
377
302
|
* for building a pager entirely outside the grid's own DOM — a toolbar or
|
|
378
303
|
* sidebar `pager.template` can't reach. Updates on every pagination change,
|
|
379
304
|
* including the silent page-0 reset a filter/sort/group change triggers,
|
|
@@ -392,12 +317,12 @@ interface GroupByStateApi {
|
|
|
392
317
|
}
|
|
393
318
|
/**
|
|
394
319
|
* Reactive group-by and group-expansion state read off a mounted
|
|
395
|
-
* `
|
|
320
|
+
* `DataGrid`'s `ref`, for a group-by bar or summary sidebar living
|
|
396
321
|
* outside the grid's own DOM.
|
|
397
322
|
*
|
|
398
|
-
* `
|
|
399
|
-
*
|
|
400
|
-
*
|
|
323
|
+
* The ref's `setGroupBy` and `setGroupExpansion` change the grouping and the
|
|
324
|
+
* collapsed groups for a custom group-by UI; this hook carries only the
|
|
325
|
+
* all-at-once expansion actions. A specific
|
|
401
326
|
* group's own computed aggregates are read off `getDisplayRows()`'s
|
|
402
327
|
* per-header `aggregates` field instead of a getter here — see
|
|
403
328
|
* `useAggregateState` for the grand-total equivalent.
|
|
@@ -408,12 +333,11 @@ interface GroupByStateApi {
|
|
|
408
333
|
declare function useGroupByState<Row>(gridRef: RefObject<DataGridApi<Row> | null>): GroupByStateApi;
|
|
409
334
|
|
|
410
335
|
/**
|
|
411
|
-
* Reactive column-sort state read off a mounted `
|
|
336
|
+
* Reactive column-sort state read off a mounted `DataGrid`'s `ref`,
|
|
412
337
|
* for a sort indicator living outside the grid's own DOM.
|
|
413
338
|
*
|
|
414
|
-
*
|
|
415
|
-
*
|
|
416
|
-
* `useGroupByState` has for group-by. Reads only.
|
|
339
|
+
* Reads only; change the sort through the ref's `setColumnSort`, or hold it
|
|
340
|
+
* yourself with the controlled `columnSort` prop.
|
|
417
341
|
*
|
|
418
342
|
* Before the grid mounts, reads as an empty array.
|
|
419
343
|
*/
|
|
@@ -428,7 +352,7 @@ interface SelectionStateApi {
|
|
|
428
352
|
}
|
|
429
353
|
/**
|
|
430
354
|
* Reactive row/column/cell selection state read off a mounted
|
|
431
|
-
* `
|
|
355
|
+
* `DataGrid`'s `ref`, for a "N rows selected" toolbar living
|
|
432
356
|
* outside the grid's own DOM. One combined hook rather than three, matching
|
|
433
357
|
* how `useGridSelection` already treats all three as one concern
|
|
434
358
|
* internally.
|
|
@@ -440,7 +364,7 @@ declare function useSelectionState<Row>(gridRef: RefObject<DataGridApi<Row> | nu
|
|
|
440
364
|
|
|
441
365
|
/**
|
|
442
366
|
* Reactive grand-total aggregate results read off a mounted
|
|
443
|
-
* `
|
|
367
|
+
* `DataGrid`'s `ref`, for a summary footer or bar living outside
|
|
444
368
|
* the grid's own DOM — mirroring the built-in one the grid renders itself.
|
|
445
369
|
*
|
|
446
370
|
* Read-only: `getAggregates` is already read-only on `DataGridApi`, computed
|
|
@@ -453,21 +377,46 @@ declare function useSelectionState<Row>(gridRef: RefObject<DataGridApi<Row> | nu
|
|
|
453
377
|
declare function useAggregateState<Row>(gridRef: RefObject<DataGridApi<Row> | null>): AggregateResults;
|
|
454
378
|
|
|
455
379
|
/**
|
|
456
|
-
* Reactive column-sizing state read off a mounted `
|
|
457
|
-
* `ref`.
|
|
458
|
-
*
|
|
380
|
+
* Reactive column-sizing state read off a mounted `DataGrid`'s
|
|
381
|
+
* `ref`. Reads only; change the widths through the ref's `setColumnSizing`,
|
|
382
|
+
* or hold them yourself with the controlled `columnSizing` prop.
|
|
459
383
|
*
|
|
460
384
|
* Before the grid mounts, reads as an empty object.
|
|
461
385
|
*/
|
|
462
386
|
declare function useColumnSizingState<Row>(gridRef: RefObject<DataGridApi<Row> | null>): ColumnSizingState;
|
|
463
387
|
|
|
464
388
|
/**
|
|
465
|
-
* Reactive column-order state read off a mounted `
|
|
466
|
-
* `ref`.
|
|
467
|
-
*
|
|
389
|
+
* Reactive column-order state read off a mounted `DataGrid`'s
|
|
390
|
+
* `ref`. Reads only; change the order through the ref's `setColumnOrder`,
|
|
391
|
+
* or hold it yourself with the controlled `columnOrder` prop.
|
|
468
392
|
*
|
|
469
393
|
* Before the grid mounts, reads as an empty array.
|
|
470
394
|
*/
|
|
471
395
|
declare function useColumnOrderState<Row>(gridRef: RefObject<DataGridApi<Row> | null>): ColumnOrderState;
|
|
472
396
|
|
|
473
|
-
|
|
397
|
+
/**
|
|
398
|
+
* Reactive column-visibility state read off a mounted `DataGrid`'s `ref` —
|
|
399
|
+
* the columns shown or hidden since it mounted, keyed by id. Read-only:
|
|
400
|
+
* change it through the ref's `showColumns`/`hideColumns`. A column absent
|
|
401
|
+
* from it follows its definition's `hidden`.
|
|
402
|
+
*
|
|
403
|
+
* Before the grid mounts, reads as an empty object.
|
|
404
|
+
*/
|
|
405
|
+
declare function useColumnVisibilityState<Row>(gridRef: RefObject<DataGridApi<Row> | null>): ColumnVisibilityState;
|
|
406
|
+
|
|
407
|
+
interface FilterStateApi<Row> {
|
|
408
|
+
filter: FilterState<Row>;
|
|
409
|
+
setFilter: (filter: FilterState<Row>) => void;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Reactive filter state read off a mounted `DataGrid`'s `ref`, for a filter
|
|
413
|
+
* bar or search box living outside the grid's own DOM — which, while the grid
|
|
414
|
+
* has no filter UI of its own, is where filtering happens. `setFilter`
|
|
415
|
+
* replaces the whole filter and sends the grid back to its first page.
|
|
416
|
+
*
|
|
417
|
+
* Before the grid mounts, `filter` reads as an empty array and `setFilter`
|
|
418
|
+
* is a no-op.
|
|
419
|
+
*/
|
|
420
|
+
declare function useFilterState<Row>(gridRef: RefObject<DataGridApi<Row> | null>): FilterStateApi<Row>;
|
|
421
|
+
|
|
422
|
+
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 };
|