-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[material-ui][Dialog] Add slots and slotProps #44792
Changes from 28 commits
454319b
7132318
435948a
8f1a0ee
3a81578
db4bea2
8d2d1cb
9c57580
f6fc3f3
58dac5b
82fea7a
3a71f67
13c0dae
9702617
b030488
55c170f
a9abb54
c9cbda4
af3d06f
9093003
6bbf6ba
aef9657
f447b80
208807a
517369f
6665320
cbef359
de4de37
4c61efb
6ae70b7
79e8ea6
12c6f4f
51ca92b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -1,12 +1,96 @@ | ||||||||||
import * as React from 'react'; | ||||||||||
import { SxProps, Breakpoint } from '@mui/system'; | ||||||||||
import { InternalStandardProps as StandardProps, Theme } from '..'; | ||||||||||
import { BackdropProps, InternalStandardProps as StandardProps, Theme } from '..'; | ||||||||||
import { PaperProps } from '../Paper'; | ||||||||||
import { ModalProps } from '../Modal'; | ||||||||||
import { TransitionProps } from '../transitions/transition'; | ||||||||||
import { DialogClasses } from './dialogClasses'; | ||||||||||
import { CreateSlotsAndSlotProps, SlotProps } from '../utils/types'; | ||||||||||
|
||||||||||
export interface DialogProps extends StandardProps<ModalProps, 'children'> { | ||||||||||
export interface DialogSlots { | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing |
||||||||||
/** | ||||||||||
* The component that renders the transition. | ||||||||||
* [Follow this guide](/material-ui/transitions/#transitioncomponent-prop) to learn more about the requirements for this component. | ||||||||||
* @default Collapse | ||||||||||
*/ | ||||||||||
transition?: React.JSXElementConstructor< | ||||||||||
TransitionProps & { children?: React.ReactElement<any, any> } | ||||||||||
>; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Is there a blocker using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not really, i used previous type. updated here 6ae70b7 |
||||||||||
/** | ||||||||||
* The component that renders the paper. | ||||||||||
* @default Paper | ||||||||||
*/ | ||||||||||
paper?: React.ElementType; | ||||||||||
/** | ||||||||||
* The component that renders the container. | ||||||||||
*/ | ||||||||||
container?: React.ElementType; | ||||||||||
/** | ||||||||||
* The component that renders the backdrop. | ||||||||||
*/ | ||||||||||
backdrop?: React.ElementType; | ||||||||||
/** | ||||||||||
* The component that renders the root. | ||||||||||
*/ | ||||||||||
root?: React.ElementType; | ||||||||||
} | ||||||||||
|
||||||||||
export interface DialogTransitionSlotPropsOverrides {} | ||||||||||
export interface DialogPaperSlotPropsOverrides {} | ||||||||||
export interface DialogContainerSlotPropsOverrides {} | ||||||||||
export interface DialogBackdropSlotPropsOverrides {} | ||||||||||
export interface DialogRootSlotPropsOverrides {} | ||||||||||
|
||||||||||
export type DialogSlotsAndSlotProps = CreateSlotsAndSlotProps< | ||||||||||
DialogSlots, | ||||||||||
{ | ||||||||||
/** | ||||||||||
* Props forwarded to the root slot. | ||||||||||
* By default, the avaible props are based on the [Modal](https://mui.com/material-ui/api/modal/#props) component. | ||||||||||
*/ | ||||||||||
root: SlotProps<React.ElementType<ModalProps>, DialogRootSlotPropsOverrides, DialogOwnerState>; | ||||||||||
/** | ||||||||||
* Props forwarded to the backdrop slot. | ||||||||||
* By default, the avaible props are based on the [Backdrop](https://mui.com/material-ui/api/backdrop/#props) component. | ||||||||||
*/ | ||||||||||
backdrop: SlotProps< | ||||||||||
React.ElementType<BackdropProps>, | ||||||||||
DialogBackdropSlotPropsOverrides, | ||||||||||
DialogOwnerState | ||||||||||
>; | ||||||||||
/** | ||||||||||
* Props forwarded to the container slot. | ||||||||||
* By default, the avaible props are based on a div element. | ||||||||||
*/ | ||||||||||
container: SlotProps< | ||||||||||
React.ElementType<React.HTMLAttributes<HTMLDivElement>>, | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I found that this is simpler. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed 79e8ea6 |
||||||||||
DialogContainerSlotPropsOverrides, | ||||||||||
DialogOwnerState | ||||||||||
>; | ||||||||||
/** | ||||||||||
* Props forwarded to the transition slot. | ||||||||||
* By default, the avaible props are based on the [Fade](https://mui.com/material-ui/api/fade/#props) component. | ||||||||||
*/ | ||||||||||
transition: SlotProps< | ||||||||||
React.ElementType<TransitionProps>, | ||||||||||
DialogTransitionSlotPropsOverrides, | ||||||||||
DialogOwnerState | ||||||||||
>; | ||||||||||
/** | ||||||||||
* Props forwarded to the paper slot. | ||||||||||
* By default, the avaible props are based on the [Paper](https://mui.com/material-ui/api/paper/#props) component. | ||||||||||
*/ | ||||||||||
paper: SlotProps< | ||||||||||
React.ElementType<PaperProps>, | ||||||||||
DialogPaperSlotPropsOverrides, | ||||||||||
DialogOwnerState | ||||||||||
>; | ||||||||||
} | ||||||||||
>; | ||||||||||
|
||||||||||
export interface DialogProps | ||||||||||
extends Omit<StandardProps<ModalProps, 'children'>, 'slots' | 'slotProps'>, | ||||||||||
DialogSlotsAndSlotProps { | ||||||||||
/** | ||||||||||
* The id(s) of the element(s) that describe the dialog. | ||||||||||
*/ | ||||||||||
|
@@ -77,6 +161,7 @@ export interface DialogProps extends StandardProps<ModalProps, 'children'> { | |||||||||
/** | ||||||||||
* Props applied to the [`Paper`](https://mui.com/material-ui/api/paper/) element. | ||||||||||
* @default {} | ||||||||||
* @deprecated Use `slotProps.paper` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details. | ||||||||||
*/ | ||||||||||
PaperProps?: Partial<PaperProps<React.ElementType>>; | ||||||||||
/** | ||||||||||
|
@@ -92,6 +177,7 @@ export interface DialogProps extends StandardProps<ModalProps, 'children'> { | |||||||||
* The component used for the transition. | ||||||||||
* [Follow this guide](https://mui.com/material-ui/transitions/#transitioncomponent-prop) to learn more about the requirements for this component. | ||||||||||
* @default Fade | ||||||||||
* @deprecated Use `slots.transition` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details. | ||||||||||
*/ | ||||||||||
TransitionComponent?: React.JSXElementConstructor< | ||||||||||
TransitionProps & { children: React.ReactElement<unknown, any> } | ||||||||||
|
@@ -108,6 +194,7 @@ export interface DialogProps extends StandardProps<ModalProps, 'children'> { | |||||||||
/** | ||||||||||
* Props applied to the transition element. | ||||||||||
* By default, the element is based on this [`Transition`](https://reactcommunity.org/react-transition-group/transition/) component. | ||||||||||
* @deprecated Use `slotProps.transition` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details. | ||||||||||
*/ | ||||||||||
TransitionProps?: TransitionProps; | ||||||||||
} | ||||||||||
|
@@ -125,3 +212,5 @@ export interface DialogProps extends StandardProps<ModalProps, 'children'> { | |||||||||
* - inherits [Modal API](https://mui.com/material-ui/api/modal/) | ||||||||||
*/ | ||||||||||
export default function Dialog(props: DialogProps): React.JSX.Element; | ||||||||||
|
||||||||||
export interface DialogOwnerState extends DialogProps {} | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
to prevent recursive types. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed 12c6f4f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed here 4c61efb