@gridkitjs/react 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +101 -4
- package/dist/index.js +1019 -421
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
import { RowSelectEvent, RowsSelectEvent, RowSelectionChangeEvent, CellSelectEvent as CellSelectEvent$1, CellSelectionChangeEvent as CellSelectionChangeEvent$1, ColumnDefinition as ColumnDefinition$1, ColumnSelectEvent as ColumnSelectEvent$1, ColumnSelectionChangeEvent as ColumnSelectionChangeEvent$1, ColumnsSelectEvent as ColumnsSelectEvent$1,
|
|
2
|
+
import { ReactNode, Ref } from 'react';
|
|
3
|
+
import { RowSelectEvent, RowsSelectEvent, RowSelectionChangeEvent, CellSelectEvent as CellSelectEvent$1, CellSelectionChangeEvent as CellSelectionChangeEvent$1, ColumnDefinition as ColumnDefinition$1, ColumnSelectEvent as ColumnSelectEvent$1, ColumnSelectionChangeEvent as ColumnSelectionChangeEvent$1, ColumnsSelectEvent as ColumnsSelectEvent$1, ResolvedRow, DisplayRow, ResolvedColumn as ResolvedColumn$1, ColumnSizingState, ColumnOrderState, ColumnSortState, GroupByState, GroupExpansionState, SelectionState, CellSelectionState, SelectableConfig, ColumnSizeDefaults, ColumnResizeEvent, ColumnOrderEvent, ColumnSortEvent, GroupByEvent, GroupExpansionEvent, FilterState, SelectedCell as SelectedCell$1, SelectedColumn as SelectedColumn$1 } from '@gridkitjs/core';
|
|
4
4
|
export { CellSelectionMode, CellSelectionState, CellTemplateContext, ColumnResizeEvent, ColumnSizeDefaults, ColumnSizingState, ResolvedRow, RowSelectEvent, RowSelectionChangeEvent, RowsSelectEvent, SelectableConfig, SelectedCellRef, SelectionMode, SelectionState } from '@gridkitjs/core';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -53,6 +53,54 @@ type ColumnsSelectEvent<Row> = ColumnsSelectEvent$1<Row, ReactNode>;
|
|
|
53
53
|
type ColumnSelectionChangeEvent<Row> = ColumnSelectionChangeEvent$1<Row, ReactNode>;
|
|
54
54
|
type CellSelectEvent<Row> = CellSelectEvent$1<Row, ReactNode>;
|
|
55
55
|
type CellSelectionChangeEvent<Row> = CellSelectionChangeEvent$1<Row, ReactNode>;
|
|
56
|
+
/**
|
|
57
|
+
* Imperative handle for a mounted `DataGridComponent`, reached via its `ref`
|
|
58
|
+
* prop. Read-plus-standard-actions: getters mirror the grid's live state,
|
|
59
|
+
* and the actions are the ones every grid ref carries (focus, clear/select
|
|
60
|
+
* all, scroll-to). Sizing, order, sort, and selection stay uncontrolled via
|
|
61
|
+
* their existing `default*` props — this is not a second, imperative-only
|
|
62
|
+
* way to drive that same state.
|
|
63
|
+
*/
|
|
64
|
+
interface DataGridApi<Row> {
|
|
65
|
+
/** The grid's scrollable viewport element. */
|
|
66
|
+
readonly element: HTMLDivElement | null;
|
|
67
|
+
/** The grid's `<table>` element. */
|
|
68
|
+
readonly table: HTMLTableElement | null;
|
|
69
|
+
/** Rows as currently filtered and sorted — what's rendered, ungrouped. */
|
|
70
|
+
getRows(): readonly ResolvedRow<Row>[];
|
|
71
|
+
/**
|
|
72
|
+
* `getRows()` regrouped into the active `groupBy` — group headers
|
|
73
|
+
* interleaved with data rows, in render order. Identical to `getRows()`
|
|
74
|
+
* when `groupBy` is empty.
|
|
75
|
+
*/
|
|
76
|
+
getDisplayRows(): readonly DisplayRow<Row>[];
|
|
77
|
+
/** Columns as currently sized and ordered — what's rendered. */
|
|
78
|
+
getColumns(): readonly ResolvedColumn<Row>[];
|
|
79
|
+
getColumnSizing(): ColumnSizingState;
|
|
80
|
+
getColumnOrder(): ColumnOrderState;
|
|
81
|
+
getColumnSort(): ColumnSortState;
|
|
82
|
+
getGroupBy(): GroupByState;
|
|
83
|
+
getGroupExpansion(): GroupExpansionState;
|
|
84
|
+
getRowSelection(): SelectionState;
|
|
85
|
+
getColumnSelection(): SelectionState;
|
|
86
|
+
getCellSelection(): CellSelectionState;
|
|
87
|
+
/** The cell currently holding the grid's single tab stop. */
|
|
88
|
+
getFocusedCell(): {
|
|
89
|
+
rowIndex: number;
|
|
90
|
+
columnIndex: number;
|
|
91
|
+
};
|
|
92
|
+
focusCell(rowIndex: number, columnIndex: number): void;
|
|
93
|
+
clearSelection(): void;
|
|
94
|
+
selectAllRows(): void;
|
|
95
|
+
/** Expands every group at once — there is no dedicated UI control for it. */
|
|
96
|
+
expandAllGroups(): void;
|
|
97
|
+
/** 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. */
|
|
98
|
+
collapseAllGroups(): void;
|
|
99
|
+
/** Scrolls the row with the given id into view, if it is currently shown. */
|
|
100
|
+
scrollToRow(rowId: string, options?: ScrollIntoViewOptions): void;
|
|
101
|
+
/** Scrolls the column with the given id into view. */
|
|
102
|
+
scrollToColumn(columnId: string, options?: ScrollIntoViewOptions): void;
|
|
103
|
+
}
|
|
56
104
|
type Borders = "horizontal" | "vertical" | "all" | "none";
|
|
57
105
|
/**
|
|
58
106
|
* How a column's width relates to the grid's.
|
|
@@ -63,6 +111,17 @@ type Borders = "horizontal" | "vertical" | "all" | "none";
|
|
|
63
111
|
* nothing else, and the grid scrolls or leaves a gap accordingly.
|
|
64
112
|
*/
|
|
65
113
|
type ResizeMode = "fit" | "fixed";
|
|
114
|
+
/**
|
|
115
|
+
* How the group-by bar's visibility follows the active grouping. `"always"`
|
|
116
|
+
* renders it even with an empty `groupBy` — a fixed drop target and a
|
|
117
|
+
* constant reminder grouping exists. `"never"` never renders it, for a grid
|
|
118
|
+
* driving `groupBy` entirely by its own UI (a header toggle, `Alt+ArrowDown`)
|
|
119
|
+
* or programmatically. `"auto"` renders it once `groupBy` is non-empty, or
|
|
120
|
+
* while a header drag eligible to drop into it is in progress — so there is
|
|
121
|
+
* always somewhere to drop the very first column, even from a fully empty
|
|
122
|
+
* grouping.
|
|
123
|
+
*/
|
|
124
|
+
type GroupByBarVisibility = "always" | "auto" | "never";
|
|
66
125
|
interface HoverableConfig {
|
|
67
126
|
rows?: boolean;
|
|
68
127
|
columns?: boolean;
|
|
@@ -151,6 +210,42 @@ interface DataGridProps<Row> extends SelectionCallbacks<Row> {
|
|
|
151
210
|
* clear back to "none".
|
|
152
211
|
*/
|
|
153
212
|
onColumnSortChange?: ((event: ColumnSortEvent) => void) | undefined;
|
|
213
|
+
/**
|
|
214
|
+
* Whether columns can be grouped by — a header's click/`Alt+ArrowDown`
|
|
215
|
+
* toggle — unless a column says otherwise. The grouping itself still
|
|
216
|
+
* applies when this is off, via `defaultGroupBy` or the imperative API;
|
|
217
|
+
* this only gates that one interaction, the same way `sortableColumns`
|
|
218
|
+
* gates the sort toggle without disabling `defaultColumnSort`. Independent
|
|
219
|
+
* of `groupByBarVisibility` and `groupByDraggableColumns`, which gate the
|
|
220
|
+
* bar and the drag-in gesture respectively.
|
|
221
|
+
*/
|
|
222
|
+
groupableColumns?: boolean | undefined;
|
|
223
|
+
/**
|
|
224
|
+
* Whether a groupable header shows its group-toggle icon, unless a column
|
|
225
|
+
* says otherwise. Purely a rendering choice: `Alt+ArrowDown` keeps working
|
|
226
|
+
* on a groupable header with the icon hidden.
|
|
227
|
+
*/
|
|
228
|
+
groupToggleIconColumns?: boolean | undefined;
|
|
229
|
+
/**
|
|
230
|
+
* Whether a column's header may be dragged into the group-by bar to add
|
|
231
|
+
* it to the grouping, unless a column says otherwise. Independent of
|
|
232
|
+
* `groupableColumns`: a column can be groupable via its header's
|
|
233
|
+
* click/keyboard toggle, via this drag, both, or neither.
|
|
234
|
+
*/
|
|
235
|
+
groupByDraggableColumns?: boolean | undefined;
|
|
236
|
+
/** How the group-by bar's visibility follows the active grouping. */
|
|
237
|
+
groupByBarVisibility?: GroupByBarVisibility | undefined;
|
|
238
|
+
/** The group-by stack to start with, outer to inner. Uncontrolled. */
|
|
239
|
+
defaultGroupBy?: GroupByState | undefined;
|
|
240
|
+
/**
|
|
241
|
+
* Called once when the user changes the group-by stack — adding, removing,
|
|
242
|
+
* or reordering a level.
|
|
243
|
+
*/
|
|
244
|
+
onGroupByChange?: ((event: GroupByEvent) => void) | undefined;
|
|
245
|
+
/** Group keys collapsed to start with — every other group starts expanded. Uncontrolled. */
|
|
246
|
+
defaultGroupExpansion?: GroupExpansionState | undefined;
|
|
247
|
+
/** Called once when the user expands or collapses a group, or every group at once. */
|
|
248
|
+
onGroupExpansionChange?: ((event: GroupExpansionEvent) => void) | undefined;
|
|
154
249
|
/** The filter to start with — every applied entry, ANDed together. Uncontrolled. */
|
|
155
250
|
defaultFilter?: FilterState<Row> | undefined;
|
|
156
251
|
/**
|
|
@@ -163,7 +258,9 @@ interface DataGridProps<Row> extends SelectionCallbacks<Row> {
|
|
|
163
258
|
* Takes precedence over `label`, as `aria-labelledby` does.
|
|
164
259
|
*/
|
|
165
260
|
labelledBy?: string | undefined;
|
|
261
|
+
/** Imperative handle for reading live grid state and triggering actions. */
|
|
262
|
+
ref?: Ref<DataGridApi<Row>> | undefined;
|
|
166
263
|
}
|
|
167
|
-
declare function DataGridComponent<Row>({ dataSource, columns, getRowId, borders, hoverable, selectable, defaultRowSelection, defaultColumnSelection, defaultCellSelection, resizableColumns, reorderableColumns, resizeMode, defaultColumnSizing, defaultColumnOrder, columnSizeDefaults, onColumnResize, onColumnOrderChange, sortableColumns, defaultColumnSort, onColumnSortChange, defaultFilter, label, labelledBy, ...callbacks }: DataGridProps<Row>): react.JSX.Element;
|
|
264
|
+
declare function DataGridComponent<Row>({ dataSource, columns, getRowId, borders, hoverable, selectable, defaultRowSelection, defaultColumnSelection, defaultCellSelection, resizableColumns, reorderableColumns, resizeMode, defaultColumnSizing, defaultColumnOrder, columnSizeDefaults, onColumnResize, onColumnOrderChange, sortableColumns, defaultColumnSort, onColumnSortChange, groupableColumns, groupToggleIconColumns, groupByDraggableColumns, groupByBarVisibility, defaultGroupBy, onGroupByChange, defaultGroupExpansion, onGroupExpansionChange, defaultFilter, label, labelledBy, ref, ...callbacks }: DataGridProps<Row>): react.JSX.Element;
|
|
168
265
|
|
|
169
|
-
export { type CellSelectEvent, type CellSelectionChangeEvent, type ColumnDefinition, type ColumnSelectEvent, type ColumnSelectionChangeEvent, type ColumnsSelectEvent, DataGridComponent, type DataGridProps, type ResizeMode, type ResolvedColumn, type SelectedCell, type SelectedColumn };
|
|
266
|
+
export { type Borders, type CellSelectEvent, type CellSelectionChangeEvent, type ColumnDefinition, type ColumnSelectEvent, type ColumnSelectionChangeEvent, type ColumnsSelectEvent, type DataGridApi, DataGridComponent, type DataGridProps, type GroupByBarVisibility, type HoverableConfig, type ResizeMode, type ResolvedColumn, type SelectedCell, type SelectedColumn };
|