From 2d912d78228f57842b911b045d54980e3e4eb1ef Mon Sep 17 00:00:00 2001 From: Jan Potoms <2109932+Janpot@users.noreply.github.com> Date: Wed, 2 Nov 2022 03:02:38 -0700 Subject: [PATCH] [core] Fixes for upcoming eslint upgrade (#6667) --- benchmark/browser/scripts/benchmark.js | 4 +- .../accessibility/FocusManagement.js | 16 ++-- .../accessibility/FocusManagement.tsx | 16 ++-- .../data-grid/api-object/UseGridApiContext.js | 4 +- .../api-object/UseGridApiContext.tsx | 4 +- .../column-definition/RenderCellGrid.js | 4 +- .../column-definition/RenderCellGrid.tsx | 4 +- .../column-groups/CustomizationDemo.js | 4 +- .../column-groups/CustomizationDemo.tsx | 4 +- .../data-grid/demo/PopularFeaturesDemo.js | 12 +-- .../data-grid/demo/PopularFeaturesDemo.tsx | 12 +-- .../editing/AskConfirmationBeforeSave.js | 6 +- .../editing/AskConfirmationBeforeSave.tsx | 6 +- .../editing/ServerSidePersistence.js | 6 +- .../editing/ServerSidePersistence.tsx | 6 +- .../data-grid/events/CatalogOfEventsNoSnap.js | 16 ++-- .../data-grid/events/SubscribeToEventsHook.js | 4 +- .../events/SubscribeToEventsHook.tsx | 4 +- .../data-grid/export/CsvGetRowsToExport.js | 4 +- .../data-grid/export/CsvGetRowsToExport.tsx | 4 +- .../export/CsvGetRowsToExportRowGrouping.js | 4 +- .../export/CsvGetRowsToExportRowGrouping.tsx | 4 +- docs/data/data-grid/export/CustomExport.js | 32 ++++---- docs/data/data-grid/export/CustomExport.tsx | 30 ++++--- .../filtering/CustomFilterPanelPosition.js | 12 +-- .../filtering/CustomFilterPanelPosition.tsx | 16 ++-- .../LinkedFieldsCellEditing.js | 4 +- .../LinkedFieldsCellEditing.tsx | 4 +- .../recipes-editing/LinkedFieldsRowEditing.js | 4 +- .../LinkedFieldsRowEditing.tsx | 4 +- .../recipes-editing/MultilineEditing.js | 4 +- .../recipes-editing/MultilineEditing.tsx | 4 +- .../data-grid/row-height/ExpandableCells.js | 4 +- .../data-grid/row-height/ExpandableCells.tsx | 4 +- .../data-grid/state/RestoreStateApiRef.js | 8 +- .../data-grid/state/RestoreStateApiRef.tsx | 12 +-- .../state/RestoreStateInitialState.js | 4 +- .../state/RestoreStateInitialState.tsx | 6 +- docs/data/data-grid/state/UseGridSelector.js | 4 +- docs/data/data-grid/state/UseGridSelector.tsx | 4 +- .../tree-data/TreeDataCustomGroupingColumn.js | 4 +- .../TreeDataCustomGroupingColumn.tsx | 4 +- .../tree-data/TreeDataLazyLoading.js | 4 +- .../tree-data/TreeDataLazyLoading.tsx | 4 +- .../custom-components/ActionBarComponent.js | 4 +- .../custom-components/ActionBarComponent.tsx | 4 +- .../PaperContentComponent.js | 8 +- .../PaperContentComponent.tsx | 20 +++-- .../date-pickers/custom-components/Tabs.js | 14 ++-- .../date-pickers/custom-components/Tabs.tsx | 14 ++-- .../DateTimeRangeFieldValue.js | 4 +- .../DateTimeRangeFieldValue.tsx | 6 +- .../fields/DateRangeFieldExamples.js | 4 +- .../fields/DateRangeFieldExamples.tsx | 6 +- .../fields/SingleDateFieldExamples.js | 4 +- .../fields/SingleDateFieldExamples.tsx | 6 +- .../getting-started/InstructionsNoSnap.js | 4 +- .../time-range-field/TimeRangeFieldValue.js | 4 +- .../time-range-field/TimeRangeFieldValue.tsx | 6 +- .../DateTimeValidationMaxDateTime.js | 4 +- .../DateTimeValidationMaxDateTime.tsx | 6 +- .../DateTimeValidationMinDateTime.js | 4 +- .../DateTimeValidationMinDateTime.tsx | 6 +- .../validation/DateValidationDisableFuture.js | 4 +- .../DateValidationDisableFuture.tsx | 6 +- .../validation/DateValidationDisablePast.js | 4 +- .../validation/DateValidationDisablePast.tsx | 6 +- .../validation/DateValidationMaxDate.js | 4 +- .../validation/DateValidationMaxDate.tsx | 6 +- .../validation/DateValidationMinDate.js | 4 +- .../validation/DateValidationMinDate.tsx | 6 +- .../DateValidationShouldDisableDate.js | 4 +- .../DateValidationShouldDisableDate.tsx | 6 +- .../DateValidationShouldDisableMonth.js | 4 +- .../DateValidationShouldDisableMonth.tsx | 6 +- .../DateValidationShouldDisableYear.js | 4 +- .../DateValidationShouldDisableYear.tsx | 6 +- .../validation/TimeValidationMaxTime.js | 4 +- .../validation/TimeValidationMaxTime.tsx | 6 +- .../validation/TimeValidationMinTime.js | 4 +- .../validation/TimeValidationMinTime.tsx | 6 +- .../TimeValidationShouldDisableTime.js | 4 +- .../TimeValidationShouldDisableTime.tsx | 6 +- docs/pages/_app.js | 4 +- docs/scripts/helpers.js | 2 +- docs/src/modules/components/SelectorsDocs.js | 4 +- .../src/renderer/renderEditProgress.tsx | 4 +- .../GridAggregationColumnMenuItem.tsx | 4 +- .../src/components/GridAggregationHeader.tsx | 4 +- .../components/GridExcelExportMenuItem.tsx | 4 +- .../src/components/GridFooterCell.tsx | 4 +- .../GridGroupingColumnFooterCell.tsx | 4 +- .../components/GridGroupingColumnLeafCell.tsx | 4 +- .../components/GridGroupingCriteriaCell.tsx | 4 +- .../GridRowGroupableColumnMenuItems.tsx | 4 +- .../GridRowGroupingColumnMenuItems.tsx | 4 +- .../useGridAggregationPreProcessors.tsx | 4 +- .../rowGrouping/gridRowGroupingUtils.ts | 2 +- .../rowGrouping/useGridRowGrouping.tsx | 4 +- .../aggregation.DataGridPremium.test.tsx | 8 +- .../exportExcel.DataGridPremium.test.tsx | 32 ++++---- .../rowGrouping.DataGridPremium.test.tsx | 4 +- .../tests/rowPinning.DataGridPremium.test.tsx | 4 +- .../statePersistence.DataGridPremium.test.tsx | 4 +- .../components/GridColumnPinningMenuItems.tsx | 4 +- .../src/components/GridDetailPanel.tsx | 4 +- .../components/GridDetailPanelToggleCell.tsx | 4 +- .../src/components/GridRowReorderCell.tsx | 4 +- .../components/GridTreeDataGroupingCell.tsx | 4 +- .../columnPinning/useGridColumnPinning.tsx | 4 +- .../tests/accessibility.DataGridPro.test.tsx | 4 +- .../tests/cellEditing.DataGridPro.test.tsx | 8 +- .../tests/columnHeaders.DataGridPro.test.tsx | 12 +-- .../tests/columnPinning.DataGridPro.test.tsx | 12 +-- .../tests/columnReorder.DataGridPro.test.tsx | 80 +++++++++---------- .../tests/columnSpanning.DataGridPro.test.tsx | 12 +-- .../src/tests/columns.DataGridPro.test.tsx | 4 +- .../columnsVisibility.DataGridPro.test.tsx | 6 +- .../src/tests/components.DataGridPro.test.tsx | 4 +- .../tests/detailPanel.DataGridPro.test.tsx | 4 +- .../tests/editComponents.DataGridPro.test.tsx | 4 +- .../src/tests/events.DataGridPro.spec.ts | 4 +- .../src/tests/events.DataGridPro.test.tsx | 8 +- .../src/tests/export.DataGridPro.test.tsx | 60 +++++++------- .../tests/filterPanel.DataGridPro.test.tsx | 4 +- .../src/tests/filtering.DataGridPro.test.tsx | 8 +- .../src/tests/layout.DataGridPro.test.tsx | 4 +- .../src/tests/lazyLoader.DataGridPro.test.tsx | 4 +- .../src/tests/pagination.DataGridPro.test.tsx | 12 +-- .../src/tests/printExport.DataGrid.test.tsx | 4 +- .../src/tests/rowEditing.DataGridPro.test.tsx | 8 +- .../src/tests/rowPinning.DataGridPro.test.tsx | 46 +++++------ .../src/tests/rowReorder.DataGridPro.test.tsx | 20 ++--- .../tests/rowSelection.DataGridPro.test.tsx | 6 +- .../src/tests/rows.DataGridPro.test.tsx | 70 ++++++++-------- .../src/tests/sorting.DataGridPro.test.tsx | 32 ++++---- .../statePersistence.DataGridPro.test.tsx | 8 +- .../src/tests/treeData.DataGridPro.test.tsx | 4 +- .../x-data-grid/src/components/GridRow.tsx | 4 +- .../src/components/cell/GridActionsCell.tsx | 4 +- .../src/components/cell/GridBooleanCell.tsx | 4 +- .../src/components/menu/GridMenu.tsx | 4 +- .../menu/columnMenu/GridColumnsMenuItem.tsx | 4 +- .../menu/columnMenu/GridFilterMenuItem.tsx | 4 +- .../menu/columnMenu/HideGridColMenuItem.tsx | 4 +- .../menu/columnMenu/SortGridMenuItems.tsx | 4 +- .../components/toolbar/GridToolbarExport.tsx | 8 +- .../src/context/GridContextProvider.tsx | 8 +- .../rowSelection/useGridRowSelection.ts | 2 +- .../utils/useGridApiEventHandler.test.tsx | 8 +- .../src/tests/columns.DataGrid.test.tsx | 14 ++-- .../x-data-grid/src/tests/columns.spec.tsx | 20 ++--- .../tests/columnsGrouping.DataGrid.test.tsx | 16 ++-- .../tests/columnsVisibility.DataGrid.test.tsx | 14 ++-- .../src/tests/components.DataGrid.test.tsx | 4 +- .../src/tests/export.DataGrid.test.tsx | 4 +- .../src/tests/filterPanel.DataGrid.test.tsx | 4 +- .../src/tests/filtering.DataGrid.test.tsx | 4 +- .../src/tests/keyboard.DataGrid.test.tsx | 12 +-- .../src/tests/layout.DataGrid.test.tsx | 48 ++++++----- .../src/tests/pagination.DataGrid.test.tsx | 28 +++---- .../tests/quickFiltering.DataGrid.test.tsx | 4 +- .../src/tests/rowSelection.DataGrid.test.tsx | 29 ++++--- .../src/tests/rows.DataGrid.test.tsx | 52 ++++++------ .../src/tests/sorting.DataGrid.test.tsx | 32 ++++---- .../src/tests/toolbar.DataGrid.test.tsx | 12 +-- .../testTextFieldValidation.tsx | 8 +- .../src/DateCalendar/DayCalendar.tsx | 6 +- .../tests/validation.DateCalendar.test.tsx | 6 +- .../src/DatePicker/DatePicker.spec.tsx | 4 +- .../src/DatePicker/DatePicker.test.tsx | 4 +- .../DateTimePicker/DateTimePicker.test.tsx | 4 +- .../DesktopDatePicker.test.tsx | 4 +- .../DesktopDatePickerLocalization.test.tsx | 4 +- .../LocalizationProvider.test.tsx | 6 +- .../src/PickersActionBar/PickersActionBar.tsx | 4 +- .../StaticDateTimePicker.test.tsx | 14 ++-- .../src/TimePicker/TimePicker.test.tsx | 4 +- .../components/PickersModalDialog.tsx | 4 +- .../testValidation/testDayViewValidation.tsx | 8 +- .../testMonthViewValidation.tsx | 8 +- .../testTextFieldValidation.tsx | 8 +- .../testValidation/testYearViewValidation.tsx | 8 +- scripts/x-data-grid-premium.exports.json | 26 +++--- scripts/x-data-grid-pro.exports.json | 24 +++--- scripts/x-data-grid.exports.json | 18 ++--- .../DataGrid/NoRowsOverlayWithButton.tsx | 12 ++- test/e2e/fixtures/DataGrid/SelectEditCell.tsx | 4 +- test/utils/pickers-utils.tsx | 4 +- 189 files changed, 881 insertions(+), 806 deletions(-) diff --git a/benchmark/browser/scripts/benchmark.js b/benchmark/browser/scripts/benchmark.js index f2d368c6e7901..2bec7f56d1e6f 100644 --- a/benchmark/browser/scripts/benchmark.js +++ b/benchmark/browser/scripts/benchmark.js @@ -9,7 +9,9 @@ const http = require('http'); const PORT = 1122; function sleep(ms) { - return new Promise((resolve) => setTimeout(resolve, ms)); + return new Promise((resolve) => { + setTimeout(resolve, ms); + }); } function createServer(options) { diff --git a/docs/data/data-grid/accessibility/FocusManagement.js b/docs/data/data-grid/accessibility/FocusManagement.js index 7a8e676fba902..3a5f18a5ef7ce 100644 --- a/docs/data/data-grid/accessibility/FocusManagement.js +++ b/docs/data/data-grid/accessibility/FocusManagement.js @@ -6,11 +6,13 @@ import Grid from '@mui/material/Grid'; import Link from '@mui/material/Link'; import Typography from '@mui/material/Typography'; -const CorrectRenderLink = (props) => ( - - more info - -); +function CorrectRenderLink(props) { + return ( + + more info + + ); +} CorrectRenderLink.propTypes = { /** @@ -19,7 +21,9 @@ CorrectRenderLink.propTypes = { tabIndex: PropTypes.oneOf([-1, 0]).isRequired, }; -const WrongRenderLink = () => more info; +function WrongRenderLink() { + return more info; +} const correctColumns = [ { field: 'link', renderCell: CorrectRenderLink, width: 200 }, diff --git a/docs/data/data-grid/accessibility/FocusManagement.tsx b/docs/data/data-grid/accessibility/FocusManagement.tsx index d876773cf298e..b23612f80b1cf 100644 --- a/docs/data/data-grid/accessibility/FocusManagement.tsx +++ b/docs/data/data-grid/accessibility/FocusManagement.tsx @@ -10,13 +10,17 @@ import Grid from '@mui/material/Grid'; import Link from '@mui/material/Link'; import Typography from '@mui/material/Typography'; -const CorrectRenderLink = (props: GridRenderCellParams) => ( - - more info - -); +function CorrectRenderLink(props: GridRenderCellParams) { + return ( + + more info + + ); +} -const WrongRenderLink = () => more info; +function WrongRenderLink() { + return more info; +} const correctColumns: GridColumns = [ { field: 'link', renderCell: CorrectRenderLink, width: 200 }, diff --git a/docs/data/data-grid/api-object/UseGridApiContext.js b/docs/data/data-grid/api-object/UseGridApiContext.js index ae2ac685636dd..e90e81a1aadd1 100644 --- a/docs/data/data-grid/api-object/UseGridApiContext.js +++ b/docs/data/data-grid/api-object/UseGridApiContext.js @@ -4,7 +4,7 @@ import Button from '@mui/material/Button'; import { DataGrid, GridToolbarContainer, useGridApiContext } from '@mui/x-data-grid'; import { useDemoData } from '@mui/x-data-grid-generator'; -const CustomToolbar = () => { +function CustomToolbar() { const apiRef = useGridApiContext(); const handleGoToPage1 = () => apiRef.current.setPage(1); @@ -14,7 +14,7 @@ const CustomToolbar = () => { ); -}; +} export default function UseGridApiContext() { const { data } = useDemoData({ diff --git a/docs/data/data-grid/api-object/UseGridApiContext.tsx b/docs/data/data-grid/api-object/UseGridApiContext.tsx index ae2ac685636dd..e90e81a1aadd1 100644 --- a/docs/data/data-grid/api-object/UseGridApiContext.tsx +++ b/docs/data/data-grid/api-object/UseGridApiContext.tsx @@ -4,7 +4,7 @@ import Button from '@mui/material/Button'; import { DataGrid, GridToolbarContainer, useGridApiContext } from '@mui/x-data-grid'; import { useDemoData } from '@mui/x-data-grid-generator'; -const CustomToolbar = () => { +function CustomToolbar() { const apiRef = useGridApiContext(); const handleGoToPage1 = () => apiRef.current.setPage(1); @@ -14,7 +14,7 @@ const CustomToolbar = () => { ); -}; +} export default function UseGridApiContext() { const { data } = useDemoData({ diff --git a/docs/data/data-grid/column-definition/RenderCellGrid.js b/docs/data/data-grid/column-definition/RenderCellGrid.js index f90f52b65de96..295c8e0e09359 100644 --- a/docs/data/data-grid/column-definition/RenderCellGrid.js +++ b/docs/data/data-grid/column-definition/RenderCellGrid.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import Button from '@mui/material/Button'; import { DataGrid } from '@mui/x-data-grid'; -const RenderDate = (props) => { +function RenderDate(props) { const { hasFocus, value } = props; const buttonElement = React.useRef(null); const rippleRef = React.useRef(null); @@ -41,7 +41,7 @@ const RenderDate = (props) => { ); -}; +} RenderDate.propTypes = { /** diff --git a/docs/data/data-grid/column-definition/RenderCellGrid.tsx b/docs/data/data-grid/column-definition/RenderCellGrid.tsx index 70133034dea74..46a6099b1118d 100644 --- a/docs/data/data-grid/column-definition/RenderCellGrid.tsx +++ b/docs/data/data-grid/column-definition/RenderCellGrid.tsx @@ -3,7 +3,7 @@ import Button from '@mui/material/Button'; import { DataGrid, GridColDef, GridRenderCellParams } from '@mui/x-data-grid'; import { TouchRippleActions } from '@mui/material/ButtonBase/TouchRipple'; -const RenderDate = (props: GridRenderCellParams) => { +function RenderDate(props: GridRenderCellParams) { const { hasFocus, value } = props; const buttonElement = React.useRef(null); const rippleRef = React.useRef(null); @@ -41,7 +41,7 @@ const RenderDate = (props: GridRenderCellParams) => { ); -}; +} const columns: GridColDef[] = [ { diff --git a/docs/data/data-grid/column-groups/CustomizationDemo.js b/docs/data/data-grid/column-groups/CustomizationDemo.js index 5b6a73c74c4d3..1ce9d8cbe8c4a 100644 --- a/docs/data/data-grid/column-groups/CustomizationDemo.js +++ b/docs/data/data-grid/column-groups/CustomizationDemo.js @@ -49,7 +49,7 @@ const HeaderWithIconRoot = styled('div')(({ theme }) => ({ }, })); -const HeaderWithIcon = (props) => { +function HeaderWithIcon(props) { const { icon, ...params } = props; return ( @@ -57,7 +57,7 @@ const HeaderWithIcon = (props) => { {params.headerName ?? params.groupId} {icon} ); -}; +} HeaderWithIcon.propTypes = { /** diff --git a/docs/data/data-grid/column-groups/CustomizationDemo.tsx b/docs/data/data-grid/column-groups/CustomizationDemo.tsx index f603bfc18e955..6fea3452b6b24 100644 --- a/docs/data/data-grid/column-groups/CustomizationDemo.tsx +++ b/docs/data/data-grid/column-groups/CustomizationDemo.tsx @@ -57,7 +57,7 @@ const HeaderWithIconRoot = styled('div')(({ theme }) => ({ }, })); -const HeaderWithIcon = (props: HeaderWithIconProps) => { +function HeaderWithIcon(props: HeaderWithIconProps) { const { icon, ...params } = props; return ( @@ -65,7 +65,7 @@ const HeaderWithIcon = (props: HeaderWithIconProps) => { {params.headerName ?? params.groupId} {icon} ); -}; +} const columnGroupingModel: GridColumnGroupingModel = [ { diff --git a/docs/data/data-grid/demo/PopularFeaturesDemo.js b/docs/data/data-grid/demo/PopularFeaturesDemo.js index 491cce46a2dc1..8ca9b063de6e8 100644 --- a/docs/data/data-grid/demo/PopularFeaturesDemo.js +++ b/docs/data/data-grid/demo/PopularFeaturesDemo.js @@ -182,7 +182,7 @@ const getChipProperties = (plan) => { } }; -const PlanTag = (props) => { +function PlanTag(props) { const chipPropperties = getChipProperties(props.plan); const avatar = !chipPropperties.avatarLink ? undefined : ( @@ -195,21 +195,21 @@ const PlanTag = (props) => { label={props.plan} /> ); -}; +} PlanTag.propTypes = { plan: PropTypes.string.isRequired, }; -const CustomToolbar = () => { +function CustomToolbar() { return ( ); -}; +} -const RowDemo = (props) => { +function RowDemo(props) { const { row } = props; const theme = useTheme(); const gridBgColor = theme.palette.mode === 'dark' ? '#000' : '#fff'; @@ -222,7 +222,7 @@ const RowDemo = (props) => { ); -}; +} RowDemo.propTypes = { row: PropTypes.object.isRequired, diff --git a/docs/data/data-grid/demo/PopularFeaturesDemo.tsx b/docs/data/data-grid/demo/PopularFeaturesDemo.tsx index 62d6236818b32..37779ea96a4f2 100644 --- a/docs/data/data-grid/demo/PopularFeaturesDemo.tsx +++ b/docs/data/data-grid/demo/PopularFeaturesDemo.tsx @@ -197,7 +197,7 @@ const getChipProperties = (plan: string) => { } }; -const PlanTag = (props: { plan: string }) => { +function PlanTag(props: { plan: string }) { const chipPropperties = getChipProperties(props.plan); const avatar = !chipPropperties.avatarLink ? undefined : ( @@ -209,17 +209,17 @@ const PlanTag = (props: { plan: string }) => { label={props.plan} /> ); -}; +} -const CustomToolbar = () => { +function CustomToolbar() { return ( ); -}; +} -const RowDemo = (props: { row: Row }) => { +function RowDemo(props: { row: Row }) { const { row } = props; const theme = useTheme(); const gridBgColor = theme.palette.mode === 'dark' ? '#000' : '#fff'; @@ -232,7 +232,7 @@ const RowDemo = (props: { row: Row }) => { ); -}; +} const columns: GridColDef[] = [ { diff --git a/docs/data/data-grid/editing/AskConfirmationBeforeSave.js b/docs/data/data-grid/editing/AskConfirmationBeforeSave.js index 0c2f03cefe5d8..e511b43116bd2 100644 --- a/docs/data/data-grid/editing/AskConfirmationBeforeSave.js +++ b/docs/data/data-grid/editing/AskConfirmationBeforeSave.js @@ -16,15 +16,15 @@ import Alert from '@mui/material/Alert'; const useFakeMutation = () => { return React.useCallback( (user) => - new Promise((resolve, reject) => + new Promise((resolve, reject) => { setTimeout(() => { if (user.name?.trim() === '') { reject(); } else { resolve(user); } - }, 200), - ), + }, 200); + }), [], ); }; diff --git a/docs/data/data-grid/editing/AskConfirmationBeforeSave.tsx b/docs/data/data-grid/editing/AskConfirmationBeforeSave.tsx index ff2bca287e8ee..d9c58be84b9a1 100644 --- a/docs/data/data-grid/editing/AskConfirmationBeforeSave.tsx +++ b/docs/data/data-grid/editing/AskConfirmationBeforeSave.tsx @@ -30,15 +30,15 @@ interface User { const useFakeMutation = () => { return React.useCallback( (user: Partial) => - new Promise>((resolve, reject) => + new Promise>((resolve, reject) => { setTimeout(() => { if (user.name?.trim() === '') { reject(); } else { resolve(user); } - }, 200), - ), + }, 200); + }), [], ); }; diff --git a/docs/data/data-grid/editing/ServerSidePersistence.js b/docs/data/data-grid/editing/ServerSidePersistence.js index e525f018c3a63..c98cc5fd43bfc 100644 --- a/docs/data/data-grid/editing/ServerSidePersistence.js +++ b/docs/data/data-grid/editing/ServerSidePersistence.js @@ -11,15 +11,15 @@ import Alert from '@mui/material/Alert'; const useFakeMutation = () => { return React.useCallback( (user) => - new Promise((resolve, reject) => + new Promise((resolve, reject) => { setTimeout(() => { if (user.name?.trim() === '') { reject(new Error("Error while saving user: name can't be empty.")); } else { resolve({ ...user, name: user.name?.toUpperCase() }); } - }, 200), - ), + }, 200); + }), [], ); }; diff --git a/docs/data/data-grid/editing/ServerSidePersistence.tsx b/docs/data/data-grid/editing/ServerSidePersistence.tsx index 8fbb13bd67ac9..cb68de5b9a84a 100644 --- a/docs/data/data-grid/editing/ServerSidePersistence.tsx +++ b/docs/data/data-grid/editing/ServerSidePersistence.tsx @@ -25,15 +25,15 @@ interface User { const useFakeMutation = () => { return React.useCallback( (user: Partial) => - new Promise>((resolve, reject) => + new Promise>((resolve, reject) => { setTimeout(() => { if (user.name?.trim() === '') { reject(new Error("Error while saving user: name can't be empty.")); } else { resolve({ ...user, name: user.name?.toUpperCase() }); } - }, 200), - ), + }, 200); + }), [], ); }; diff --git a/docs/data/data-grid/events/CatalogOfEventsNoSnap.js b/docs/data/data-grid/events/CatalogOfEventsNoSnap.js index 0e20eab68649d..50bf8988e2ff0 100644 --- a/docs/data/data-grid/events/CatalogOfEventsNoSnap.js +++ b/docs/data/data-grid/events/CatalogOfEventsNoSnap.js @@ -25,7 +25,7 @@ function getDataGridComponentNameFromProjectName(project) { const Description = styled(Typography)({ whiteSpace: 'nowrap' }); -const EventRow = ({ event }) => { +function EventRow({ event }) { const example = React.useMemo(() => { const args = ['details, // GridCallbackDetails']; if (event.event) { @@ -68,7 +68,7 @@ ${propExample} ); -}; +} const COLUMNS = [ { @@ -120,11 +120,13 @@ const COLUMNS = [ }, ]; -const Toolbar = () => ( - - - -); +function Toolbar() { + return ( + + + + ); +} export default function CatalogOfEventsNoSnap() { return ( diff --git a/docs/data/data-grid/events/SubscribeToEventsHook.js b/docs/data/data-grid/events/SubscribeToEventsHook.js index d3d748048757b..7470067c11a1a 100644 --- a/docs/data/data-grid/events/SubscribeToEventsHook.js +++ b/docs/data/data-grid/events/SubscribeToEventsHook.js @@ -10,7 +10,7 @@ import Alert from '@mui/material/Alert'; import Box from '@mui/material/Box'; import Stack from '@mui/material/Stack'; -const Footer = () => { +function Footer() { const [message, setMessage] = React.useState(''); const apiRef = useGridApiContext(); @@ -26,7 +26,7 @@ const Footer = () => { {message && {message}} ); -}; +} export default function SubscribeToEventsHook() { const data = useMovieData(); diff --git a/docs/data/data-grid/events/SubscribeToEventsHook.tsx b/docs/data/data-grid/events/SubscribeToEventsHook.tsx index ef65609dcbb23..203ce5923c8f5 100644 --- a/docs/data/data-grid/events/SubscribeToEventsHook.tsx +++ b/docs/data/data-grid/events/SubscribeToEventsHook.tsx @@ -11,7 +11,7 @@ import Alert from '@mui/material/Alert'; import Box from '@mui/material/Box'; import Stack from '@mui/material/Stack'; -const Footer = () => { +function Footer() { const [message, setMessage] = React.useState(''); const apiRef = useGridApiContext(); @@ -27,7 +27,7 @@ const Footer = () => { {message && {message}} ); -}; +} export default function SubscribeToEventsHook() { const data = useMovieData(); diff --git a/docs/data/data-grid/export/CsvGetRowsToExport.js b/docs/data/data-grid/export/CsvGetRowsToExport.js index 5e5c8cb18b5fd..a6d2dd73f9375 100644 --- a/docs/data/data-grid/export/CsvGetRowsToExport.js +++ b/docs/data/data-grid/export/CsvGetRowsToExport.js @@ -23,7 +23,7 @@ const ExportIcon = createSvgIcon( 'SaveAlt', ); -const CustomToolbar = () => { +function CustomToolbar() { const apiRef = useGridApiContext(); const handleExport = (options) => apiRef.current.exportDataAsCsv(options); @@ -56,7 +56,7 @@ const CustomToolbar = () => { ); -}; +} export default function CsvGetRowsToExport() { const { data, loading } = useDemoData({ diff --git a/docs/data/data-grid/export/CsvGetRowsToExport.tsx b/docs/data/data-grid/export/CsvGetRowsToExport.tsx index 2259c26df97d4..4ff94d6461b23 100644 --- a/docs/data/data-grid/export/CsvGetRowsToExport.tsx +++ b/docs/data/data-grid/export/CsvGetRowsToExport.tsx @@ -27,7 +27,7 @@ const ExportIcon = createSvgIcon( 'SaveAlt', ); -const CustomToolbar = () => { +function CustomToolbar() { const apiRef = useGridApiContext(); const handleExport = (options: GridCsvExportOptions) => @@ -61,7 +61,7 @@ const CustomToolbar = () => { ); -}; +} export default function CsvGetRowsToExport() { const { data, loading } = useDemoData({ diff --git a/docs/data/data-grid/export/CsvGetRowsToExportRowGrouping.js b/docs/data/data-grid/export/CsvGetRowsToExportRowGrouping.js index cdaf62921f6f3..a58c5e8aac9d0 100644 --- a/docs/data/data-grid/export/CsvGetRowsToExportRowGrouping.js +++ b/docs/data/data-grid/export/CsvGetRowsToExportRowGrouping.js @@ -24,7 +24,7 @@ const ExportIcon = createSvgIcon( 'SaveAlt', ); -const CustomToolbar = () => { +function CustomToolbar() { const apiRef = useGridApiContext(); const handleExport = (options) => apiRef.current.exportDataAsCsv(options); @@ -51,7 +51,7 @@ const CustomToolbar = () => { ); -}; +} export default function CsvGetRowsToExportRowGrouping() { const { data, loading } = useDemoData({ diff --git a/docs/data/data-grid/export/CsvGetRowsToExportRowGrouping.tsx b/docs/data/data-grid/export/CsvGetRowsToExportRowGrouping.tsx index b2ff6697d9917..479ad64e8a8cd 100644 --- a/docs/data/data-grid/export/CsvGetRowsToExportRowGrouping.tsx +++ b/docs/data/data-grid/export/CsvGetRowsToExportRowGrouping.tsx @@ -27,7 +27,7 @@ const ExportIcon = createSvgIcon( 'SaveAlt', ); -const CustomToolbar = () => { +function CustomToolbar() { const apiRef = useGridApiContext(); const handleExport = (options: GridCsvExportOptions) => @@ -55,7 +55,7 @@ const CustomToolbar = () => { ); -}; +} export default function CsvGetRowsToExportRowGrouping() { const { data, loading } = useDemoData({ diff --git a/docs/data/data-grid/export/CustomExport.js b/docs/data/data-grid/export/CustomExport.js index e4e7b5e0b5173..df37cb8d5307a 100644 --- a/docs/data/data-grid/export/CustomExport.js +++ b/docs/data/data-grid/export/CustomExport.js @@ -45,7 +45,7 @@ const exportBlob = (blob, filename) => { }); }; -const JsonExportMenuItem = (props) => { +function JsonExportMenuItem(props) { const apiRef = useGridApiContext(); const { hideMenu } = props; @@ -67,7 +67,7 @@ const JsonExportMenuItem = (props) => { Export JSON ); -}; +} JsonExportMenuItem.propTypes = { hideMenu: PropTypes.func, @@ -75,18 +75,22 @@ JsonExportMenuItem.propTypes = { const csvOptions = { delimiter: ';' }; -const CustomExportButton = (props) => ( - - - - -); - -const CustomToolbar = (props) => ( - - - -); +function CustomExportButton(props) { + return ( + + + + + ); +} + +function CustomToolbar(props) { + return ( + + + + ); +} export default function CustomExport() { const { data, loading } = useDemoData({ diff --git a/docs/data/data-grid/export/CustomExport.tsx b/docs/data/data-grid/export/CustomExport.tsx index 46c4921989c32..d1e5f91d0047d 100644 --- a/docs/data/data-grid/export/CustomExport.tsx +++ b/docs/data/data-grid/export/CustomExport.tsx @@ -49,7 +49,7 @@ const exportBlob = (blob: Blob, filename: string) => { }); }; -const JsonExportMenuItem = (props: GridExportMenuItemProps<{}>) => { +function JsonExportMenuItem(props: GridExportMenuItemProps<{}>) { const apiRef = useGridApiContext(); const { hideMenu } = props; @@ -70,22 +70,26 @@ const JsonExportMenuItem = (props: GridExportMenuItemProps<{}>) => { Export JSON ); -}; +} const csvOptions: GridCsvExportOptions = { delimiter: ';' }; -const CustomExportButton = (props: ButtonProps) => ( - - - - -); +function CustomExportButton(props: ButtonProps) { + return ( + + + + + ); +} -const CustomToolbar = (props: GridToolbarContainerProps) => ( - - - -); +function CustomToolbar(props: GridToolbarContainerProps) { + return ( + + + + ); +} export default function CustomExport() { const { data, loading } = useDemoData({ diff --git a/docs/data/data-grid/filtering/CustomFilterPanelPosition.js b/docs/data/data-grid/filtering/CustomFilterPanelPosition.js index 3133baeee60c8..ce4f14b8fe7c5 100644 --- a/docs/data/data-grid/filtering/CustomFilterPanelPosition.js +++ b/docs/data/data-grid/filtering/CustomFilterPanelPosition.js @@ -9,11 +9,13 @@ import { useDemoData } from '@mui/x-data-grid-generator'; const VISIBLE_FIELDS = ['name', 'rating', 'country', 'dateCreated', 'isAdmin']; -const CustomToolbar = ({ setFilterButtonEl }) => ( - - - -); +function CustomToolbar({ setFilterButtonEl }) { + return ( + + + + ); +} CustomToolbar.propTypes = { setFilterButtonEl: PropTypes.func.isRequired, diff --git a/docs/data/data-grid/filtering/CustomFilterPanelPosition.tsx b/docs/data/data-grid/filtering/CustomFilterPanelPosition.tsx index 2aea5193f421a..9882fab0ff52d 100644 --- a/docs/data/data-grid/filtering/CustomFilterPanelPosition.tsx +++ b/docs/data/data-grid/filtering/CustomFilterPanelPosition.tsx @@ -8,13 +8,17 @@ import { useDemoData } from '@mui/x-data-grid-generator'; const VISIBLE_FIELDS = ['name', 'rating', 'country', 'dateCreated', 'isAdmin']; -const CustomToolbar: React.FunctionComponent<{ +interface CustomToolbarProps { setFilterButtonEl: React.Dispatch>; -}> = ({ setFilterButtonEl }) => ( - - - -); +} + +function CustomToolbar({ setFilterButtonEl }: CustomToolbarProps) { + return ( + + + + ); +} export default function CustomFilterPanelPosition() { const { data } = useDemoData({ diff --git a/docs/data/data-grid/recipes-editing/LinkedFieldsCellEditing.js b/docs/data/data-grid/recipes-editing/LinkedFieldsCellEditing.js index edd3ff486d0eb..b4a289845f5a9 100644 --- a/docs/data/data-grid/recipes-editing/LinkedFieldsCellEditing.js +++ b/docs/data/data-grid/recipes-editing/LinkedFieldsCellEditing.js @@ -32,7 +32,7 @@ const initialRows = [ }, ]; -const CustomTypeEditComponent = (props) => { +function CustomTypeEditComponent(props) { const { setRows, ...other } = props; const handleValueChange = () => { @@ -45,7 +45,7 @@ const CustomTypeEditComponent = (props) => { }; return ; -}; +} CustomTypeEditComponent.propTypes = { /** diff --git a/docs/data/data-grid/recipes-editing/LinkedFieldsCellEditing.tsx b/docs/data/data-grid/recipes-editing/LinkedFieldsCellEditing.tsx index 4ecab29c7dca3..1b2bb49ad5233 100644 --- a/docs/data/data-grid/recipes-editing/LinkedFieldsCellEditing.tsx +++ b/docs/data/data-grid/recipes-editing/LinkedFieldsCellEditing.tsx @@ -40,7 +40,7 @@ interface CustomTypeEditComponentProps extends GridEditSingleSelectCellProps { setRows: React.Dispatch>; } -const CustomTypeEditComponent = (props: CustomTypeEditComponentProps) => { +function CustomTypeEditComponent(props: CustomTypeEditComponentProps) { const { setRows, ...other } = props; const handleValueChange = () => { @@ -53,7 +53,7 @@ const CustomTypeEditComponent = (props: CustomTypeEditComponentProps) => { }; return ; -}; +} export default function LinkedFieldsCellEditing() { const editingRow = React.useRef(null); diff --git a/docs/data/data-grid/recipes-editing/LinkedFieldsRowEditing.js b/docs/data/data-grid/recipes-editing/LinkedFieldsRowEditing.js index 24db7bf23adac..bff2f80e652b9 100644 --- a/docs/data/data-grid/recipes-editing/LinkedFieldsRowEditing.js +++ b/docs/data/data-grid/recipes-editing/LinkedFieldsRowEditing.js @@ -32,7 +32,7 @@ const rows = [ }, ]; -const CustomTypeEditComponent = (props) => { +function CustomTypeEditComponent(props) { const apiRef = useGridApiContext(); const handleValueChange = async () => { @@ -44,7 +44,7 @@ const CustomTypeEditComponent = (props) => { }; return ; -}; +} CustomTypeEditComponent.propTypes = { /** diff --git a/docs/data/data-grid/recipes-editing/LinkedFieldsRowEditing.tsx b/docs/data/data-grid/recipes-editing/LinkedFieldsRowEditing.tsx index fdd1a790baef7..c3bc26e9e9540 100644 --- a/docs/data/data-grid/recipes-editing/LinkedFieldsRowEditing.tsx +++ b/docs/data/data-grid/recipes-editing/LinkedFieldsRowEditing.tsx @@ -34,7 +34,7 @@ const rows: GridRowsProp = [ }, ]; -const CustomTypeEditComponent = (props: GridEditSingleSelectCellProps) => { +function CustomTypeEditComponent(props: GridEditSingleSelectCellProps) { const apiRef = useGridApiContext(); const handleValueChange = async () => { @@ -46,7 +46,7 @@ const CustomTypeEditComponent = (props: GridEditSingleSelectCellProps) => { }; return ; -}; +} export default function LinkedFieldsRowEditing() { const columns: GridColumns = [ diff --git a/docs/data/data-grid/recipes-editing/MultilineEditing.js b/docs/data/data-grid/recipes-editing/MultilineEditing.js index 3a14f535290a8..a306eac5c7203 100644 --- a/docs/data/data-grid/recipes-editing/MultilineEditing.js +++ b/docs/data/data-grid/recipes-editing/MultilineEditing.js @@ -26,7 +26,7 @@ const lines = [ 'Vestibulum pulvinar aliquam turpis, ac faucibus risus varius a.', ]; -const EditTextarea = (props) => { +function EditTextarea(props) { const { id, field, value, colDef } = props; const [valueState, setValueState] = React.useState(value); const [anchorEl, setAnchorEl] = React.useState(); @@ -92,7 +92,7 @@ const EditTextarea = (props) => { )} ); -}; +} EditTextarea.propTypes = { /** diff --git a/docs/data/data-grid/recipes-editing/MultilineEditing.tsx b/docs/data/data-grid/recipes-editing/MultilineEditing.tsx index 5ab71d00f7f88..f18a0ff09da9d 100644 --- a/docs/data/data-grid/recipes-editing/MultilineEditing.tsx +++ b/docs/data/data-grid/recipes-editing/MultilineEditing.tsx @@ -32,7 +32,7 @@ const lines = [ 'Vestibulum pulvinar aliquam turpis, ac faucibus risus varius a.', ]; -const EditTextarea = (props: GridRenderEditCellParams) => { +function EditTextarea(props: GridRenderEditCellParams) { const { id, field, value, colDef } = props; const [valueState, setValueState] = React.useState(value); const [anchorEl, setAnchorEl] = React.useState(); @@ -98,7 +98,7 @@ const EditTextarea = (props: GridRenderEditCellParams) => { )} ); -}; +} const multilineColumn: GridColTypeDef = { type: 'string', diff --git a/docs/data/data-grid/row-height/ExpandableCells.js b/docs/data/data-grid/row-height/ExpandableCells.js index b1675a038d3d2..919ac9ff15dc1 100644 --- a/docs/data/data-grid/row-height/ExpandableCells.js +++ b/docs/data/data-grid/row-height/ExpandableCells.js @@ -25,7 +25,7 @@ const lines = [ 'Vestibulum pulvinar aliquam turpis, ac faucibus risus varius a.', ]; -const ExpandableCell = ({ value }) => { +function ExpandableCell({ value }) { const [expanded, setExpanded] = React.useState(false); return ( @@ -44,7 +44,7 @@ const ExpandableCell = ({ value }) => { )} ); -}; +} ExpandableCell.propTypes = { /** diff --git a/docs/data/data-grid/row-height/ExpandableCells.tsx b/docs/data/data-grid/row-height/ExpandableCells.tsx index 59b06ea52d061..4bc6da9cb6cfb 100644 --- a/docs/data/data-grid/row-height/ExpandableCells.tsx +++ b/docs/data/data-grid/row-height/ExpandableCells.tsx @@ -24,7 +24,7 @@ const lines = [ 'Vestibulum pulvinar aliquam turpis, ac faucibus risus varius a.', ]; -const ExpandableCell = ({ value }: GridRenderCellParams) => { +function ExpandableCell({ value }: GridRenderCellParams) { const [expanded, setExpanded] = React.useState(false); return ( @@ -43,7 +43,7 @@ const ExpandableCell = ({ value }: GridRenderCellParams) => { )} ); -}; +} const columns = [ { field: 'id' }, diff --git a/docs/data/data-grid/state/RestoreStateApiRef.js b/docs/data/data-grid/state/RestoreStateApiRef.js index d8cd402e9fd94..375986b2fa09d 100644 --- a/docs/data/data-grid/state/RestoreStateApiRef.js +++ b/docs/data/data-grid/state/RestoreStateApiRef.js @@ -109,7 +109,7 @@ const DEMO_INITIAL_STATE = { activeViewId: null, }; -const ViewListItem = (props) => { +function ViewListItem(props) { const { view, viewId, selected, onDelete, onSelect, ...other } = props; return ( @@ -128,7 +128,7 @@ const ViewListItem = (props) => { ); -}; +} ViewListItem.propTypes = { onDelete: PropTypes.func.isRequired, @@ -175,7 +175,7 @@ ViewListItem.propTypes = { viewId: PropTypes.string.isRequired, }; -const NewViewListButton = (props) => { +function NewViewListButton(props) { const { label, onLabelChange, onSubmit, isValid } = props; const [isAddingView, setIsAddingView] = React.useState(false); @@ -221,7 +221,7 @@ const NewViewListButton = (props) => { ); -}; +} NewViewListButton.propTypes = { isValid: PropTypes.bool.isRequired, diff --git a/docs/data/data-grid/state/RestoreStateApiRef.tsx b/docs/data/data-grid/state/RestoreStateApiRef.tsx index 225d774846ea2..3afc746d31687 100644 --- a/docs/data/data-grid/state/RestoreStateApiRef.tsx +++ b/docs/data/data-grid/state/RestoreStateApiRef.tsx @@ -130,13 +130,13 @@ const DEMO_INITIAL_STATE: DemoState = { activeViewId: null, }; -const ViewListItem = (props: { +function ViewListItem(props: { view: StateView; viewId: string; selected: boolean; onDelete: (viewId: string) => void; onSelect: (viewId: string) => void; -}) => { +}) { const { view, viewId, selected, onDelete, onSelect, ...other } = props; return ( @@ -155,16 +155,16 @@ const ViewListItem = (props: { ); -}; +} -const NewViewListButton = (props: { +function NewViewListButton(props: { label: string; onLabelChange: ( e: React.ChangeEvent, ) => void; onSubmit: () => void; isValid: boolean; -}) => { +}) { const { label, onLabelChange, onSubmit, isValid } = props; const [isAddingView, setIsAddingView] = React.useState(false); @@ -210,7 +210,7 @@ const NewViewListButton = (props: { ); -}; +} function CustomToolbar() { const apiRef = useGridApiContext(); diff --git a/docs/data/data-grid/state/RestoreStateInitialState.js b/docs/data/data-grid/state/RestoreStateInitialState.js index 16dbb708fd160..35ad2b6a32f6d 100644 --- a/docs/data/data-grid/state/RestoreStateInitialState.js +++ b/docs/data/data-grid/state/RestoreStateInitialState.js @@ -13,7 +13,7 @@ import { } from '@mui/x-data-grid-pro'; import { useDemoData } from '@mui/x-data-grid-generator'; -const GridCustomToolbar = ({ syncState }) => { +function GridCustomToolbar({ syncState }) { const rootProps = useGridRootProps(); const apiRef = useGridApiContext(); @@ -31,7 +31,7 @@ const GridCustomToolbar = ({ syncState }) => { ); -}; +} GridCustomToolbar.propTypes = { syncState: PropTypes.func.isRequired, diff --git a/docs/data/data-grid/state/RestoreStateInitialState.tsx b/docs/data/data-grid/state/RestoreStateInitialState.tsx index ba6b80c7e4fa5..3bdb65a49fc3f 100644 --- a/docs/data/data-grid/state/RestoreStateInitialState.tsx +++ b/docs/data/data-grid/state/RestoreStateInitialState.tsx @@ -13,11 +13,11 @@ import { } from '@mui/x-data-grid-pro'; import { useDemoData } from '@mui/x-data-grid-generator'; -const GridCustomToolbar = ({ +function GridCustomToolbar({ syncState, }: { syncState: (stateToSave: GridInitialState) => void; -}) => { +}) { const rootProps = useGridRootProps(); const apiRef = useGridApiContext(); @@ -35,7 +35,7 @@ const GridCustomToolbar = ({ ); -}; +} export default function RestoreStateInitialState() { const { data, loading } = useDemoData({ diff --git a/docs/data/data-grid/state/UseGridSelector.js b/docs/data/data-grid/state/UseGridSelector.js index 3fa07c6d5da5b..124fbb2149297 100644 --- a/docs/data/data-grid/state/UseGridSelector.js +++ b/docs/data/data-grid/state/UseGridSelector.js @@ -9,7 +9,7 @@ import { import { useDemoData } from '@mui/x-data-grid-generator'; import Pagination from '@mui/material/Pagination'; -const Toolbar = () => { +function Toolbar() { const apiRef = useGridApiContext(); const page = useGridSelector(apiRef, gridPageSelector); const pageCount = useGridSelector(apiRef, gridPageCountSelector); @@ -23,7 +23,7 @@ const Toolbar = () => { onChange={(event, value) => apiRef.current.setPage(value - 1)} /> ); -}; +} export default function UseGridSelector() { const { data, loading } = useDemoData({ diff --git a/docs/data/data-grid/state/UseGridSelector.tsx b/docs/data/data-grid/state/UseGridSelector.tsx index 3fa07c6d5da5b..124fbb2149297 100644 --- a/docs/data/data-grid/state/UseGridSelector.tsx +++ b/docs/data/data-grid/state/UseGridSelector.tsx @@ -9,7 +9,7 @@ import { import { useDemoData } from '@mui/x-data-grid-generator'; import Pagination from '@mui/material/Pagination'; -const Toolbar = () => { +function Toolbar() { const apiRef = useGridApiContext(); const page = useGridSelector(apiRef, gridPageSelector); const pageCount = useGridSelector(apiRef, gridPageCountSelector); @@ -23,7 +23,7 @@ const Toolbar = () => { onChange={(event, value) => apiRef.current.setPage(value - 1)} /> ); -}; +} export default function UseGridSelector() { const { data, loading } = useDemoData({ diff --git a/docs/data/data-grid/tree-data/TreeDataCustomGroupingColumn.js b/docs/data/data-grid/tree-data/TreeDataCustomGroupingColumn.js index bae2d52a32dca..47b58ba7b8719 100644 --- a/docs/data/data-grid/tree-data/TreeDataCustomGroupingColumn.js +++ b/docs/data/data-grid/tree-data/TreeDataCustomGroupingColumn.js @@ -15,7 +15,7 @@ export const isNavigationKey = (key) => key.indexOf('Page') === 0 || key === ' '; -const CustomGridTreeDataGroupingCell = (props) => { +function CustomGridTreeDataGroupingCell(props) { const { id, field, rowNode } = props; const apiRef = useGridApiContext(); const filteredDescendantCountLookup = useGridSelector( @@ -62,7 +62,7 @@ const CustomGridTreeDataGroupingCell = (props) => { ); -}; +} const rows = [ { diff --git a/docs/data/data-grid/tree-data/TreeDataCustomGroupingColumn.tsx b/docs/data/data-grid/tree-data/TreeDataCustomGroupingColumn.tsx index f7cfccfba4345..409eaeeca3ce6 100644 --- a/docs/data/data-grid/tree-data/TreeDataCustomGroupingColumn.tsx +++ b/docs/data/data-grid/tree-data/TreeDataCustomGroupingColumn.tsx @@ -20,7 +20,7 @@ export const isNavigationKey = (key: string) => key.indexOf('Page') === 0 || key === ' '; -const CustomGridTreeDataGroupingCell = (props: GridRenderCellParams) => { +function CustomGridTreeDataGroupingCell(props: GridRenderCellParams) { const { id, field, rowNode } = props; const apiRef = useGridApiContext(); const filteredDescendantCountLookup = useGridSelector( @@ -66,7 +66,7 @@ const CustomGridTreeDataGroupingCell = (props: GridRenderCellParams) => { ); -}; +} interface Row { hierarchy: string[]; diff --git a/docs/data/data-grid/tree-data/TreeDataLazyLoading.js b/docs/data/data-grid/tree-data/TreeDataLazyLoading.js index 843a73214273e..90bdc302198e2 100644 --- a/docs/data/data-grid/tree-data/TreeDataLazyLoading.js +++ b/docs/data/data-grid/tree-data/TreeDataLazyLoading.js @@ -162,7 +162,7 @@ const useUtilityClasses = (ownerState) => { * Reproduce the behavior of the `GridTreeDataGroupingCell` component in `@mui/x-data-grid-pro` * But base the amount of children on a `row.descendantCount` property rather than on the internal lookups. */ -const GroupingCellWithLazyLoading = (props) => { +function GroupingCellWithLazyLoading(props) { const { id, field, rowNode, row, hideDescendantCount, formattedValue } = props; const rootProps = useGridRootProps(); @@ -215,7 +215,7 @@ const GroupingCellWithLazyLoading = (props) => { ); -}; +} GroupingCellWithLazyLoading.propTypes = { hideDescendantCount: PropTypes.bool, diff --git a/docs/data/data-grid/tree-data/TreeDataLazyLoading.tsx b/docs/data/data-grid/tree-data/TreeDataLazyLoading.tsx index 068b14b21bc53..c4e7524a6f9a0 100644 --- a/docs/data/data-grid/tree-data/TreeDataLazyLoading.tsx +++ b/docs/data/data-grid/tree-data/TreeDataLazyLoading.tsx @@ -182,7 +182,7 @@ interface GroupingCellWithLazyLoadingProps * Reproduce the behavior of the `GridTreeDataGroupingCell` component in `@mui/x-data-grid-pro` * But base the amount of children on a `row.descendantCount` property rather than on the internal lookups. */ -const GroupingCellWithLazyLoading = (props: GroupingCellWithLazyLoadingProps) => { +function GroupingCellWithLazyLoading(props: GroupingCellWithLazyLoadingProps) { const { id, field, rowNode, row, hideDescendantCount, formattedValue } = props; const rootProps = useGridRootProps(); @@ -235,7 +235,7 @@ const GroupingCellWithLazyLoading = (props: GroupingCellWithLazyLoadingProps) => ); -}; +} const CUSTOM_GROUPING_COL_DEF: GridGroupingColDefOverride = { renderCell: (params) => ( diff --git a/docs/data/date-pickers/custom-components/ActionBarComponent.js b/docs/data/date-pickers/custom-components/ActionBarComponent.js index faba5419f0fc9..a4644f9f613e7 100644 --- a/docs/data/date-pickers/custom-components/ActionBarComponent.js +++ b/docs/data/date-pickers/custom-components/ActionBarComponent.js @@ -13,7 +13,7 @@ import { StaticDatePicker } from '@mui/x-date-pickers/StaticDatePicker'; import { useLocaleText, WrapperVariantContext } from '@mui/x-date-pickers/internals'; -const CustomActionBar = (props) => { +function CustomActionBar(props) { const { onAccept, onClear, onCancel, onSetToday, actions } = props; const wrapperVariant = React.useContext(WrapperVariantContext); const localeText = useLocaleText(); @@ -113,7 +113,7 @@ const CustomActionBar = (props) => { ); -}; +} CustomActionBar.propTypes = { /** diff --git a/docs/data/date-pickers/custom-components/ActionBarComponent.tsx b/docs/data/date-pickers/custom-components/ActionBarComponent.tsx index b8c2342bf81aa..f136b0f9c87e7 100644 --- a/docs/data/date-pickers/custom-components/ActionBarComponent.tsx +++ b/docs/data/date-pickers/custom-components/ActionBarComponent.tsx @@ -12,7 +12,7 @@ import { StaticDatePicker } from '@mui/x-date-pickers/StaticDatePicker'; import { PickersActionBarProps } from '@mui/x-date-pickers/PickersActionBar'; import { useLocaleText, WrapperVariantContext } from '@mui/x-date-pickers/internals'; -const CustomActionBar = (props: PickersActionBarProps) => { +function CustomActionBar(props: PickersActionBarProps) { const { onAccept, onClear, onCancel, onSetToday, actions } = props; const wrapperVariant = React.useContext(WrapperVariantContext); const localeText = useLocaleText(); @@ -108,7 +108,7 @@ const CustomActionBar = (props: PickersActionBarProps) => { ); -}; +} export default function ActionBarComponent() { const [value, setValue] = React.useState(() => diff --git a/docs/data/date-pickers/custom-components/PaperContentComponent.js b/docs/data/date-pickers/custom-components/PaperContentComponent.js index c15ee2bf11c87..8c8ae9bf33ffb 100644 --- a/docs/data/date-pickers/custom-components/PaperContentComponent.js +++ b/docs/data/date-pickers/custom-components/PaperContentComponent.js @@ -87,7 +87,7 @@ const buildHandleRangeClick = (setValue) => (range) => { } }; -const RangeShortcutsPanel = ({ setValue, children }) => { +function RangeShortcutsPanel({ setValue, children }) { const handleRangeClick = React.useCallback( (range) => setValue && buildHandleRangeClick(setValue)(range), [setValue], @@ -113,14 +113,14 @@ const RangeShortcutsPanel = ({ setValue, children }) => { {children} ); -}; +} RangeShortcutsPanel.propTypes = { children: PropTypes.node, setValue: PropTypes.func, }; -const StaticRangeShortcutsPanel = ({ setValue, children, ...other }) => { +function StaticRangeShortcutsPanel({ setValue, children, ...other }) { const handleRangeClick = React.useCallback( (range) => setValue && buildHandleRangeClick(setValue)(range), [setValue], @@ -148,7 +148,7 @@ const StaticRangeShortcutsPanel = ({ setValue, children, ...other }) => { {children} ); -}; +} StaticRangeShortcutsPanel.propTypes = { children: PropTypes.node, diff --git a/docs/data/date-pickers/custom-components/PaperContentComponent.tsx b/docs/data/date-pickers/custom-components/PaperContentComponent.tsx index 1c73fd82e853e..cbf589f19c3b1 100644 --- a/docs/data/date-pickers/custom-components/PaperContentComponent.tsx +++ b/docs/data/date-pickers/custom-components/PaperContentComponent.tsx @@ -92,10 +92,12 @@ const buildHandleRangeClick = } }; -const RangeShortcutsPanel: React.FC<{ +interface RangeShortcutsPanelProps { setValue?: React.Dispatch>>; children: React.ReactNode; -}> = ({ setValue, children }) => { +} + +function RangeShortcutsPanel({ setValue, children }: RangeShortcutsPanelProps) { const handleRangeClick = React.useCallback( (range: RangeShortcutType) => setValue && buildHandleRangeClick(setValue)(range), [setValue], @@ -122,12 +124,18 @@ const RangeShortcutsPanel: React.FC<{ {children} ); -}; +} -const StaticRangeShortcutsPanel: React.FunctionComponent<{ +interface StaticRangeShortcutsPanelProps { setValue?: React.Dispatch>>; children: React.ReactNode; -}> = ({ setValue, children, ...other }) => { +} + +function StaticRangeShortcutsPanel({ + setValue, + children, + ...other +}: StaticRangeShortcutsPanelProps) { const handleRangeClick = React.useCallback( (range: RangeShortcutType) => setValue && buildHandleRangeClick(setValue)(range), [setValue], @@ -154,7 +162,7 @@ const StaticRangeShortcutsPanel: React.FunctionComponent<{ {children} ); -}; +} export default function PaperContentComponent() { const [value, setValue] = React.useState>([null, null]); diff --git a/docs/data/date-pickers/custom-components/Tabs.js b/docs/data/date-pickers/custom-components/Tabs.js index 0c02ce634cd47..8015ef4b213bb 100644 --- a/docs/data/date-pickers/custom-components/Tabs.js +++ b/docs/data/date-pickers/custom-components/Tabs.js @@ -11,12 +11,14 @@ import { import LightModeIcon from '@mui/icons-material/LightMode'; import AcUnitIcon from '@mui/icons-material/AcUnit'; -const CustomTabs = (props) => ( - - - - -); +function CustomTabs(props) { + return ( + + + + + ); +} export default function Tabs() { const [value, setValue] = React.useState(dayjs('2022-04-07')); diff --git a/docs/data/date-pickers/custom-components/Tabs.tsx b/docs/data/date-pickers/custom-components/Tabs.tsx index 3a93a51ae18c7..20781854a2b51 100644 --- a/docs/data/date-pickers/custom-components/Tabs.tsx +++ b/docs/data/date-pickers/custom-components/Tabs.tsx @@ -12,12 +12,14 @@ import { import LightModeIcon from '@mui/icons-material/LightMode'; import AcUnitIcon from '@mui/icons-material/AcUnit'; -const CustomTabs = (props: DateTimePickerTabsProps) => ( - - - - -); +function CustomTabs(props: DateTimePickerTabsProps) { + return ( + + + + + ); +} export default function Tabs() { const [value, setValue] = React.useState(dayjs('2022-04-07')); diff --git a/docs/data/date-pickers/date-time-range-field/DateTimeRangeFieldValue.js b/docs/data/date-pickers/date-time-range-field/DateTimeRangeFieldValue.js index e0713e7d5ed63..76842bfb815de 100644 --- a/docs/data/date-pickers/date-time-range-field/DateTimeRangeFieldValue.js +++ b/docs/data/date-pickers/date-time-range-field/DateTimeRangeFieldValue.js @@ -9,7 +9,7 @@ import Grid from '@mui/material/Grid'; import Box from '@mui/material/Box'; import Typography from '@mui/material/Typography'; -const GridItem = ({ label, children, spacing = 1 }) => { +function GridItem({ label, children, spacing = 1 }) { return ( @@ -20,7 +20,7 @@ const GridItem = ({ label, children, spacing = 1 }) => { ); -}; +} // TODO: Use the same structure as on the other `XXXFieldValue` demos when using the single input version. diff --git a/docs/data/date-pickers/date-time-range-field/DateTimeRangeFieldValue.tsx b/docs/data/date-pickers/date-time-range-field/DateTimeRangeFieldValue.tsx index 87152c3defb79..6ef0958a78256 100644 --- a/docs/data/date-pickers/date-time-range-field/DateTimeRangeFieldValue.tsx +++ b/docs/data/date-pickers/date-time-range-field/DateTimeRangeFieldValue.tsx @@ -8,7 +8,7 @@ import Grid from '@mui/material/Grid'; import Box from '@mui/material/Box'; import Typography from '@mui/material/Typography'; -const GridItem = ({ +function GridItem({ label, children, spacing = 1, @@ -16,7 +16,7 @@ const GridItem = ({ label: string; children: React.ReactNode; spacing?: number; -}) => { +}) { return ( @@ -27,7 +27,7 @@ const GridItem = ({ ); -}; +} // TODO: Use the same structure as on the other `XXXFieldValue` demos when using the single input version. export default function DateTimeRangeFieldValue() { diff --git a/docs/data/date-pickers/fields/DateRangeFieldExamples.js b/docs/data/date-pickers/fields/DateRangeFieldExamples.js index 7ddfe459695d2..ee47b139e9f52 100644 --- a/docs/data/date-pickers/fields/DateRangeFieldExamples.js +++ b/docs/data/date-pickers/fields/DateRangeFieldExamples.js @@ -11,7 +11,7 @@ import { Unstable_MultiInputDateRangeField as MultiInputDateRangeField } from '@ import { Unstable_MultiInputTimeRangeField as MultiInputTimeRangeField } from '@mui/x-date-pickers-pro/MultiInputTimeRangeField'; import { Unstable_MultiInputDateTimeRangeField as MultiInputDateTimeRangeField } from '@mui/x-date-pickers-pro/MultiInputDateTimeRangeField'; -const GridItem = ({ label, children, spacing = 1 }) => { +function GridItem({ label, children, spacing = 1 }) { return ( @@ -22,7 +22,7 @@ const GridItem = ({ label, children, spacing = 1 }) => { ); -}; +} GridItem.propTypes = { children: PropTypes.node, diff --git a/docs/data/date-pickers/fields/DateRangeFieldExamples.tsx b/docs/data/date-pickers/fields/DateRangeFieldExamples.tsx index 9b3a1af627be8..584cb43dc1196 100644 --- a/docs/data/date-pickers/fields/DateRangeFieldExamples.tsx +++ b/docs/data/date-pickers/fields/DateRangeFieldExamples.tsx @@ -10,7 +10,7 @@ import { Unstable_MultiInputDateRangeField as MultiInputDateRangeField } from '@ import { Unstable_MultiInputTimeRangeField as MultiInputTimeRangeField } from '@mui/x-date-pickers-pro/MultiInputTimeRangeField'; import { Unstable_MultiInputDateTimeRangeField as MultiInputDateTimeRangeField } from '@mui/x-date-pickers-pro/MultiInputDateTimeRangeField'; -const GridItem = ({ +function GridItem({ label, children, spacing = 1, @@ -18,7 +18,7 @@ const GridItem = ({ label: string; children: React.ReactNode; spacing?: number; -}) => { +}) { return ( @@ -29,7 +29,7 @@ const GridItem = ({ ); -}; +} const date1 = dayjs('2022-04-07T14:30:22'); const date2 = dayjs('2022-04-12T18:25:14'); diff --git a/docs/data/date-pickers/fields/SingleDateFieldExamples.js b/docs/data/date-pickers/fields/SingleDateFieldExamples.js index c844fdc0123ba..a2cf68795cab7 100644 --- a/docs/data/date-pickers/fields/SingleDateFieldExamples.js +++ b/docs/data/date-pickers/fields/SingleDateFieldExamples.js @@ -10,7 +10,7 @@ import { Unstable_DateField as DateField } from '@mui/x-date-pickers/DateField'; import { Unstable_TimeField as TimeField } from '@mui/x-date-pickers/TimeField'; import { Unstable_DateTimeField as DateTimeField } from '@mui/x-date-pickers/DateTimeField'; -const GridItem = ({ label, children, spacing = 1 }) => { +function GridItem({ label, children, spacing = 1 }) { return ( @@ -21,7 +21,7 @@ const GridItem = ({ label, children, spacing = 1 }) => { ); -}; +} GridItem.propTypes = { children: PropTypes.node, diff --git a/docs/data/date-pickers/fields/SingleDateFieldExamples.tsx b/docs/data/date-pickers/fields/SingleDateFieldExamples.tsx index 14ebc887444e9..cdd7650610376 100644 --- a/docs/data/date-pickers/fields/SingleDateFieldExamples.tsx +++ b/docs/data/date-pickers/fields/SingleDateFieldExamples.tsx @@ -9,7 +9,7 @@ import { Unstable_DateField as DateField } from '@mui/x-date-pickers/DateField'; import { Unstable_TimeField as TimeField } from '@mui/x-date-pickers/TimeField'; import { Unstable_DateTimeField as DateTimeField } from '@mui/x-date-pickers/DateTimeField'; -const GridItem = ({ +function GridItem({ label, children, spacing = 1, @@ -17,7 +17,7 @@ const GridItem = ({ label: string; children: React.ReactNode; spacing?: number; -}) => { +}) { return ( @@ -28,7 +28,7 @@ const GridItem = ({ ); -}; +} const date1 = dayjs('2022-04-07T14:30:22'); diff --git a/docs/data/date-pickers/getting-started/InstructionsNoSnap.js b/docs/data/date-pickers/getting-started/InstructionsNoSnap.js index 4d0c8440f9cd4..160e96af8fba4 100644 --- a/docs/data/date-pickers/getting-started/InstructionsNoSnap.js +++ b/docs/data/date-pickers/getting-started/InstructionsNoSnap.js @@ -8,7 +8,7 @@ import ToggleButton from '@mui/material/ToggleButton'; const libraries = ['date-fns', 'dayjs', 'luxon', 'moment']; -const InstructionsNoSnap = () => { +function InstructionsNoSnap() { const [licenceType, setLicenceType] = React.useState('community'); const [packageManger, setPackageManger] = React.useState('yarn'); const [libraryUsed, setLibraryUsed] = React.useState('moment'); @@ -74,6 +74,6 @@ const InstructionsNoSnap = () => { ); -}; +} export default InstructionsNoSnap; diff --git a/docs/data/date-pickers/time-range-field/TimeRangeFieldValue.js b/docs/data/date-pickers/time-range-field/TimeRangeFieldValue.js index 1dfe269e060b9..282f06bd5ab2f 100644 --- a/docs/data/date-pickers/time-range-field/TimeRangeFieldValue.js +++ b/docs/data/date-pickers/time-range-field/TimeRangeFieldValue.js @@ -9,7 +9,7 @@ import Grid from '@mui/material/Grid'; import Box from '@mui/material/Box'; import Typography from '@mui/material/Typography'; -const GridItem = ({ label, children, spacing = 1 }) => { +function GridItem({ label, children, spacing = 1 }) { return ( @@ -20,7 +20,7 @@ const GridItem = ({ label, children, spacing = 1 }) => { ); -}; +} // TODO: Use the same structure as on the other `XXXFieldValue` demos when using the single input version. diff --git a/docs/data/date-pickers/time-range-field/TimeRangeFieldValue.tsx b/docs/data/date-pickers/time-range-field/TimeRangeFieldValue.tsx index 8ef59223780e3..cb145714185f7 100644 --- a/docs/data/date-pickers/time-range-field/TimeRangeFieldValue.tsx +++ b/docs/data/date-pickers/time-range-field/TimeRangeFieldValue.tsx @@ -8,7 +8,7 @@ import Grid from '@mui/material/Grid'; import Box from '@mui/material/Box'; import Typography from '@mui/material/Typography'; -const GridItem = ({ +function GridItem({ label, children, spacing = 1, @@ -16,7 +16,7 @@ const GridItem = ({ label: string; children: React.ReactNode; spacing?: number; -}) => { +}) { return ( @@ -27,7 +27,7 @@ const GridItem = ({ ); -}; +} // TODO: Use the same structure as on the other `XXXFieldValue` demos when using the single input version. export default function TimeRangeFieldValue() { diff --git a/docs/data/date-pickers/validation/DateTimeValidationMaxDateTime.js b/docs/data/date-pickers/validation/DateTimeValidationMaxDateTime.js index 1aa8727144d01..86a25a5701604 100644 --- a/docs/data/date-pickers/validation/DateTimeValidationMaxDateTime.js +++ b/docs/data/date-pickers/validation/DateTimeValidationMaxDateTime.js @@ -11,7 +11,7 @@ import Typography from '@mui/material/Typography'; const todayAtNoon = dayjs().set('hour', 12).startOf('hour'); const todayAt9AM = dayjs().set('hour', 9).startOf('hour'); -const GridItem = ({ label, children, spacing = 1 }) => { +function GridItem({ label, children, spacing = 1 }) { return ( @@ -20,7 +20,7 @@ const GridItem = ({ label, children, spacing = 1 }) => { {children} ); -}; +} GridItem.propTypes = { children: PropTypes.node, diff --git a/docs/data/date-pickers/validation/DateTimeValidationMaxDateTime.tsx b/docs/data/date-pickers/validation/DateTimeValidationMaxDateTime.tsx index 5ef5c19075c3d..25a18282bfdc0 100644 --- a/docs/data/date-pickers/validation/DateTimeValidationMaxDateTime.tsx +++ b/docs/data/date-pickers/validation/DateTimeValidationMaxDateTime.tsx @@ -10,7 +10,7 @@ import Typography from '@mui/material/Typography'; const todayAtNoon = dayjs().set('hour', 12).startOf('hour'); const todayAt9AM = dayjs().set('hour', 9).startOf('hour'); -const GridItem = ({ +function GridItem({ label, children, spacing = 1, @@ -18,7 +18,7 @@ const GridItem = ({ label: string; children: React.ReactNode; spacing?: number; -}) => { +}) { return ( @@ -27,7 +27,7 @@ const GridItem = ({ {children} ); -}; +} export default function DateTimeValidationMaxDateTime() { const [value, setValue] = React.useState(todayAtNoon); diff --git a/docs/data/date-pickers/validation/DateTimeValidationMinDateTime.js b/docs/data/date-pickers/validation/DateTimeValidationMinDateTime.js index 11c33ab929632..f9a9d47f0f59a 100644 --- a/docs/data/date-pickers/validation/DateTimeValidationMinDateTime.js +++ b/docs/data/date-pickers/validation/DateTimeValidationMinDateTime.js @@ -11,7 +11,7 @@ import Typography from '@mui/material/Typography'; const todayAtNoon = dayjs().set('hour', 12).startOf('hour'); const todayAt3PM = dayjs().set('hour', 15).startOf('hour'); -const GridItem = ({ label, children, spacing = 1 }) => { +function GridItem({ label, children, spacing = 1 }) { return ( @@ -20,7 +20,7 @@ const GridItem = ({ label, children, spacing = 1 }) => { {children} ); -}; +} GridItem.propTypes = { children: PropTypes.node, diff --git a/docs/data/date-pickers/validation/DateTimeValidationMinDateTime.tsx b/docs/data/date-pickers/validation/DateTimeValidationMinDateTime.tsx index 63a9613376480..a8846873f1b16 100644 --- a/docs/data/date-pickers/validation/DateTimeValidationMinDateTime.tsx +++ b/docs/data/date-pickers/validation/DateTimeValidationMinDateTime.tsx @@ -10,7 +10,7 @@ import Typography from '@mui/material/Typography'; const todayAtNoon = dayjs().set('hour', 12).startOf('hour'); const todayAt3PM = dayjs().set('hour', 15).startOf('hour'); -const GridItem = ({ +function GridItem({ label, children, spacing = 1, @@ -18,7 +18,7 @@ const GridItem = ({ label: string; children: React.ReactNode; spacing?: number; -}) => { +}) { return ( @@ -27,7 +27,7 @@ const GridItem = ({ {children} ); -}; +} export default function DateTimeValidationMinDateTime() { const [value, setValue] = React.useState(todayAtNoon); diff --git a/docs/data/date-pickers/validation/DateValidationDisableFuture.js b/docs/data/date-pickers/validation/DateValidationDisableFuture.js index f7569449c9692..3c81835666737 100644 --- a/docs/data/date-pickers/validation/DateValidationDisableFuture.js +++ b/docs/data/date-pickers/validation/DateValidationDisableFuture.js @@ -16,7 +16,7 @@ const today = dayjs(); const tomorrow = dayjs().add(1, 'day'); const todayEndOfTheDay = today.endOf('day'); -const GridItem = ({ label, children, spacing = 1 }) => { +function GridItem({ label, children, spacing = 1 }) { return ( @@ -25,7 +25,7 @@ const GridItem = ({ label, children, spacing = 1 }) => { {children} ); -}; +} GridItem.propTypes = { children: PropTypes.node, diff --git a/docs/data/date-pickers/validation/DateValidationDisableFuture.tsx b/docs/data/date-pickers/validation/DateValidationDisableFuture.tsx index 5fc36202d63e0..61d1d83183e9f 100644 --- a/docs/data/date-pickers/validation/DateValidationDisableFuture.tsx +++ b/docs/data/date-pickers/validation/DateValidationDisableFuture.tsx @@ -15,7 +15,7 @@ const today = dayjs(); const tomorrow = dayjs().add(1, 'day'); const todayEndOfTheDay = today.endOf('day'); -const GridItem = ({ +function GridItem({ label, children, spacing = 1, @@ -23,7 +23,7 @@ const GridItem = ({ label: string; children: React.ReactNode; spacing?: number; -}) => { +}) { return ( @@ -32,7 +32,7 @@ const GridItem = ({ {children} ); -}; +} export default function DateValidationDisableFuture() { const [datePickerValue, setDatePickerValue] = React.useState( diff --git a/docs/data/date-pickers/validation/DateValidationDisablePast.js b/docs/data/date-pickers/validation/DateValidationDisablePast.js index b76b61817c191..f5f764cbda1a8 100644 --- a/docs/data/date-pickers/validation/DateValidationDisablePast.js +++ b/docs/data/date-pickers/validation/DateValidationDisablePast.js @@ -16,7 +16,7 @@ const today = dayjs(); const yesterday = dayjs().subtract(1, 'day'); const todayStartOfTheDay = today.startOf('day'); -const GridItem = ({ label, children, spacing = 1 }) => { +function GridItem({ label, children, spacing = 1 }) { return ( @@ -25,7 +25,7 @@ const GridItem = ({ label, children, spacing = 1 }) => { {children} ); -}; +} GridItem.propTypes = { children: PropTypes.node, diff --git a/docs/data/date-pickers/validation/DateValidationDisablePast.tsx b/docs/data/date-pickers/validation/DateValidationDisablePast.tsx index 5e2b997efa01f..4c0d3d37beee0 100644 --- a/docs/data/date-pickers/validation/DateValidationDisablePast.tsx +++ b/docs/data/date-pickers/validation/DateValidationDisablePast.tsx @@ -15,7 +15,7 @@ const today = dayjs(); const yesterday = dayjs().subtract(1, 'day'); const todayStartOfTheDay = today.startOf('day'); -const GridItem = ({ +function GridItem({ label, children, spacing = 1, @@ -23,7 +23,7 @@ const GridItem = ({ label: string; children: React.ReactNode; spacing?: number; -}) => { +}) { return ( @@ -32,7 +32,7 @@ const GridItem = ({ {children} ); -}; +} export default function DateValidationDisablePast() { const [datePickerValue, setDatePickerValue] = React.useState( diff --git a/docs/data/date-pickers/validation/DateValidationMaxDate.js b/docs/data/date-pickers/validation/DateValidationMaxDate.js index 1be5b58633a4d..1bc301030da3a 100644 --- a/docs/data/date-pickers/validation/DateValidationMaxDate.js +++ b/docs/data/date-pickers/validation/DateValidationMaxDate.js @@ -14,7 +14,7 @@ import { DateRangePicker } from '@mui/x-date-pickers-pro/DateRangePicker'; const today = dayjs(); const yesterday = dayjs().subtract(1, 'day'); -const GridItem = ({ label, children, spacing = 1 }) => { +function GridItem({ label, children, spacing = 1 }) { return ( @@ -23,7 +23,7 @@ const GridItem = ({ label, children, spacing = 1 }) => { {children} ); -}; +} GridItem.propTypes = { children: PropTypes.node, diff --git a/docs/data/date-pickers/validation/DateValidationMaxDate.tsx b/docs/data/date-pickers/validation/DateValidationMaxDate.tsx index 4ca72ac4a3a98..d6127788e2193 100644 --- a/docs/data/date-pickers/validation/DateValidationMaxDate.tsx +++ b/docs/data/date-pickers/validation/DateValidationMaxDate.tsx @@ -13,7 +13,7 @@ import { DateRange, DateRangePicker } from '@mui/x-date-pickers-pro/DateRangePic const today = dayjs(); const yesterday = dayjs().subtract(1, 'day'); -const GridItem = ({ +function GridItem({ label, children, spacing = 1, @@ -21,7 +21,7 @@ const GridItem = ({ label: string; children: React.ReactNode; spacing?: number; -}) => { +}) { return ( @@ -30,7 +30,7 @@ const GridItem = ({ {children} ); -}; +} export default function DateValidationMaxDate() { const [datePickerValue, setDatePickerValue] = React.useState(today); diff --git a/docs/data/date-pickers/validation/DateValidationMinDate.js b/docs/data/date-pickers/validation/DateValidationMinDate.js index cf023d8c5ee90..c9bac878169ba 100644 --- a/docs/data/date-pickers/validation/DateValidationMinDate.js +++ b/docs/data/date-pickers/validation/DateValidationMinDate.js @@ -14,7 +14,7 @@ import { DateRangePicker } from '@mui/x-date-pickers-pro/DateRangePicker'; const today = dayjs(); const tomorrow = dayjs().add(1, 'day'); -const GridItem = ({ label, children, spacing = 1 }) => { +function GridItem({ label, children, spacing = 1 }) { return ( @@ -23,7 +23,7 @@ const GridItem = ({ label, children, spacing = 1 }) => { {children} ); -}; +} GridItem.propTypes = { children: PropTypes.node, diff --git a/docs/data/date-pickers/validation/DateValidationMinDate.tsx b/docs/data/date-pickers/validation/DateValidationMinDate.tsx index 046242b9364da..9145895895714 100644 --- a/docs/data/date-pickers/validation/DateValidationMinDate.tsx +++ b/docs/data/date-pickers/validation/DateValidationMinDate.tsx @@ -13,7 +13,7 @@ import { DateRange, DateRangePicker } from '@mui/x-date-pickers-pro/DateRangePic const today = dayjs(); const tomorrow = dayjs().add(1, 'day'); -const GridItem = ({ +function GridItem({ label, children, spacing = 1, @@ -21,7 +21,7 @@ const GridItem = ({ label: string; children: React.ReactNode; spacing?: number; -}) => { +}) { return ( @@ -30,7 +30,7 @@ const GridItem = ({ {children} ); -}; +} export default function DateValidationMinDate() { const [datePickerValue, setDatePickerValue] = React.useState(today); diff --git a/docs/data/date-pickers/validation/DateValidationShouldDisableDate.js b/docs/data/date-pickers/validation/DateValidationShouldDisableDate.js index 6baec111cce0b..fb1ba6f0e622d 100644 --- a/docs/data/date-pickers/validation/DateValidationShouldDisableDate.js +++ b/docs/data/date-pickers/validation/DateValidationShouldDisableDate.js @@ -20,7 +20,7 @@ const isWeekend = (date) => { return day === 0 || day === 6; }; -const GridItem = ({ label, children, spacing = 1 }) => { +function GridItem({ label, children, spacing = 1 }) { return ( @@ -29,7 +29,7 @@ const GridItem = ({ label, children, spacing = 1 }) => { {children} ); -}; +} GridItem.propTypes = { children: PropTypes.node, diff --git a/docs/data/date-pickers/validation/DateValidationShouldDisableDate.tsx b/docs/data/date-pickers/validation/DateValidationShouldDisableDate.tsx index 1306d3352eb30..59ef6f4366770 100644 --- a/docs/data/date-pickers/validation/DateValidationShouldDisableDate.tsx +++ b/docs/data/date-pickers/validation/DateValidationShouldDisableDate.tsx @@ -19,7 +19,7 @@ const isWeekend = (date: Dayjs) => { return day === 0 || day === 6; }; -const GridItem = ({ +function GridItem({ label, children, spacing = 1, @@ -27,7 +27,7 @@ const GridItem = ({ label: string; children: React.ReactNode; spacing?: number; -}) => { +}) { return ( @@ -36,7 +36,7 @@ const GridItem = ({ {children} ); -}; +} export default function DateValidationShouldDisableDate() { const [datePickerValue, setDatePickerValue] = React.useState( diff --git a/docs/data/date-pickers/validation/DateValidationShouldDisableMonth.js b/docs/data/date-pickers/validation/DateValidationShouldDisableMonth.js index 4042c433bd885..bca54bc6320c6 100644 --- a/docs/data/date-pickers/validation/DateValidationShouldDisableMonth.js +++ b/docs/data/date-pickers/validation/DateValidationShouldDisableMonth.js @@ -14,7 +14,7 @@ const today = dayjs(); const isInCurrentMonth = (date) => date.get('month') === dayjs().get('month'); -const GridItem = ({ label, children, spacing = 1 }) => { +function GridItem({ label, children, spacing = 1 }) { return ( @@ -23,7 +23,7 @@ const GridItem = ({ label, children, spacing = 1 }) => { {children} ); -}; +} GridItem.propTypes = { children: PropTypes.node, diff --git a/docs/data/date-pickers/validation/DateValidationShouldDisableMonth.tsx b/docs/data/date-pickers/validation/DateValidationShouldDisableMonth.tsx index 6b36329fee075..a75a2b81f978f 100644 --- a/docs/data/date-pickers/validation/DateValidationShouldDisableMonth.tsx +++ b/docs/data/date-pickers/validation/DateValidationShouldDisableMonth.tsx @@ -13,7 +13,7 @@ const today = dayjs(); const isInCurrentMonth = (date: Dayjs) => date.get('month') === dayjs().get('month'); -const GridItem = ({ +function GridItem({ label, children, spacing = 1, @@ -21,7 +21,7 @@ const GridItem = ({ label: string; children: React.ReactNode; spacing?: number; -}) => { +}) { return ( @@ -30,7 +30,7 @@ const GridItem = ({ {children} ); -}; +} export default function DateValidationShouldDisableMonth() { const [datePickerValue, setDatePickerValue] = React.useState(today); diff --git a/docs/data/date-pickers/validation/DateValidationShouldDisableYear.js b/docs/data/date-pickers/validation/DateValidationShouldDisableYear.js index fa11c4c2da14c..3b2539a887f95 100644 --- a/docs/data/date-pickers/validation/DateValidationShouldDisableYear.js +++ b/docs/data/date-pickers/validation/DateValidationShouldDisableYear.js @@ -14,7 +14,7 @@ const today = dayjs(); const isInCurrentYear = (date) => date.get('year') === dayjs().get('year'); -const GridItem = ({ label, children, spacing = 1 }) => { +function GridItem({ label, children, spacing = 1 }) { return ( @@ -23,7 +23,7 @@ const GridItem = ({ label, children, spacing = 1 }) => { {children} ); -}; +} GridItem.propTypes = { children: PropTypes.node, diff --git a/docs/data/date-pickers/validation/DateValidationShouldDisableYear.tsx b/docs/data/date-pickers/validation/DateValidationShouldDisableYear.tsx index 71b151b1e5d5e..f79da68c83145 100644 --- a/docs/data/date-pickers/validation/DateValidationShouldDisableYear.tsx +++ b/docs/data/date-pickers/validation/DateValidationShouldDisableYear.tsx @@ -13,7 +13,7 @@ const today = dayjs(); const isInCurrentYear = (date: Dayjs) => date.get('year') === dayjs().get('year'); -const GridItem = ({ +function GridItem({ label, children, spacing = 1, @@ -21,7 +21,7 @@ const GridItem = ({ label: string; children: React.ReactNode; spacing?: number; -}) => { +}) { return ( @@ -30,7 +30,7 @@ const GridItem = ({ {children} ); -}; +} export default function DateValidationShouldDisableYear() { const [datePickerValue, setDatePickerValue] = React.useState(today); diff --git a/docs/data/date-pickers/validation/TimeValidationMaxTime.js b/docs/data/date-pickers/validation/TimeValidationMaxTime.js index 8e8b7229c6cf0..4ce86e2c9dd32 100644 --- a/docs/data/date-pickers/validation/TimeValidationMaxTime.js +++ b/docs/data/date-pickers/validation/TimeValidationMaxTime.js @@ -13,7 +13,7 @@ import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker'; const fiveAM = dayjs().set('hour', 5).startOf('hour'); const nineAM = dayjs().set('hour', 9).startOf('hour'); -const GridItem = ({ label, children, spacing = 1 }) => { +function GridItem({ label, children, spacing = 1 }) { return ( @@ -22,7 +22,7 @@ const GridItem = ({ label, children, spacing = 1 }) => { {children} ); -}; +} GridItem.propTypes = { children: PropTypes.node, diff --git a/docs/data/date-pickers/validation/TimeValidationMaxTime.tsx b/docs/data/date-pickers/validation/TimeValidationMaxTime.tsx index ffc3eb98e97c9..c49d43512356b 100644 --- a/docs/data/date-pickers/validation/TimeValidationMaxTime.tsx +++ b/docs/data/date-pickers/validation/TimeValidationMaxTime.tsx @@ -12,7 +12,7 @@ import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker'; const fiveAM = dayjs().set('hour', 5).startOf('hour'); const nineAM = dayjs().set('hour', 9).startOf('hour'); -const GridItem = ({ +function GridItem({ label, children, spacing = 1, @@ -20,7 +20,7 @@ const GridItem = ({ label: string; children: React.ReactNode; spacing?: number; -}) => { +}) { return ( @@ -29,7 +29,7 @@ const GridItem = ({ {children} ); -}; +} export default function TimeValidationMaxTime() { const [timePickerValue, setTimePickerValue] = React.useState(nineAM); diff --git a/docs/data/date-pickers/validation/TimeValidationMinTime.js b/docs/data/date-pickers/validation/TimeValidationMinTime.js index c96ac6a8380ba..410a440661957 100644 --- a/docs/data/date-pickers/validation/TimeValidationMinTime.js +++ b/docs/data/date-pickers/validation/TimeValidationMinTime.js @@ -13,7 +13,7 @@ import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker'; const fiveAM = dayjs().set('hour', 5).startOf('hour'); const nineAM = dayjs().set('hour', 9).startOf('hour'); -const GridItem = ({ label, children, spacing = 1 }) => { +function GridItem({ label, children, spacing = 1 }) { return ( @@ -22,7 +22,7 @@ const GridItem = ({ label, children, spacing = 1 }) => { {children} ); -}; +} GridItem.propTypes = { children: PropTypes.node, diff --git a/docs/data/date-pickers/validation/TimeValidationMinTime.tsx b/docs/data/date-pickers/validation/TimeValidationMinTime.tsx index ccfe4b8292052..32b1c3964baef 100644 --- a/docs/data/date-pickers/validation/TimeValidationMinTime.tsx +++ b/docs/data/date-pickers/validation/TimeValidationMinTime.tsx @@ -12,7 +12,7 @@ import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker'; const fiveAM = dayjs().set('hour', 5).startOf('hour'); const nineAM = dayjs().set('hour', 9).startOf('hour'); -const GridItem = ({ +function GridItem({ label, children, spacing = 1, @@ -20,7 +20,7 @@ const GridItem = ({ label: string; children: React.ReactNode; spacing?: number; -}) => { +}) { return ( @@ -29,7 +29,7 @@ const GridItem = ({ {children} ); -}; +} export default function TimeValidationMinTime() { const [timePickerValue, setTimePickerValue] = React.useState(fiveAM); diff --git a/docs/data/date-pickers/validation/TimeValidationShouldDisableTime.js b/docs/data/date-pickers/validation/TimeValidationShouldDisableTime.js index 94e1802008ad2..4e844d62d091a 100644 --- a/docs/data/date-pickers/validation/TimeValidationShouldDisableTime.js +++ b/docs/data/date-pickers/validation/TimeValidationShouldDisableTime.js @@ -14,7 +14,7 @@ const shouldDisableTime = (timeValue, view) => view === 'minutes' && timeValue > const defaultValue = dayjs().set('hour', 10).set('minute', 50).startOf('minute'); -const GridItem = ({ label, children, spacing = 1 }) => { +function GridItem({ label, children, spacing = 1 }) { return ( @@ -23,7 +23,7 @@ const GridItem = ({ label, children, spacing = 1 }) => { {children} ); -}; +} GridItem.propTypes = { children: PropTypes.node, diff --git a/docs/data/date-pickers/validation/TimeValidationShouldDisableTime.tsx b/docs/data/date-pickers/validation/TimeValidationShouldDisableTime.tsx index 1e89c4ef7ad65..0032e0b6e1982 100644 --- a/docs/data/date-pickers/validation/TimeValidationShouldDisableTime.tsx +++ b/docs/data/date-pickers/validation/TimeValidationShouldDisableTime.tsx @@ -16,7 +16,7 @@ const shouldDisableTime: TimePickerProps['shouldDisableTime'] = ( const defaultValue = dayjs().set('hour', 10).set('minute', 50).startOf('minute'); -const GridItem = ({ +function GridItem({ label, children, spacing = 1, @@ -24,7 +24,7 @@ const GridItem = ({ label: string; children: React.ReactNode; spacing?: number; -}) => { +}) { return ( @@ -33,7 +33,7 @@ const GridItem = ({ {children} ); -}; +} export default function TimeValidationShouldDisableTime() { const [timePickerValue, setTimePickerValue] = React.useState( diff --git a/docs/pages/_app.js b/docs/pages/_app.js index c5f94c2a87d36..5d19519ba0369 100644 --- a/docs/pages/_app.js +++ b/docs/pages/_app.js @@ -211,6 +211,8 @@ function AppWrapper(props) { ]; } + const pageContextValue = React.useMemo(() => ({ activePage, pages }), [activePage]); + return ( @@ -221,7 +223,7 @@ function AppWrapper(props) { - + {children} diff --git a/docs/scripts/helpers.js b/docs/scripts/helpers.js index 8bb40768472c4..4320ecd97d418 100644 --- a/docs/scripts/helpers.js +++ b/docs/scripts/helpers.js @@ -5,7 +5,7 @@ function getLineFeed(source) { return match === null ? os.EOL : match[0]; } -const fixBabelIssuesRegExp = new RegExp(/(?<=(\/>)|,)(\r?\n){2}/g); +const fixBabelIssuesRegExp = /(?<=(\/>)|,)(\r?\n){2}/g; function fixBabelGeneratorIssues(source) { return source.replace(fixBabelIssuesRegExp, '\n'); } diff --git a/docs/src/modules/components/SelectorsDocs.js b/docs/src/modules/components/SelectorsDocs.js index 19c3569ce5de2..1319adc4fb6a6 100644 --- a/docs/src/modules/components/SelectorsDocs.js +++ b/docs/src/modules/components/SelectorsDocs.js @@ -32,7 +32,7 @@ export const SelectorExample = styled(HighlightedCode)(({ theme }) => ({ const SELECTOR_NAME_PATTERN = /^grid(.*)Selector/; -const SelectorAccordion = ({ selector }) => { +function SelectorAccordion({ selector }) { let signature = `${selector.name}: (state: GridState) => ${selector.returnType}`; if (selector.supportsApiRef) { signature = [ @@ -83,7 +83,7 @@ const SelectorAccordion = ({ selector }) => { ); -}; +} function SelectorCategoryDocs(props) { const { selectors, ...other } = props; diff --git a/packages/grid/x-data-grid-generator/src/renderer/renderEditProgress.tsx b/packages/grid/x-data-grid-generator/src/renderer/renderEditProgress.tsx index 8c4601ef66425..185bc5f857dbb 100644 --- a/packages/grid/x-data-grid-generator/src/renderer/renderEditProgress.tsx +++ b/packages/grid/x-data-grid-generator/src/renderer/renderEditProgress.tsx @@ -42,7 +42,7 @@ const StyledSlider = styled(Slider)(({ theme }) => ({ }, })); -const ValueLabelComponent = (props: any) => { +function ValueLabelComponent(props: any) { const { children, open, value } = props; return ( @@ -50,7 +50,7 @@ const ValueLabelComponent = (props: any) => { {children} ); -}; +} function EditProgress(props: GridRenderEditCellParams) { const { id, value, field } = props; diff --git a/packages/grid/x-data-grid-premium/src/components/GridAggregationColumnMenuItem.tsx b/packages/grid/x-data-grid-premium/src/components/GridAggregationColumnMenuItem.tsx index 384ee60b22291..0686f60405c8f 100644 --- a/packages/grid/x-data-grid-premium/src/components/GridAggregationColumnMenuItem.tsx +++ b/packages/grid/x-data-grid-premium/src/components/GridAggregationColumnMenuItem.tsx @@ -20,7 +20,7 @@ interface GridAggregationColumnMenuItemsProps { availableAggregationFunctions: string[]; } -export const GridAggregationColumnMenuItem = (props: GridAggregationColumnMenuItemsProps) => { +export function GridAggregationColumnMenuItem(props: GridAggregationColumnMenuItemsProps) { const { column, label, availableAggregationFunctions } = props; const apiRef = useGridApiContext(); const rootProps = useGridRootProps(); @@ -88,4 +88,4 @@ export const GridAggregationColumnMenuItem = (props: GridAggregationColumnMenuIt ); -}; +} diff --git a/packages/grid/x-data-grid-premium/src/components/GridAggregationHeader.tsx b/packages/grid/x-data-grid-premium/src/components/GridAggregationHeader.tsx index 33d8856e61e87..ea52ae51ff073 100644 --- a/packages/grid/x-data-grid-premium/src/components/GridAggregationHeader.tsx +++ b/packages/grid/x-data-grid-premium/src/components/GridAggregationHeader.tsx @@ -68,7 +68,7 @@ const useUtilityClasses = (ownerState: OwnerState) => { return composeClasses(slots, getDataGridUtilityClass, classes); }; -const GridAggregationHeader = (props: GridColumnHeaderParams) => { +function GridAggregationHeader(props: GridColumnHeaderParams) { const { colDef, aggregation } = props; const apiRef = useGridApiContext(); @@ -99,6 +99,6 @@ const GridAggregationHeader = (props: GridColumnHeaderParams) => { ); -}; +} export { GridAggregationHeader }; diff --git a/packages/grid/x-data-grid-premium/src/components/GridExcelExportMenuItem.tsx b/packages/grid/x-data-grid-premium/src/components/GridExcelExportMenuItem.tsx index d7d83d437737f..0154a3e8ab3d9 100644 --- a/packages/grid/x-data-grid-premium/src/components/GridExcelExportMenuItem.tsx +++ b/packages/grid/x-data-grid-premium/src/components/GridExcelExportMenuItem.tsx @@ -7,7 +7,7 @@ import { GridExcelExportOptions } from '../hooks/features/export'; export type GridExcelExportMenuItemProps = GridExportMenuItemProps; -const GridExcelExportMenuItem = (props: GridExcelExportMenuItemProps) => { +function GridExcelExportMenuItem(props: GridExcelExportMenuItemProps) { const apiRef = useGridApiContext(); const { hideMenu, options, ...other } = props; @@ -22,7 +22,7 @@ const GridExcelExportMenuItem = (props: GridExcelExportMenuItemProps) => { {apiRef.current.getLocaleText('toolbarExportExcel')} ); -}; +} GridExcelExportMenuItem.propTypes = { // ----------------------------- Warning -------------------------------- diff --git a/packages/grid/x-data-grid-premium/src/components/GridFooterCell.tsx b/packages/grid/x-data-grid-premium/src/components/GridFooterCell.tsx index b3b9e8c0546c6..14995cbd324e6 100644 --- a/packages/grid/x-data-grid-premium/src/components/GridFooterCell.tsx +++ b/packages/grid/x-data-grid-premium/src/components/GridFooterCell.tsx @@ -34,7 +34,7 @@ const useUtilityClasses = (ownerState: OwnerState) => { return composeClasses(slots, getDataGridUtilityClass, classes); }; -const GridFooterCell = (props: GridFooterCellProps) => { +function GridFooterCell(props: GridFooterCellProps) { const { formattedValue, colDef, @@ -62,6 +62,6 @@ const GridFooterCell = (props: GridFooterCellProps) => { {formattedValue} ); -}; +} export { GridFooterCell }; diff --git a/packages/grid/x-data-grid-premium/src/components/GridGroupingColumnFooterCell.tsx b/packages/grid/x-data-grid-premium/src/components/GridGroupingColumnFooterCell.tsx index 2e5b399aabb79..7559b658eb9ed 100644 --- a/packages/grid/x-data-grid-premium/src/components/GridGroupingColumnFooterCell.tsx +++ b/packages/grid/x-data-grid-premium/src/components/GridGroupingColumnFooterCell.tsx @@ -3,7 +3,7 @@ import { GridRenderCellParams } from '@mui/x-data-grid-pro'; import { useGridRootProps } from '../hooks/utils/useGridRootProps'; import { GridFooterCell } from './GridFooterCell'; -const GridGroupingColumnFooterCell = (props: GridRenderCellParams) => { +function GridGroupingColumnFooterCell(props: GridRenderCellParams) { const { rowNode } = props; const rootProps = useGridRootProps(); @@ -18,6 +18,6 @@ const GridGroupingColumnFooterCell = (props: GridRenderCellParams) => { } return ; -}; +} export { GridGroupingColumnFooterCell }; diff --git a/packages/grid/x-data-grid-premium/src/components/GridGroupingColumnLeafCell.tsx b/packages/grid/x-data-grid-premium/src/components/GridGroupingColumnLeafCell.tsx index 6a6009fd19a04..25fe84a7796c1 100644 --- a/packages/grid/x-data-grid-premium/src/components/GridGroupingColumnLeafCell.tsx +++ b/packages/grid/x-data-grid-premium/src/components/GridGroupingColumnLeafCell.tsx @@ -3,7 +3,7 @@ import Box from '@mui/material/Box'; import { GridRenderCellParams } from '@mui/x-data-grid-pro'; import { useGridRootProps } from '../hooks/utils/useGridRootProps'; -const GridGroupingColumnLeafCell = (props: GridRenderCellParams) => { +function GridGroupingColumnLeafCell(props: GridRenderCellParams) { const { rowNode } = props; const rootProps = useGridRootProps(); @@ -11,6 +11,6 @@ const GridGroupingColumnLeafCell = (props: GridRenderCellParams) => { const marginLeft = rootProps.rowGroupingColumnMode === 'multiple' ? 1 : rowNode.depth * 2; return {props.formattedValue ?? props.value}; -}; +} export { GridGroupingColumnLeafCell }; diff --git a/packages/grid/x-data-grid-premium/src/components/GridGroupingCriteriaCell.tsx b/packages/grid/x-data-grid-premium/src/components/GridGroupingCriteriaCell.tsx index 01a9ee6b4ed4a..69c00dfaf484d 100644 --- a/packages/grid/x-data-grid-premium/src/components/GridGroupingCriteriaCell.tsx +++ b/packages/grid/x-data-grid-premium/src/components/GridGroupingCriteriaCell.tsx @@ -30,7 +30,7 @@ interface GridGroupingCriteriaCellProps extends GridRenderCellParams { +export function GridGroupingCriteriaCell(props: GridGroupingCriteriaCellProps) { const { id, field, rowNode, hideDescendantCount, formattedValue } = props; const rootProps = useGridRootProps(); @@ -87,4 +87,4 @@ export const GridGroupingCriteriaCell = (props: GridGroupingCriteriaCellProps) = ); -}; +} diff --git a/packages/grid/x-data-grid-premium/src/components/GridRowGroupableColumnMenuItems.tsx b/packages/grid/x-data-grid-premium/src/components/GridRowGroupableColumnMenuItems.tsx index 1c8a926e79cd9..f62449cd2fb95 100644 --- a/packages/grid/x-data-grid-premium/src/components/GridRowGroupableColumnMenuItems.tsx +++ b/packages/grid/x-data-grid-premium/src/components/GridRowGroupableColumnMenuItems.tsx @@ -10,7 +10,7 @@ interface GridRowGroupableColumnMenuItemsProps { onClick?: (event: React.MouseEvent) => void; } -const GridRowGroupableColumnMenuItems = (props: GridRowGroupableColumnMenuItemsProps) => { +function GridRowGroupableColumnMenuItems(props: GridRowGroupableColumnMenuItemsProps) { const { column, onClick } = props; const apiRef = useGridApiContext(); const rowGroupingModel = useGridSelector(apiRef, gridRowGroupingSanitizedModelSelector); @@ -47,7 +47,7 @@ const GridRowGroupableColumnMenuItems = (props: GridRowGroupableColumnMenuItemsP return ( {apiRef.current.getLocaleText('groupColumn')(name)} ); -}; +} GridRowGroupableColumnMenuItems.propTypes = { // ----------------------------- Warning -------------------------------- diff --git a/packages/grid/x-data-grid-premium/src/components/GridRowGroupingColumnMenuItems.tsx b/packages/grid/x-data-grid-premium/src/components/GridRowGroupingColumnMenuItems.tsx index 0889bc5b42ae2..f5557d8dd46d9 100644 --- a/packages/grid/x-data-grid-premium/src/components/GridRowGroupingColumnMenuItems.tsx +++ b/packages/grid/x-data-grid-premium/src/components/GridRowGroupingColumnMenuItems.tsx @@ -15,7 +15,7 @@ interface GridRowGroupingColumnMenuItemsProps { onClick?: (event: React.MouseEvent) => void; } -const GridRowGroupingColumnMenuItems = (props: GridRowGroupingColumnMenuItemsProps) => { +function GridRowGroupingColumnMenuItems(props: GridRowGroupingColumnMenuItemsProps) { const { column, onClick } = props; const apiRef = useGridApiContext(); const rowGroupingModel = useGridSelector(apiRef, gridRowGroupingSanitizedModelSelector); @@ -47,7 +47,7 @@ const GridRowGroupingColumnMenuItems = (props: GridRowGroupingColumnMenuItemsPro } return renderUnGroupingMenuItem(getRowGroupingCriteriaFromGroupingField(column.field)!); -}; +} GridRowGroupingColumnMenuItems.propTypes = { // ----------------------------- Warning -------------------------------- diff --git a/packages/grid/x-data-grid-premium/src/hooks/features/aggregation/useGridAggregationPreProcessors.tsx b/packages/grid/x-data-grid-premium/src/hooks/features/aggregation/useGridAggregationPreProcessors.tsx index 3e2146028bcda..a37245d1fe244 100644 --- a/packages/grid/x-data-grid-premium/src/hooks/features/aggregation/useGridAggregationPreProcessors.tsx +++ b/packages/grid/x-data-grid-premium/src/hooks/features/aggregation/useGridAggregationPreProcessors.tsx @@ -22,7 +22,9 @@ import { GridAggregationColumnMenuItem } from '../../../components/GridAggregati import { gridAggregationModelSelector } from './gridAggregationSelectors'; import { GridInitialStatePremium } from '../../../models/gridStatePremium'; -const Divider = () => event.stopPropagation()} />; +function Divider() { + return event.stopPropagation()} />; +} export const useGridAggregationPreProcessors = ( apiRef: React.MutableRefObject, diff --git a/packages/grid/x-data-grid-premium/src/hooks/features/rowGrouping/gridRowGroupingUtils.ts b/packages/grid/x-data-grid-premium/src/hooks/features/rowGrouping/gridRowGroupingUtils.ts index 161c9f3365388..cfc239ca54876 100644 --- a/packages/grid/x-data-grid-premium/src/hooks/features/rowGrouping/gridRowGroupingUtils.ts +++ b/packages/grid/x-data-grid-premium/src/hooks/features/rowGrouping/gridRowGroupingUtils.ts @@ -264,7 +264,7 @@ export const getGroupingRules = ({ * Compares two sets of grouping rules to determine if they are equal or not. */ export const areGroupingRulesEqual = ( - previousValue: GridGroupingRules | undefined = [], + previousValue: GridGroupingRules = [], newValue: GridGroupingRules, ) => { if (previousValue.length !== newValue.length) { diff --git a/packages/grid/x-data-grid-premium/src/hooks/features/rowGrouping/useGridRowGrouping.tsx b/packages/grid/x-data-grid-premium/src/hooks/features/rowGrouping/useGridRowGrouping.tsx index 8bdf5a4c7e24e..b12c7d92304e9 100644 --- a/packages/grid/x-data-grid-premium/src/hooks/features/rowGrouping/useGridRowGrouping.tsx +++ b/packages/grid/x-data-grid-premium/src/hooks/features/rowGrouping/useGridRowGrouping.tsx @@ -32,7 +32,9 @@ import { GridRowGroupableColumnMenuItems } from '../../../components/GridRowGrou import { GridRowGroupingColumnMenuItems } from '../../../components/GridRowGroupingColumnMenuItems'; import { GridInitialStatePremium } from '../../../models/gridStatePremium'; -const Divider = () => event.stopPropagation()} />; +function Divider() { + return event.stopPropagation()} />; +} export const rowGroupingStateInitializer: GridStateInitializer< Pick diff --git a/packages/grid/x-data-grid-premium/src/tests/aggregation.DataGridPremium.test.tsx b/packages/grid/x-data-grid-premium/src/tests/aggregation.DataGridPremium.test.tsx index ac03366736121..4778e4299ecaa 100644 --- a/packages/grid/x-data-grid-premium/src/tests/aggregation.DataGridPremium.test.tsx +++ b/packages/grid/x-data-grid-premium/src/tests/aggregation.DataGridPremium.test.tsx @@ -47,7 +47,7 @@ describe(' - Aggregation', () => { let apiRef: React.MutableRefObject; - const Test = (props: Partial) => { + function Test(props: Partial) { apiRef = useGridApiRef(); return ( @@ -55,7 +55,7 @@ describe(' - Aggregation', () => { ); - }; + } describe('Setting aggregation model', () => { describe('initialState: aggregation.model', () => { @@ -270,7 +270,7 @@ describe(' - Aggregation', () => { }); describe('Tree Data', () => { - const TreeDataTest = (props: Omit) => { + function TreeDataTest(props: Omit) { return ( - Aggregation', () => { {...props} /> ); - }; + } it('should use aggregated values instead of provided values on data groups', () => { render( diff --git a/packages/grid/x-data-grid-premium/src/tests/exportExcel.DataGridPremium.test.tsx b/packages/grid/x-data-grid-premium/src/tests/exportExcel.DataGridPremium.test.tsx index 2e0989d2177cf..fd3e6f29b3dc0 100644 --- a/packages/grid/x-data-grid-premium/src/tests/exportExcel.DataGridPremium.test.tsx +++ b/packages/grid/x-data-grid-premium/src/tests/exportExcel.DataGridPremium.test.tsx @@ -41,14 +41,14 @@ describe(' - Export Excel', () => { autoHeight: isJSDOM, }; - const TestCaseExcelExport = (props: Partial) => { + function TestCaseExcelExport(props: Partial) { apiRef = useGridApiRef(); return (
); - }; + } describe('export interface', () => { it('should generate a file', async () => { @@ -67,7 +67,7 @@ describe(' - Export Excel', () => { describe('generated file', () => { it(`should export column with correct type`, async () => { - const Test = () => { + function Test() { apiRef = useGridApiRef(); return (
@@ -95,7 +95,7 @@ describe(' - Export Excel', () => { />
); - }; + } render(); const workbook = await act(() => apiRef.current.getDataAsExcel()); @@ -123,7 +123,7 @@ describe(' - Export Excel', () => { }); it(`should export singleSelect options`, async () => { - const Test = () => { + function Test() { apiRef = useGridApiRef(); return (
@@ -139,7 +139,7 @@ describe(' - Export Excel', () => { />
); - }; + } render(); const workbook = await act(() => apiRef.current.getDataAsExcel()); @@ -151,8 +151,10 @@ describe(' - Export Excel', () => { }); it(`should not export actions columns`, async () => { - const Icon = () => i; - const Test = () => { + function Icon() { + return i; + } + function Test() { apiRef = useGridApiRef(); return (
@@ -177,7 +179,7 @@ describe(' - Export Excel', () => { />
); - }; + } render(); const workbook = await act(() => apiRef.current.getDataAsExcel()); @@ -190,7 +192,7 @@ describe(' - Export Excel', () => { }); it('should merge cells with `colSpan`', async () => { - const Test = () => { + function Test() { apiRef = useGridApiRef(); return (
@@ -215,7 +217,7 @@ describe(' - Export Excel', () => { />
); - }; + } render(); const workbook = await act(() => apiRef.current.getDataAsExcel()); @@ -242,7 +244,7 @@ describe(' - Export Excel', () => { }); it('should export hidden columns when `allColumns=true`', async () => { - const Test = () => { + function Test() { apiRef = useGridApiRef(); return (
@@ -268,7 +270,7 @@ describe(' - Export Excel', () => { />
); - }; + } render(); const workbook = await apiRef.current.getDataAsExcel({ @@ -284,7 +286,7 @@ describe(' - Export Excel', () => { }); it(`should export column grouping`, async () => { - const Test = () => { + function Test() { apiRef = useGridApiRef(); return (
@@ -317,7 +319,7 @@ describe(' - Export Excel', () => { />
); - }; + } render(); const workbook = await act(() => apiRef.current.getDataAsExcel()); diff --git a/packages/grid/x-data-grid-premium/src/tests/rowGrouping.DataGridPremium.test.tsx b/packages/grid/x-data-grid-premium/src/tests/rowGrouping.DataGridPremium.test.tsx index dbdf1a9aff6b1..debdb40e4c854 100644 --- a/packages/grid/x-data-grid-premium/src/tests/rowGrouping.DataGridPremium.test.tsx +++ b/packages/grid/x-data-grid-premium/src/tests/rowGrouping.DataGridPremium.test.tsx @@ -66,7 +66,7 @@ describe(' - Row Grouping', () => { let apiRef: React.MutableRefObject; - const Test = (props: Partial) => { + function Test(props: Partial) { apiRef = useGridApiRef(); return ( @@ -74,7 +74,7 @@ describe(' - Row Grouping', () => { ); - }; + } describe('Setting grouping criteria', () => { describe('initialState: rowGrouping.model', () => { diff --git a/packages/grid/x-data-grid-premium/src/tests/rowPinning.DataGridPremium.test.tsx b/packages/grid/x-data-grid-premium/src/tests/rowPinning.DataGridPremium.test.tsx index d4e7aaa05c8f3..aab941eb7a949 100644 --- a/packages/grid/x-data-grid-premium/src/tests/rowPinning.DataGridPremium.test.tsx +++ b/packages/grid/x-data-grid-premium/src/tests/rowPinning.DataGridPremium.test.tsx @@ -61,7 +61,7 @@ describe(' - Row pinning', () => { } it('should render pinned rows outside of row groups', () => { - const Test = () => { + function Test() { const [pinnedRow0, pinnedRow1, ...rowsData] = rows; return ( @@ -78,7 +78,7 @@ describe(' - Row pinning', () => { /> ); - }; + } render(); diff --git a/packages/grid/x-data-grid-premium/src/tests/statePersistence.DataGridPremium.test.tsx b/packages/grid/x-data-grid-premium/src/tests/statePersistence.DataGridPremium.test.tsx index 1587a511f91b9..99db4001de09c 100644 --- a/packages/grid/x-data-grid-premium/src/tests/statePersistence.DataGridPremium.test.tsx +++ b/packages/grid/x-data-grid-premium/src/tests/statePersistence.DataGridPremium.test.tsx @@ -53,7 +53,7 @@ describe(' - State Persistence', () => { let apiRef: React.MutableRefObject; - const TestCase = (props: Omit) => { + function TestCase(props: Omit) { apiRef = useGridApiRef(); return ( @@ -71,7 +71,7 @@ describe(' - State Persistence', () => { /> ); - }; + } describe('apiRef: exportState', () => { it('should export the initial values of the models', () => { diff --git a/packages/grid/x-data-grid-pro/src/components/GridColumnPinningMenuItems.tsx b/packages/grid/x-data-grid-pro/src/components/GridColumnPinningMenuItems.tsx index 9c2a4a25aa247..9861ee22873c4 100644 --- a/packages/grid/x-data-grid-pro/src/components/GridColumnPinningMenuItems.tsx +++ b/packages/grid/x-data-grid-pro/src/components/GridColumnPinningMenuItems.tsx @@ -10,7 +10,7 @@ interface GridColumnPinningMenuItemsProps { onClick?: (event: React.MouseEvent) => void; } -const GridColumnPinningMenuItems = (props: GridColumnPinningMenuItemsProps) => { +function GridColumnPinningMenuItems(props: GridColumnPinningMenuItemsProps) { const { column, onClick } = props; const apiRef = useGridApiContext(); @@ -59,7 +59,7 @@ const GridColumnPinningMenuItems = (props: GridColumnPinningMenuItemsProps) => {
); -}; +} GridColumnPinningMenuItems.propTypes = { // ----------------------------- Warning -------------------------------- diff --git a/packages/grid/x-data-grid-pro/src/components/GridDetailPanel.tsx b/packages/grid/x-data-grid-pro/src/components/GridDetailPanel.tsx index cb08ea8b0bb2f..c6836e2b65071 100644 --- a/packages/grid/x-data-grid-pro/src/components/GridDetailPanel.tsx +++ b/packages/grid/x-data-grid-pro/src/components/GridDetailPanel.tsx @@ -31,7 +31,7 @@ interface GridDetailPanelProps extends React.HTMLAttributes { rowId: GridRowId; } -const GridDetailPanel = (props: GridDetailPanelProps) => { +function GridDetailPanel(props: GridDetailPanelProps) { const { rowId, height, style: styleProp = {}, ...other } = props; const apiRef = useGridApiContext(); const ref = React.useRef(); @@ -67,6 +67,6 @@ const GridDetailPanel = (props: GridDetailPanelProps) => { const style = { ...styleProp, height }; return ; -}; +} export { GridDetailPanel }; diff --git a/packages/grid/x-data-grid-pro/src/components/GridDetailPanelToggleCell.tsx b/packages/grid/x-data-grid-pro/src/components/GridDetailPanelToggleCell.tsx index 5e0f293ae7e1c..57da2ae5d78a9 100644 --- a/packages/grid/x-data-grid-pro/src/components/GridDetailPanelToggleCell.tsx +++ b/packages/grid/x-data-grid-pro/src/components/GridDetailPanelToggleCell.tsx @@ -20,7 +20,7 @@ const useUtilityClasses = (ownerState: OwnerState) => { return composeClasses(slots, getDataGridUtilityClass, classes); }; -const GridDetailPanelToggleCell = (props: GridRenderCellParams) => { +function GridDetailPanelToggleCell(props: GridRenderCellParams) { const { id, value: isExpanded } = props; const rootProps = useGridRootProps(); @@ -50,7 +50,7 @@ const GridDetailPanelToggleCell = (props: GridRenderCellParams) => { ); -}; +} GridDetailPanelToggleCell.propTypes = { // ----------------------------- Warning -------------------------------- diff --git a/packages/grid/x-data-grid-pro/src/components/GridRowReorderCell.tsx b/packages/grid/x-data-grid-pro/src/components/GridRowReorderCell.tsx index 7d8ec780e1aec..4f5bf51378389 100644 --- a/packages/grid/x-data-grid-pro/src/components/GridRowReorderCell.tsx +++ b/packages/grid/x-data-grid-pro/src/components/GridRowReorderCell.tsx @@ -29,7 +29,7 @@ const useUtilityClasses = (ownerState: OwnerState) => { return composeClasses(slots, getDataGridUtilityClass, classes); }; -const GridRowReorderCell = (params: GridRenderCellParams) => { +function GridRowReorderCell(params: GridRenderCellParams) { const apiRef = useGridApiContext(); const rootProps = useGridRootProps(); const sortModel = useGridSelector(apiRef, gridSortModelSelector); @@ -99,7 +99,7 @@ const GridRowReorderCell = (params: GridRenderCellParams) => {
{cellValue}
); -}; +} export { GridRowReorderCell }; diff --git a/packages/grid/x-data-grid-pro/src/components/GridTreeDataGroupingCell.tsx b/packages/grid/x-data-grid-pro/src/components/GridTreeDataGroupingCell.tsx index caf515b4a732c..615a3fe927298 100644 --- a/packages/grid/x-data-grid-pro/src/components/GridTreeDataGroupingCell.tsx +++ b/packages/grid/x-data-grid-pro/src/components/GridTreeDataGroupingCell.tsx @@ -32,7 +32,7 @@ interface GridTreeDataGroupingCellProps extends GridRenderCellParams { +function GridTreeDataGroupingCell(props: GridTreeDataGroupingCellProps) { const { id, field, formattedValue, rowNode, hideDescendantCount } = props; const rootProps = useGridRootProps(); @@ -90,7 +90,7 @@ const GridTreeDataGroupingCell = (props: GridTreeDataGroupingCellProps) => { ); -}; +} GridTreeDataGroupingCell.propTypes = { // ----------------------------- Warning -------------------------------- diff --git a/packages/grid/x-data-grid-pro/src/hooks/features/columnPinning/useGridColumnPinning.tsx b/packages/grid/x-data-grid-pro/src/hooks/features/columnPinning/useGridColumnPinning.tsx index a4538293b2e33..165bce24fc53e 100644 --- a/packages/grid/x-data-grid-pro/src/hooks/features/columnPinning/useGridColumnPinning.tsx +++ b/packages/grid/x-data-grid-pro/src/hooks/features/columnPinning/useGridColumnPinning.tsx @@ -30,7 +30,9 @@ import { import { gridPinnedColumnsSelector } from './gridColumnPinningSelector'; import { filterColumns } from '../../../components/DataGridProVirtualScroller'; -const Divider = () => event.stopPropagation()} />; +function Divider() { + return event.stopPropagation()} />; +} export const columnPinningStateInitializer: GridStateInitializer< Pick diff --git a/packages/grid/x-data-grid-pro/src/tests/accessibility.DataGridPro.test.tsx b/packages/grid/x-data-grid-pro/src/tests/accessibility.DataGridPro.test.tsx index 02f9520c29f77..702a6af090717 100644 --- a/packages/grid/x-data-grid-pro/src/tests/accessibility.DataGridPro.test.tsx +++ b/packages/grid/x-data-grid-pro/src/tests/accessibility.DataGridPro.test.tsx @@ -26,7 +26,7 @@ describe(' - Accessibility', () => { const { render } = createRenderer(); it('pinned columns should pass `aria-required-parent` rule', async () => { - const TestCase = () => { + function TestCase() { const data = useBasicDemoData(1, 3); return (
@@ -37,7 +37,7 @@ describe(' - Accessibility', () => { />
); - }; + } render(); diff --git a/packages/grid/x-data-grid-pro/src/tests/cellEditing.DataGridPro.test.tsx b/packages/grid/x-data-grid-pro/src/tests/cellEditing.DataGridPro.test.tsx index 46d10335dd38a..be4e881c6468b 100644 --- a/packages/grid/x-data-grid-pro/src/tests/cellEditing.DataGridPro.test.tsx +++ b/packages/grid/x-data-grid-pro/src/tests/cellEditing.DataGridPro.test.tsx @@ -30,7 +30,7 @@ describe(' - Cell Editing', () => { let columnProps: any = {}; - const TestCase = (props: Partial) => { + function TestCase(props: Partial) { apiRef = useGridApiRef(); return (
@@ -46,7 +46,7 @@ describe(' - Cell Editing', () => { />
); - }; + } afterEach(() => { renderEditCell.resetHistory(); @@ -316,7 +316,7 @@ describe(' - Cell Editing', () => { }); describe('stopCellEditMode', () => { - const CustomEditComponent = ({ hasFocus }: GridCellProps) => { + function CustomEditComponent({ hasFocus }: GridCellProps) { const ref = React.useRef(null); React.useLayoutEffect(() => { if (hasFocus) { @@ -324,7 +324,7 @@ describe(' - Cell Editing', () => { } }, [hasFocus]); return ; - }; + } it('should throw an error when the cell is not in edit mode', () => { render(); diff --git a/packages/grid/x-data-grid-pro/src/tests/columnHeaders.DataGridPro.test.tsx b/packages/grid/x-data-grid-pro/src/tests/columnHeaders.DataGridPro.test.tsx index 44a4d8d8893be..0b88f04ff3e6f 100644 --- a/packages/grid/x-data-grid-pro/src/tests/columnHeaders.DataGridPro.test.tsx +++ b/packages/grid/x-data-grid-pro/src/tests/columnHeaders.DataGridPro.test.tsx @@ -71,13 +71,13 @@ describe(' - Column Headers', () => { }); it('should not close the menu when updating the rows prop', () => { - const Test = (props: Partial) => { + function Test(props: Partial) { return (
); - }; + } const { setProps } = render(); const columnCell = getColumnHeaderCell(0); const menuIconButton = columnCell.querySelector('button[aria-label="Menu"]'); @@ -216,7 +216,7 @@ describe(' - Column Headers', () => { }); it('should restore focus to the column header when dismissing the menu by selecting any item', () => { - const Test = (props: Partial) => { + function Test(props: Partial) { return (
- Column Headers', () => { />
); - }; + } render(); const columnCell = getColumnHeaderCell(0); const menuIconButton = columnCell.querySelector('button[aria-label="Menu"]'); @@ -246,13 +246,13 @@ describe(' - Column Headers', () => { }); it('should restore focus to the column header when dismissing the menu without selecting any item', () => { - const Test = (props: Partial) => { + function Test(props: Partial) { return (
); - }; + } render(); const columnCell = getColumnHeaderCell(0); const menuIconButton = columnCell.querySelector('button[aria-label="Menu"]'); diff --git a/packages/grid/x-data-grid-pro/src/tests/columnPinning.DataGridPro.test.tsx b/packages/grid/x-data-grid-pro/src/tests/columnPinning.DataGridPro.test.tsx index 8e7db78dad673..13368e079adeb 100644 --- a/packages/grid/x-data-grid-pro/src/tests/columnPinning.DataGridPro.test.tsx +++ b/packages/grid/x-data-grid-pro/src/tests/columnPinning.DataGridPro.test.tsx @@ -40,7 +40,7 @@ describe(' - Column pinning', () => { let apiRef: React.MutableRefObject; - const TestCase = ({ nbCols = 20, ...other }: Partial & { nbCols?: number }) => { + function TestCase({ nbCols = 20, ...other }: Partial & { nbCols?: number }) { apiRef = useGridApiRef(); const data = useBasicDemoData(1, nbCols); return ( @@ -48,7 +48,7 @@ describe(' - Column pinning', () => { ); - }; + } function ResizeObserverMock( callback: (entries: { borderBoxSize: [{ blockSize: number }] }[]) => void, @@ -277,7 +277,7 @@ describe(' - Column pinning', () => { this.skip(); } - const Test = ({ bioHeight }: { bioHeight: number }) => { + function Test({ bioHeight }: { bioHeight: number }) { const data = React.useMemo(() => getBasicGridData(1, 2), []); const columns = [ @@ -293,7 +293,7 @@ describe(' - Column pinning', () => { initialState={{ pinnedColumns: { left: ['id'], right: ['bio'] } }} /> ); - }; + } render(); await act(() => Promise.resolve()); @@ -315,7 +315,7 @@ describe(' - Column pinning', () => { this.skip(); } - const Test = ({ bioHeight }: { bioHeight: number }) => { + function Test({ bioHeight }: { bioHeight: number }) { const data = React.useMemo(() => getBasicGridData(1, 2), []); const columns = [ @@ -331,7 +331,7 @@ describe(' - Column pinning', () => { initialState={{ pinnedColumns: { left: ['id'], right: ['bio'] } }} /> ); - }; + } const { setProps } = render(); await act(() => Promise.resolve()); diff --git a/packages/grid/x-data-grid-pro/src/tests/columnReorder.DataGridPro.test.tsx b/packages/grid/x-data-grid-pro/src/tests/columnReorder.DataGridPro.test.tsx index 0c92cb6754189..003f1869d43d1 100644 --- a/packages/grid/x-data-grid-pro/src/tests/columnReorder.DataGridPro.test.tsx +++ b/packages/grid/x-data-grid-pro/src/tests/columnReorder.DataGridPro.test.tsx @@ -54,7 +54,7 @@ describe(' - Columns reorder', () => { it('resizing after columns reorder should respect the new columns order', async () => { let apiRef: React.MutableRefObject; - const TestCase = (props: { width: number }) => { + function TestCase(props: { width: number }) { const { width } = props; apiRef = useGridApiRef(); return ( @@ -62,7 +62,7 @@ describe(' - Columns reorder', () => { ); - }; + } const { setProps } = render(); @@ -78,7 +78,7 @@ describe(' - Columns reorder', () => { const rows = [{ id: 0, brand: 'Nike' }]; const columns = [{ field: 'brand' }, { field: 'desc' }, { field: 'type' }]; - const Test = () => { + function Test() { apiRef = useGridApiRef(); return ( @@ -86,7 +86,7 @@ describe(' - Columns reorder', () => { ); - }; + } const { forceUpdate } = render(); expect(getColumnHeadersTextContent()).to.deep.equal(['brand', 'desc', 'type']); @@ -101,7 +101,7 @@ describe(' - Columns reorder', () => { const rows = [{ id: 0, brand: 'Nike' }]; const columns = [{ field: 'brand' }, { field: 'desc' }, { field: 'type' }]; - const Test = () => { + function Test() { apiRef = useGridApiRef(); return ( @@ -109,7 +109,7 @@ describe(' - Columns reorder', () => { ); - }; + } render(); expect(getColumnHeadersTextContent()).to.deep.equal(['brand', 'desc', 'type']); @@ -132,7 +132,7 @@ describe(' - Columns reorder', () => { const rows = [{ id: 0, brand: 'Nike' }]; const columns = [{ field: 'brand' }, { field: 'desc' }, { field: 'type' }]; - const Test = () => { + function Test() { apiRef = useGridApiRef(); return ( @@ -140,7 +140,7 @@ describe(' - Columns reorder', () => { ); - }; + } render(); expect(getColumnHeadersTextContent()).to.deep.equal(['brand', 'desc', 'type']); @@ -163,7 +163,7 @@ describe(' - Columns reorder', () => { const rows = [{ id: 0, brand: 'Nike' }]; const columns = [{ field: 'brand' }, { field: 'desc' }, { field: 'type' }]; - const Test = () => { + function Test() { apiRef = useGridApiRef(); return ( @@ -171,7 +171,7 @@ describe(' - Columns reorder', () => { ); - }; + } render(); expect(getColumnHeadersTextContent()).to.deep.equal(['brand', 'desc', 'type']); @@ -188,7 +188,7 @@ describe(' - Columns reorder', () => { const rows = [{ id: 0, brand: 'Nike' }]; const columns = [{ field: 'brand' }, { field: 'desc' }, { field: 'type' }]; - const Test = () => { + function Test() { apiRef = useGridApiRef(); return ( @@ -196,7 +196,7 @@ describe(' - Columns reorder', () => { ); - }; + } render(); expect(getColumnHeadersTextContent()).to.deep.equal(['brand', 'desc', 'type']); @@ -209,7 +209,7 @@ describe(' - Columns reorder', () => { it('should call onColumnOrderChange after the column has been reordered', () => { const onColumnOrderChange = spy(); let apiRef: React.MutableRefObject; - const Test = () => { + function Test() { apiRef = useGridApiRef(); const data = useBasicDemoData(1, 3); @@ -218,7 +218,7 @@ describe(' - Columns reorder', () => { ); - }; + } render(); @@ -250,7 +250,7 @@ describe(' - Columns reorder', () => { { field: 'type' }, ]; - const Test = () => { + function Test() { apiRef = useGridApiRef(); return ( @@ -258,7 +258,7 @@ describe(' - Columns reorder', () => { ); - }; + } render(); expect(getColumnHeadersTextContent()).to.deep.equal(['brand', 'desc', 'type']); @@ -289,7 +289,7 @@ describe(' - Columns reorder', () => { { field: 'type' }, ]; - const Test = () => { + function Test() { apiRef = useGridApiRef(); return ( @@ -297,7 +297,7 @@ describe(' - Columns reorder', () => { ); - }; + } render(); expect(getColumnHeadersTextContent()).to.deep.equal(['brand', 'desc', 'type']); @@ -324,7 +324,7 @@ describe(' - Columns reorder', () => { { field: 'type', disableReorder: true }, ]; - const Test = () => { + function Test() { apiRef = useGridApiRef(); return ( @@ -332,7 +332,7 @@ describe(' - Columns reorder', () => { ); - }; + } render(); expect(getColumnHeadersTextContent()).to.deep.equal(['brand', 'desc', 'type']); @@ -358,13 +358,13 @@ describe(' - Columns reorder', () => { { field: 'type' }, ]; - const Test = () => { + function Test() { return (
); - }; + } render(); expect(getColumnHeadersTextContent()).to.deep.equal(['brand', 'desc', 'type']); @@ -389,7 +389,7 @@ describe(' - Columns reorder', () => { const handleDragOver = spy(); const handleDragEnd = spy(); let apiRef: React.MutableRefObject; - const Test = () => { + function Test() { apiRef = useGridApiRef(); const data = useBasicDemoData(3, 3); @@ -405,7 +405,7 @@ describe(' - Columns reorder', () => { ); - }; + } render(); @@ -434,7 +434,7 @@ describe(' - Columns reorder', () => { { groupId: 'col12', children: [{ field: 'col1' }, { field: 'col2' }] }, ]; - const Test = () => { + function Test() { return (
- Columns reorder', () => { />
); - }; + } render(); expect(getColumnHeadersTextContent()).to.deep.equal(['col12', '', 'col1', 'col2', 'col3']); @@ -477,7 +477,7 @@ describe(' - Columns reorder', () => { { groupId: 'col23', children: [{ field: 'col2' }, { field: 'col3' }] }, ]; - const Test = () => { + function Test() { return (
- Columns reorder', () => { />
); - }; + } render(); expect(getColumnHeadersTextContent()).to.deep.equal(['col23', '', 'col2', 'col3', 'col4']); @@ -519,7 +519,7 @@ describe(' - Columns reorder', () => { { groupId: 'col23', children: [{ field: 'col2' }, { field: 'col3' }] }, ]; - const Test = (props: any) => { + function Test(props: any) { return (
- Columns reorder', () => { />
); - }; + } const { setProps } = render(); expect(getColumnHeadersTextContent()).to.deep.equal(['', 'col23', 'col1', 'col2']); @@ -559,7 +559,7 @@ describe(' - Columns reorder', () => { { groupId: 'col12', children: [{ field: 'col1' }, { field: 'col2' }] }, ]; - const Test = () => { + function Test() { return (
- Columns reorder', () => { />
); - }; + } render(); expect(getColumnHeadersTextContent()).to.deep.equal(['col12', '', 'col1', 'col2', 'col3']); @@ -600,7 +600,7 @@ describe(' - Columns reorder', () => { }, ]; - const Test = () => { + function Test() { return (
- Columns reorder', () => { />
); - }; + } render(); expect(getColumnHeadersTextContent()).to.deep.equal(['col12', '', 'col1', 'col2', 'col3']); @@ -659,7 +659,7 @@ describe(' - Columns reorder', () => { }, ]; - const Test = () => { + function Test() { return (
- Columns reorder', () => { />
); - }; + } render(); expect(getColumnHeadersTextContent()).to.deep.equal(['', 'col23', 'col1', 'col2', 'col3']); @@ -720,7 +720,7 @@ describe(' - Columns reorder', () => { }, ]; - const Test = () => { + function Test() { return (
- Columns reorder', () => { />
); - }; + } render(); expect(getColumnHeadersTextContent()).to.deep.equal([ @@ -790,7 +790,7 @@ describe(' - Columns reorder', () => { }, ]; - const Test = () => { + function Test() { return (
- Columns reorder', () => { />
); - }; + } render(); expect(getColumnHeadersTextContent()).to.deep.equal([ diff --git a/packages/grid/x-data-grid-pro/src/tests/columnSpanning.DataGridPro.test.tsx b/packages/grid/x-data-grid-pro/src/tests/columnSpanning.DataGridPro.test.tsx index 80e2aa7f2edca..3e784f1f51838 100644 --- a/packages/grid/x-data-grid-pro/src/tests/columnSpanning.DataGridPro.test.tsx +++ b/packages/grid/x-data-grid-pro/src/tests/columnSpanning.DataGridPro.test.tsx @@ -89,7 +89,7 @@ describe(' - Column Spanning', () => { it('should work after column reordering', () => { let apiRef: React.MutableRefObject; - const Test = () => { + function Test() { apiRef = useGridApiRef(); return ( @@ -97,7 +97,7 @@ describe(' - Column Spanning', () => { ); - }; + } render(); @@ -112,7 +112,7 @@ describe(' - Column Spanning', () => { it('should recalculate cells after column reordering', () => { let apiRef: React.MutableRefObject; - const Test = () => { + function Test() { apiRef = useGridApiRef(); return ( @@ -130,7 +130,7 @@ describe(' - Column Spanning', () => { /> ); - }; + } render(); @@ -193,7 +193,7 @@ describe(' - Column Spanning', () => { let apiRef: React.MutableRefObject; - const Test = () => { + function Test() { apiRef = useGridApiRef(); return ( @@ -206,7 +206,7 @@ describe(' - Column Spanning', () => { /> ); - }; + } render(); diff --git a/packages/grid/x-data-grid-pro/src/tests/columns.DataGridPro.test.tsx b/packages/grid/x-data-grid-pro/src/tests/columns.DataGridPro.test.tsx index 48534dbbd957d..b286daab0ddb2 100644 --- a/packages/grid/x-data-grid-pro/src/tests/columns.DataGridPro.test.tsx +++ b/packages/grid/x-data-grid-pro/src/tests/columns.DataGridPro.test.tsx @@ -40,14 +40,14 @@ describe(' - Columns', () => { columns: [{ field: 'brand' }], }; - const Test = (props: Partial) => { + function Test(props: Partial) { apiRef = useGridApiRef(); return (
); - }; + } describe('showColumnMenu', () => { it('should open the column menu', async () => { diff --git a/packages/grid/x-data-grid-pro/src/tests/columnsVisibility.DataGridPro.test.tsx b/packages/grid/x-data-grid-pro/src/tests/columnsVisibility.DataGridPro.test.tsx index c9f86c44ee460..703925380bd25 100644 --- a/packages/grid/x-data-grid-pro/src/tests/columnsVisibility.DataGridPro.test.tsx +++ b/packages/grid/x-data-grid-pro/src/tests/columnsVisibility.DataGridPro.test.tsx @@ -27,10 +27,10 @@ describe(' - Columns Visibility', () => { let apiRef: React.MutableRefObject; - const TestDataGridPro = ( + function TestDataGridPro( props: Omit & Partial>, - ) => { + ) { apiRef = useGridApiRef(); return ( @@ -44,7 +44,7 @@ describe(' - Columns Visibility', () => { /> ); - }; + } describe('apiRef: updateColumns', () => { it('should not call `onColumnVisibilityModelChange` when no column visibility has changed', () => { diff --git a/packages/grid/x-data-grid-pro/src/tests/components.DataGridPro.test.tsx b/packages/grid/x-data-grid-pro/src/tests/components.DataGridPro.test.tsx index b5b9aecc0494b..7a2a609d0e1f1 100644 --- a/packages/grid/x-data-grid-pro/src/tests/components.DataGridPro.test.tsx +++ b/packages/grid/x-data-grid-pro/src/tests/components.DataGridPro.test.tsx @@ -18,7 +18,7 @@ describe(' - Components', () => { let apiRef: React.MutableRefObject; - const TestCase = (props: Partial) => { + function TestCase(props: Partial) { apiRef = useGridApiRef(); const data = useBasicDemoData(100, 1); return ( @@ -26,7 +26,7 @@ describe(' - Components', () => { ); - }; + } describe('footer', () => { it('should hide the row count if `hideFooterRowCount` prop is set', () => { diff --git a/packages/grid/x-data-grid-pro/src/tests/detailPanel.DataGridPro.test.tsx b/packages/grid/x-data-grid-pro/src/tests/detailPanel.DataGridPro.test.tsx index f132a54d81f6b..6842477911805 100644 --- a/packages/grid/x-data-grid-pro/src/tests/detailPanel.DataGridPro.test.tsx +++ b/packages/grid/x-data-grid-pro/src/tests/detailPanel.DataGridPro.test.tsx @@ -29,7 +29,7 @@ describe(' - Detail panel', () => { let apiRef: React.MutableRefObject; - const TestCase = ({ nbRows = 20, ...other }: Partial & { nbRows?: number }) => { + function TestCase({ nbRows = 20, ...other }: Partial & { nbRows?: number }) { apiRef = useGridApiRef(); const data = useBasicDemoData(nbRows, 1); return ( @@ -37,7 +37,7 @@ describe(' - Detail panel', () => { ); - }; + } it('should add a bottom margin to the expanded row', function test() { if (isJSDOM) { diff --git a/packages/grid/x-data-grid-pro/src/tests/editComponents.DataGridPro.test.tsx b/packages/grid/x-data-grid-pro/src/tests/editComponents.DataGridPro.test.tsx index 486e67797f308..580292bb104e5 100644 --- a/packages/grid/x-data-grid-pro/src/tests/editComponents.DataGridPro.test.tsx +++ b/packages/grid/x-data-grid-pro/src/tests/editComponents.DataGridPro.test.tsx @@ -45,14 +45,14 @@ describe(' - Edit Components', () => { const defaultData: Pick = { columns: [], rows: [] }; - const TestCase = (props: Partial) => { + function TestCase(props: Partial) { apiRef = useGridApiRef(); return (
); - }; + } describe('column type: string', () => { beforeEach(() => { diff --git a/packages/grid/x-data-grid-pro/src/tests/events.DataGridPro.spec.ts b/packages/grid/x-data-grid-pro/src/tests/events.DataGridPro.spec.ts index 3456be2749efa..6c2e77f7179f5 100644 --- a/packages/grid/x-data-grid-pro/src/tests/events.DataGridPro.spec.ts +++ b/packages/grid/x-data-grid-pro/src/tests/events.DataGridPro.spec.ts @@ -6,7 +6,7 @@ import { GridCellParams, } from '@mui/x-data-grid-pro'; -const TestEvents = () => { +function TestEvents() { const apiRef = useGridApiContext(); // @ts-expect-error Argument of type '(params: GridRowParams) => void' is not assignable to parameter of type 'GridEventListener<'cellClick'>'. @@ -57,4 +57,4 @@ const TestEvents = () => { useGridApiEventHandler(apiRef, 'cellClick', () => {}); return null; -}; +} diff --git a/packages/grid/x-data-grid-pro/src/tests/events.DataGridPro.test.tsx b/packages/grid/x-data-grid-pro/src/tests/events.DataGridPro.test.tsx index e50af56063cde..aba02b70f0e04 100644 --- a/packages/grid/x-data-grid-pro/src/tests/events.DataGridPro.test.tsx +++ b/packages/grid/x-data-grid-pro/src/tests/events.DataGridPro.test.tsx @@ -56,14 +56,14 @@ describe(' - Events Params', () => { let apiRef: React.MutableRefObject; - const TestEvents = (props: Partial) => { + function TestEvents(props: Partial) { apiRef = useGridApiRef(); return (
); - }; + } describe('columnHeaderParams', () => { it('should include the correct params', () => { @@ -368,7 +368,7 @@ describe(' - Events Params', () => { { id: 5, brand: 'Reebok' }, ]; const handleRowsScrollEnd = spy(); - const TestCase = ({ rows }: { rows: typeof baseRows }) => { + function TestCase({ rows }: { rows: typeof baseRows }) { return (
- Events Params', () => { />
); - }; + } const { container, setProps } = render(); const virtualScroller = container.querySelector('.MuiDataGrid-virtualScroller'); // arbitrary number to make sure that the bottom of the grid window is reached. diff --git a/packages/grid/x-data-grid-pro/src/tests/export.DataGridPro.test.tsx b/packages/grid/x-data-grid-pro/src/tests/export.DataGridPro.test.tsx index da3c39d25c0b6..5b817fa6924e4 100644 --- a/packages/grid/x-data-grid-pro/src/tests/export.DataGridPro.test.tsx +++ b/packages/grid/x-data-grid-pro/src/tests/export.DataGridPro.test.tsx @@ -19,7 +19,7 @@ describe(' - Export', () => { describe('getDataAsCsv', () => { it('should work with basic strings', () => { - const TestCaseCSVExport = () => { + function TestCaseCSVExport() { apiRef = useGridApiRef(); return ( @@ -45,7 +45,7 @@ describe(' - Export', () => { /> ); - }; + } render(); expect(apiRef.current.getDataAsCsv()).to.equal( @@ -65,7 +65,7 @@ describe(' - Export', () => { }); it('should work with comma', () => { - const TestCaseCSVExport = () => { + function TestCaseCSVExport() { apiRef = useGridApiRef(); return (
@@ -86,7 +86,7 @@ describe(' - Export', () => { />
); - }; + } render(); expect(apiRef.current.getDataAsCsv()).to.equal( @@ -95,7 +95,7 @@ describe(' - Export', () => { }); it('should apply valueFormatter correctly', () => { - const TestCaseCSVExport = () => { + function TestCaseCSVExport() { apiRef = useGridApiRef(); return (
@@ -123,7 +123,7 @@ describe(' - Export', () => { />
); - }; + } render(); expect(apiRef.current.getDataAsCsv()).to.equal( @@ -132,7 +132,7 @@ describe(' - Export', () => { }); it('should work with double quotes', () => { - const TestCaseCSVExport = () => { + function TestCaseCSVExport() { apiRef = useGridApiRef(); return (
@@ -153,7 +153,7 @@ describe(' - Export', () => { />
); - }; + } render(); expect(apiRef.current.getDataAsCsv()).to.equal( @@ -162,7 +162,7 @@ describe(' - Export', () => { }); it('should work with newline', () => { - const TestCaseCSVExport = () => { + function TestCaseCSVExport() { apiRef = useGridApiRef(); return (
@@ -191,7 +191,7 @@ describe(' - Export', () => { />
); - }; + } render(); expect(apiRef.current.getDataAsCsv()).to.equal( @@ -206,7 +206,7 @@ describe(' - Export', () => { }); it('should allow to change the delimiter', () => { - const TestCaseCSVExport = () => { + function TestCaseCSVExport() { apiRef = useGridApiRef(); return (
@@ -227,7 +227,7 @@ describe(' - Export', () => { />
); - }; + } render(); expect( @@ -238,7 +238,7 @@ describe(' - Export', () => { }); it('should only export the selected rows if any', () => { - const TestCaseCSVExport = () => { + function TestCaseCSVExport() { apiRef = useGridApiRef(); return (
@@ -260,14 +260,14 @@ describe(' - Export', () => { />
); - }; + } render(); expect(apiRef.current.getDataAsCsv()).to.equal(['id,Brand', '0,Nike'].join('\r\n')); }); it('should export the rows returned by params.getRowsToExport if defined', () => { - const TestCaseCSVExport = () => { + function TestCaseCSVExport() { apiRef = useGridApiRef(); return (
@@ -288,7 +288,7 @@ describe(' - Export', () => { />
); - }; + } render(); expect(apiRef.current.getDataAsCsv({ getRowsToExport: () => [0] })).to.equal( @@ -297,7 +297,7 @@ describe(' - Export', () => { }); it('should not export hidden column', () => { - const TestCaseCSVExport = () => { + function TestCaseCSVExport() { apiRef = useGridApiRef(); return (
@@ -319,14 +319,14 @@ describe(' - Export', () => { />
); - }; + } render(); expect(apiRef.current.getDataAsCsv()).to.equal(['id', '0', '1'].join('\r\n')); }); it('should export hidden column if params.allColumns = true', () => { - const TestCaseCSVExport = () => { + function TestCaseCSVExport() { apiRef = useGridApiRef(); return (
@@ -348,7 +348,7 @@ describe(' - Export', () => { />
); - }; + } render(); expect( @@ -359,7 +359,7 @@ describe(' - Export', () => { }); it('should not export columns with column.disableExport = true', () => { - const TestCaseCSVExport = () => { + function TestCaseCSVExport() { apiRef = useGridApiRef(); return (
@@ -383,7 +383,7 @@ describe(' - Export', () => { />
); - }; + } render(); expect( @@ -394,7 +394,7 @@ describe(' - Export', () => { }); it('should only export columns in params.fields if defined', () => { - const TestCaseCSVExport = () => { + function TestCaseCSVExport() { apiRef = useGridApiRef(); return (
@@ -416,7 +416,7 @@ describe(' - Export', () => { />
); - }; + } render(); expect( @@ -427,7 +427,7 @@ describe(' - Export', () => { }); it('should export column defined in params.fields even if `columnVisibilityModel` does not include the field or column.disableExport=true', () => { - const TestCaseCSVExport = () => { + function TestCaseCSVExport() { apiRef = useGridApiRef(); return (
@@ -452,7 +452,7 @@ describe(' - Export', () => { />
); - }; + } render(); expect( @@ -463,7 +463,7 @@ describe(' - Export', () => { }); it('should work with booleans', () => { - const TestCaseCSVExport = () => { + function TestCaseCSVExport() { apiRef = useGridApiRef(); return (
@@ -479,7 +479,7 @@ describe(' - Export', () => { />
); - }; + } render(); expect(apiRef.current.getDataAsCsv()).to.equal(['id,isAdmin', '0,Yes', '1,No'].join('\r\n')); }); @@ -490,7 +490,7 @@ describe(' - Export', () => { { value: 'BR', label: 'Brazil' }, ]; - const TestCaseCSVExport = () => { + function TestCaseCSVExport() { apiRef = useGridApiRef(); return (
@@ -512,7 +512,7 @@ describe(' - Export', () => { />
); - }; + } render(); expect(() => { diff --git a/packages/grid/x-data-grid-pro/src/tests/filterPanel.DataGridPro.test.tsx b/packages/grid/x-data-grid-pro/src/tests/filterPanel.DataGridPro.test.tsx index 7102ef025d617..c2644fb3ab81c 100644 --- a/packages/grid/x-data-grid-pro/src/tests/filterPanel.DataGridPro.test.tsx +++ b/packages/grid/x-data-grid-pro/src/tests/filterPanel.DataGridPro.test.tsx @@ -24,14 +24,14 @@ describe(' - Filter panel', () => { let apiRef: React.MutableRefObject; - const TestCase = (props: Partial) => { + function TestCase(props: Partial) { apiRef = useGridApiRef(); return (
); - }; + } it('should add an id and operatorValue to the filter item created when opening the filter panel', () => { render(); diff --git a/packages/grid/x-data-grid-pro/src/tests/filtering.DataGridPro.test.tsx b/packages/grid/x-data-grid-pro/src/tests/filtering.DataGridPro.test.tsx index e200a81b198a5..ad8e59b25a03f 100644 --- a/packages/grid/x-data-grid-pro/src/tests/filtering.DataGridPro.test.tsx +++ b/packages/grid/x-data-grid-pro/src/tests/filtering.DataGridPro.test.tsx @@ -46,7 +46,7 @@ describe(' - Filter', () => { columns: [{ field: 'brand' }], }; - const TestCase = (props: Partial) => { + function TestCase(props: Partial) { const { rows, ...other } = props; apiRef = useGridApiRef(); return ( @@ -60,7 +60,7 @@ describe(' - Filter', () => { /> ); - }; + } const filterModel = { items: [ @@ -741,7 +741,7 @@ describe(' - Filter', () => { }); it('should control filter state when the model and the onChange are set', () => { - const ControlCase = (props: Partial) => { + function ControlCase(props: Partial) { const { rows, columns, ...others } = props; const [caseFilterModel, setFilterModel] = React.useState(getDefaultGridFilterModel); const handleFilterChange: DataGridProProps['onFilterModelChange'] = (newModel) => { @@ -766,7 +766,7 @@ describe(' - Filter', () => { /> ); - }; + } render(); const addButton = screen.getByRole('button', { name: /Add Filter/i }); diff --git a/packages/grid/x-data-grid-pro/src/tests/layout.DataGridPro.test.tsx b/packages/grid/x-data-grid-pro/src/tests/layout.DataGridPro.test.tsx index 3cc697c4b4dae..d65010068028c 100644 --- a/packages/grid/x-data-grid-pro/src/tests/layout.DataGridPro.test.tsx +++ b/packages/grid/x-data-grid-pro/src/tests/layout.DataGridPro.test.tsx @@ -85,7 +85,7 @@ describe(' - Layout', () => { it('should resize flex: 1 column when changing column visibility to avoid exceeding grid width (apiRef setColumnVisibility method call)', () => { let apiRef: React.MutableRefObject; - const TestCase = (props: Omit) => { + function TestCase(props: Omit) { apiRef = useGridApiRef(); return ( @@ -93,7 +93,7 @@ describe(' - Layout', () => { ); - }; + } render( - Lazy loader', () => { let apiRef: React.MutableRefObject; - const TestLazyLoader = (props: Partial) => { + function TestLazyLoader(props: Partial) { apiRef = useGridApiRef(); return (
@@ -58,7 +58,7 @@ describe(' - Lazy loader', () => { />
); - }; + } it('should not call onFetchRows if the viewport is fully loaded', function test() { if (isJSDOM) { diff --git a/packages/grid/x-data-grid-pro/src/tests/pagination.DataGridPro.test.tsx b/packages/grid/x-data-grid-pro/src/tests/pagination.DataGridPro.test.tsx index 177c1182de96d..6012d693201bd 100644 --- a/packages/grid/x-data-grid-pro/src/tests/pagination.DataGridPro.test.tsx +++ b/packages/grid/x-data-grid-pro/src/tests/pagination.DataGridPro.test.tsx @@ -13,7 +13,7 @@ describe(' - Pagination', () => { it('should apply valid value', () => { let apiRef: React.MutableRefObject; - const GridTest = () => { + function GridTest() { const basicData = useBasicDemoData(20, 2); apiRef = useGridApiRef(); @@ -28,7 +28,7 @@ describe(' - Pagination', () => { /> ); - }; + } render(); @@ -42,7 +42,7 @@ describe(' - Pagination', () => { it('should apply last page if trying to go to a non-existing page', () => { let apiRef: React.MutableRefObject; - const GridTest = () => { + function GridTest() { const basicData = useBasicDemoData(20, 2); apiRef = useGridApiRef(); @@ -57,7 +57,7 @@ describe(' - Pagination', () => { /> ); - }; + } render(); @@ -73,7 +73,7 @@ describe(' - Pagination', () => { describe('setPageSize', () => { it('should apply value', () => { let apiRef: React.MutableRefObject; - const GridTest = () => { + function GridTest() { const [pageSize, setPageSize] = React.useState(5); const basicData = useBasicDemoData(20, 2); apiRef = useGridApiRef(); @@ -91,7 +91,7 @@ describe(' - Pagination', () => { /> ); - }; + } render(); clock.runToLast(); diff --git a/packages/grid/x-data-grid-pro/src/tests/printExport.DataGrid.test.tsx b/packages/grid/x-data-grid-pro/src/tests/printExport.DataGrid.test.tsx index 46e832de4b3af..1840c3796354c 100644 --- a/packages/grid/x-data-grid-pro/src/tests/printExport.DataGrid.test.tsx +++ b/packages/grid/x-data-grid-pro/src/tests/printExport.DataGrid.test.tsx @@ -25,7 +25,7 @@ describe(' - Print export', () => { rowsPerPageOptions: [NB_ROWS, 100], }; - const Test = (props: Partial) => { + function Test(props: Partial) { apiRef = useGridApiRef(); return ( @@ -33,7 +33,7 @@ describe(' - Print export', () => { ); - }; + } const allBooleanConfigurations = [ { diff --git a/packages/grid/x-data-grid-pro/src/tests/rowEditing.DataGridPro.test.tsx b/packages/grid/x-data-grid-pro/src/tests/rowEditing.DataGridPro.test.tsx index 483b073c20f8a..e6d2e41f4412d 100644 --- a/packages/grid/x-data-grid-pro/src/tests/rowEditing.DataGridPro.test.tsx +++ b/packages/grid/x-data-grid-pro/src/tests/rowEditing.DataGridPro.test.tsx @@ -23,7 +23,7 @@ describe(' - Row Editing', () => { const defaultData = getBasicGridData(4, 4); - const CustomEditComponent = ({ hasFocus }: GridRenderEditCellParams) => { + function CustomEditComponent({ hasFocus }: GridRenderEditCellParams) { const ref = React.useRef(null); React.useLayoutEffect(() => { if (hasFocus) { @@ -31,7 +31,7 @@ describe(' - Row Editing', () => { } }, [hasFocus]); return ; - }; + } const renderEditCell1 = spy((props: GridRenderEditCellParams) => ( @@ -44,7 +44,7 @@ describe(' - Row Editing', () => { let column1Props: any = {}; let column2Props: any = {}; - const TestCase = (props: Partial) => { + function TestCase(props: Partial) { apiRef = useGridApiRef(); return (
@@ -76,7 +76,7 @@ describe(' - Row Editing', () => { />
); - }; + } afterEach(() => { renderEditCell1.resetHistory(); diff --git a/packages/grid/x-data-grid-pro/src/tests/rowPinning.DataGridPro.test.tsx b/packages/grid/x-data-grid-pro/src/tests/rowPinning.DataGridPro.test.tsx index 6aa417b995922..48f4f97972ca8 100644 --- a/packages/grid/x-data-grid-pro/src/tests/rowPinning.DataGridPro.test.tsx +++ b/packages/grid/x-data-grid-pro/src/tests/rowPinning.DataGridPro.test.tsx @@ -52,7 +52,7 @@ describe(' - Row pinning', () => { return container.contains(row); } - const BaselineTestCase = ({ + function BaselineTestCase({ rowCount, colCount, height = 300, @@ -61,7 +61,7 @@ describe(' - Row pinning', () => { rowCount: number; colCount: number; height?: number | string; - } & Partial) => { + } & Partial) { const data = getBasicGridData(rowCount, colCount); const [pinnedRow0, pinnedRow1, ...rows] = data.rows; @@ -79,7 +79,7 @@ describe(' - Row pinning', () => { /> ); - }; + } it('should render pinned rows in pinned containers', () => { render(); @@ -91,7 +91,7 @@ describe(' - Row pinning', () => { it('should treat row as pinned even if row with the same id is present in `rows` prop', () => { const rowCount = 5; - const TestCase = ({ pinRows = true }) => { + function TestCase({ pinRows = true }) { const data = getBasicGridData(rowCount, 5); const pinnedRows = React.useMemo(() => { @@ -114,7 +114,7 @@ describe(' - Row pinning', () => { /> ); - }; + } const { setProps } = render(); @@ -162,7 +162,7 @@ describe(' - Row pinning', () => { it('should update pinned rows when `pinnedRows` prop change', () => { const data = getBasicGridData(20, 5); - const TestCase = (props: any) => { + function TestCase(props: any) { const [pinnedRow0, pinnedRow1, ...rows] = data.rows; return (
@@ -178,7 +178,7 @@ describe(' - Row pinning', () => { />
); - }; + } const { setProps } = render(); @@ -201,7 +201,7 @@ describe(' - Row pinning', () => { const data = getBasicGridData(20, 5); let apiRef!: React.MutableRefObject; - const TestCase = (props: any) => { + function TestCase(props: any) { const [pinnedRow0, pinnedRow1, ...rows] = data.rows; apiRef = useGridApiRef(); return ( @@ -219,7 +219,7 @@ describe(' - Row pinning', () => { /> ); - }; + } render(); @@ -258,7 +258,7 @@ describe(' - Row pinning', () => { }); it('should work with `getRowId`', () => { - const TestCase = () => { + function TestCase() { const data = getBasicGridData(20, 5); const rowsData = data.rows.map((row) => { @@ -290,7 +290,7 @@ describe(' - Row pinning', () => { /> ); - }; + } render(); @@ -361,7 +361,7 @@ describe(' - Row pinning', () => { } it('should work with top pinned rows', () => { - const TestCase = () => { + function TestCase() { const data = getBasicGridData(20, 5); const [pinnedRow0, pinnedRow1, ...rows] = data.rows; @@ -377,7 +377,7 @@ describe(' - Row pinning', () => { /> ); - }; + } render(); @@ -404,7 +404,7 @@ describe(' - Row pinning', () => { }); it('should work with bottom pinned rows', () => { - const TestCase = () => { + function TestCase() { const data = getBasicGridData(5, 5); const [pinnedRow0, pinnedRow1, ...rows] = data.rows; @@ -420,7 +420,7 @@ describe(' - Row pinning', () => { /> ); - }; + } render(); @@ -449,7 +449,7 @@ describe(' - Row pinning', () => { this.skip(); } - const TestCase = () => { + function TestCase() { const data = getBasicGridData(5, 7); const [pinnedRow0, pinnedRow1, ...rows] = data.rows; @@ -472,7 +472,7 @@ describe(' - Row pinning', () => { /> ); - }; + } render(); @@ -694,7 +694,7 @@ describe(' - Row pinning', () => { const columns = [{ field: 'name', width: 200 }]; - const Test = () => { + function Test() { const [pinnedRow0, pinnedRow1, ...rowsData] = rows; return ( @@ -712,7 +712,7 @@ describe(' - Row pinning', () => { /> ); - }; + } render(); @@ -723,10 +723,10 @@ describe(' - Row pinning', () => { it('should not be selectable', () => { let apiRef: React.MutableRefObject; - const TestCase = () => { + function TestCase() { apiRef = useGridApiRef(); return ; - }; + } render(); @@ -744,10 +744,10 @@ describe(' - Row pinning', () => { it('should export pinned rows to CSV', () => { let apiRef: React.MutableRefObject; - const TestCase = () => { + function TestCase() { apiRef = useGridApiRef(); return ; - }; + } render(); diff --git a/packages/grid/x-data-grid-pro/src/tests/rowReorder.DataGridPro.test.tsx b/packages/grid/x-data-grid-pro/src/tests/rowReorder.DataGridPro.test.tsx index c7e7d6dfe6d5d..757b0b06b80d7 100644 --- a/packages/grid/x-data-grid-pro/src/tests/rowReorder.DataGridPro.test.tsx +++ b/packages/grid/x-data-grid-pro/src/tests/rowReorder.DataGridPro.test.tsx @@ -38,7 +38,7 @@ describe(' - Row reorder', () => { ]; const columns = [{ field: 'brand' }]; - const Test = () => { + function Test() { apiRef = useGridApiRef(); return ( @@ -46,7 +46,7 @@ describe(' - Row reorder', () => { ); - }; + } render(); @@ -74,7 +74,7 @@ describe(' - Row reorder', () => { ]; const columns = [{ field: 'brand' }]; - const Test = () => { + function Test() { apiRef = useGridApiRef(); return ( @@ -82,7 +82,7 @@ describe(' - Row reorder', () => { ); - }; + } render(); expect(getRowsFieldContent('brand')).to.deep.equal(['Nike', 'Adidas', 'Puma']); @@ -102,7 +102,7 @@ describe(' - Row reorder', () => { ]; const columns = [{ field: 'brand' }]; - const Test = () => { + function Test() { apiRef = useGridApiRef(); return ( @@ -110,7 +110,7 @@ describe(' - Row reorder', () => { ); - }; + } render(); expect(getRowsFieldContent('brand')).to.deep.equal(['Nike', 'Adidas', 'Puma']); @@ -123,7 +123,7 @@ describe(' - Row reorder', () => { it('should call onRowOrderChange after the row stops being dragged', () => { const handleOnRowOrderChange = spy(); let apiRef: React.MutableRefObject; - const Test = () => { + function Test() { apiRef = useGridApiRef(); const rows = [ { id: 0, brand: 'Nike' }, @@ -143,7 +143,7 @@ describe(' - Row reorder', () => { /> ); - }; + } render(); @@ -169,7 +169,7 @@ describe(' - Row reorder', () => { const handleDragOver = spy(); const handleDragEnd = spy(); let apiRef: React.MutableRefObject; - const Test = () => { + function Test() { apiRef = useGridApiRef(); const data = useBasicDemoData(3, 3); @@ -185,7 +185,7 @@ describe(' - Row reorder', () => { ); - }; + } render(); diff --git a/packages/grid/x-data-grid-pro/src/tests/rowSelection.DataGridPro.test.tsx b/packages/grid/x-data-grid-pro/src/tests/rowSelection.DataGridPro.test.tsx index 688523b241412..1087d71bf541d 100644 --- a/packages/grid/x-data-grid-pro/src/tests/rowSelection.DataGridPro.test.tsx +++ b/packages/grid/x-data-grid-pro/src/tests/rowSelection.DataGridPro.test.tsx @@ -29,11 +29,11 @@ describe(' - Row Selection', () => { let apiRef: React.MutableRefObject; - const TestDataGridSelection = ({ + function TestDataGridSelection({ rowLength = 4, ...other }: Omit & - Partial> & { rowLength?: number }) => { + Partial> & { rowLength?: number }) { apiRef = useGridApiRef(); const data = React.useMemo(() => getBasicGridData(rowLength, 2), [rowLength]); @@ -43,7 +43,7 @@ describe(' - Row Selection', () => { ); - }; + } describe('prop: checkboxSelectionVisibleOnly = false', () => { it('should select all rows of all pages if no row is selected', () => { diff --git a/packages/grid/x-data-grid-pro/src/tests/rows.DataGridPro.test.tsx b/packages/grid/x-data-grid-pro/src/tests/rows.DataGridPro.test.tsx index 26c59f57acb60..7a536a6c69f20 100644 --- a/packages/grid/x-data-grid-pro/src/tests/rows.DataGridPro.test.tsx +++ b/packages/grid/x-data-grid-pro/src/tests/rows.DataGridPro.test.tsx @@ -70,14 +70,14 @@ describe(' - Rows', () => { editableProps.columns = editableProps.columns.map((col) => ({ ...col, editable: true })); const getRowId: DataGridProProps['getRowId'] = (row) => `${row.clientId}`; - const Test = () => { + function Test() { apiRef = useGridApiRef(); return (
); - }; + } render(); act(() => apiRef!.current.startCellEditMode({ id: 'c2', field: 'first' })); const cell = getCell(1, 1); @@ -95,14 +95,14 @@ describe(' - Rows', () => { it('should not clone the row', () => { const getRowId: DataGridProProps['getRowId'] = (row) => `${row.clientId}`; let apiRef: React.MutableRefObject; - const Test = () => { + function Test() { apiRef = useGridApiRef(); return (
); - }; + } render(); expect(apiRef!.current.getRow('c1')).to.equal(baselineProps.rows[0]); }); @@ -112,17 +112,19 @@ describe(' - Rows', () => { it('should not throttle even when props.throttleRowsMs is defined', () => { const { rows, columns } = getBasicGridData(5, 2); - const Test = (props: Pick) => ( -
- -
- ); + function Test(props: Pick) { + return ( +
+ +
+ ); + } const { setProps } = render(); @@ -156,14 +158,14 @@ describe(' - Rows', () => { let apiRef: React.MutableRefObject; - const TestCase = (props: Partial) => { + function TestCase(props: Partial) { apiRef = useGridApiRef(); return (
); - }; + } it('should not throttle by default', () => { render(); @@ -235,7 +237,7 @@ describe(' - Rows', () => { }); it('update row data should process getRowId', () => { - const TestCaseGetRowId = () => { + function TestCaseGetRowId() { apiRef = useGridApiRef(); const getRowId = React.useCallback((row: GridRowModel) => row.idField, []); return ( @@ -248,7 +250,7 @@ describe(' - Rows', () => { /> ); - }; + } render(); expect(getColumnValues(0)).to.deep.equal(['Nike', 'Adidas', 'Puma']); @@ -264,14 +266,14 @@ describe(' - Rows', () => { }); it('should not loose partial updates after a props.loading switch', () => { - const Test = (props: Partial) => { + function Test(props: Partial) { apiRef = useGridApiRef(); return (
); - }; + } const { setProps } = render(); expect(getColumnValues(0)).to.deep.equal(['Nike', 'Adidas', 'Puma']); @@ -307,14 +309,14 @@ describe(' - Rows', () => { let apiRef: React.MutableRefObject; - const TestCase = (props: Partial) => { + function TestCase(props: Partial) { apiRef = useGridApiRef(); return (
); - }; + } it('should not throttle by default', () => { render(); @@ -369,14 +371,14 @@ describe(' - Rows', () => { }); let apiRef: React.MutableRefObject; - const TestCaseVirtualization = ( + function TestCaseVirtualization( props: Partial & { nbRows?: number; nbCols?: number; width?: number; height?: number; }, - ) => { + ) { apiRef = useGridApiRef(); const data = useBasicDemoData(props.nbRows || 100, props.nbCols || 10); @@ -385,7 +387,7 @@ describe(' - Rows', () => { ); - }; + } it('should render last row when scrolling to the bottom', () => { const rowHeight = 50; @@ -640,7 +642,7 @@ describe(' - Rows', () => { describe('no virtualization', () => { let apiRef: React.MutableRefObject; - const TestCase = (props: Partial & { nbRows?: number; nbCols?: number }) => { + function TestCase(props: Partial & { nbRows?: number; nbCols?: number }) { apiRef = useGridApiRef(); const data = useBasicDemoData(props.nbRows || 10, props.nbCols || 10); return ( @@ -654,7 +656,7 @@ describe(' - Rows', () => { /> ); - }; + } it('should allow to disable virtualization', () => { render(); @@ -673,7 +675,7 @@ describe(' - Rows', () => { describe('Cell focus', () => { let apiRef: React.MutableRefObject; - const TestCase = (props: Partial) => { + function TestCase(props: Partial) { apiRef = useGridApiRef(); return ( @@ -681,7 +683,7 @@ describe(' - Rows', () => { ); - }; + } beforeEach(() => { baselineProps = { @@ -863,14 +865,14 @@ describe(' - Rows', () => { let apiRef: React.MutableRefObject; - const TestCase = (props: Partial) => { + function TestCase(props: Partial) { apiRef = useGridApiRef(); return (
); - }; + } it('should change row height', () => { const resizedRowId = 1; @@ -903,13 +905,13 @@ describe(' - Rows', () => { }); describe('prop: rowCount', () => { - const TestCase = (props: DataGridProProps) => { + function TestCase(props: DataGridProProps) { return (
); - }; + } it('should not show total row count in footer if `rowCount === rows.length`', () => { const { rows, columns } = getBasicGridData(10, 2); diff --git a/packages/grid/x-data-grid-pro/src/tests/sorting.DataGridPro.test.tsx b/packages/grid/x-data-grid-pro/src/tests/sorting.DataGridPro.test.tsx index 06efe9145a602..7d2a3c8c9dcaf 100644 --- a/packages/grid/x-data-grid-pro/src/tests/sorting.DataGridPro.test.tsx +++ b/packages/grid/x-data-grid-pro/src/tests/sorting.DataGridPro.test.tsx @@ -42,7 +42,7 @@ describe(' - Sorting', () => { let apiRef: React.MutableRefObject; - const TestCase = (props: Partial) => { + function TestCase(props: Partial) { const { rows, ...other } = props; apiRef = useGridApiRef(); return ( @@ -55,7 +55,7 @@ describe(' - Sorting', () => { /> ); - }; + } const renderBrandSortedAsc = () => { const sortModel: GridSortModel = [{ field: 'brand', sort: 'asc' }]; @@ -240,7 +240,7 @@ describe(' - Sorting', () => { it('should control sort state when the model and the onChange are set', () => { let expectedModel: GridSortModel = []; - const ControlCase = (props: Partial) => { + function ControlCase(props: Partial) { const { rows, columns, ...others } = props; const [caseSortModel, setSortModel] = React.useState([]); const handleSortChange: DataGridProProps['onSortModelChange'] = (newModel) => { @@ -260,7 +260,7 @@ describe(' - Sorting', () => { /> ); - }; + } render(); fireEvent.click(getColumnHeaderCell(0)); @@ -271,17 +271,19 @@ describe(' - Sorting', () => { it('should not call onSortModelChange on initialization or on sortModel prop change', () => { const onSortModelChange = spy(); - const Test = (props: Partial) => ( -
- -
- ); + function Test(props: Partial) { + return ( +
+ +
+ ); + } const { setProps } = render( - State Persistence', () => { let apiRef: React.MutableRefObject; - const TestCase = (props: Omit) => { + function TestCase(props: Omit) { apiRef = useGridApiRef(); return ( @@ -110,7 +110,7 @@ describe(' - State Persistence', () => { /> ); - }; + } describe('apiRef: exportState', () => { it('should export the default values of the models', () => { @@ -258,7 +258,7 @@ describe(' - State Persistence', () => { }); it('should restore controlled sub-state', () => { - const ControlledTest = () => { + function ControlledTest() { const [page, setPage] = React.useState(0); return ( @@ -269,7 +269,7 @@ describe(' - State Persistence', () => { }} /> ); - }; + } render(); act(() => diff --git a/packages/grid/x-data-grid-pro/src/tests/treeData.DataGridPro.test.tsx b/packages/grid/x-data-grid-pro/src/tests/treeData.DataGridPro.test.tsx index 2fa5bbf93f995..95a4f8a80b05b 100644 --- a/packages/grid/x-data-grid-pro/src/tests/treeData.DataGridPro.test.tsx +++ b/packages/grid/x-data-grid-pro/src/tests/treeData.DataGridPro.test.tsx @@ -61,7 +61,7 @@ describe(' - Tree Data', () => { let apiRef: React.MutableRefObject; - const Test = (props: Partial) => { + function Test(props: Partial) { apiRef = useGridApiRef(); return ( @@ -69,7 +69,7 @@ describe(' - Tree Data', () => { ); - }; + } describe('prop: treeData', () => { it('should support tree data toggling', () => { diff --git a/packages/grid/x-data-grid/src/components/GridRow.tsx b/packages/grid/x-data-grid/src/components/GridRow.tsx index d97d27be6e766..5539664bd80d4 100644 --- a/packages/grid/x-data-grid/src/components/GridRow.tsx +++ b/packages/grid/x-data-grid/src/components/GridRow.tsx @@ -84,7 +84,7 @@ const useUtilityClasses = (ownerState: OwnerState) => { return composeClasses(slots, getDataGridUtilityClass, classes); }; -const EmptyCell = ({ width }: { width: number }) => { +function EmptyCell({ width }: { width: number }) { if (!width) { return null; } @@ -92,7 +92,7 @@ const EmptyCell = ({ width }: { width: number }) => { const style = { width }; return
; // TODO change to .MuiDataGrid-emptyCell or .MuiDataGrid-rowFiller -}; +} const GridRow = React.forwardRef< HTMLDivElement, diff --git a/packages/grid/x-data-grid/src/components/cell/GridActionsCell.tsx b/packages/grid/x-data-grid/src/components/cell/GridActionsCell.tsx index 879440ff65036..eb222ce7153e3 100644 --- a/packages/grid/x-data-grid/src/components/cell/GridActionsCell.tsx +++ b/packages/grid/x-data-grid/src/components/cell/GridActionsCell.tsx @@ -23,7 +23,7 @@ interface GridActionsCellProps extends Omit { +function GridActionsCell(props: GridActionsCellProps) { const { colDef, id, @@ -227,7 +227,7 @@ const GridActionsCell = (props: GridActionsCellProps) => { )}
); -}; +} GridActionsCell.propTypes = { // ----------------------------- Warning -------------------------------- diff --git a/packages/grid/x-data-grid/src/components/cell/GridBooleanCell.tsx b/packages/grid/x-data-grid/src/components/cell/GridBooleanCell.tsx index ca63510dbed88..af422085b3d5b 100644 --- a/packages/grid/x-data-grid/src/components/cell/GridBooleanCell.tsx +++ b/packages/grid/x-data-grid/src/components/cell/GridBooleanCell.tsx @@ -26,7 +26,7 @@ interface GridBooleanCellProps extends GridRenderCellParams, Omit {} -const GridBooleanCellRaw = (props: GridBooleanCellProps) => { +function GridBooleanCellRaw(props: GridBooleanCellProps) { const { id, value, @@ -66,7 +66,7 @@ const GridBooleanCellRaw = (props: GridBooleanCellProps) => { {...other} /> ); -}; +} GridBooleanCellRaw.propTypes = { // ----------------------------- Warning -------------------------------- diff --git a/packages/grid/x-data-grid/src/components/menu/GridMenu.tsx b/packages/grid/x-data-grid/src/components/menu/GridMenu.tsx index ed77c2c302a8a..e9f6e705d2f2d 100644 --- a/packages/grid/x-data-grid/src/components/menu/GridMenu.tsx +++ b/packages/grid/x-data-grid/src/components/menu/GridMenu.tsx @@ -64,7 +64,7 @@ const transformOrigin = { 'bottom-end': 'top right', }; -const GridMenu = (props: GridMenuProps) => { +function GridMenu(props: GridMenuProps) { const { open, target, onClickAway, children, position, className, onExited, ...other } = props; const apiRef = useGridApiContext(); const prevTarget = React.useRef(target); @@ -120,7 +120,7 @@ const GridMenu = (props: GridMenuProps) => { )} ); -}; +} GridMenu.propTypes = { // ----------------------------- Warning -------------------------------- diff --git a/packages/grid/x-data-grid/src/components/menu/columnMenu/GridColumnsMenuItem.tsx b/packages/grid/x-data-grid/src/components/menu/columnMenu/GridColumnsMenuItem.tsx index 0bb633429fa04..dcb0dd6ba7a9e 100644 --- a/packages/grid/x-data-grid/src/components/menu/columnMenu/GridColumnsMenuItem.tsx +++ b/packages/grid/x-data-grid/src/components/menu/columnMenu/GridColumnsMenuItem.tsx @@ -6,7 +6,7 @@ import { useGridApiContext } from '../../../hooks/utils/useGridApiContext'; import { GridFilterItemProps } from './GridFilterItemProps'; import { useGridRootProps } from '../../../hooks/utils/useGridRootProps'; -const GridColumnsMenuItem = (props: GridFilterItemProps) => { +function GridColumnsMenuItem(props: GridFilterItemProps) { const { onClick } = props; const apiRef = useGridApiContext(); const rootProps = useGridRootProps(); @@ -28,7 +28,7 @@ const GridColumnsMenuItem = (props: GridFilterItemProps) => { {apiRef.current.getLocaleText('columnMenuShowColumns')} ); -}; +} GridColumnsMenuItem.propTypes = { // ----------------------------- Warning -------------------------------- diff --git a/packages/grid/x-data-grid/src/components/menu/columnMenu/GridFilterMenuItem.tsx b/packages/grid/x-data-grid/src/components/menu/columnMenu/GridFilterMenuItem.tsx index 3b2f61d300e58..785e17fc19580 100644 --- a/packages/grid/x-data-grid/src/components/menu/columnMenu/GridFilterMenuItem.tsx +++ b/packages/grid/x-data-grid/src/components/menu/columnMenu/GridFilterMenuItem.tsx @@ -5,7 +5,7 @@ import { useGridApiContext } from '../../../hooks/utils/useGridApiContext'; import { GridFilterItemProps } from './GridFilterItemProps'; import { useGridRootProps } from '../../../hooks/utils/useGridRootProps'; -const GridFilterMenuItem = (props: GridFilterItemProps) => { +function GridFilterMenuItem(props: GridFilterItemProps) { const { column, onClick } = props; const apiRef = useGridApiContext(); const rootProps = useGridRootProps(); @@ -25,7 +25,7 @@ const GridFilterMenuItem = (props: GridFilterItemProps) => { return ( {apiRef.current.getLocaleText('columnMenuFilter')} ); -}; +} GridFilterMenuItem.propTypes = { // ----------------------------- Warning -------------------------------- diff --git a/packages/grid/x-data-grid/src/components/menu/columnMenu/HideGridColMenuItem.tsx b/packages/grid/x-data-grid/src/components/menu/columnMenu/HideGridColMenuItem.tsx index 6c4cae71bebf6..fcde932ad24a8 100644 --- a/packages/grid/x-data-grid/src/components/menu/columnMenu/HideGridColMenuItem.tsx +++ b/packages/grid/x-data-grid/src/components/menu/columnMenu/HideGridColMenuItem.tsx @@ -6,7 +6,7 @@ import { useGridApiContext } from '../../../hooks/utils/useGridApiContext'; import { useGridRootProps } from '../../../hooks/utils/useGridRootProps'; import { gridVisibleColumnDefinitionsSelector } from '../../../hooks/features/columns'; -const HideGridColMenuItem = (props: GridFilterItemProps) => { +function HideGridColMenuItem(props: GridFilterItemProps) { const { column, onClick } = props; const apiRef = useGridApiContext(); const rootProps = useGridRootProps(); @@ -53,7 +53,7 @@ const HideGridColMenuItem = (props: GridFilterItemProps) => { {apiRef.current.getLocaleText('columnMenuHideColumn')} ); -}; +} HideGridColMenuItem.propTypes = { // ----------------------------- Warning -------------------------------- diff --git a/packages/grid/x-data-grid/src/components/menu/columnMenu/SortGridMenuItems.tsx b/packages/grid/x-data-grid/src/components/menu/columnMenu/SortGridMenuItems.tsx index 29d6f366f1b5e..ac345d2fe1128 100644 --- a/packages/grid/x-data-grid/src/components/menu/columnMenu/SortGridMenuItems.tsx +++ b/packages/grid/x-data-grid/src/components/menu/columnMenu/SortGridMenuItems.tsx @@ -7,7 +7,7 @@ import { GridSortDirection } from '../../../models/gridSortModel'; import { useGridApiContext } from '../../../hooks/utils/useGridApiContext'; import { GridFilterItemProps } from './GridFilterItemProps'; -const SortGridMenuItems = (props: GridFilterItemProps) => { +function SortGridMenuItems(props: GridFilterItemProps) { const { column, onClick } = props; const apiRef = useGridApiContext(); const sortModel = useGridSelector(apiRef, gridSortModelSelector); @@ -46,7 +46,7 @@ const SortGridMenuItems = (props: GridFilterItemProps) => { ); -}; +} SortGridMenuItems.propTypes = { // ----------------------------- Warning -------------------------------- diff --git a/packages/grid/x-data-grid/src/components/toolbar/GridToolbarExport.tsx b/packages/grid/x-data-grid/src/components/toolbar/GridToolbarExport.tsx index d3f7e69a31be8..ab8b2bf22366f 100644 --- a/packages/grid/x-data-grid/src/components/toolbar/GridToolbarExport.tsx +++ b/packages/grid/x-data-grid/src/components/toolbar/GridToolbarExport.tsx @@ -29,7 +29,7 @@ export interface GridToolbarExportProps extends ButtonProps { [key: string]: any; } -export const GridCsvExportMenuItem = (props: GridCsvExportMenuItemProps) => { +export function GridCsvExportMenuItem(props: GridCsvExportMenuItemProps) { const apiRef = useGridApiContext(); const { hideMenu, options, ...other } = props; @@ -44,9 +44,9 @@ export const GridCsvExportMenuItem = (props: GridCsvExportMenuItemProps) => { {apiRef.current.getLocaleText('toolbarExportCSV')} ); -}; +} -export const GridPrintExportMenuItem = (props: GridPrintExportMenuItemProps) => { +export function GridPrintExportMenuItem(props: GridPrintExportMenuItemProps) { const apiRef = useGridApiContext(); const { hideMenu, options, ...other } = props; @@ -61,7 +61,7 @@ export const GridPrintExportMenuItem = (props: GridPrintExportMenuItemProps) => {apiRef.current.getLocaleText('toolbarExportPrint')} ); -}; +} const GridToolbarExport = React.forwardRef( function GridToolbarExport(props, ref) { diff --git a/packages/grid/x-data-grid/src/context/GridContextProvider.tsx b/packages/grid/x-data-grid/src/context/GridContextProvider.tsx index b530cd9f73595..2fd8de2a3e435 100644 --- a/packages/grid/x-data-grid/src/context/GridContextProvider.tsx +++ b/packages/grid/x-data-grid/src/context/GridContextProvider.tsx @@ -10,11 +10,7 @@ type GridContextProviderProps = { children: React.ReactNode; }; -export const GridContextProvider = ({ - privateApiRef, - props, - children, -}: GridContextProviderProps) => { +export function GridContextProvider({ privateApiRef, props, children }: GridContextProviderProps) { const apiRef = React.useRef(privateApiRef.current.getPublicApi()); return ( @@ -24,4 +20,4 @@ export const GridContextProvider = ({ ); -}; +} diff --git a/packages/grid/x-data-grid/src/hooks/features/rowSelection/useGridRowSelection.ts b/packages/grid/x-data-grid/src/hooks/features/rowSelection/useGridRowSelection.ts index bfd6bdc382e01..d11a47d46f932 100644 --- a/packages/grid/x-data-grid/src/hooks/features/rowSelection/useGridRowSelection.ts +++ b/packages/grid/x-data-grid/src/hooks/features/rowSelection/useGridRowSelection.ts @@ -262,7 +262,7 @@ export const useGridRowSelection = ( endId: GridRowId; }, isSelected = true, - resetSelection, + resetSelection = false, ) => { if (!apiRef.current.getRow(startId) || !apiRef.current.getRow(endId)) { return; diff --git a/packages/grid/x-data-grid/src/hooks/utils/useGridApiEventHandler.test.tsx b/packages/grid/x-data-grid/src/hooks/utils/useGridApiEventHandler.test.tsx index 6a4ddc1d6789c..1bee67891e959 100644 --- a/packages/grid/x-data-grid/src/hooks/utils/useGridApiEventHandler.test.tsx +++ b/packages/grid/x-data-grid/src/hooks/utils/useGridApiEventHandler.test.tsx @@ -37,10 +37,10 @@ describe('useGridApiEventHandler', () => { current: { subscribeEvent: spy(() => unsubscribe) }, }; - const Test = () => { + function Test() { useGridApiEventHandler(apiRef as any, 'cellClick', noop); return null; - }; + } const { unmount } = render(); @@ -69,10 +69,10 @@ describe('useGridApiEventHandler', () => { current: { subscribeEvent: spy(() => unsubscribe) }, }; - const Test = () => { + function Test() { useGridApiEventHandler(apiRef as any, 'cellClick', noop); return null; - }; + } const { unmount } = render(); diff --git a/packages/grid/x-data-grid/src/tests/columns.DataGrid.test.tsx b/packages/grid/x-data-grid/src/tests/columns.DataGrid.test.tsx index 7d52b2727ac5a..c0ac823893bab 100644 --- a/packages/grid/x-data-grid/src/tests/columns.DataGrid.test.tsx +++ b/packages/grid/x-data-grid/src/tests/columns.DataGrid.test.tsx @@ -17,14 +17,16 @@ const columns: GridColumns = [{ field: 'id' }, { field: 'idBis' }]; describe(' - Columns', () => { const { render } = createRenderer(); - const TestDataGrid = ( + function TestDataGrid( props: Omit & Partial>, - ) => ( -
- -
- ); + ) { + return ( +
+ +
+ ); + } describe('prop: initialState.columns.orderedFields / initialState.columns.dimensions', () => { it('should allow to initialize the columns order and dimensions', () => { diff --git a/packages/grid/x-data-grid/src/tests/columns.spec.tsx b/packages/grid/x-data-grid/src/tests/columns.spec.tsx index ffc89836b7ad6..189dea54ad236 100644 --- a/packages/grid/x-data-grid/src/tests/columns.spec.tsx +++ b/packages/grid/x-data-grid/src/tests/columns.spec.tsx @@ -3,7 +3,7 @@ import { DataGrid, GridRenderCellParams } from '@mui/x-data-grid'; import { GridCellParams } from '../models/params/gridCellParams'; import { GridActionsColDef, GridColDef, GridColumns, GridRowParams } from '../models'; -const RenderCellParamsExplicitTyping = () => { +function RenderCellParamsExplicitTyping() { return ( { ]} /> ); -}; +} -const CellParamsFromRowModel = () => { +function CellParamsFromRowModel() { type PriceRowModel = { price1: number; price2: string }; const actionColumn: GridActionsColDef = { @@ -101,9 +101,9 @@ const CellParamsFromRowModel = () => { ]; return ; -}; +} -const CellParamsValue = () => { +function CellParamsValue() { return ( { }} /> ); -}; +} -const CellParamsRow = () => { +function CellParamsRow() { return ( { }} /> ); -}; +} -const CellParamsFormattedValue = () => { +function CellParamsFormattedValue() { return ( { }} /> ); -}; +} diff --git a/packages/grid/x-data-grid/src/tests/columnsGrouping.DataGrid.test.tsx b/packages/grid/x-data-grid/src/tests/columnsGrouping.DataGrid.test.tsx index cfbb9217ea7e5..7928c3d355cb4 100644 --- a/packages/grid/x-data-grid/src/tests/columnsGrouping.DataGrid.test.tsx +++ b/packages/grid/x-data-grid/src/tests/columnsGrouping.DataGrid.test.tsx @@ -30,14 +30,14 @@ type TestDataGridProps = Omit & describe(' - Column grouping', () => { const { render } = createRenderer(); - const TestDataGrid = (props: TestDataGridProps) => { + function TestDataGrid(props: TestDataGridProps) { const { nbColumns, ...other } = props; return (
); - }; + } describe('Header grouping columns', () => { it('should add one header row when columns have a group', () => { @@ -291,11 +291,13 @@ describe(' - Column grouping', () => { // TODO: remove the skip. I failed to test if an error is thrown // eslint-disable-next-line mocha/no-skipped-tests describe.skip('error messages', () => { - const TestWithError = (props: TestDataGridProps) => ( - - - - ); + function TestWithError(props: TestDataGridProps) { + return ( + + + + ); + } it('should log an error if two groups have the same id', () => { expect(() => { diff --git a/packages/grid/x-data-grid/src/tests/columnsVisibility.DataGrid.test.tsx b/packages/grid/x-data-grid/src/tests/columnsVisibility.DataGrid.test.tsx index d67d0901fe068..b42be479be8d1 100644 --- a/packages/grid/x-data-grid/src/tests/columnsVisibility.DataGrid.test.tsx +++ b/packages/grid/x-data-grid/src/tests/columnsVisibility.DataGrid.test.tsx @@ -15,14 +15,16 @@ const columns: GridColumns = [{ field: 'id' }, { field: 'idBis' }]; describe(' - Columns Visibility', () => { const { render } = createRenderer(); - const TestDataGrid = ( + function TestDataGrid( props: Omit & Partial>, - ) => ( -
- -
- ); + ) { + return ( +
+ +
+ ); + } describe('prop: columnVisibilityModel and onColumnVisibilityModelChange', () => { it('should allow to set the columnVisibilityModel prop', () => { diff --git a/packages/grid/x-data-grid/src/tests/components.DataGrid.test.tsx b/packages/grid/x-data-grid/src/tests/components.DataGrid.test.tsx index a53915210b237..dc2fe292ec403 100644 --- a/packages/grid/x-data-grid/src/tests/components.DataGrid.test.tsx +++ b/packages/grid/x-data-grid/src/tests/components.DataGrid.test.tsx @@ -43,7 +43,9 @@ describe(' - Components', () => { }); it('should hide custom footer if prop hideFooter is set', () => { - const CustomFooter = () =>
Custom Footer
; + function CustomFooter() { + return
Custom Footer
; + } render(
diff --git a/packages/grid/x-data-grid/src/tests/export.DataGrid.test.tsx b/packages/grid/x-data-grid/src/tests/export.DataGrid.test.tsx index b932235a0f8d4..37d361fdc6bb9 100644 --- a/packages/grid/x-data-grid/src/tests/export.DataGrid.test.tsx +++ b/packages/grid/x-data-grid/src/tests/export.DataGrid.test.tsx @@ -9,7 +9,7 @@ import { createRenderer, screen, fireEvent } from '@mui/monorepo/test/utils'; describe(' - Export', () => { const { render, clock } = createRenderer({ clock: 'fake' }); - const TestCase = (props: Omit) => { + function TestCase(props: Omit) { const basicData = useBasicDemoData(3, 2); return ( @@ -17,7 +17,7 @@ describe(' - Export', () => {
); - }; + } // We need `createObjectURL` to test the downloaded value before(function beforeHook() { diff --git a/packages/grid/x-data-grid/src/tests/filterPanel.DataGrid.test.tsx b/packages/grid/x-data-grid/src/tests/filterPanel.DataGrid.test.tsx index 96e92d88031a0..f978405fba8c4 100644 --- a/packages/grid/x-data-grid/src/tests/filterPanel.DataGrid.test.tsx +++ b/packages/grid/x-data-grid/src/tests/filterPanel.DataGrid.test.tsx @@ -129,13 +129,13 @@ describe(' - Filter panel', () => { ], }; - const TestCase = (props: Partial) => { + function TestCase(props: Partial) { return (
); - }; + } it('should show an empty string as the default filter input value', () => { render( diff --git a/packages/grid/x-data-grid/src/tests/filtering.DataGrid.test.tsx b/packages/grid/x-data-grid/src/tests/filtering.DataGrid.test.tsx index 18e154b03a394..9d185967d737d 100644 --- a/packages/grid/x-data-grid/src/tests/filtering.DataGrid.test.tsx +++ b/packages/grid/x-data-grid/src/tests/filtering.DataGrid.test.tsx @@ -37,13 +37,13 @@ describe(' - Filter', () => { columns: [{ field: 'brand' }], }; - const TestCase = (props: Partial) => { + function TestCase(props: Partial) { return (
); - }; + } describe('prop: filterModel', () => { it('should throw for more than one filter item', () => { diff --git a/packages/grid/x-data-grid/src/tests/keyboard.DataGrid.test.tsx b/packages/grid/x-data-grid/src/tests/keyboard.DataGrid.test.tsx index 92409bedcb314..ba9dc6d5306db 100644 --- a/packages/grid/x-data-grid/src/tests/keyboard.DataGrid.test.tsx +++ b/packages/grid/x-data-grid/src/tests/keyboard.DataGrid.test.tsx @@ -35,12 +35,12 @@ const expectAriaCoordinate = ( describe(' - Keyboard', () => { const { render } = createRenderer({ clock: 'fake' }); - const NavigationTestCaseNoScrollX = ( + function NavigationTestCaseNoScrollX( props: Omit< DataGridProps, 'autoHeight' | 'rows' | 'columns' | 'pageSize' | 'rowsPerPageOptions' > & {}, - ) => { + ) { const data = useBasicDemoData(100, 3); const transformColSizes = (columns: GridColumns) => columns.map((column) => ({ ...column, width: 60 })); @@ -63,7 +63,7 @@ describe(' - Keyboard', () => { /> ); - }; + } /* eslint-disable material-ui/disallow-active-element-as-key-event-target */ describe('cell navigation', () => { @@ -463,12 +463,12 @@ describe(' - Keyboard', () => { }, ]; - const NavigationTestGroupingCaseNoScrollX = ( + function NavigationTestGroupingCaseNoScrollX( props: Omit< DataGridProps, 'autoHeight' | 'rows' | 'columns' | 'pageSize' | 'rowsPerPageOptions' > & {}, - ) => { + ) { const data = getBasicGridData(10, 10); const transformColSizes = (columns: GridColumns) => columns.map((column) => ({ ...column, width: 60 })); @@ -492,7 +492,7 @@ describe(' - Keyboard', () => { /> ); - }; + } it('should scroll horizontally when navigating between column group headers with arrows', function test() { if (isJSDOM) { diff --git a/packages/grid/x-data-grid/src/tests/layout.DataGrid.test.tsx b/packages/grid/x-data-grid/src/tests/layout.DataGrid.test.tsx index 1504d0648ba9b..b6d74f51ae920 100644 --- a/packages/grid/x-data-grid/src/tests/layout.DataGrid.test.tsx +++ b/packages/grid/x-data-grid/src/tests/layout.DataGrid.test.tsx @@ -84,14 +84,14 @@ describe(' - Layout & Warnings', () => { width?: number; } - const TestCase = (props: TestCaseProps) => { + function TestCase(props: TestCaseProps) { const { width = 300 } = props; return (
); - }; + } const { container, setProps } = render(); let rect; @@ -598,11 +598,13 @@ describe(' - Layout & Warnings', () => { }); it('should resize flex: 1 column when changing columnVisibilityModel to avoid exceeding grid width', () => { - const TestCase = (props: DataGridProps) => ( -
- -
- ); + function TestCase(props: DataGridProps) { + return ( +
+ +
+ ); + } const { setProps } = render( - Layout & Warnings', () => { }); it('should be rerender invariant', () => { - const Test = () => { + function Test() { const columns = [{ field: 'id', headerName: 'ID', flex: 1 }]; return (
); - }; + } const { setProps } = render(); setProps(); @@ -803,14 +805,14 @@ describe(' - Layout & Warnings', () => { // A function test counterpart of ScrollbarOverflowVerticalSnap. it('should not have a horizontal scrollbar if not needed', () => { - const TestCase = () => { + function TestCase() { const data = useBasicDemoData(100, 1); return (
); - }; + } render(); const virtualScroller = document.querySelector('.MuiDataGrid-virtualScroller')!; // It should not have a horizontal scrollbar @@ -1070,11 +1072,13 @@ describe(' - Layout & Warnings', () => { it('should not render the "no rows" overlay when transitioning the loading prop from false to true', () => { const NoRowsOverlay = spy(() => null); - const TestCase = (props: Partial) => ( -
- -
- ); + function TestCase(props: Partial) { + return ( +
+ +
+ ); + } const { setProps } = render(); expect(NoRowsOverlay.callCount).to.equal(0); setProps({ loading: false, rows: [{ id: 1 }] }); @@ -1083,11 +1087,13 @@ describe(' - Layout & Warnings', () => { it('should render the "no rows" overlay when changing the loading to false but not changing the rows prop', () => { const NoRowsOverlay = spy(() => null); - const TestCase = (props: Partial) => ( -
- -
- ); + function TestCase(props: Partial) { + return ( +
+ +
+ ); + } const rows: DataGridProps['rows'] = []; const { setProps } = render(); expect(NoRowsOverlay.callCount).to.equal(0); diff --git a/packages/grid/x-data-grid/src/tests/pagination.DataGrid.test.tsx b/packages/grid/x-data-grid/src/tests/pagination.DataGrid.test.tsx index 19ac349a60484..29a11ffc9a220 100644 --- a/packages/grid/x-data-grid/src/tests/pagination.DataGrid.test.tsx +++ b/packages/grid/x-data-grid/src/tests/pagination.DataGrid.test.tsx @@ -23,9 +23,7 @@ const isJSDOM = /jsdom/.test(window.navigator.userAgent); describe(' - Pagination', () => { const { render } = createRenderer({ clock: 'fake' }); - const BaselineTestCase = ( - props: Omit & { height?: number }, - ) => { + function BaselineTestCase(props: Omit & { height?: number }) { const { height = 300, ...other } = props; const basicData = useBasicDemoData(20, 2); @@ -35,7 +33,7 @@ describe(' - Pagination', () => { ); - }; + } describe('prop: page and onPageChange', () => { before(function beforeHook() { @@ -151,7 +149,7 @@ describe(' - Pagination', () => { }); it('should control page state when the prop and the onChange are set', () => { - const ControlCase = () => { + function ControlCase() { const [page, setPage] = React.useState(0); return ( @@ -162,7 +160,7 @@ describe(' - Pagination', () => { rowsPerPageOptions={[1]} /> ); - }; + } render(); @@ -175,7 +173,7 @@ describe(' - Pagination', () => { it('should go to last page when page is controlled and the current page is greater than the last page', () => { const onPageChange = spy(); - const TestCasePaginationFilteredData = (props: Partial) => { + function TestCasePaginationFilteredData(props: Partial) { const [page, setPage] = React.useState(1); const handlePageChange: DataGridProps['onPageChange'] = (newPage) => { @@ -192,7 +190,7 @@ describe(' - Pagination', () => { {...props} /> ); - }; + } const { setProps } = render(); expect(onPageChange.callCount).to.equal(0); @@ -337,7 +335,7 @@ describe(' - Pagination', () => { }); it('should control pageSize state when the prop and the onChange are set', () => { - const ControlCase = () => { + function ControlCase() { const [pageSize, setPageSize] = React.useState(1); return ( @@ -348,7 +346,7 @@ describe(' - Pagination', () => { rowsPerPageOptions={[1, 2, 3]} /> ); - }; + } render(); @@ -412,9 +410,9 @@ describe(' - Pagination', () => { } }); - const TestCaseAutoPageSize = ( + function TestCaseAutoPageSize( props: Omit & { height: number; nbRows: number }, - ) => { + ) { const { height, nbRows, ...other } = props; const data = useBasicDemoData(nbRows, 10); @@ -424,7 +422,7 @@ describe(' - Pagination', () => { ); - }; + } it('should give priority to the controlled pageSize', () => { render(); @@ -549,7 +547,7 @@ describe(' - Pagination', () => { }); it('should support server side pagination', () => { - const ServerPaginationGrid = () => { + function ServerPaginationGrid() { const [rows, setRows] = React.useState([]); const [page, setPage] = React.useState(0); @@ -592,7 +590,7 @@ describe(' - Pagination', () => { /> ); - }; + } render(); expect(getColumnValues(0)).to.deep.equal(['0']); diff --git a/packages/grid/x-data-grid/src/tests/quickFiltering.DataGrid.test.tsx b/packages/grid/x-data-grid/src/tests/quickFiltering.DataGrid.test.tsx index bf2328cfb21ef..6a6eb788fbd91 100644 --- a/packages/grid/x-data-grid/src/tests/quickFiltering.DataGrid.test.tsx +++ b/packages/grid/x-data-grid/src/tests/quickFiltering.DataGrid.test.tsx @@ -37,13 +37,13 @@ describe(' - Quick Filter', () => { columns: [{ field: 'brand' }], }; - const TestCase = (props: Partial) => { + function TestCase(props: Partial) { return (
); - }; + } describe('component', () => { it('should apply filter', () => { diff --git a/packages/grid/x-data-grid/src/tests/rowSelection.DataGrid.test.tsx b/packages/grid/x-data-grid/src/tests/rowSelection.DataGrid.test.tsx index a3eb9e6c0b2e3..c351ac7ac5f44 100644 --- a/packages/grid/x-data-grid/src/tests/rowSelection.DataGrid.test.tsx +++ b/packages/grid/x-data-grid/src/tests/rowSelection.DataGrid.test.tsx @@ -38,16 +38,21 @@ describe(' - Row Selection', () => { const defaultData = getBasicGridData(4, 2); - const TestDataGridSelection = (props: Partial) => ( -
- -
- ); + function TestDataGridSelection(props: Partial) { + return ( +
+ +
+ ); + } describe('prop: checkboxSelection = false (single selection)', () => { it('should select one row at a time on click WITHOUT ctrl or meta pressed', () => { @@ -701,7 +706,7 @@ describe(' - Row Selection', () => { }); it('should control selection state when the model and the onChange are set', () => { - const ControlCase = () => { + function ControlCase() { const [rowSelectionModel, setRowSelectionModel] = React.useState([]); const handleSelectionChange: DataGridProps['onRowSelectionModelChange'] = (newModel) => { @@ -719,7 +724,7 @@ describe(' - Row Selection', () => { checkboxSelection /> ); - }; + } render(); expect(getSelectedRowIds()).to.deep.equal([]); diff --git a/packages/grid/x-data-grid/src/tests/rows.DataGrid.test.tsx b/packages/grid/x-data-grid/src/tests/rows.DataGrid.test.tsx index 7774aee84d5c1..309a6e5bd80fc 100644 --- a/packages/grid/x-data-grid/src/tests/rows.DataGrid.test.tsx +++ b/packages/grid/x-data-grid/src/tests/rows.DataGrid.test.tsx @@ -67,11 +67,13 @@ describe(' - Rows', () => { it('should support new dataset', () => { const { rows, columns } = getBasicGridData(5, 2); - const Test = (props: Pick) => ( -
- -
- ); + function Test(props: Pick) { + return ( +
+ +
+ ); + } const { setProps } = render(); expect(getColumnValues(0)).to.deep.equal(['0', '1']); @@ -82,12 +84,16 @@ describe(' - Rows', () => { it('should ignore events coming from a portal in the cell', () => { const handleRowClick = spy(); - const InputCell = () => ; - const PortalCell = () => ( - - - - ); + function InputCell() { + return ; + } + function PortalCell() { + return ( + + + + ); + } render(
@@ -154,10 +160,10 @@ describe(' - Rows', () => { }); describe('columnType: actions', () => { - const TestCase = ({ + function TestCase({ getActions, ...other - }: { getActions?: () => JSX.Element[] } & Partial) => { + }: { getActions?: () => JSX.Element[] } & Partial) { return (
- Rows', () => { />
); - }; + } it('should throw an error if getActions is missing', function test() { if (!isJSDOM) { @@ -373,7 +379,7 @@ describe(' - Rows', () => { it('should focus the last button if the clicked button removes itself', () => { let canDelete = true; - const Test = () => { + function Test() { return ( @@ -392,7 +398,7 @@ describe(' - Rows', () => { } /> ); - }; + } render(); fireEvent.click(screen.getByRole('menuitem', { name: 'delete' })); expect(screen.getByRole('menuitem', { name: 'print' })).toHaveFocus(); @@ -424,14 +430,14 @@ describe(' - Rows', () => { describe('static row height', () => { const ROW_HEIGHT = 52; - const TestCase = (props: Partial) => { + function TestCase(props: Partial) { const getRowId: GridRowIdGetter = (row) => `${row.clientId}`; return (
); - }; + } it('should set each row height whe rowHeight prop is used', () => { const { setProps } = render(); @@ -522,13 +528,13 @@ describe(' - Rows', () => { window.ResizeObserver = originalResizeObserver; }); - const TestCase = ( + function TestCase( props: Partial & { getBioContentHeight: (row: GridRowModel) => number; height?: number; width?: number; }, - ) => { + ) { const { getBioContentHeight, width = 300, height = 300, ...other } = props; const customCellRenderer = React.useCallback( @@ -554,7 +560,7 @@ describe(' - Rows', () => { />
); - }; + } it('should measure all rows and update the content size', async () => { const border = 1; @@ -869,13 +875,13 @@ describe(' - Rows', () => { describe('prop: getRowSpacing', () => { const { rows, columns } = getBasicGridData(4, 2); - const TestCase = (props: Partial) => { + function TestCase(props: Partial) { return (
); - }; + } it('should be called with the correct params', () => { const getRowSpacing = stub().returns({}); diff --git a/packages/grid/x-data-grid/src/tests/sorting.DataGrid.test.tsx b/packages/grid/x-data-grid/src/tests/sorting.DataGrid.test.tsx index bf482d41b186e..e893d2dd0a6f6 100644 --- a/packages/grid/x-data-grid/src/tests/sorting.DataGrid.test.tsx +++ b/packages/grid/x-data-grid/src/tests/sorting.DataGrid.test.tsx @@ -180,7 +180,7 @@ describe(' - Sorting', () => { rows: any[]; } - const TestCase = (props: TestCaseProps) => { + function TestCase(props: TestCaseProps) { const { rows } = props; return (
@@ -196,7 +196,7 @@ describe(' - Sorting', () => { />
); - }; + } const { setProps } = render(); expect(getColumnValues(0)).to.deep.equal(['Adidas', 'Nike', 'Puma']); @@ -225,7 +225,7 @@ describe(' - Sorting', () => { rows: any[]; } - const TestCase = (props: TestCaseProps) => { + function TestCase(props: TestCaseProps) { const { rows } = props; return (
@@ -242,7 +242,7 @@ describe(' - Sorting', () => { />
); - }; + } const rows = [ { @@ -266,14 +266,14 @@ describe(' - Sorting', () => { }); it('should support new dataset', () => { - const TestCase = (props: DataGridProps) => { + function TestCase(props: DataGridProps) { const { rows, columns } = props; return (
); - }; + } const { setProps } = render(); @@ -305,7 +305,7 @@ describe(' - Sorting', () => { }); it('should support new dataset in control mode', () => { - const TestCase = (props: DataGridProps) => { + function TestCase(props: DataGridProps) { const { rows, columns } = props; const [sortModel, setSortModel] = React.useState(); @@ -320,7 +320,7 @@ describe(' - Sorting', () => { /> ); - }; + } const { setProps } = render(); @@ -352,13 +352,13 @@ describe(' - Sorting', () => { }); it('should clear the sorting col when passing an empty sortModel', () => { - const TestCase = (props: Partial) => { + function TestCase(props: Partial) { return (
); - }; + } const { setProps } = render(); @@ -368,11 +368,13 @@ describe(' - Sorting', () => { }); describe('prop: initialState.sorting', () => { - const Test = (props: Partial) => ( -
- -
- ); + function Test(props: Partial) { + return ( +
+ +
+ ); + } it('should allow to initialize the sortModel', () => { render( diff --git a/packages/grid/x-data-grid/src/tests/toolbar.DataGrid.test.tsx b/packages/grid/x-data-grid/src/tests/toolbar.DataGrid.test.tsx index 23eedd9f8de33..a0665ba0690a2 100644 --- a/packages/grid/x-data-grid/src/tests/toolbar.DataGrid.test.tsx +++ b/packages/grid/x-data-grid/src/tests/toolbar.DataGrid.test.tsx @@ -135,11 +135,13 @@ describe(' - Toolbar', () => { }); it('should apply to the root element a class corresponding to the current density', () => { - const Test = (props: Partial) => ( -
- -
- ); + function Test(props: Partial) { + return ( +
+ +
+ ); + } const { setProps } = render(); expect(screen.getByRole('grid')).to.have.class(gridClasses['root--densityStandard']); setProps({ density: 'compact' }); diff --git a/packages/x-date-pickers-pro/src/tests/testValidation/testTextFieldValidation.tsx b/packages/x-date-pickers-pro/src/tests/testValidation/testTextFieldValidation.tsx index bda16db8350ed..96bcffbea877a 100644 --- a/packages/x-date-pickers-pro/src/tests/testValidation/testTextFieldValidation.tsx +++ b/packages/x-date-pickers-pro/src/tests/testValidation/testTextFieldValidation.tsx @@ -223,10 +223,10 @@ function testTextFieldValidation(ElementToTest, propsToTest, getOptions) { const { render, withDate, isSingleInput } = getOptions(); let now; - const WithFakeTimer = (props) => { + function WithFakeTimer(props) { now = adapterToUse.date(new Date()); return ; - }; + } const { setProps } = render(); @@ -258,10 +258,10 @@ function testTextFieldValidation(ElementToTest, propsToTest, getOptions) { const { render, withDate, isSingleInput } = getOptions(); let now; - const WithFakeTimer = (props) => { + function WithFakeTimer(props) { now = adapterToUse.date(new Date()); return ; - }; + } const { setProps } = render(); diff --git a/packages/x-date-pickers/src/DateCalendar/DayCalendar.tsx b/packages/x-date-pickers/src/DateCalendar/DayCalendar.tsx index c4f0db7dedb38..fd0edfaab49ac 100644 --- a/packages/x-date-pickers/src/DateCalendar/DayCalendar.tsx +++ b/packages/x-date-pickers/src/DateCalendar/DayCalendar.tsx @@ -173,7 +173,7 @@ const PickersCalendarWeek = styled('div', { justifyContent: 'center', }); -const WrappedDay = ({ +function WrappedDay({ parentProps, day, focusableDay, @@ -191,7 +191,7 @@ const WrappedDay = ({ selectedDays: TDate[]; isDateDisabled: (date: TDate | null) => boolean; currentMonthNumber: number; -}) => { +}) { const utils = useUtils(); const now = useNow(); @@ -241,7 +241,7 @@ const WrappedDay = ({ aria-current={isToday ? 'date' : undefined} /> ); -}; +} /** * @ignore - do not document. diff --git a/packages/x-date-pickers/src/DateCalendar/tests/validation.DateCalendar.test.tsx b/packages/x-date-pickers/src/DateCalendar/tests/validation.DateCalendar.test.tsx index 3335ae9aadcce..f2a538bab9820 100644 --- a/packages/x-date-pickers/src/DateCalendar/tests/validation.DateCalendar.test.tsx +++ b/packages/x-date-pickers/src/DateCalendar/tests/validation.DateCalendar.test.tsx @@ -4,9 +4,9 @@ import { screen, fireEvent } from '@mui/monorepo/test/utils'; import { DateCalendar, DateCalendarProps } from '@mui/x-date-pickers/DateCalendar'; import { createPickerRenderer, adapterToUse } from '../../../../../test/utils/pickers-utils'; -const WrappedDateCalendar = ( +function WrappedDateCalendar( props: Omit, 'value' | 'onChange'> & { initialValue: TDate }, -) => { +) { const { initialValue, ...other } = props; const [value, setValue] = React.useState(initialValue); @@ -16,7 +16,7 @@ const WrappedDateCalendar = ( }, []); return ; -}; +} describe(' - Validation', () => { const { render, clock } = createPickerRenderer({ clock: 'fake' }); diff --git a/packages/x-date-pickers/src/DatePicker/DatePicker.spec.tsx b/packages/x-date-pickers/src/DatePicker/DatePicker.spec.tsx index 2187bf9696614..e8b54c1688808 100644 --- a/packages/x-date-pickers/src/DatePicker/DatePicker.spec.tsx +++ b/packages/x-date-pickers/src/DatePicker/DatePicker.spec.tsx @@ -19,7 +19,7 @@ import { expectType } from '@mui/types'; />; // Inference from the state -const InferTest = () => { +function InferTest() { const [value, setValue] = React.useState(moment()); return ( @@ -29,7 +29,7 @@ const InferTest = () => { renderInput={() => } /> ); -}; +} // Allows inferring from side props ', () => { }); describe('rendering', () => { - const ControlledDatePicker = () => { + function ControlledDatePicker() { const [value, setValue] = React.useState(null); return ( ', () => { onChange={(newValue) => setValue(newValue)} /> ); - }; + } it('should handle controlled `onChange` in desktop mode', () => { render(); diff --git a/packages/x-date-pickers/src/DateTimePicker/DateTimePicker.test.tsx b/packages/x-date-pickers/src/DateTimePicker/DateTimePicker.test.tsx index 39e427f8c14fa..3dae12dca48fc 100644 --- a/packages/x-date-pickers/src/DateTimePicker/DateTimePicker.test.tsx +++ b/packages/x-date-pickers/src/DateTimePicker/DateTimePicker.test.tsx @@ -7,7 +7,7 @@ import { createPickerRenderer, stubMatchMedia } from 'test/utils/pickers-utils'; import describeValidation from '@mui/x-date-pickers/tests/describeValidation'; describe('', () => { - const ControlledDateTimePicker = () => { + function ControlledDateTimePicker() { const [value, setValue] = React.useState(null); return ( ', () => { onChange={(newValue) => setValue(newValue)} /> ); - }; + } const { render, clock } = createPickerRenderer({ clock: 'fake' }); diff --git a/packages/x-date-pickers/src/DesktopDatePicker/DesktopDatePicker.test.tsx b/packages/x-date-pickers/src/DesktopDatePicker/DesktopDatePicker.test.tsx index d67ee8b7ac474..d181478b3d0d7 100644 --- a/packages/x-date-pickers/src/DesktopDatePicker/DesktopDatePicker.test.tsx +++ b/packages/x-date-pickers/src/DesktopDatePicker/DesktopDatePicker.test.tsx @@ -122,7 +122,7 @@ describe('', () => { }); it('should allow to switch from invalid date to null date in the input', () => { - const Test = () => { + function Test() { const [value, setValue] = React.useState(null); return ( @@ -140,7 +140,7 @@ describe('', () => { ); - }; + } render(); diff --git a/packages/x-date-pickers/src/DesktopDatePicker/DesktopDatePickerLocalization.test.tsx b/packages/x-date-pickers/src/DesktopDatePicker/DesktopDatePickerLocalization.test.tsx index 08c2e9596199f..06e6e314cd587 100644 --- a/packages/x-date-pickers/src/DesktopDatePicker/DesktopDatePickerLocalization.test.tsx +++ b/packages/x-date-pickers/src/DesktopDatePicker/DesktopDatePickerLocalization.test.tsx @@ -32,7 +32,7 @@ describe(' localization', () => { PickerProps: Partial>; } - const Form = (props: FormProps) => { + function Form(props: FormProps) { const { Picker, PickerProps } = props; const [value, setValue] = React.useState(adapterToUse.date('01/01/2020')); @@ -44,7 +44,7 @@ describe(' localization', () => { {...PickerProps} /> ); - }; + } it(`should set invalid`, () => { localizedRender( diff --git a/packages/x-date-pickers/src/LocalizationProvider/LocalizationProvider.test.tsx b/packages/x-date-pickers/src/LocalizationProvider/LocalizationProvider.test.tsx index c85bab12ce27c..60ff5e42af823 100644 --- a/packages/x-date-pickers/src/LocalizationProvider/LocalizationProvider.test.tsx +++ b/packages/x-date-pickers/src/LocalizationProvider/LocalizationProvider.test.tsx @@ -7,11 +7,11 @@ import { useLocalizationContext } from '@mui/x-date-pickers/internals'; import { LocalizationProvider, PickersLocaleText } from '@mui/x-date-pickers'; import { AdapterClassToUse } from 'test/utils/pickers-utils'; -const ContextListener = ({ +function ContextListener({ onContextChange, }: { onContextChange: (context: ReturnType) => void; -}) => { +}) { const context = useLocalizationContext(); React.useEffect(() => { @@ -19,7 +19,7 @@ const ContextListener = ({ }, [onContextChange, context]); return null; -}; +} describe('', () => { const { render } = createRenderer(); diff --git a/packages/x-date-pickers/src/PickersActionBar/PickersActionBar.tsx b/packages/x-date-pickers/src/PickersActionBar/PickersActionBar.tsx index d811b3b0a3ede..2943f94a262b6 100644 --- a/packages/x-date-pickers/src/PickersActionBar/PickersActionBar.tsx +++ b/packages/x-date-pickers/src/PickersActionBar/PickersActionBar.tsx @@ -24,7 +24,7 @@ export interface PickersActionBarProps extends DialogActionsProps { onSetToday: () => void; } -export const PickersActionBar = (props: PickersActionBarProps) => { +export function PickersActionBar(props: PickersActionBarProps) { const { onAccept, onClear, onCancel, onSetToday, actions, ...other } = props; const wrapperVariant = React.useContext(WrapperVariantContext); @@ -68,4 +68,4 @@ export const PickersActionBar = (props: PickersActionBarProps) => { }); return {buttons}; -}; +} diff --git a/packages/x-date-pickers/src/StaticDateTimePicker/StaticDateTimePicker.test.tsx b/packages/x-date-pickers/src/StaticDateTimePicker/StaticDateTimePicker.test.tsx index f8afb83f6dda2..914385edadd8a 100644 --- a/packages/x-date-pickers/src/StaticDateTimePicker/StaticDateTimePicker.test.tsx +++ b/packages/x-date-pickers/src/StaticDateTimePicker/StaticDateTimePicker.test.tsx @@ -126,12 +126,14 @@ describe('', () => { }); it('should render custom component', () => { - const CustomPickerTabs = (props: DateTimePickerTabsProps) => ( - - - test-custom-picker-tabs - - ); + function CustomPickerTabs(props: DateTimePickerTabsProps) { + return ( + + + test-custom-picker-tabs + + ); + } render( ', () => { - const ControlledTimePicker = () => { + function ControlledTimePicker() { const [value, setValue] = React.useState(null); return ( ', () => { onChange={(newValue) => setValue(newValue)} /> ); - }; + } describeConformance( ) => { +export function PickersModalDialog(props: React.PropsWithChildren) { const { children, onAccept, @@ -111,4 +111,4 @@ export const PickersModalDialog = (props: React.PropsWithChildren ); -}; +} diff --git a/packages/x-date-pickers/src/tests/testValidation/testDayViewValidation.tsx b/packages/x-date-pickers/src/tests/testValidation/testDayViewValidation.tsx index e0c587e3e2233..e1360c2a8d216 100644 --- a/packages/x-date-pickers/src/tests/testValidation/testDayViewValidation.tsx +++ b/packages/x-date-pickers/src/tests/testValidation/testDayViewValidation.tsx @@ -94,10 +94,10 @@ function testDayViewValidation(ElementToTest, propsToTest, getOptions) { const { render, clock } = getOptions(); let now; - const WithFakeTimer = (props) => { + function WithFakeTimer(props) { now = adapterToUse.date(new Date()); return ; - }; + } const { setProps } = render(); const tomorrow = adapterToUse.addDays(now, 1); @@ -130,10 +130,10 @@ function testDayViewValidation(ElementToTest, propsToTest, getOptions) { const { render, clock } = getOptions(); let now; - const WithFakeTimer = (props) => { + function WithFakeTimer(props) { now = adapterToUse.date(new Date()); return ; - }; + } const { setProps } = render(); const tomorrow = adapterToUse.addDays(now, 1); diff --git a/packages/x-date-pickers/src/tests/testValidation/testMonthViewValidation.tsx b/packages/x-date-pickers/src/tests/testValidation/testMonthViewValidation.tsx index 1b9a91a380080..b6bea998392b3 100644 --- a/packages/x-date-pickers/src/tests/testValidation/testMonthViewValidation.tsx +++ b/packages/x-date-pickers/src/tests/testValidation/testMonthViewValidation.tsx @@ -43,10 +43,10 @@ function testMonthViewValidation(ElementToTest, propsToTest, getOptions) { const { render, clock } = getOptions(); let now; - const WithFakeTimer = (props) => { + function WithFakeTimer(props) { now = adapterToUse.date(new Date()); return ; - }; + } const { setProps } = render(); const nextMonth = adapterToUse.addMonths(now, 1); @@ -81,10 +81,10 @@ function testMonthViewValidation(ElementToTest, propsToTest, getOptions) { const { render, clock } = getOptions(); let now; - const WithFakeTimer = (props) => { + function WithFakeTimer(props) { now = adapterToUse.date(new Date()); return ; - }; + } const { setProps } = render(); const nextMonth = adapterToUse.addMonths(now, 1); diff --git a/packages/x-date-pickers/src/tests/testValidation/testTextFieldValidation.tsx b/packages/x-date-pickers/src/tests/testValidation/testTextFieldValidation.tsx index 66da63d9949c9..200c63a67525a 100644 --- a/packages/x-date-pickers/src/tests/testValidation/testTextFieldValidation.tsx +++ b/packages/x-date-pickers/src/tests/testValidation/testTextFieldValidation.tsx @@ -101,10 +101,10 @@ function testTextFieldValidation(ElementToTest, propsToTest, getOptions) { } let now; - const WithFakeTimer = (props) => { + function WithFakeTimer(props) { now = adapterToUse.date(new Date()); return ; - }; + } const { setProps } = render(); @@ -129,10 +129,10 @@ function testTextFieldValidation(ElementToTest, propsToTest, getOptions) { } let now; - const WithFakeTimer = (props) => { + function WithFakeTimer(props) { now = adapterToUse.date(new Date()); return ; - }; + } const { setProps } = render(); diff --git a/packages/x-date-pickers/src/tests/testValidation/testYearViewValidation.tsx b/packages/x-date-pickers/src/tests/testValidation/testYearViewValidation.tsx index 5375001ed3a5c..c6f809f501a15 100644 --- a/packages/x-date-pickers/src/tests/testValidation/testYearViewValidation.tsx +++ b/packages/x-date-pickers/src/tests/testValidation/testYearViewValidation.tsx @@ -49,10 +49,10 @@ function testYearViewValidation(ElementToTest, propsToTest, getOptions) { const { render } = getOptions(); let now; - const WithFakeTimer = (props) => { + function WithFakeTimer(props) { now = adapterToUse.date(new Date()); return ; - }; + } render(); const nextYear = adapterToUse.addYears(now, 1); @@ -75,10 +75,10 @@ function testYearViewValidation(ElementToTest, propsToTest, getOptions) { const { render } = getOptions(); let now; - const WithFakeTimer = (props) => { + function WithFakeTimer(props) { now = adapterToUse.date(new Date()); return ; - }; + } render(); const nextYear = adapterToUse.addYears(now, 1); diff --git a/scripts/x-data-grid-premium.exports.json b/scripts/x-data-grid-premium.exports.json index ac5e00735d027..260f59b1921d9 100644 --- a/scripts/x-data-grid-premium.exports.json +++ b/scripts/x-data-grid-premium.exports.json @@ -66,7 +66,7 @@ { "name": "GRID_SINGLE_SELECT_COL_DEF", "kind": "Variable" }, { "name": "GRID_STRING_COL_DEF", "kind": "Variable" }, { "name": "GRID_TREE_DATA_GROUPING_FIELD", "kind": "Variable" }, - { "name": "GridActionsCell", "kind": "Variable" }, + { "name": "GridActionsCell", "kind": "Function" }, { "name": "GridActionsCellItem", "kind": "Variable" }, { "name": "GridActionsCellItemProps", "kind": "TypeAlias" }, { "name": "GridActionsColDef", "kind": "Interface" }, @@ -174,7 +174,7 @@ { "name": "GridColumnOrderChangeParams", "kind": "Interface" }, { "name": "GridColumnPinningApi", "kind": "Interface" }, { "name": "GridColumnPinningInternalCache", "kind": "Interface" }, - { "name": "GridColumnPinningMenuItems", "kind": "Variable" }, + { "name": "GridColumnPinningMenuItems", "kind": "Function" }, { "name": "GridColumnPinningState", "kind": "TypeAlias" }, { "name": "gridColumnPositionsSelector", "kind": "Variable" }, { "name": "gridColumnReorderDragColSelector", "kind": "Variable" }, @@ -186,7 +186,7 @@ { "name": "GridColumns", "kind": "TypeAlias" }, { "name": "GridColumnsGroupingState", "kind": "Interface" }, { "name": "GridColumnsInitialState", "kind": "Interface" }, - { "name": "GridColumnsMenuItem", "kind": "Variable" }, + { "name": "GridColumnsMenuItem", "kind": "Function" }, { "name": "GridColumnsMeta", "kind": "Interface" }, { "name": "gridColumnsMetaSelector", "kind": "Variable" }, { "name": "GridColumnsPanel", "kind": "Function" }, @@ -197,12 +197,12 @@ { "name": "GridColumnVisibilityModel", "kind": "TypeAlias" }, { "name": "gridColumnVisibilityModelSelector", "kind": "Variable" }, { "name": "GridComparatorFn", "kind": "TypeAlias" }, - { "name": "GridContextProvider", "kind": "Variable" }, + { "name": "GridContextProvider", "kind": "Function" }, { "name": "GridControlledStateEventLookup", "kind": "Interface" }, { "name": "GridControlledStateReasonLookup", "kind": "Interface" }, { "name": "GridCoreApi", "kind": "Interface" }, { "name": "GridCsvExportApi", "kind": "Interface" }, - { "name": "GridCsvExportMenuItem", "kind": "Variable" }, + { "name": "GridCsvExportMenuItem", "kind": "Function" }, { "name": "GridCsvExportMenuItemProps", "kind": "TypeAlias" }, { "name": "GridCsvExportOptions", "kind": "Interface" }, { "name": "GridCsvGetRowsToExportParams", "kind": "Interface" }, @@ -228,7 +228,7 @@ { "name": "gridDetailPanelExpandedRowsHeightCacheSelector", "kind": "Variable" }, { "name": "GridDetailPanelInitialState", "kind": "TypeAlias" }, { "name": "GridDetailPanelState", "kind": "Interface" }, - { "name": "GridDetailPanelToggleCell", "kind": "Variable" }, + { "name": "GridDetailPanelToggleCell", "kind": "Function" }, { "name": "GridDimensions", "kind": "Interface" }, { "name": "GridDimensionsApi", "kind": "Interface" }, { "name": "GridDisableVirtualizationApi", "kind": "Interface" }, @@ -258,7 +258,7 @@ { "name": "GridEventPublisher", "kind": "TypeAlias" }, { "name": "GridEvents", "kind": "TypeAlias" }, { "name": "GridExcelExportApi", "kind": "Interface" }, - { "name": "GridExcelExportMenuItem", "kind": "Variable" }, + { "name": "GridExcelExportMenuItem", "kind": "Function" }, { "name": "GridExcelExportMenuItemProps", "kind": "TypeAlias" }, { "name": "GridExcelExportOptions", "kind": "Interface" }, { "name": "GridExceljsProcessInput", "kind": "Interface" }, @@ -300,7 +300,7 @@ { "name": "GridFilterItem", "kind": "Interface" }, { "name": "GridFilterItemProps", "kind": "Interface" }, { "name": "GridFilterListIcon", "kind": "Variable" }, - { "name": "GridFilterMenuItem", "kind": "Variable" }, + { "name": "GridFilterMenuItem", "kind": "Function" }, { "name": "GridFilterModel", "kind": "Interface" }, { "name": "gridFilterModelSelector", "kind": "Variable" }, { "name": "GridFilterOperator", "kind": "Interface" }, @@ -341,7 +341,7 @@ { "name": "GridLoadingOverlay", "kind": "Variable" }, { "name": "GridLocaleText", "kind": "Interface" }, { "name": "GridLocaleTextApi", "kind": "Interface" }, - { "name": "GridMenu", "kind": "Variable" }, + { "name": "GridMenu", "kind": "Function" }, { "name": "GridMenuIcon", "kind": "Variable" }, { "name": "GridMenuParams", "kind": "Interface" }, { "name": "GridMenuProps", "kind": "Interface" }, @@ -388,7 +388,7 @@ { "name": "GridPreferencesPanelApi", "kind": "Interface" }, { "name": "GridPreProcessEditCellProps", "kind": "Interface" }, { "name": "GridPrintExportApi", "kind": "Interface" }, - { "name": "GridPrintExportMenuItem", "kind": "Variable" }, + { "name": "GridPrintExportMenuItem", "kind": "Function" }, { "name": "GridPrintExportMenuItemProps", "kind": "TypeAlias" }, { "name": "GridPrintExportOptions", "kind": "Interface" }, { "name": "gridQuickFilterValuesSelector", "kind": "Variable" }, @@ -519,7 +519,7 @@ { "name": "gridTotalHeaderHeightSelector", "kind": "Variable" }, { "name": "GridTranslationKeys", "kind": "TypeAlias" }, { "name": "GridTreeBasicNode", "kind": "Interface" }, - { "name": "GridTreeDataGroupingCell", "kind": "Variable" }, + { "name": "GridTreeDataGroupingCell", "kind": "Function" }, { "name": "GridTreeNode", "kind": "TypeAlias" }, { "name": "GridTreeNodeWithRender", "kind": "TypeAlias" }, { "name": "GridTripleDotsVerticalIcon", "kind": "Variable" }, @@ -543,7 +543,7 @@ { "name": "gridVisibleSortedTopLevelRowEntriesSelector", "kind": "Variable" }, { "name": "gridVisibleTopLevelRowCountSelector", "kind": "Variable" }, { "name": "heIL", "kind": "Variable" }, - { "name": "HideGridColMenuItem", "kind": "Variable" }, + { "name": "HideGridColMenuItem", "kind": "Function" }, { "name": "huHU", "kind": "Variable" }, { "name": "isLeaf", "kind": "Function" }, { "name": "itIT", "kind": "Variable" }, @@ -570,7 +570,7 @@ { "name": "selectedGridRowsSelector", "kind": "Variable" }, { "name": "selectedIdsLookupSelector", "kind": "Variable" }, { "name": "skSK", "kind": "Variable" }, - { "name": "SortGridMenuItems", "kind": "Variable" }, + { "name": "SortGridMenuItems", "kind": "Function" }, { "name": "SUBMIT_FILTER_DATE_STROKE_TIME", "kind": "Variable" }, { "name": "SUBMIT_FILTER_STROKE_TIME", "kind": "Variable" }, { "name": "svSE", "kind": "Variable" }, diff --git a/scripts/x-data-grid-pro.exports.json b/scripts/x-data-grid-pro.exports.json index 9ca45abab7ffc..b492a79086691 100644 --- a/scripts/x-data-grid-pro.exports.json +++ b/scripts/x-data-grid-pro.exports.json @@ -60,7 +60,7 @@ { "name": "GRID_SINGLE_SELECT_COL_DEF", "kind": "Variable" }, { "name": "GRID_STRING_COL_DEF", "kind": "Variable" }, { "name": "GRID_TREE_DATA_GROUPING_FIELD", "kind": "Variable" }, - { "name": "GridActionsCell", "kind": "Variable" }, + { "name": "GridActionsCell", "kind": "Function" }, { "name": "GridActionsCellItem", "kind": "Variable" }, { "name": "GridActionsCellItemProps", "kind": "TypeAlias" }, { "name": "GridActionsColDef", "kind": "Interface" }, @@ -153,7 +153,7 @@ { "name": "GridColumnOrderChangeParams", "kind": "Interface" }, { "name": "GridColumnPinningApi", "kind": "Interface" }, { "name": "GridColumnPinningInternalCache", "kind": "Interface" }, - { "name": "GridColumnPinningMenuItems", "kind": "Variable" }, + { "name": "GridColumnPinningMenuItems", "kind": "Function" }, { "name": "GridColumnPinningState", "kind": "TypeAlias" }, { "name": "gridColumnPositionsSelector", "kind": "Variable" }, { "name": "gridColumnReorderDragColSelector", "kind": "Variable" }, @@ -165,7 +165,7 @@ { "name": "GridColumns", "kind": "TypeAlias" }, { "name": "GridColumnsGroupingState", "kind": "Interface" }, { "name": "GridColumnsInitialState", "kind": "Interface" }, - { "name": "GridColumnsMenuItem", "kind": "Variable" }, + { "name": "GridColumnsMenuItem", "kind": "Function" }, { "name": "GridColumnsMeta", "kind": "Interface" }, { "name": "gridColumnsMetaSelector", "kind": "Variable" }, { "name": "GridColumnsPanel", "kind": "Function" }, @@ -176,12 +176,12 @@ { "name": "GridColumnVisibilityModel", "kind": "TypeAlias" }, { "name": "gridColumnVisibilityModelSelector", "kind": "Variable" }, { "name": "GridComparatorFn", "kind": "TypeAlias" }, - { "name": "GridContextProvider", "kind": "Variable" }, + { "name": "GridContextProvider", "kind": "Function" }, { "name": "GridControlledStateEventLookup", "kind": "Interface" }, { "name": "GridControlledStateReasonLookup", "kind": "Interface" }, { "name": "GridCoreApi", "kind": "Interface" }, { "name": "GridCsvExportApi", "kind": "Interface" }, - { "name": "GridCsvExportMenuItem", "kind": "Variable" }, + { "name": "GridCsvExportMenuItem", "kind": "Function" }, { "name": "GridCsvExportMenuItemProps", "kind": "TypeAlias" }, { "name": "GridCsvExportOptions", "kind": "Interface" }, { "name": "GridCsvGetRowsToExportParams", "kind": "Interface" }, @@ -207,7 +207,7 @@ { "name": "gridDetailPanelExpandedRowsHeightCacheSelector", "kind": "Variable" }, { "name": "GridDetailPanelInitialState", "kind": "TypeAlias" }, { "name": "GridDetailPanelState", "kind": "Interface" }, - { "name": "GridDetailPanelToggleCell", "kind": "Variable" }, + { "name": "GridDetailPanelToggleCell", "kind": "Function" }, { "name": "GridDimensions", "kind": "Interface" }, { "name": "GridDimensionsApi", "kind": "Interface" }, { "name": "GridDisableVirtualizationApi", "kind": "Interface" }, @@ -274,7 +274,7 @@ { "name": "GridFilterItem", "kind": "Interface" }, { "name": "GridFilterItemProps", "kind": "Interface" }, { "name": "GridFilterListIcon", "kind": "Variable" }, - { "name": "GridFilterMenuItem", "kind": "Variable" }, + { "name": "GridFilterMenuItem", "kind": "Function" }, { "name": "GridFilterModel", "kind": "Interface" }, { "name": "gridFilterModelSelector", "kind": "Variable" }, { "name": "GridFilterOperator", "kind": "Interface" }, @@ -312,7 +312,7 @@ { "name": "GridLoadingOverlay", "kind": "Variable" }, { "name": "GridLocaleText", "kind": "Interface" }, { "name": "GridLocaleTextApi", "kind": "Interface" }, - { "name": "GridMenu", "kind": "Variable" }, + { "name": "GridMenu", "kind": "Function" }, { "name": "GridMenuIcon", "kind": "Variable" }, { "name": "GridMenuParams", "kind": "Interface" }, { "name": "GridMenuProps", "kind": "Interface" }, @@ -359,7 +359,7 @@ { "name": "GridPreferencesPanelApi", "kind": "Interface" }, { "name": "GridPreProcessEditCellProps", "kind": "Interface" }, { "name": "GridPrintExportApi", "kind": "Interface" }, - { "name": "GridPrintExportMenuItem", "kind": "Variable" }, + { "name": "GridPrintExportMenuItem", "kind": "Function" }, { "name": "GridPrintExportMenuItemProps", "kind": "TypeAlias" }, { "name": "GridPrintExportOptions", "kind": "Interface" }, { "name": "gridQuickFilterValuesSelector", "kind": "Variable" }, @@ -482,7 +482,7 @@ { "name": "gridTotalHeaderHeightSelector", "kind": "Variable" }, { "name": "GridTranslationKeys", "kind": "TypeAlias" }, { "name": "GridTreeBasicNode", "kind": "Interface" }, - { "name": "GridTreeDataGroupingCell", "kind": "Variable" }, + { "name": "GridTreeDataGroupingCell", "kind": "Function" }, { "name": "GridTreeNode", "kind": "TypeAlias" }, { "name": "GridTreeNodeWithRender", "kind": "TypeAlias" }, { "name": "GridTripleDotsVerticalIcon", "kind": "Variable" }, @@ -506,7 +506,7 @@ { "name": "gridVisibleSortedTopLevelRowEntriesSelector", "kind": "Variable" }, { "name": "gridVisibleTopLevelRowCountSelector", "kind": "Variable" }, { "name": "heIL", "kind": "Variable" }, - { "name": "HideGridColMenuItem", "kind": "Variable" }, + { "name": "HideGridColMenuItem", "kind": "Function" }, { "name": "huHU", "kind": "Variable" }, { "name": "isLeaf", "kind": "Function" }, { "name": "itIT", "kind": "Variable" }, @@ -533,7 +533,7 @@ { "name": "selectedGridRowsSelector", "kind": "Variable" }, { "name": "selectedIdsLookupSelector", "kind": "Variable" }, { "name": "skSK", "kind": "Variable" }, - { "name": "SortGridMenuItems", "kind": "Variable" }, + { "name": "SortGridMenuItems", "kind": "Function" }, { "name": "SUBMIT_FILTER_DATE_STROKE_TIME", "kind": "Variable" }, { "name": "SUBMIT_FILTER_STROKE_TIME", "kind": "Variable" }, { "name": "svSE", "kind": "Variable" }, diff --git a/scripts/x-data-grid.exports.json b/scripts/x-data-grid.exports.json index 62e22f3a756fa..d1f2fb2b56c85 100644 --- a/scripts/x-data-grid.exports.json +++ b/scripts/x-data-grid.exports.json @@ -55,7 +55,7 @@ { "name": "GRID_ROOT_GROUP_ID", "kind": "Variable" }, { "name": "GRID_SINGLE_SELECT_COL_DEF", "kind": "Variable" }, { "name": "GRID_STRING_COL_DEF", "kind": "Variable" }, - { "name": "GridActionsCell", "kind": "Variable" }, + { "name": "GridActionsCell", "kind": "Function" }, { "name": "GridActionsCellItem", "kind": "Variable" }, { "name": "GridActionsCellItemProps", "kind": "TypeAlias" }, { "name": "GridActionsColDef", "kind": "Interface" }, @@ -151,7 +151,7 @@ { "name": "GridColumns", "kind": "TypeAlias" }, { "name": "GridColumnsGroupingState", "kind": "Interface" }, { "name": "GridColumnsInitialState", "kind": "Interface" }, - { "name": "GridColumnsMenuItem", "kind": "Variable" }, + { "name": "GridColumnsMenuItem", "kind": "Function" }, { "name": "GridColumnsMeta", "kind": "Interface" }, { "name": "gridColumnsMetaSelector", "kind": "Variable" }, { "name": "GridColumnsPanel", "kind": "Function" }, @@ -162,12 +162,12 @@ { "name": "GridColumnVisibilityModel", "kind": "TypeAlias" }, { "name": "gridColumnVisibilityModelSelector", "kind": "Variable" }, { "name": "GridComparatorFn", "kind": "TypeAlias" }, - { "name": "GridContextProvider", "kind": "Variable" }, + { "name": "GridContextProvider", "kind": "Function" }, { "name": "GridControlledStateEventLookup", "kind": "Interface" }, { "name": "GridControlledStateReasonLookup", "kind": "Interface" }, { "name": "GridCoreApi", "kind": "Interface" }, { "name": "GridCsvExportApi", "kind": "Interface" }, - { "name": "GridCsvExportMenuItem", "kind": "Variable" }, + { "name": "GridCsvExportMenuItem", "kind": "Function" }, { "name": "GridCsvExportMenuItemProps", "kind": "TypeAlias" }, { "name": "GridCsvExportOptions", "kind": "Interface" }, { "name": "GridCsvGetRowsToExportParams", "kind": "Interface" }, @@ -252,7 +252,7 @@ { "name": "GridFilterItem", "kind": "Interface" }, { "name": "GridFilterItemProps", "kind": "Interface" }, { "name": "GridFilterListIcon", "kind": "Variable" }, - { "name": "GridFilterMenuItem", "kind": "Variable" }, + { "name": "GridFilterMenuItem", "kind": "Function" }, { "name": "GridFilterModel", "kind": "Interface" }, { "name": "gridFilterModelSelector", "kind": "Variable" }, { "name": "GridFilterOperator", "kind": "Interface" }, @@ -288,7 +288,7 @@ { "name": "GridLoadingOverlay", "kind": "Variable" }, { "name": "GridLocaleText", "kind": "Interface" }, { "name": "GridLocaleTextApi", "kind": "Interface" }, - { "name": "GridMenu", "kind": "Variable" }, + { "name": "GridMenu", "kind": "Function" }, { "name": "GridMenuIcon", "kind": "Variable" }, { "name": "GridMenuParams", "kind": "Interface" }, { "name": "GridMenuProps", "kind": "Interface" }, @@ -331,7 +331,7 @@ { "name": "GridPreferencesPanelApi", "kind": "Interface" }, { "name": "GridPreProcessEditCellProps", "kind": "Interface" }, { "name": "GridPrintExportApi", "kind": "Interface" }, - { "name": "GridPrintExportMenuItem", "kind": "Variable" }, + { "name": "GridPrintExportMenuItem", "kind": "Function" }, { "name": "GridPrintExportMenuItemProps", "kind": "TypeAlias" }, { "name": "GridPrintExportOptions", "kind": "Interface" }, { "name": "gridQuickFilterValuesSelector", "kind": "Variable" }, @@ -472,7 +472,7 @@ { "name": "gridVisibleSortedTopLevelRowEntriesSelector", "kind": "Variable" }, { "name": "gridVisibleTopLevelRowCountSelector", "kind": "Variable" }, { "name": "heIL", "kind": "Variable" }, - { "name": "HideGridColMenuItem", "kind": "Variable" }, + { "name": "HideGridColMenuItem", "kind": "Function" }, { "name": "huHU", "kind": "Variable" }, { "name": "isLeaf", "kind": "Function" }, { "name": "itIT", "kind": "Variable" }, @@ -499,7 +499,7 @@ { "name": "selectedGridRowsSelector", "kind": "Variable" }, { "name": "selectedIdsLookupSelector", "kind": "Variable" }, { "name": "skSK", "kind": "Variable" }, - { "name": "SortGridMenuItems", "kind": "Variable" }, + { "name": "SortGridMenuItems", "kind": "Function" }, { "name": "SUBMIT_FILTER_DATE_STROKE_TIME", "kind": "Variable" }, { "name": "SUBMIT_FILTER_STROKE_TIME", "kind": "Variable" }, { "name": "svSE", "kind": "Variable" }, diff --git a/test/e2e/fixtures/DataGrid/NoRowsOverlayWithButton.tsx b/test/e2e/fixtures/DataGrid/NoRowsOverlayWithButton.tsx index 2d662dea40e6e..87c543af1f064 100644 --- a/test/e2e/fixtures/DataGrid/NoRowsOverlayWithButton.tsx +++ b/test/e2e/fixtures/DataGrid/NoRowsOverlayWithButton.tsx @@ -3,7 +3,7 @@ import { DataGrid } from '@mui/x-data-grid'; const columns = [{ field: 'brand', width: 100 }]; -const NoRowsOverlay = () => { +function NoRowsOverlay() { const [text, setText] = React.useState('Refresh'); return ( @@ -11,14 +11,12 @@ const NoRowsOverlay = () => { {text} ); -}; +} export default function NoRowsOverlayWithButton() { return ( - -
- -
-
+
+ +
); } diff --git a/test/e2e/fixtures/DataGrid/SelectEditCell.tsx b/test/e2e/fixtures/DataGrid/SelectEditCell.tsx index efb959ee944c4..9b2eaa7162053 100644 --- a/test/e2e/fixtures/DataGrid/SelectEditCell.tsx +++ b/test/e2e/fixtures/DataGrid/SelectEditCell.tsx @@ -3,7 +3,7 @@ import Select from '@mui/material/Select'; import MenuItem from '@mui/material/MenuItem'; import { DataGrid, GridRenderEditCellParams, useGridApiContext } from '@mui/x-data-grid'; -const SelectEditInputCell = (props: GridRenderEditCellParams) => { +function SelectEditInputCell(props: GridRenderEditCellParams) { const { id, value, field } = props; const apiRef = useGridApiContext(); @@ -20,7 +20,7 @@ const SelectEditInputCell = (props: GridRenderEditCellParams) => { Gucci ); -}; +} function renderSelectEditInputCell(params) { return ; diff --git a/test/utils/pickers-utils.tsx b/test/utils/pickers-utils.tsx index 992bfa46d7061..d6f2781913c52 100644 --- a/test/utils/pickers-utils.tsx +++ b/test/utils/pickers-utils.tsx @@ -172,7 +172,7 @@ export const withPickerControls = Component: React.ComponentType, ) => >(defaultProps: DefaultProps) => { - return ( + return function WithPickerControls( props: Omit< Props, 'value' | 'onChange' | Exclude @@ -182,7 +182,7 @@ export const withPickerControls = value?: TValue; onChange?: any; }, - ) => { + ) { const { initialValue, value: inValue, onChange, ...other } = props; const [value, setValue] = useControlled({