@mui/material 5.15.12 → 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 (66) hide show
  1. package/Alert/Alert.d.ts +2 -2
  2. package/Autocomplete/Autocomplete.js +58 -49
  3. package/CHANGELOG.md +96 -0
  4. package/Drawer/Drawer.js +9 -3
  5. package/LinearProgress/LinearProgress.js +4 -4
  6. package/Menu/Menu.js +5 -4
  7. package/MenuList/MenuList.js +4 -2
  8. package/PaginationItem/PaginationItem.js +3 -3
  9. package/Rating/Rating.js +3 -3
  10. package/Slider/Slider.js +2 -3
  11. package/Switch/Switch.js +61 -41
  12. package/TabScrollButton/TabScrollButton.js +2 -3
  13. package/TablePagination/TablePaginationActions.js +14 -14
  14. package/Tabs/Tabs.js +3 -2
  15. package/Tooltip/Tooltip.js +5 -4
  16. package/index.js +1 -1
  17. package/legacy/Autocomplete/Autocomplete.js +62 -51
  18. package/legacy/Drawer/Drawer.js +8 -3
  19. package/legacy/LinearProgress/LinearProgress.js +4 -4
  20. package/legacy/Menu/Menu.js +5 -4
  21. package/legacy/MenuList/MenuList.js +3 -2
  22. package/legacy/PaginationItem/PaginationItem.js +3 -3
  23. package/legacy/Rating/Rating.js +3 -3
  24. package/legacy/Slider/Slider.js +2 -3
  25. package/legacy/Switch/Switch.js +88 -59
  26. package/legacy/TabScrollButton/TabScrollButton.js +2 -3
  27. package/legacy/TablePagination/TablePaginationActions.js +14 -14
  28. package/legacy/Tabs/Tabs.js +3 -2
  29. package/legacy/Tooltip/Tooltip.js +7 -3
  30. package/legacy/index.js +1 -1
  31. package/legacy/styles/experimental_extendTheme.js +3 -0
  32. package/modern/Autocomplete/Autocomplete.js +58 -49
  33. package/modern/Drawer/Drawer.js +9 -3
  34. package/modern/LinearProgress/LinearProgress.js +4 -4
  35. package/modern/Menu/Menu.js +5 -4
  36. package/modern/MenuList/MenuList.js +4 -2
  37. package/modern/PaginationItem/PaginationItem.js +3 -3
  38. package/modern/Rating/Rating.js +3 -3
  39. package/modern/Slider/Slider.js +2 -3
  40. package/modern/Switch/Switch.js +61 -41
  41. package/modern/TabScrollButton/TabScrollButton.js +2 -3
  42. package/modern/TablePagination/TablePaginationActions.js +14 -14
  43. package/modern/Tabs/Tabs.js +3 -2
  44. package/modern/Tooltip/Tooltip.js +5 -4
  45. package/modern/index.js +1 -1
  46. package/modern/styles/experimental_extendTheme.js +3 -0
  47. package/node/Autocomplete/Autocomplete.js +58 -49
  48. package/node/Drawer/Drawer.js +9 -3
  49. package/node/LinearProgress/LinearProgress.js +4 -4
  50. package/node/Menu/Menu.js +5 -4
  51. package/node/MenuList/MenuList.js +4 -2
  52. package/node/PaginationItem/PaginationItem.js +3 -3
  53. package/node/Rating/Rating.js +3 -3
  54. package/node/Slider/Slider.js +2 -3
  55. package/node/Switch/Switch.js +66 -46
  56. package/node/TabScrollButton/TabScrollButton.js +2 -3
  57. package/node/TablePagination/TablePaginationActions.js +14 -14
  58. package/node/Tabs/Tabs.js +3 -2
  59. package/node/Tooltip/Tooltip.js +5 -4
  60. package/node/index.js +1 -1
  61. package/node/styles/experimental_extendTheme.js +3 -0
  62. package/package.json +5 -5
  63. package/styles/experimental_extendTheme.d.ts +1 -0
  64. package/styles/experimental_extendTheme.js +3 -0
  65. package/umd/material-ui.development.js +356 -286
  66. package/umd/material-ui.production.min.js +2 -2
package/Alert/Alert.d.ts CHANGED
@@ -33,7 +33,7 @@ export type AlertSlotsAndSlotProps = CreateSlotsAndSlotProps<
33
33
  }
34
34
  >;
35
35
 
