@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
@@ -105,7 +105,7 @@ const SkeletonRoot = styled('span', {
105
105
  }, ({
106
106
  ownerState
107
107
  }) => ownerState.animation === 'pulse' && css(_t3 || (_t3 = _`
108
- animation: ${0} 1.5s ease-in-out 0.5s infinite;
108
+ animation: ${0} 2s ease-in-out 0.5s infinite;
109
109
  `), pulseKeyframe), ({
110
110
  ownerState,
111
111
  theme
@@ -117,7 +117,7 @@ const SkeletonRoot = styled('span', {
117
117
  -webkit-mask-image: -webkit-radial-gradient(white, black);
118
118
 
119
119
  &::after {
120
- animation: ${0} 1.6s linear 0.5s infinite;
120
+ animation: ${0} 2s linear 0.5s infinite;
121
121
  background: linear-gradient(
122
122
  90deg,
123
123
  transparent,
@@ -111,10 +111,6 @@ export interface BaseTextFieldProps
111
111
  name?: string;
112
112
  onBlur?: InputBaseProps['onBlur'];
113
113
  onFocus?: StandardInputProps['onFocus'];
114
- /**
115
- * @ignore
116
- */
117
- onClick?: InputBaseProps['onClick'];
118
114
  /**
119
115
  * The short hint displayed in the `input` before the user enters a value.
120
116
  */
@@ -2,7 +2,7 @@
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 = ["autoComplete", "autoFocus", "children", "className", "color", "defaultValue", "disabled", "error", "FormHelperTextProps", "fullWidth", "helperText", "id", "InputLabelProps", "inputProps", "InputProps", "inputRef", "label", "maxRows", "minRows", "multiline", "name", "onBlur", "onChange", "onClick", "onFocus", "placeholder", "required", "rows", "select", "SelectProps", "type", "value", "variant"];
5
+ const _excluded = ["autoComplete", "autoFocus", "children", "className", "color", "defaultValue", "disabled", "error", "FormHelperTextProps", "fullWidth", "helperText", "id", "InputLabelProps", "inputProps", "InputProps", "inputRef", "label", "maxRows", "minRows", "multiline", "name", "onBlur", "onChange", "onFocus", "placeholder", "required", "rows", "select", "SelectProps", "type", "value", "variant"];
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import clsx from 'clsx';
@@ -101,7 +101,6 @@ const TextField = /*#__PURE__*/React.forwardRef(function TextField(inProps, ref)
101
101
  name,
102
102
  onBlur,
103
103
  onChange,
104
- onClick,
105
104
  onFocus,
106
105
  placeholder,
107
106
  required = false,
@@ -144,14 +143,6 @@ const TextField = /*#__PURE__*/React.forwardRef(function TextField(inProps, ref)
144
143
  }
145
144
  InputMore['aria-describedby'] = undefined;
146
145
  }
147
- const handleClick = event => {
148
- if (!disabled && onClick) {
149
- // The `onClick` is registered both on the root and the input elements.
150
- // Without stopping the propagation, the event could be triggered twice.
151
- event.stopPropagation();
152
- onClick(event);
153
- }
154
- };
155
146
  const id = useId(idOverride);
156
147
  const helperTextId = helperText && id ? `${id}-helper-text` : undefined;
157
148
  const inputLabelId = label && id ? `${id}-label` : undefined;
@@ -174,7 +165,6 @@ const TextField = /*#__PURE__*/React.forwardRef(function TextField(inProps, ref)
174
165
  onBlur: onBlur,
175
166
  onChange: onChange,
176
167
  onFocus: onFocus,
177
- onClick: handleClick,
178
168
  placeholder: placeholder,
179
169
  inputProps: inputProps
180
170
  }, InputMore, InputProps));
@@ -187,8 +177,7 @@ const TextField = /*#__PURE__*/React.forwardRef(function TextField(inProps, ref)
187
177
  required: required,
188
178
  color: color,
189
179
  variant: variant,
190
- ownerState: ownerState,
191
- onClick: handleClick
180
+ ownerState: ownerState
192
181
  }, other, {
193
182
  children: [label != null && label !== '' && /*#__PURE__*/_jsx(InputLabel, _extends({
194
183
  htmlFor: id,
@@ -334,10 +323,6 @@ process.env.NODE_ENV !== "production" ? TextField.propTypes /* remove-proptypes
334
323
  * You can pull out the new value by accessing `event.target.value` (string).
335
324
  */
336
325
  onChange: PropTypes.func,
337
- /**
338
- * @ignore
339
- */
340
- onClick: PropTypes.func,
341
326
  /**
342
327
  * @ignore
343
328
  */
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/material v5.14.5
2
+ * @mui/material v5.14.6
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -265,8 +265,10 @@ process.env.NODE_ENV !== "production" ? Drawer.propTypes /* remove-proptypes */
265
265
  ModalProps: PropTypes.object,
266
266
  /**
267
267
  * Callback fired when the component requests to be closed.
268
+ * The `reason` parameter can optionally be used to control the response to `onClose`.
268
269
  *
269
270
  * @param {object} event The event source of the callback.
271
+ * @param {string} reason Can be: `"escapeKeyDown"`, `"backdropClick"`.
270
272
  */
271
273
  onClose: PropTypes.func,
272
274
  /**
@@ -377,7 +377,7 @@ var InputBase = /*#__PURE__*/React.forwardRef(function InputBase(inProps, ref) {
377
377
  if (inputRef.current && event.currentTarget === event.target) {
378
378
  inputRef.current.focus();
379
379
  }
380
- if (onClick && !fcs.disabled) {
380
+ if (onClick) {
381
381
  onClick(event);
382
382
  }
383
383
  };
@@ -5,14 +5,28 @@ import _extends from "@babel/runtime/helpers/esm/extends";
5
5
  import * as React from 'react';
6
6
  import PropTypes from 'prop-types';
7
7
  import clsx from 'clsx';
8
- import { Modal as ModalUnstyled, modalClasses as modalUnstyledClasses } from '@mui/base/Modal';
9
- import { isHostComponent, resolveComponentProps } from '@mui/base/utils';
10
8
  import { elementAcceptingRef, HTMLElementType } from '@mui/utils';
9
+ import { useSlotProps } from '@mui/base';
10
+ import { unstable_useModal as useModal } from '@mui/base/unstable_useModal';
11
+ import { unstable_composeClasses as composeClasses } from '@mui/base/composeClasses';
12
+ import FocusTrap from '../Unstable_TrapFocus';
13
+ import Portal from '../Portal';
11
14
  import styled from '../styles/styled';
12
15
  import useThemeProps from '../styles/useThemeProps';
13
16
  import Backdrop from '../Backdrop';
17
+ import { getModalUtilityClass } from './modalClasses';
14
18
  import { jsx as _jsx } from "react/jsx-runtime";
15
- export var modalClasses = modalUnstyledClasses;
19
+ import { jsxs as _jsxs } from "react/jsx-runtime";
20
+ var useUtilityClasses = function useUtilityClasses(ownerState) {
21
+ var open = ownerState.open,
22
+ exited = ownerState.exited,
23
+ classes = ownerState.classes;
24
+ var slots = {
25
+ root: ['root', !open && exited && 'hidden'],
26
+ backdrop: ['backdrop']
27
+ };
28
+ return composeClasses(slots, getModalUtilityClass, classes);
29
+ };
16
30
  var ModalRoot = styled('div', {
17
31
  name: 'MuiModal',
18
32
  slot: 'Root',
@@ -66,7 +80,7 @@ var Modal = /*#__PURE__*/React.forwardRef(function Modal(inProps, ref) {
66
80
  var _props$BackdropCompon = props.BackdropComponent,
67
81
  BackdropComponent = _props$BackdropCompon === void 0 ? ModalBackdrop : _props$BackdropCompon,
68
82
  BackdropProps = props.BackdropProps,
69
- classes = props.classes,
83
+ classesProp = props.classes,
70
84
  className = props.className,
71
85
  _props$closeAfterTran = props.closeAfterTransition,
72
86
  closeAfterTransition = _props$closeAfterTran === void 0 ? false : _props$closeAfterTran,
@@ -100,11 +114,7 @@ var Modal = /*#__PURE__*/React.forwardRef(function Modal(inProps, ref) {
100
114
  slots = props.slots,
101
115
  theme = props.theme,
102
116
  other = _objectWithoutProperties(props, ["BackdropComponent", "BackdropProps", "classes", "className", "closeAfterTransition", "children", "container", "component", "components", "componentsProps", "disableAutoFocus", "disableEnforceFocus", "disableEscapeKeyDown", "disablePortal", "disableRestoreFocus", "disableScrollLock", "hideBackdrop", "keepMounted", "onBackdropClick", "onClose", "open", "slotProps", "slots", "theme"]);
103
- var _React$useState = React.useState(true),
104
- exited = _React$useState[0],
105
- setExited = _React$useState[1];
106
- var commonProps = {
107
- container: container,
117
+ var propsWithDefaults = _extends({}, props, {
108
118
  closeAfterTransition: closeAfterTransition,
109
119
  disableAutoFocus: disableAutoFocus,
110
120
  disableEnforceFocus: disableEnforceFocus,
@@ -113,48 +123,88 @@ var Modal = /*#__PURE__*/React.forwardRef(function Modal(inProps, ref) {
113
123
  disableRestoreFocus: disableRestoreFocus,
114
124
  disableScrollLock: disableScrollLock,
115
125
  hideBackdrop: hideBackdrop,
116
- keepMounted: keepMounted,
117
- onBackdropClick: onBackdropClick,
118
- onClose: onClose,
119
- open: open
120
- };
121
- var ownerState = _extends({}, props, commonProps, {
126
+ keepMounted: keepMounted
127
+ });
128
+ var _useModal = useModal(_extends({}, propsWithDefaults, {
129
+ rootRef: ref
130
+ })),
131
+ getRootProps = _useModal.getRootProps,
132
+ getBackdropProps = _useModal.getBackdropProps,
133
+ getTransitionProps = _useModal.getTransitionProps,
134
+ portalRef = _useModal.portalRef,
135
+ isTopModal = _useModal.isTopModal,
136
+ exited = _useModal.exited,
137
+ hasTransition = _useModal.hasTransition;
138
+ var ownerState = _extends({}, propsWithDefaults, {
122
139
  exited: exited
123
140
  });
141
+ var classes = useUtilityClasses(ownerState);
142
+ var childProps = {};
143
+ if (children.props.tabIndex === undefined) {
144
+ childProps.tabIndex = '-1';
145
+ }
146
+
147
+ // It's a Transition like component
148
+ if (hasTransition) {
149
+ var _getTransitionProps = getTransitionProps(),
150
+ onEnter = _getTransitionProps.onEnter,
151
+ onExited = _getTransitionProps.onExited;
152
+ childProps.onEnter = onEnter;
153
+ childProps.onExited = onExited;
154
+ }
124
155
  var RootSlot = (_ref2 = (_slots$root = slots == null ? void 0 : slots.root) != null ? _slots$root : components.Root) != null ? _ref2 : ModalRoot;
125
156
  var BackdropSlot = (_ref3 = (_slots$backdrop = slots == null ? void 0 : slots.backdrop) != null ? _slots$backdrop : components.Backdrop) != null ? _ref3 : BackdropComponent;
126
157
  var rootSlotProps = (_slotProps$root = slotProps == null ? void 0 : slotProps.root) != null ? _slotProps$root : componentsProps.root;
127
158
  var backdropSlotProps = (_slotProps$backdrop = slotProps == null ? void 0 : slotProps.backdrop) != null ? _slotProps$backdrop : componentsProps.backdrop;
128
- return /*#__PURE__*/_jsx(ModalUnstyled, _extends({
129
- slots: {
130
- root: RootSlot,
131
- backdrop: BackdropSlot
132
- },
133
- slotProps: {
134
- root: function root() {
135
- return _extends({}, resolveComponentProps(rootSlotProps, ownerState), !isHostComponent(RootSlot) && {
136
- as: component,
137
- theme: theme
138
- }, {
139
- 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))
140
- });
141
- },
142
- backdrop: function backdrop() {
143
- return _extends({}, BackdropProps, resolveComponentProps(backdropSlotProps, ownerState), {
144
- className: clsx(backdropSlotProps == null ? void 0 : backdropSlotProps.className, BackdropProps == null ? void 0 : BackdropProps.className, classes == null ? void 0 : classes.backdrop)
145
- });
146
- }
159
+ var rootProps = useSlotProps({
160
+ elementType: RootSlot,
161
+ externalSlotProps: rootSlotProps,
162
+ externalForwardedProps: other,
163
+ getSlotProps: getRootProps,
164
+ additionalProps: {
165
+ ref: ref,
166
+ as: component
147
167
  },
148
- onTransitionEnter: function onTransitionEnter() {
149
- return setExited(false);
150
- },
151
- onTransitionExited: function onTransitionExited() {
152
- return setExited(true);
168
+ ownerState: ownerState,
169
+ 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))
170
+ });
171
+ var backdropProps = useSlotProps({
172
+ elementType: BackdropSlot,
173
+ externalSlotProps: backdropSlotProps,
174
+ additionalProps: BackdropProps,
175
+ getSlotProps: function getSlotProps(otherHandlers) {
176
+ return getBackdropProps(_extends({}, otherHandlers, {
177
+ onClick: function onClick(e) {
178
+ if (onBackdropClick) {
179
+ onBackdropClick(e);
180
+ }
181
+ if (otherHandlers != null && otherHandlers.onClick) {
182
+ otherHandlers.onClick(e);
183
+ }
184
+ }
185
+ }));
153
186
  },
154
- ref: ref
155
- }, other, commonProps, {
156
- children: children
157
- }));
187
+ className: clsx(backdropSlotProps == null ? void 0 : backdropSlotProps.className, BackdropProps == null ? void 0 : BackdropProps.className, classes == null ? void 0 : classes.backdrop),
188
+ ownerState: ownerState
189
+ });
190
+ if (!keepMounted && !open && (!hasTransition || exited)) {
191
+ return null;
192
+ }
193
+ return /*#__PURE__*/_jsx(Portal, {
194
+ ref: portalRef,
195
+ container: container,
196
+ disablePortal: disablePortal,
197
+ children: /*#__PURE__*/_jsxs(RootSlot, _extends({}, rootProps, {
198
+ children: [!hideBackdrop && BackdropComponent ? /*#__PURE__*/_jsx(BackdropSlot, _extends({}, backdropProps)) : null, /*#__PURE__*/_jsx(FocusTrap, {
199
+ disableEnforceFocus: disableEnforceFocus,
200
+ disableAutoFocus: disableAutoFocus,
201
+ disableRestoreFocus: disableRestoreFocus,
202
+ isEnabled: isTopModal,
203
+ open: open,
204
+ children: /*#__PURE__*/React.cloneElement(children, childProps)
205
+ })]
206
+ }))
207
+ });
158
208
  });
159
209
  process.env.NODE_ENV !== "production" ? Modal.propTypes /* remove-proptypes */ = {
160
210
  // ----------------------------- Warning --------------------------------
@@ -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,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
+ var modalClasses = generateUtilityClasses('MuiModal', ['root', 'hidden', 'backdrop']);
7
+ export default modalClasses;
@@ -83,6 +83,8 @@ var Select = /*#__PURE__*/React.forwardRef(function Select(inProps, ref) {
83
83
  classes: classesProp
84
84
  });
85
85
  var classes = useUtilityClasses(ownerState);
86
+ var root = classes.root,
87
+ restOfClasses = _objectWithoutProperties(classes, ["root"]);
86
88
  var InputComponent = input || {
87
89
  standard: /*#__PURE__*/_jsx(StyledInput, {
88
90
  ownerState: ownerState
@@ -125,13 +127,13 @@ var Select = /*#__PURE__*/React.forwardRef(function Select(inProps, ref) {
125
127
  id: id
126
128
  }, SelectDisplayProps)
127
129
  }, inputProps, {
128
- classes: inputProps ? deepmerge(classes, inputProps.classes) : classes
130
+ classes: inputProps ? deepmerge(restOfClasses, inputProps.classes) : restOfClasses
129
131
  }, input ? input.props.inputProps : {})
130
132
  }, multiple && native && variant === 'outlined' ? {
131
133
  notched: true
132
134
  } : {}, {
133
135
  ref: inputComponentRef,
134
- className: clsx(InputComponent.props.className, className)
136
+ className: clsx(InputComponent.props.className, className, classes.root)
135
137
  }, !input && {
136
138
  variant: variant
137
139
  }, other))
@@ -3,5 +3,5 @@ import generateUtilityClass from '../generateUtilityClass';
3
3
  export function getSelectUtilityClasses(slot) {
4
4
  return generateUtilityClass('MuiSelect', slot);
5
5
  }
6
- var selectClasses = generateUtilityClasses('MuiSelect', ['select', 'multiple', 'filled', 'outlined', 'standard', 'disabled', 'focused', 'icon', 'iconOpen', 'iconFilled', 'iconOutlined', 'iconStandard', 'nativeInput', 'error']);
6
+ var selectClasses = generateUtilityClasses('MuiSelect', ['root', 'select', 'multiple', 'filled', 'outlined', 'standard', 'disabled', 'focused', 'icon', 'iconOpen', 'iconFilled', 'iconOutlined', 'iconStandard', 'nativeInput', 'error']);
7
7
  export default selectClasses;
@@ -70,11 +70,11 @@ var SkeletonRoot = styled('span', {
70
70
  });
71
71
  }, function (_ref2) {
72
72
  var ownerState = _ref2.ownerState;
73
- return ownerState.animation === 'pulse' && css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n animation: ", " 1.5s ease-in-out 0.5s infinite;\n "])), pulseKeyframe);
73
+ return ownerState.animation === 'pulse' && css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n animation: ", " 2s ease-in-out 0.5s infinite;\n "])), pulseKeyframe);
74
74
  }, function (_ref3) {
75
75
  var ownerState = _ref3.ownerState,
76
76
  theme = _ref3.theme;
77
- return ownerState.animation === 'wave' && css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n position: relative;\n overflow: hidden;\n\n /* Fix bug in Safari https://bugs.webkit.org/show_bug.cgi?id=68196 */\n -webkit-mask-image: -webkit-radial-gradient(white, black);\n\n &::after {\n animation: ", " 1.6s linear 0.5s infinite;\n background: linear-gradient(\n 90deg,\n transparent,\n ", ",\n transparent\n );\n content: '';\n position: absolute;\n transform: translateX(-100%); /* Avoid flash during server-side hydration */\n bottom: 0;\n left: 0;\n right: 0;\n top: 0;\n }\n "])), waveKeyframe, (theme.vars || theme).palette.action.hover);
77
+ return ownerState.animation === 'wave' && css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n position: relative;\n overflow: hidden;\n\n /* Fix bug in Safari https://bugs.webkit.org/show_bug.cgi?id=68196 */\n -webkit-mask-image: -webkit-radial-gradient(white, black);\n\n &::after {\n animation: ", " 2s linear 0.5s infinite;\n background: linear-gradient(\n 90deg,\n transparent,\n ", ",\n transparent\n );\n content: '';\n position: absolute;\n transform: translateX(-100%); /* Avoid flash during server-side hydration */\n bottom: 0;\n left: 0;\n right: 0;\n top: 0;\n }\n "])), waveKeyframe, (theme.vars || theme).palette.action.hover);
78
78
  });
79
79
  var Skeleton = /*#__PURE__*/React.forwardRef(function Skeleton(inProps, ref) {
80
80
  var props = useThemeProps({
@@ -105,7 +105,6 @@ var TextField = /*#__PURE__*/React.forwardRef(function TextField(inProps, ref) {
105
105
  name = props.name,
106
106
  onBlur = props.onBlur,
107
107
  onChange = props.onChange,
108
- onClick = props.onClick,
109
108
  onFocus = props.onFocus,
110
109
  placeholder = props.placeholder,
111
110
  _props$required = props.required,
@@ -118,7 +117,7 @@ var TextField = /*#__PURE__*/React.forwardRef(function TextField(inProps, ref) {
118
117
  value = props.value,
119
118
  _props$variant = props.variant,
120
119
  variant = _props$variant === void 0 ? 'outlined' : _props$variant,
121
- other = _objectWithoutProperties(props, ["autoComplete", "autoFocus", "children", "className", "color", "defaultValue", "disabled", "error", "FormHelperTextProps", "fullWidth", "helperText", "id", "InputLabelProps", "inputProps", "InputProps", "inputRef", "label", "maxRows", "minRows", "multiline", "name", "onBlur", "onChange", "onClick", "onFocus", "placeholder", "required", "rows", "select", "SelectProps", "type", "value", "variant"]);
120
+ other = _objectWithoutProperties(props, ["autoComplete", "autoFocus", "children", "className", "color", "defaultValue", "disabled", "error", "FormHelperTextProps", "fullWidth", "helperText", "id", "InputLabelProps", "inputProps", "InputProps", "inputRef", "label", "maxRows", "minRows", "multiline", "name", "onBlur", "onChange", "onFocus", "placeholder", "required", "rows", "select", "SelectProps", "type", "value", "variant"]);
122
121
  var ownerState = _extends({}, props, {
123
122
  autoFocus: autoFocus,
124
123
  color: color,
@@ -150,14 +149,6 @@ var TextField = /*#__PURE__*/React.forwardRef(function TextField(inProps, ref) {
150
149
  }
151
150
  InputMore['aria-describedby'] = undefined;
152
151
  }
153
- var handleClick = function handleClick(event) {
154
- if (!disabled && onClick) {
155
- // The `onClick` is registered both on the root and the input elements.
156
- // Without stopping the propagation, the event could be triggered twice.
157
- event.stopPropagation();
158
- onClick(event);
159
- }
160
- };
161
152
  var id = useId(idOverride);
162
153
  var helperTextId = helperText && id ? "".concat(id, "-helper-text") : undefined;
163
154
  var inputLabelId = label && id ? "".concat(id, "-label") : undefined;
@@ -180,7 +171,6 @@ var TextField = /*#__PURE__*/React.forwardRef(function TextField(inProps, ref) {
180
171
  onBlur: onBlur,
181
172
  onChange: onChange,
182
173
  onFocus: onFocus,
183
- onClick: handleClick,
184
174
  placeholder: placeholder,
185
175
  inputProps: inputProps
186
176
  }, InputMore, InputProps));
@@ -193,8 +183,7 @@ var TextField = /*#__PURE__*/React.forwardRef(function TextField(inProps, ref) {
193
183
  required: required,
194
184
  color: color,
195
185
  variant: variant,
196
- ownerState: ownerState,
197
- onClick: handleClick
186
+ ownerState: ownerState
198
187
  }, other, {
199
188
  children: [label != null && label !== '' && /*#__PURE__*/_jsx(InputLabel, _extends({
200
189
  htmlFor: id,
@@ -340,10 +329,6 @@ process.env.NODE_ENV !== "production" ? TextField.propTypes /* remove-proptypes
340
329
  * You can pull out the new value by accessing `event.target.value` (string).
341
330
  */
342
331
  onChange: PropTypes.func,
343
- /**
344
- * @ignore
345
- */
346
- onClick: PropTypes.func,
347
332
  /**
348
333
  * @ignore
349
334
  */
package/legacy/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/material v5.14.5
2
+ * @mui/material v5.14.6
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -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
  /**
@@ -373,7 +373,7 @@ const InputBase = /*#__PURE__*/React.forwardRef(function InputBase(inProps, ref)
373
373
  if (inputRef.current && event.currentTarget === event.target) {
374
374
  inputRef.current.focus();
375
375
  }
376
- if (onClick && !fcs.disabled) {
376
+ if (onClick) {
377
377
  onClick(event);
378
378
  }
379
379
  };
@@ -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',
@@ -67,7 +83,6 @@ const Modal = /*#__PURE__*/React.forwardRef(function Modal(inProps, ref) {
67
83
  const {
68
84
  BackdropComponent = ModalBackdrop,
69
85
  BackdropProps,
70
- classes,
71
86
  className,
72
87
  closeAfterTransition = false,
73
88
  children,
@@ -84,17 +99,13 @@ const Modal = /*#__PURE__*/React.forwardRef(function Modal(inProps, ref) {
84
99
  hideBackdrop = false,
85
100
  keepMounted = false,
86
101
  onBackdropClick,
87
- onClose,
88
102
  open,
89
103
  slotProps,
90
- slots,
104
+ slots
91
105
  // eslint-disable-next-line react/prop-types
92
- theme
93
106
  } = props,
94
107
  other = _objectWithoutPropertiesLoose(props, _excluded);
95
- const [exited, setExited] = React.useState(true);
96
- const commonProps = {
97
- container,
108
+ const propsWithDefaults = _extends({}, props, {
98
109
  closeAfterTransition,
99
110
  disableAutoFocus,
100
111
  disableEnforceFocus,
@@ -103,40 +114,90 @@ const Modal = /*#__PURE__*/React.forwardRef(function Modal(inProps, ref) {
103
114
  disableRestoreFocus,
104
115
  disableScrollLock,
105
116
  hideBackdrop,
106
- keepMounted,
107
- onBackdropClick,
108
- onClose,
109
- open
110
- };
111
- const ownerState = _extends({}, props, commonProps, {
117
+ keepMounted
118
+ });
119
+ const {
120
+ getRootProps,
121
+ getBackdropProps,
122
+ getTransitionProps,
123
+ portalRef,
124
+ isTopModal,
125
+ exited,
126
+ hasTransition
127
+ } = useModal(_extends({}, propsWithDefaults, {
128
+ rootRef: ref
129
+ }));
130
+ const ownerState = _extends({}, propsWithDefaults, {
112
131
  exited
113
132
  });
133
+ const classes = useUtilityClasses(ownerState);
134
+ const childProps = {};
135
+ if (children.props.tabIndex === undefined) {
136
+ childProps.tabIndex = '-1';
137
+ }
138
+
139
+ // It's a Transition like component
140
+ if (hasTransition) {
141
+ const {
142
+ onEnter,
143
+ onExited
144
+ } = getTransitionProps();
145
+ childProps.onEnter = onEnter;
146
+ childProps.onExited = onExited;
147
+ }
114
148
  const RootSlot = slots?.root ?? components.Root ?? ModalRoot;
115
149
  const BackdropSlot = slots?.backdrop ?? components.Backdrop ?? BackdropComponent;
116
150
  const rootSlotProps = slotProps?.root ?? componentsProps.root;
117
151
  const backdropSlotProps = slotProps?.backdrop ?? componentsProps.backdrop;
118
- return /*#__PURE__*/_jsx(ModalUnstyled, _extends({
119
- slots: {
120
- root: RootSlot,
121
- backdrop: BackdropSlot
152
+ const rootProps = useSlotProps({
153
+ elementType: RootSlot,
154
+ externalSlotProps: rootSlotProps,
155
+ externalForwardedProps: other,
156
+ getSlotProps: getRootProps,
157
+ additionalProps: {
158
+ ref,
159
+ as: component
122
160
  },
123
- slotProps: {
124
- root: () => _extends({}, resolveComponentProps(rootSlotProps, ownerState), !isHostComponent(RootSlot) && {
125
- as: component,
126
- theme
127
- }, {
128
- className: clsx(className, rootSlotProps?.className, classes?.root, !ownerState.open && ownerState.exited && classes?.hidden)
129
- }),
130
- backdrop: () => _extends({}, BackdropProps, resolveComponentProps(backdropSlotProps, ownerState), {
131
- className: clsx(backdropSlotProps?.className, BackdropProps?.className, classes?.backdrop)
132
- })
161
+ ownerState,
162
+ className: clsx(className, rootSlotProps?.className, classes?.root, !ownerState.open && ownerState.exited && classes?.hidden)
163
+ });
164
+ const backdropProps = useSlotProps({
165
+ elementType: BackdropSlot,
166
+ externalSlotProps: backdropSlotProps,
167
+ additionalProps: BackdropProps,
168
+ getSlotProps: otherHandlers => {
169
+ return getBackdropProps(_extends({}, otherHandlers, {
170
+ onClick: e => {
171
+ if (onBackdropClick) {
172
+ onBackdropClick(e);
173
+ }
174
+ if (otherHandlers?.onClick) {
175
+ otherHandlers.onClick(e);
176
+ }
177
+ }
178
+ }));
133
179
  },
134
- onTransitionEnter: () => setExited(false),
135
- onTransitionExited: () => setExited(true),
136
- ref: ref
137
- }, other, commonProps, {
138
- children: children
139
- }));
180
+ className: clsx(backdropSlotProps?.className, BackdropProps?.className, classes?.backdrop),
181
+ ownerState
182
+ });
183
+ if (!keepMounted && !open && (!hasTransition || exited)) {
184
+ return null;
185
+ }
186
+ return /*#__PURE__*/_jsx(Portal, {
187
+ ref: portalRef,
188
+ container: container,
189
+ disablePortal: disablePortal,
190
+ children: /*#__PURE__*/_jsxs(RootSlot, _extends({}, rootProps, {
191
+ children: [!hideBackdrop && BackdropComponent ? /*#__PURE__*/_jsx(BackdropSlot, _extends({}, backdropProps)) : null, /*#__PURE__*/_jsx(FocusTrap, {
192
+ disableEnforceFocus: disableEnforceFocus,
193
+ disableAutoFocus: disableAutoFocus,
194
+ disableRestoreFocus: disableRestoreFocus,
195
+ isEnabled: isTopModal,
196
+ open: open,
197
+ children: /*#__PURE__*/React.cloneElement(children, childProps)
198
+ })]
199
+ }))
200
+ });
140
201
  });
141
202
  process.env.NODE_ENV !== "production" ? Modal.propTypes /* remove-proptypes */ = {
142
203
  // ----------------------------- Warning --------------------------------
@@ -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,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;