Skip to content

Commit

Permalink
[DataGrid] Use readonly on more array props (mui#13331)
Browse files Browse the repository at this point in the history
Co-authored-by: Rom Grk <romgrk.cc@gmail.com>
  • Loading branch information
2 people authored and thomasmoon committed Sep 6, 2024
1 parent fb15dea commit 0f86246
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 17 deletions.
8 changes: 5 additions & 3 deletions docs/pages/x/api/data-grid/grid-actions-col-def.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"field": { "type": { "description": "string" }, "required": true },
"getActions": {
"type": {
"description": "(params: GridRowParams&lt;R&gt;) =&gt; React.ReactElement&lt;GridActionsCellItemProps&gt;[]"
"description": "(params: GridRowParams&lt;R&gt;) =&gt; readonly React.ReactElement&lt;GridActionsCellItemProps&gt;[]"
},
"required": true
},
Expand All @@ -37,7 +37,9 @@
"display": { "type": { "description": "'text' | 'flex'" } },
"editable": { "type": { "description": "boolean" }, "default": "false" },
"filterable": { "type": { "description": "boolean" }, "default": "true" },
"filterOperators": { "type": { "description": "GridFilterOperator&lt;R, V, F&gt;[]" } },
"filterOperators": {
"type": { "description": "readonly GridFilterOperator&lt;R, V, F&gt;[]" }
},
"flex": { "type": { "description": "number" } },
"getApplyQuickFilterFn": { "type": { "description": "GetApplyQuickFilterFn&lt;R, V&gt;" } },
"getSortComparator": {
Expand Down Expand Up @@ -89,7 +91,7 @@
"resizable": { "type": { "description": "boolean" }, "default": "true" },
"sortable": { "type": { "description": "boolean" }, "default": "true" },
"sortComparator": { "type": { "description": "GridComparatorFn&lt;V&gt;" } },
"sortingOrder": { "type": { "description": "GridSortDirection[]" } },
"sortingOrder": { "type": { "description": "readonly GridSortDirection[]" } },
"valueFormatter": { "type": { "description": "GridValueFormatter&lt;R, V, F&gt;" } },
"valueGetter": { "type": { "description": "GridValueGetter&lt;R, V, F&gt;" } },
"valueParser": { "type": { "description": "GridValueParser&lt;R, V, F&gt;" } },
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/x/api/data-grid/grid-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@
},
"setRows": { "type": { "description": "(rows: GridRowModel[]) =&gt; void" }, "required": true },
"setRowSelectionModel": {
"type": { "description": "(rowIds: GridRowId[]) =&gt; void" },
"type": { "description": "(rowIds: readonly GridRowId[]) =&gt; void" },
"required": true
},
"setSortModel": {
Expand Down
6 changes: 4 additions & 2 deletions docs/pages/x/api/data-grid/grid-col-def.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
"display": { "type": { "description": "'text' | 'flex'" } },
"editable": { "type": { "description": "boolean" }, "default": "false" },
"filterable": { "type": { "description": "boolean" }, "default": "true" },
"filterOperators": { "type": { "description": "GridFilterOperator&lt;R, V, F&gt;[]" } },
"filterOperators": {
"type": { "description": "readonly GridFilterOperator&lt;R, V, F&gt;[]" }
},
"flex": { "type": { "description": "number" } },
"getApplyQuickFilterFn": { "type": { "description": "GetApplyQuickFilterFn&lt;R, V&gt;" } },
"getSortComparator": {
Expand Down Expand Up @@ -82,7 +84,7 @@
"resizable": { "type": { "description": "boolean" }, "default": "true" },
"sortable": { "type": { "description": "boolean" }, "default": "true" },
"sortComparator": { "type": { "description": "GridComparatorFn&lt;V&gt;" } },
"sortingOrder": { "type": { "description": "GridSortDirection[]" } },
"sortingOrder": { "type": { "description": "readonly GridSortDirection[]" } },
"type": { "type": { "description": "GridColType" }, "default": "'singleSelect'" },
"valueFormatter": { "type": { "description": "GridValueFormatter&lt;R, V, F&gt;" } },
"valueGetter": { "type": { "description": "GridValueGetter&lt;R, V, F&gt;" } },
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/x/api/data-grid/grid-row-selection-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
{
"name": "setRowSelectionModel",
"description": "Updates the selected rows to be those passed to the <code>rowIds</code> argument. Any row already selected will be unselected.",
"type": "(rowIds: GridRowId[]) => void"
"type": "(rowIds: readonly GridRowId[]) => void"
}
]
}
6 changes: 4 additions & 2 deletions docs/pages/x/api/data-grid/grid-single-select-col-def.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
"display": { "type": { "description": "'text' | 'flex'" } },
"editable": { "type": { "description": "boolean" }, "default": "false" },
"filterable": { "type": { "description": "boolean" }, "default": "true" },
"filterOperators": { "type": { "description": "GridFilterOperator&lt;R, V, F&gt;[]" } },
"filterOperators": {
"type": { "description": "readonly GridFilterOperator&lt;R, V, F&gt;[]" }
},
"flex": { "type": { "description": "number" } },
"getApplyQuickFilterFn": { "type": { "description": "GetApplyQuickFilterFn&lt;R, V&gt;" } },
"getOptionLabel": { "type": { "description": "(value: ValueOptions) =&gt; string" } },
Expand Down Expand Up @@ -89,7 +91,7 @@
"resizable": { "type": { "description": "boolean" }, "default": "true" },
"sortable": { "type": { "description": "boolean" }, "default": "true" },
"sortComparator": { "type": { "description": "GridComparatorFn&lt;V&gt;" } },
"sortingOrder": { "type": { "description": "GridSortDirection[]" } },
"sortingOrder": { "type": { "description": "readonly GridSortDirection[]" } },
"valueFormatter": { "type": { "description": "GridValueFormatter&lt;R, V, F&gt;" } },
"valueGetter": { "type": { "description": "GridValueGetter&lt;R, V, F&gt;" } },
"valueOptions": {
Expand Down
4 changes: 2 additions & 2 deletions packages/x-data-grid/src/models/api/gridRowSelectionApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export interface GridRowSelectionApi {
/**
* Updates the selected rows to be those passed to the `rowIds` argument.
* Any row already selected will be unselected.
* @param {GridRowId[]} rowIds The row ids to select.
* @param {readonly GridRowId[]} rowIds The row ids to select.
*/
setRowSelectionModel: (rowIds: GridRowId[]) => void;
setRowSelectionModel: (rowIds: readonly GridRowId[]) => void;
}

export interface GridRowMultiSelectionApi {
Expand Down
8 changes: 4 additions & 4 deletions packages/x-data-grid/src/models/colDef/gridColDef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export interface GridBaseColDef<R extends GridValidRowModel = GridValidRowModel,
/**
* The order of the sorting sequence.
*/
sortingOrder?: GridSortDirection[];
sortingOrder?: readonly GridSortDirection[];
/**
* If `true`, the column is resizable.
* @default true
Expand Down Expand Up @@ -264,7 +264,7 @@ export interface GridBaseColDef<R extends GridValidRowModel = GridValidRowModel,
/**
* Allows setting the filter operators for this column.
*/
filterOperators?: GridFilterOperator<R, V, F>[];
filterOperators?: readonly GridFilterOperator<R, V, F>[];
/**
* The callback that generates a filtering function for a given quick filter value.
* This function can return `null` to skip filtering for this value and column.
Expand Down Expand Up @@ -306,9 +306,9 @@ export interface GridActionsColDef<R extends GridValidRowModel = any, V = any, F
/**
* Function that returns the actions to be shown.
* @param {GridRowParams} params The params for each row.
* @returns {React.ReactElement<GridActionsCellItemProps>[]} An array of [[GridActionsCell]] elements.
* @returns {readonly React.ReactElement<GridActionsCellItemProps>[]} An array of [[GridActionsCell]] elements.
*/
getActions: (params: GridRowParams<R>) => React.ReactElement<GridActionsCellItemProps>[];
getActions: (params: GridRowParams<R>) => readonly React.ReactElement<GridActionsCellItemProps>[];
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/x-data-grid/src/models/gridRowSelectionModel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GridRowId } from './gridRows';

export type GridInputRowSelectionModel = GridRowId[] | GridRowId;
export type GridInputRowSelectionModel = readonly GridRowId[] | GridRowId;

export type GridRowSelectionModel = GridRowId[];
export type GridRowSelectionModel = readonly GridRowId[];

0 comments on commit 0f86246

Please sign in to comment.