@mui/material 5.15.11 → 5.15.13

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 (97) hide show
  1. package/Alert/Alert.d.ts +2 -2
  2. package/Alert/Alert.js +53 -35
  3. package/Alert/alertClasses.d.ts +68 -12
  4. package/Alert/alertClasses.js +1 -1
  5. package/AlertTitle/AlertTitle.js +2 -2
  6. package/Autocomplete/Autocomplete.js +58 -49
  7. package/Avatar/Avatar.js +2 -2
  8. package/Button/Button.js +3 -3
  9. package/Button/buttonClasses.d.ts +113 -33
  10. package/Button/buttonClasses.js +1 -1
  11. package/CHANGELOG.md +290 -116
  12. package/Checkbox/Checkbox.d.ts +1 -1
  13. package/Chip/chipClasses.d.ts +78 -26
  14. package/Drawer/Drawer.js +9 -3
  15. package/LinearProgress/LinearProgress.js +4 -4
  16. package/Menu/Menu.js +5 -4
  17. package/MenuList/MenuList.js +4 -2
  18. package/PaginationItem/PaginationItem.js +3 -3
  19. package/README.md +1 -1
  20. package/Rating/Rating.js +3 -3
  21. package/Slider/Slider.d.ts +2 -4
  22. package/Slider/Slider.js +4 -7
  23. package/Switch/Switch.js +61 -41
  24. package/TabScrollButton/TabScrollButton.js +2 -3
  25. package/TablePagination/TablePaginationActions.js +14 -14
  26. package/Tabs/Tabs.js +3 -2
  27. package/Tooltip/Tooltip.js +5 -4
  28. package/index.js +1 -1
  29. package/legacy/Alert/Alert.js +77 -34
  30. package/legacy/Alert/alertClasses.js +1 -1
  31. package/legacy/AlertTitle/AlertTitle.js +2 -2
  32. package/legacy/Autocomplete/Autocomplete.js +62 -51
  33. package/legacy/Avatar/Avatar.js +2 -2
  34. package/legacy/Button/Button.js +3 -3
  35. package/legacy/Button/buttonClasses.js +1 -1
  36. package/legacy/Drawer/Drawer.js +8 -3
  37. package/legacy/LinearProgress/LinearProgress.js +4 -4
  38. package/legacy/Menu/Menu.js +5 -4
  39. package/legacy/MenuList/MenuList.js +3 -2
  40. package/legacy/PaginationItem/PaginationItem.js +3 -3
  41. package/legacy/Rating/Rating.js +3 -3
  42. package/legacy/Slider/Slider.js +4 -7
  43. package/legacy/Switch/Switch.js +88 -59
  44. package/legacy/TabScrollButton/TabScrollButton.js +2 -3
  45. package/legacy/TablePagination/TablePaginationActions.js +14 -14
  46. package/legacy/Tabs/Tabs.js +3 -2
  47. package/legacy/Tooltip/Tooltip.js +7 -3
  48. package/legacy/index.js +1 -1
  49. package/legacy/styles/experimental_extendTheme.js +3 -0
  50. package/modern/Alert/Alert.js +53 -35
  51. package/modern/Alert/alertClasses.js +1 -1
  52. package/modern/AlertTitle/AlertTitle.js +2 -2
  53. package/modern/Autocomplete/Autocomplete.js +58 -49
  54. package/modern/Avatar/Avatar.js +2 -2
  55. package/modern/Button/Button.js +3 -3
  56. package/modern/Button/buttonClasses.js +1 -1
  57. package/modern/Drawer/Drawer.js +9 -3
  58. package/modern/LinearProgress/LinearProgress.js +4 -4
  59. package/modern/Menu/Menu.js +5 -4
  60. package/modern/MenuList/MenuList.js +4 -2
  61. package/modern/PaginationItem/PaginationItem.js +3 -3
  62. package/modern/Rating/Rating.js +3 -3
  63. package/modern/Slider/Slider.js +4 -7
  64. package/modern/Switch/Switch.js +61 -41
  65. package/modern/TabScrollButton/TabScrollButton.js +2 -3
  66. package/modern/TablePagination/TablePaginationActions.js +14 -14
  67. package/modern/Tabs/Tabs.js +3 -2
  68. package/modern/Tooltip/Tooltip.js +5 -4
  69. package/modern/index.js +1 -1
  70. package/modern/styles/experimental_extendTheme.js +3 -0
  71. package/node/Alert/Alert.js +61 -43
  72. package/node/Alert/alertClasses.js +1 -1
  73. package/node/AlertTitle/AlertTitle.js +4 -4
  74. package/node/Autocomplete/Autocomplete.js +58 -49
  75. package/node/Avatar/Avatar.js +6 -6
  76. package/node/Button/Button.js +3 -3
  77. package/node/Button/buttonClasses.js +1 -1
  78. package/node/Drawer/Drawer.js +9 -3
  79. package/node/LinearProgress/LinearProgress.js +4 -4
  80. package/node/Menu/Menu.js +5 -4
  81. package/node/MenuList/MenuList.js +4 -2
  82. package/node/PaginationItem/PaginationItem.js +3 -3
  83. package/node/Rating/Rating.js +3 -3
  84. package/node/Slider/Slider.js +4 -7
  85. package/node/Switch/Switch.js +66 -46
  86. package/node/TabScrollButton/TabScrollButton.js +2 -3
  87. package/node/TablePagination/TablePaginationActions.js +14 -14
  88. package/node/Tabs/Tabs.js +3 -2
  89. package/node/Tooltip/Tooltip.js +5 -4
  90. package/node/index.js +1 -1
  91. package/node/styles/experimental_extendTheme.js +3 -0
  92. package/package.json +5 -5
  93. package/styles/experimental_extendTheme.d.ts +1 -0
  94. package/styles/experimental_extendTheme.js +3 -0
  95. package/styles/variants.d.ts +7 -1
  96. package/umd/material-ui.development.js +6197 -6084
  97. package/umd/material-ui.production.min.js +2 -2
