diff --git a/packages/grid/x-data-grid/src/components/cell/GridEditSingleSelectCell.tsx b/packages/grid/x-data-grid/src/components/cell/GridEditSingleSelectCell.tsx index a78afe0dfde9..dc3974643c7f 100644 --- a/packages/grid/x-data-grid/src/components/cell/GridEditSingleSelectCell.tsx +++ b/packages/grid/x-data-grid/src/components/cell/GridEditSingleSelectCell.tsx @@ -137,6 +137,7 @@ function GridEditSingleSelectCell(props: GridRenderEditCellParams & Omit {valueOptionsFormatted.map(renderSingleSelectOptions)} diff --git a/packages/grid/x-data-grid/src/components/panel/GridPanel.tsx b/packages/grid/x-data-grid/src/components/panel/GridPanel.tsx index cf53ad89018a..07cf2a65bd77 100644 --- a/packages/grid/x-data-grid/src/components/panel/GridPanel.tsx +++ b/packages/grid/x-data-grid/src/components/panel/GridPanel.tsx @@ -106,7 +106,7 @@ const GridPanel = React.forwardRef((props, ref) modifiers={modifiers} {...other} > - + {isPlaced && children} diff --git a/packages/grid/x-data-grid/src/components/panel/filterPanel/GridFilterForm.tsx b/packages/grid/x-data-grid/src/components/panel/filterPanel/GridFilterForm.tsx index c98cf21a6a98..1436ee22e1cc 100644 --- a/packages/grid/x-data-grid/src/components/panel/filterPanel/GridFilterForm.tsx +++ b/packages/grid/x-data-grid/src/components/panel/filterPanel/GridFilterForm.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import PropTypes from 'prop-types'; -import { unstable_composeClasses as composeClasses } from '@mui/material'; +import { MenuItem, unstable_composeClasses as composeClasses } from '@mui/material'; import IconButton from '@mui/material/IconButton'; import InputLabel from '@mui/material/InputLabel'; import FormControl from '@mui/material/FormControl'; @@ -152,6 +152,9 @@ function GridFilterForm(props: GridFilterFormProps) { const baseFormControlProps = rootProps.componentsProps?.baseFormControl || {}; + const baseSelectProps = rootProps.componentsProps?.baseSelect || {}; + const isBaseSelectNative = baseSelectProps.native ?? true; + const sortedFilterableColumns = React.useMemo(() => { switch (columnsSort) { case 'asc': @@ -314,14 +317,20 @@ function GridFilterForm(props: GridFilterFormProps) { value={multiFilterOperator} onChange={changeLinkOperator} disabled={!!disableMultiFilterOperator || linkOperators.length === 1} - native + native={isBaseSelectNative} {...rootProps.componentsProps?.baseSelect} > - {linkOperators.map((linkOperator) => ( - - ))} + {linkOperators.map((linkOperator) => + isBaseSelectNative ? ( + + ) : ( + + {apiRef.current.getLocaleText(getLinkOperatorLocaleKey(linkOperator))} + + ), + )} - {sortedFilterableColumns.map((col) => ( - - ))} + {sortedFilterableColumns.map((col) => + isBaseSelectNative ? ( + + ) : ( + + {getColumnLabel(col)} + + ), + )} - {currentColumn?.filterOperators?.map((operator) => ( - - ))} + {currentColumn?.filterOperators?.map((operator) => + isBaseSelectNative ? ( + + ) : ( + + {operator.label || + apiRef.current.getLocaleText( + `filterOperator${capitalize(operator.value)}` as GridTranslationKeys, + )} + + ), + )} { const value = event.target.value; @@ -21,6 +25,32 @@ export function GridFilterInputBoolean(props: GridFilterInputValueProps & TextFi setFilterValueState(item.value || ''); }, [item.value]); + if (isSelectNative) { + return ( + + + + + + ); + } + return ( - - - + {apiRef.current.getLocaleText('filterValueAny')} + {apiRef.current.getLocaleText('filterValueTrue')} + {apiRef.current.getLocaleText('filterValueFalse')} ); } diff --git a/packages/grid/x-data-grid/src/components/panel/filterPanel/GridFilterInputSingleSelect.tsx b/packages/grid/x-data-grid/src/components/panel/filterPanel/GridFilterInputSingleSelect.tsx index 5696f5d24eef..f9bbebe5f721 100644 --- a/packages/grid/x-data-grid/src/components/panel/filterPanel/GridFilterInputSingleSelect.tsx +++ b/packages/grid/x-data-grid/src/components/panel/filterPanel/GridFilterInputSingleSelect.tsx @@ -2,6 +2,7 @@ import * as React from 'react'; import PropTypes from 'prop-types'; import { TextFieldProps } from '@mui/material/TextField'; import { unstable_useId as useId } from '@mui/material/utils'; +import { MenuItem } from '@mui/material'; import { GridFilterInputValueProps } from './GridFilterInputValueProps'; import { GridColDef } from '../../../models/colDef/gridColDef'; import { GridApiCommunity } from '../../../models/api/gridApiCommunity'; @@ -11,23 +12,33 @@ import { getValueFromValueOptions } from './filterPanelUtils'; const renderSingleSelectOptions = ( { valueOptions, valueFormatter, field }: GridColDef, api: GridApiCommunity, + isSelectNative: boolean, ) => { const iterableColumnValues = typeof valueOptions === 'function' ? ['', ...valueOptions({ field })] : ['', ...(valueOptions || [])]; - return iterableColumnValues.map((option) => - typeof option === 'object' ? ( - ) : ( - - ), - ); + + {content} + + ); + }); }; export type GridFilterInputSingleSelectProps = GridFilterInputValueProps & @@ -39,6 +50,9 @@ function GridFilterInputSingleSelect(props: GridFilterInputSingleSelectProps) { const id = useId(); const rootProps = useGridRootProps(); + const baseSelectProps = rootProps.componentsProps?.baseSelect || {}; + const isSelectNative = baseSelectProps.native ?? true; + const currentColumn = item.columnField ? apiRef.current.getColumn(item.columnField) : null; const currentValueOptions = React.useMemo(() => { @@ -94,12 +108,17 @@ function GridFilterInputSingleSelect(props: GridFilterInputSingleSelectProps) { inputRef={focusElementRef} select SelectProps={{ - native: true, + native: isSelectNative, + ...rootProps.componentsProps?.baseSelect, }} {...others} {...rootProps.componentsProps?.baseTextField} > - {renderSingleSelectOptions(apiRef.current.getColumn(item.columnField), apiRef.current)} + {renderSingleSelectOptions( + apiRef.current.getColumn(item.columnField), + apiRef.current, + isSelectNative, + )} ); } diff --git a/packages/grid/x-data-grid/src/components/panel/filterPanel/GridFilterInputValue.tsx b/packages/grid/x-data-grid/src/components/panel/filterPanel/GridFilterInputValue.tsx index 6477e43d9d41..efcb4f4196df 100644 --- a/packages/grid/x-data-grid/src/components/panel/filterPanel/GridFilterInputValue.tsx +++ b/packages/grid/x-data-grid/src/components/panel/filterPanel/GridFilterInputValue.tsx @@ -2,6 +2,7 @@ import * as React from 'react'; import PropTypes from 'prop-types'; import { TextFieldProps } from '@mui/material/TextField'; import { unstable_useId as useId } from '@mui/material/utils'; +import { MenuItem } from '@mui/material'; import { GridLoadIcon } from '../../icons'; import { GridFilterInputValueProps } from './GridFilterInputValueProps'; import { GridColDef } from '../../../models/colDef/gridColDef'; @@ -24,23 +25,33 @@ function warnDeprecatedTypeSupport(type: string) { const renderSingleSelectOptions = ( { valueOptions, valueFormatter, field }: GridColDef, api: GridApiCommunity, + isSelectNative: boolean, ) => { const iterableColumnValues = typeof valueOptions === 'function' ? ['', ...valueOptions({ field })] : ['', ...(valueOptions || [])]; - return iterableColumnValues.map((option) => - typeof option === 'object' ? ( - ) : ( - - ), - ); + + {content} + + ); + }); }; export const SUBMIT_FILTER_STROKE_TIME = 500; @@ -63,16 +74,21 @@ function GridFilterInputValue(props: GridTypeFilterInputValueProps & TextFieldPr const [applying, setIsApplying] = React.useState(false); const id = useId(); const rootProps = useGridRootProps(); + + const baseSelectProps = rootProps.componentsProps?.baseSelect || {}; + const isSelectNative = baseSelectProps.native ?? true; + const singleSelectProps: TextFieldProps = type === 'singleSelect' ? { select: true, SelectProps: { - native: true, + ...rootProps.componentsProps?.baseSelect, }, children: renderSingleSelectOptions( apiRef.current.getColumn(item.columnField), apiRef.current, + isSelectNative, ), } : {};