From 86d6e2a6660abc8aa8bbaa0f766aafd09ff3c8f7 Mon Sep 17 00:00:00 2001 From: Rom Grk Date: Tue, 7 Jan 2025 17:39:23 -0500 Subject: [PATCH] [DataGrid] Refactor: create tooltip props (#16086) --- .../x-data-grid/src/models/gridBaseSlots.ts | 6 ++++++ .../src/models/gridSlotsComponentsProps.ts | 21 ++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/packages/x-data-grid/src/models/gridBaseSlots.ts b/packages/x-data-grid/src/models/gridBaseSlots.ts index 0fd571d9c0ab9..58175695e28eb 100644 --- a/packages/x-data-grid/src/models/gridBaseSlots.ts +++ b/packages/x-data-grid/src/models/gridBaseSlots.ts @@ -66,3 +66,9 @@ export type SkeletonProps = { width?: number | string; height?: number | string; }; + +export type TooltipProps = { + children: React.ReactElement; + enterDelay?: number; + title: React.ReactNode; +}; diff --git a/packages/x-data-grid/src/models/gridSlotsComponentsProps.ts b/packages/x-data-grid/src/models/gridSlotsComponentsProps.ts index 661671952075d..83ae4d9e924ff 100644 --- a/packages/x-data-grid/src/models/gridSlotsComponentsProps.ts +++ b/packages/x-data-grid/src/models/gridSlotsComponentsProps.ts @@ -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'; @@ -44,6 +44,7 @@ import type { LinearProgressProps, MenuItemProps, SkeletonProps, + TooltipProps, } from './gridBaseSlots'; type RootProps = React.HTMLAttributes & Record<`data-${string}`, string>; @@ -125,6 +126,7 @@ interface MaterialSlotProps { baseLinearProgress: MUILinearProgressProps; baseCircularProgress: MUICircularProgressProps; baseMenuItem: MUIMenuItemProps; + baseTooltip: MUITooltipProps; } interface ElementSlotProps { @@ -160,14 +162,17 @@ interface ElementSlotProps { } // Merge MUI types into base types to keep slotProps working. +type Select = K extends keyof A ? A[K] : K extends keyof B ? B[K] : never; type Merge = { - [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 + : 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 & ElementSlotProps;