@mui/material 7.3.5 → 7.3.7

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 (105) hide show
  1. package/Accordion/Accordion.d.ts +56 -55
  2. package/Accordion/Accordion.js +3 -13
  3. package/Alert/Alert.js +1 -1
  4. package/AppBar/AppBar.d.ts +13 -2
  5. package/AppBar/AppBar.js +14 -2
  6. package/Backdrop/Backdrop.js +0 -1
  7. package/Button/Button.d.ts +1 -0
  8. package/ButtonBase/ButtonBase.js +8 -1
  9. package/ButtonBase/TouchRipple.js +1 -1
  10. package/ButtonGroup/ButtonGroup.js +8 -11
  11. package/CHANGELOG.md +144 -1
  12. package/CardActionArea/CardActionArea.js +0 -1
  13. package/Chip/Chip.js +1 -1
  14. package/CssBaseline/CssBaseline.d.ts +1 -1
  15. package/CssBaseline/CssBaseline.js +1 -1
  16. package/Dialog/Dialog.js +4 -3
  17. package/Dialog/dialogClasses.d.ts +2 -0
  18. package/Dialog/dialogClasses.js +1 -1
  19. package/FormControl/FormControl.d.ts +1 -0
  20. package/FormHelperText/FormHelperText.d.ts +1 -0
  21. package/FormLabel/FormLabel.d.ts +1 -0
  22. package/IconButton/IconButton.d.ts +1 -0
  23. package/InputLabel/InputLabel.d.ts +1 -0
  24. package/ListItem/ListItem.d.ts +5 -0
  25. package/ListItem/ListItem.js +19 -4
  26. package/MenuList/MenuList.js +2 -1
  27. package/Modal/ModalManager.js +1 -1
  28. package/OutlinedInput/OutlinedInput.d.ts +1 -0
  29. package/README.md +2 -2
  30. package/ScopedCssBaseline/ScopedCssBaseline.d.ts +1 -1
  31. package/ScopedCssBaseline/ScopedCssBaseline.js +1 -1
  32. package/Select/SelectInput.d.ts +2 -0
  33. package/Select/SelectInput.js +25 -4
  34. package/Slider/Slider.d.ts +1 -1
  35. package/Slider/useSlider.types.d.ts +1 -1
  36. package/Snackbar/Snackbar.js +1 -3
  37. package/Tabs/Tabs.d.ts +1 -1
  38. package/Tabs/Tabs.js +4 -3
  39. package/TextField/TextField.d.ts +10 -5
  40. package/Unstable_TrapFocus/FocusTrap.js +13 -8
  41. package/esm/Accordion/Accordion.d.ts +56 -55
  42. package/esm/Accordion/Accordion.js +3 -13
  43. package/esm/Alert/Alert.js +1 -1
  44. package/esm/AppBar/AppBar.d.ts +13 -2
  45. package/esm/AppBar/AppBar.js +14 -2
  46. package/esm/Backdrop/Backdrop.js +0 -1
  47. package/esm/Button/Button.d.ts +1 -0
  48. package/esm/ButtonBase/ButtonBase.js +8 -1
  49. package/esm/ButtonBase/TouchRipple.js +1 -1
  50. package/esm/ButtonGroup/ButtonGroup.js +8 -11
  51. package/esm/CardActionArea/CardActionArea.js +0 -1
  52. package/esm/Chip/Chip.js +1 -1
  53. package/esm/CssBaseline/CssBaseline.d.ts +1 -1
  54. package/esm/CssBaseline/CssBaseline.js +1 -1
  55. package/esm/Dialog/Dialog.js +4 -3
  56. package/esm/Dialog/dialogClasses.d.ts +2 -0
  57. package/esm/Dialog/dialogClasses.js +1 -1
  58. package/esm/FormControl/FormControl.d.ts +1 -0
  59. package/esm/FormHelperText/FormHelperText.d.ts +1 -0
  60. package/esm/FormLabel/FormLabel.d.ts +1 -0
  61. package/esm/IconButton/IconButton.d.ts +1 -0
  62. package/esm/InputLabel/InputLabel.d.ts +1 -0
  63. package/esm/ListItem/ListItem.d.ts +5 -0
  64. package/esm/ListItem/ListItem.js +19 -4
  65. package/esm/MenuList/MenuList.js +2 -1
  66. package/esm/Modal/ModalManager.js +1 -1
  67. package/esm/OutlinedInput/OutlinedInput.d.ts +1 -0
  68. package/esm/ScopedCssBaseline/ScopedCssBaseline.d.ts +1 -1
  69. package/esm/ScopedCssBaseline/ScopedCssBaseline.js +1 -1
  70. package/esm/Select/SelectInput.d.ts +2 -0
  71. package/esm/Select/SelectInput.js +25 -4
  72. package/esm/Slider/Slider.d.ts +1 -1
  73. package/esm/Slider/useSlider.types.d.ts +1 -1
  74. package/esm/Snackbar/Snackbar.js +1 -3
  75. package/esm/Tabs/Tabs.d.ts +1 -1
  76. package/esm/Tabs/Tabs.js +4 -3
  77. package/esm/TextField/TextField.d.ts +10 -5
  78. package/esm/Unstable_TrapFocus/FocusTrap.js +13 -8
  79. package/esm/index.js +1 -1
  80. package/esm/internal/SwitchBase.js +1 -1
  81. package/esm/locale/arEG.js +1 -1
  82. package/esm/locale/arSA.js +1 -1
  83. package/esm/locale/arSD.js +1 -1
  84. package/esm/locale/kuCKB.js +1 -1
  85. package/esm/locale/neNP.js +1 -1
  86. package/esm/styles/createThemeNoVars.d.ts +4 -3
  87. package/esm/styles/createThemeWithVars.d.ts +2 -2
  88. package/esm/useAutocomplete/useAutocomplete.js +62 -16
  89. package/esm/utils/getActiveElement.d.ts +2 -0
  90. package/esm/utils/getActiveElement.js +2 -0
  91. package/esm/version/index.js +2 -2
  92. package/index.js +1 -1
  93. package/internal/SwitchBase.js +1 -1
  94. package/locale/arEG.js +1 -1
  95. package/locale/arSA.js +1 -1
  96. package/locale/arSD.js +1 -1
  97. package/locale/kuCKB.js +1 -1
  98. package/locale/neNP.js +1 -1
  99. package/package.json +8 -8
  100. package/styles/createThemeNoVars.d.ts +4 -3
  101. package/styles/createThemeWithVars.d.ts +2 -2
  102. package/useAutocomplete/useAutocomplete.js +62 -16
  103. package/utils/getActiveElement.d.ts +2 -0
  104. package/utils/getActiveElement.js +9 -0
  105. package/version/index.js +2 -2
