@mui/material 6.0.0-alpha.6 → 6.0.0-alpha.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.
@@ -3,8 +3,9 @@
3
3
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
4
4
  import _extends from "@babel/runtime/helpers/esm/extends";
5
5
  var _ClearIcon, _ArrowDropDownIcon;
6
- const _excluded = ["autoComplete", "autoHighlight", "autoSelect", "blurOnSelect", "ChipProps", "className", "clearIcon", "clearOnBlur", "clearOnEscape", "clearText", "closeText", "componentsProps", "defaultValue", "disableClearable", "disableCloseOnSelect", "disabled", "disabledItemsFocusable", "disableListWrap", "disablePortal", "filterOptions", "filterSelectedOptions", "forcePopupIcon", "freeSolo", "fullWidth", "getLimitTagsText", "getOptionDisabled", "getOptionKey", "getOptionLabel", "isOptionEqualToValue", "groupBy", "handleHomeEndKeys", "id", "includeInputInList", "inputValue", "limitTags", "ListboxComponent", "ListboxProps", "loading", "loadingText", "multiple", "noOptionsText", "onChange", "onClose", "onHighlightChange", "onInputChange", "onOpen", "open", "openOnFocus", "openText", "options", "PaperComponent", "PopperComponent", "popupIcon", "readOnly", "renderGroup", "renderInput", "renderOption", "renderTags", "selectOnFocus", "size", "slotProps", "value"],
7
- _excluded2 = ["ref"];
6
+ const _excluded = ["autoComplete", "autoHighlight", "autoSelect", "blurOnSelect", "ChipProps", "className", "clearIcon", "clearOnBlur", "clearOnEscape", "clearText", "closeText", "componentsProps", "defaultValue", "disableClearable", "disableCloseOnSelect", "disabled", "disabledItemsFocusable", "disableListWrap", "disablePortal", "filterOptions", "filterSelectedOptions", "forcePopupIcon", "freeSolo", "fullWidth", "getLimitTagsText", "getOptionDisabled", "getOptionKey", "getOptionLabel", "isOptionEqualToValue", "groupBy", "handleHomeEndKeys", "id", "includeInputInList", "inputValue", "limitTags", "ListboxComponent", "ListboxProps", "loading", "loadingText", "multiple", "noOptionsText", "onChange", "onClose", "onHighlightChange", "onInputChange", "onOpen", "open", "openOnFocus", "openText", "options", "PaperComponent", "PopperComponent", "popupIcon", "readOnly", "renderGroup", "renderInput", "renderOption", "renderTags", "selectOnFocus", "size", "slots", "slotProps", "value"],
7
+ _excluded2 = ["ref"],
8
+ _excluded3 = ["key"];
8
9
  import * as React from 'react';
9
10
  import PropTypes from 'prop-types';
10
11
  import clsx from 'clsx';
@@ -27,7 +28,7 @@ import ArrowDropDownIcon from '../internal/svg-icons/ArrowDropDown';
27
28
  import { styled, createUseThemeProps } from '../zero-styled';
28
29
  import autocompleteClasses, { getAutocompleteUtilityClass } from './autocompleteClasses';
29
30
  import capitalize from '../utils/capitalize';
30
- import useForkRef from '../utils/useForkRef';
31
+ import useSlot from '../utils/useSlot';
31
32
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
32
33
  import { createElement as _createElement } from "react";
33
34
  const useThemeProps = createUseThemeProps('MuiAutocomplete');
@@ -90,21 +91,11 @@ const AutocompleteRoot = styled('div', {
90
91
  }, styles.root, fullWidth && styles.fullWidth, hasPopupIcon && styles.hasPopupIcon, hasClearIcon && styles.hasClearIcon];
91
92
  }