36
- export interface AlertProps extends StandardProps<PaperProps, 'variant'> {
36
+ export interface AlertProps extends StandardProps<PaperProps, 'variant'>, AlertSlotsAndSlotProps {
37
37
  /**
38
38
  * The action to display. It renders after the message, at the end of the alert.
39
39
  */
@@ -133,4 +133,4 @@ export interface AlertOwnerState extends AlertProps {}
133
133
  * - [Alert API](https://mui.com/material-ui/api/alert/)
134
134
  * - inherits [Paper API](https://mui.com/material-ui/api/paper/)
135
135
  */
136
- export default function Alert(props: AlertProps & AlertSlotsAndSlotProps): JSX.Element;
136
+ export default function Alert(props: AlertProps): JSX.Element;
@@ -554,6 +554,63 @@ const Autocomplete = /*#__PURE__*/React.forwardRef(function Autocomplete(inProps
554
554
  const paperSlotProps = (_slotProps$paper = slotProps.paper) != null ? _slotProps$paper : componentsProps.paper;
555
555
  const popperSlotProps = (_slotProps$popper = slotProps.popper) != null ? _slotProps$popper : componentsProps.popper;
556
556
  const popupIndicatorSlotProps = (_slotProps$popupIndic = slotProps.popupIndicator) != null ? _slotProps$popupIndic : componentsProps.popupIndicator;
557
+ const renderAutocompletePopperChildren = children => /*#__PURE__*/_jsx(AutocompletePopper, _extends({
558
+ as: PopperComponent,
559
+ disablePortal: disablePortal,
560
+ style: {
561
+ width: anchorEl ? anchorEl.clientWidth : null
562
+ },
563
+ ownerState: ownerState,
564
+ role: "presentation",
565
+ anchorEl: anchorEl,
566
+ open: popupOpen
567
+ }, popperSlotProps, {
568
+ className: clsx(classes.popper, popperSlotProps == null ? void 0 : popperSlotProps.className),
569
+ children: /*#__PURE__*/_jsx(AutocompletePaper, _extends({
570
+ ownerState: ownerState,
571
+ as: PaperComponent
572
+ }, paperSlotProps, {
573
+ className: clsx(classes.paper, paperSlotProps == null ? void 0 : paperSlotProps.className),
574
+ children: children
575
+ }))
576
+ }));
577
+ let autocompletePopper = null;
578
+ if (!loading && groupedOptions.length > 0) {
579
+ autocompletePopper = renderAutocompletePopperChildren( /*#__PURE__*/_jsx(AutocompleteListbox, _extends({
580
+ as: ListboxComponent,
581
+ className: classes.listbox,
582
+ ownerState: ownerState
583
+ }, otherListboxProps, ListboxProps, {
584
+ ref: combinedListboxRef,
585
+ children: groupedOptions.map((option, index) => {
586
+ if (groupBy) {
587
+ return renderGroup({
588
+ key: option.key,
589
+ group: option.group,
590
+ children: option.options.map((option2, index2) => renderListOption(option2, option.index + index2))
591
+ });
592
+ }
593
+ return renderListOption(option, index);
594
+ })
595
+ })));
596
+ } else if (loading && groupedOptions.length === 0) {
597
+ autocompletePopper = renderAutocompletePopperChildren( /*#__PURE__*/_jsx(AutocompleteLoading, {
598
+ className: classes.loading,
599
+ ownerState: ownerState,
600
+ children: loadingText
601
+ }));
602
+ } else if (groupedOptions.length === 0 && !freeSolo && !loading) {
603
+ autocompletePopper = renderAutocompletePopperChildren( /*#__PURE__*/_jsx(AutocompleteNoOptions, {
604
+ className: classes.noOptions,
605
+ ownerState: ownerState,
606
+ role: "presentation",
607
+ onMouseDown: event => {
608
+ // Prevent input blur when interacting with the "no options" content
609
+ event.preventDefault();
610
+ },
611
+ children: noOptionsText
612
+ }));
613
+ }
557
614
  return /*#__PURE__*/_jsxs(React.Fragment, {
558
615
  children: [/*#__PURE__*/_jsx(AutocompleteRoot, _extends({
559
616
  ref: ref,
@@ -603,55 +660,7 @@ const Autocomplete = /*#__PURE__*/React.forwardRef(function Autocomplete(inProps
603
660
  readOnly
604
661
  }, getInputProps())
605
662
  })
606
- })), anchorEl ? /*#__PURE__*/_jsx(AutocompletePopper, _extends({
607
- as: PopperComponent,
608
- disablePortal: disablePortal,
609
- style: {
610
- width: anchorEl ? anchorEl.clientWidth : null
611
- },
612
- ownerState: ownerState,
613
- role: "presentation",
614
- anchorEl: anchorEl,
615
- open: popupOpen
616
- }, popperSlotProps, {
617
- className: clsx(classes.popper, popperSlotProps == null ? void 0 : popperSlotProps.className),
618
- children: /*#__PURE__*/_jsxs(AutocompletePaper, _extends({
619
- ownerState: ownerState,
620
- as: PaperComponent
621
- }, paperSlotProps, {
622
- className: clsx(classes.paper, paperSlotProps == null ? void 0 : paperSlotProps.className),
623
- children: [loading && groupedOptions.length === 0 ? /*#__PURE__*/_jsx(AutocompleteLoading, {
624
- className: classes.loading,
625
- ownerState: ownerState,
626
- children: loadingText
627
- }) : null, groupedOptions.length === 0 && !freeSolo && !loading ? /*#__PURE__*/_jsx(AutocompleteNoOptions, {
628
- className: classes.noOptions,
629
- ownerState: ownerState,
630
- role: "presentation",
631
- onMouseDown: event => {
632
- // Prevent input blur when interacting with the "no options" content
633
- event.preventDefault();
634
- },
635
- children: noOptionsText
636
- }) : null, groupedOptions.length > 0 ? /*#__PURE__*/_jsx(AutocompleteListbox, _extends({
637
- as: ListboxComponent,
638
- className: classes.listbox,
639
- ownerState: ownerState
640
- }, otherListboxProps, ListboxProps, {
641
- ref: combinedListboxRef,
642
- children: groupedOptions.map((option, index) => {
643
- if (groupBy) {
644
- return renderGroup({
645
- key: option.key,
646
- group: option.group,
647
- children: option.options.map((option2, index2) => renderListOption(option2, option.index + index2))
648
- });
649
- }
650
- return renderListOption(option, index);
651
- })
652
- })) : null]
653
- }))
654
- })) : null]
663
+ })), anchorEl ? autocompletePopper : null]
655
664
  });
