From ee2c2d8abeaaeef7f0619385acae8d6b6dab5685 Mon Sep 17 00:00:00 2001 From: Danail H Date: Thu, 8 Sep 2022 11:41:27 +0300 Subject: [PATCH] Remove GridFeatureMode alias --- .../src/DataGridPro/useDataGridProProps.ts | 3 +-- .../infiniteLoader/useGridInfiniteLoader.ts | 3 +-- .../hooks/features/lazyLoader/useGridLazyLoader.ts | 3 +-- .../lazyLoader/useGridLazyLoaderPreProcessors.tsx | 4 ++-- .../x-data-grid/src/DataGrid/useDataGridProps.ts | 14 ++++---------- .../src/hooks/features/filter/useGridFilter.tsx | 7 ++----- .../src/hooks/features/sorting/useGridSorting.ts | 3 +-- .../grid/x-data-grid/src/models/gridFeatureMode.ts | 4 ---- scripts/x-data-grid-premium.exports.json | 1 - scripts/x-data-grid-pro.exports.json | 1 - scripts/x-data-grid.exports.json | 1 - 11 files changed, 12 insertions(+), 32 deletions(-) diff --git a/packages/grid/x-data-grid-pro/src/DataGridPro/useDataGridProProps.ts b/packages/grid/x-data-grid-pro/src/DataGridPro/useDataGridProProps.ts index f9a4a27c739e4..7e4c954c34cc7 100644 --- a/packages/grid/x-data-grid-pro/src/DataGridPro/useDataGridProProps.ts +++ b/packages/grid/x-data-grid-pro/src/DataGridPro/useDataGridProProps.ts @@ -6,7 +6,6 @@ import { GridSlotsComponent, DATA_GRID_PROPS_DEFAULT_VALUES, GridValidRowModel, - GridFeatureModeConstant, } from '@mui/x-data-grid'; import { DataGridProProps, @@ -26,7 +25,7 @@ export const DATA_GRID_PRO_PROPS_DEFAULT_VALUES: DataGridProPropsWithDefaultValu disableChildrenFiltering: false, disableChildrenSorting: false, rowReordering: false, - rowsLoadingMode: GridFeatureModeConstant.client, + rowsLoadingMode: 'client', getDetailPanelHeight: () => 500, }; diff --git a/packages/grid/x-data-grid-pro/src/hooks/features/infiniteLoader/useGridInfiniteLoader.ts b/packages/grid/x-data-grid-pro/src/hooks/features/infiniteLoader/useGridInfiniteLoader.ts index a0e82095c177b..cea0d151cc14d 100644 --- a/packages/grid/x-data-grid-pro/src/hooks/features/infiniteLoader/useGridInfiniteLoader.ts +++ b/packages/grid/x-data-grid-pro/src/hooks/features/infiniteLoader/useGridInfiniteLoader.ts @@ -7,7 +7,6 @@ import { useGridApiOptionHandler, gridVisibleColumnDefinitionsSelector, gridRowsMetaSelector, - GridFeatureModeConstant, } from '@mui/x-data-grid'; import { useGridVisibleRows } from '@mui/x-data-grid/internals'; import { GridRowScrollEndParams } from '../../../models'; @@ -38,7 +37,7 @@ export const useGridInfiniteLoader = ( const dimensions = apiRef.current.getRootDimensions(); // Prevent the infite loading working in combination with lazy loading - if (!dimensions || props.rowsLoadingMode !== GridFeatureModeConstant.client) { + if (!dimensions || props.rowsLoadingMode !== 'client') { return; } diff --git a/packages/grid/x-data-grid-pro/src/hooks/features/lazyLoader/useGridLazyLoader.ts b/packages/grid/x-data-grid-pro/src/hooks/features/lazyLoader/useGridLazyLoader.ts index 6321ae6ecb974..5949dd89af972 100644 --- a/packages/grid/x-data-grid-pro/src/hooks/features/lazyLoader/useGridLazyLoader.ts +++ b/packages/grid/x-data-grid-pro/src/hooks/features/lazyLoader/useGridLazyLoader.ts @@ -1,7 +1,6 @@ import * as React from 'react'; import { useGridApiEventHandler, - GridFeatureModeConstant, GridRenderedRowsIntervalChangeParams, useGridSelector, gridSortModelSelector, @@ -67,7 +66,7 @@ function isLazyLoadingDisabled({ return true; } - if (rowsLoadingMode !== GridFeatureModeConstant.server) { + if (rowsLoadingMode !== 'server') { return true; } diff --git a/packages/grid/x-data-grid-pro/src/hooks/features/lazyLoader/useGridLazyLoaderPreProcessors.tsx b/packages/grid/x-data-grid-pro/src/hooks/features/lazyLoader/useGridLazyLoaderPreProcessors.tsx index dcb4025f88bd0..bfc9826c73645 100644 --- a/packages/grid/x-data-grid-pro/src/hooks/features/lazyLoader/useGridLazyLoaderPreProcessors.tsx +++ b/packages/grid/x-data-grid-pro/src/hooks/features/lazyLoader/useGridLazyLoaderPreProcessors.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import { GridPipeProcessor, useGridRegisterPipeProcessor } from '@mui/x-data-grid/internals'; -import { GridFeatureModeConstant, GridRowId } from '@mui/x-data-grid'; +import { GridRowId } from '@mui/x-data-grid'; import { DataGridProProcessedProps, GridExperimentalProFeatures, @@ -21,7 +21,7 @@ export const useGridLazyLoaderPreProcessors = ( (groupingParams) => { if ( !lazyLoading || - props.rowsLoadingMode !== GridFeatureModeConstant.server || + props.rowsLoadingMode !== 'server' || !props.rowCount || groupingParams.ids.length >= props.rowCount ) { diff --git a/packages/grid/x-data-grid/src/DataGrid/useDataGridProps.ts b/packages/grid/x-data-grid/src/DataGrid/useDataGridProps.ts index 339e3ffe630c5..a0b7988a66ade 100644 --- a/packages/grid/x-data-grid/src/DataGrid/useDataGridProps.ts +++ b/packages/grid/x-data-grid/src/DataGrid/useDataGridProps.ts @@ -7,13 +7,7 @@ import { DataGridPropsWithDefaultValues, } from '../models/props/DataGridProps'; import { DATA_GRID_DEFAULT_SLOTS_COMPONENTS, GRID_DEFAULT_LOCALE_TEXT } from '../constants'; -import { - GridDensityTypes, - GridEditModes, - GridFeatureModeConstant, - GridSlotsComponent, - GridValidRowModel, -} from '../models'; +import { GridDensityTypes, GridEditModes, GridSlotsComponent, GridValidRowModel } from '../models'; const DATA_GRID_FORCED_PROPS: { [key in DataGridForcedPropsKey]?: DataGridProcessedProps[key] } = { apiRef: undefined, @@ -56,7 +50,7 @@ export const DATA_GRID_PROPS_DEFAULT_VALUES: DataGridPropsWithDefaultValues = { disableVirtualization: false, disableIgnoreModificationsIfProcessingProps: false, editMode: GridEditModes.Cell, - filterMode: GridFeatureModeConstant.client, + filterMode: 'client', headerHeight: 56, hideFooter: false, hideFooterPagination: false, @@ -65,14 +59,14 @@ export const DATA_GRID_PROPS_DEFAULT_VALUES: DataGridPropsWithDefaultValues = { logger: console, logLevel: process.env.NODE_ENV === 'production' ? ('error' as const) : ('warn' as const), pagination: false, - paginationMode: GridFeatureModeConstant.client, + paginationMode: 'client', rowHeight: 52, rowsPerPageOptions: [25, 50, 100], rowSpacingType: 'margin', showCellRightBorder: false, showColumnRightBorder: false, sortingOrder: ['asc' as const, 'desc' as const, null], - sortingMode: GridFeatureModeConstant.client, + sortingMode: 'client', throttleRowsMs: 0, disableColumnReorder: false, disableColumnResize: false, diff --git a/packages/grid/x-data-grid/src/hooks/features/filter/useGridFilter.tsx b/packages/grid/x-data-grid/src/hooks/features/filter/useGridFilter.tsx index 690f67c831733..f89da6471c844 100644 --- a/packages/grid/x-data-grid/src/hooks/features/filter/useGridFilter.tsx +++ b/packages/grid/x-data-grid/src/hooks/features/filter/useGridFilter.tsx @@ -3,7 +3,6 @@ import { GridEventListener } from '../../../models/events'; import { DataGridProcessedProps } from '../../../models/props/DataGridProps'; import { GridApiCommunity } from '../../../models/api/gridApiCommunity'; import { GridFilterApi } from '../../../models/api/gridFilterApi'; -import { GridFeatureModeConstant } from '../../../models/gridFeatureMode'; import { GridFilterItem } from '../../../models/gridFilterItem'; import { GridRowId, GridRowModel } from '../../../models/gridRows'; import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler'; @@ -79,9 +78,7 @@ export const useGridFilter = ( apiRef.current.setState((state) => { const filterModel = gridFilterModelSelector(state, apiRef.current.instanceId); const isRowMatchingFilters = - props.filterMode === GridFeatureModeConstant.client - ? buildAggregatedFilterApplier(filterModel, apiRef) - : null; + props.filterMode === 'client' ? buildAggregatedFilterApplier(filterModel, apiRef) : null; const filteringResult = apiRef.current.unstable_applyStrategyProcessor('filtering', { isRowMatchingFilters, @@ -344,7 +341,7 @@ export const useGridFilter = ( const flatFilteringMethod = React.useCallback>( (params) => { - if (props.filterMode === GridFeatureModeConstant.client && params.isRowMatchingFilters) { + if (props.filterMode === 'client' && params.isRowMatchingFilters) { const rowIds = gridRowIdsSelector(apiRef); const filteredRowsLookup: Record = {}; for (let i = 0; i < rowIds.length; i += 1) { diff --git a/packages/grid/x-data-grid/src/hooks/features/sorting/useGridSorting.ts b/packages/grid/x-data-grid/src/hooks/features/sorting/useGridSorting.ts index e76a0b41abb1f..79e7a27469fd5 100644 --- a/packages/grid/x-data-grid/src/hooks/features/sorting/useGridSorting.ts +++ b/packages/grid/x-data-grid/src/hooks/features/sorting/useGridSorting.ts @@ -4,7 +4,6 @@ import { DataGridProcessedProps } from '../../../models/props/DataGridProps'; import { GridApiCommunity } from '../../../models/api/gridApiCommunity'; import { GridSortApi } from '../../../models/api/gridSortApi'; import { GridColDef } from '../../../models/colDef/gridColDef'; -import { GridFeatureModeConstant } from '../../../models/gridFeatureMode'; import { GridRowId, GridRowTreeNodeConfig } from '../../../models/gridRows'; import { GridSortItem, GridSortModel, GridSortDirection } from '../../../models/gridSortModel'; import { isEnterKey } from '../../../utils/keyboardUtils'; @@ -121,7 +120,7 @@ export const useGridSorting = ( */ const applySorting = React.useCallback(() => { apiRef.current.setState((state) => { - if (props.sortingMode === GridFeatureModeConstant.server) { + if (props.sortingMode === 'server') { logger.debug('Skipping sorting rows as sortingMode = server'); return { ...state, diff --git a/packages/grid/x-data-grid/src/models/gridFeatureMode.ts b/packages/grid/x-data-grid/src/models/gridFeatureMode.ts index 22e70ae84626e..52bb171397431 100644 --- a/packages/grid/x-data-grid/src/models/gridFeatureMode.ts +++ b/packages/grid/x-data-grid/src/models/gridFeatureMode.ts @@ -1,5 +1 @@ -export const GridFeatureModeConstant = { - client: 'client' as 'client', - server: 'server' as 'server', -}; export type GridFeatureMode = 'client' | 'server'; diff --git a/scripts/x-data-grid-premium.exports.json b/scripts/x-data-grid-premium.exports.json index 6bb83c837918e..1bca424315e65 100644 --- a/scripts/x-data-grid-premium.exports.json +++ b/scripts/x-data-grid-premium.exports.json @@ -264,7 +264,6 @@ { "name": "GridExportOptions", "kind": "Interface" }, { "name": "GridExportStateParams", "kind": "Interface" }, { "name": "GridFeatureMode", "kind": "TypeAlias" }, - { "name": "GridFeatureModeConstant", "kind": "Variable" }, { "name": "GridFetchRowsParams", "kind": "Interface" }, { "name": "GridFileExportOptions", "kind": "Interface" }, { "name": "gridFilterableColumnDefinitionsSelector", "kind": "Variable" }, diff --git a/scripts/x-data-grid-pro.exports.json b/scripts/x-data-grid-pro.exports.json index db8050c65627d..4e2683d2515b4 100644 --- a/scripts/x-data-grid-pro.exports.json +++ b/scripts/x-data-grid-pro.exports.json @@ -238,7 +238,6 @@ { "name": "GridExportOptions", "kind": "Interface" }, { "name": "GridExportStateParams", "kind": "Interface" }, { "name": "GridFeatureMode", "kind": "TypeAlias" }, - { "name": "GridFeatureModeConstant", "kind": "Variable" }, { "name": "GridFetchRowsParams", "kind": "Interface" }, { "name": "GridFileExportOptions", "kind": "Interface" }, { "name": "gridFilterableColumnDefinitionsSelector", "kind": "Variable" }, diff --git a/scripts/x-data-grid.exports.json b/scripts/x-data-grid.exports.json index 9131314ded99e..7e24c8b04fb80 100644 --- a/scripts/x-data-grid.exports.json +++ b/scripts/x-data-grid.exports.json @@ -217,7 +217,6 @@ { "name": "GridExportOptions", "kind": "Interface" }, { "name": "GridExportStateParams", "kind": "Interface" }, { "name": "GridFeatureMode", "kind": "TypeAlias" }, - { "name": "GridFeatureModeConstant", "kind": "Variable" }, { "name": "GridFileExportOptions", "kind": "Interface" }, { "name": "gridFilterableColumnDefinitionsSelector", "kind": "Variable" }, { "name": "gridFilterableColumnLookupSelector", "kind": "Variable" },