@mui/material 5.14.5 → 5.14.7

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 (61) hide show
  1. package/CHANGELOG.md +163 -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/Popover/Popover.d.ts +2 -1
  12. package/Popover/Popover.js +20 -6
  13. package/README.md +2 -3
  14. package/Select/Select.js +5 -3
  15. package/Select/selectClasses.d.ts +2 -0
  16. package/Select/selectClasses.js +1 -1
  17. package/Skeleton/Skeleton.js +2 -2
  18. package/Snackbar/Snackbar.d.ts +4 -4
  19. package/Snackbar/Snackbar.js +4 -4
  20. package/TextField/TextField.d.ts +0 -4
  21. package/TextField/TextField.js +2 -17
  22. package/index.js +1 -1
  23. package/legacy/Drawer/Drawer.js +2 -0
  24. package/legacy/InputBase/InputBase.js +1 -1
  25. package/legacy/Modal/Modal.js +93 -43
  26. package/legacy/Modal/index.js +2 -1
  27. package/legacy/Modal/modalClasses.js +7 -0
  28. package/legacy/Popover/Popover.js +22 -5
  29. package/legacy/Select/Select.js +4 -2
  30. package/legacy/Select/selectClasses.js +1 -1
  31. package/legacy/Skeleton/Skeleton.js +2 -2
  32. package/legacy/Snackbar/Snackbar.js +4 -4
  33. package/legacy/TextField/TextField.js +2 -17
  34. package/legacy/index.js +1 -1
  35. package/modern/Drawer/Drawer.js +2 -0
  36. package/modern/InputBase/InputBase.js +1 -1
  37. package/modern/Modal/Modal.js +97 -36
  38. package/modern/Modal/index.js +2 -1
  39. package/modern/Modal/modalClasses.js +7 -0
  40. package/modern/Popover/Popover.js +20 -6
  41. package/modern/Select/Select.js +5 -3
  42. package/modern/Select/selectClasses.js +1 -1
  43. package/modern/Skeleton/Skeleton.js +2 -2
  44. package/modern/Snackbar/Snackbar.js +4 -4
  45. package/modern/TextField/TextField.js +2 -17
  46. package/modern/index.js +1 -1
  47. package/node/Drawer/Drawer.js +2 -0
  48. package/node/InputBase/InputBase.js +1 -1
  49. package/node/Modal/Modal.js +100 -41
  50. package/node/Modal/index.js +14 -5
  51. package/node/Modal/modalClasses.js +16 -0
  52. package/node/Popover/Popover.js +20 -6
  53. package/node/Select/Select.js +5 -3
  54. package/node/Select/selectClasses.js +1 -1
  55. package/node/Skeleton/Skeleton.js +2 -2
  56. package/node/Snackbar/Snackbar.js +4 -4
  57. package/node/TextField/TextField.js +2 -17
  58. package/node/index.js +1 -1
  59. package/package.json +6 -6
  60. package/umd/material-ui.development.js +456 -657
  61. package/umd/material-ui.production.min.js +23 -23
package/CHANGELOG.md CHANGED
@@ -1,5 +1,165 @@
1
1
  # [Versions](https://mui.com/versions/)
2
2
 