@@ -550,6 +550,63 @@ const Autocomplete = /*#__PURE__*/React.forwardRef(function Autocomplete(inProps
550
550
  const paperSlotProps = slotProps.paper ?? componentsProps.paper;
551
551
  const popperSlotProps = slotProps.popper ?? componentsProps.popper;
552
552
  const popupIndicatorSlotProps = slotProps.popupIndicator ?? componentsProps.popupIndicator;
553
+ const renderAutocompletePopperChildren = children => /*#__PURE__*/_jsx(AutocompletePopper, _extends({
554
+ as: PopperComponent,
555
+ disablePortal: disablePortal,
556
+ style: {
557
+ width: anchorEl ? anchorEl.clientWidth : null
558
+ },
559
+ ownerState: ownerState,
560
+ role: "presentation",
561
+ anchorEl: anchorEl,
562
+ open: popupOpen
563
+ }, popperSlotProps, {
564
+ className: clsx(classes.popper, popperSlotProps?.className),
565
+ children: /*#__PURE__*/_jsx(AutocompletePaper, _extends({
566
+ ownerState: ownerState,
567
+ as: PaperComponent
568
+ }, paperSlotProps, {
569
+ className: clsx(classes.paper, paperSlotProps?.className),
570
+ children: children
571
+ }))
572
+ }));
573
+ let autocompletePopper = null;
574
+ if (!loading && groupedOptions.length > 0) {
575
+ autocompletePopper = renderAutocompletePopperChildren( /*#__PURE__*/_jsx(AutocompleteListbox, _extends({
576
+ as: ListboxComponent,
577
+ className: classes.listbox,
578
+ ownerState: ownerState
579
+ }, otherListboxProps, ListboxProps, {
580
+ ref: combinedListboxRef,
581
+ children: groupedOptions.map((option, index) => {
582
+ if (groupBy) {
583
+ return renderGroup({
584
+ key: option.key,
585
+ group: option.group,
586
+ children: option.options.map((option2, index2) => renderListOption(option2, option.index + index2))
587
+ });
588
+ }
589
+ return renderListOption(option, index);
590
+ })
591
+ })));
592
+ } else if (loading && groupedOptions.length === 0) {
593
+ autocompletePopper = renderAutocompletePopperChildren( /*#__PURE__*/_jsx(AutocompleteLoading, {
594
+ className: classes.loading,
595
+ ownerState: ownerState,
596
+ children: loadingText
597
+ }));
598
+ } else if (groupedOptions.length === 0 && !freeSolo && !loading) {
599
+ autocompletePopper = renderAutocompletePopperChildren( /*#__PURE__*/_jsx(AutocompleteNoOptions, {
600
+ className: classes.noOptions,
601
+ ownerState: ownerState,
602
+ role: "presentation",
603
+ onMouseDown: event => {
604
+ // Prevent input blur when interacting with the "no options" content
605
+ event.preventDefault();
606
+ },
607
+ children: noOptionsText
608
+ }));
609
+ }
553
610
  return /*#__PURE__*/_jsxs(React.Fragment, {
554
611
  children: [/*#__PURE__*/_jsx(AutocompleteRoot, _extends({
555
612
  ref: ref,
@@ -599,55 +656,7 @@ const Autocomplete = /*#__PURE__*/React.forwardRef(function Autocomplete(inProps
599
656
  readOnly
600
657
  }, getInputProps())
601
658
  })
602
- })), anchorEl ? /*#__PURE__*/_jsx(AutocompletePopper, _extends({
603
- as: PopperComponent,
604
- disablePortal: disablePortal,
605
- style: {
606
- width: anchorEl ? anchorEl.clientWidth : null
607
- },
608
- ownerState: ownerState,
609
- role: "presentation",
610
- anchorEl: anchorEl,
611
- open: popupOpen
612
- }, popperSlotProps, {
613
- className: clsx(classes.popper, popperSlotProps?.className),
614
- children: /*#__PURE__*/_jsxs(AutocompletePaper, _extends({
615
- ownerState: ownerState,
616
- as: PaperComponent
617
- }, paperSlotProps, {
618
- className: clsx(classes.paper, paperSlotProps?.className),
619
- children: [loading && groupedOptions.length === 0 ? /*#__PURE__*/_jsx(AutocompleteLoading, {
620
- className: classes.loading,
621
- ownerState: ownerState,
622
- children: loadingText
623
- }) : null, groupedOptions.length === 0 && !freeSolo && !loading ? /*#__PURE__*/_jsx(AutocompleteNoOptions, {
624
- className: classes.noOptions,
625
- ownerState: ownerState,
626
- role: "presentation",
627
- onMouseDown: event => {
628
- // Prevent input blur when interacting with the "no options" content
629
- event.preventDefault();
630
- },
631
- children: noOptionsText
632
- }) : null, groupedOptions.length > 0 ? /*#__PURE__*/_jsx(AutocompleteListbox, _extends({
633
- as: ListboxComponent,
634
- className: classes.listbox,
635
- ownerState: ownerState
636
- }, otherListboxProps, ListboxProps, {
637
- ref: combinedListboxRef,
638
- children: groupedOptions.map((option, index) => {
639
- if (groupBy) {
640
- return renderGroup({
641
- key: option.key,
642
- group: option.group,
643
- children: option.options.map((option2, index2) => renderListOption(option2, option.index + index2))
644
- });
645
- }
646
- return renderListOption(option, index);
647
- })
648
- })) : null]
649
- }))
650
- })) : null]
659
+ })), anchorEl ? autocompletePopper : null]
651
660
  });
