@mui/material 6.0.0-beta.0 → 6.0.0-beta.2
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.
- package/Autocomplete/Autocomplete.d.ts +6 -7
- package/Autocomplete/Autocomplete.js +1 -1
- package/Badge/Badge.d.ts +1 -1
- package/Badge/Badge.js +2 -2
- package/Badge/useBadge.d.ts +13 -0
- package/Badge/useBadge.js +41 -0
- package/Badge/useBadge.types.d.ts +40 -0
- package/Badge/useBadge.types.js +1 -0
- package/Breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/Breadcrumbs/Breadcrumbs.js +1 -1
- package/CHANGELOG.md +48 -0
- package/ClickAwayListener/ClickAwayListener.d.ts +47 -0
- package/ClickAwayListener/ClickAwayListener.js +178 -0
- package/ClickAwayListener/index.d.ts +2 -2
- package/ClickAwayListener/index.js +1 -1
- package/InputBase/InputBase.js +2 -2
- package/ListItem/ListItem.js +1 -1
- package/Menu/Menu.js +1 -1
- package/Modal/Modal.d.ts +1 -1
- package/Modal/Modal.js +1 -1
- package/Modal/ModalManager.d.ts +25 -0
- package/Modal/ModalManager.js +211 -0
- package/Modal/index.d.ts +1 -1
- package/Modal/index.js +1 -1
- package/Modal/useModal.d.ts +13 -0
- package/Modal/useModal.js +195 -0
- package/Modal/useModal.types.d.ts +115 -0
- package/Modal/useModal.types.js +1 -0
- package/NoSsr/NoSsr.d.ts +25 -0
- package/NoSsr/NoSsr.js +73 -0
- package/NoSsr/NoSsr.types.d.ts +18 -0
- package/NoSsr/NoSsr.types.js +1 -0
- package/NoSsr/index.d.ts +3 -2
- package/NoSsr/index.js +1 -1
- package/Popover/Popover.js +1 -1
- package/Popper/BasePopper.d.ts +7 -0
- package/Popper/BasePopper.js +370 -0
- package/Popper/BasePopper.types.d.ts +130 -0
- package/Popper/BasePopper.types.js +1 -0
- package/Popper/Popper.d.ts +1 -1
- package/Popper/Popper.js +1 -1
- package/Popper/index.d.ts +2 -1
- package/Popper/index.js +2 -1
- package/Popper/popperClasses.d.ts +8 -0
- package/Popper/popperClasses.js +7 -0
- package/Portal/Portal.d.ts +16 -0
- package/Portal/Portal.js +92 -0
- package/Portal/Portal.types.d.ts +23 -0
- package/Portal/Portal.types.js +1 -0
- package/Portal/index.d.ts +3 -2
- package/Portal/index.js +1 -1
- package/Slider/Slider.d.ts +2 -2
- package/Slider/Slider.js +3 -2
- package/Slider/useSlider.d.ts +14 -0
- package/Slider/useSlider.js +647 -0
- package/Slider/useSlider.types.d.ts +228 -0
- package/Slider/useSlider.types.js +1 -0
- package/Snackbar/Snackbar.d.ts +1 -1
- package/Snackbar/Snackbar.js +3 -3
- package/Snackbar/useSnackbar.d.ts +14 -0
- package/Snackbar/useSnackbar.js +133 -0
- package/Snackbar/useSnackbar.types.d.ts +60 -0
- package/Snackbar/useSnackbar.types.js +1 -0
- package/SwipeableDrawer/SwipeableDrawer.js +1 -1
- package/TabScrollButton/TabScrollButton.d.ts +1 -1
- package/TabScrollButton/TabScrollButton.js +1 -1
- package/TablePagination/TablePagination.js +1 -1
- package/Tabs/Tabs.d.ts +1 -1
- package/Tabs/Tabs.js +1 -1
- package/TextareaAutosize/TextareaAutosize.d.ts +14 -0
- package/TextareaAutosize/TextareaAutosize.js +222 -0
- package/TextareaAutosize/TextareaAutosize.types.d.ts +13 -0
- package/TextareaAutosize/TextareaAutosize.types.js +1 -0
- package/TextareaAutosize/index.d.ts +3 -2
- package/TextareaAutosize/index.js +1 -1
- package/Tooltip/Tooltip.js +1 -1
- package/Unstable_TrapFocus/FocusTrap.d.ts +10 -0
- package/Unstable_TrapFocus/FocusTrap.js +330 -0
- package/Unstable_TrapFocus/FocusTrap.types.d.ts +51 -0
- package/Unstable_TrapFocus/FocusTrap.types.js +1 -0
- package/Unstable_TrapFocus/index.d.ts +2 -2
- package/Unstable_TrapFocus/index.js +1 -1
- package/index.d.ts +1 -1
- package/index.js +2 -2
- package/modern/Autocomplete/Autocomplete.js +1 -1
- package/modern/Badge/Badge.js +2 -2
- package/modern/Badge/useBadge.js +41 -0
- package/modern/Badge/useBadge.types.js +1 -0
- package/modern/Breadcrumbs/Breadcrumbs.js +1 -1
- package/modern/ClickAwayListener/ClickAwayListener.js +178 -0
- package/modern/ClickAwayListener/index.js +1 -1
- package/modern/InputBase/InputBase.js +2 -2
- package/modern/ListItem/ListItem.js +1 -1
- package/modern/Menu/Menu.js +1 -1
- package/modern/Modal/Modal.js +1 -1
- package/modern/Modal/ModalManager.js +211 -0
- package/modern/Modal/index.js +1 -1
- package/modern/Modal/useModal.js +195 -0
- package/modern/Modal/useModal.types.js +1 -0
- package/modern/NoSsr/NoSsr.js +73 -0
- package/modern/NoSsr/NoSsr.types.js +1 -0
- package/modern/NoSsr/index.js +1 -1
- package/modern/Popover/Popover.js +1 -1
- package/modern/Popper/BasePopper.js +370 -0
- package/modern/Popper/BasePopper.types.js +1 -0
- package/modern/Popper/Popper.js +1 -1
- package/modern/Popper/index.js +2 -1
- package/modern/Popper/popperClasses.js +7 -0
- package/modern/Portal/Portal.js +92 -0
- package/modern/Portal/Portal.types.js +1 -0
- package/modern/Portal/index.js +1 -1
- package/modern/Slider/Slider.js +3 -2
- package/modern/Slider/useSlider.js +647 -0
- package/modern/Slider/useSlider.types.js +1 -0
- package/modern/Snackbar/Snackbar.js +3 -3
- package/modern/Snackbar/useSnackbar.js +133 -0
- package/modern/Snackbar/useSnackbar.types.js +1 -0
- package/modern/SwipeableDrawer/SwipeableDrawer.js +1 -1
- package/modern/TabScrollButton/TabScrollButton.js +1 -1
- package/modern/TablePagination/TablePagination.js +1 -1
- package/modern/Tabs/Tabs.js +1 -1
- package/modern/TextareaAutosize/TextareaAutosize.js +222 -0
- package/modern/TextareaAutosize/TextareaAutosize.types.js +1 -0
- package/modern/TextareaAutosize/index.js +1 -1
- package/modern/Tooltip/Tooltip.js +1 -1
- package/modern/Unstable_TrapFocus/FocusTrap.js +330 -0
- package/modern/Unstable_TrapFocus/FocusTrap.types.js +1 -0
- package/modern/Unstable_TrapFocus/index.js +1 -1
- package/modern/index.js +2 -2
- package/modern/useAutocomplete/useAutocomplete.js +976 -2
- package/modern/utils/PolymorphicComponent.js +1 -0
- package/modern/utils/areArraysEqual.js +4 -0
- package/modern/utils/index.js +1 -1
- package/modern/utils/isHostComponent.js +7 -0
- package/modern/utils/omitEventHandlers.js +18 -0
- package/modern/utils/shouldSpreadAdditionalProps.js +1 -1
- package/modern/utils/useSlot.js +3 -1
- package/node/Autocomplete/Autocomplete.js +3 -3
- package/node/Badge/Badge.js +5 -5
- package/node/Badge/useBadge.js +46 -0
- package/node/Badge/useBadge.types.js +5 -0
- package/node/Breadcrumbs/Breadcrumbs.js +2 -2
- package/node/ClickAwayListener/ClickAwayListener.js +184 -0
- package/node/ClickAwayListener/index.js +1 -1
- package/node/InputBase/InputBase.js +7 -7
- package/node/ListItem/ListItem.js +3 -3
- package/node/Menu/Menu.js +3 -3
- package/node/Modal/Modal.js +2 -2
- package/node/Modal/ModalManager.js +219 -0
- package/node/Modal/index.js +2 -2
- package/node/Modal/useModal.js +205 -0
- package/node/Modal/useModal.types.js +5 -0
- package/node/NoSsr/NoSsr.js +81 -0
- package/node/NoSsr/NoSsr.types.js +5 -0
- package/node/NoSsr/index.js +3 -2
- package/node/Popover/Popover.js +2 -2
- package/node/Popper/BasePopper.js +379 -0
- package/node/Popper/BasePopper.types.js +5 -0
- package/node/Popper/Popper.js +2 -2
- package/node/Popper/index.js +14 -1
- package/node/Popper/popperClasses.js +15 -0
- package/node/Portal/Portal.js +100 -0
- package/node/Portal/Portal.types.js +5 -0
- package/node/Portal/index.js +3 -2
- package/node/Slider/Slider.js +14 -13
- package/node/Slider/useSlider.js +670 -0
- package/node/Slider/useSlider.types.js +5 -0
- package/node/Snackbar/Snackbar.js +6 -6
- package/node/Snackbar/useSnackbar.js +141 -0
- package/node/Snackbar/useSnackbar.types.js +5 -0
- package/node/SwipeableDrawer/SwipeableDrawer.js +2 -2
- package/node/TabScrollButton/TabScrollButton.js +3 -3
- package/node/TablePagination/TablePagination.js +2 -2
- package/node/Tabs/Tabs.js +3 -3
- package/node/TextareaAutosize/TextareaAutosize.js +230 -0
- package/node/TextareaAutosize/TextareaAutosize.types.js +5 -0
- package/node/TextareaAutosize/index.js +3 -2
- package/node/Tooltip/Tooltip.js +5 -5
- package/node/Unstable_TrapFocus/FocusTrap.js +339 -0
- package/node/Unstable_TrapFocus/FocusTrap.types.js +5 -0
- package/node/Unstable_TrapFocus/index.js +3 -2
- package/node/index.js +3 -3
- package/node/useAutocomplete/useAutocomplete.js +985 -18
- package/node/utils/PolymorphicComponent.js +5 -0
- package/node/utils/areArraysEqual.js +10 -0
- package/node/utils/index.js +2 -2
- package/node/utils/isHostComponent.js +13 -0
- package/node/utils/omitEventHandlers.js +24 -0
- package/node/utils/shouldSpreadAdditionalProps.js +3 -2
- package/node/utils/useSlot.js +6 -4
- package/package.json +8 -8
- package/styles/overrides.d.ts +1 -1
- package/useAutocomplete/useAutocomplete.d.ts +468 -2
- package/useAutocomplete/useAutocomplete.js +976 -2
- package/utils/PolymorphicComponent.d.ts +17 -0
- package/utils/PolymorphicComponent.js +1 -0
- package/utils/areArraysEqual.d.ts +3 -0
- package/utils/areArraysEqual.js +4 -0
- package/utils/index.d.ts +2 -1
- package/utils/index.js +1 -1
- package/utils/isHostComponent.d.ts +6 -0
- package/utils/isHostComponent.js +7 -0
- package/utils/omitEventHandlers.d.ts +9 -0
- package/utils/omitEventHandlers.js +18 -0
- package/utils/shouldSpreadAdditionalProps.js +1 -1
- package/utils/types.d.ts +2 -1
- package/utils/useSlot.js +3 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
function areArraysEqual(array1, array2, itemComparer = (a, b) => a === b) {
|
|
8
|
+
return array1.length === array2.length && array1.every((value, index) => itemComparer(value, array2[index]));
|
|
9
|
+
}
|
|
10
|
+
var _default = exports.default = areArraysEqual;
|
package/node/utils/index.js
CHANGED
|
@@ -102,7 +102,7 @@ Object.defineProperty(exports, "useForkRef", {
|
|
|
102
102
|
return _useForkRef.default;
|
|
103
103
|
}
|
|
104
104
|
});
|
|
105
|
-
var
|
|
105
|
+
var _utils = require("@mui/utils");
|
|
106
106
|
var _capitalize = _interopRequireDefault(require("./capitalize"));
|
|
107
107
|
var _createChainedFunction = _interopRequireDefault(require("./createChainedFunction"));
|
|
108
108
|
var _createSvgIcon = _interopRequireDefault(require("./createSvgIcon"));
|
|
@@ -126,6 +126,6 @@ const unstable_ClassNameGenerator = exports.unstable_ClassNameGenerator = {
|
|
|
126
126
|
if (process.env.NODE_ENV !== 'production') {
|
|
127
127
|
console.warn(['MUI: `ClassNameGenerator` import from `@mui/material/utils` is outdated and might cause unexpected issues.', '', "You should use `import { unstable_ClassNameGenerator } from '@mui/material/className'` instead", '', 'The detail of the issue: https://github.com/mui/material-ui/issues/30011#issuecomment-1024993401', '', 'The updated documentation: https://mui.com/guides/classname-generator/'].join('\n'));
|
|
128
128
|
}
|
|
129
|
-
|
|
129
|
+
_utils.unstable_ClassNameGenerator.configure(generator);
|
|
130
130
|
}
|
|
131
131
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Determines if a given element is a DOM element name (i.e. not a React component).
|
|
9
|
+
*/
|
|
10
|
+
function isHostComponent(element) {
|
|
11
|
+
return typeof element === 'string';
|
|
12
|
+
}
|
|
13
|
+
var _default = exports.default = isHostComponent;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Removes event handlers from the given object.
|
|
9
|
+
* A field is considered an event handler if it is a function with a name beginning with `on`.
|
|
10
|
+
*
|
|
11
|
+
* @param object Object to remove event handlers from.
|
|
12
|
+
* @returns Object with event handlers removed.
|
|
13
|
+
*/
|
|
14
|
+
function omitEventHandlers(object) {
|
|
15
|
+
if (object === undefined) {
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
const result = {};
|
|
19
|
+
Object.keys(object).filter(prop => !(prop.match(/^on[A-Z]/) && typeof object[prop] === 'function')).forEach(prop => {
|
|
20
|
+
result[prop] = object[prop];
|
|
21
|
+
});
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
var _default = exports.default = omitEventHandlers;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.default = void 0;
|
|
7
|
-
var
|
|
8
|
+
var _isHostComponent = _interopRequireDefault(require("./isHostComponent"));
|
|
8
9
|
const shouldSpreadAdditionalProps = Slot => {
|
|
9
|
-
return !Slot || !(0,
|
|
10
|
+
return !Slot || !(0, _isHostComponent.default)(Slot);
|
|
10
11
|
};
|
|
11
12
|
var _default = exports.default = shouldSpreadAdditionalProps;
|
package/node/utils/useSlot.js
CHANGED
|
@@ -7,7 +7,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = useSlot;
|
|
9
9
|
var _useForkRef = _interopRequireDefault(require("@mui/utils/useForkRef"));
|
|
10
|
-
var
|
|
10
|
+
var _appendOwnerState = _interopRequireDefault(require("@mui/utils/appendOwnerState"));
|
|
11
|
+
var _resolveComponentProps = _interopRequireDefault(require("@mui/utils/resolveComponentProps"));
|
|
12
|
+
var _mergeSlotProps = _interopRequireDefault(require("@mui/utils/mergeSlotProps"));
|
|
11
13
|
/**
|
|
12
14
|
* An internal function to create a Material UI slot.
|
|
13
15
|
*
|
|
@@ -53,14 +55,14 @@ name, parameters) {
|
|
|
53
55
|
|
|
54
56
|
// `slotProps[name]` can be a callback that receives the component's ownerState.
|
|
55
57
|
// `resolvedComponentsProps` is always a plain object.
|
|
56
|
-
const resolvedComponentsProps = (0,
|
|
58
|
+
const resolvedComponentsProps = (0, _resolveComponentProps.default)(slotProps[name], ownerState);
|
|
57
59
|
const {
|
|
58
60
|
props: {
|
|
59
61
|
component: slotComponent,
|
|
60
62
|
...mergedProps
|
|
61
63
|
},
|
|
62
64
|
internalRef
|
|
63
|
-
} = (0,
|
|
65
|
+
} = (0, _mergeSlotProps.default)({
|
|
64
66
|
className,
|
|
65
67
|
...useSlotPropsParams,
|
|
66
68
|
externalForwardedProps: name === 'root' ? other : undefined,
|
|
@@ -73,7 +75,7 @@ name, parameters) {
|
|
|
73
75
|
...slotOwnerState
|
|
74
76
|
};
|
|
75
77
|
const LeafComponent = name === 'root' ? slotComponent || rootComponent : slotComponent;
|
|
76
|
-
const props = (0,
|
|
78
|
+
const props = (0, _appendOwnerState.default)(elementType, {
|
|
77
79
|
...(name === 'root' && !rootComponent && !slots[name] && internalForwardedProps),
|
|
78
80
|
...(name !== 'root' && !slots[name] && internalForwardedProps),
|
|
79
81
|
...mergedProps,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/material",
|
|
3
|
-
"version": "6.0.0-beta.
|
|
3
|
+
"version": "6.0.0-beta.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"description": "Material UI is an open-source React component library that implements Google's Material Design. It's comprehensive and can be used in production out of the box.",
|
|
@@ -27,18 +27,18 @@
|
|
|
27
27
|
"url": "https://opencollective.com/mui-org"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@babel/runtime": "^7.24.
|
|
30
|
+
"@babel/runtime": "^7.24.8",
|
|
31
|
+
"@popperjs/core": "^2.11.8",
|
|
31
32
|
"@types/react-transition-group": "^4.4.10",
|
|
32
33
|
"clsx": "^2.1.1",
|
|
33
34
|
"csstype": "^3.1.3",
|
|
34
35
|
"prop-types": "^15.8.1",
|
|
35
36
|
"react-is": "^18.3.1",
|
|
36
37
|
"react-transition-group": "^4.4.5",
|
|
37
|
-
"@mui/
|
|
38
|
-
"@mui/
|
|
39
|
-
"@mui/system": "6.0.0-beta.
|
|
40
|
-
"@mui/types": "^7.2.14"
|
|
41
|
-
"@mui/utils": "6.0.0-beta.0"
|
|
38
|
+
"@mui/core-downloads-tracker": "^6.0.0-beta.2",
|
|
39
|
+
"@mui/utils": "6.0.0-beta.1",
|
|
40
|
+
"@mui/system": "6.0.0-beta.1",
|
|
41
|
+
"@mui/types": "^7.2.14"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@emotion/react": "^11.5.0",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@types/react": "^17.0.0 || ^18.0.0",
|
|
47
47
|
"react": "^17.0.0 || ^18.0.0",
|
|
48
48
|
"react-dom": "^17.0.0 || ^18.0.0",
|
|
49
|
-
"@mui/material-pigment-css": "^6.0.0-
|
|
49
|
+
"@mui/material-pigment-css": "^6.0.0-beta.1"
|
|
50
50
|
},
|
|
51
51
|
"peerDependenciesMeta": {
|
|
52
52
|
"@types/react": {
|
package/styles/overrides.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CSSObject, CSSInterpolation, Interpolation } from '@mui/system';
|
|
2
|
-
import { PopperClassKey } from '
|
|
2
|
+
import { PopperClassKey } from '../Popper';
|
|
3
3
|
import { ComponentsPropsList } from './props';
|
|
4
4
|
import { AccordionActionsClassKey } from '../AccordionActions';
|
|
5
5
|
import { AccordionClassKey } from '../Accordion';
|
|
@@ -1,2 +1,468 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
export interface CreateFilterOptionsConfig<Value> {
|
|
4
|
+
ignoreAccents?: boolean;
|
|
5
|
+
ignoreCase?: boolean;
|
|
6
|
+
limit?: number;
|
|
7
|
+
matchFrom?: 'any' | 'start';
|
|
8
|
+
stringify?: (option: Value) => string;
|
|
9
|
+
trim?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface FilterOptionsState<Value> {
|
|
13
|
+
inputValue: string;
|
|
14
|
+
getOptionLabel: (option: Value) => string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface AutocompleteGroupedOption<Value = string> {
|
|
18
|
+
key: number;
|
|
19
|
+
index: number;
|
|
20
|
+
group: string;
|
|
21
|
+
options: Value[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function createFilterOptions<Value>(
|
|
25
|
+
config?: CreateFilterOptionsConfig<Value>,
|
|
26
|
+
): (options: Value[], state: FilterOptionsState<Value>) => Value[];
|
|
27
|
+
|
|
28
|
+
export type AutocompleteFreeSoloValueMapping<FreeSolo> = FreeSolo extends true ? string : never;
|
|
29
|
+
|
|
30
|
+
export type AutocompleteValue<Value, Multiple, DisableClearable, FreeSolo> = Multiple extends true
|
|
31
|
+
? Array<Value | AutocompleteFreeSoloValueMapping<FreeSolo>>
|
|
32
|
+
: DisableClearable extends true
|
|
33
|
+
? NonNullable<Value | AutocompleteFreeSoloValueMapping<FreeSolo>>
|
|
34
|
+
: Value | null | AutocompleteFreeSoloValueMapping<FreeSolo>;
|
|
35
|
+
|
|
36
|
+
export interface UseAutocompleteProps<
|
|
37
|
+
Value,
|
|
38
|
+
Multiple extends boolean | undefined,
|
|
39
|
+
DisableClearable extends boolean | undefined,
|
|
40
|
+
FreeSolo extends boolean | undefined,
|
|
41
|
+
> {
|
|
42
|
+
/**
|
|
43
|
+
* @internal The prefix of the state class name, temporary for Joy UI
|
|
44
|
+
* @default 'Mui'
|
|
45
|
+
*/
|
|
46
|
+
unstable_classNamePrefix?: string;
|
|
47
|
+
/**
|
|
48
|
+
* @internal
|
|
49
|
+
* Temporary for Joy UI because the parent listbox is the document object
|
|
50
|
+
* TODO v6: Normalize the logic and remove this param.
|
|
51
|
+
*/
|
|
52
|
+
unstable_isActiveElementInListbox?: (listbox: React.RefObject<HTMLElement>) => boolean;
|
|
53
|
+
/**
|
|
54
|
+
* If `true`, the portion of the selected suggestion that the user hasn't typed,
|
|
55
|
+
* known as the completion string, appears inline after the input cursor in the textbox.
|
|
56
|
+
* The inline completion string is visually highlighted and has a selected state.
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
autoComplete?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* If `true`, the first option is automatically highlighted.
|
|
62
|
+
* @default false
|
|
63
|
+
*/
|
|
64
|
+
autoHighlight?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* If `true`, the selected option becomes the value of the input
|
|
67
|
+
* when the Autocomplete loses focus unless the user chooses
|
|
68
|
+
* a different option or changes the character string in the input.
|
|
69
|
+
*
|
|
70
|
+
* When using the `freeSolo` mode, the typed value will be the input value
|
|
71
|
+
* if the Autocomplete loses focus without highlighting an option.
|
|
72
|
+
* @default false
|
|
73
|
+
*/
|
|
74
|
+
autoSelect?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Control if the input should be blurred when an option is selected:
|
|
77
|
+
*
|
|
78
|
+
* - `false` the input is not blurred.
|
|
79
|
+
* - `true` the input is always blurred.
|
|
80
|
+
* - `touch` the input is blurred after a touch event.
|
|
81
|
+
* - `mouse` the input is blurred after a mouse event.
|
|
82
|
+
* @default false
|
|
83
|
+
*/
|
|
84
|
+
blurOnSelect?: 'touch' | 'mouse' | true | false;
|
|
85
|
+
/**
|
|
86
|
+
* If `true`, the input's text is cleared on blur if no value is selected.
|
|
87
|
+
*
|
|
88
|
+
* Set it to `true` if you want to help the user enter a new value.
|
|
89
|
+
* Set it to `false` if you want to help the user resume their search.
|
|
90
|
+
* @default !props.freeSolo
|
|
91
|
+
*/
|
|
92
|
+
clearOnBlur?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* If `true`, clear all values when the user presses escape and the popup is closed.
|
|
95
|
+
* @default false
|
|
96
|
+
*/
|
|
97
|
+
clearOnEscape?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* The component name that is using this hook. Used for warnings.
|
|
100
|
+
*/
|
|
101
|
+
componentName?: string;
|
|
102
|
+
/**
|
|
103
|
+
* The default value. Use when the component is not controlled.
|
|
104
|
+
* @default props.multiple ? [] : null
|
|
105
|
+
*/
|
|
106
|
+
defaultValue?: AutocompleteValue<Value, Multiple, DisableClearable, FreeSolo>;
|
|
107
|
+
/**
|
|
108
|
+
* If `true`, the input can't be cleared.
|
|
109
|
+
* @default false
|
|
110
|
+
*/
|
|
111
|
+
disableClearable?: DisableClearable;
|
|
112
|
+
/**
|
|
113
|
+
* If `true`, the popup won't close when a value is selected.
|
|
114
|
+
* @default false
|
|
115
|
+
*/
|
|
116
|
+
disableCloseOnSelect?: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* If `true`, the component is disabled.
|
|
119
|
+
* @default false
|
|
120
|
+
*/
|
|
121
|
+
disabled?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* If `true`, will allow focus on disabled items.
|
|
124
|
+
* @default false
|
|
125
|
+
*/
|
|
126
|
+
disabledItemsFocusable?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* If `true`, the list box in the popup will not wrap focus.
|
|
129
|
+
* @default false
|
|
130
|
+
*/
|
|
131
|
+
disableListWrap?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* A function that determines the filtered options to be rendered on search.
|
|
134
|
+
*
|
|
135
|
+
* @default createFilterOptions()
|
|
136
|
+
* @param {Value[]} options The options to render.
|
|
137
|
+
* @param {object} state The state of the component.
|
|
138
|
+
* @returns {Value[]}
|
|
139
|
+
*/
|
|
140
|
+
filterOptions?: (options: Value[], state: FilterOptionsState<Value>) => Value[];
|
|
141
|
+
/**
|
|
142
|
+
* If `true`, hide the selected options from the list box.
|
|
143
|
+
* @default false
|
|
144
|
+
*/
|
|
145
|
+
filterSelectedOptions?: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* If `true`, the Autocomplete is free solo, meaning that the user input is not bound to provided options.
|
|
148
|
+
* @default false
|
|
149
|
+
*/
|
|
150
|
+
freeSolo?: FreeSolo;
|
|
151
|
+
/**
|
|
152
|
+
* Used to determine the disabled state for a given option.
|
|
153
|
+
*
|
|
154
|
+
* @param {Value} option The option to test.
|
|
155
|
+
* @returns {boolean}
|
|
156
|
+
*/
|
|
157
|
+
getOptionDisabled?: (option: Value) => boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Used to determine the key for a given option.
|
|
160
|
+
* This can be useful when the labels of options are not unique (since labels are used as keys by default).
|
|
161
|
+
*
|
|
162
|
+
* @param {Value} option The option to get the key for.
|
|
163
|
+
* @returns {string | number}
|
|
164
|
+
*/
|
|
165
|
+
getOptionKey?: (option: Value | AutocompleteFreeSoloValueMapping<FreeSolo>) => string | number;
|
|
166
|
+
/**
|
|
167
|
+
* Used to determine the string value for a given option.
|
|
168
|
+
* It's used to fill the input (and the list box options if `renderOption` is not provided).
|
|
169
|
+
*
|
|
170
|
+
* If used in free solo mode, it must accept both the type of the options and a string.
|
|
171
|
+
*
|
|
172
|
+
* @param {Value} option
|
|
173
|
+
* @returns {string}
|
|
174
|
+
* @default (option) => option.label ?? option
|
|
175
|
+
*/
|
|
176
|
+
getOptionLabel?: (option: Value | AutocompleteFreeSoloValueMapping<FreeSolo>) => string;
|
|
177
|
+
/**
|
|
178
|
+
* If provided, the options will be grouped under the returned string.
|
|
179
|
+
* The groupBy value is also used as the text for group headings when `renderGroup` is not provided.
|
|
180
|
+
*
|
|
181
|
+
* @param {Value} options The options to group.
|
|
182
|
+
* @returns {string}
|
|
183
|
+
*/
|
|
184
|
+
groupBy?: (option: Value) => string;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* If `true`, the component handles the "Home" and "End" keys when the popup is open.
|
|
188
|
+
* It should move focus to the first option and last option, respectively.
|
|
189
|
+
* @default !props.freeSolo
|
|
190
|
+
*/
|
|
191
|
+
handleHomeEndKeys?: boolean;
|
|
192
|
+
/**
|
|
193
|
+
* This prop is used to help implement the accessibility logic.
|
|
194
|
+
* If you don't provide an id it will fall back to a randomly generated one.
|
|
195
|
+
*/
|
|
196
|
+
id?: string;
|
|
197
|
+
/**
|
|
198
|
+
* If `true`, the highlight can move to the input.
|
|
199
|
+
* @default false
|
|
200
|
+
*/
|
|
201
|
+
includeInputInList?: boolean;
|
|
202
|
+
/**
|
|
203
|
+
* The input value.
|
|
204
|
+
*/
|
|
205
|
+
inputValue?: string;
|
|
206
|
+
/**
|
|
207
|
+
* Used to determine if the option represents the given value.
|
|
208
|
+
* Uses strict equality by default.
|
|
209
|
+
* ⚠️ Both arguments need to be handled, an option can only match with one value.
|
|
210
|
+
*
|
|
211
|
+
* @param {Value} option The option to test.
|
|
212
|
+
* @param {Value} value The value to test against.
|
|
213
|
+
* @returns {boolean}
|
|
214
|
+
*/
|
|
215
|
+
isOptionEqualToValue?: (option: Value, value: Value) => boolean;
|
|
216
|
+
/**
|
|
217
|
+
* If `true`, `value` must be an array and the menu will support multiple selections.
|
|
218
|
+
* @default false
|
|
219
|
+
*/
|
|
220
|
+
multiple?: Multiple;
|
|
221
|
+
/**
|
|
222
|
+
* Callback fired when the value changes.
|
|
223
|
+
*
|
|
224
|
+
* @param {React.SyntheticEvent} event The event source of the callback.
|
|
225
|
+
* @param {Value|Value[]} value The new value of the component.
|
|
226
|
+
* @param {string} reason One of "createOption", "selectOption", "removeOption", "blur" or "clear".
|
|
227
|
+
* @param {string} [details]
|
|
228
|
+
*/
|
|
229
|
+
onChange?: (
|
|
230
|
+
event: React.SyntheticEvent,
|
|
231
|
+
value: AutocompleteValue<Value, Multiple, DisableClearable, FreeSolo>,
|
|
232
|
+
reason: AutocompleteChangeReason,
|
|
233
|
+
details?: AutocompleteChangeDetails<Value>,
|
|
234
|
+
) => void;
|
|
235
|
+
/**
|
|
236
|
+
* Callback fired when the popup requests to be closed.
|
|
237
|
+
* Use in controlled mode (see open).
|
|
238
|
+
*
|
|
239
|
+
* @param {React.SyntheticEvent} event The event source of the callback.
|
|
240
|
+
* @param {string} reason Can be: `"toggleInput"`, `"escape"`, `"selectOption"`, `"removeOption"`, `"blur"`.
|
|
241
|
+
*/
|
|
242
|
+
onClose?: (event: React.SyntheticEvent, reason: AutocompleteCloseReason) => void;
|
|
243
|
+
/**
|
|
244
|
+
* Callback fired when the highlight option changes.
|
|
245
|
+
*
|
|
246
|
+
* @param {React.SyntheticEvent} event The event source of the callback.
|
|
247
|
+
* @param {Value} option The highlighted option.
|
|
248
|
+
* @param {string} reason Can be: `"keyboard"`, `"auto"`, `"mouse"`, `"touch"`.
|
|
249
|
+
*/
|
|
250
|
+
onHighlightChange?: (
|
|
251
|
+
event: React.SyntheticEvent,
|
|
252
|
+
option: Value | null,
|
|
253
|
+
reason: AutocompleteHighlightChangeReason,
|
|
254
|
+
) => void;
|
|
255
|
+
/**
|
|
256
|
+
* Callback fired when the input value changes.
|
|
257
|
+
*
|
|
258
|
+
* @param {React.SyntheticEvent} event The event source of the callback.
|
|
259
|
+
* @param {string} value The new value of the text input.
|
|
260
|
+
* @param {string} reason Can be: `"input"` (user input), `"reset"` (programmatic change), `"clear"`, `"blur"`, `"selectOption"`, `"removeOption"`
|
|
261
|
+
*/
|
|
262
|
+
onInputChange?: (
|
|
263
|
+
event: React.SyntheticEvent,
|
|
264
|
+
value: string,
|
|
265
|
+
reason: AutocompleteInputChangeReason,
|
|
266
|
+
) => void;
|
|
267
|
+
/**
|
|
268
|
+
* Callback fired when the popup requests to be opened.
|
|
269
|
+
* Use in controlled mode (see open).
|
|
270
|
+
*
|
|
271
|
+
* @param {React.SyntheticEvent} event The event source of the callback.
|
|
272
|
+
*/
|
|
273
|
+
onOpen?: (event: React.SyntheticEvent) => void;
|
|
274
|
+
/**
|
|
275
|
+
* If `true`, the component is shown.
|
|
276
|
+
*/
|
|
277
|
+
open?: boolean;
|
|
278
|
+
/**
|
|
279
|
+
* If `true`, the popup will open on input focus.
|
|
280
|
+
* @default false
|
|
281
|
+
*/
|
|
282
|
+
openOnFocus?: boolean;
|
|
283
|
+
/**
|
|
284
|
+
* Array of options.
|
|
285
|
+
*/
|
|
286
|
+
options: ReadonlyArray<Value>;
|
|
287
|
+
/**
|
|
288
|
+
* If `true`, the component becomes readonly. It is also supported for multiple tags where the tag cannot be deleted.
|
|
289
|
+
* @default false
|
|
290
|
+
*/
|
|
291
|
+
readOnly?: boolean;
|
|
292
|
+
/**
|
|
293
|
+
* If `true`, the input's text is selected on focus.
|
|
294
|
+
* It helps the user clear the selected value.
|
|
295
|
+
* @default !props.freeSolo
|
|
296
|
+
*/
|
|
297
|
+
selectOnFocus?: boolean;
|
|
298
|
+
/**
|
|
299
|
+
* The value of the autocomplete.
|
|
300
|
+
*
|
|
301
|
+
* The value must have reference equality with the option in order to be selected.
|
|
302
|
+
* You can customize the equality behavior with the `isOptionEqualToValue` prop.
|
|
303
|
+
*/
|
|
304
|
+
value?: AutocompleteValue<Value, Multiple, DisableClearable, FreeSolo>;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export interface UseAutocompleteParameters<
|
|
308
|
+
Value,
|
|
309
|
+
Multiple extends boolean | undefined,
|
|
310
|
+
DisableClearable extends boolean | undefined,
|
|
311
|
+
FreeSolo extends boolean | undefined,
|
|
312
|
+
> extends UseAutocompleteProps<Value, Multiple, DisableClearable, FreeSolo> {}
|
|
313
|
+
|
|
314
|
+
export type AutocompleteHighlightChangeReason = 'keyboard' | 'mouse' | 'auto' | 'touch';
|
|
315
|
+
|
|
316
|
+
export type AutocompleteChangeReason =
|
|
317
|
+
| 'createOption'
|
|
318
|
+
| 'selectOption'
|
|
319
|
+
| 'removeOption'
|
|
320
|
+
| 'clear'
|
|
321
|
+
| 'blur';
|
|
322
|
+
export interface AutocompleteChangeDetails<Value = string> {
|
|
323
|
+
option: Value;
|
|
324
|
+
}
|
|
325
|
+
export type AutocompleteCloseReason =
|
|
326
|
+
| 'createOption'
|
|
327
|
+
| 'toggleInput'
|
|
328
|
+
| 'escape'
|
|
329
|
+
| 'selectOption'
|
|
330
|
+
| 'removeOption'
|
|
331
|
+
| 'blur';
|
|
332
|
+
export type AutocompleteInputChangeReason =
|
|
333
|
+
| 'input'
|
|
334
|
+
| 'reset'
|
|
335
|
+
| 'clear'
|
|
336
|
+
| 'blur'
|
|
337
|
+
| 'selectOption'
|
|
338
|
+
| 'removeOption';
|
|
339
|
+
|
|
340
|
+
export type AutocompleteGetTagProps = ({ index }: { index: number }) => {
|
|
341
|
+
key: number;
|
|
342
|
+
'data-tag-index': number;
|
|
343
|
+
tabIndex: -1;
|
|
344
|
+
onDelete: (event: any) => void;
|
|
345
|
+
};
|
|
346
|
+
/**
|
|
347
|
+
*
|
|
348
|
+
* Demos:
|
|
349
|
+
*
|
|
350
|
+
* - [Autocomplete](https://next.mui.com/base-ui/react-autocomplete/#hook)
|
|
351
|
+
*
|
|
352
|
+
* API:
|
|
353
|
+
*
|
|
354
|
+
* - [useAutocomplete API](https://next.mui.com/base-ui/react-autocomplete/hooks-api/#use-autocomplete)
|
|
355
|
+
*/
|
|
356
|
+
export function useAutocomplete<
|
|
357
|
+
Value,
|
|
358
|
+
Multiple extends boolean | undefined = false,
|
|
359
|
+
DisableClearable extends boolean | undefined = false,
|
|
360
|
+
FreeSolo extends boolean | undefined = false,
|
|
361
|
+
>(
|
|
362
|
+
props: UseAutocompleteProps<Value, Multiple, DisableClearable, FreeSolo>,
|
|
363
|
+
): UseAutocompleteReturnValue<Value, Multiple, DisableClearable, FreeSolo>;
|
|
364
|
+
|
|
365
|
+
export interface UseAutocompleteRenderedOption<Value> {
|
|
366
|
+
option: Value;
|
|
367
|
+
index: number;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
export interface UseAutocompleteReturnValue<
|
|
371
|
+
Value,
|
|
372
|
+
Multiple extends boolean | undefined = false,
|
|
373
|
+
DisableClearable extends boolean | undefined = false,
|
|
374
|
+
FreeSolo extends boolean | undefined = false,
|
|
375
|
+
> {
|
|
376
|
+
/**
|
|
377
|
+
* Resolver for the root slot's props.
|
|
378
|
+
* @param externalProps props for the root slot
|
|
379
|
+
* @returns props that should be spread on the root slot
|
|
380
|
+
*/
|
|
381
|
+
getRootProps: (externalProps?: any) => React.HTMLAttributes<HTMLDivElement>;
|
|
382
|
+
/**
|
|
383
|
+
* Resolver for the input element's props.
|
|
384
|
+
* @returns props that should be spread on the input element
|
|
385
|
+
*/
|
|
386
|
+
getInputProps: () => React.InputHTMLAttributes<HTMLInputElement> & {
|
|
387
|
+
ref: React.Ref<HTMLInputElement>;
|
|
388
|
+
};
|
|
389
|
+
/**
|
|
390
|
+
* Resolver for the input label element's props.
|
|
391
|
+
* @returns props that should be spread on the input label element
|
|
392
|
+
*/
|
|
393
|
+
getInputLabelProps: () => Omit<React.HTMLAttributes<HTMLLabelElement>, 'color'>;
|
|
394
|
+
/**
|
|
395
|
+
* Resolver for the `clear` button element's props.
|
|
396
|
+
* @returns props that should be spread on the *clear* button element
|
|
397
|
+
*/
|
|
398
|
+
getClearProps: () => React.HTMLAttributes<HTMLButtonElement>;
|
|
399
|
+
/**
|
|
400
|
+
* Resolver for the popup icon's props.
|
|
401
|
+
* @returns props that should be spread on the popup icon
|
|
402
|
+
*/
|
|
403
|
+
getPopupIndicatorProps: () => React.HTMLAttributes<HTMLButtonElement>;
|
|
404
|
+
/**
|
|
405
|
+
* A tag props getter.
|
|
406
|
+
*/
|
|
407
|
+
getTagProps: AutocompleteGetTagProps;
|
|
408
|
+
/**
|
|
409
|
+
* Resolver for the listbox component's props.
|
|
410
|
+
* @returns props that should be spread on the listbox component
|
|
411
|
+
*/
|
|
412
|
+
getListboxProps: () => React.HTMLAttributes<HTMLUListElement>;
|
|
413
|
+
/**
|
|
414
|
+
* Resolver for the rendered option element's props.
|
|
415
|
+
* @param renderedOption option rendered on the Autocomplete
|
|
416
|
+
* @returns props that should be spread on the li element
|
|
417
|
+
*/
|
|
418
|
+
getOptionProps: (
|
|
419
|
+
renderedOption: UseAutocompleteRenderedOption<Value>,
|
|
420
|
+
) => React.HTMLAttributes<HTMLLIElement> & { key: any };
|
|
421
|
+
/**
|
|
422
|
+
* Id for the Autocomplete.
|
|
423
|
+
*/
|
|
424
|
+
id: string;
|
|
425
|
+
/**
|
|
426
|
+
* The input value.
|
|
427
|
+
*/
|
|
428
|
+
inputValue: string;
|
|
429
|
+
/**
|
|
430
|
+
* The value of the autocomplete.
|
|
431
|
+
*/
|
|
432
|
+
value: AutocompleteValue<Value, Multiple, DisableClearable, FreeSolo>;
|
|
433
|
+
/**
|
|
434
|
+
* If `true`, the component input has some values.
|
|
435
|
+
*/
|
|
436
|
+
dirty: boolean;
|
|
437
|
+
/**
|
|
438
|
+
* If `true`, the listbox is being displayed.
|
|
439
|
+
*/
|
|
440
|
+
expanded: boolean;
|
|
441
|
+
/**
|
|
442
|
+
* If `true`, the popup is open on the component.
|
|
443
|
+
*/
|
|
444
|
+
popupOpen: boolean;
|
|
445
|
+
/**
|
|
446
|
+
* If `true`, the component is focused.
|
|
447
|
+
*/
|
|
448
|
+
focused: boolean;
|
|
449
|
+
/**
|
|
450
|
+
* An HTML element that is used to set the position of the component.
|
|
451
|
+
*/
|
|
452
|
+
anchorEl: null | HTMLElement;
|
|
453
|
+
/**
|
|
454
|
+
* Setter for the component `anchorEl`.
|
|
455
|
+
* @returns function for setting `anchorEl`
|
|
456
|
+
*/
|
|
457
|
+
setAnchorEl: () => void;
|
|
458
|
+
/**
|
|
459
|
+
* Index of the focused tag for the component.
|
|
460
|
+
*/
|
|
461
|
+
focusedTag: number;
|
|
462
|
+
/**
|
|
463
|
+
* The options to render. It's either `Value[]` or `AutocompleteGroupedOption<Value>[]` if the groupBy prop is provided.
|
|
464
|
+
*/
|
|
465
|
+
groupedOptions: Value[] | Array<AutocompleteGroupedOption<Value>>;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
export default useAutocomplete;
|