Skip to content
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

Merged
merged 33 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
454319b
[material-ui][Dialog] Add slots and slotProps and deprecate *Componen…
sai6855 Dec 17, 2024
7132318
fix
sai6855 Dec 17, 2024
435948a
fix tests
sai6855 Dec 17, 2024
8f1a0ee
fix import
sai6855 Dec 17, 2024
3a81578
Merge branch 'master' into dialog-slots
sai6855 Jan 6, 2025
db4bea2
add paperslot
sai6855 Jan 6, 2025
8d2d1cb
Merge branch 'master' into dialog-slots
sai6855 Jan 6, 2025
9c57580
fix class name
sai6855 Jan 6, 2025
f6fc3f3
add dialog backdrop
sai6855 Jan 6, 2025
58dac5b
Merge branch 'dialog-slots' of https://github.com/sai6855/material-ui…
sai6855 Jan 6, 2025
82fea7a
update d.ts
sai6855 Jan 6, 2025
3a71f67
dcos:api
sai6855 Jan 6, 2025
13c0dae
typescript formatted
sai6855 Jan 6, 2025
9702617
dcos:api
sai6855 Jan 6, 2025
b030488
remove paper and backdrop slots
sai6855 Jan 7, 2025
55c170f
fix
sai6855 Jan 7, 2025
a9abb54
fix
sai6855 Jan 7, 2025
c9cbda4
Merge branch 'master' into dialog-slots
sai6855 Jan 7, 2025
af3d06f
add paper slot
sai6855 Jan 13, 2025
9093003
add backdrop slot
sai6855 Jan 13, 2025
6bbf6ba
add container slot
sai6855 Jan 13, 2025
aef9657
add root slot
sai6855 Jan 13, 2025
f447b80
add slots
sai6855 Jan 13, 2025
208807a
Merge branch 'master' into dialog-slots
sai6855 Jan 13, 2025
517369f
add prop descriptions
sai6855 Jan 13, 2025
6665320
proptypes
sai6855 Jan 13, 2025
cbef359
Merge branch 'dialog-slots' of https://github.com/sai6855/material-ui…
sai6855 Jan 13, 2025
de4de37
prettier
sai6855 Jan 14, 2025
4c61efb
fix Backdrop import
sai6855 Jan 15, 2025
6ae70b7
fix transition slot type
sai6855 Jan 15, 2025
79e8ea6
use 'div'
sai6855 Jan 15, 2025
12c6f4f
prevent recursive types in DialogOwnerState
sai6855 Jan 15, 2025
51ca92b
add shouldForwordComponent prop
sai6855 Jan 15, 2025
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
75 changes: 57 additions & 18 deletions docs/pages/material-ui/api/dialog.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,46 +41,91 @@
}
},
"PaperComponent": { "type": { "name": "elementType" }, "default": "Paper" },
"PaperProps": { "type": { "name": "object" }, "default": "{}" },
"PaperProps": {
"type": { "name": "object" },
"default": "{}",
"deprecated": true,
"deprecationInfo": "Use <code>slotProps.paper</code> instead. This prop will be removed in v7. See <a href=\"/material-ui/migration/migrating-from-deprecated-apis/\">Migrating from deprecated APIs</a> for more details."
},
"scroll": {
"type": { "name": "enum", "description": "'body'<br>&#124;&nbsp;'paper'" },
"default": "'paper'"
},
"slotProps": {
"type": {
"name": "shape",
"description": "{ backdrop?: func<br>&#124;&nbsp;object, container?: func<br>&#124;&nbsp;object, paper?: func<br>&#124;&nbsp;object, root?: func<br>&#124;&nbsp;object, transition?: func<br>&#124;&nbsp;object }"
},
"default": "{}"
},
"slots": {
"type": {
"name": "shape",
"description": "{ backdrop?: elementType, container?: elementType, paper?: elementType, root?: elementType, transition?: elementType }"
},
"default": "{}"
},
"sx": {
"type": {
"name": "union",
"description": "Array&lt;func<br>&#124;&nbsp;object<br>&#124;&nbsp;bool&gt;<br>&#124;&nbsp;func<br>&#124;&nbsp;object"
},
"additionalInfo": { "sx": true }
},
"TransitionComponent": { "type": { "name": "elementType" }, "default": "Fade" },
"TransitionComponent": {
"type": { "name": "elementType" },
"default": "Fade",
"deprecated": true,
"deprecationInfo": "Use <code>slots.transition</code> instead. This prop will be removed in v7. See <a href=\"/material-ui/migration/migrating-from-deprecated-apis/\">Migrating from deprecated APIs</a> for more details."
},
"transitionDuration": {
"type": {
"name": "union",
"description": "number<br>&#124;&nbsp;{ appear?: number, enter?: number, exit?: number }"
},
"default": "{\n enter: theme.transitions.duration.enteringScreen,\n exit: theme.transitions.duration.leavingScreen,\n}"
},
"TransitionProps": { "type": { "name": "object" } }
"TransitionProps": {
"type": { "name": "object" },
"deprecated": true,
"deprecationInfo": "Use <code>slotProps.transition</code> instead. This prop will be removed in v7. See <a href=\"/material-ui/migration/migrating-from-deprecated-apis/\">Migrating from deprecated APIs</a> for more details."
}
},
"name": "Dialog",
"imports": [
"import Dialog from '@mui/material/Dialog';",
"import { Dialog } from '@mui/material';"
],
"classes": [
"slots": [
{
"key": "container",
"className": "MuiDialog-container",
"description": "Styles applied to the container element.",
"isGlobal": false
"name": "transition",
"description": "The component that renders the transition.\n[Follow this guide](/material-ui/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.",
"default": "Collapse",
"class": null
},
{
"key": "paper",
"className": "MuiDialog-paper",
"description": "Styles applied to the Paper component.",
"isGlobal": false
"name": "paper",
"description": "The component that renders the paper.",
"default": "Paper",
"class": "MuiDialog-paper"
},
{
"name": "container",
"description": "The component that renders the container.",
"class": "MuiDialog-container"
},
{
"name": "backdrop",
"description": "The component that renders the backdrop.",
"class": null
},
{
"name": "root",
"description": "The component that renders the root.",
"class": "MuiDialog-root"
}
],
"classes": [
{
"key": "paperFullScreen",
"className": "MuiDialog-paperFullScreen",
Expand Down Expand Up @@ -141,12 +186,6 @@
"description": "Styles applied to the Paper component if `maxWidth=\"xs\"`.",
"isGlobal": false
},
{
"key": "root",
"className": "MuiDialog-root",
"description": "Styles applied to the root element.",
"isGlobal": false
},
{
"key": "scrollBody",
"className": "MuiDialog-scrollBody",
Expand Down
18 changes: 9 additions & 9 deletions docs/translations/api-docs/dialog/dialog.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
"description": "Props applied to the <a href=\"https://mui.com/material-ui/api/paper/\"><code>Paper</code></a> element."
},
"scroll": { "description": "Determine the container for scrolling the dialog." },
"slotProps": { "description": "The props used for each slot inside." },
"slots": { "description": "The components used for each slot inside." },
"sx": {
"description": "The system prop that allows defining system overrides as well as additional CSS styles."
},
Expand All @@ -49,14 +51,6 @@
}
},
"classDescriptions": {
"container": {
"description": "Styles applied to {{nodeName}}.",
"nodeName": "the container element"
},
"paper": {
"description": "Styles applied to {{nodeName}}.",
"nodeName": "the Paper component"
},
"paperFullScreen": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the Paper component",
Expand Down Expand Up @@ -107,7 +101,6 @@
"nodeName": "the Paper component",
"conditions": "<code>maxWidth=\"xs\"</code>"
},
"root": { "description": "Styles applied to the root element." },
"scrollBody": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the container element",
Expand All @@ -118,5 +111,12 @@
"nodeName": "the container element",
"conditions": "<code>scroll=\"paper\"</code>"
}
},
"slotDescriptions": {
"backdrop": "The component that renders the backdrop.",
"container": "The component that renders the container.",
"paper": "The component that renders the paper.",
"root": "The component that renders the root.",
"transition": "The component that renders the transition. <a href=\"/material-ui/transitions/#transitioncomponent-prop\">Follow this guide</a> to learn more about the requirements for this component."
}
}
86 changes: 85 additions & 1 deletion packages/mui-material/src/Dialog/Dialog.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,91 @@
import * as React from 'react';
import { SxProps, Breakpoint } from '@mui/system';
import { InternalStandardProps as StandardProps, Theme } from '..';
import { BackdropProps } from '../Backdrop';
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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing root, backdrop, container, and paper slots.

/**
* 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.ElementType;
/**
* 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<'div', 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.
*/
Expand Down Expand Up @@ -77,6 +156,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>>;
/**
Expand All @@ -92,6 +172,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> }
Expand All @@ -108,6 +189,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;
}
Expand All @@ -125,3 +207,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 Omit<DialogProps, 'slots' | 'slotProps'> {}
Loading
Loading