3
+ ## 5.14.7
4
+
5
+ <!-- generated comparing v5.14.6..master -->
6
+
7
+ _Aug 29, 2023_
8
+
9
+ A big thanks to the 11 contributors who made this release possible. This release focuses primarily on 🐛 bug fixes, 📚 documentation, and ⚙️ infrastructure improvements.
10
+
11
+ ### `@mui/material@5.14.7`
12
+
13
+ - &#8203;<!-- 17 -->[Autocomplete] Fix listbox opened unexpectedly when component is `disabled` (#38611) @mj12albert
14
+ - &#8203;<!-- 03 -->[Select][material-ui] Fix select menu moving on scroll when disableScrollLock is true (#37773) @VishruthR
15
+
16
+ ### `@mui/base@5.0.0-beta.13`
17
+
18
+ - &#8203;<!-- 16 -->[useButton][base-ui] Accept arbitrary props in getRootProps and forward them (#38475) @DiegoAndai
19
+
20
+ ### `@mui/zero-runtime@0.0.1-alpha.1`
21
+
22
+ - &#8203;<!-- 02 -->[system][zero][tag] Add support for sx prop (#38535) @brijeshb42
23
+
24
+ ### Docs
25
+
26
+ - &#8203;<!-- 10 -->[docs] Number Input docs fixes (#38521) @mj12albert
27
+ - &#8203;<!-- 09 -->[docs] Show all the code in the usage section (#38691) @oliviertassinari
28
+ - &#8203;<!-- 06 -->[docs][joy-ui] Change the customization and how-to guides docs tree (#38396) @danilo-leal
29
+ - &#8203;<!-- 05 -->[docs][lab][LoadingButton] Improve `loading` prop documentation (#38625) @sai6855
30
+ - &#8203;<!-- 04 -->[docs][material-ui] Format `key` prop JSDoc description in `Snackbar` component code correctly (#38603) @jaydenseric
31
+
32
+ ### Core
33
+
34
+ - &#8203;<!-- 15 -->[core] Add use-client to custom icons (#38132) @mj12albert
35
+ - &#8203;<!-- 14 -->[core] Remove unnecessary `@types/jsdom` (#38657) @renovate[bot]
36
+ - &#8203;<!-- 13 -->[core] Improve sponsors GA labels (#38649) @oliviertassinari
37
+ - &#8203;<!-- 12 -->[core] Fix ESM issues with regression tests (#37963) @Janpot
38
+ - &#8203;<!-- 11 -->[core] Potential fix for intermittent ci crashes in e2e test (#38614) @Janpot
39
+ - &#8203;<!-- 08 -->[docs-infra] Adjust the Material You playground demo design (#38636) @danilo-leal
40
+ - &#8203;<!-- 07 -->[docs-infra] Hide the SkipLink button if user prefers reduced motion (#38632) @DerTimonius
41
+ - &#8203;<!-- 01 -->[website] Add tiny fixes the homepage Sponsors section (#38635) @danilo-leal
42
+
43
+ All contributors of this release in alphabetical order: @brijeshb42, @danilo-leal, @DerTimonius, @DiegoAndai, @Janpot, @jaydenseric, @mj12albert, @oliviertassinari, @renovate[bot], @sai6855, @VishruthR
44
+
45
+ ## 5.14.6
46
+
47
+ <!-- generated comparing v5.14.5..master -->
48
+
49
+ _Aug 23, 2023_
50
+
51
+ A big thanks to the 21 contributors who made this release possible. Here are some highlights ✨:
52
+
53
+ - 🚀 Added the [Popup](https://mui.com/base-ui/react-popup/) component to Base UI (#37960) @michaldudak
54
+ 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.
55
+ - 🚀 Added the [Accordion](https://mui.com/joy-ui/react-accordion/) component to Joy UI (#38164) @siriwatknp
56
+ - 🚀 Added InputBase and ButtonBase components to `material-next` (#38319) @DiegoAndai @mj12albert
57
+ - 🔋 First iteration on the zero-runtime styling engine compatible with Server Components (#38378) @brijeshb42
58
+
59
+ ### `@mui/material@5.14.6`
60
+
61
+ - [Modal] Update it to use the useModal hook (#38498) @mnajdova
62
+ - [Select] Add `root` class to `SelectClasses` (#38424) @sai6855
63
+ - [Skeleton] Soften the pulse animation (#38506) @oliviertassinari
64
+ - [TextField] Fix onClick regressions handling changes (#38474) @mj12albert
65
+ - [TextField] Fix TextField onClick test (#38597) @mj12albert
66
+
67
+ ### `@mui/base@5.0.0-beta.12`
68
+
69
+ - [Popup] New component (#37960) @michaldudak
70
+
71
+ ### `@mui/joy@5.0.0-beta.3`
72
+
73
+ - [Accordion] Add Joy UI Accordion components (#38164) @siriwatknp
74
+ - [Select] Add `required` prop (#38167) @siriwatknp
75
+ - Miscellaneous fixes (#38462) @siriwatknp
76
+
77
+ ### `@mui/material-next@6.0.0-alpha.98`
78
+
79
+ - [ButtonBase] Add ButtonBase component (#38319) @DiegoAndai
80
+ - [Input] Add InputBase component (#38392) @mj12albert
81
+
82
+ ### `@mui/zero-runtime@0.0.1-alpha.0`
83
+
84
+ - Implementation of styled tag processor for linaria (#38378) @brijeshb42
85
+
86
+ ### Docs
87
+
88
+ - [blog] Clarify tree view move @oliviertassinari
89
+ - [docs] Improve the "Understanding MUI packages" page images (#38619) @danilo-leal
90
+ - [docs][base-ui] Revise the structure of the Component docs (#38529) @samuelsycamore
91
+ - [docs][base-ui] Fix Menu Hooks demo (#38479) @homerchen19
92
+ - [docs][base-ui] Correct the MUI System quickstart example (#38496) @michaldudak
93
+ - [docs][base-ui] Add Tailwind & plain CSS demos for Autocomplete page (#38157) @mj12albert
94
+ - [docs][base-ui] Add Tailwind CSS + plain CSS demo on the Input page (#38302) @alisasanib
95
+ - [docs][base-ui] Add Tailwind CSS + plain CSS demo on the Snackbar, Badge, Switch pages (#38425) @alisasanib
96
+ - [docs][base-ui] Add Tailwind CSS + plain CSS demo on the Slider page (#38413) @alisasanib
97
+ - [docs][base-ui] Add Tailwind CSS + plain CSS demo on the Select page (#38367) @alisasanib
98
+ - [docs][joy-ui] Fix typo: Classname -> Class name for consistency (#38510) @alexfauquette
99
+ - [docs][joy-ui] Revise the theme color page (#38402) @danilo-leal
100
+ - [docs][joy-ui] Sort templates by popularity (#38490) @oliviertassinari
101
+ - [docs][joy-ui] Fix the `fullWidth` prop description for the Input (#38545) @0xturner
102
+ - [docs][joy-ui] Updated the List playground demo (#38499) @zanivan
103
+ - [docs][joy-ui] Changed bgcolor of the Playground demo (#38502) @zanivan
104
+ - [docs][material-ui] Fix key warning in SimpleDialog demo (#38580) @ZeeshanTamboli
105
+ - [docs][material-ui] Fixed Google Fonts link for material two-tone icons in CodeSandbox and Stackblitz (#38247) @ZeeshanTamboli
106
+ - [docs][material-ui] Fix the Drawer's `onClose` API docs (#38273) @johnmatthiggins
107
+ - [docs][material-ui] Improve nav link tab example (#38315) @oliviertassinari
108
+ - [docs][material-ui] Fix missing import in the styled engine guide (#38450) @codersjj
109
+ - [docs][material-ui][Dialog] Improve screen reader announcement of Customized Dialog (#38592) @ZeeshanTamboli
110
+ - [docs] Add 3rd party libraries integration examples for Joy Input (#38541) @siriwatknp
111
+ - [docs] Hide translation call to action (#38449) @cristianmacedo
112
+ - [docs] Fix codemod name in changelog of v5.14.4 (#38593) @GresilleSiffle
113
+ - [docs] More space for theme builder (#38532) @oliviertassinari
114
+ - [docs] Fix the math symbol of the width sx prop range @oliviertassinari
115
+ - [docs] Fix typo on a11y section of Tabs @oliviertassinari
116
+ - [docs] Clarify System peer dependencies @oliviertassinari
117
+ - [docs] Fix horizontal scrollbar @oliviertassinari
118
+ - [docs] Code style convention @oliviertassinari
119
+ - [docs] Fix typo in Base UI @oliviertassinari
120
+ - [docs] Update the backers page (#38505) @danilo-leal
121
+ - [docs] Add stray design adjustments to the docs (#38501) @danilo-leal
122
+ - [docs] Use IBM Plex Sans in Tailwind CSS demos (#38464) @mnajdova
123
+ - [docs] Fix SEO issues reported by ahrefs (#38423) @oliviertassinari
124
+
125
+ ### Examples
126
+
127
+ - [examples] Start to remove Gatsby (#38567) @oliviertassinari
128
+ - [examples][joy-ui] Fix Joy UI example CLI (#38531) @oliviertassinari
129
+ - [examples][joy-ui] Improve example when using Next Font (#38540) @mwskwong
130
+
131
+ ### Core
132
+
133
+ - [CHANGELOG] Fix issues in highlight @oliviertassinari
134
+ - [core] Remove redundant `@material-ui/` aliases from regression test webpack config (#38574) @ZeeshanTamboli
135
+ - [core] Fix CI error @oliviertassinari
136
+ - [core] Remove unnecessary Box (#38461) @oliviertassinari
137
+ - [core] Set GitHub Action top level permission @oliviertassinari
138
+ - [docs-infra][joy-ui] Polish the usage and CSS vars playgrounds (#38600) @danilo-leal
139
+ - [docs-infra] Support link title (#38579) @oliviertassinari
140
+ - [docs-infra] Fix ad layout shift (#38622) @oliviertassinari
141
+ - [docs-infra] Add light tweaks to the ad container (#38504) @danilo-leal
142
+ - [docs-infra] Fix anchor scroll without tabs (#38586) @oliviertassinari
143
+ - [docs-infra] Retain velocity animation speed (#38470) @oliviertassinari
144
+ - [docs-infra] Follow import and CSS token standard (#38508) @oliviertassinari
145
+ - [docs-infra] Add icon to callouts (#38525) @alexfauquette
146
+ - [docs-infra] Fix the anchor link on headings (#38528) @danilo-leal
147
+ - [docs-infra] Cleanup code on demo code block expansion (#38522) @ZeeshanTamboli
148
+ - [docs-infra] Improve the heading buttons positioning (#38428) @danilo-leal
149
+ - [docs-infra] Customize the blockquote design (#38503) @danilo-leal
150
+ - [docs-infra] Improve the alert before a negative feedback (#38500) @danilo-leal
151
+ - [docs-infra] Fix GoogleAnalytics missing event for code copy (#38469) @alexfauquette
152
+ - [docs-infra] Improve affordance on the code block expansion (#38421) @danilo-leal
153
+ - [website] Fine-tune the branding theme buttons (#38588) @danilo-leal
154
+ - [website] Improve the Base UI hero section demo (#38585) @danilo-leal
155
+ - [website] Add stray design improvements to the Material UI page (#38590) @danilo-leal
156
+ - [website] Fix mobile view Material UI page (#38568) @oliviertassinari
157
+ - [website] Fix reference to the data grid @oliviertassinari
158
+ - [website] Configure Apple Pay @oliviertassinari
159
+ - [website] Fix template link on the homepage (#38471) @danilo-leal
160
+
161
+ 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
162
+
3
163
  ## 5.14.5
4
164
 
5
165
  <!-- generated comparing v5.14.4..master -->
@@ -78,7 +238,7 @@ _Aug 8, 2023_
78
238
 
79
239
  A big thanks to the 18 contributors who made this release possible. Here are some highlights ✨:
80
240
 
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
241
+ - 🎉 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
242
 
83
243
  ### `@mui/material@5.14.4`
84
244
 
@@ -116,7 +276,7 @@ A big thanks to the 18 contributors who made this release possible. Here are som
116
276
  A codemod is provided to help with the migration:
117
277
 
118
278
  ```bash
119
- npx @mui/codemod v5.0.0/base-use-named-imports <path>
279
+ npx @mui/codemod v5.0.0/base-use-named-exports <path>
120
280
  ```
121
281
 
122
282
  #### Changes
@@ -5736,7 +5896,7 @@ A big thanks to the 16 contributors who made this release possible. Here are som
5736
5896
 
5737
5897
  ### Core
5738
5898
 
5739
- - &#8203;<!-- 23 -->[core] Fix link to Open Collective @oliviertassinari
5899
+ - &#8203;<!-- 23 -->[core] Fix link to Open Collective @oliviertassinari
5740
5900
  - &#8203;<!-- 26 -->[core] Update snapshots and s3 fallback (#30134) @Janpot
5741
5901
  - &#8203;<!-- 24 -->[ci] Update CI bucket (#30080) @Janpot
5742
5902
  - &#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;
@@ -91,9 +91,10 @@ export interface PopoverProps
91
91
  elevation?: number;
92
92
  /**
93
93
  * Specifies how close to the edge of the window the popover can appear.
94
+ * If null, the popover will not be constrained by the window.
94
95
  * @default 16
95
96
  */
96
- marginThreshold?: number;
97
+ marginThreshold?: number | null;
97
98
  onClose?: ModalProps['onClose'];
98
99
  /**
99
100
  * If `true`, the component is shown.