@mui/material 7.0.0-alpha.2 → 7.0.0-beta.1
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.
- package/CHANGELOG.md +57 -0
- package/Dialog/Dialog.d.ts +0 -5
- package/Dialog/Dialog.js +0 -9
- package/Grid/Grid.d.ts +51 -100
- package/Grid/Grid.js +68 -515
- package/Grid/gridClasses.d.ts +0 -38
- package/Grid/gridClasses.js +1 -1
- package/Grid/index.js +12 -2
- package/GridLegacy/GridLegacy.d.ts +160 -0
- package/GridLegacy/GridLegacy.js +601 -0
- package/{Grid/GridContext.js → GridLegacy/GridLegacyContext.js} +3 -3
- package/GridLegacy/gridLegacyClasses.d.ts +48 -0
- package/{Grid2/grid2Classes.js → GridLegacy/gridLegacyClasses.js} +5 -5
- package/GridLegacy/index.d.ts +4 -0
- package/GridLegacy/index.js +35 -0
- package/Menu/Menu.d.ts +68 -1
- package/Menu/Menu.js +52 -17
- package/Modal/Modal.d.ts +0 -5
- package/Modal/Modal.js +0 -9
- package/PigmentGrid/PigmentGrid.d.ts +1 -1
- package/PigmentGrid/PigmentGrid.js +2 -2
- package/PigmentGrid/index.d.ts +1 -1
- package/PigmentGrid/index.js +4 -4
- package/Rating/Rating.d.ts +52 -1
- package/Rating/Rating.js +132 -46
- package/Select/SelectInput.js +8 -8
- package/StepButton/StepButton.d.ts +0 -5
- package/esm/Dialog/Dialog.d.ts +0 -5
- package/esm/Dialog/Dialog.js +0 -9
- package/esm/Grid/Grid.d.ts +51 -100
- package/esm/Grid/Grid.js +68 -508
- package/esm/Grid/gridClasses.d.ts +0 -38
- package/esm/Grid/gridClasses.js +1 -1
- package/esm/Grid/index.js +1 -0
- package/esm/GridLegacy/GridLegacy.d.ts +160 -0
- package/esm/GridLegacy/GridLegacy.js +588 -0
- package/esm/GridLegacy/GridLegacyContext.js +12 -0
- package/esm/GridLegacy/gridLegacyClasses.d.ts +48 -0
- package/esm/{Grid2/grid2Classes.js → GridLegacy/gridLegacyClasses.js} +4 -4
- package/esm/GridLegacy/index.d.ts +4 -0
- package/esm/GridLegacy/index.js +3 -0
- package/esm/Menu/Menu.d.ts +68 -1
- package/esm/Menu/Menu.js +52 -17
- package/esm/Modal/Modal.d.ts +0 -5
- package/esm/Modal/Modal.js +0 -9
- package/esm/PigmentGrid/PigmentGrid.d.ts +1 -1
- package/esm/PigmentGrid/PigmentGrid.js +2 -2
- package/esm/PigmentGrid/index.d.ts +1 -1
- package/esm/PigmentGrid/index.js +1 -1
- package/esm/Rating/Rating.d.ts +52 -1
- package/esm/Rating/Rating.js +131 -45
- package/esm/Select/SelectInput.js +8 -8
- package/esm/StepButton/StepButton.d.ts +0 -5
- package/esm/index.d.ts +3 -8
- package/esm/index.js +3 -3
- package/esm/styles/components.d.ts +5 -5
- package/esm/styles/createTheme.d.ts +0 -1
- package/esm/styles/createTheme.js +0 -1
- package/esm/styles/createThemeNoVars.d.ts +0 -6
- package/esm/styles/createThemeNoVars.js +7 -12
- package/esm/styles/index.d.ts +1 -5
- package/esm/styles/index.js +1 -2
- package/esm/styles/overrides.d.ts +2 -2
- package/esm/styles/props.d.ts +2 -2
- package/esm/utils/createSvgIcon.d.ts +1 -1
- package/esm/utils/createSvgIcon.js +1 -1
- package/esm/version/index.js +2 -2
- package/index.d.ts +3 -8
- package/index.js +9 -9
- package/modern/Dialog/Dialog.d.ts +0 -5
- package/modern/Dialog/Dialog.js +0 -9
- package/modern/Grid/Grid.d.ts +51 -100
- package/modern/Grid/Grid.js +68 -508
- package/modern/Grid/gridClasses.d.ts +0 -38
- package/modern/Grid/gridClasses.js +1 -1
- package/modern/Grid/index.js +1 -0
- package/modern/GridLegacy/GridLegacy.d.ts +160 -0
- package/modern/GridLegacy/GridLegacy.js +588 -0
- package/modern/GridLegacy/GridLegacyContext.js +12 -0
- package/modern/GridLegacy/gridLegacyClasses.d.ts +48 -0
- package/modern/{Grid2/grid2Classes.js → GridLegacy/gridLegacyClasses.js} +4 -4
- package/modern/GridLegacy/index.d.ts +4 -0
- package/modern/GridLegacy/index.js +3 -0
- package/modern/Menu/Menu.d.ts +68 -1
- package/modern/Menu/Menu.js +52 -17
- package/modern/Modal/Modal.d.ts +0 -5
- package/modern/Modal/Modal.js +0 -9
- package/modern/PigmentGrid/PigmentGrid.d.ts +1 -1
- package/modern/PigmentGrid/PigmentGrid.js +2 -2
- package/modern/PigmentGrid/index.d.ts +1 -1
- package/modern/PigmentGrid/index.js +1 -1
- package/modern/Rating/Rating.d.ts +52 -1
- package/modern/Rating/Rating.js +131 -45
- package/modern/Select/SelectInput.js +8 -8
- package/modern/StepButton/StepButton.d.ts +0 -5
- package/modern/index.d.ts +3 -8
- package/modern/index.js +3 -3
- package/modern/styles/components.d.ts +5 -5
- package/modern/styles/createTheme.d.ts +0 -1
- package/modern/styles/createTheme.js +0 -1
- package/modern/styles/createThemeNoVars.d.ts +0 -6
- package/modern/styles/createThemeNoVars.js +7 -12
- package/modern/styles/index.d.ts +1 -5
- package/modern/styles/index.js +1 -2
- package/modern/styles/overrides.d.ts +2 -2
- package/modern/styles/props.d.ts +2 -2
- package/modern/utils/createSvgIcon.d.ts +1 -1
- package/modern/utils/createSvgIcon.js +1 -1
- package/modern/version/index.js +2 -2
- package/package.json +4 -4
- package/styles/components.d.ts +5 -5
- package/styles/createTheme.d.ts +0 -1
- package/styles/createTheme.js +1 -8
- package/styles/createThemeNoVars.d.ts +0 -6
- package/styles/createThemeNoVars.js +7 -13
- package/styles/index.d.ts +1 -5
- package/styles/index.js +1 -15
- package/styles/overrides.d.ts +2 -2
- package/styles/props.d.ts +2 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/utils/createSvgIcon.d.ts +1 -1
- package/utils/createSvgIcon.js +1 -1
- package/version/index.js +2 -2
- package/Grid2/Grid2.d.ts +0 -111
- package/Grid2/Grid2.js +0 -144
- package/Grid2/grid2Classes.d.ts +0 -10
- package/Grid2/index.d.ts +0 -4
- package/Grid2/index.js +0 -45
- package/StyledEngineProvider/index.d.ts +0 -4
- package/StyledEngineProvider/index.js +0 -12
- package/esm/Grid/GridContext.js +0 -12
- package/esm/Grid2/Grid2.d.ts +0 -111
- package/esm/Grid2/Grid2.js +0 -138
- package/esm/Grid2/grid2Classes.d.ts +0 -10
- package/esm/Grid2/index.d.ts +0 -4
- package/esm/Grid2/index.js +0 -4
- package/esm/StyledEngineProvider/index.d.ts +0 -4
- package/esm/StyledEngineProvider/index.js +0 -1
- package/modern/Grid/GridContext.js +0 -12
- package/modern/Grid2/Grid2.d.ts +0 -111
- package/modern/Grid2/Grid2.js +0 -138
- package/modern/Grid2/grid2Classes.d.ts +0 -10
- package/modern/Grid2/index.d.ts +0 -4
- package/modern/Grid2/index.js +0 -4
- package/modern/StyledEngineProvider/index.d.ts +0 -4
- package/modern/StyledEngineProvider/index.js +0 -1
package/esm/Menu/Menu.d.ts
CHANGED
|
@@ -4,10 +4,74 @@ import { InternalStandardProps as StandardProps } from "../index.js";
|
|
|
4
4
|
import { PaperProps } from "../Paper/index.js";
|
|
5
5
|
import { PopoverProps } from "../Popover/index.js";
|
|
6
6
|
import { MenuListProps } from "../MenuList/index.js";
|
|
7
|
+
import { ModalProps } from "../Modal/index.js";
|
|
8
|
+
import { BackdropProps } from "../Backdrop/index.js";
|
|
7
9
|
import { Theme } from "../styles/index.js";
|
|
8
10
|
import { TransitionProps } from "../transitions/transition.js";
|
|
9
11
|
import { MenuClasses } from "./menuClasses.js";
|
|
10
|
-
|
|
12
|
+
import { CreateSlotsAndSlotProps, SlotComponentProps, SlotProps } from "../utils/types.js";
|
|
13
|
+
export interface MenuRootSlotPropsOverrides {}
|
|
14
|
+
export interface MenuPaperSlotPropsOverrides {}
|
|
15
|
+
export interface MenuTransitionSlotPropsOverrides {}
|
|
16
|
+
export interface MenuListSlotPropsOverrides {}
|
|
17
|
+
export interface MenuBackdropSlotPropsOverrides {}
|
|
18
|
+
export interface MenuSlots {
|
|
19
|
+
/**
|
|
20
|
+
* The component used for the popper.
|
|
21
|
+
* @default Modal
|
|
22
|
+
*/
|
|
23
|
+
root: React.ElementType;
|
|
24
|
+
/**
|
|
25
|
+
* The component used for the paper.
|
|
26
|
+
* @default Paper
|
|
27
|
+
*/
|
|
28
|
+
paper: React.ElementType;
|
|
29
|
+
/**
|
|
30
|
+
* The component used for the list.
|
|
31
|
+
* @default MenuList
|
|
32
|
+
*/
|
|
33
|
+
list: React.ElementType;
|
|
34
|
+
/**
|
|
35
|
+
* The component used for the transition slot.
|
|
36
|
+
* @default Grow
|
|
37
|
+
*/
|
|
38
|
+
transition: React.ElementType;
|
|
39
|
+
/**
|
|
40
|
+
* The component used for the backdrop slot.
|
|
41
|
+
* @default Backdrop
|
|
42
|
+
*/
|
|
43
|
+
backdrop: React.ElementType;
|
|
44
|
+
}
|
|
45
|
+
export type MenuSlotsAndSlotProps = CreateSlotsAndSlotProps<MenuSlots, {
|
|
46
|
+
/**
|
|
47
|
+
* Props forwarded to the root slot.
|
|
48
|
+
* By default, the avaible props are based on the [Popover](https://mui.com/material-ui/api/popover/#props) component.
|
|
49
|
+
*/
|
|
50
|
+
root: SlotProps<React.ElementType<ModalProps>, MenuRootSlotPropsOverrides, MenuOwnerState>;
|
|
51
|
+
/**
|
|
52
|
+
* Props forwarded to the paper slot.
|
|
53
|
+
* By default, the avaible props are based on the [Paper](https://mui.com/material-ui/api/paper/#props) component.
|
|
54
|
+
*/
|
|
55
|
+
paper: SlotProps<React.ElementType<PaperProps>, MenuPaperSlotPropsOverrides, MenuOwnerState>;
|
|
56
|
+
/**
|
|
57
|
+
* Props forwarded to the list slot.
|
|
58
|
+
* By default, the avaible props are based on the [MenuList](https://mui.com/material-ui/api/menu-list/#props) component.
|
|
59
|
+
*/
|
|
60
|
+
list: SlotProps<React.ElementType<MenuListProps>, MenuListSlotPropsOverrides, MenuOwnerState>;
|
|
61
|
+
/**
|
|
62
|
+
* Props forwarded to the transition slot.
|
|
63
|
+
* By default, the avaible props are based on the [Grow](https://mui.com/material-ui/api/grow/#props) component.
|
|
64
|
+
*/
|
|
65
|
+
transition: SlotComponentProps<
|
|
66
|
+
// use SlotComponentProps because transition slot does not support `component` and `sx` prop
|
|
67
|
+
React.ElementType, TransitionProps & MenuTransitionSlotPropsOverrides, MenuOwnerState>;
|
|
68
|
+
/**
|
|
69
|
+
* Props forwarded to the backdrop slot.
|
|
70
|
+
* By default, the avaible props are based on the [Backdrop](https://mui.com/material-ui/api/backdrop/#props) component.
|
|
71
|
+
*/
|
|
72
|
+
backdrop: SlotProps<React.ElementType<BackdropProps>, MenuBackdropSlotPropsOverrides, MenuOwnerState>;
|
|
73
|
+
}>;
|
|
74
|
+
export interface MenuProps extends StandardProps<Omit<PopoverProps, 'slots' | 'slotProps'>>, MenuSlotsAndSlotProps {
|
|
11
75
|
/**
|
|
12
76
|
* An HTML element, or a function that returns one.
|
|
13
77
|
* It's used to set the position of the menu.
|
|
@@ -39,6 +103,7 @@ export interface MenuProps extends StandardProps<PopoverProps> {
|
|
|
39
103
|
disableAutoFocusItem?: boolean;
|
|
40
104
|
/**
|
|
41
105
|
* Props applied to the [`MenuList`](https://mui.com/material-ui/api/menu-list/) element.
|
|
106
|
+
* @deprecated use the `slotProps.list` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
42
107
|
* @default {}
|
|
43
108
|
*/
|
|
44
109
|
MenuListProps?: Partial<MenuListProps>;
|
|
@@ -69,6 +134,7 @@ export interface MenuProps extends StandardProps<PopoverProps> {
|
|
|
69
134
|
/**
|
|
70
135
|
* Props applied to the transition element.
|
|
71
136
|
* By default, the element is based on this [`Transition`](https://reactcommunity.org/react-transition-group/transition/) component.
|
|
137
|
+
* @deprecated use the `slotProps.transition` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
72
138
|
* @default {}
|
|
73
139
|
*/
|
|
74
140
|
TransitionProps?: TransitionProps;
|
|
@@ -78,6 +144,7 @@ export interface MenuProps extends StandardProps<PopoverProps> {
|
|
|
78
144
|
*/
|
|
79
145
|
variant?: 'menu' | 'selectedMenu';
|
|
80
146
|
}
|
|
147
|
+
export interface MenuOwnerState extends Omit<MenuProps, 'slots' | 'slotProps'> {}
|
|
81
148
|
export declare const MenuPaper: React.FC<PaperProps>;
|
|
82
149
|
|
|
83
150
|
/**
|
package/esm/Menu/Menu.js
CHANGED
|
@@ -14,6 +14,7 @@ import rootShouldForwardProp from "../styles/rootShouldForwardProp.js";
|
|
|
14
14
|
import { styled } from "../zero-styled/index.js";
|
|
15
15
|
import { useDefaultProps } from "../DefaultPropsProvider/index.js";
|
|
16
16
|
import { getMenuUtilityClass } from "./menuClasses.js";
|
|
17
|
+
import useSlot from "../utils/useSlot.js";
|
|
17
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
19
|
const RTL_ORIGIN = {
|
|
19
20
|
vertical: 'top',
|
|
@@ -145,20 +146,43 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu(inProps, ref) {
|
|
|
145
146
|
}
|
|
146
147
|
}
|
|
147
148
|
});
|
|
148
|
-
const
|
|
149
|
-
|
|
149
|
+
const externalForwardedProps = {
|
|
150
|
+
slots,
|
|
151
|
+
slotProps: {
|
|
152
|
+
list: MenuListProps,
|
|
153
|
+
transition: TransitionProps,
|
|
154
|
+
paper: PaperProps,
|
|
155
|
+
...slotProps
|
|
156
|
+
}
|
|
157
|
+
};
|
|
150
158
|
const rootSlotProps = useSlotProps({
|
|
151
159
|
elementType: slots.root,
|
|
152
160
|
externalSlotProps: slotProps.root,
|
|
153
161
|
ownerState,
|
|
154
162
|
className: [classes.root, className]
|
|
155
163
|
});
|
|
156
|
-
const paperSlotProps =
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
164
|
+
const [PaperSlot, paperSlotProps] = useSlot('paper', {
|
|
165
|
+
className: classes.paper,
|
|
166
|
+
elementType: MenuPaper,
|
|
167
|
+
externalForwardedProps,
|
|
168
|
+
shouldForwardComponentProp: true,
|
|
169
|
+
ownerState
|
|
170
|
+
});
|
|
171
|
+
const [ListSlot, listSlotProps] = useSlot('list', {
|
|
172
|
+
className: clsx(classes.list, MenuListProps.className),
|
|
173
|
+
elementType: MenuMenuList,
|
|
174
|
+
shouldForwardComponentProp: true,
|
|
175
|
+
externalForwardedProps,
|
|
176
|
+
getSlotProps: handlers => ({
|
|
177
|
+
...handlers,
|
|
178
|
+
onKeyDown: event => {
|
|
179
|
+
handleListKeyDown(event);
|
|
180
|
+
handlers.onKeyDown?.(event);
|
|
181
|
+
}
|
|
182
|
+
}),
|
|
183
|
+
ownerState
|
|
161
184
|
});
|
|
185
|
+
const resolvedTransitionProps = typeof externalForwardedProps.slotProps.transition === 'function' ? externalForwardedProps.slotProps.transition(ownerState) : externalForwardedProps.slotProps.transition;
|
|
162
186
|
return /*#__PURE__*/_jsx(MenuRoot, {
|
|
163
187
|
onClose: onClose,
|
|
164
188
|
anchorOrigin: {
|
|
@@ -167,31 +191,38 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu(inProps, ref) {
|
|
|
167
191
|
},
|
|
168
192
|
transformOrigin: isRtl ? RTL_ORIGIN : LTR_ORIGIN,
|
|
169
193
|
slots: {
|
|
194
|
+
root: slots.root,
|
|
170
195
|
paper: PaperSlot,
|
|
171
|
-
|
|
196
|
+
backdrop: slots.backdrop,
|
|
197
|
+
...(slots.transition && {
|
|
198
|
+
// TODO: pass `slots.transition` directly once `TransitionComponent` is removed from Popover
|
|
199
|
+
transition: slots.transition
|
|
200
|
+
})
|
|
172
201
|
},
|
|
173
202
|
slotProps: {
|
|
174
203
|
root: rootSlotProps,
|
|
175
|
-
paper: paperSlotProps
|
|
204
|
+
paper: paperSlotProps,
|
|
205
|
+
backdrop: typeof slotProps.backdrop === 'function' ? slotProps.backdrop(ownerState) : slotProps.backdrop,
|
|
206
|
+
transition: {
|
|
207
|
+
...resolvedTransitionProps,
|
|
208
|
+
onEntering: (...args) => {
|
|
209
|
+
handleEntering(...args);
|
|
210
|
+
resolvedTransitionProps?.onEntering?.(...args);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
176
213
|
},
|
|
177
214
|
open: open,
|
|
178
215
|
ref: ref,
|
|
179
216
|
transitionDuration: transitionDuration,
|
|
180
|
-
TransitionProps: {
|
|
181
|
-
onEntering: handleEntering,
|
|
182
|
-
...TransitionProps
|
|
183
|
-
},
|
|
184
217
|
ownerState: ownerState,
|
|
185
218
|
...other,
|
|
186
219
|
classes: PopoverClasses,
|
|
187
|
-
children: /*#__PURE__*/_jsx(
|
|
188
|
-
onKeyDown: handleListKeyDown,
|
|
220
|
+
children: /*#__PURE__*/_jsx(ListSlot, {
|
|
189
221
|
actions: menuListActionsRef,
|
|
190
222
|
autoFocus: autoFocus && (activeItemIndex === -1 || disableAutoFocusItem),
|
|
191
223
|
autoFocusItem: autoFocusItem,
|
|
192
224
|
variant: variant,
|
|
193
|
-
...
|
|
194
|
-
className: clsx(classes.list, MenuListProps.className),
|
|
225
|
+
...listSlotProps,
|
|
195
226
|
children: children
|
|
196
227
|
})
|
|
197
228
|
});
|
|
@@ -236,6 +267,7 @@ process.env.NODE_ENV !== "production" ? Menu.propTypes /* remove-proptypes */ =
|
|
|
236
267
|
disableAutoFocusItem: PropTypes.bool,
|
|
237
268
|
/**
|
|
238
269
|
* Props applied to the [`MenuList`](https://mui.com/material-ui/api/menu-list/) element.
|
|
270
|
+
* @deprecated use the `slotProps.list` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
239
271
|
* @default {}
|
|
240
272
|
*/
|
|
241
273
|
MenuListProps: PropTypes.object,
|
|
@@ -264,6 +296,7 @@ process.env.NODE_ENV !== "production" ? Menu.propTypes /* remove-proptypes */ =
|
|
|
264
296
|
*/
|
|
265
297
|
slotProps: PropTypes.shape({
|
|
266
298
|
backdrop: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
299
|
+
list: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
267
300
|
paper: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
268
301
|
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
269
302
|
transition: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
@@ -274,6 +307,7 @@ process.env.NODE_ENV !== "production" ? Menu.propTypes /* remove-proptypes */ =
|
|
|
274
307
|
*/
|
|
275
308
|
slots: PropTypes.shape({
|
|
276
309
|
backdrop: PropTypes.elementType,
|
|
310
|
+
list: PropTypes.elementType,
|
|
277
311
|
paper: PropTypes.elementType,
|
|
278
312
|
root: PropTypes.elementType,
|
|
279
313
|
transition: PropTypes.elementType
|
|
@@ -294,6 +328,7 @@ process.env.NODE_ENV !== "production" ? Menu.propTypes /* remove-proptypes */ =
|
|
|
294
328
|
/**
|
|
295
329
|
* Props applied to the transition element.
|
|
296
330
|
* By default, the element is based on this [`Transition`](https://reactcommunity.org/react-transition-group/transition/) component.
|
|
331
|
+
* @deprecated use the `slotProps.transition` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
297
332
|
* @default {}
|
|
298
333
|
*/
|
|
299
334
|
TransitionProps: PropTypes.object,
|
package/esm/Modal/Modal.d.ts
CHANGED
|
@@ -145,11 +145,6 @@ export interface ModalOwnProps {
|
|
|
145
145
|
* @default false
|
|
146
146
|
*/
|
|
147
147
|
keepMounted?: boolean;
|
|
148
|
-
/**
|
|
149
|
-
* Callback fired when the backdrop is clicked.
|
|
150
|
-
* @deprecated Use the `onClose` prop with the `reason` argument to handle the `backdropClick` events.
|
|
151
|
-
*/
|
|
152
|
-
onBackdropClick?: React.ReactEventHandler<{}>;
|
|
153
148
|
/**
|
|
154
149
|
* Callback fired when the component requests to be closed.
|
|
155
150
|
* The `reason` parameter can optionally be used to control the response to `onClose`.
|
package/esm/Modal/Modal.js
CHANGED
|
@@ -102,7 +102,6 @@ const Modal = /*#__PURE__*/React.forwardRef(function Modal(inProps, ref) {
|
|
|
102
102
|
disableScrollLock = false,
|
|
103
103
|
hideBackdrop = false,
|
|
104
104
|
keepMounted = false,
|
|
105
|
-
onBackdropClick,
|
|
106
105
|
onClose,
|
|
107
106
|
onTransitionEnter,
|
|
108
107
|
onTransitionExited,
|
|
@@ -189,9 +188,6 @@ const Modal = /*#__PURE__*/React.forwardRef(function Modal(inProps, ref) {
|
|
|
189
188
|
return getBackdropProps({
|
|
190
189
|
...otherHandlers,
|
|
191
190
|
onClick: event => {
|
|
192
|
-
if (onBackdropClick) {
|
|
193
|
-
onBackdropClick(event);
|
|
194
|
-
}
|
|
195
191
|
if (otherHandlers?.onClick) {
|
|
196
192
|
otherHandlers.onClick(event);
|
|
197
193
|
}
|
|
@@ -355,11 +351,6 @@ process.env.NODE_ENV !== "production" ? Modal.propTypes /* remove-proptypes */ =
|
|
|
355
351
|
* @default false
|
|
356
352
|
*/
|
|
357
353
|
keepMounted: PropTypes.bool,
|
|
358
|
-
/**
|
|
359
|
-
* Callback fired when the backdrop is clicked.
|
|
360
|
-
* @deprecated Use the `onClose` prop with the `reason` argument to handle the `backdropClick` events.
|
|
361
|
-
*/
|
|
362
|
-
onBackdropClick: PropTypes.func,
|
|
363
354
|
/**
|
|
364
355
|
* Callback fired when the component requests to be closed.
|
|
365
356
|
* The `reason` parameter can optionally be used to control the response to `onClose`.
|
|
@@ -31,13 +31,13 @@ const useUtilityClasses = ownerState => {
|
|
|
31
31
|
const slots = {
|
|
32
32
|
root: ['root', container && 'container', ...generateDirectionClasses(direction), ...generateSizeClassNames(gridSize), ...(container ? generateSpacingClassNames(spacing) : [])]
|
|
33
33
|
};
|
|
34
|
-
return composeClasses(slots, slot => generateUtilityClass('
|
|
34
|
+
return composeClasses(slots, slot => generateUtilityClass('MuiGrid', slot), {});
|
|
35
35
|
};
|
|
36
36
|
/**
|
|
37
37
|
*
|
|
38
38
|
* Demos:
|
|
39
39
|
*
|
|
40
|
-
* - [Grid
|
|
40
|
+
* - [Grid](https://next.mui.com/material-ui/react-grid/)
|
|
41
41
|
*
|
|
42
42
|
* API:
|
|
43
43
|
*
|
package/esm/PigmentGrid/index.js
CHANGED
package/esm/Rating/Rating.d.ts
CHANGED
|
@@ -4,11 +4,60 @@ import { OverridableStringUnion } from '@mui/types';
|
|
|
4
4
|
import { Theme } from "../index.js";
|
|
5
5
|
import { RatingClasses } from "./ratingClasses.js";
|
|
6
6
|
import { OverridableComponent, OverrideProps } from "../OverridableComponent/index.js";
|
|
7
|
+
import { CreateSlotsAndSlotProps, SlotProps } from "../utils/types.js";
|
|
7
8
|
export interface IconContainerProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
8
9
|
value: number;
|
|
9
10
|
}
|
|
10
11
|
export interface RatingPropsSizeOverrides {}
|
|
11
|
-
export interface
|
|
12
|
+
export interface RatingRootSlotPropsOverrides {}
|
|
13
|
+
export interface RatingLabelSlotPropsOverrides {}
|
|
14
|
+
export interface RatingIconSlotPropsOverrides {}
|
|
15
|
+
export interface RatingDecimalSlotPropsOverrides {}
|
|
16
|
+
export interface RatingSlots {
|
|
17
|
+
/**
|
|
18
|
+
* The component used for the root slot.
|
|
19
|
+
* @default 'span'
|
|
20
|
+
*/
|
|
21
|
+
root: React.ElementType;
|
|
22
|
+
/**
|
|
23
|
+
* The component used for the label slot.
|
|
24
|
+
* @default 'label'
|
|
25
|
+
*/
|
|
26
|
+
label: React.ElementType;
|
|
27
|
+
/**
|
|
28
|
+
* The component used for the icon slot.
|
|
29
|
+
* @default 'span'
|
|
30
|
+
*/
|
|
31
|
+
icon: React.ElementType;
|
|
32
|
+
/**
|
|
33
|
+
* The component used fo r the decimal slot.
|
|
34
|
+
* @default 'span'
|
|
35
|
+
*/
|
|
36
|
+
decimal: React.ElementType;
|
|
37
|
+
}
|
|
38
|
+
export type RatingSlotsAndSlotProps = CreateSlotsAndSlotProps<RatingSlots, {
|
|
39
|
+
/**
|
|
40
|
+
* Props forwarded to the root slot.
|
|
41
|
+
* By default, the avaible props are based on the span element.
|
|
42
|
+
*/
|
|
43
|
+
root: SlotProps<'span', RatingRootSlotPropsOverrides, RatingOwnerState>;
|
|
44
|
+
/**
|
|
45
|
+
* Props forwarded to the label slot.
|
|
46
|
+
* By default, the avaible props are based on the label element.
|
|
47
|
+
*/
|
|
48
|
+
label: SlotProps<'label', RatingLabelSlotPropsOverrides, RatingOwnerState>;
|
|
49
|
+
/**
|
|
50
|
+
* Props forwarded to the icon slot.
|
|
51
|
+
* By default, the avaible props are based on the span element.
|
|
52
|
+
*/
|
|
53
|
+
icon: SlotProps<'span', RatingIconSlotPropsOverrides, RatingOwnerState>;
|
|
54
|
+
/**
|
|
55
|
+
* Props forwarded to the decimal slot.
|
|
56
|
+
* By default, the avaible props are based on the span element.
|
|
57
|
+
*/
|
|
58
|
+
decimal: SlotProps<'span', RatingDecimalSlotPropsOverrides, RatingOwnerState>;
|
|
59
|
+
}>;
|
|
60
|
+
export interface RatingOwnProps extends RatingSlotsAndSlotProps {
|
|
12
61
|
/**
|
|
13
62
|
* Override or extend the styles applied to the component.
|
|
14
63
|
*/
|
|
@@ -57,6 +106,7 @@ export interface RatingOwnProps {
|
|
|
57
106
|
icon?: React.ReactNode;
|
|
58
107
|
/**
|
|
59
108
|
* The component containing the icon.
|
|
109
|
+
* @deprecated Use `slotProps.icon.component` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
60
110
|
* @default function IconContainer(props) {
|
|
61
111
|
* const { value, ...other } = props;
|
|
62
112
|
* return <span {...other} />;
|
|
@@ -110,6 +160,7 @@ export interface RatingOwnProps {
|
|
|
110
160
|
*/
|
|
111
161
|
value?: number | null;
|
|
112
162
|
}
|
|
163
|
+
export interface RatingOwnerState extends Omit<RatingProps, 'slots' | 'slotProps'> {}
|
|
113
164
|
export type RatingTypeMap<AdditionalProps = {}, RootComponent extends React.ElementType = 'span'> = {
|
|
114
165
|
props: AdditionalProps & RatingOwnProps;
|
|
115
166
|
defaultComponent: RootComponent;
|
package/esm/Rating/Rating.js
CHANGED
|
@@ -17,7 +17,9 @@ import memoTheme from "../utils/memoTheme.js";
|
|
|
17
17
|
import { useDefaultProps } from "../DefaultPropsProvider/index.js";
|
|
18
18
|
import slotShouldForwardProp from "../styles/slotShouldForwardProp.js";
|
|
19
19
|
import ratingClasses, { getRatingUtilityClass } from "./ratingClasses.js";
|
|
20
|
+
import useSlot from "../utils/useSlot.js";
|
|
20
21
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
|
+
import { createElement as _createElement } from "react";
|
|
21
23
|
function getDecimalPrecision(num) {
|
|
22
24
|
const decimalPart = num.toString().split('.')[1];
|
|
23
25
|
return decimalPart ? decimalPart.length : 0;
|
|
@@ -220,7 +222,9 @@ function RatingItem(props) {
|
|
|
220
222
|
readOnly,
|
|
221
223
|
ownerState,
|
|
222
224
|
ratingValue,
|
|
223
|
-
ratingValueRounded
|
|
225
|
+
ratingValueRounded,
|
|
226
|
+
slots = {},
|
|
227
|
+
slotProps = {}
|
|
224
228
|
} = props;
|
|
225
229
|
const isFilled = highlightSelectedOnly ? itemValue === ratingValue : itemValue <= ratingValue;
|
|
226
230
|
const isHovered = itemValue <= hover;
|
|
@@ -232,10 +236,14 @@ function RatingItem(props) {
|
|
|
232
236
|
// Update to const id = useId(); when React 17 support is dropped.
|
|
233
237
|
// More details: https://github.com/mui/material-ui/issues/40997
|
|
234
238
|
const id = `${name}-${useId()}`;
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
|
|
239
|
+
const externalForwardedProps = {
|
|
240
|
+
slots,
|
|
241
|
+
slotProps
|
|
242
|
+
};
|
|
243
|
+
const [IconSlot, iconSlotProps] = useSlot('icon', {
|
|
244
|
+
elementType: RatingIcon,
|
|
238
245
|
className: clsx(classes.icon, isFilled ? classes.iconFilled : classes.iconEmpty, isHovered && classes.iconHover, isFocused && classes.iconFocus, isActive && classes.iconActive),
|
|
246
|
+
externalForwardedProps,
|
|
239
247
|
ownerState: {
|
|
240
248
|
...ownerState,
|
|
241
249
|
iconEmpty: !isFilled,
|
|
@@ -244,6 +252,29 @@ function RatingItem(props) {
|
|
|
244
252
|
iconFocus: isFocused,
|
|
245
253
|
iconActive: isActive
|
|
246
254
|
},
|
|
255
|
+
additionalProps: {
|
|
256
|
+
value: itemValue
|
|
257
|
+
},
|
|
258
|
+
internalForwardedProps: {
|
|
259
|
+
// TODO: remove this in v7 because `IconContainerComponent` is deprecated
|
|
260
|
+
// only forward if `slots.icon` is NOT provided
|
|
261
|
+
as: IconContainerComponent
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
const [LabelSlot, labelSlotProps] = useSlot('label', {
|
|
265
|
+
elementType: RatingLabel,
|
|
266
|
+
externalForwardedProps,
|
|
267
|
+
ownerState: {
|
|
268
|
+
...ownerState,
|
|
269
|
+
emptyValueFocused: undefined
|
|
270
|
+
},
|
|
271
|
+
additionalProps: {
|
|
272
|
+
style: labelProps?.style,
|
|
273
|
+
htmlFor: id
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
const container = /*#__PURE__*/_jsx(IconSlot, {
|
|
277
|
+
...iconSlotProps,
|
|
247
278
|
children: emptyIcon && !isFilled ? emptyIcon : icon
|
|
248
279
|
});
|
|
249
280
|
if (readOnly) {
|
|
@@ -253,13 +284,8 @@ function RatingItem(props) {
|
|
|
253
284
|
});
|
|
254
285
|
}
|
|
255
286
|
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
256
|
-
children: [/*#__PURE__*/_jsxs(
|
|
257
|
-
|
|
258
|
-
...ownerState,
|
|
259
|
-
emptyValueFocused: undefined
|
|
260
|
-
},
|
|
261
|
-
htmlFor: id,
|
|
262
|
-
...labelProps,
|
|
287
|
+
children: [/*#__PURE__*/_jsxs(LabelSlot, {
|
|
288
|
+
...labelSlotProps,
|
|
263
289
|
children: [container, /*#__PURE__*/_jsx("span", {
|
|
264
290
|
className: classes.visuallyHidden,
|
|
265
291
|
children: getLabelText(itemValue)
|
|
@@ -300,7 +326,9 @@ process.env.NODE_ENV !== "production" ? RatingItem.propTypes = {
|
|
|
300
326
|
ownerState: PropTypes.object.isRequired,
|
|
301
327
|
ratingValue: PropTypes.number,
|
|
302
328
|
ratingValueRounded: PropTypes.number,
|
|
303
|
-
readOnly: PropTypes.bool.isRequired
|
|
329
|
+
readOnly: PropTypes.bool.isRequired,
|
|
330
|
+
slotProps: PropTypes.object,
|
|
331
|
+
slots: PropTypes.object
|
|
304
332
|
} : void 0;
|
|
305
333
|
const defaultIcon = /*#__PURE__*/_jsx(Star, {
|
|
306
334
|
fontSize: "inherit"
|
|
@@ -337,6 +365,8 @@ const Rating = /*#__PURE__*/React.forwardRef(function Rating(inProps, ref) {
|
|
|
337
365
|
readOnly = false,
|
|
338
366
|
size = 'medium',
|
|
339
367
|
value: valueProp,
|
|
368
|
+
slots = {},
|
|
369
|
+
slotProps = {},
|
|
340
370
|
...other
|
|
341
371
|
} = props;
|
|
342
372
|
const name = useId(nameProp);
|
|
@@ -474,16 +504,50 @@ const Rating = /*#__PURE__*/React.forwardRef(function Rating(inProps, ref) {
|
|
|
474
504
|
size
|
|
475
505
|
};
|
|
476
506
|
const classes = useUtilityClasses(ownerState);
|
|
477
|
-
|
|
478
|
-
|
|
507
|
+
const externalForwardedProps = {
|
|
508
|
+
slots,
|
|
509
|
+
slotProps
|
|
510
|
+
};
|
|
511
|
+
const [RootSlot, rootSlotProps] = useSlot('root', {
|
|
479
512
|
ref: handleRef,
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
513
|
+
className: clsx(classes.root, className),
|
|
514
|
+
elementType: RatingRoot,
|
|
515
|
+
externalForwardedProps: {
|
|
516
|
+
...externalForwardedProps,
|
|
517
|
+
...other,
|
|
518
|
+
component
|
|
519
|
+
},
|
|
520
|
+
getSlotProps: handlers => ({
|
|
521
|
+
...handlers,
|
|
522
|
+
onMouseMove: event => {
|
|
523
|
+
handleMouseMove(event);
|
|
524
|
+
handlers.onMouseMove?.(event);
|
|
525
|
+
},
|
|
526
|
+
onMouseLeave: event => {
|
|
527
|
+
handleMouseLeave(event);
|
|
528
|
+
handlers.onMouseLeave?.(event);
|
|
529
|
+
}
|
|
530
|
+
}),
|
|
531
|
+
ownerState,
|
|
532
|
+
additionalProps: {
|
|
533
|
+
role: readOnly ? 'img' : null,
|
|
534
|
+
'aria-label': readOnly ? getLabelText(value) : null
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
const [LabelSlot, labelSlotProps] = useSlot('label', {
|
|
538
|
+
className: clsx(classes.label, classes.labelEmptyValue),
|
|
539
|
+
elementType: RatingLabel,
|
|
540
|
+
externalForwardedProps,
|
|
541
|
+
ownerState
|
|
542
|
+
});
|
|
543
|
+
const [DecimalSlot, decimalSlotProps] = useSlot('decimal', {
|
|
544
|
+
className: classes.decimal,
|
|
545
|
+
elementType: RatingDecimal,
|
|
546
|
+
externalForwardedProps,
|
|
547
|
+
ownerState
|
|
548
|
+
});
|
|
549
|
+
return /*#__PURE__*/_jsxs(RootSlot, {
|
|
550
|
+
...rootSlotProps,
|
|
487
551
|
children: [Array.from(new Array(max)).map((_, index) => {
|
|
488
552
|
const itemValue = index + 1;
|
|
489
553
|
const ratingItemProps = {
|
|
@@ -504,41 +568,42 @@ const Rating = /*#__PURE__*/React.forwardRef(function Rating(inProps, ref) {
|
|
|
504
568
|
ratingValue: value,
|
|
505
569
|
ratingValueRounded: valueRounded,
|
|
506
570
|
readOnly,
|
|
507
|
-
ownerState
|
|
571
|
+
ownerState,
|
|
572
|
+
slots,
|
|
573
|
+
slotProps
|
|
508
574
|
};
|
|
509
575
|
const isActive = itemValue === Math.ceil(value) && (hover !== -1 || focus !== -1);
|
|
510
576
|
if (precision < 1) {
|
|
511
577
|
const items = Array.from(new Array(1 / precision));
|
|
512
|
-
return /*#__PURE__*/
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
578
|
+
return /*#__PURE__*/_createElement(DecimalSlot, {
|
|
579
|
+
...decimalSlotProps,
|
|
580
|
+
key: itemValue,
|
|
581
|
+
className: clsx(decimalSlotProps.className, isActive && classes.iconActive),
|
|
582
|
+
iconActive: isActive
|
|
583
|
+
}, items.map(($, indexDecimal) => {
|
|
584
|
+
const itemDecimalValue = roundValueToPrecision(itemValue - 1 + (indexDecimal + 1) * precision, precision);
|
|
585
|
+
return /*#__PURE__*/_jsx(RatingItem, {
|
|
586
|
+
...ratingItemProps,
|
|
587
|
+
// The icon is already displayed as active
|
|
588
|
+
isActive: false,
|
|
589
|
+
itemValue: itemDecimalValue,
|
|
590
|
+
labelProps: {
|
|
591
|
+
style: items.length - 1 === indexDecimal ? {} : {
|
|
592
|
+
width: itemDecimalValue === value ? `${(indexDecimal + 1) * precision * 100}%` : '0%',
|
|
593
|
+
overflow: 'hidden',
|
|
594
|
+
position: 'absolute'
|
|
529
595
|
}
|
|
530
|
-
}
|
|
531
|
-
})
|
|
532
|
-
}
|
|
596
|
+
}
|
|
597
|
+
}, itemDecimalValue);
|
|
598
|
+
}));
|
|
533
599
|
}
|
|
534
600
|
return /*#__PURE__*/_jsx(RatingItem, {
|
|
535
601
|
...ratingItemProps,
|
|
536
602
|
isActive: isActive,
|
|
537
603
|
itemValue: itemValue
|
|
538
604
|
}, itemValue);
|
|
539
|
-
}), !readOnly && !disabled && /*#__PURE__*/_jsxs(
|
|
540
|
-
|
|
541
|
-
ownerState: ownerState,
|
|
605
|
+
}), !readOnly && !disabled && /*#__PURE__*/_jsxs(LabelSlot, {
|
|
606
|
+
...labelSlotProps,
|
|
542
607
|
children: [/*#__PURE__*/_jsx("input", {
|
|
543
608
|
className: classes.visuallyHidden,
|
|
544
609
|
value: "",
|
|
@@ -622,6 +687,7 @@ process.env.NODE_ENV !== "production" ? Rating.propTypes /* remove-proptypes */
|
|
|
622
687
|
icon: PropTypes.node,
|
|
623
688
|
/**
|
|
624
689
|
* The component containing the icon.
|
|
690
|
+
* @deprecated Use `slotProps.icon.component` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
625
691
|
* @default function IconContainer(props) {
|
|
626
692
|
* const { value, ...other } = props;
|
|
627
693
|
* return <span {...other} />;
|
|
@@ -679,6 +745,26 @@ process.env.NODE_ENV !== "production" ? Rating.propTypes /* remove-proptypes */
|
|
|
679
745
|
* @default 'medium'
|
|
680
746
|
*/
|
|
681
747
|
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['small', 'medium', 'large']), PropTypes.string]),
|
|
748
|
+
/**
|
|
749
|
+
* The props used for each slot inside.
|
|
750
|
+
* @default {}
|
|
751
|
+
*/
|
|
752
|
+
slotProps: PropTypes.shape({
|
|
753
|
+
decimal: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
754
|
+
icon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
755
|
+
label: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
756
|
+
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
757
|
+
}),
|
|
758
|
+
/**
|
|
759
|
+
* The components used for each slot inside.
|
|
760
|
+
* @default {}
|
|
761
|
+
*/
|
|
762
|
+
slots: PropTypes.shape({
|
|
763
|
+
decimal: PropTypes.elementType,
|
|
764
|
+
icon: PropTypes.elementType,
|
|
765
|
+
label: PropTypes.elementType,
|
|
766
|
+
root: PropTypes.elementType
|
|
767
|
+
}),
|
|
682
768
|
/**
|
|
683
769
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
684
770
|
*/
|