Skip to content

Commit 45d30f1

Browse files
committed
More updates
1 parent 3a6622c commit 45d30f1

2 files changed

Lines changed: 38 additions & 29 deletions

File tree

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Rows pinned at the bottom of the grid for summary purposes.
113113

114114
###### `rowKeyGetter?: Maybe<(row: R) => K>`
115115

116-
A function returning a unique key/identifier per row. `rowKeyGetter` is required for row selection to work.
116+
Function to return a unique key/identifier for each row. `rowKeyGetter` is required for row selection to work.
117117

118118
```tsx
119119
import { DataGrid } from 'react-data-grid';
@@ -136,7 +136,8 @@ function MyGrid() {
136136

137137
###### `onRowsChange?: Maybe<(rows: R[], data: RowsChangeData<R, SR>) => void>`
138138

139-
A function receiving row updates.
139+
Callback triggered when rows are updated.
140+
140141
The first parameter is a new rows array with both the updated rows and the other untouched rows.
141142
The second parameter is an object with an `indexes` array highlighting which rows have changed by their index, and the `column` where the change happened.
142143

@@ -155,7 +156,7 @@ function MyGrid() {
155156

156157
**Default:** `35` pixels
157158

158-
Either a number defining the height of row in pixels, or a function returning dynamic row heights.
159+
Height of each row in pixels. A function can be used to set different row heights.
159160

160161
###### `headerRowHeight?: Maybe<number>`
161162

@@ -175,11 +176,11 @@ A set of selected row keys. `rowKeyGetter` is required for row selection to work
175176

176177
###### `isRowSelectionDisabled?: Maybe<(row: NoInfer<R>) => boolean>`
177178

178-
A function used to disable row selection on certain rows.
179+
Function to determine if row selection is disabled for a specific row.
179180

180181
###### `onSelectedRowsChange?: Maybe<(selectedRows: Set<K>) => void>`
181182

182-
A function called when row selection is changed.
183+
Function called whenever row selection is changed.
183184

184185
```tsx
185186
import { useState } from 'react';
@@ -218,11 +219,11 @@ function isRowSelectionDisabled(row: Row) {
218219

219220
###### `sortColumns?: Maybe<readonly SortColumn[]>`
220221

221-
An array of sorted columns.
222+
An array of sorted columns. Sorting can be done on multiple columns.
222223

223224
###### `onSortColumnsChange?: Maybe<(sortColumns: SortColumn[]) => void>`
224225

225-
A function called when sorting is changed.
226+
Callback triggered when sorting changes.
226227

227228
```tsx
228229
import { useState } from 'react';
@@ -286,7 +287,7 @@ function MyGrid() {
286287

287288
###### `onCellClick?: Maybe<(args: CellClickArgs<R, SR>, event: CellMouseEvent) => void>`
288289

289-
Triggered when a cell is clicked. The default behavior is to select the cell. Call `preventGridDefault` to prevent the default behavior
290+
Callback triggered when a cell is clicked. The default behavior is to select the cell. Call `preventGridDefault` to prevent the default behavior
290291

291292
```tsx
292293
function onCellClick(args: CellClickArgs<R, SR>, event: CellMouseEvent) {
@@ -677,7 +678,7 @@ Enables cell editing. If set and no editor property specified, then a textinput
677678

678679
**Default**: `false`
679680

680-
Determines whether column is frozen. Frozem columns are pinned on th left. At the moment
681+
Determines whether column is frozen. Frozen columns are pinned on the left. At the moment we do not support pinning columns on the right.
681682

682683
##### `resizable?: Maybe<boolean>`
683684

src/DataGrid.tsx

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -132,83 +132,85 @@ export interface DataGridProps<R, SR = unknown, K extends Key = Key> extends Sha
132132
columns: readonly ColumnOrColumnGroup<NoInfer<R>, NoInfer<SR>>[];
133133
/** A function called for each rendered row that should return a plain key/value pair object */
134134
rows: readonly R[];
135-
/**
136-
* Rows to be pinned at the top of the rows view for summary, the vertical scroll bar will not scroll these rows.
137-
*/
135+
/** Rows pinned at the top of the grid for summary purposes */
138136
topSummaryRows?: Maybe<readonly SR[]>;
139-
/**
140-
* Rows to be pinned at the bottom of the rows view for summary, the vertical scroll bar will not scroll these rows.
141-
*/
137+
/** Rows pinned at the bottom of the grid for summary purposes */
142138
bottomSummaryRows?: Maybe<readonly SR[]>;
143-
/** The getter should return a unique key for each row */
139+
/** Function to return a unique key/identifier for each row */
144140
rowKeyGetter?: Maybe<(row: NoInfer<R>) => K>;
141+
/** Callback triggered when rows are updated */
145142
onRowsChange?: Maybe<(rows: NoInfer<R>[], data: RowsChangeData<NoInfer<R>, NoInfer<SR>>) => void>;
146143

147144
/**
148145
* Dimensions props
149146
*/
150147
/**
151-
* The height of each row in pixels
148+
* Height of each row in pixels
152149
* @default 35
153150
*/
154151
rowHeight?: Maybe<number | ((row: NoInfer<R>) => number)>;
155152
/**
156-
* The height of the header row in pixels
153+
* Height of the header row in pixels
157154
* @default 35
158155
*/
159156
headerRowHeight?: Maybe<number>;
160157
/**
161-
* The height of each summary row in pixels
158+
* Height of each summary row in pixels
162159
* @default 35
163160
*/
164161
summaryRowHeight?: Maybe<number>;
165162

166163
/**
167164
* Feature props
168165
*/
169-
/** Set of selected row keys */
166+
/** A set of selected row keys */
170167
selectedRows?: Maybe<ReadonlySet<K>>;
171-
/** Determines if row selection is disabled, per row */
168+
/** Function to determine if row selection is disabled for a specific row */
172169
isRowSelectionDisabled?: Maybe<(row: NoInfer<R>) => boolean>;
173170
/** Function called whenever row selection is changed */
174171
onSelectedRowsChange?: Maybe<(selectedRows: Set<NoInfer<K>>) => void>;
175-
/** Used for multi column sorting */
172+
/** An array of sorted columns */
176173
sortColumns?: Maybe<readonly SortColumn[]>;
174+
/** Callback triggered when sorting changes */
177175
onSortColumnsChange?: Maybe<(sortColumns: SortColumn[]) => void>;
176+
/** Default options applied to all columns */
178177
defaultColumnOptions?: Maybe<DefaultColumnOptions<NoInfer<R>, NoInfer<SR>>>;
179178
onFill?: Maybe<(event: FillEvent<NoInfer<R>>) => NoInfer<R>>;
180179

181180
/**
182181
* Event props
183182
*/
184-
/** Function called whenever a cell is clicked */
183+
/** Callback triggered when a cell is clicked */
185184
onCellClick?: Maybe<
186185
(args: CellClickArgs<NoInfer<R>, NoInfer<SR>>, event: CellMouseEvent) => void
187186
>;
188-
/** Function called whenever a cell is double clicked */
187+
/** Callback triggered when a cell is double-clicked */
189188
onCellDoubleClick?: Maybe<
190189
(args: CellClickArgs<NoInfer<R>, NoInfer<SR>>, event: CellMouseEvent) => void
191190
>;
192-
/** Function called whenever a cell is right clicked */
191+
/** Callback triggered when a cell is right-clicked */
193192
onCellContextMenu?: Maybe<
194193
(args: CellClickArgs<NoInfer<R>, NoInfer<SR>>, event: CellMouseEvent) => void
195194
>;
195+
/** Callback triggered when a key is pressed in a cell */
196196
onCellKeyDown?: Maybe<
197197
(args: CellKeyDownArgs<NoInfer<R>, NoInfer<SR>>, event: CellKeyboardEvent) => void
198198
>;
199+
/** Callback triggered when a cell's content is copied */
199200
onCellCopy?: Maybe<
200201
(args: CellCopyEvent<NoInfer<R>, NoInfer<SR>>, event: CellClipboardEvent) => void
201202
>;
203+
/** Callback triggered when content is pasted into a cell */
202204
onCellPaste?: Maybe<
203205
(args: CellPasteEvent<NoInfer<R>, NoInfer<SR>>, event: CellClipboardEvent) => NoInfer<R>
204206
>;
205207
/** Function called whenever cell selection is changed */
206208
onSelectedCellChange?: Maybe<(args: CellSelectArgs<NoInfer<R>, NoInfer<SR>>) => void>;
207-
/** Called when the grid is scrolled */
209+
/** Callback triggered when the grid is scrolled */
208210
onScroll?: Maybe<(event: React.UIEvent<HTMLDivElement>) => void>;
209-
/** Called when a column is resized */
211+
/** Callback triggered when column is resized */
210212
onColumnResize?: Maybe<(column: CalculatedColumn<R, SR>, width: number) => void>;
211-
/** Called when a column is reordered */
213+
/** Callback triggered when columns are reordered */
212214
onColumnsReorder?: Maybe<(sourceColumnKey: string, targetColumnKey: string) => void>;
213215

214216
/**
@@ -220,10 +222,16 @@ export interface DataGridProps<R, SR = unknown, K extends Key = Key> extends Sha
220222
/**
221223
* Miscellaneous
222224
*/
225+
/** Custom renderers for cells, rows, and other components */
223226
renderers?: Maybe<Renderers<NoInfer<R>, NoInfer<SR>>>;
227+
/** Function to apply custom class names to rows */
224228
rowClass?: Maybe<(row: NoInfer<R>, rowIdx: number) => Maybe<string>>;
229+
/** Custom class name for the header row */
225230
headerRowClass?: Maybe<string>;
226-
/** @default 'ltr' */
231+
/**
232+
* Text direction of the grid ('ltr' or 'rtl')
233+
* @default 'ltr'
234+
* */
227235
direction?: Maybe<Direction>;
228236
'data-testid'?: Maybe<string>;
229237
'data-cy'?: Maybe<string>;

0 commit comments

Comments
 (0)