Skip to content

Commit 42195d6

Browse files
pcorpetromgrk
andauthored
[DataGrid] Use readonly on more array props (#13331)
Co-authored-by: Rom Grk <[email protected]>
1 parent 8acc141 commit 42195d6

File tree

8 files changed

+23
-17
lines changed

8 files changed

+23
-17
lines changed

docs/pages/x/api/data-grid/grid-actions-col-def.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"field": { "type": { "description": "string" }, "required": true },
1111
"getActions": {
1212
"type": {
13-
"description": "(params: GridRowParams&lt;R&gt;) =&gt; React.ReactElement&lt;GridActionsCellItemProps&gt;[]"
13+
"description": "(params: GridRowParams&lt;R&gt;) =&gt; readonly React.ReactElement&lt;GridActionsCellItemProps&gt;[]"
1414
},
1515
"required": true
1616
},
@@ -37,7 +37,9 @@
3737
"display": { "type": { "description": "'text' | 'flex'" } },
3838
"editable": { "type": { "description": "boolean" }, "default": "false" },
3939
"filterable": { "type": { "description": "boolean" }, "default": "true" },
40-
"filterOperators": { "type": { "description": "GridFilterOperator&lt;R, V, F&gt;[]" } },
40+
"filterOperators": {
41+
"type": { "description": "readonly GridFilterOperator&lt;R, V, F&gt;[]" }
42+
},
4143
"flex": { "type": { "description": "number" } },
4244
"getApplyQuickFilterFn": { "type": { "description": "GetApplyQuickFilterFn&lt;R, V&gt;" } },
4345
"getSortComparator": {
@@ -89,7 +91,7 @@
8991
"resizable": { "type": { "description": "boolean" }, "default": "true" },
9092
"sortable": { "type": { "description": "boolean" }, "default": "true" },
9193
"sortComparator": { "type": { "description": "GridComparatorFn&lt;V&gt;" } },
92-
"sortingOrder": { "type": { "description": "GridSortDirection[]" } },
94+
"sortingOrder": { "type": { "description": "readonly GridSortDirection[]" } },
9395
"valueFormatter": { "type": { "description": "GridValueFormatter&lt;R, V, F&gt;" } },
9496
"valueGetter": { "type": { "description": "GridValueGetter&lt;R, V, F&gt;" } },
9597
"valueParser": { "type": { "description": "GridValueParser&lt;R, V, F&gt;" } },

docs/pages/x/api/data-grid/grid-api.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@
395395
},
396396
"setRows": { "type": { "description": "(rows: GridRowModel[]) =&gt; void" }, "required": true },
397397
"setRowSelectionModel": {
398-
"type": { "description": "(rowIds: GridRowId[]) =&gt; void" },
398+
"type": { "description": "(rowIds: readonly GridRowId[]) =&gt; void" },
399399
"required": true
400400
},
401401
"setSortModel": {

docs/pages/x/api/data-grid/grid-col-def.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
"display": { "type": { "description": "'text' | 'flex'" } },
3131
"editable": { "type": { "description": "boolean" }, "default": "false" },
3232
"filterable": { "type": { "description": "boolean" }, "default": "true" },
33-
"filterOperators": { "type": { "description": "GridFilterOperator&lt;R, V, F&gt;[]" } },
33+
"filterOperators": {
34+
"type": { "description": "readonly GridFilterOperator&lt;R, V, F&gt;[]" }
35+
},
3436
"flex": { "type": { "description": "number" } },
3537
"getApplyQuickFilterFn": { "type": { "description": "GetApplyQuickFilterFn&lt;R, V&gt;" } },
3638
"getSortComparator": {
@@ -82,7 +84,7 @@
8284
"resizable": { "type": { "description": "boolean" }, "default": "true" },
8385
"sortable": { "type": { "description": "boolean" }, "default": "true" },
8486
"sortComparator": { "type": { "description": "GridComparatorFn&lt;V&gt;" } },
85-
"sortingOrder": { "type": { "description": "GridSortDirection[]" } },
87+
"sortingOrder": { "type": { "description": "readonly GridSortDirection[]" } },
8688
"type": { "type": { "description": "GridColType" }, "default": "'singleSelect'" },
8789
"valueFormatter": { "type": { "description": "GridValueFormatter&lt;R, V, F&gt;" } },
8890
"valueGetter": { "type": { "description": "GridValueGetter&lt;R, V, F&gt;" } },

docs/pages/x/api/data-grid/grid-row-selection-api.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
{
2626
"name": "setRowSelectionModel",
2727
"description": "Updates the selected rows to be those passed to the <code>rowIds</code> argument. Any row already selected will be unselected.",
28-
"type": "(rowIds: GridRowId[]) => void"
28+
"type": "(rowIds: readonly GridRowId[]) => void"
2929
}
3030
]
3131
}

docs/pages/x/api/data-grid/grid-single-select-col-def.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@
3535
"display": { "type": { "description": "'text' | 'flex'" } },
3636
"editable": { "type": { "description": "boolean" }, "default": "false" },
3737
"filterable": { "type": { "description": "boolean" }, "default": "true" },
38-
"filterOperators": { "type": { "description": "GridFilterOperator&lt;R, V, F&gt;[]" } },
38+
"filterOperators": {
39+
"type": { "description": "readonly GridFilterOperator&lt;R, V, F&gt;[]" }
40+
},
3941
"flex": { "type": { "description": "number" } },
4042
"getApplyQuickFilterFn": { "type": { "description": "GetApplyQuickFilterFn&lt;R, V&gt;" } },
4143
"getOptionLabel": { "type": { "description": "(value: ValueOptions) =&gt; string" } },
@@ -89,7 +91,7 @@
8991
"resizable": { "type": { "description": "boolean" }, "default": "true" },
9092
"sortable": { "type": { "description": "boolean" }, "default": "true" },
9193
"sortComparator": { "type": { "description": "GridComparatorFn&lt;V&gt;" } },
92-
"sortingOrder": { "type": { "description": "GridSortDirection[]" } },
94+
"sortingOrder": { "type": { "description": "readonly GridSortDirection[]" } },
9395
"valueFormatter": { "type": { "description": "GridValueFormatter&lt;R, V, F&gt;" } },
9496
"valueGetter": { "type": { "description": "GridValueGetter&lt;R, V, F&gt;" } },
9597
"valueOptions": {

packages/x-data-grid/src/models/api/gridRowSelectionApi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ export interface GridRowSelectionApi {
3131
/**
3232
* Updates the selected rows to be those passed to the `rowIds` argument.
3333
* Any row already selected will be unselected.
34-
* @param {GridRowId[]} rowIds The row ids to select.
34+
* @param {readonly GridRowId[]} rowIds The row ids to select.
3535
*/
36-
setRowSelectionModel: (rowIds: GridRowId[]) => void;
36+
setRowSelectionModel: (rowIds: readonly GridRowId[]) => void;
3737
}
3838

3939
export interface GridRowMultiSelectionApi {

packages/x-data-grid/src/models/colDef/gridColDef.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export interface GridBaseColDef<R extends GridValidRowModel = GridValidRowModel,
134134
/**
135135
* The order of the sorting sequence.
136136
*/
137-
sortingOrder?: GridSortDirection[];
137+
sortingOrder?: readonly GridSortDirection[];
138138
/**
139139
* If `true`, the column is resizable.
140140
* @default true
@@ -264,7 +264,7 @@ export interface GridBaseColDef<R extends GridValidRowModel = GridValidRowModel,
264264
/**
265265
* Allows setting the filter operators for this column.
266266
*/
267-
filterOperators?: GridFilterOperator<R, V, F>[];
267+
filterOperators?: readonly GridFilterOperator<R, V, F>[];
268268
/**
269269
* The callback that generates a filtering function for a given quick filter value.
270270
* This function can return `null` to skip filtering for this value and column.
@@ -306,9 +306,9 @@ export interface GridActionsColDef<R extends GridValidRowModel = any, V = any, F
306306
/**
307307
* Function that returns the actions to be shown.
308308
* @param {GridRowParams} params The params for each row.
309-
* @returns {React.ReactElement<GridActionsCellItemProps>[]} An array of [[GridActionsCell]] elements.
309+
* @returns {readonly React.ReactElement<GridActionsCellItemProps>[]} An array of [[GridActionsCell]] elements.
310310
*/
311-
getActions: (params: GridRowParams<R>) => React.ReactElement<GridActionsCellItemProps>[];
311+
getActions: (params: GridRowParams<R>) => readonly React.ReactElement<GridActionsCellItemProps>[];
312312
}
313313

314314
/**
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { GridRowId } from './gridRows';
22

3-
export type GridInputRowSelectionModel = GridRowId[] | GridRowId;
3+
export type GridInputRowSelectionModel = readonly GridRowId[] | GridRowId;
44

5-
export type GridRowSelectionModel = GridRowId[];
5+
export type GridRowSelectionModel = readonly GridRowId[];

0 commit comments

Comments
 (0)