Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Remove GridFeatureModeConstant #6077

Merged
merged 4 commits into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
GridSlotsComponent,
DATA_GRID_PROPS_DEFAULT_VALUES,
GridValidRowModel,
GridFeatureModeConstant,
} from '@mui/x-data-grid';
import {
DataGridProProps,
Expand All @@ -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,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from 'react';
import {
useGridApiEventHandler,
GridFeatureModeConstant,
GridRenderedRowsIntervalChangeParams,
useGridSelector,
gridSortModelSelector,
Expand Down Expand Up @@ -77,7 +76,7 @@ function isLazyLoadingDisabled({
return true;
}

if (rowsLoadingMode !== GridFeatureModeConstant.server) {
if (rowsLoadingMode !== 'server') {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import * as React from 'react';
import { GridPipeProcessor, useGridRegisterPipeProcessor } from '@mui/x-data-grid/internals';
import {
GRID_ROOT_GROUP_ID,
GridFeatureModeConstant,
GridGroupNode,
GridSkeletonRowNode,
} from '@mui/x-data-grid';
import { GRID_ROOT_GROUP_ID, GridGroupNode, GridSkeletonRowNode } from '@mui/x-data-grid';
import { GridApiPro } from '../../../models/gridApiPro';
import {
DataGridProProcessedProps,
Expand All @@ -29,7 +24,7 @@ export const useGridLazyLoaderPreProcessors = (

if (
!lazyLoading ||
props.rowsLoadingMode !== GridFeatureModeConstant.server ||
props.rowsLoadingMode !== 'server' ||
!props.rowCount ||
rootGroup.children.length >= props.rowCount
) {
Expand Down
14 changes: 4 additions & 10 deletions packages/grid/x-data-grid/src/DataGrid/useDataGridProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 { GridGroupNode, GridRowId, GridRowModel } from '../../../models/gridRows';
import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -344,7 +341,7 @@ export const useGridFilter = (

const flatFilteringMethod = React.useCallback<GridStrategyProcessor<'filtering'>>(
(params) => {
if (props.filterMode === GridFeatureModeConstant.client && params.isRowMatchingFilters) {
if (props.filterMode === 'client' && params.isRowMatchingFilters) {
const tree = gridRowTreeSelector(apiRef);
const rowIds = (tree[GRID_ROOT_GROUP_ID] as GridGroupNode).children;
const filteredRowsLookup: Record<GridRowId, boolean> = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 { GridGroupNode } from '../../../models/gridRows';
import { GridSortItem, GridSortModel, GridSortDirection } from '../../../models/gridSortModel';
import { isEnterKey } from '../../../utils/keyboardUtils';
Expand Down Expand Up @@ -122,7 +121,7 @@ export const useGridSorting = (
*/
const applySorting = React.useCallback<GridSortApi['applySorting']>(() => {
apiRef.current.setState((state) => {
if (props.sortingMode === GridFeatureModeConstant.server) {
if (props.sortingMode === 'server') {
logger.debug('Skipping sorting rows as sortingMode = server');
return {
...state,
Expand Down
4 changes: 0 additions & 4 deletions packages/grid/x-data-grid/src/models/gridFeatureMode.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
export const GridFeatureModeConstant = {
client: 'client' as 'client',
server: 'server' as 'server',
};
export type GridFeatureMode = 'client' | 'server';
1 change: 0 additions & 1 deletion scripts/x-data-grid-premium.exports.json
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,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" },
Expand Down
1 change: 0 additions & 1 deletion scripts/x-data-grid-pro.exports.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,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" },
Expand Down
1 change: 0 additions & 1 deletion scripts/x-data-grid.exports.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,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" },
Expand Down