Skip to content

Commit

Permalink
[DataGrid] Refactor: create base Switch (#16527)
Browse files Browse the repository at this point in the history
  • Loading branch information
romgrk authored Feb 14, 2025
1 parent 510a56e commit a7de08f
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 1 deletion.
6 changes: 6 additions & 0 deletions docs/pages/x/api/data-grid/data-grid-premium.json
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,12 @@
"default": "Skeleton",
"class": null
},
{
"name": "baseSwitch",
"description": "The custom Switch component used in the grid.",
"default": "Switch",
"class": null
},
{
"name": "booleanCellTrueIcon",
"description": "Icon displayed on the boolean cell to represent the true value.",
Expand Down
6 changes: 6 additions & 0 deletions docs/pages/x/api/data-grid/data-grid-pro.json
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,12 @@
"default": "Skeleton",
"class": null
},
{
"name": "baseSwitch",
"description": "The custom Switch component used in the grid.",
"default": "Switch",
"class": null
},
{
"name": "booleanCellTrueIcon",
"description": "Icon displayed on the boolean cell to represent the true value.",
Expand Down
6 changes: 6 additions & 0 deletions docs/pages/x/api/data-grid/data-grid.json
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,12 @@
"default": "Skeleton",
"class": null
},
{
"name": "baseSwitch",
"description": "The custom Switch component used in the grid.",
"default": "Switch",
"class": null
},
{
"name": "booleanCellTrueIcon",
"description": "Icon displayed on the boolean cell to represent the true value.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,7 @@
"baseSelect": "The custom Select component used in the grid.",
"baseSelectOption": "The custom SelectOption component used in the grid.",
"baseSkeleton": "The custom Skeleton component used in the grid.",
"baseSwitch": "The custom Switch component used in the grid.",
"baseTextField": "The custom TextField component used in the grid.",
"baseTooltip": "The custom Tooltip component used in the grid.",
"booleanCellFalseIcon": "Icon displayed on the boolean cell to represent the false value.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1235,6 +1235,7 @@
"baseSelect": "The custom Select component used in the grid.",
"baseSelectOption": "The custom SelectOption component used in the grid.",
"baseSkeleton": "The custom Skeleton component used in the grid.",
"baseSwitch": "The custom Switch component used in the grid.",
"baseTextField": "The custom TextField component used in the grid.",
"baseTooltip": "The custom Tooltip component used in the grid.",
"booleanCellFalseIcon": "Icon displayed on the boolean cell to represent the false value.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,7 @@
"baseSelect": "The custom Select component used in the grid.",
"baseSelectOption": "The custom SelectOption component used in the grid.",
"baseSkeleton": "The custom Skeleton component used in the grid.",
"baseSwitch": "The custom Switch component used in the grid.",
"baseTextField": "The custom TextField component used in the grid.",
"baseTooltip": "The custom Tooltip component used in the grid.",
"booleanCellFalseIcon": "Icon displayed on the boolean cell to represent the false value.",
Expand Down
2 changes: 2 additions & 0 deletions packages/x-data-grid/src/material/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import MUITextField from '@mui/material/TextField';
import MUIFormControl from '@mui/material/FormControl';
import MUIFormControlLabel from '@mui/material/FormControlLabel';
import MUISelect from '@mui/material/Select';
import MUISwitch from '@mui/material/Switch';
import MUIButton from '@mui/material/Button';
import MUIIconButton from '@mui/material/IconButton';
import MUIInputAdornment from '@mui/material/InputAdornment';
Expand Down Expand Up @@ -180,6 +181,7 @@ const baseSlots: GridBaseSlots = {
baseSelect: BaseSelect,
baseSelectOption: BaseSelectOption,
baseSkeleton: MUISkeleton,
baseSwitch: MUISwitch,
baseChip: MUIChip,
};

Expand Down
6 changes: 6 additions & 0 deletions packages/x-data-grid/src/models/gridBaseSlots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ export type SkeletonProps = {
height?: number | string;
};

export type SwitchProps = {
checked?: boolean;
onChange?: React.ChangeEventHandler;
size?: 'small' | 'medium';
};

export type TextFieldProps = {
autoComplete?: string;
className?: string;
Expand Down
5 changes: 5 additions & 0 deletions packages/x-data-grid/src/models/gridSlotsComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ export interface GridBaseSlots {
* @default Skeleton
*/
baseSkeleton: React.JSXElementConstructor<GridSlotProps['baseSkeleton']>;
/**
* The custom Switch component used in the grid.
* @default Switch
*/
baseSwitch: React.JSXElementConstructor<GridSlotProps['baseSwitch']>;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type { CircularProgressProps as MUICircularProgressProps } from '@mui/mat
import type { LinearProgressProps as MUILinearProgressProps } from '@mui/material/LinearProgress';
import type { MenuItemProps as MUIMenuItemProps } from '@mui/material/MenuItem';
import type { FormControlProps } from '@mui/material/FormControl';
import type { SwitchProps } from '@mui/material/Switch';
import type { IconButtonProps as MUIIconButtonProps } from '@mui/material/IconButton';
import type { InputAdornmentProps } from '@mui/material/InputAdornment';
import type { TooltipProps as MUITooltipProps } from '@mui/material/Tooltip';
Expand Down Expand Up @@ -45,6 +44,7 @@ import type {
SelectProps,
SelectOptionProps,
SkeletonProps,
SwitchProps,
TooltipProps,
TextFieldProps,
} from './gridBaseSlots';
Expand Down

0 comments on commit a7de08f

Please sign in to comment.