652
661
  });
653
662
  process.env.NODE_ENV !== "production" ? Autocomplete.propTypes /* remove-proptypes */ = {
@@ -7,12 +7,12 @@ import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import clsx from 'clsx';
9
9
  import composeClasses from '@mui/utils/composeClasses';
10
- import styled from '../styles/styled';
11
- import useThemeProps from '../styles/useThemeProps';
10
+ import { styled, createUseThemeProps } from '../zero-styled';
12
11
  import Person from '../internal/svg-icons/Person';
13
12
  import { getAvatarUtilityClass } from './avatarClasses';
14
13
  import useSlot from '../utils/useSlot';
15
14
  import { jsx as _jsx } from "react/jsx-runtime";
15
+ const useThemeProps = createUseThemeProps('MuiAvatar');
16
16
  const useUtilityClasses = ownerState => {
17
17
  const {
18
18
  classes,
@@ -28,10 +28,10 @@ const useUtilityClasses = ownerState => {
28
28
  classes
29
29
  } = ownerState;
30
30
  const slots = {
31
- root: ['root', variant, `${variant}${capitalize(color)}`, `size${capitalize(size)}`, `${variant}Size${capitalize(size)}`, color === 'inherit' && 'colorInherit', disableElevation && 'disableElevation', fullWidth && 'fullWidth'],
31
+ root: ['root', variant, `${variant}${capitalize(color)}`, `size${capitalize(size)}`, `${variant}Size${capitalize(size)}`, `color${capitalize(color)}`, disableElevation && 'disableElevation', fullWidth && 'fullWidth'],
32
32
  label: ['label'],
33
- startIcon: ['startIcon', `iconSize${capitalize(size)}`],
34
- endIcon: ['endIcon', `iconSize${capitalize(size)}`]
33
+ startIcon: ['icon', 'startIcon', `iconSize${capitalize(size)}`],
34
+ endIcon: ['icon', 'endIcon', `iconSize${capitalize(size)}`]
35
35
  };
36
36
  const composedClasses = composeClasses(slots, getButtonUtilityClass, classes);
37
37
  return _extends({}, classes, composedClasses);
@@ -3,5 +3,5 @@ import generateUtilityClass from '@mui/utils/generateUtilityClass';
3
3
  export function getButtonUtilityClass(slot) {
4
4
  return generateUtilityClass('MuiButton', slot);
5
5
  }
6
- const buttonClasses = generateUtilityClasses('MuiButton', ['root', 'text', 'textInherit', 'textPrimary', 'textSecondary', 'textSuccess', 'textError', 'textInfo', 'textWarning', 'outlined', 'outlinedInherit', 'outlinedPrimary', 'outlinedSecondary', 'outlinedSuccess', 'outlinedError', 'outlinedInfo', 'outlinedWarning', 'contained', 'containedInherit', 'containedPrimary', 'containedSecondary', 'containedSuccess', 'containedError', 'containedInfo', 'containedWarning', 'disableElevation', 'focusVisible', 'disabled', 'colorInherit', 'textSizeSmall', 'textSizeMedium', 'textSizeLarge', 'outlinedSizeSmall', 'outlinedSizeMedium', 'outlinedSizeLarge', 'containedSizeSmall', 'containedSizeMedium', 'containedSizeLarge', 'sizeMedium', 'sizeSmall', 'sizeLarge', 'fullWidth', 'startIcon', 'endIcon', 'iconSizeSmall', 'iconSizeMedium', 'iconSizeLarge']);
6
+ const buttonClasses = generateUtilityClasses('MuiButton', ['root', 'text', 'textInherit', 'textPrimary', 'textSecondary', 'textSuccess', 'textError', 'textInfo', 'textWarning', 'outlined', 'outlinedInherit', 'outlinedPrimary', 'outlinedSecondary', 'outlinedSuccess', 'outlinedError', 'outlinedInfo', 'outlinedWarning', 'contained', 'containedInherit', 'containedPrimary', 'containedSecondary', 'containedSuccess', 'containedError', 'containedInfo', 'containedWarning', 'disableElevation', 'focusVisible', 'disabled', 'colorInherit', 'colorPrimary', 'colorSecondary', 'colorSuccess', 'colorError', 'colorInfo', 'colorWarning', 'textSizeSmall', 'textSizeMedium', 'textSizeLarge', 'outlinedSizeSmall', 'outlinedSizeMedium', 'outlinedSizeLarge', 'containedSizeSmall', 'containedSizeMedium', 'containedSizeLarge', 'sizeMedium', 'sizeSmall', 'sizeLarge', 'fullWidth', 'startIcon', 'endIcon', 'icon', 'iconSizeSmall', 'iconSizeMedium', 'iconSizeLarge']);
7
7
  export default buttonClasses;
@@ -9,6 +9,7 @@ import PropTypes from 'prop-types';
9
9
  import clsx from 'clsx';
10
10
  import integerPropType from '@mui/utils/integerPropType';
11
11
  import composeClasses from '@mui/utils/composeClasses';
12
+ import { useRtl } from '@mui/system/RtlProvider';
12
13
  import Modal from '../Modal';
13
14
  import Slide from '../Slide';
14
15
  import Paper from '../Paper';
@@ -119,8 +120,10 @@ const oppositeDirection = {
119
120
  export function isHorizontal(anchor) {
120
121
  return ['left', 'right'].indexOf(anchor) !== -1;
121
122
  }
122
- export function getAnchor(theme, anchor) {
123
- return theme.direction === 'rtl' && isHorizontal(anchor) ? oppositeDirection[anchor] : anchor;
123
+ export function getAnchor({
124
+ direction
125
+ }, anchor) {
126
+ return direction === 'rtl' && isHorizontal(anchor) ? oppositeDirection[anchor] : anchor;
124
127
  }
125
128
 
126
129
  /**
@@ -133,6 +136,7 @@ const Drawer = /*#__PURE__*/React.forwardRef(function Drawer(inProps, ref) {
133
136
  name: 'MuiDrawer'
134
137
  });
135
138
  const theme = useTheme();
139
+ const isRtl = useRtl();
136
140
  const defaultTransitionDuration = {
137
141
  enter: theme.transitions.duration.enteringScreen,
138
142
  exit: theme.transitions.duration.leavingScreen
@@ -166,7 +170,9 @@ const Drawer = /*#__PURE__*/React.forwardRef(function Drawer(inProps, ref) {
166
170
  React.useEffect(() => {
167
171
  mounted.current = true;
168
172
  }, []);
169
- const anchorInvariant = getAnchor(theme, anchorProp);
173
+ const anchorInvariant = getAnchor({
174
+ direction: isRtl ? 'rtl' : 'ltr'
175
+ }, anchorProp);
170
176
  const anchor = anchorProp;
171
177
  const ownerState = _extends({}, props, {
172
178
  anchor,
@@ -9,8 +9,8 @@ import clsx from 'clsx';
9
9
  import composeClasses from '@mui/utils/composeClasses';
10
10
  import { keyframes, css } from '@mui/system';
11
11
  import { darken, lighten } from '@mui/system/colorManipulator';
12
+ import { useRtl } from '@mui/system/RtlProvider';
12
13
  import capitalize from '../utils/capitalize';
13
- import useTheme from '../styles/useTheme';
14
14
  import styled from '../styles/styled';
15
15
  import useThemeProps from '../styles/useThemeProps';
16
16
  import { getLinearProgressUtilityClass } from './linearProgressClasses';
@@ -248,7 +248,7 @@ const LinearProgress = /*#__PURE__*/React.forwardRef(function LinearProgress(inP
248
248
  variant
249
249
  });
250
250
  const classes = useUtilityClasses(ownerState);
251
- const theme = useTheme();
251
+ const isRtl = useRtl();
252
252
  const rootProps = {};
253
253
  const inlineStyles = {
254
254
  bar1: {},
@@ -260,7 +260,7 @@ const LinearProgress = /*#__PURE__*/React.forwardRef(function LinearProgress(inP
260
260
  rootProps['aria-valuemin'] = 0;
261
261
  rootProps['aria-valuemax'] = 100;
262
262
  let transform = value - 100;
263
- if (theme.direction === 'rtl') {
263
+ if (isRtl) {
264
264
  transform = -transform;
265
265
  }
266
266
  inlineStyles.bar1.transform = `translateX(${transform}%)`;
@@ -271,7 +271,7 @@ const LinearProgress = /*#__PURE__*/React.forwardRef(function LinearProgress(inP
271
271
  if (variant === 'buffer') {
272
272
  if (valueBuffer !== undefined) {
273
273
  let transform = (valueBuffer || 0) - 100;
274
- if (theme.direction === 'rtl') {
274
+ if (isRtl) {
275
275
  transform = -transform;
276
276
  }
277
277
  inlineStyles.bar2.transform = `translateX(${transform}%)`;
@@ -11,10 +11,10 @@ import clsx from 'clsx';
11
11
  import composeClasses from '@mui/utils/composeClasses';
12
12
  import { useSlotProps } from '@mui/base/utils';
13
13
  import HTMLElementType from '@mui/utils/HTMLElementType';
14
+ import { useRtl } from '@mui/system/RtlProvider';
14
15
  import MenuList from '../MenuList';
15
16
  import Popover, { PopoverPaper } from '../Popover';
16
17
  import styled, { rootShouldForwardProp } from '../styles/styled';
17
- import useTheme from '../styles/useTheme';
18
18
  import useThemeProps from '../styles/useThemeProps';
19
19
  import { getMenuUtilityClass } from './menuClasses';
20
20
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -88,8 +88,7 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu(inProps, ref) {
88
88
  } = props,
89
89
  TransitionProps = _objectWithoutPropertiesLoose(props.TransitionProps, _excluded),
90
90
  other = _objectWithoutPropertiesLoose(props, _excluded2);
91
- const theme = useTheme();
92
- const isRtl = theme.direction === 'rtl';
91
+ const isRtl = useRtl();
93
92
  const ownerState = _extends({}, props, {
94
93
  autoFocus,
95
94
  disableAutoFocusItem,
@@ -105,7 +104,9 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu(inProps, ref) {
105
104
  const menuListActionsRef = React.useRef(null);
106
105
  const handleEntering = (element, isAppearing) => {
107
106
  if (menuListActionsRef.current) {
108
- menuListActionsRef.current.adjustStyleForScrollbar(element, theme);
107
+ menuListActionsRef.current.adjustStyleForScrollbar(element, {
108
+ direction: isRtl ? 'rtl' : 'ltr'
109
+ });
109
110
  }
110
111
  if (onEntering) {
111
112
  onEntering(element, isAppearing);
@@ -107,13 +107,15 @@ const MenuList = /*#__PURE__*/React.forwardRef(function MenuList(props, ref) {
107
107
  }
108
108
  }, [autoFocus]);
109
109
  React.useImperativeHandle(actions, () => ({
110
- adjustStyleForScrollbar: (containerElement, theme) => {
110
+ adjustStyleForScrollbar: (containerElement, {
111
+ direction
112
+ }) => {
111
113
  // Let's ignore that piece of logic if users are already overriding the width
112
114
  // of the menu.
113
115
  const noExplicitWidth = !listRef.current.style.width;
114
116
  if (containerElement.clientHeight < listRef.current.clientHeight && noExplicitWidth) {
115
117
  const scrollbarSize = `${getScrollbarSize(ownerDocument(containerElement))}px`;
116
- listRef.current.style[theme.direction === 'rtl' ? 'paddingLeft' : 'paddingRight'] = scrollbarSize;
118
+ listRef.current.style[direction === 'rtl' ? 'paddingLeft' : 'paddingRight'] = scrollbarSize;
117
119
  listRef.current.style.width = `calc(100% + ${scrollbarSize})`;
118
120
  }
119
121
  return listRef.current;
@@ -8,9 +8,9 @@ import PropTypes from 'prop-types';
8
8
  import clsx from 'clsx';
9
9
  import composeClasses from '@mui/utils/composeClasses';
10
10
  import { alpha } from '@mui/system/colorManipulator';
11
+ import { useRtl } from '@mui/system/RtlProvider';
11
12
  import useThemeProps from '../styles/useThemeProps';
12
13
  import paginationItemClasses, { getPaginationItemUtilityClass } from './paginationItemClasses';
13
- import useTheme from '../styles/useTheme';
14
14
  import ButtonBase from '../ButtonBase';
15
15
  import capitalize from '../utils/capitalize';
16
16
  import FirstPageIcon from '../internal/svg-icons/FirstPage';
@@ -234,9 +234,9 @@ const PaginationItem = /*#__PURE__*/React.forwardRef(function PaginationItem(inP
234
234
  type,
235
235
  variant
236
236
  });
237
- const theme = useTheme();
237
+ const isRtl = useRtl();
238
238
  const classes = useUtilityClasses(ownerState);
239
- const normalizedIcons = theme.direction === 'rtl' ? {
239
+ const normalizedIcons = isRtl ? {
240
240
  previous: slots.next || components.next || NavigateNextIcon,
241
241
  next: slots.previous || components.previous || NavigateBeforeIcon,
242
242
  last: slots.first || components.first || FirstPageIcon,
@@ -11,7 +11,7 @@ import clamp from '@mui/utils/clamp';
11
11
  import visuallyHidden from '@mui/utils/visuallyHidden';
12
12
  import chainPropTypes from '@mui/utils/chainPropTypes';
13
13
  import composeClasses from '@mui/utils/composeClasses';
14
- import useTheme from '../styles/useTheme';
14
+ import { useRtl } from '@mui/system/RtlProvider';
15
15
  import { capitalize, useForkRef, useIsFocusVisible, useControlled, unstable_useId as useId } from '../utils';
16
16
  import Star from '../internal/svg-icons/Star';
17
17
  import StarBorder from '../internal/svg-icons/StarBorder';
@@ -300,7 +300,7 @@ const Rating = /*#__PURE__*/React.forwardRef(function Rating(inProps, ref) {
300
300
  name: 'Rating'
301
301
  });
302
302
  const valueRounded = roundValueToPrecision(valueDerived, precision);
303
- const theme = useTheme();
303
+ const isRtl = useRtl();
304
304
  const [{
305
305
  hover,
306
306
  focus
@@ -335,7 +335,7 @@ const Rating = /*#__PURE__*/React.forwardRef(function Rating(inProps, ref) {
335
335
  width: containerWidth
336
336
  } = rootNode.getBoundingClientRect();
337
337
  let percent;
338
- if (theme.direction === 'rtl') {
338
+ if (isRtl) {
339
339
  percent = (right - event.clientX) / containerWidth;
340
340
  } else {
341
341
  percent = (event.clientX - left) / containerWidth;
@@ -11,9 +11,9 @@ import { isHostComponent, useSlotProps } from '@mui/base/utils';
11
11
  import composeClasses from '@mui/utils/composeClasses';
12
12
  import { useSlider, valueToPercent } from '@mui/base/useSlider';
13
13
  import { alpha, lighten, darken } from '@mui/system/colorManipulator';
14
+ import { useRtl } from '@mui/system/RtlProvider';
14
15
  import useThemeProps from '../styles/useThemeProps';
15
16
  import styled, { slotShouldForwardProp } from '../styles/styled';
16
- import useTheme from '../styles/useTheme';
17
17
  import shouldSpreadAdditionalProps from '../utils/shouldSpreadAdditionalProps';
18
18
  import capitalize from '../utils/capitalize';
19
19
  import BaseSliderValueLabel from './SliderValueLabel';
@@ -370,8 +370,7 @@ const Slider = /*#__PURE__*/React.forwardRef(function Slider(inputProps, ref) {
370
370
  props: inputProps,
371
371
  name: 'MuiSlider'
372
372
  });
373
- const theme = useTheme();
374
- const isRtl = theme.direction === 'rtl';
373
+ const isRtl = useRtl();
375
374
  const {
376
375
  'aria-label': ariaLabel,
377
376
  'aria-valuetext': ariaValuetext,
@@ -632,8 +631,7 @@ process.env.NODE_ENV !== "production" ? Slider.propTypes /* remove-proptypes */
632
631
  /**
633
632
  * The components used for each slot inside.
634
633
  *
635
- * This prop is an alias for the `slots` prop.
636
- * It's recommended to use the `slots` prop instead.
634
+ * @deprecated use the `slots` prop instead. This prop will be removed in v7. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/).
637
635
  *
638
636
  * @default {}
639
637
  */
@@ -651,8 +649,7 @@ process.env.NODE_ENV !== "production" ? Slider.propTypes /* remove-proptypes */
651
649
  * The extra props for the slot components.
652
650
  * You can override the existing props or add new ones.
653
651
  *
654
- * This prop is an alias for the `slotProps` prop.
655
- * It's recommended to use the `slotProps` prop instead, as `componentsProps` will be deprecated in the future.
652
+ * @deprecated use the `slotProps` prop instead. This prop will be removed in v7. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/).
656
653
  *
657
654
  * @default {}
658
655
  */
@@ -12,11 +12,11 @@ import composeClasses from '@mui/utils/composeClasses';
12
12
  import { alpha, darken, lighten } from '@mui/system/colorManipulator';
13
13
  import capitalize from '../utils/capitalize';
14
14
  import SwitchBase from '../internal/SwitchBase';
15
- import useThemeProps from '../styles/useThemeProps';
16
- import styled from '../styles/styled';
15
+ import { styled, createUseThemeProps } from '../zero-styled';
17
16
  import switchClasses, { getSwitchUtilityClass } from './switchClasses';
18
17
  import { jsx as _jsx } from "react/jsx-runtime";
19
18
  import { jsxs as _jsxs } from "react/jsx-runtime";
19
+ const useThemeProps = createUseThemeProps('MuiSwitch');
20
20
  const useUtilityClasses = ownerState => {
21
21
  const {
22
22
  classes,
@@ -45,9 +45,7 @@ const SwitchRoot = styled('span', {
45
45
  } = props;
46
46
  return [styles.root, ownerState.edge && styles[`edge${capitalize(ownerState.edge)}`], styles[`size${capitalize(ownerState.size)}`]];
47
47
  }
48
- })(({
49
- ownerState
50
- }) => _extends({
48
+ })({
51
49
  display: 'inline-flex',
52
50
  width: 34 + 12 * 2,
53
51
  height: 14 + 12 * 2,
@@ -62,26 +60,42 @@ const SwitchRoot = styled('span', {
62
60
  // For correct alignment with the text.
63
61
  '@media print': {
64
62
  colorAdjust: 'exact'
65
- }
66
- }, ownerState.edge === 'start' && {
67
- marginLeft: -8
68
- }, ownerState.edge === 'end' && {
69
- marginRight: -8
70
- }, ownerState.size === 'small' && {
71
- width: 40,
72
- height: 24,
73
- padding: 7,
74
- [`& .${switchClasses.thumb}`]: {
75
- width: 16,
76
- height: 16
77
63
  },
78
- [`& .${switchClasses.switchBase}`]: {
79
- padding: 4,
80
- [`&.${switchClasses.checked}`]: {
81
- transform: 'translateX(16px)'
64
+ variants: [{
65
+ props: {
66
+ edge: 'start'
67
+ },
68
+ style: {
69
+ marginLeft: -8
82
70
  }
83
- }
84
- }));
71
+ }, {
72
+ props: {
73
+ edge: 'end'
74
+ },
75
+ style: {
76
+ marginRight: -8
77
+ }
78
+ }, {
79
+ props: {
80
+ size: 'small'
81
+ },
82
+ style: {
83
+ width: 40,
84
+ height: 24,
85
+ padding: 7,
86
+ [`& .${switchClasses.thumb}`]: {
87
+ width: 16,
88
+ height: 16
89
+ },
90
+ [`& .${switchClasses.switchBase}`]: {
91
+ padding: 4,
92
+ [`&.${switchClasses.checked}`]: {
93
+ transform: 'translateX(16px)'
94
+ }
95
+ }
96
+ }
97
+ }]
98
+ });
85
99
  const SwitchSwitchBase = styled(SwitchBase, {
86
100
  name: 'MuiSwitch',
87
101
  slot: 'SwitchBase',
@@ -122,32 +136,38 @@ const SwitchSwitchBase = styled(SwitchBase, {
122
136
  width: '300%'
123
137
  }
124
138
  }), ({
125
- theme,
126
- ownerState
127
- }) => _extends({
139
+ theme
140
+ }) => ({
128
141
  '&:hover': {
129
142
  backgroundColor: theme.vars ? `rgba(${theme.vars.palette.action.activeChannel} / ${theme.vars.palette.action.hoverOpacity})` : alpha(theme.palette.action.active, theme.palette.action.hoverOpacity),
130
143
  // Reset on touch devices, it doesn't add specificity
131
144
  '@media (hover: none)': {
132
145
  backgroundColor: 'transparent'
133
146
  }
134
- }
135
- }, ownerState.color !== 'default' && {
136
- [`&.${switchClasses.checked}`]: {
137
- color: (theme.vars || theme).palette[ownerState.color].main,
138
- '&:hover': {
139
- backgroundColor: theme.vars ? `rgba(${theme.vars.palette[ownerState.color].mainChannel} / ${theme.vars.palette.action.hoverOpacity})` : alpha(theme.palette[ownerState.color].main, theme.palette.action.hoverOpacity),
140
- '@media (hover: none)': {
141
- backgroundColor: 'transparent'
142
- }
147
+ },
148
+ variants: [...Object.entries(theme.palette).filter(([, value]) => value.main && value.light) // check all the used fields in the style below
149
+ .map(([color]) => ({
150
+ props: {
151
+ color
143
152
  },
144
- [`&.${switchClasses.disabled}`]: {
145
- color: theme.vars ? theme.vars.palette.Switch[`${ownerState.color}DisabledColor`] : `${theme.palette.mode === 'light' ? lighten(theme.palette[ownerState.color].main, 0.62) : darken(theme.palette[ownerState.color].main, 0.55)}`
153
+ style: {
154
+ [`&.${switchClasses.checked}`]: {
155
+ color: (theme.vars || theme).palette[color].main,
156
+ '&:hover': {
157
+ backgroundColor: theme.vars ? `rgba(${theme.vars.palette[color].mainChannel} / ${theme.vars.palette.action.hoverOpacity})` : alpha(theme.palette[color].main, theme.palette.action.hoverOpacity),
158
+ '@media (hover: none)': {
159
+ backgroundColor: 'transparent'
160
+ }
161
+ },
162
+ [`&.${switchClasses.disabled}`]: {
163
+ color: theme.vars ? theme.vars.palette.Switch[`${color}DisabledColor`] : `${theme.palette.mode === 'light' ? lighten(theme.palette[color].main, 0.62) : darken(theme.palette[color].main, 0.55)}`
164
+ }
165
+ },
166
+ [`&.${switchClasses.checked} + .${switchClasses.track}`]: {
167
+ backgroundColor: (theme.vars || theme).palette[color].main
168
+ }
146
169
  }
147
- },
148
- [`&.${switchClasses.checked} + .${switchClasses.track}`]: {
149
- backgroundColor: (theme.vars || theme).palette[ownerState.color].main
150
- }
170
+ }))]
151
171
  }));
152
172
  const SwitchTrack = styled('span', {
153
173
  name: 'MuiSwitch',
@@ -9,10 +9,10 @@ import PropTypes from 'prop-types';
9
9
  import clsx from 'clsx';
10
10
  import { useSlotProps } from '@mui/base/utils';
11
11
  import composeClasses from '@mui/utils/composeClasses';
12
+ import { useRtl } from '@mui/system/RtlProvider';
12
13
  import KeyboardArrowLeft from '../internal/svg-icons/KeyboardArrowLeft';
13
14
  import KeyboardArrowRight from '../internal/svg-icons/KeyboardArrowRight';
14
15
  import ButtonBase from '../ButtonBase';
15
- import useTheme from '../styles/useTheme';
16
16
  import useThemeProps from '../styles/useThemeProps';
17
17
  import styled from '../styles/styled';
18
18
  import tabScrollButtonClasses, { getTabScrollButtonUtilityClass } from './tabScrollButtonClasses';
@@ -65,8 +65,7 @@ const TabScrollButton = /*#__PURE__*/React.forwardRef(function TabScrollButton(i
65
65
  direction
66
66
  } = props,
67
67
  other = _objectWithoutPropertiesLoose(props, _excluded);
68
- const theme = useTheme();
69
- const isRtl = theme.direction === 'rtl';
68
+ const isRtl = useRtl();
70
69
  const ownerState = _extends({
71
70
  isRtl
72
71
  }, props);
@@ -5,9 +5,9 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
5
5
  const _excluded = ["backIconButtonProps", "count", "disabled", "getItemAriaLabel", "nextIconButtonProps", "onPageChange", "page", "rowsPerPage", "showFirstButton", "showLastButton", "slots", "slotProps"];
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
+ import { useRtl } from '@mui/system/RtlProvider';
8
9
  import KeyboardArrowLeft from '../internal/svg-icons/KeyboardArrowLeft';
9
10
  import KeyboardArrowRight from '../internal/svg-icons/KeyboardArrowRight';
10
- import useTheme from '../styles/useTheme';
11
11
  import IconButton from '../IconButton';
12
12
  import LastPageIconDefault from '../internal/svg-icons/LastPage';
13
13
  import FirstPageIconDefault from '../internal/svg-icons/FirstPage';
@@ -33,7 +33,7 @@ const TablePaginationActions = /*#__PURE__*/React.forwardRef(function TablePagin
33
33
  slotProps = {}
34
34
  } = props,
35
35
  other = _objectWithoutPropertiesLoose(props, _excluded);
36
- const theme = useTheme();
36
+ const isRtl = useRtl();
37
37
  const handleFirstPageButtonClick = event => {
38
38
  onPageChange(event, 0);
39
39
  };
@@ -54,14 +54,14 @@ const TablePaginationActions = /*#__PURE__*/React.forwardRef(function TablePagin
54
54
  const LastButtonIcon = slots.lastButtonIcon ?? LastPageIconDefault;
55
55
  const NextButtonIcon = slots.nextButtonIcon ?? KeyboardArrowRight;
56
56
  const PreviousButtonIcon = slots.previousButtonIcon ?? KeyboardArrowLeft;
57
- const FirstButtonSlot = theme.direction === 'rtl' ? LastButton : FirstButton;
58
- const PreviousButtonSlot = theme.direction === 'rtl' ? NextButton : PreviousButton;
59
- const NextButtonSlot = theme.direction === 'rtl' ? PreviousButton : NextButton;
60
- const LastButtonSlot = theme.direction === 'rtl' ? FirstButton : LastButton;
61
- const firstButtonSlotProps = theme.direction === 'rtl' ? slotProps.lastButton : slotProps.firstButton;
62
- const previousButtonSlotProps = theme.direction === 'rtl' ? slotProps.nextButton : slotProps.previousButton;
63
- const nextButtonSlotProps = theme.direction === 'rtl' ? slotProps.previousButton : slotProps.nextButton;
64
- const lastButtonSlotProps = theme.direction === 'rtl' ? slotProps.firstButton : slotProps.lastButton;
57
+ const FirstButtonSlot = isRtl ? LastButton : FirstButton;
58
+ const PreviousButtonSlot = isRtl ? NextButton : PreviousButton;
59
+ const NextButtonSlot = isRtl ? PreviousButton : NextButton;
60
+ const LastButtonSlot = isRtl ? FirstButton : LastButton;
61
+ const firstButtonSlotProps = isRtl ? slotProps.lastButton : slotProps.firstButton;
62
+ const previousButtonSlotProps = isRtl ? slotProps.nextButton : slotProps.previousButton;
63
+ const nextButtonSlotProps = isRtl ? slotProps.previousButton : slotProps.nextButton;
64
+ const lastButtonSlotProps = isRtl ? slotProps.firstButton : slotProps.lastButton;
65
65
  return /*#__PURE__*/_jsxs("div", _extends({
66
66
  ref: ref
67
67
  }, other, {
@@ -71,7 +71,7 @@ const TablePaginationActions = /*#__PURE__*/React.forwardRef(function TablePagin
71
71
  "aria-label": getItemAriaLabel('first', page),
72
72
  title: getItemAriaLabel('first', page)
73
73
  }, firstButtonSlotProps, {
74
- children: theme.direction === 'rtl' ? /*#__PURE__*/_jsx(LastButtonIcon, _extends({}, slotProps.lastButtonIcon)) : /*#__PURE__*/_jsx(FirstButtonIcon, _extends({}, slotProps.firstButtonIcon))
74
+ children: isRtl ? /*#__PURE__*/_jsx(LastButtonIcon, _extends({}, slotProps.lastButtonIcon)) : /*#__PURE__*/_jsx(FirstButtonIcon, _extends({}, slotProps.firstButtonIcon))
75
75
  })), /*#__PURE__*/_jsx(PreviousButtonSlot, _extends({
76
76
  onClick: handleBackButtonClick,
77
77
  disabled: disabled || page === 0,
@@ -79,7 +79,7 @@ const TablePaginationActions = /*#__PURE__*/React.forwardRef(function TablePagin
79
79
  "aria-label": getItemAriaLabel('previous', page),
80
80
  title: getItemAriaLabel('previous', page)
81
81
  }, previousButtonSlotProps ?? backIconButtonProps, {
82
- children: theme.direction === 'rtl' ? /*#__PURE__*/_jsx(NextButtonIcon, _extends({}, slotProps.nextButtonIcon)) : /*#__PURE__*/_jsx(PreviousButtonIcon, _extends({}, slotProps.previousButtonIcon))
82
+ children: isRtl ? /*#__PURE__*/_jsx(NextButtonIcon, _extends({}, slotProps.nextButtonIcon)) : /*#__PURE__*/_jsx(PreviousButtonIcon, _extends({}, slotProps.previousButtonIcon))
83
83
  })), /*#__PURE__*/_jsx(NextButtonSlot, _extends({
84
84
  onClick: handleNextButtonClick,
85
85
  disabled: disabled || (count !== -1 ? page >= Math.ceil(count / rowsPerPage) - 1 : false),
@@ -87,14 +87,14 @@ const TablePaginationActions = /*#__PURE__*/React.forwardRef(function TablePagin
87
87
  "aria-label": getItemAriaLabel('next', page),
88
88
  title: getItemAriaLabel('next', page)
89
89
  }, nextButtonSlotProps ?? nextIconButtonProps, {
90
- children: theme.direction === 'rtl' ? /*#__PURE__*/_jsx(PreviousButtonIcon, _extends({}, slotProps.previousButtonIcon)) : /*#__PURE__*/_jsx(NextButtonIcon, _extends({}, slotProps.nextButtonIcon))
90
+ children: isRtl ? /*#__PURE__*/_jsx(PreviousButtonIcon, _extends({}, slotProps.previousButtonIcon)) : /*#__PURE__*/_jsx(NextButtonIcon, _extends({}, slotProps.nextButtonIcon))
91
91
  })), showLastButton && /*#__PURE__*/_jsx(LastButtonSlot, _extends({
92
92
  onClick: handleLastPageButtonClick,
93
93
  disabled: disabled || page >= Math.ceil(count / rowsPerPage) - 1,
94
94
  "aria-label": getItemAriaLabel('last', page),
95
95
  title: getItemAriaLabel('last', page)
96
96
  }, lastButtonSlotProps, {
97
- children: theme.direction === 'rtl' ? /*#__PURE__*/_jsx(FirstButtonIcon, _extends({}, slotProps.firstButtonIcon)) : /*#__PURE__*/_jsx(LastButtonIcon, _extends({}, slotProps.lastButtonIcon))
97
+ children: isRtl ? /*#__PURE__*/_jsx(FirstButtonIcon, _extends({}, slotProps.firstButtonIcon)) : /*#__PURE__*/_jsx(LastButtonIcon, _extends({}, slotProps.lastButtonIcon))
98
98
  }))]
99
99
  }));
100
100
  });
@@ -10,6 +10,7 @@ import clsx from 'clsx';
10
10
  import refType from '@mui/utils/refType';
11
11
  import { useSlotProps } from '@mui/base/utils';
12
12
  import composeClasses from '@mui/utils/composeClasses';
13
+ import { useRtl } from '@mui/system/RtlProvider';
13
14
  import styled from '../styles/styled';
14
15
  import useThemeProps from '../styles/useThemeProps';
15
16
  import useTheme from '../styles/useTheme';
@@ -209,7 +210,7 @@ const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(inProps, ref) {
209
210
  name: 'MuiTabs'
210
211
  });
211
212
  const theme = useTheme();
212
- const isRtl = theme.direction === 'rtl';
213
+ const isRtl = useRtl();
213
214
  const {
214
215
  'aria-label': ariaLabel,
215
216
  'aria-labelledby': ariaLabelledBy,
@@ -297,7 +298,7 @@ const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(inProps, ref) {
297
298
  clientWidth: tabsNode.clientWidth,
298
299
  scrollLeft: tabsNode.scrollLeft,
299
300
  scrollTop: tabsNode.scrollTop,
300
- scrollLeftNormalized: getNormalizedScrollLeft(tabsNode, theme.direction),
301
+ scrollLeftNormalized: getNormalizedScrollLeft(tabsNode, isRtl ? 'rtl' : 'ltr'),
301
302
  scrollWidth: tabsNode.scrollWidth,
302
303
  top: rect.top,
303
304
  bottom: rect.bottom,