Skip to content

Commit

Permalink
[DataGrid] Refactor: create tooltip props (#16086)
Browse files Browse the repository at this point in the history
  • Loading branch information
romgrk authored Jan 7, 2025
1 parent f1332f1 commit 86d6e2a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
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 @@ -66,3 +66,9 @@ export type SkeletonProps = {
width?: number | string;
height?: number | string;
};

export type TooltipProps = {
children: React.ReactElement<any, any>;
enterDelay?: number;
title: React.ReactNode;
};
21 changes: 13 additions & 8 deletions packages/x-data-grid/src/models/gridSlotsComponentsProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { SelectProps } from '@mui/material/Select';
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 } from '@mui/material/Tooltip';
import type { TooltipProps as MUITooltipProps } from '@mui/material/Tooltip';
import type { InputLabelProps } from '@mui/material/InputLabel';
import type { PopperProps } from '@mui/material/Popper';
import type { TablePaginationProps } from '@mui/material/TablePagination';
Expand Down Expand Up @@ -44,6 +44,7 @@ import type {
LinearProgressProps,
MenuItemProps,
SkeletonProps,
TooltipProps,
} from './gridBaseSlots';

type RootProps = React.HTMLAttributes<HTMLDivElement> & Record<`data-${string}`, string>;
Expand Down Expand Up @@ -125,6 +126,7 @@ interface MaterialSlotProps {
baseLinearProgress: MUILinearProgressProps;
baseCircularProgress: MUICircularProgressProps;
baseMenuItem: MUIMenuItemProps;
baseTooltip: MUITooltipProps;
}

interface ElementSlotProps {
Expand Down Expand Up @@ -160,14 +162,17 @@ interface ElementSlotProps {
}

// Merge MUI types into base types to keep slotProps working.
type Select<A, B, K> = K extends keyof A ? A[K] : K extends keyof B ? B[K] : never;
type Merge<A, B> = {
[K in keyof A | keyof B]: K extends keyof A & keyof B
? A[K] & B[K]
: K extends keyof B
? B[K]
: K extends keyof A
? A[K]
: never;
[K in keyof A | keyof B]: K extends 'ref'
? Select<A, B, 'ref'>
: K extends keyof A & keyof B
? A[K] & B[K]
: K extends keyof B
? B[K]
: K extends keyof A
? A[K]
: never;
};
export type GridSlotProps = Merge<BaseSlotProps, MaterialSlotProps> & ElementSlotProps;

Expand Down

0 comments on commit 86d6e2a

Please sign in to comment.