92
93
  })({
93
- [`&.${autocompleteClasses.focused} .${autocompleteClasses.clearIndicator}`]: {
94
- visibility: 'visible'
95
- },
96
- /* Avoid double tap issue on iOS */
97
- '@media (pointer: fine)': {
98
- [`&:hover .${autocompleteClasses.clearIndicator}`]: {
99
- visibility: 'visible'
100
- }
101
- },
102
94
  [`& .${autocompleteClasses.tag}`]: {
103
95
  margin: 3,
104
96
  maxWidth: 'calc(100% - 6px)'
105
97
  },
106
98
  [`& .${autocompleteClasses.inputRoot}`]: {
107
- flexWrap: 'wrap',
108
99
  [`.${autocompleteClasses.hasPopupIcon}&, .${autocompleteClasses.hasClearIcon}&`]: {
109
100
  paddingRight: 26 + 4
110
101
  },
@@ -116,6 +107,23 @@ const AutocompleteRoot = styled('div', {
116
107
  minWidth: 30
117
108
  }
118
109
  },
110
+ [`&.${autocompleteClasses.focused}`]: {
111
+ [`& .${autocompleteClasses.clearIndicator}`]: {
112
+ visibility: 'visible'
113
+ },
114
+ [`& .${autocompleteClasses.input}`]: {
115
+ minWidth: 0
116
+ }
117
+ },
118
+ /* Avoid double tap issue on iOS */
119
+ '@media (pointer: fine)': {
120
+ [`&:hover .${autocompleteClasses.clearIndicator}`]: {
121
+ visibility: 'visible'
122
+ },
123
+ [`&:hover .${autocompleteClasses.input}`]: {
124
+ minWidth: 0
125
+ }
126
+ },
119
127
  [`& .${inputClasses.root}`]: {
120
128
  paddingBottom: 1,
121
129
  '& .MuiInput-input': {
@@ -222,6 +230,15 @@ const AutocompleteRoot = styled('div', {
222
230
  opacity: 1
223
231
  }
224
232
  }
233
+ }, {
234
+ props: {
235
+ multiple: true
236
+ },
237
+ style: {
238
+ [`& .${autocompleteClasses.inputRoot}`]: {
239
+ flexWrap: 'wrap'
240
+ }
241
+ }
225
242
  }]
226
243
  });
227
244
  const AutocompleteEndAdornment = styled('div', {
@@ -407,7 +424,7 @@ const Autocomplete = /*#__PURE__*/React.forwardRef(function Autocomplete(inProps
407
424
  autoHighlight = false,
408
425
  autoSelect = false,
409
426
  blurOnSelect = false,
410
- ChipProps,
427
+ ChipProps: ChipPropsProp,
411
428
  className,
412
429
  clearIcon = _ClearIcon || (_ClearIcon = /*#__PURE__*/_jsx(ClearIcon, {
413
430
  fontSize: "small"
@@ -416,7 +433,7 @@ const Autocomplete = /*#__PURE__*/React.forwardRef(function Autocomplete(inProps
416
433
  clearOnEscape = false,
417
434
  clearText = 'Clear',
418
435
  closeText = 'Close',
419
- componentsProps = {},
436
+ componentsProps,
420
437
  defaultValue = props.multiple ? [] : null,
421
438
  disableClearable = false,
422
439
  disableCloseOnSelect = false,
@@ -434,16 +451,16 @@ const Autocomplete = /*#__PURE__*/React.forwardRef(function Autocomplete(inProps
434
451
  handleHomeEndKeys = !props.freeSolo,
435
452
  includeInputInList = false,
436
453
  limitTags = -1,
437
- ListboxComponent = 'ul',
438
- ListboxProps,
454
+ ListboxComponent: ListboxComponentProp,
455
+ ListboxProps: ListboxPropsProp,
439
456
  loading = false,
440
457
  loadingText = 'Loading…',
441
458
  multiple = false,
442
459
  noOptionsText = 'No options',
443
460
  openOnFocus = false,
444
461
  openText = 'Open',
445
- PaperComponent = Paper,
446
- PopperComponent = Popper,
462
+ PaperComponent: PaperComponentProp,
463
+ PopperComponent: PopperComponentProp,
447
464
  popupIcon = _ArrowDropDownIcon || (_ArrowDropDownIcon = /*#__PURE__*/_jsx(ArrowDropDownIcon, {})),
448
465
  readOnly = false,
449
466
  renderGroup: renderGroupProp,
@@ -452,6 +469,7 @@ const Autocomplete = /*#__PURE__*/React.forwardRef(function Autocomplete(inProps
452
469
  renderTags,
453
470
  selectOnFocus = !props.freeSolo,
454
471
  size = 'medium',
472
+ slots = {},
455
473
  slotProps = {}
456
474
  } = props,
457
475
  other = _objectWithoutPropertiesLoose(props, _excluded);
@@ -485,15 +503,11 @@ const Autocomplete = /*#__PURE__*/React.forwardRef(function Autocomplete(inProps
485
503
  const {
486
504
  onMouseDown: handleInputMouseDown
487
505
  } = getInputProps();
488
- const {
489
- ref: externalListboxRef
490
- } = ListboxProps ?? {};
491
506
  const _getListboxProps = getListboxProps(),
492
507
  {
493
508
  ref: listboxRef
494
509
  } = _getListboxProps,
495
510
  otherListboxProps = _objectWithoutPropertiesLoose(_getListboxProps, _excluded2);
496
- const combinedListboxRef = useForkRef(listboxRef, externalListboxRef);
497
511
  const defaultGetOptionLabel = option => option.label ?? option;
498
512
  const getOptionLabel = getOptionLabelProp || defaultGetOptionLabel;
499
513
 
@@ -511,6 +525,46 @@ const Autocomplete = /*#__PURE__*/React.forwardRef(function Autocomplete(inProps
511
525
  size
512
526
  });
513
527
  const classes = useUtilityClasses(ownerState);
528
+ const externalForwardedProps = {
529
+ slots: _extends({
530
+ listbox: ListboxComponentProp,
531
+ paper: PaperComponentProp,
532
+ popper: PopperComponentProp
533
+ }, slots),
534
+ slotProps: _extends({
535
+ chip: ChipPropsProp,
536
+ listbox: ListboxPropsProp
537
+ }, componentsProps, slotProps)
538
+ };
539
+ const [ListboxSlot, listboxProps] = useSlot('listbox', {
540
+ elementType: 'ul',
541
+ externalForwardedProps,
542
+ ownerState,
543
+ className: classes.listbox,
544
+ additionalProps: otherListboxProps,
545
+ ref: listboxRef
546
+ });
547
+ const [PaperSlot, paperProps] = useSlot('paper', {
548
+ elementType: Paper,
549
+ externalForwardedProps,
550
+ ownerState,
551
+ className: classes.paper
552
+ });
553
+ const [PopperSlot, popperProps] = useSlot('popper', {
554
+ elementType: Popper,
555
+ externalForwardedProps,
556
+ ownerState,
557
+ className: classes.popper,
558
+ additionalProps: {
559
+ disablePortal,
560
+ style: {
561
+ width: anchorEl ? anchorEl.clientWidth : null
562
+ },
563
+ role: 'presentation',
564
+ anchorEl,
565
+ open: popupOpen
566
+ }
567
+ });
514
568
  let startAdornment;
515
569
  if (multiple && value.length > 0) {
516
570
  const getCustomizedTagProps = params => _extends({
@@ -520,12 +574,19 @@ const Autocomplete = /*#__PURE__*/React.forwardRef(function Autocomplete(inProps
520
574
  if (renderTags) {
521
575
  startAdornment = renderTags(value, getCustomizedTagProps, ownerState);
522
576
  } else {
523
- startAdornment = value.map((option, index) => /*#__PURE__*/_jsx(Chip, _extends({
524
- label: getOptionLabel(option),
525
- size: size
526
- }, getCustomizedTagProps({
527
- index
528
- }), ChipProps)));
577
+ startAdornment = value.map((option, index) => {
578
+ const _getCustomizedTagProp = getCustomizedTagProps({
579
+ index
580
+ }),
581
+ {
582
+ key
583
+ } = _getCustomizedTagProp,
584
+ customTagProps = _objectWithoutPropertiesLoose(_getCustomizedTagProp, _excluded3);
585
+ return /*#__PURE__*/_jsx(Chip, _extends({
586
+ label: getOptionLabel(option),
587
+ size: size
588
+ }, customTagProps, externalForwardedProps.slotProps.chip), key);
589
+ });
529
590
  }
530
591
  }
531
592
  if (limitTags > -1 && Array.isArray(startAdornment)) {
@@ -571,38 +632,22 @@ const Autocomplete = /*#__PURE__*/React.forwardRef(function Autocomplete(inProps
571
632
  inputValue
572
633
  }, ownerState);
573
634
  };
574
- const clearIndicatorSlotProps = slotProps.clearIndicator ?? componentsProps.clearIndicator;
575
- const paperSlotProps = slotProps.paper ?? componentsProps.paper;
576
- const popperSlotProps = slotProps.popper ?? componentsProps.popper;
577
- const popupIndicatorSlotProps = slotProps.popupIndicator ?? componentsProps.popupIndicator;
635
+ const clearIndicatorSlotProps = externalForwardedProps.slotProps.clearIndicator;
636
+ const popupIndicatorSlotProps = externalForwardedProps.slotProps.popupIndicator;
578
637
  const renderAutocompletePopperChildren = children => /*#__PURE__*/_jsx(AutocompletePopper, _extends({
579
- as: PopperComponent,
580
- disablePortal: disablePortal,
581
- style: {
582
- width: anchorEl ? anchorEl.clientWidth : null
583
- },
584
- ownerState: ownerState,
585
- role: "presentation",
586
- anchorEl: anchorEl,
587
- open: popupOpen
588
- }, popperSlotProps, {
589
- className: clsx(classes.popper, popperSlotProps?.className),
638
+ as: PopperSlot
639
+ }, popperProps, {
590
640
  children: /*#__PURE__*/_jsx(AutocompletePaper, _extends({
591
- ownerState: ownerState,
592
- as: PaperComponent
593
- }, paperSlotProps, {
594
- className: clsx(classes.paper, paperSlotProps?.className),
641
+ as: PaperSlot
642
+ }, paperProps, {
595
643
  children: children
596
644
  }))
597
645
  }));
598
646
  let autocompletePopper = null;
599
647
  if (groupedOptions.length > 0) {
600
648
  autocompletePopper = renderAutocompletePopperChildren( /*#__PURE__*/_jsx(AutocompleteListbox, _extends({
601
- as: ListboxComponent,
602
- className: classes.listbox,
603
- ownerState: ownerState
604
- }, otherListboxProps, ListboxProps, {
605
- ref: combinedListboxRef,
649
+ as: ListboxSlot
650
+ }, listboxProps, {
606
651
  children: groupedOptions.map((option, index) => {
607
652
  if (groupBy) {
608
653
  return renderGroup({
@@ -723,6 +768,7 @@ process.env.NODE_ENV !== "production" ? Autocomplete.propTypes /* remove-proptyp
723
768
  blurOnSelect: PropTypes.oneOfType([PropTypes.oneOf(['mouse', 'touch']), PropTypes.bool]),
724
769
  /**
725
770
  * Props applied to the [`Chip`](/material-ui/api/chip/) element.
771
+ * @deprecated Use `slotProps.chip` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
726
772
  */
727
773
  ChipProps: PropTypes.object,
728
774
  /**
@@ -767,7 +813,7 @@ process.env.NODE_ENV !== "production" ? Autocomplete.propTypes /* remove-proptyp
767
813
  closeText: PropTypes.string,
768
814
  /**
769
815
  * The props used for each slot inside.
770
- * @default {}
816
+ * @deprecated Use the `slotProps` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
771
817
  */
772
818
  componentsProps: PropTypes.shape({
773
819
  clearIndicator: PropTypes.object,
@@ -925,10 +971,12 @@ process.env.NODE_ENV !== "production" ? Autocomplete.propTypes /* remove-proptyp
925
971
  /**
926
972
  * The component used to render the listbox.
927
973
  * @default 'ul'
974
+ * @deprecated Use `slots.listbox` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
928
975
  */
929
976
  ListboxComponent: PropTypes.elementType,
930
977
  /**
931
978
  * Props applied to the Listbox element.
979
+ * @deprecated Use `slotProps.listbox` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
932
980
  */
933
981
  ListboxProps: PropTypes.object,
934
982
  /**
@@ -1023,11 +1071,13 @@ process.env.NODE_ENV !== "production" ? Autocomplete.propTypes /* remove-proptyp
1023
1071
  /**
1024
1072
  * The component used to render the body of the popup.
1025
1073
  * @default Paper
1074
+ * @deprecated Use `slots.paper` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
1026
1075
  */
1027
1076
  PaperComponent: PropTypes.elementType,
1028
1077
  /**
1029
1078
  * The component used to position the popup.
1030
1079
  * @default Popper
1080
+ * @deprecated Use `slots.popper` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
1031
1081
  */
1032
1082
  PopperComponent: PropTypes.elementType,
1033
1083
  /**
@@ -1088,11 +1138,22 @@ process.env.NODE_ENV !== "production" ? Autocomplete.propTypes /* remove-proptyp
1088
1138
  * The props used for each slot inside.
1089
1139
  * @default {}
1090
1140
  */
1091
- slotProps: PropTypes.shape({
1092
- clearIndicator: PropTypes.object,
1093
- paper: PropTypes.object,
1094
- popper: PropTypes.object,
1095
- popupIndicator: PropTypes.object
1141
+ slotProps: PropTypes /* @typescript-to-proptypes-ignore */.shape({
1142
+ chip: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
1143
+ clearIndicator: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
1144
+ listbox: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
1145
+ paper: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
1146
+ popper: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
1147
+ popupIndicator: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
1148
+ }),
1149
+ /**
1150
+ * The components used for each slot inside.
1151
+ * @default {}
1152
+ */
1153
+ slots: PropTypes.shape({
1154
+ listbox: PropTypes.elementType,
1155
+ paper: PropTypes.elementType,
1156
+ popper: PropTypes.elementType
1096
1157
  }),
1097
1158
  /**
1098
1159
  * The system prop that allows defining system overrides as well as additional CSS styles.
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/material v6.0.0-alpha.6
2
+ * @mui/material v6.0.0-alpha.7
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the