@mui/material 9.0.0 → 9.0.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.
Files changed (130) hide show
  1. package/Autocomplete/Autocomplete.js +65 -11
  2. package/Autocomplete/Autocomplete.mjs +65 -11
  3. package/Avatar/Avatar.js +4 -0
  4. package/Avatar/Avatar.mjs +4 -0
  5. package/Badge/Badge.js +3 -0
  6. package/Badge/Badge.mjs +3 -0
  7. package/Button/Button.js +19 -2
  8. package/Button/Button.mjs +19 -2
  9. package/ButtonBase/ButtonBase.d.mts +7 -0
  10. package/ButtonBase/ButtonBase.d.ts +7 -0
  11. package/ButtonBase/ButtonBase.js +5 -2
  12. package/ButtonBase/ButtonBase.mjs +5 -2
  13. package/CHANGELOG.md +132 -1245
  14. package/Checkbox/Checkbox.js +2 -1
  15. package/Checkbox/Checkbox.mjs +2 -1
  16. package/CircularProgress/CircularProgress.d.mts +12 -2
  17. package/CircularProgress/CircularProgress.d.ts +12 -2
  18. package/CircularProgress/CircularProgress.js +33 -6
  19. package/CircularProgress/CircularProgress.mjs +33 -6
  20. package/ClickAwayListener/ClickAwayListener.js +3 -6
  21. package/ClickAwayListener/ClickAwayListener.mjs +3 -6
  22. package/Dialog/Dialog.js +11 -6
  23. package/Dialog/Dialog.mjs +11 -6
  24. package/Drawer/Drawer.js +18 -4
  25. package/Drawer/Drawer.mjs +18 -4
  26. package/Fab/Fab.js +7 -1
  27. package/Fab/Fab.mjs +7 -1
  28. package/FilledInput/FilledInput.d.mts +4 -0
  29. package/FilledInput/FilledInput.d.ts +4 -0
  30. package/FilledInput/FilledInput.js +18 -20
  31. package/FilledInput/FilledInput.mjs +18 -20
  32. package/FormControl/useFormControl.d.mts +12 -2
  33. package/FormControl/useFormControl.d.ts +12 -2
  34. package/FormControl/useFormControl.js +13 -0
  35. package/FormControl/useFormControl.mjs +12 -0
  36. package/FormControlLabel/FormControlLabel.js +5 -8
  37. package/FormControlLabel/FormControlLabel.mjs +5 -8
  38. package/FormGroup/FormGroup.js +2 -5
  39. package/FormGroup/FormGroup.mjs +2 -5
  40. package/FormHelperText/FormHelperText.js +2 -5
  41. package/FormHelperText/FormHelperText.mjs +2 -5
  42. package/FormLabel/FormLabel.js +2 -5
  43. package/FormLabel/FormLabel.mjs +2 -5
  44. package/IconButton/IconButton.js +1 -8
  45. package/IconButton/IconButton.mjs +1 -8
  46. package/Input/Input.d.mts +4 -0
  47. package/Input/Input.d.ts +4 -0
  48. package/Input/Input.js +6 -0
  49. package/Input/Input.mjs +6 -0
  50. package/InputBase/InputBase.d.mts +2 -1
  51. package/InputBase/InputBase.d.ts +2 -1
  52. package/InputBase/InputBase.js +50 -15
  53. package/InputBase/InputBase.mjs +50 -15
  54. package/InputLabel/InputLabel.js +5 -8
  55. package/InputLabel/InputLabel.mjs +5 -8
  56. package/LinearProgress/LinearProgress.d.mts +12 -2
  57. package/LinearProgress/LinearProgress.d.ts +12 -2
  58. package/LinearProgress/LinearProgress.js +42 -10
  59. package/LinearProgress/LinearProgress.mjs +42 -10
  60. package/List/List.js +2 -1
  61. package/List/List.mjs +2 -1
  62. package/ListItemButton/ListItemButton.js +7 -1
  63. package/ListItemButton/ListItemButton.mjs +7 -1
  64. package/MenuItem/MenuItem.js +7 -1
  65. package/MenuItem/MenuItem.mjs +7 -1
  66. package/MenuList/MenuList.js +2 -1
  67. package/MenuList/MenuList.mjs +2 -1
  68. package/NativeSelect/NativeSelect.js +2 -5
  69. package/NativeSelect/NativeSelect.mjs +2 -5
  70. package/OutlinedInput/OutlinedInput.js +13 -23
  71. package/OutlinedInput/OutlinedInput.mjs +13 -23
  72. package/PigmentContainer/PigmentContainer.js +0 -1
  73. package/PigmentContainer/PigmentContainer.mjs +0 -1
  74. package/Popper/BasePopper.js +23 -1
  75. package/Popper/BasePopper.mjs +23 -1
  76. package/Select/Select.js +2 -5
  77. package/Select/Select.mjs +2 -5
  78. package/Select/SelectInput.js +164 -2
  79. package/Select/SelectInput.mjs +164 -2
  80. package/Slide/Slide.js +48 -26
  81. package/Slide/Slide.mjs +49 -27
  82. package/Slider/Slider.js +10 -1
  83. package/Slider/Slider.mjs +10 -1
  84. package/Slider/useSlider.js +3 -2
  85. package/Slider/useSlider.mjs +3 -2
  86. package/SwipeableDrawer/SwipeableDrawer.js +7 -3
  87. package/SwipeableDrawer/SwipeableDrawer.mjs +7 -3
  88. package/Switch/Switch.js +7 -6
  89. package/Switch/Switch.mjs +7 -6
  90. package/Tabs/ScrollbarSize.js +2 -1
  91. package/Tabs/ScrollbarSize.mjs +2 -1
  92. package/Tabs/Tabs.js +2 -1
  93. package/Tabs/Tabs.mjs +2 -1
  94. package/Tooltip/Tooltip.js +26 -108
  95. package/Tooltip/Tooltip.mjs +26 -108
  96. package/Unstable_TrapFocus/FocusTrap.js +18 -14
  97. package/Unstable_TrapFocus/FocusTrap.mjs +18 -14
  98. package/index.js +1 -1
  99. package/index.mjs +1 -1
  100. package/package.json +49 -49
  101. package/styles/responsiveFontSizes.js +19 -8
  102. package/styles/responsiveFontSizes.mjs +19 -8
  103. package/styles/useThemeProps.d.mts +3 -3
  104. package/styles/useThemeProps.d.ts +3 -3
  105. package/transitions/utils.d.mts +17 -0
  106. package/transitions/utils.d.ts +17 -0
  107. package/transitions/utils.js +64 -0
  108. package/transitions/utils.mjs +63 -0
  109. package/useAutocomplete/useAutocomplete.d.mts +4 -5
  110. package/useAutocomplete/useAutocomplete.d.ts +4 -5
  111. package/useAutocomplete/useAutocomplete.js +166 -53
  112. package/useAutocomplete/useAutocomplete.mjs +166 -53
  113. package/utils/contains.d.mts +2 -0
  114. package/utils/contains.d.ts +2 -0
  115. package/utils/contains.js +9 -0
  116. package/utils/contains.mjs +2 -0
  117. package/utils/focusable.d.mts +7 -0
  118. package/utils/focusable.d.ts +7 -0
  119. package/utils/focusable.js +20 -0
  120. package/utils/focusable.mjs +13 -0
  121. package/utils/getEventTarget.d.mts +2 -0
  122. package/utils/getEventTarget.d.ts +2 -0
  123. package/utils/getEventTarget.js +9 -0
  124. package/utils/getEventTarget.mjs +2 -0
  125. package/utils/mergeSlotProps.js +2 -8
  126. package/utils/mergeSlotProps.mjs +1 -8
  127. package/version/index.js +2 -2
  128. package/version/index.mjs +2 -2
  129. package/FormControl/formControlState.js +0 -21
  130. package/FormControl/formControlState.mjs +0 -15
