@mui/material 5.14.5 → 5.14.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/CHANGELOG.md +121 -3
  2. package/Drawer/Drawer.d.ts +2 -0
  3. package/Drawer/Drawer.js +2 -0
  4. package/InputBase/InputBase.js +1 -1
  5. package/Modal/Modal.d.ts +117 -12
  6. package/Modal/Modal.js +97 -36
  7. package/Modal/index.d.ts +3 -0
  8. package/Modal/index.js +2 -1
  9. package/Modal/modalClasses.d.ts +12 -0
  10. package/Modal/modalClasses.js +7 -0
  11. package/README.md +2 -3
  12. package/Select/Select.js +5 -3
  13. package/Select/selectClasses.d.ts +2 -0
  14. package/Select/selectClasses.js +1 -1
  15. package/Skeleton/Skeleton.js +2 -2
  16. package/TextField/TextField.d.ts +0 -4
  17. package/TextField/TextField.js +2 -17
  18. package/index.js +1 -1
  19. package/legacy/Drawer/Drawer.js +2 -0
  20. package/legacy/InputBase/InputBase.js +1 -1
  21. package/legacy/Modal/Modal.js +93 -43
  22. package/legacy/Modal/index.js +2 -1
  23. package/legacy/Modal/modalClasses.js +7 -0
  24. package/legacy/Select/Select.js +4 -2
  25. package/legacy/Select/selectClasses.js +1 -1
  26. package/legacy/Skeleton/Skeleton.js +2 -2
  27. package/legacy/TextField/TextField.js +2 -17
  28. package/legacy/index.js +1 -1
  29. package/modern/Drawer/Drawer.js +2 -0
  30. package/modern/InputBase/InputBase.js +1 -1
  31. package/modern/Modal/Modal.js +97 -36
  32. package/modern/Modal/index.js +2 -1
  33. package/modern/Modal/modalClasses.js +7 -0
  34. package/modern/Select/Select.js +5 -3
  35. package/modern/Select/selectClasses.js +1 -1
  36. package/modern/Skeleton/Skeleton.js +2 -2
  37. package/modern/TextField/TextField.js +2 -17
  38. package/modern/index.js +1 -1
  39. package/node/Drawer/Drawer.js +2 -0
  40. package/node/InputBase/InputBase.js +1 -1
  41. package/node/Modal/Modal.js +100 -41
  42. package/node/Modal/index.js +14 -5
  43. package/node/Modal/modalClasses.js +16 -0
  44. package/node/Select/Select.js +5 -3
  45. package/node/Select/selectClasses.js +1 -1
  46. package/node/Skeleton/Skeleton.js +2 -2
  47. package/node/TextField/TextField.js +2 -17
  48. package/node/index.js +1 -1
  49. package/package.json +6 -6
  50. package/umd/material-ui.development.js +432 -647
  51. package/umd/material-ui.production.min.js +23 -23
package/CHANGELOG.md CHANGED
@@ -1,5 +1,123 @@
1
1
  # [Versions](https://mui.com/versions/)
2
2
 
