Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion packages/mui-material/src/Accordion/Accordion.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export type AccordionSlotsAndSlotProps = CreateSlotsAndSlotProps<
* By default, the available props are based on the [Collapse](https://mui.com/material-ui/api/collapse/#props) component.
*/
transition: SlotComponentProps<
React.ElementType,
React.ElementType<TransitionProps>,
TransitionProps & AccordionTransitionSlotPropsOverrides,
AccordionOwnerState
>;
Expand Down
10 changes: 10 additions & 0 deletions packages/mui-material/src/Accordion/Accordion.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ function Custom(props: AccordionProps) {
);
}

// slotProps.transition should reject unknown props
<Accordion
slotProps={{
// @ts-expect-error — unknown props should be rejected
transition: { randomInvalidProp: 'test' },
}}
>
<div />
</Accordion>;

function Custom2(props: AccordionProps) {
const { slotProps, ...other } = props;
return (
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-material/src/Backdrop/Backdrop.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export type BackdropSlotsAndSlotProps = CreateSlotsAndSlotProps<
* By default, the available props are based on the [Fade](https://mui.com/material-ui/api/fade/#props) component.
*/
transition: SlotComponentProps<
React.ElementType,
React.ElementType<TransitionProps>,
TransitionProps & BackdropTransitionSlotPropsOverrides,
BackdropOwnerState
>;
Expand Down
10 changes: 10 additions & 0 deletions packages/mui-material/src/Backdrop/Backdrop.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Backdrop from '@mui/material/Backdrop';

// slotProps.transition should reject unknown props
<Backdrop
open
slotProps={{
// @ts-expect-error — unknown props should be rejected
transition: { randomInvalidProp: 'test' },
}}
/>;
2 changes: 1 addition & 1 deletion packages/mui-material/src/Dialog/Dialog.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export type DialogSlotsAndSlotProps = CreateSlotsAndSlotProps<
* By default, the available props are based on the [Fade](https://mui.com/material-ui/api/fade/#props) component.
*/
transition: SlotComponentProps<
React.ElementType,
React.ElementType<TransitionProps>,
TransitionProps & DialogTransitionSlotPropsOverrides,
DialogOwnerState
>;
Expand Down
10 changes: 9 additions & 1 deletion packages/mui-material/src/Dialog/Dialog.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ function Test() {
return (
<React.Fragment>
<Dialog open />;
<Dialog open PaperProps={paperProps} />;
<Dialog open slotProps={{ paper: paperProps }} />;
<Dialog
open
slotProps={{
// @ts-expect-error — unknown props should be rejected
transition: { randomInvalidProp: 'test' },
}}
/>
;
</React.Fragment>
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-material/src/Drawer/Drawer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export type DrawerSlotsAndSlotProps = CreateSlotsAndSlotProps<
* By default, the available props are based on the [Slide](https://mui.com/material-ui/api/slide/#props) component.
*/
transition: SlotProps<
React.ElementType,
React.ElementType<TransitionProps>,
TransitionProps & DrawerTransitionSlotPropsOverrides,
DrawerOwnerState
>;
Expand Down
10 changes: 9 additions & 1 deletion packages/mui-material/src/Drawer/Drawer.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ function Test() {
return (
<React.Fragment>
<Drawer open />;
<Drawer open PaperProps={paperProps} />;
<Drawer open slotProps={{ paper: paperProps }} />;
<Drawer
open
slotProps={{
// @ts-expect-error — unknown props should be rejected
transition: { randomInvalidProp: 'test' },
}}
/>
;
</React.Fragment>
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-material/src/Menu/Menu.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export type MenuSlotsAndSlotProps = CreateSlotsAndSlotProps<
*/
transition: SlotComponentProps<
// use SlotComponentProps because transition slot does not support `component` and `sx` prop
React.ElementType,
React.ElementType<TransitionProps>,
TransitionProps & MenuTransitionSlotPropsOverrides,
MenuOwnerState
>;
Expand Down
9 changes: 9 additions & 0 deletions packages/mui-material/src/Menu/Menu.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import Menu, { MenuProps } from '@mui/material/Menu';

// slotProps.transition should reject unknown props
<Menu
open
slotProps={{
// @ts-expect-error — unknown props should be rejected
transition: { randomInvalidProp: 'test' },
}}
/>;

<Menu
open
slotProps={{
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-material/src/Popover/Popover.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export type PopoverSlotsAndSlotProps = CreateSlotsAndSlotProps<
*/
transition: SlotComponentProps<
// use SlotComponentProps because transition slot does not support `component` and `sx` prop
React.ElementType,
React.ElementType<TransitionProps>,
TransitionProps & PopoverTransitionSlotPropsOverrides,
PopoverOwnerState
>;
Expand Down
10 changes: 9 additions & 1 deletion packages/mui-material/src/Popover/Popover.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ function Test() {
return (
<React.Fragment>
<Popover open />;
<Popover open PaperProps={paperProps} />
<Popover open slotProps={{ paper: paperProps }} />;
<Popover
open
slotProps={{
// @ts-expect-error — unknown props should be rejected
transition: { randomInvalidProp: 'test' },
}}
/>
;
</React.Fragment>
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-material/src/Snackbar/Snackbar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export type SnackbarSlotsAndSlotProps = CreateSlotsAndSlotProps<
* By default, the element is based on the [Grow](https://mui.com/material-ui/api/grow/#props) component.
*/
transition: SlotComponentProps<
React.ElementType,
React.ElementType<TransitionProps>,
TransitionProps & SnackbarTransitionSlotPropsOverrides,
SnackbarOwnerState
>;
Expand Down
8 changes: 8 additions & 0 deletions packages/mui-material/src/Snackbar/Snackbar.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ import { mergeSlotProps } from '@mui/material/utils';
import Snackbar, { SnackbarProps } from '@mui/material/Snackbar';
import { expectType } from '@mui/types';

// slotProps.transition should reject unknown props
<Snackbar
slotProps={{
// @ts-expect-error — unknown props should be rejected
transition: { randomInvalidProp: 'test' },
}}
/>;

<Snackbar
slots={{
root: 'dialog',
Expand Down
6 changes: 5 additions & 1 deletion packages/mui-material/src/SpeedDial/SpeedDial.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ export type SpeedDialSlotsAndSlotProps = CreateSlotsAndSlotProps<
* Props forwarded to the transition slot.
* By default, the available props are based on the [Zoom](https://mui.com/material-ui/api/zoom/#props) component.
*/
transition: SlotComponentProps<React.ElementType, TransitionProps, SpeedDialOwnerState>;
transition: SlotComponentProps<
React.ElementType<TransitionProps>,
TransitionProps,
SpeedDialOwnerState
>;
}
>;

Expand Down
10 changes: 10 additions & 0 deletions packages/mui-material/src/SpeedDial/SpeedDial.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import SpeedDial from '@mui/material/SpeedDial';

// slotProps.transition should reject unknown props
<SpeedDial
ariaLabel="SpeedDial"
slotProps={{
// @ts-expect-error — unknown props should be rejected
transition: { randomInvalidProp: 'test' },
}}
/>;
6 changes: 5 additions & 1 deletion packages/mui-material/src/StepContent/StepContent.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ export type StepContentSlotsAndSlotProps = CreateSlotsAndSlotProps<
* Props forwarded to the transition slot.
* By default, the available props are based on the [Collapse](https://mui.com/material-ui/api/collapse/#props) component
*/
transition: SlotComponentProps<React.ElementType, CollapseProps, StepContentOwnerState>;
transition: SlotComponentProps<
React.ElementType<CollapseProps>,
CollapseProps,
StepContentOwnerState
>;
}
>;

Expand Down
20 changes: 15 additions & 5 deletions packages/mui-material/src/StepContent/StepContent.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,21 @@ import Grow from '@mui/material/Grow';
import Slide from '@mui/material/Slide';
import Zoom from '@mui/material/Zoom';

<StepContent TransitionComponent={Fade}>Step Content</StepContent>;
<StepContent TransitionComponent={Collapse}>Step Content</StepContent>;
<StepContent TransitionComponent={Grow}>Step Content</StepContent>;
<StepContent TransitionComponent={Slide}>Step Content</StepContent>;
<StepContent TransitionComponent={Zoom}>Step Content</StepContent>;
// slotProps.transition should reject unknown props
<StepContent
slotProps={{
// @ts-expect-error — unknown props should be rejected
transition: { randomInvalidProp: 'test' },
}}
>
Step Content
</StepContent>;

<StepContent slots={{ transition: Fade }}>Step Content</StepContent>;
<StepContent slots={{ transition: Collapse }}>Step Content</StepContent>;
<StepContent slots={{ transition: Grow }}>Step Content</StepContent>;
<StepContent slots={{ transition: Slide }}>Step Content</StepContent>;
<StepContent slots={{ transition: Zoom }}>Step Content</StepContent>;

function Custom(props: StepContentProps) {
const { slotProps, ...other } = props;
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-material/src/Tooltip/Tooltip.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export type TooltipSlotsAndSlotProps = CreateSlotsAndSlotProps<
* By default, the available props are based on the [Grow](https://mui.com/material-ui/api/grow/#props) component.
*/
transition: SlotProps<
React.ElementType,
React.ElementType<TransitionProps>,
TransitionProps & TooltipTransitionSlotPropsOverrides,
TooltipOwnerState
>;
Expand Down
11 changes: 11 additions & 0 deletions packages/mui-material/src/Tooltip/Tooltip.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ import { expectType } from '@mui/types';
import { mergeSlotProps } from '@mui/material/utils';
import Tooltip, { TooltipProps } from '@mui/material/Tooltip';

// slotProps.transition should reject unknown props
<Tooltip
title="Hello"
slotProps={{
// @ts-expect-error — unknown props should be rejected
transition: { randomInvalidProp: 'test' },
}}
>
<button type="button">Hover or touch me</button>
</Tooltip>;

<Tooltip title="Hello">
<button type="button">Hover or touch me</button>
</Tooltip>;
Expand Down
Loading