@@ -473,7 +473,7 @@ function useAutocomplete(props) {
473
473
  filteredOptions.length,
474
474
  // Don't sync the highlighted index with the value when multiple
475
475
  // eslint-disable-next-line react-hooks/exhaustive-deps
476
- multiple ? false : value, filterSelectedOptions, changeHighlightedIndex, setHighlightedIndex, popupOpen, inputValue, multiple]);
476
+ multiple ? false : value, changeHighlightedIndex, setHighlightedIndex, popupOpen, inputValue, multiple]);
477
477
  const handleListboxRef = (0, _useEventCallback.default)(node => {
478
478
  (0, _setRef.default)(listboxRef, node);
479
479
  if (!node) {
@@ -592,9 +592,17 @@ function useAutocomplete(props) {
592
592
  handleClose(event, 'toggleInput');
593
593
  }
594
594
  let nextItem = focusedItem;
595
- if (focusedItem === -1) {
596
- if (inputValue === '' && direction === 'previous') {
597
- nextItem = value.length - 1;
595
+
596
+ // When moving focus from the input to tags with ArrowLeft,
597
+ // always jump to the last tag (if any) from the input.
598
+ if (focusedItem === -1 && direction === 'previous') {
599
+ nextItem = value.length - 1;
600
+ // In freeSolo, clear any draft text so it doesn't "come back" later.
601
+ if (freeSolo && inputValue !== '') {
602
+ setInputValueState('');
603
+ if (onInputChange) {
604
+ onInputChange(event, '', 'reset');
605
+ }
598
606
  }
599
607
  } else {
600
608
  nextItem += direction === 'next' ? 1 : -1;
@@ -701,14 +709,37 @@ function useAutocomplete(props) {
701
709
  handleOpen(event);
702
710
  break;
703
711
  case 'ArrowLeft':
704
- if (!multiple && renderValue) {
705
- focusItem(0);
706
- } else {
707
- handleFocusItem(event, 'previous');
712
+ {
713
+ const input = inputRef.current;
714
+ // Only handle ArrowLeft when the caret is at the start of the input.
715
+ // Otherwise let the browser move the caret normally.
716
+ const caretAtStart = input && input.selectionStart === 0 && input.selectionEnd === 0;
717
+ if (!caretAtStart) {
718
+ // Let the browser handle normal cursor movement
719
+ return;
720
+ }
721
+
722
+ // Single-value rendering: move focus from input to the single tag.
723
+ if (!multiple && renderValue && value != null) {
724
+ // Moving from input to single tag; clear freeSolo draft text,
725
+ // so it doesn't reappear when we move back.
726
+ if (freeSolo && inputValue !== '') {
727
+ setInputValueState('');
728
+ if (onInputChange) {
729
+ onInputChange(event, '', 'reset');
730
+ }
731
+ }
732
+ setFocusedItem(0);
733
+ focusItem(0);
734
+ } else {
735
+ // Multi-value: delegate to tag navigation helper.
736
+ handleFocusItem(event, 'previous');
737
+ }
738
+ break;
708
739
  }
709
- break;
710
740
  case 'ArrowRight':
711
741
  if (!multiple && renderValue) {
742
+ setFocusedItem(-1);
712
743
  focusItem(-1);
713
744
  } else {
714
745
  handleFocusItem(event, 'next');
@@ -763,9 +794,10 @@ function useAutocomplete(props) {
763
794
  option: value[index]
764
795
  });
765
796
  }
766
- if (!multiple && renderValue && !readOnly) {
767
- setValueState(null);
768
- focusItem(-1);
797
+ if (!multiple && renderValue && !readOnly && inputValue === '') {
798
+ handleValue(event, null, 'removeOption', {
799
+ option: value
800
+ });
769
801
  }
770
802
  break;
771
803
  case 'Delete':
@@ -778,9 +810,12 @@ function useAutocomplete(props) {
778
810
  option: value[index]
779
811
  });
780
812
  }
781
- if (!multiple && renderValue && !readOnly) {
782
- setValueState(null);
783
- focusItem(-1);
813
+ if (!multiple && renderValue && !readOnly && inputValue === '') {
814
+ // Single-value rendering: Delete on empty input removes
815
+ // the single rendered option, same "removeOption" reason as multiple.
816
+ handleValue(event, null, 'removeOption', {
817
+ option: value
818
+ });
784
819
  }
785
820
  break;
786
821
  default:
@@ -789,6 +824,15 @@ function useAutocomplete(props) {
789
824
  };
790
825
  const handleFocus = event => {
791
826
  setFocused(true);
827
+
828
+ // When focusing the input, ensure any previously focused item (chip)
829
+ // is cleared so the input receives the visible caret and the
830
+ // input-focused styling is applied.
831
+ if (focusedItem !== -1) {
832
+ setFocusedItem(-1);
833
+ // Ensure DOM focus lands on the input
834
+ focusItem(-1);
835
+ }
792
836
  if (openOnFocus && !ignoreFocus.current) {
793
837
  handleOpen(event);
794
838
  }
@@ -821,7 +865,9 @@ function useAutocomplete(props) {
821
865
  }
822
866
  }
823
867
  if (newValue === '') {
824
- if (!disableClearable && !multiple) {
868
+ // For normal single-select, clearing the input clears the value.
869
+ // For renderValue (chip-style single), only Backspace/Delete clear the value.
870
+ if (!disableClearable && !multiple && !renderValue) {
825
871
  handleValue(event, null, 'clear');
826
872
  }
827
873
  } else {
@@ -0,0 +1,2 @@
1
+ import getActiveElement from '@mui/utils/getActiveElement';
2
+ export default getActiveElement;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _getActiveElement = _interopRequireDefault(require("@mui/utils/getActiveElement"));
9
+ var _default = exports.default = _getActiveElement.default;
package/version/index.js CHANGED
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.version = exports.prerelease = exports.patch = exports.minor = exports.major = exports.default = void 0;
7
- const version = exports.version = "7.3.5";
7
+ const version = exports.version = "7.3.7";
8
8
  const major = exports.major = Number("7");
9
9
  const minor = exports.minor = Number("3");
10
- const patch = exports.patch = Number("5");
10
+ const patch = exports.patch = Number("7");
11
11
  const prerelease = exports.prerelease = undefined;
12
12
  var _default = exports.default = version;