3
+ ## 5.14.6
4
+
5
+ <!-- generated comparing v5.14.5..master -->
6
+
7
+ _Aug 23, 2023_
8
+
9
+ A big thanks to the 21 contributors who made this release possible. Here are some highlights ✨:
10
+
11
+ - 🚀 Added the [Popup](https://mui.com/base-ui/react-popup/) component to Base UI (#37960) @michaldudak
12
+ It's intended to replace the Popper component, which uses the deprecated Popper JS library. The Popup is built on top of Floating UI and has a similar API to the Popper.
13
+ - 🚀 Added the [Accordion](https://mui.com/joy-ui/react-accordion/) component to Joy UI (#38164) @siriwatknp
14
+ - 🚀 Added InputBase and ButtonBase components to `material-next` (#38319) @DiegoAndai @mj12albert
15
+ - 🔋 First iteration on the zero-runtime styling engine compatible with Server Components (#38378) @brijeshb42
16
+
17
+ ### `@mui/material@5.14.6`
18
+
19
+ - [Modal] Update it to use the useModal hook (#38498) @mnajdova
20
+ - [Select] Add `root` class to `SelectClasses` (#38424) @sai6855
21
+ - [Skeleton] Soften the pulse animation (#38506) @oliviertassinari
22
+ - [TextField] Fix onClick regressions handling changes (#38474) @mj12albert
23
+ - [TextField] Fix TextField onClick test (#38597) @mj12albert
24
+
25
+ ### `@mui/base@5.0.0-beta.12`
26
+
27
+ - [Popup] New component (#37960) @michaldudak
28
+
29
+ ### `@mui/joy@5.0.0-beta.3`
30
+
31
+ - [Accordion] Add Joy UI Accordion components (#38164) @siriwatknp
32
+ - [Select] Add `required` prop (#38167) @siriwatknp
33
+ - Miscellaneous fixes (#38462) @siriwatknp
34
+
35
+ ### `@mui/material-next@6.0.0-alpha.98`
36
+
37
+ - [ButtonBase] Add ButtonBase component (#38319) @DiegoAndai
38
+ - [Input] Add InputBase component (#38392) @mj12albert
39
+
40
+ ### `@mui/zero-runtime@0.0.1-alpha.0`
41
+
42
+ - Implementation of styled tag processor for linaria (#38378) @brijeshb42
43
+
44
+ ### Docs
45
+
46
+ - [blog] Clarify tree view move @oliviertassinari
47
+ - [docs] Improve the "Understanding MUI packages" page images (#38619) @danilo-leal
48
+ - [docs][base-ui] Revise the structure of the Component docs (#38529) @samuelsycamore
49
+ - [docs][base-ui] Fix Menu Hooks demo (#38479) @homerchen19
50
+ - [docs][base-ui] Correct the MUI System quickstart example (#38496) @michaldudak
51
+ - [docs][base-ui] Add Tailwind & plain CSS demos for Autocomplete page (#38157) @mj12albert
52
+ - [docs][base-ui] Add Tailwind CSS + plain CSS demo on the Input page (#38302) @alisasanib
53
+ - [docs][base-ui] Add Tailwind CSS + plain CSS demo on the Snackbar, Badge, Switch pages (#38425) @alisasanib
54
+ - [docs][base-ui] Add Tailwind CSS + plain CSS demo on the Slider page (#38413) @alisasanib
55
+ - [docs][base-ui] Add Tailwind CSS + plain CSS demo on the Select page (#38367) @alisasanib
56
+ - [docs][joy-ui] Fix typo: Classname -> Class name for consistency (#38510) @alexfauquette
57
+ - [docs][joy-ui] Revise the theme color page (#38402) @danilo-leal
58
+ - [docs][joy-ui] Sort templates by popularity (#38490) @oliviertassinari
59
+ - [docs][joy-ui] Fix the `fullWidth` prop description for the Input (#38545) @0xturner
60
+ - [docs][joy-ui] Updated the List playground demo (#38499) @zanivan
61
+ - [docs][joy-ui] Changed bgcolor of the Playground demo (#38502) @zanivan
62
+ - [docs][material-ui] Fix key warning in SimpleDialog demo (#38580) @ZeeshanTamboli
63
+ - [docs][material-ui] Fixed Google Fonts link for material two-tone icons in CodeSandbox and Stackblitz (#38247) @ZeeshanTamboli
64
+ - [docs][material-ui] Fix the Drawer's `onClose` API docs (#38273) @johnmatthiggins
65
+ - [docs][material-ui] Improve nav link tab example (#38315) @oliviertassinari
66
+ - [docs][material-ui] Fix missing import in the styled engine guide (#38450) @codersjj
67
+ - [docs][material-ui][Dialog] Improve screen reader announcement of Customized Dialog (#38592) @ZeeshanTamboli
68
+ - [docs] Add 3rd party libraries integration examples for Joy Input (#38541) @siriwatknp
69
+ - [docs] Hide translation call to action (#38449) @cristianmacedo
70
+ - [docs] Fix codemod name in changelog of v5.14.4 (#38593) @GresilleSiffle
71
+ - [docs] More space for theme builder (#38532) @oliviertassinari
72
+ - [docs] Fix the math symbol of the width sx prop range @oliviertassinari
73
+ - [docs] Fix typo on a11y section of Tabs @oliviertassinari
74
+ - [docs] Clarify System peer dependencies @oliviertassinari
75
+ - [docs] Fix horizontal scrollbar @oliviertassinari
76
+ - [docs] Code style convention @oliviertassinari
77
+ - [docs] Fix typo in Base UI @oliviertassinari
78
+ - [docs] Update the backers page (#38505) @danilo-leal
79
+ - [docs] Add stray design adjustments to the docs (#38501) @danilo-leal
80
+ - [docs] Use IBM Plex Sans in Tailwind CSS demos (#38464) @mnajdova
81
+ - [docs] Fix SEO issues reported by ahrefs (#38423) @oliviertassinari
82
+
83
+ ### Examples
84
+
85
+ - [examples] Start to remove Gatsby (#38567) @oliviertassinari
86
+ - [examples][joy-ui] Fix Joy UI example CLI (#38531) @oliviertassinari
87
+ - [examples][joy-ui] Improve example when using Next Font (#38540) @mwskwong
88
+
89
+ ### Core
90
+
91
+ - [CHANGELOG] Fix issues in highlight @oliviertassinari
92
+ - [core] Remove redundant `@material-ui/` aliases from regression test webpack config (#38574) @ZeeshanTamboli
93
+ - [core] Fix CI error @oliviertassinari
94
+ - [core] Remove unnecessary Box (#38461) @oliviertassinari
95
+ - [core] Set GitHub Action top level permission @oliviertassinari
96
+ - [docs-infra][joy-ui] Polish the usage and CSS vars playgrounds (#38600) @danilo-leal
97
+ - [docs-infra] Support link title (#38579) @oliviertassinari
98
+ - [docs-infra] Fix ad layout shift (#38622) @oliviertassinari
99
+ - [docs-infra] Add light tweaks to the ad container (#38504) @danilo-leal
100
+ - [docs-infra] Fix anchor scroll without tabs (#38586) @oliviertassinari
101
+ - [docs-infra] Retain velocity animation speed (#38470) @oliviertassinari
102
+ - [docs-infra] Follow import and CSS token standard (#38508) @oliviertassinari
103
+ - [docs-infra] Add icon to callouts (#38525) @alexfauquette
104
+ - [docs-infra] Fix the anchor link on headings (#38528) @danilo-leal
105
+ - [docs-infra] Cleanup code on demo code block expansion (#38522) @ZeeshanTamboli
106
+ - [docs-infra] Improve the heading buttons positioning (#38428) @danilo-leal
107
+ - [docs-infra] Customize the blockquote design (#38503) @danilo-leal
108
+ - [docs-infra] Improve the alert before a negative feedback (#38500) @danilo-leal
109
+ - [docs-infra] Fix GoogleAnalytics missing event for code copy (#38469) @alexfauquette
110
+ - [docs-infra] Improve affordance on the code block expansion (#38421) @danilo-leal
111
+ - [website] Fine-tune the branding theme buttons (#38588) @danilo-leal
112
+ - [website] Improve the Base UI hero section demo (#38585) @danilo-leal
113
+ - [website] Add stray design improvements to the Material UI page (#38590) @danilo-leal
114
+ - [website] Fix mobile view Material UI page (#38568) @oliviertassinari
115
+ - [website] Fix reference to the data grid @oliviertassinari
116
+ - [website] Configure Apple Pay @oliviertassinari
117
+ - [website] Fix template link on the homepage (#38471) @danilo-leal
118
+
119
+ All contributors of this release in alphabetical order: @0xturner, @alexfauquette, @alisasanib, @brijeshb42, @codersjj, @cristianmacedo, @danilo-leal, @DiegoAndai, @GresilleSiffle, @homerchen19, @johnmatthiggins, @michaldudak, @mj12albert, @mnajdova, @mwskwong, @oliviertassinari, @sai6855, @samuelsycamore, @siriwatknp, @zanivan, @ZeeshanTamboli
120
+
3
121
  ## 5.14.5
4
122
 
5
123
  <!-- generated comparing v5.14.4..master -->
@@ -78,7 +196,7 @@ _Aug 8, 2023_
78
196
 
79
197
  A big thanks to the 18 contributors who made this release possible. Here are some highlights ✨:
80
198
 
81
- - 🎉 Added [Number input](https://mui.com/base-ui/react-number-input) component & [useNumberInput](https://mui.com/base-ui/react-number-input#hook) hook in [Base UI](https://mui.com/base-ui/getting-started/) @mj12albert
199
+ - 🎉 Added [Number Input](https://mui.com/base-ui/react-number-input/) component & [useNumberInput](https://mui.com/base-ui/react-number-input/#hook) hook in [Base UI](https://mui.com/base-ui/getting-started/) @mj12albert
82
200
 
83
201
  ### `@mui/material@5.14.4`
84
202
 
@@ -116,7 +234,7 @@ A big thanks to the 18 contributors who made this release possible. Here are som
116
234
  A codemod is provided to help with the migration:
117
235
 
118
236
  ```bash
119
- npx @mui/codemod v5.0.0/base-use-named-imports <path>
237
+ npx @mui/codemod v5.0.0/base-use-named-exports <path>
120
238
  ```
121
239
 
122
240
  #### Changes
@@ -5736,7 +5854,7 @@ A big thanks to the 16 contributors who made this release possible. Here are som
5736
5854
 
5737
5855
  ### Core
5738
5856
 
5739
- - &#8203;<!-- 23 -->[core] Fix link to Open Collective @oliviertassinari
5857
+ - &#8203;<!-- 23 -->[core] Fix link to Open Collective @oliviertassinari
5740
5858
  - &#8203;<!-- 26 -->[core] Update snapshots and s3 fallback (#30134) @Janpot
5741
5859
  - &#8203;<!-- 24 -->[ci] Update CI bucket (#30080) @Janpot
5742
5860
  - &#8203;<!-- 13 -->[fix] size:snapshot for mui-material-next and mui-joy components (#30106) @Janpot
@@ -33,8 +33,10 @@ export interface DrawerProps extends StandardProps<ModalProps, 'open' | 'childre
33
33
  ModalProps?: Partial<ModalProps>;
34
34
  /**
35
35
  * Callback fired when the component requests to be closed.
36
+ * The `reason` parameter can optionally be used to control the response to `onClose`.
36
37
  *
37
38
  * @param {object} event The event source of the callback.
39
+ * @param {string} reason Can be: `"escapeKeyDown"`, `"backdropClick"`.
38
40
  */
39
41
  onClose?: ModalProps['onClose'];
40
42
  /**
package/Drawer/Drawer.js CHANGED
@@ -268,8 +268,10 @@ process.env.NODE_ENV !== "production" ? Drawer.propTypes /* remove-proptypes */
268
268
  ModalProps: PropTypes.object,
269
269
  /**
270
270
  * Callback fired when the component requests to be closed.
271
+ * The `reason` parameter can optionally be used to control the response to `onClose`.
271
272
  *
272
273
  * @param {object} event The event source of the callback.
274
+ * @param {string} reason Can be: `"escapeKeyDown"`, `"backdropClick"`.
273
275
  */
274
276
  onClose: PropTypes.func,
275
277
  /**
@@ -374,7 +374,7 @@ const InputBase = /*#__PURE__*/React.forwardRef(function InputBase(inProps, ref)
374
374
  if (inputRef.current && event.currentTarget === event.target) {
375
375
  inputRef.current.focus();
376
376
  }
377
- if (onClick && !fcs.disabled) {
377
+ if (onClick) {
378
378
  onClick(event);
379
379
  }
380
380
  };
package/Modal/Modal.d.ts CHANGED
@@ -2,13 +2,11 @@ import * as React from 'react';
2
2
  import { SxProps } from '@mui/system';
3
3
  import { OverrideProps } from '@mui/types';
4
4
  import { SlotComponentProps } from '@mui/base';
5
- import {
6
- ModalTypeMap as BaseModalTypeMap,
7
- ModalClasses as BaseModalClasses,
8
- } from '@mui/base/Modal';
5
+ import { PortalProps } from '../Portal';
9
6
  import { Theme } from '../styles';
10
7
  import Backdrop, { BackdropProps } from '../Backdrop';
11
8
  import { OverridableComponent } from '../OverridableComponent';
9
+ import { ModalClasses } from './modalClasses';
12
10
 
13
11
  export interface ModalComponentsPropsOverrides {}
14
12
 
@@ -16,6 +14,18 @@ export interface ModalOwnerState extends ModalProps {
16
14
  exited: boolean;
17
15
  }
18
16
 
17
+ export interface ModalSlots {
18
+ /**
19
+ * The component that renders the root.
20
+ * @default 'div'
21
+ */
22
+ root?: React.ElementType;
23
+ /**
24
+ * The component that renders the backdrop.
25
+ */
26
+ backdrop?: React.ElementType;
27
+ }
28
+
19
29
  export interface ModalTypeMap<
20
30
  DefaultComponent extends React.ElementType = 'div',
21
31
  AdditionalProps = {},
@@ -41,14 +51,23 @@ export interface ModalTypeMap<
41
51
  * @deprecated Use `slotProps.backdrop` instead.
42
52
  */
43
53
  BackdropProps?: Partial<BackdropProps>;
54
+ /**
55
+ * A single child content element.
56
+ */
57
+ children: React.ReactElement;
44
58
  /**
45
59
  * Override or extend the styles applied to the component.
46
60
  */
47
- classes?: Partial<BaseModalClasses>;
61
+ classes?: Partial<ModalClasses>;
48
62
  /**
49
63
  * @ignore
50
64
  */
51
65
  className?: string;
66
+ /**
67
+ * When set to true the Modal waits until a nested Transition is completed before closing.
68
+ * @default false
69
+ */
70
+ closeAfterTransition?: boolean;
52
71
  /**
53
72
  * The components used for each slot inside.
54
73
  *
@@ -78,6 +97,98 @@ export interface ModalTypeMap<
78
97
  ModalOwnerState
79
98
  >;
80
99
  };
100
+ /**
101
+ * An HTML element or function that returns one.
102
+ * The `container` will have the portal children appended to it.
103
+ *
104
+ * By default, it uses the body of the top-level document object,
105
+ * so it's simply `document.body` most of the time.
106
+ */
107
+ container?: PortalProps['container'];
108
+ /**
109
+ * If `true`, the modal will not automatically shift focus to itself when it opens, and
110
+ * replace it to the last focused element when it closes.
111
+ * This also works correctly with any modal children that have the `disableAutoFocus` prop.
112
+ *
113
+ * Generally this should never be set to `true` as it makes the modal less
114
+ * accessible to assistive technologies, like screen readers.
115
+ * @default false
116
+ */
117
+ disableAutoFocus?: boolean;
118
+ /**
119
+ * If `true`, the modal will not prevent focus from leaving the modal while open.
120
+ *
121
+ * Generally this should never be set to `true` as it makes the modal less
122
+ * accessible to assistive technologies, like screen readers.
123
+ * @default false
124
+ */
125
+ disableEnforceFocus?: boolean;
126
+ /**
127
+ * If `true`, hitting escape will not fire the `onClose` callback.
128
+ * @default false
129
+ */
130
+ disableEscapeKeyDown?: boolean;
131
+ /**
132
+ * The `children` will be under the DOM hierarchy of the parent component.
133
+ * @default false
134
+ */
135
+ disablePortal?: PortalProps['disablePortal'];
136
+ /**
137
+ * If `true`, the modal will not restore focus to previously focused element once
138
+ * modal is hidden or unmounted.
139
+ * @default false
140
+ */
141
+ disableRestoreFocus?: boolean;
142
+ /**
143
+ * Disable the scroll lock behavior.
144
+ * @default false
145
+ */
146
+ disableScrollLock?: boolean;
147
+ /**
148
+ * If `true`, the backdrop is not rendered.
149
+ * @default false
150
+ */
151
+ hideBackdrop?: boolean;
152
+ /**
153
+ * Always keep the children in the DOM.
154
+ * This prop can be useful in SEO situation or
155
+ * when you want to maximize the responsiveness of the Modal.
156
+ * @default false
157
+ */
158
+ keepMounted?: boolean;
159
+ /**
160
+ * Callback fired when the backdrop is clicked.
161
+ * @deprecated Use the `onClose` prop with the `reason` argument to handle the `backdropClick` events.
162
+ */
163
+ onBackdropClick?: React.ReactEventHandler<{}>;
164
+ /**
165
+ * Callback fired when the component requests to be closed.
166
+ * The `reason` parameter can optionally be used to control the response to `onClose`.
167
+ *
168
+ * @param {object} event The event source of the callback.
169
+ * @param {string} reason Can be: `"escapeKeyDown"`, `"backdropClick"`.
170
+ */
171
+ onClose?: {
172
+ bivarianceHack(event: {}, reason: 'backdropClick' | 'escapeKeyDown'): void;
173
+ }['bivarianceHack'];
174
+ /**
175
+ * A function called when a transition enters.
176
+ */
177
+ onTransitionEnter?: () => void;
178
+ /**
179
+ * A function called when a transition has exited.
180
+ */
181
+ onTransitionExited?: () => void;
182
+ /**
183
+ * If `true`, the component is shown.
184
+ */
185
+ open: boolean;
186
+ /**
187
+ * The components used for each slot inside the Modal.
188
+ * Either a string to use a HTML element or a component.
189
+ * @default {}
190
+ */
191
+ slots?: ModalSlots;
81
192
  /**
82
193
  * The props used for each slot inside the Modal.
83
194
  * @default {}
@@ -94,7 +205,7 @@ export interface ModalTypeMap<
94
205
  * The system prop that allows defining system overrides as well as additional CSS styles.
95
206
  */
96
207
  sx?: SxProps<Theme>;
97
- } & Omit<BaseModalTypeMap['props'], 'slotProps'>;
208
+ };
98
209
  defaultComponent: DefaultComponent;
99
210
  }
100
211
 
@@ -102,8 +213,6 @@ type ModalRootProps = NonNullable<ModalTypeMap['props']['slotProps']>['root'];
102
213
 
103
214
  export declare const ModalRoot: React.FC<ModalRootProps>;
104
215
 
105
- export type ModalClassKey = keyof NonNullable<ModalProps['classes']>;
106
-
107
216
  /**
108
217
  * Modal is a lower-level construct that is leveraged by the following components:
109
218
  *
@@ -127,10 +236,6 @@ export type ModalClassKey = keyof NonNullable<ModalProps['classes']>;
127
236
  */
128
237
  declare const Modal: OverridableComponent<ModalTypeMap>;
129
238
 
130
- export type ModalClasses = Record<ModalClassKey, string>;
131
-
132
- export declare const modalClasses: ModalClasses;
133
-
134
239
  export type ModalProps<
135
240
  RootComponent extends React.ElementType = ModalTypeMap['defaultComponent'],
136
241
  AdditionalProps = {},
package/Modal/Modal.js CHANGED
@@ -6,14 +6,30 @@ const _excluded = ["BackdropComponent", "BackdropProps", "classes", "className",
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import clsx from 'clsx';
9
- import { Modal as ModalUnstyled, modalClasses as modalUnstyledClasses } from '@mui/base/Modal';
10
- import { isHostComponent, resolveComponentProps } from '@mui/base/utils';
11
9
  import { elementAcceptingRef, HTMLElementType } from '@mui/utils';
10
+ import { useSlotProps } from '@mui/base';
11
+ import { unstable_useModal as useModal } from '@mui/base/unstable_useModal';
12
+ import { unstable_composeClasses as composeClasses } from '@mui/base/composeClasses';
13
+ import FocusTrap from '../Unstable_TrapFocus';
14
+ import Portal from '../Portal';
12
15
  import styled from '../styles/styled';
13
16
  import useThemeProps from '../styles/useThemeProps';
14
17
  import Backdrop from '../Backdrop';
18
+ import { getModalUtilityClass } from './modalClasses';
15
19
  import { jsx as _jsx } from "react/jsx-runtime";
16
- export const modalClasses = modalUnstyledClasses;
20
+ import { jsxs as _jsxs } from "react/jsx-runtime";
21
+ const useUtilityClasses = ownerState => {
22
+ const {
23
+ open,
24
+ exited,
25
+ classes
26
+ } = ownerState;
27
+ const slots = {
28
+ root: ['root', !open && exited && 'hidden'],
29
+ backdrop: ['backdrop']
30
+ };
31
+ return composeClasses(slots, getModalUtilityClass, classes);
32
+ };
17
33
  const ModalRoot = styled('div', {
18
34
  name: 'MuiModal',
19
35
  slot: 'Root',
@@ -68,7 +84,6 @@ const Modal = /*#__PURE__*/React.forwardRef(function Modal(inProps, ref) {
68
84
  const {
69
85
  BackdropComponent = ModalBackdrop,
70
86
  BackdropProps,
71
- classes,
72
87
  className,
73
88
  closeAfterTransition = false,
74
89
  children,
@@ -85,17 +100,13 @@ const Modal = /*#__PURE__*/React.forwardRef(function Modal(inProps, ref) {
85
100
  hideBackdrop = false,
86
101
  keepMounted = false,
87
102
  onBackdropClick,
88
- onClose,
89
103
  open,
90
104
  slotProps,
91
- slots,
105
+ slots
92
106
  // eslint-disable-next-line react/prop-types
93
- theme
94
107
  } = props,
95
108
  other = _objectWithoutPropertiesLoose(props, _excluded);
96
- const [exited, setExited] = React.useState(true);
97
- const commonProps = {
98
- container,
109
+ const propsWithDefaults = _extends({}, props, {
99
110
  closeAfterTransition,
100
111
  disableAutoFocus,
101
112
  disableEnforceFocus,
@@ -104,40 +115,90 @@ const Modal = /*#__PURE__*/React.forwardRef(function Modal(inProps, ref) {
104
115
  disableRestoreFocus,
105
116
  disableScrollLock,
106
117
  hideBackdrop,
107
- keepMounted,
108
- onBackdropClick,
109
- onClose,
110
- open
111
- };
112
- const ownerState = _extends({}, props, commonProps, {
118
+ keepMounted
119
+ });
120
+ const {
121
+ getRootProps,
122
+ getBackdropProps,
123
+ getTransitionProps,
124
+ portalRef,
125
+ isTopModal,
126
+ exited,
127
+ hasTransition
128
+ } = useModal(_extends({}, propsWithDefaults, {
129
+ rootRef: ref
130
+ }));
131
+ const ownerState = _extends({}, propsWithDefaults, {
113
132
  exited
114
133
  });
134
+ const classes = useUtilityClasses(ownerState);
135
+ const childProps = {};
136
+ if (children.props.tabIndex === undefined) {
137
+ childProps.tabIndex = '-1';
138
+ }
139
+
140
+ // It's a Transition like component
141
+ if (hasTransition) {
142
+ const {
143
+ onEnter,
144
+ onExited
145
+ } = getTransitionProps();
146
+ childProps.onEnter = onEnter;
147
+ childProps.onExited = onExited;
148
+ }
115
149
  const RootSlot = (_ref = (_slots$root = slots == null ? void 0 : slots.root) != null ? _slots$root : components.Root) != null ? _ref : ModalRoot;
116
150
  const BackdropSlot = (_ref2 = (_slots$backdrop = slots == null ? void 0 : slots.backdrop) != null ? _slots$backdrop : components.Backdrop) != null ? _ref2 : BackdropComponent;
117
151
  const rootSlotProps = (_slotProps$root = slotProps == null ? void 0 : slotProps.root) != null ? _slotProps$root : componentsProps.root;
118
152
  const backdropSlotProps = (_slotProps$backdrop = slotProps == null ? void 0 : slotProps.backdrop) != null ? _slotProps$backdrop : componentsProps.backdrop;
119
- return /*#__PURE__*/_jsx(ModalUnstyled, _extends({
120
- slots: {
121
- root: RootSlot,
122
- backdrop: BackdropSlot
153
+ const rootProps = useSlotProps({
154
+ elementType: RootSlot,
155
+ externalSlotProps: rootSlotProps,
156
+ externalForwardedProps: other,
157
+ getSlotProps: getRootProps,
158
+ additionalProps: {
159
+ ref,
160
+ as: component
123
161
  },
124
- slotProps: {
125
- root: () => _extends({}, resolveComponentProps(rootSlotProps, ownerState), !isHostComponent(RootSlot) && {
126
- as: component,
127
- theme
128
- }, {
129
- className: clsx(className, rootSlotProps == null ? void 0 : rootSlotProps.className, classes == null ? void 0 : classes.root, !ownerState.open && ownerState.exited && (classes == null ? void 0 : classes.hidden))
130
- }),
131
- backdrop: () => _extends({}, BackdropProps, resolveComponentProps(backdropSlotProps, ownerState), {
132
- className: clsx(backdropSlotProps == null ? void 0 : backdropSlotProps.className, BackdropProps == null ? void 0 : BackdropProps.className, classes == null ? void 0 : classes.backdrop)
133
- })
162
+ ownerState,
163
+ className: clsx(className, rootSlotProps == null ? void 0 : rootSlotProps.className, classes == null ? void 0 : classes.root, !ownerState.open && ownerState.exited && (classes == null ? void 0 : classes.hidden))
164
+ });
165
+ const backdropProps = useSlotProps({
166
+ elementType: BackdropSlot,
167
+ externalSlotProps: backdropSlotProps,
168
+ additionalProps: BackdropProps,
169
+ getSlotProps: otherHandlers => {
170
+ return getBackdropProps(_extends({}, otherHandlers, {
171
+ onClick: e => {
172
+ if (onBackdropClick) {
173
+ onBackdropClick(e);
174
+ }
175
+ if (otherHandlers != null && otherHandlers.onClick) {
176
+ otherHandlers.onClick(e);
177
+ }
178
+ }
179
+ }));
134
180
  },
135
- onTransitionEnter: () => setExited(false),
136
- onTransitionExited: () => setExited(true),
137
- ref: ref
138
- }, other, commonProps, {
139
- children: children
140
- }));
181
+ className: clsx(backdropSlotProps == null ? void 0 : backdropSlotProps.className, BackdropProps == null ? void 0 : BackdropProps.className, classes == null ? void 0 : classes.backdrop),
182
+ ownerState
183
+ });
184
+ if (!keepMounted && !open && (!hasTransition || exited)) {
185
+ return null;
186
+ }
187
+ return /*#__PURE__*/_jsx(Portal, {
188
+ ref: portalRef,
189
+ container: container,
190
+ disablePortal: disablePortal,
191
+ children: /*#__PURE__*/_jsxs(RootSlot, _extends({}, rootProps, {
192
+ children: [!hideBackdrop && BackdropComponent ? /*#__PURE__*/_jsx(BackdropSlot, _extends({}, backdropProps)) : null, /*#__PURE__*/_jsx(FocusTrap, {
193
+ disableEnforceFocus: disableEnforceFocus,
194
+ disableAutoFocus: disableAutoFocus,
195
+ disableRestoreFocus: disableRestoreFocus,
196
+ isEnabled: isTopModal,
197
+ open: open,
198
+ children: /*#__PURE__*/React.cloneElement(children, childProps)
199
+ })]
200
+ }))
201
+ });
141
202
  });
142
203
  process.env.NODE_ENV !== "production" ? Modal.propTypes /* remove-proptypes */ = {
143
204
  // ----------------------------- Warning --------------------------------
package/Modal/index.d.ts CHANGED
@@ -2,3 +2,6 @@ export { ModalManager } from '@mui/base/unstable_useModal'; // exporting ModalMa
2
2
 
3
3
  export { default } from './Modal';
4
4
  export * from './Modal';
5
+
6
+ export { default as modalClasses } from './modalClasses';
7
+ export * from './modalClasses';
package/Modal/index.js CHANGED
@@ -2,4 +2,5 @@
2
2
 
3
3
  export { ModalManager } from '@mui/base/unstable_useModal';
4
4
  export { default } from './Modal';
5
- export * from './Modal';
5
+ export { default as modalClasses } from './modalClasses';
6
+ export * from './modalClasses';
@@ -0,0 +1,12 @@
1
+ export interface ModalClasses {
2
+ /** Class name applied to the root element. */
3
+ root: string;
4
+ /** Class name applied to the root element if the `Modal` has exited. */
5
+ hidden: string;
6
+ /** Class name applied to the backdrop element. */
7
+ backdrop: string;
8
+ }
9
+ export type ModalClassKey = keyof ModalClasses;
10
+ export declare function getModalUtilityClass(slot: string): string;
11
+ declare const modalClasses: ModalClasses;
12
+ export default modalClasses;
@@ -0,0 +1,7 @@
1
+ import { unstable_generateUtilityClasses as generateUtilityClasses } from '@mui/utils';
2
+ import generateUtilityClass from '../generateUtilityClass';
3
+ export function getModalUtilityClass(slot) {
4
+ return generateUtilityClass('MuiModal', slot);
5
+ }
6
+ const modalClasses = generateUtilityClasses('MuiModal', ['root', 'hidden', 'backdrop']);
7
+ export default modalClasses;
package/README.md CHANGED
@@ -28,7 +28,7 @@
28
28
  [![Follow on Twitter](https://img.shields.io/twitter/follow/MUI_hq.svg?label=follow+MUI)](https://twitter.com/MUI_hq)
29
29
  [![Renovate status](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://github.com/mui/material-ui/issues/27062)
30
30
  [![Average time to resolve an issue](https://isitmaintained.com/badge/resolution/mui/material-ui.svg)](https://isitmaintained.com/project/mui/material-ui 'Average time to resolve an issue')
31
- [![Open Collective backers and sponsors](https://img.shields.io/opencollective/all/mui)](https://opencollective.com/mui)
31
+ [![Open Collective backers and sponsors](https://img.shields.io/opencollective/all/mui)](https://opencollective.com/mui)
32
32
  [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/1320/badge)](https://bestpractices.coreinfrastructure.org/projects/1320)
33
33
 
34
34
  </div>
@@ -121,14 +121,13 @@ Visit our [`styled-engine` guide](https://mui.com/material-ui/guides/styled-engi
121
121
  <p>
122
122
  <a href="https://octopus.com/?utm_source=MUI&utm_medium=referral&utm_content=readme" rel="noopener sponsored" target="_blank"><img height="128" width="128" src="https://i.ibb.co/w0HF0Nz/Logo-Blue-140px-rgb.png" alt="octopus" title="Repeatable, reliable deployments" loading="lazy" /></a>
123
123
  <a href="https://www.doit.com/flexsave/?utm_source=MUI&utm_medium=referral&utm_content=readme" rel="noopener sponsored" target="_blank"><img height="128" width="128" src="https://avatars.githubusercontent.com/u/8424863?s=256" alt="doit" title="Management Platform for Google Cloud and AWS" loading="lazy" /></a>
124
- <a href="https://www.zesty.io/integrations/mui-nextjs/?utm_source=mui&utm_medium=referral&utm_campaign=sponsor" rel="noopener sponsored" target="_blank"><img height="90" width="90" src="https://brand.zesty.io/zesty-io-logo.svg" alt="zesty.io" title="The only Next.js CMS you need" loading="lazy" /></a>
125
124
  </p>
126
125
 
127
126
  Diamond Sponsors are those who have pledged \$1,500/month or more to MUI.
128
127
 
129
128
  ### Gold 🏆
130
129
 
131
- via [OpenCollective](https://opencollective.com/mui) or via [Patreon](https://www.patreon.com/oliviertassinari)
130
+ via [Open Collective](https://opencollective.com/mui) or via [Patreon](https://www.patreon.com/oliviertassinari)
132
131
 
133
132
  <p>
134
133
  <a href="https://tidelift.com/subscription/pkg/npm-material-ui?utm_source=npm-material-ui&utm_medium=referral&utm_campaign=homepage" rel="noopener sponsored" target="_blank"><img height="96" width="96" src="https://avatars.githubusercontent.com/u/30204434?s=192" alt="tidelift.com" title="Enterprise-ready open-source software" loading="lazy" /></a>
package/Select/Select.js CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
- const _excluded = ["autoWidth", "children", "classes", "className", "defaultOpen", "displayEmpty", "IconComponent", "id", "input", "inputProps", "label", "labelId", "MenuProps", "multiple", "native", "onClose", "onOpen", "open", "renderValue", "SelectDisplayProps", "variant"];
5
+ const _excluded = ["autoWidth", "children", "classes", "className", "defaultOpen", "displayEmpty", "IconComponent", "id", "input", "inputProps", "label", "labelId", "MenuProps", "multiple", "native", "onClose", "onOpen", "open", "renderValue", "SelectDisplayProps", "variant"],
6
+ _excluded2 = ["root"];
6
7
  import * as React from 'react';
7
8
  import PropTypes from 'prop-types';
8
9
  import clsx from 'clsx';
@@ -76,6 +77,7 @@ const Select = /*#__PURE__*/React.forwardRef(function Select(inProps, ref) {
76
77
  classes: classesProp
77
78
  });
78
79
  const classes = useUtilityClasses(ownerState);
80
+ const restOfClasses = _objectWithoutPropertiesLoose(classes, _excluded2);
79
81
  const InputComponent = input || {
80
82
  standard: /*#__PURE__*/_jsx(StyledInput, {
81
83
  ownerState: ownerState
@@ -118,13 +120,13 @@ const Select = /*#__PURE__*/React.forwardRef(function Select(inProps, ref) {
118
120
  id
119
121
  }, SelectDisplayProps)
120
122
  }, inputProps, {
121
- classes: inputProps ? deepmerge(classes, inputProps.classes) : classes
123
+ classes: inputProps ? deepmerge(restOfClasses, inputProps.classes) : restOfClasses
122
124
  }, input ? input.props.inputProps : {})
123
125
  }, multiple && native && variant === 'outlined' ? {
124
126
  notched: true
125
127
  } : {}, {
126
128
  ref: inputComponentRef,
127
- className: clsx(InputComponent.props.className, className)
129
+ className: clsx(InputComponent.props.className, className, classes.root)
128
130
  }, !input && {
129
131
  variant
130
132
  }, other))
@@ -1,4 +1,6 @@
1
1
  export interface SelectClasses {
2
+ /** Styles applied to the root element. */
3
+ root: string;
2
4
  /** Styles applied to the select component `select` class. */
3
5
  select: string;
4
6
  /** Styles applied to the select component if `multiple={true}`. */
@@ -3,5 +3,5 @@ import generateUtilityClass from '../generateUtilityClass';
3
3
  export function getSelectUtilityClasses(slot) {
4
4
  return generateUtilityClass('MuiSelect', slot);
5
5
  }
6
- const selectClasses = generateUtilityClasses('MuiSelect', ['select', 'multiple', 'filled', 'outlined', 'standard', 'disabled', 'focused', 'icon', 'iconOpen', 'iconFilled', 'iconOutlined', 'iconStandard', 'nativeInput', 'error']);
6
+ const selectClasses = generateUtilityClasses('MuiSelect', ['root', 'select', 'multiple', 'filled', 'outlined', 'standard', 'disabled', 'focused', 'icon', 'iconOpen', 'iconFilled', 'iconOutlined', 'iconStandard', 'nativeInput', 'error']);
7
7
  export default selectClasses;