@@ -18,6 +18,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
18
18
  var _integerPropType = _interopRequireDefault(require("@mui/utils/integerPropType"));
19
19
  var _chainPropTypes = _interopRequireDefault(require("@mui/utils/chainPropTypes"));
20
20
  var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
21
+ var _useForcedRerendering = _interopRequireDefault(require("@mui/utils/useForcedRerendering"));
22
+ var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
21
23
  var _useAutocomplete = _interopRequireWildcard(require("../useAutocomplete"));
22
24
  var _Popper = _interopRequireDefault(require("../Popper"));
23
25
  var _ListSubheader = _interopRequireDefault(require("../ListSubheader"));
@@ -340,6 +342,8 @@ const AutocompleteListbox = (0, _zeroStyled.styled)('ul', {
340
342
  padding: '8px 0',
341
343
  maxHeight: '40vh',
342
344
  overflow: 'auto',
345
+ isolation: 'isolate',
346
+ // Prevent overlap with iOS overlay scrollbars.
343
347
  position: 'relative',
344
348
  [`& .${_autocompleteClasses.default.option}`]: {
345
349
  minHeight: 48,
@@ -500,6 +504,46 @@ const Autocomplete = /*#__PURE__*/React.forwardRef(function Autocomplete(inProps
500
504
  ...props,
501
505
  componentName: 'Autocomplete'
502
506
  });
507
+
508
+ // Re-render when anchorEl resizes so the Popper width stays in sync.
509
+ // Width is always read synchronously from anchorEl.clientWidth during render
510
+ // (no stale cached value). The hook just triggers a re-render on resize.
511
+ const forceRenderOnResize = (0, _useForcedRerendering.default)();
512
+ React.useEffect(() => {
513
+ if (!popupOpen || !anchorEl || typeof ResizeObserver === 'undefined') {
514
+ return undefined;
515
+ }
516
+ let lastWidth = anchorEl.clientWidth;
517
+ const observer = new ResizeObserver(() => {
518
+ const newWidth = anchorEl.clientWidth;
519
+ if (lastWidth !== newWidth) {
520
+ lastWidth = newWidth;
521
+ forceRenderOnResize();
522
+ }
523
+ });
524
+ observer.observe(anchorEl);
525
+ return () => {
526
+ observer.disconnect();
527
+ };
528
+ }, [popupOpen, anchorEl, forceRenderOnResize]);
529
+
530
+ // When popupOpen becomes false, useAutocomplete returns [] for groupedOptions.
531
+ // Transitioned Poppers can remain mounted for their exit animation, so keep rendering
532
+ // the last open-state options instead of flashing "No options" or an empty Paper.
533
+ // These options are stale because they no longer reflect the hook's current
534
+ // groupedOptions, but they are non-interactive while closing and reset on next open.
535
+ const previousGroupedOptionsRef = React.useRef([]);
536
+ const prevPopupOpenRef = React.useRef(false);
537
+ const renderedOptions = popupOpen ? groupedOptions : previousGroupedOptionsRef.current;
538
+ (0, _useEnhancedEffect.default)(() => {
539
+ if (popupOpen && !prevPopupOpenRef.current) {
540
+ previousGroupedOptionsRef.current = [];
541
+ }
542
+ prevPopupOpenRef.current = popupOpen;
543
+ if (popupOpen && groupedOptions.length > 0) {
544
+ previousGroupedOptionsRef.current = groupedOptions;
545
+ }
546
+ }, [popupOpen, groupedOptions]);
503
547
  const hasClearIcon = !disableClearable && !disabled && dirty && !readOnly;
504
548
  const hasPopupIcon = (!freeSolo || forcePopupIcon === true) && forcePopupIcon !== false;
505
549
  const {
@@ -564,13 +608,24 @@ const Autocomplete = /*#__PURE__*/React.forwardRef(function Autocomplete(inProps
564
608
  additionalProps: {
565
609
  disablePortal,
566
610
  style: {
567
- width: anchorEl ? anchorEl.clientWidth : null
611
+ width: anchorEl ? anchorEl.clientWidth : null,
612
+ // Prevent interaction with stale cached options during exit transitions.
613
+ // The hook's filteredOptions is [] when popupOpen=false, so clicks on stale
614
+ // rendered options would pass undefined to selectNewValue.
615
+ pointerEvents: popupOpen ? undefined : 'none'
568
616
  },
569
617
  role: 'presentation',
570
618
  anchorEl,
571
619
  open: popupOpen
572
620
  }
573
621
  });
622
+
623
+ // Don't render the Popper when there's no content to show.
624
+ // In freeSolo mode, "No options" text is suppressed, so if there are also no
625
+ // matching options and loading is false, the Paper would be empty.
626
+ // Uses renderedOptions (not groupedOptions) so Popper stays during exit transitions.
627
+ // Respect keepMounted from resolved popperProps (handles both object and callback slotProps forms).
628
+ const hasPopupContent = renderedOptions.length > 0 || loading || !freeSolo || popperProps.keepMounted === true;
574
629
  const [ClearIndicatorSlot, clearIndicatorProps] = (0, _useSlot.default)('clearIndicator', {
575
630
  elementType: AutocompleteClearIndicator,
576
631
  externalForwardedProps,
@@ -716,17 +771,17 @@ const Autocomplete = /*#__PURE__*/React.forwardRef(function Autocomplete(inProps
716
771
  }
717
772
  }
718
773
  })
719
- }), anchorEl ? /*#__PURE__*/(0, _jsxRuntime.jsx)(AutocompletePopper, {
774
+ }), anchorEl && hasPopupContent ? /*#__PURE__*/(0, _jsxRuntime.jsx)(AutocompletePopper, {
720
775
  as: PopperSlot,
721
776
  ...popperProps,
722
777
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(AutocompletePaper, {
723
778
  as: PaperSlot,
724
779
  ...paperProps,
725
- children: [loading && groupedOptions.length === 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(AutocompleteLoading, {
780
+ children: [loading && renderedOptions.length === 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(AutocompleteLoading, {
726
781
  className: classes.loading,
727
782
  ownerState: ownerState,
728
783
  children: loadingText
729
- }) : null, groupedOptions.length === 0 && !freeSolo && !loading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(AutocompleteNoOptions, {
784
+ }) : null, renderedOptions.length === 0 && !freeSolo && !loading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(AutocompleteNoOptions, {
730
785
  className: classes.noOptions,
731
786
  ownerState: ownerState,
732
787
  role: "presentation",
@@ -735,9 +790,9 @@ const Autocomplete = /*#__PURE__*/React.forwardRef(function Autocomplete(inProps
735
790
  event.preventDefault();
736
791
  },
737
792
  children: noOptionsText
738
- }) : null, groupedOptions.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(ListboxSlot, {
793
+ }) : null, renderedOptions.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(ListboxSlot, {
739
794
  ...listboxProps,
740
- children: groupedOptions.map((option, index) => {
795
+ children: renderedOptions.map((option, index) => {
741
796
  if (groupBy) {
742
797
  return renderGroup({
743
798
  key: option.key,
@@ -770,12 +825,11 @@ process.env.NODE_ENV !== "production" ? Autocomplete.propTypes /* remove-proptyp
770
825
  */
771
826
  autoHighlight: _propTypes.default.bool,
772
827
  /**
773
- * If `true`, the selected option becomes the value of the input
774
- * when the Autocomplete loses focus unless the user chooses
775
- * a different option or changes the character string in the input.
828
+ * If `true`, the value is updated when the input loses focus under one of these conditions:
776
829
  *
777
- * When using the `freeSolo` mode, the typed value will be the input value
778
- * if the Autocomplete loses focus without highlighting an option.
830
+ * - An option highlighted via keyboard navigation or `autoHighlight` is selected.
831
+ * Hover and touch highlights are ignored.
832
+ * - Otherwise, in `freeSolo` mode, the typed text becomes the value.
779
833
  * @default false
780
834
  */
781
835
  autoSelect: _propTypes.default.bool,
@@ -6,6 +6,8 @@ import PropTypes from 'prop-types';
6
6
  import integerPropType from '@mui/utils/integerPropType';
7
7
  import chainPropTypes from '@mui/utils/chainPropTypes';
8
8
  import composeClasses from '@mui/utils/composeClasses';
9
+ import useForcedRerendering from '@mui/utils/useForcedRerendering';
10
+ import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
9
11
  import useAutocomplete, { createFilterOptions } from "../useAutocomplete/index.mjs";
10
12
  import Popper from "../Popper/index.mjs";
11
13
  import ListSubheader from "../ListSubheader/index.mjs";
@@ -327,6 +329,8 @@ const AutocompleteListbox = styled('ul', {
327
329
  padding: '8px 0',
328
330
  maxHeight: '40vh',
329
331
  overflow: 'auto',
332
+ isolation: 'isolate',
333
+ // Prevent overlap with iOS overlay scrollbars.
330
334
  position: 'relative',
331
335
  [`& .${autocompleteClasses.option}`]: {
332
336
  minHeight: 48,
@@ -488,6 +492,46 @@ const Autocomplete = /*#__PURE__*/React.forwardRef(function Autocomplete(inProps
488
492
  ...props,
489
493
  componentName: 'Autocomplete'
490
494
  });
495
+
496
+ // Re-render when anchorEl resizes so the Popper width stays in sync.
497
+ // Width is always read synchronously from anchorEl.clientWidth during render
498
+ // (no stale cached value). The hook just triggers a re-render on resize.
499
+ const forceRenderOnResize = useForcedRerendering();
500
+ React.useEffect(() => {
501
+ if (!popupOpen || !anchorEl || typeof ResizeObserver === 'undefined') {
502
+ return undefined;
503
+ }
504
+ let lastWidth = anchorEl.clientWidth;
505
+ const observer = new ResizeObserver(() => {
506
+ const newWidth = anchorEl.clientWidth;
507
+ if (lastWidth !== newWidth) {
508
+ lastWidth = newWidth;
509
+ forceRenderOnResize();
510
+ }
511
+ });
512
+ observer.observe(anchorEl);
513
+ return () => {
514
+ observer.disconnect();
515
+ };
516
+ }, [popupOpen, anchorEl, forceRenderOnResize]);
517
+
518
+ // When popupOpen becomes false, useAutocomplete returns [] for groupedOptions.
519
+ // Transitioned Poppers can remain mounted for their exit animation, so keep rendering
520
+ // the last open-state options instead of flashing "No options" or an empty Paper.
521
+ // These options are stale because they no longer reflect the hook's current
522
+ // groupedOptions, but they are non-interactive while closing and reset on next open.
523
+ const previousGroupedOptionsRef = React.useRef([]);
524
+ const prevPopupOpenRef = React.useRef(false);
525
+ const renderedOptions = popupOpen ? groupedOptions : previousGroupedOptionsRef.current;
526
+ useEnhancedEffect(() => {
527
+ if (popupOpen && !prevPopupOpenRef.current) {
528
+ previousGroupedOptionsRef.current = [];
529
+ }
530
+ prevPopupOpenRef.current = popupOpen;
531
+ if (popupOpen && groupedOptions.length > 0) {
532
+ previousGroupedOptionsRef.current = groupedOptions;
533
+ }
534
+ }, [popupOpen, groupedOptions]);
491
535
  const hasClearIcon = !disableClearable && !disabled && dirty && !readOnly;
492
536
  const hasPopupIcon = (!freeSolo || forcePopupIcon === true) && forcePopupIcon !== false;
493
537
  const {
@@ -552,13 +596,24 @@ const Autocomplete = /*#__PURE__*/React.forwardRef(function Autocomplete(inProps
552
596
  additionalProps: {
553
597
  disablePortal,
554
598
  style: {
555
- width: anchorEl ? anchorEl.clientWidth : null
599
+ width: anchorEl ? anchorEl.clientWidth : null,
600
+ // Prevent interaction with stale cached options during exit transitions.
601
+ // The hook's filteredOptions is [] when popupOpen=false, so clicks on stale
602
+ // rendered options would pass undefined to selectNewValue.
603
+ pointerEvents: popupOpen ? undefined : 'none'
556
604
  },
557
605
  role: 'presentation',
558
606
  anchorEl,
559
607
  open: popupOpen
560
608
  }
561
609
  });
610
+
611
+ // Don't render the Popper when there's no content to show.
612
+ // In freeSolo mode, "No options" text is suppressed, so if there are also no
613
+ // matching options and loading is false, the Paper would be empty.
614
+ // Uses renderedOptions (not groupedOptions) so Popper stays during exit transitions.
615
+ // Respect keepMounted from resolved popperProps (handles both object and callback slotProps forms).
616
+ const hasPopupContent = renderedOptions.length > 0 || loading || !freeSolo || popperProps.keepMounted === true;
562
617
  const [ClearIndicatorSlot, clearIndicatorProps] = useSlot('clearIndicator', {
563
618
  elementType: AutocompleteClearIndicator,
564
619
  externalForwardedProps,
@@ -704,17 +759,17 @@ const Autocomplete = /*#__PURE__*/React.forwardRef(function Autocomplete(inProps
704
759
  }
705
760
  }
706
761
  })
707
- }), anchorEl ? /*#__PURE__*/_jsx(AutocompletePopper, {
762
+ }), anchorEl && hasPopupContent ? /*#__PURE__*/_jsx(AutocompletePopper, {
708
763
  as: PopperSlot,
709
764
  ...popperProps,
710
765
  children: /*#__PURE__*/_jsxs(AutocompletePaper, {
711
766
  as: PaperSlot,
712
767
  ...paperProps,
713
- children: [loading && groupedOptions.length === 0 ? /*#__PURE__*/_jsx(AutocompleteLoading, {
768
+ children: [loading && renderedOptions.length === 0 ? /*#__PURE__*/_jsx(AutocompleteLoading, {
714
769
  className: classes.loading,
715
770
  ownerState: ownerState,
716
771
  children: loadingText
717
- }) : null, groupedOptions.length === 0 && !freeSolo && !loading ? /*#__PURE__*/_jsx(AutocompleteNoOptions, {
772
+ }) : null, renderedOptions.length === 0 && !freeSolo && !loading ? /*#__PURE__*/_jsx(AutocompleteNoOptions, {
718
773
  className: classes.noOptions,
719
774
  ownerState: ownerState,
720
775
  role: "presentation",
@@ -723,9 +778,9 @@ const Autocomplete = /*#__PURE__*/React.forwardRef(function Autocomplete(inProps
723
778
  event.preventDefault();
724
779
  },
725
780
  children: noOptionsText
726
- }) : null, groupedOptions.length > 0 ? /*#__PURE__*/_jsx(ListboxSlot, {
781
+ }) : null, renderedOptions.length > 0 ? /*#__PURE__*/_jsx(ListboxSlot, {
727
782
  ...listboxProps,
728
- children: groupedOptions.map((option, index) => {
783
+ children: renderedOptions.map((option, index) => {
729
784
  if (groupBy) {
730
785
  return renderGroup({
731
786
  key: option.key,
@@ -758,12 +813,11 @@ process.env.NODE_ENV !== "production" ? Autocomplete.propTypes /* remove-proptyp
758
813
  */
759
814
  autoHighlight: PropTypes.bool,
760
815
  /**
761
- * If `true`, the selected option becomes the value of the input
762
- * when the Autocomplete loses focus unless the user chooses
763
- * a different option or changes the character string in the input.
816
+ * If `true`, the value is updated when the input loses focus under one of these conditions:
764
817
  *
765
- * When using the `freeSolo` mode, the typed value will be the input value
766
- * if the Autocomplete loses focus without highlighting an option.
818
+ * - An option highlighted via keyboard navigation or `autoHighlight` is selected.
819
+ * Hover and touch highlights are ignored.
820
+ * - Otherwise, in `freeSolo` mode, the typed text becomes the value.
767
821
  * @default false
768
822
  */
769
823
  autoSelect: PropTypes.bool,
package/Avatar/Avatar.js CHANGED
@@ -76,6 +76,10 @@ const AvatarRoot = (0, _zeroStyled.styled)('div', {
76
76
  },
77
77
  style: {
78
78
  color: (theme.vars || theme).palette.background.default,
79
+ '@media (forced-colors: active)': {
80
+ boxSizing: 'border-box',
81
+ border: '1px solid ButtonBorder'
82
+ },
79
83
  ...(theme.vars ? {
80
84
  backgroundColor: theme.vars.palette.Avatar.defaultBg
81
85
  } : {
package/Avatar/Avatar.mjs CHANGED
@@ -69,6 +69,10 @@ const AvatarRoot = styled('div', {
69
69
  },
70
70
  style: {
71
71
  color: (theme.vars || theme).palette.background.default,
72
+ '@media (forced-colors: active)': {
73
+ boxSizing: 'border-box',
74
+ border: '1px solid ButtonBorder'
75
+ },
72
76
  ...(theme.vars ? {
73
77
  backgroundColor: theme.vars.palette.Avatar.defaultBg
74
78
  } : {
package/Badge/Badge.js CHANGED
@@ -78,6 +78,9 @@ const BadgeBadge = (0, _zeroStyled.styled)('span', {
78
78
  borderRadius: RADIUS_STANDARD,
79
79
  zIndex: 1,
80
80
  // Render the badge on top of potential ripples.
81
+ '@media (forced-colors: active)': {
82
+ border: '1px solid ButtonBorder'
83
+ },
81
84
  transition: theme.transitions.create('transform', {
82
85
  easing: theme.transitions.easing.easeInOut,
83
86
  duration: theme.transitions.duration.enteringScreen
package/Badge/Badge.mjs CHANGED
@@ -71,6 +71,9 @@ const BadgeBadge = styled('span', {
71
71
  borderRadius: RADIUS_STANDARD,
72
72
  zIndex: 1,
73
73
  // Render the badge on top of potential ripples.
74
+ '@media (forced-colors: active)': {
75
+ border: '1px solid ButtonBorder'
76
+ },
74
77
  transition: theme.transitions.create('transform', {
75
78
  easing: theme.transitions.easing.easeInOut,
76
79
  duration: theme.transitions.duration.enteringScreen
package/Button/Button.js CHANGED
@@ -109,6 +109,17 @@ const ButtonRoot = (0, _zeroStyled.styled)(_ButtonBase.default, {
109
109
  color: (theme.vars || theme).palette.action.disabled
110
110
  },
111
111
  variants: [{
112
+ props: ({
113
+ ownerState
114
+ }) => ownerState.startIcon || ownerState.loading && ownerState.loadingPosition === 'start',
115
+ style: {
116
+ '&::before': {
117
+ content: '"\\200b"',
118
+ width: 0,
119
+ overflow: 'hidden'
120
+ }
121
+ }
122
+ }, {
112
123
  props: {
113
124
  variant: 'contained'
114
125
  },
@@ -558,6 +569,12 @@ const Button = /*#__PURE__*/React.forwardRef(function Button(inProps, ref) {
558
569
  children: loadingIndicator
559
570
  })
560
571
  }) : null;
572
+
573
+ // Don't forward the 'root' classes to the ButtonBase, as they will get duplicated with the one passed to the className prop.
574
+ const {
575
+ root,
576
+ ...forwardedClasses
577
+ } = classes;
561
578
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(ButtonRoot, {
562
579
  ownerState: ownerState,
563
580
  className: (0, _clsx.default)(contextProps.className, classes.root, className, positionClassName),
@@ -570,7 +587,7 @@ const Button = /*#__PURE__*/React.forwardRef(function Button(inProps, ref) {
570
587
  type: type,
571
588
  id: loading ? loadingId : idProp,
572
589
  ...other,
573
- classes: classes,
590
+ classes: forwardedClasses,
574
591
  children: [startIcon, loadingPosition !== 'end' && loader, children, loadingPosition === 'end' && loader, endIcon]
575
592
  });
576
593
  });
@@ -683,7 +700,7 @@ process.env.NODE_ENV !== "production" ? Button.propTypes /* remove-proptypes */
683
700
  /**
684
701
  * @ignore
685
702
  */
686
- type: _propTypes.default.oneOfType([_propTypes.default.oneOf(['button', 'reset', 'submit']), _propTypes.default.string]),
703
+ type: _propTypes.default.string,
687
704
  /**
688
705
  * The variant to use.
689
706
  * @default 'text'
package/Button/Button.mjs CHANGED
@@ -102,6 +102,17 @@ const ButtonRoot = styled(ButtonBase, {
102
102
  color: (theme.vars || theme).palette.action.disabled
103
103
  },
104
104
  variants: [{
105
+ props: ({
106
+ ownerState
107
+ }) => ownerState.startIcon || ownerState.loading && ownerState.loadingPosition === 'start',
108
+ style: {
109
+ '&::before': {
110
+ content: '"\\200b"',
111
+ width: 0,
112
+ overflow: 'hidden'
113
+ }
114
+ }
115
+ }, {
105
116
  props: {
106
117
  variant: 'contained'
107
118
  },
@@ -551,6 +562,12 @@ const Button = /*#__PURE__*/React.forwardRef(function Button(inProps, ref) {
551
562
  children: loadingIndicator
552
563
  })
553
564
  }) : null;
565
+
566
+ // Don't forward the 'root' classes to the ButtonBase, as they will get duplicated with the one passed to the className prop.
567
+ const {
568
+ root,
569
+ ...forwardedClasses
570
+ } = classes;
554
571
  return /*#__PURE__*/_jsxs(ButtonRoot, {
555
572
  ownerState: ownerState,
556
573
  className: clsx(contextProps.className, classes.root, className, positionClassName),
@@ -563,7 +580,7 @@ const Button = /*#__PURE__*/React.forwardRef(function Button(inProps, ref) {
563
580
  type: type,
564
581
  id: loading ? loadingId : idProp,
565
582
  ...other,
566
- classes: classes,
583
+ classes: forwardedClasses,
567
584
  children: [startIcon, loadingPosition !== 'end' && loader, children, loadingPosition === 'end' && loader, endIcon]
568
585
  });
569
586
  });
@@ -676,7 +693,7 @@ process.env.NODE_ENV !== "production" ? Button.propTypes /* remove-proptypes */
676
693
  /**
677
694
  * @ignore
678
695
  */
679
- type: PropTypes.oneOfType([PropTypes.oneOf(['button', 'reset', 'submit']), PropTypes.string]),
696
+ type: PropTypes.string,
680
697
  /**
681
698
  * The variant to use.
682
699
  * @default 'text'
@@ -88,6 +88,13 @@ export interface ButtonBaseOwnProps {
88
88
  * A ref that points to the `TouchRipple` element.
89
89
  */
90
90
  touchRippleRef?: React.Ref<TouchRippleActions> | undefined;
91
+ /**
92
+ * The HTML [`type`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#type)
93
+ * attribute applied to `button` and `a` elements.
94
+ * Ignored when rendering non-native buttons.
95
+ * @default 'button'
96
+ */
97
+ type?: string | undefined;
91
98
  }
92
99
  export interface ButtonBaseTypeMap<AdditionalProps = {}, RootComponent extends React.ElementType = 'button'> {
93
100
  props: AdditionalProps & ButtonBaseOwnProps;
@@ -88,6 +88,13 @@ export interface ButtonBaseOwnProps {
88
88
  * A ref that points to the `TouchRipple` element.
89
89
  */
90
90
  touchRippleRef?: React.Ref<TouchRippleActions> | undefined;
91
+ /**
92
+ * The HTML [`type`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#type)
93
+ * attribute applied to `button` and `a` elements.
94
+ * Ignored when rendering non-native buttons.
95
+ * @default 'button'
96
+ */
97
+ type?: string | undefined;
91
98
  }
92
99
  export interface ButtonBaseTypeMap<AdditionalProps = {}, RootComponent extends React.ElementType = 'button'> {
93
100
  props: AdditionalProps & ButtonBaseOwnProps;
@@ -464,8 +464,11 @@ process.env.NODE_ENV !== "production" ? ButtonBase.propTypes /* remove-proptypes
464
464
  })
465
465
  })]),
466
466
  /**
467
- * @ignore
467
+ * The HTML [`type`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#type)
468
+ * attribute applied to `button` and `a` elements.
469
+ * Ignored when rendering non-native buttons.
470
+ * @default 'button'
468
471
  */
469
- type: _propTypes.default.oneOfType([_propTypes.default.oneOf(['button', 'reset', 'submit']), _propTypes.default.string])
472
+ type: _propTypes.default.string
470
473
  } : void 0;
471
474
  var _default = exports.default = ButtonBase;
@@ -457,8 +457,11 @@ process.env.NODE_ENV !== "production" ? ButtonBase.propTypes /* remove-proptypes
457
457
  })
458
458
  })]),
459
459
  /**
460
- * @ignore
460
+ * The HTML [`type`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#type)
461
+ * attribute applied to `button` and `a` elements.
462
+ * Ignored when rendering non-native buttons.
463
+ * @default 'button'
461
464
  */
462
- type: PropTypes.oneOfType([PropTypes.oneOf(['button', 'reset', 'submit']), PropTypes.string])
465
+ type: PropTypes.string
463
466
  } : void 0;
464
467
  export default ButtonBase;