656
665
  });
657
666
  process.env.NODE_ENV !== "production" ? Autocomplete.propTypes /* remove-proptypes */ = {
package/CHANGELOG.md CHANGED
@@ -1,5 +1,97 @@
1
1
  # [Versions](https://mui.com/versions/)
2
2
 
3
+ ## v5.15.13
4
+
5
+ <!-- generated comparing v5.15.12..master -->
6
+
7
+ _Mar 12, 2024_
8
+
9
+ A big thanks to the 15 contributors who made this release possible. Here are some highights ✨
10
+
11
+ - The Material UI free Checkout template got a design uplift (#41447) @zanivan
12
+
13
+ ### `@mui/material@5.15.13`
14
+
15
+ - [Alert] Add `slots` and `slotProps` type to theme (#41324) @sai6855
16
+ - [Autocomplete] Fix the options list being added to the DOM in `freeSolo` mode even when there are no options, causing style problems (#41300) @rakeshmusturi
17
+ - Add `paperChannel` token (#41447) @siriwatknp
18
+ - [Switch] Convert to support CSS extraction (#41367) @alexfauquette
19
+ - [Tooltip] Support event handlers with extra parameters (#41320) @LukasTy
20
+
21
+ ### `@mui/system@5.15.13`
22
+
23
+ - [RtlProvider] Add component & hook (#41241) @mnajdova
24
+
25
+ ### `@mui/utils@5.15.13`
26
+
27
+ - [utils] Fix visually hidden styles' margin unit (#41477) @michaldudak
28
+
29
+ ### `@mui/codemod@5.15.13`
30
+
31
+ - Fix merging of slotProps and componentProps (#41323) @sai6855
32
+
33
+ ### `@mui/base@5.0.0-beta.39`
34
+
35
+ - [material-ui][joy-ui][Autocomplete] Keep in sync highlighted index when the option still exists (#41306) @CGNonofr
36
+ - [FormControl] Export `FormControlOwnerState` type from index (#41287) @michaeldfoley
37
+ - [material-ui][TextareaAutosize] Fix inline style not getting applied (#41369) @ZeeshanTamboli
38
+
39
+ ### `@pigment-css/react@0.0.2`
40
+
41
+ - Handle more scenarios while transforming sx prop (#41372) @brijeshb42
42
+ - Improve testing of fixtures (#41389) @brijeshb42
43
+ - Fix `keyframes` serialize styles error (#41395) @siriwatknp
44
+ - Use class selector instead of class value (#41442) @brijeshb42
45
+ - [next] Warn about unsupported turbo mode in Next.js (#41445) @brijeshb42
46
+
47
+ ### Docs
48
+
49
+ - [material-ui] Refine checkout template (#40967) @zanivan
50
+ - [material-ui] Add docs for complementary List components (#41329) @anle9650
51
+ - [material-ui] Add docs for complementary Dialog components (#41313) @jwithington
52
+ - [material-ui] Fix Templates live preview link (#41467) @danilo-leal
53
+ - [material-ui] Polish out the templates page (#41468) @zanivan
54
+ - [material-ui] Adjust the Templates card design (#41450) @danilo-leal
55
+ - [joy-ui] Remove unnecessary styles in color inversion footer demo (#41419) @cipherlogs
56
+ - [joy-ui] Update case studies chip background color (#41413) @cipherlogs
57
+ - [joy-ui] Remove wrong CSS prop from the Sign-in-side template (#41383) @cipherlogs
58
+ - [joy-ui] Fix broken link on the Color Inversion page (#41407) @cipherlogs
59
+ - [pigment] Add example and guide section (#41249) @siriwatknp
60
+ - [pigment-css] Brand name nonbreaking space (#41438) @oliviertassinari
61
+ - [pigment-css] Fix import on the README (#41411) @danilo-leal
62
+ - [pigment-css] Edit starter template links on README (#41409) @danilo-leal
63
+ - [pigment-css] Tweak the examples and edit READMEs (#41408) @danilo-leal
64
+ - [pigment-css] Adjust the bit about CSS vars on the README (#41463) @danilo-leal
65
+ - Finish brand name fixes #41438 @oliviertassinari
66
+ - Remove noreferrer @oliviertassinari
67
+ - Fix v4 docs <b> appearing in notifications (#41390) @peterwangsc
68
+ - Update GitHub project links (#41370) @danilo-leal
69
+
70
+ ### Core
71
+
72
+ - [pigment] Make all Pigment CSS packages public (#41404) @brijeshb42
73
+ - [pigment] Rename directories to match package names (#41453) @brijeshb42
74
+ - [pigment-css] Example fix leading spaces (#41439) @oliviertassinari
75
+ - [code-infra] Add short note about e2e-website workflow schedule (#41355) @Janpot
76
+ - [code-infra] Add alias for icon types (#41248) @Janpot
77
+ - [code-infra] Reduce concurrency of typescript:ci further (#41392) @Janpot
78
+ - [code-infra] Reduce concurrency for test_types ci job (#41385) @Janpot
79
+ - [code-infra] Adapt API code generator to Base UI repo needs (#41475) @michaldudak
80
+ - [docs-infra] Don't generate preview files for the templates (#41379) @mnajdova
81
+ - [docs-infra] Fix pigment css apps path in the render mui demos script (#41476) @mnajdova
82
+ - [docs-infra] move feedback to ESM (#41381) @alexfauquette
83
+ - [docs-infra] Improve color contrast throughout (#41387) @danilo-leal
84
+ - [docs-infra] Simplify Algolia crawler config (#41312) @oliviertassinari
85
+ - [docs-infra] Adjust the tabs and layout selection design (#41084) @danilo-leal
86
+ - [blog] Update the Base UI post with links to dedicated repo (#41358) @danilo-leal
87
+ - [website] Update the Careers page role (#41384) @danilo-leal
88
+ - [website] Compress about images @oliviertassinari
89
+ - [website] Improve color contrast on the homepage (#41465) @danilo-leal
90
+ - [examples] Add pigment-css-vite-ts starter example (#41196) @siriwatknp
91
+ - [examples] Add pigment-css-nextjs-ts starter project (#41105) @siriwatknp
92
+
93
+ All contributors of this release in alphabetical order: @alexfauquette, @brijeshb42, @CGNonofr, @cipherlogs, @danilo-leal, @Janpot, @michaeldfoley, @mnajdova, @oliviertassinari, @peterwangsc, @rakeshmusturi, @sai6855, @siriwatknp, @zanivan, @ZeeshanTamboli
94
+
3
95
  ## v5.15.12
4
96
 
5
97
  <!-- generated comparing v5.15.11..master -->
@@ -9,6 +101,10 @@ _Mar 5, 2024_
9
101
  A big thanks to the 21 contributors who made this release possible.
10
102
  This release was mostly about 🐛 bug fixes and 📚 documentation improvements.
11
103
 
104
+ ### `@pigment-css/react@0.0.1`, `@pigment-css/nextjs-plugin@0.0.1`, `@pigment-css/vite-plugin@0.0.1`, & `@pigment-css/unplugin@0.0.1`
105
+
106
+ - This is the first public release of our new zero-runtime CSS-in-JS library, Pigment CSS.
107
+
12
108
  ### `@mui/material@5.15.12`
13
109
 
14
110
  - &#8203;<!-- 52 -->Support props callback type in theme variants (#40946) @ZeeshanTamboli
package/Drawer/Drawer.js CHANGED
@@ -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,
@@ -16,8 +16,8 @@ import clsx from 'clsx';
16
16
  import composeClasses from '@mui/utils/composeClasses';
17
17
  import { keyframes, css } from '@mui/system';
18
18
  import { darken, lighten } from '@mui/system/colorManipulator';
19
+ import { useRtl } from '@mui/system/RtlProvider';
19
20
  import capitalize from '../utils/capitalize';
20
- import useTheme from '../styles/useTheme';
21
21
  import styled from '../styles/styled';
22
22
  import useThemeProps from '../styles/useThemeProps';
23
23
  import { getLinearProgressUtilityClass } from './linearProgressClasses';
@@ -255,7 +255,7 @@ const LinearProgress = /*#__PURE__*/React.forwardRef(function LinearProgress(inP
255
255
  variant
256
256
  });
257
257
  const classes = useUtilityClasses(ownerState);
258
- const theme = useTheme();
258
+ const isRtl = useRtl();
259
259
  const rootProps = {};
260
260
  const inlineStyles = {
261
261
  bar1: {},
@@ -267,7 +267,7 @@ const LinearProgress = /*#__PURE__*/React.forwardRef(function LinearProgress(inP
267
267
  rootProps['aria-valuemin'] = 0;
268
268
  rootProps['aria-valuemax'] = 100;
269
269
  let transform = value - 100;
270
- if (theme.direction === 'rtl') {
270
+ if (isRtl) {
271
271
  transform = -transform;
272
272
  }
273
273
  inlineStyles.bar1.transform = `translateX(${transform}%)`;
@@ -278,7 +278,7 @@ const LinearProgress = /*#__PURE__*/React.forwardRef(function LinearProgress(inP
278
278
  if (variant === 'buffer') {
279
279
  if (valueBuffer !== undefined) {
280
280
  let transform = (valueBuffer || 0) - 100;
281
- if (theme.direction === 'rtl') {
281
+ if (isRtl) {
282
282
  transform = -transform;
283
283
  }
284
284
  inlineStyles.bar2.transform = `translateX(${transform}%)`;
package/Menu/Menu.js CHANGED
@@ -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";
@@ -89,8 +89,7 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu(inProps, ref) {
89
89
  } = props,
90
90
  TransitionProps = _objectWithoutPropertiesLoose(props.TransitionProps, _excluded),
91
91
  other = _objectWithoutPropertiesLoose(props, _excluded2);
92
- const theme = useTheme();
93
- const isRtl = theme.direction === 'rtl';
92
+ const isRtl = useRtl();
94
93
  const ownerState = _extends({}, props, {
95
94
  autoFocus,
96
95
  disableAutoFocusItem,
@@ -106,7 +105,9 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu(inProps, ref) {
106
105
  const menuListActionsRef = React.useRef(null);
107
106
  const handleEntering = (element, isAppearing) => {
108
107
  if (menuListActionsRef.current) {
109
- menuListActionsRef.current.adjustStyleForScrollbar(element, theme);
108
+ menuListActionsRef.current.adjustStyleForScrollbar(element, {
109
+ direction: isRtl ? 'rtl' : 'ltr'
110
+ });
110
111
  }
111
112
  if (onEntering) {
112
113
  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,
package/Rating/Rating.js CHANGED
@@ -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;
package/Slider/Slider.js CHANGED
@@ -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';
@@ -371,8 +371,7 @@ const Slider = /*#__PURE__*/React.forwardRef(function Slider(inputProps, ref) {
371
371
  props: inputProps,
372
372
  name: 'MuiSlider'
373
373
  });
374
- const theme = useTheme();
375
- const isRtl = theme.direction === 'rtl';
374
+ const isRtl = useRtl();
376
375
  const {
377
376
  'aria-label': ariaLabel,
378
377
  'aria-valuetext': ariaValuetext,
package/Switch/Switch.js CHANGED
@@ -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';
@@ -66,8 +66,7 @@ const TabScrollButton = /*#__PURE__*/React.forwardRef(function TabScrollButton(i
66
66
  direction
67
67
  } = props,
68
68
  other = _objectWithoutPropertiesLoose(props, _excluded);
69
- const theme = useTheme();
70
- const isRtl = theme.direction === 'rtl';
69
+ const isRtl = useRtl();
71
70
  const ownerState = _extends({
72
71
  isRtl
73
72
  }, props);