@mui/material 5.16.1 → 5.16.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 +18 -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 +2 -2
- package/Modal/ModalManager.d.ts +25 -0
- package/Modal/ModalManager.js +213 -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 +2 -1
- package/Popper/BasePopper.d.ts +7 -0
- package/Popper/BasePopper.js +372 -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 +655 -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 +4 -5
- package/Snackbar/useSnackbar.d.ts +14 -0
- package/Snackbar/useSnackbar.js +131 -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 +223 -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 +2 -3
- package/Unstable_TrapFocus/FocusTrap.d.ts +10 -0
- package/Unstable_TrapFocus/FocusTrap.js +332 -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/legacy/Autocomplete/Autocomplete.js +1 -1
- package/legacy/Badge/Badge.js +2 -2
- package/legacy/Badge/useBadge.js +42 -0
- package/legacy/Badge/useBadge.types.js +1 -0
- package/legacy/Breadcrumbs/Breadcrumbs.js +1 -1
- package/legacy/ClickAwayListener/ClickAwayListener.js +181 -0
- package/legacy/ClickAwayListener/index.js +1 -1
- package/legacy/InputBase/InputBase.js +2 -2
- package/legacy/ListItem/ListItem.js +1 -1
- package/legacy/Menu/Menu.js +1 -1
- package/legacy/Modal/Modal.js +2 -2
- package/legacy/Modal/ModalManager.js +233 -0
- package/legacy/Modal/index.js +1 -1
- package/legacy/Modal/useModal.js +206 -0
- package/legacy/Modal/useModal.types.js +1 -0
- package/legacy/NoSsr/NoSsr.js +75 -0
- package/legacy/NoSsr/NoSsr.types.js +1 -0
- package/legacy/NoSsr/index.js +1 -1
- package/legacy/Popover/Popover.js +2 -1
- package/legacy/Popper/BasePopper.js +380 -0
- package/legacy/Popper/BasePopper.types.js +1 -0
- package/legacy/Popper/Popper.js +1 -1
- package/legacy/Popper/index.js +2 -1
- package/legacy/Popper/popperClasses.js +7 -0
- package/legacy/Portal/Portal.js +92 -0
- package/legacy/Portal/Portal.types.js +1 -0
- package/legacy/Portal/index.js +1 -1
- package/legacy/Slider/Slider.js +3 -2
- package/legacy/Slider/useSlider.js +701 -0
- package/legacy/Slider/useSlider.types.js +1 -0
- package/legacy/Snackbar/Snackbar.js +4 -5
- package/legacy/Snackbar/useSnackbar.js +141 -0
- package/legacy/Snackbar/useSnackbar.types.js +1 -0
- package/legacy/SwipeableDrawer/SwipeableDrawer.js +1 -1
- package/legacy/TabScrollButton/TabScrollButton.js +1 -1
- package/legacy/TablePagination/TablePagination.js +1 -1
- package/legacy/Tabs/Tabs.js +1 -1
- package/legacy/TextareaAutosize/TextareaAutosize.js +220 -0
- package/legacy/TextareaAutosize/TextareaAutosize.types.js +1 -0
- package/legacy/TextareaAutosize/index.js +1 -1
- package/legacy/Tooltip/Tooltip.js +2 -3
- package/legacy/Unstable_TrapFocus/FocusTrap.js +341 -0
- package/legacy/Unstable_TrapFocus/FocusTrap.types.js +1 -0
- package/legacy/Unstable_TrapFocus/index.js +1 -1
- package/legacy/index.js +2 -2
- package/legacy/useAutocomplete/useAutocomplete.js +1078 -2
- package/legacy/utils/PolymorphicComponent.js +1 -0
- package/legacy/utils/areArraysEqual.js +9 -0
- package/legacy/utils/index.js +1 -1
- package/legacy/utils/shouldSpreadAdditionalProps.js +1 -1
- package/legacy/utils/useSlot.js +3 -1
- 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 +2 -2
- package/modern/Modal/ModalManager.js +213 -0
- package/modern/Modal/index.js +1 -1
- package/modern/Modal/useModal.js +193 -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 +2 -1
- package/modern/Popper/BasePopper.js +371 -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 +643 -0
- package/modern/Slider/useSlider.types.js +1 -0
- package/modern/Snackbar/Snackbar.js +4 -5
- package/modern/Snackbar/useSnackbar.js +131 -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 +223 -0
- package/modern/TextareaAutosize/TextareaAutosize.types.js +1 -0
- package/modern/TextareaAutosize/index.js +1 -1
- package/modern/Tooltip/Tooltip.js +2 -3
- package/modern/Unstable_TrapFocus/FocusTrap.js +331 -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 +987 -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/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 +5 -5
- package/node/Modal/ModalManager.js +221 -0
- package/node/Modal/index.js +2 -2
- package/node/Modal/useModal.js +203 -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 +5 -4
- package/node/Popper/BasePopper.js +380 -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 +666 -0
- package/node/Slider/useSlider.types.js +5 -0
- package/node/Snackbar/Snackbar.js +9 -10
- package/node/Snackbar/useSnackbar.js +139 -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 +10 -11
- 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 +997 -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/shouldSpreadAdditionalProps.js +3 -2
- package/node/utils/useSlot.js +6 -4
- package/package.json +4 -5
- package/styles/overrides.d.ts +1 -1
- package/umd/material-ui.development.js +9190 -9248
- package/umd/material-ui.production.min.js +3 -3
- package/useAutocomplete/useAutocomplete.d.ts +460 -2
- package/useAutocomplete/useAutocomplete.js +994 -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/shouldSpreadAdditionalProps.js +1 -1
- package/utils/types.d.ts +2 -1
- package/utils/useSlot.js +3 -1
|
@@ -5,12 +5,11 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
5
5
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
-
import { useSlotProps } from '@mui/base/utils';
|
|
9
8
|
import composeClasses from '@mui/utils/composeClasses';
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import useTheme from '../styles
|
|
9
|
+
import useSlotProps from '@mui/utils/useSlotProps';
|
|
10
|
+
import useSnackbar from './useSnackbar';
|
|
11
|
+
import ClickAwayListener from '../ClickAwayListener';
|
|
12
|
+
import { styled, useTheme } from '../styles';
|
|
14
13
|
import { useDefaultProps } from '../DefaultPropsProvider';
|
|
15
14
|
import capitalize from '../utils/capitalize';
|
|
16
15
|
import Grow from '../Grow';
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { unstable_useEventCallback as useEventCallback, unstable_useTimeout as useTimeout } from '@mui/utils';
|
|
6
|
+
import extractEventHandlers from '@mui/utils/extractEventHandlers';
|
|
7
|
+
/**
|
|
8
|
+
* The basic building block for creating custom snackbar.
|
|
9
|
+
*
|
|
10
|
+
* Demos:
|
|
11
|
+
*
|
|
12
|
+
* - [Snackbar](https://mui.com/base-ui/react-snackbar/#hook)
|
|
13
|
+
*
|
|
14
|
+
* API:
|
|
15
|
+
*
|
|
16
|
+
* - [useSnackbar API](https://mui.com/base-ui/react-snackbar/hooks-api/#use-snackbar)
|
|
17
|
+
*/
|
|
18
|
+
function useSnackbar() {
|
|
19
|
+
var parameters = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
20
|
+
var _parameters$autoHideD = parameters.autoHideDuration,
|
|
21
|
+
autoHideDuration = _parameters$autoHideD === void 0 ? null : _parameters$autoHideD,
|
|
22
|
+
_parameters$disableWi = parameters.disableWindowBlurListener,
|
|
23
|
+
disableWindowBlurListener = _parameters$disableWi === void 0 ? false : _parameters$disableWi,
|
|
24
|
+
onClose = parameters.onClose,
|
|
25
|
+
open = parameters.open,
|
|
26
|
+
resumeHideDuration = parameters.resumeHideDuration;
|
|
27
|
+
var timerAutoHide = useTimeout();
|
|
28
|
+
React.useEffect(function () {
|
|
29
|
+
if (!open) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @param {KeyboardEvent} nativeEvent
|
|
35
|
+
*/
|
|
36
|
+
function handleKeyDown(nativeEvent) {
|
|
37
|
+
if (!nativeEvent.defaultPrevented) {
|
|
38
|
+
// IE11, Edge (prior to using Blink?) use 'Esc'
|
|
39
|
+
if (nativeEvent.key === 'Escape' || nativeEvent.key === 'Esc') {
|
|
40
|
+
// not calling `preventDefault` since we don't know if people may ignore this event e.g. a permanently open snackbar
|
|
41
|
+
onClose == null || onClose(nativeEvent, 'escapeKeyDown');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
46
|
+
return function () {
|
|
47
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
48
|
+
};
|
|
49
|
+
}, [open, onClose]);
|
|
50
|
+
var handleClose = useEventCallback(function (event, reason) {
|
|
51
|
+
onClose == null || onClose(event, reason);
|
|
52
|
+
});
|
|
53
|
+
var setAutoHideTimer = useEventCallback(function (autoHideDurationParam) {
|
|
54
|
+
if (!onClose || autoHideDurationParam == null) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
timerAutoHide.start(autoHideDurationParam, function () {
|
|
58
|
+
handleClose(null, 'timeout');
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
React.useEffect(function () {
|
|
62
|
+
if (open) {
|
|
63
|
+
setAutoHideTimer(autoHideDuration);
|
|
64
|
+
}
|
|
65
|
+
return timerAutoHide.clear;
|
|
66
|
+
}, [open, autoHideDuration, setAutoHideTimer, timerAutoHide]);
|
|
67
|
+
var handleClickAway = function handleClickAway(event) {
|
|
68
|
+
onClose == null || onClose(event, 'clickaway');
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// Pause the timer when the user is interacting with the Snackbar
|
|
72
|
+
// or when the user hide the window.
|
|
73
|
+
var handlePause = timerAutoHide.clear;
|
|
74
|
+
|
|
75
|
+
// Restart the timer when the user is no longer interacting with the Snackbar
|
|
76
|
+
// or when the window is shown back.
|
|
77
|
+
var handleResume = React.useCallback(function () {
|
|
78
|
+
if (autoHideDuration != null) {
|
|
79
|
+
setAutoHideTimer(resumeHideDuration != null ? resumeHideDuration : autoHideDuration * 0.5);
|
|
80
|
+
}
|
|
81
|
+
}, [autoHideDuration, resumeHideDuration, setAutoHideTimer]);
|
|
82
|
+
var createHandleBlur = function createHandleBlur(otherHandlers) {
|
|
83
|
+
return function (event) {
|
|
84
|
+
var onBlurCallback = otherHandlers.onBlur;
|
|
85
|
+
onBlurCallback == null || onBlurCallback(event);
|
|
86
|
+
handleResume();
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
var createHandleFocus = function createHandleFocus(otherHandlers) {
|
|
90
|
+
return function (event) {
|
|
91
|
+
var onFocusCallback = otherHandlers.onFocus;
|
|
92
|
+
onFocusCallback == null || onFocusCallback(event);
|
|
93
|
+
handlePause();
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
var createMouseEnter = function createMouseEnter(otherHandlers) {
|
|
97
|
+
return function (event) {
|
|
98
|
+
var onMouseEnterCallback = otherHandlers.onMouseEnter;
|
|
99
|
+
onMouseEnterCallback == null || onMouseEnterCallback(event);
|
|
100
|
+
handlePause();
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
var createMouseLeave = function createMouseLeave(otherHandlers) {
|
|
104
|
+
return function (event) {
|
|
105
|
+
var onMouseLeaveCallback = otherHandlers.onMouseLeave;
|
|
106
|
+
onMouseLeaveCallback == null || onMouseLeaveCallback(event);
|
|
107
|
+
handleResume();
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
React.useEffect(function () {
|
|
111
|
+
// TODO: window global should be refactored here
|
|
112
|
+
if (!disableWindowBlurListener && open) {
|
|
113
|
+
window.addEventListener('focus', handleResume);
|
|
114
|
+
window.addEventListener('blur', handlePause);
|
|
115
|
+
return function () {
|
|
116
|
+
window.removeEventListener('focus', handleResume);
|
|
117
|
+
window.removeEventListener('blur', handlePause);
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
return undefined;
|
|
121
|
+
}, [disableWindowBlurListener, open, handleResume, handlePause]);
|
|
122
|
+
var getRootProps = function getRootProps() {
|
|
123
|
+
var externalProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
124
|
+
var externalEventHandlers = _extends({}, extractEventHandlers(parameters), extractEventHandlers(externalProps));
|
|
125
|
+
return _extends({
|
|
126
|
+
// ClickAwayListener adds an `onClick` prop which results in the alert not being announced.
|
|
127
|
+
// See https://github.com/mui/material-ui/issues/29080
|
|
128
|
+
role: 'presentation'
|
|
129
|
+
}, externalProps, externalEventHandlers, {
|
|
130
|
+
onBlur: createHandleBlur(externalEventHandlers),
|
|
131
|
+
onFocus: createHandleFocus(externalEventHandlers),
|
|
132
|
+
onMouseEnter: createMouseEnter(externalEventHandlers),
|
|
133
|
+
onMouseLeave: createMouseLeave(externalEventHandlers)
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
return {
|
|
137
|
+
getRootProps: getRootProps,
|
|
138
|
+
onClickAway: handleClickAway
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
export default useSnackbar;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -6,7 +6,7 @@ import * as React from 'react';
|
|
|
6
6
|
import * as ReactDOM from 'react-dom';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import elementTypeAcceptingRef from '@mui/utils/elementTypeAcceptingRef';
|
|
9
|
-
import
|
|
9
|
+
import NoSsr from '../NoSsr';
|
|
10
10
|
import { useDefaultProps } from '../DefaultPropsProvider';
|
|
11
11
|
import Drawer, { getAnchor, isHorizontal } from '../Drawer/Drawer';
|
|
12
12
|
import useForkRef from '../utils/useForkRef';
|
|
@@ -7,9 +7,9 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
7
7
|
import * as React from 'react';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
9
|
import clsx from 'clsx';
|
|
10
|
-
import { useSlotProps } from '@mui/base/utils';
|
|
11
10
|
import composeClasses from '@mui/utils/composeClasses';
|
|
12
11
|
import { useRtl } from '@mui/system/RtlProvider';
|
|
12
|
+
import useSlotProps from '@mui/utils/useSlotProps';
|
|
13
13
|
import KeyboardArrowLeft from '../internal/svg-icons/KeyboardArrowLeft';
|
|
14
14
|
import KeyboardArrowRight from '../internal/svg-icons/KeyboardArrowRight';
|
|
15
15
|
import ButtonBase from '../ButtonBase';
|
|
@@ -9,8 +9,8 @@ import PropTypes from 'prop-types';
|
|
|
9
9
|
import clsx from 'clsx';
|
|
10
10
|
import integerPropType from '@mui/utils/integerPropType';
|
|
11
11
|
import chainPropTypes from '@mui/utils/chainPropTypes';
|
|
12
|
-
import { isHostComponent } from '@mui/base/utils';
|
|
13
12
|
import composeClasses from '@mui/utils/composeClasses';
|
|
13
|
+
import isHostComponent from '@mui/utils/isHostComponent';
|
|
14
14
|
import styled from '../styles/styled';
|
|
15
15
|
import { useDefaultProps } from '../DefaultPropsProvider';
|
|
16
16
|
import InputBase from '../InputBase';
|
package/legacy/Tabs/Tabs.js
CHANGED
|
@@ -8,9 +8,9 @@ import { isFragment } from 'react-is';
|
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
9
|
import clsx from 'clsx';
|
|
10
10
|
import refType from '@mui/utils/refType';
|
|
11
|
-
import { useSlotProps } from '@mui/base/utils';
|
|
12
11
|
import composeClasses from '@mui/utils/composeClasses';
|
|
13
12
|
import { useRtl } from '@mui/system/RtlProvider';
|
|
13
|
+
import useSlotProps from '@mui/utils/useSlotProps';
|
|
14
14
|
import styled from '../styles/styled';
|
|
15
15
|
import { useDefaultProps } from '../DefaultPropsProvider';
|
|
16
16
|
import useTheme from '../styles/useTheme';
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import { unstable_debounce as debounce, unstable_useForkRef as useForkRef, unstable_useEnhancedEffect as useEnhancedEffect, unstable_ownerWindow as ownerWindow } from '@mui/utils';
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
function getStyleValue(value) {
|
|
11
|
+
return parseInt(value, 10) || 0;
|
|
12
|
+
}
|
|
13
|
+
var styles = {
|
|
14
|
+
shadow: {
|
|
15
|
+
// Visibility needed to hide the extra text area on iPads
|
|
16
|
+
visibility: 'hidden',
|
|
17
|
+
// Remove from the content flow
|
|
18
|
+
position: 'absolute',
|
|
19
|
+
// Ignore the scrollbar width
|
|
20
|
+
overflow: 'hidden',
|
|
21
|
+
height: 0,
|
|
22
|
+
top: 0,
|
|
23
|
+
left: 0,
|
|
24
|
+
// Create a new layer, increase the isolation of the computed values
|
|
25
|
+
transform: 'translateZ(0)'
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
function isEmpty(obj) {
|
|
29
|
+
return obj === undefined || obj === null || Object.keys(obj).length === 0 || obj.outerHeightStyle === 0 && !obj.overflowing;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* Demos:
|
|
35
|
+
*
|
|
36
|
+
* - [Textarea Autosize](https://mui.com/material-ui/react-textarea-autosize/)
|
|
37
|
+
*
|
|
38
|
+
* API:
|
|
39
|
+
*
|
|
40
|
+
* - [TextareaAutosize API](https://mui.com/material-ui/api/textarea-autosize/)
|
|
41
|
+
*/
|
|
42
|
+
var TextareaAutosize = /*#__PURE__*/React.forwardRef(function TextareaAutosize(props, forwardedRef) {
|
|
43
|
+
var onChange = props.onChange,
|
|
44
|
+
maxRows = props.maxRows,
|
|
45
|
+
_props$minRows = props.minRows,
|
|
46
|
+
minRows = _props$minRows === void 0 ? 1 : _props$minRows,
|
|
47
|
+
style = props.style,
|
|
48
|
+
value = props.value,
|
|
49
|
+
other = _objectWithoutProperties(props, ["onChange", "maxRows", "minRows", "style", "value"]);
|
|
50
|
+
var _React$useRef = React.useRef(value != null),
|
|
51
|
+
isControlled = _React$useRef.current;
|
|
52
|
+
var inputRef = React.useRef(null);
|
|
53
|
+
var handleRef = useForkRef(forwardedRef, inputRef);
|
|
54
|
+
var heightRef = React.useRef(null);
|
|
55
|
+
var shadowRef = React.useRef(null);
|
|
56
|
+
var calculateTextareaStyles = React.useCallback(function () {
|
|
57
|
+
var input = inputRef.current;
|
|
58
|
+
var containerWindow = ownerWindow(input);
|
|
59
|
+
var computedStyle = containerWindow.getComputedStyle(input);
|
|
60
|
+
|
|
61
|
+
// If input's width is shrunk and it's not visible, don't sync height.
|
|
62
|
+
if (computedStyle.width === '0px') {
|
|
63
|
+
return {
|
|
64
|
+
outerHeightStyle: 0,
|
|
65
|
+
overflowing: false
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
var inputShallow = shadowRef.current;
|
|
69
|
+
inputShallow.style.width = computedStyle.width;
|
|
70
|
+
inputShallow.value = input.value || props.placeholder || 'x';
|
|
71
|
+
if (inputShallow.value.slice(-1) === '\n') {
|
|
72
|
+
// Certain fonts which overflow the line height will cause the textarea
|
|
73
|
+
// to report a different scrollHeight depending on whether the last line
|
|
74
|
+
// is empty. Make it non-empty to avoid this issue.
|
|
75
|
+
inputShallow.value += ' ';
|
|
76
|
+
}
|
|
77
|
+
var boxSizing = computedStyle.boxSizing;
|
|
78
|
+
var padding = getStyleValue(computedStyle.paddingBottom) + getStyleValue(computedStyle.paddingTop);
|
|
79
|
+
var border = getStyleValue(computedStyle.borderBottomWidth) + getStyleValue(computedStyle.borderTopWidth);
|
|
80
|
+
|
|
81
|
+
// The height of the inner content
|
|
82
|
+
var innerHeight = inputShallow.scrollHeight;
|
|
83
|
+
|
|
84
|
+
// Measure height of a textarea with a single row
|
|
85
|
+
inputShallow.value = 'x';
|
|
86
|
+
var singleRowHeight = inputShallow.scrollHeight;
|
|
87
|
+
|
|
88
|
+
// The height of the outer content
|
|
89
|
+
var outerHeight = innerHeight;
|
|
90
|
+
if (minRows) {
|
|
91
|
+
outerHeight = Math.max(Number(minRows) * singleRowHeight, outerHeight);
|
|
92
|
+
}
|
|
93
|
+
if (maxRows) {
|
|
94
|
+
outerHeight = Math.min(Number(maxRows) * singleRowHeight, outerHeight);
|
|
95
|
+
}
|
|
96
|
+
outerHeight = Math.max(outerHeight, singleRowHeight);
|
|
97
|
+
|
|
98
|
+
// Take the box sizing into account for applying this value as a style.
|
|
99
|
+
var outerHeightStyle = outerHeight + (boxSizing === 'border-box' ? padding + border : 0);
|
|
100
|
+
var overflowing = Math.abs(outerHeight - innerHeight) <= 1;
|
|
101
|
+
return {
|
|
102
|
+
outerHeightStyle: outerHeightStyle,
|
|
103
|
+
overflowing: overflowing
|
|
104
|
+
};
|
|
105
|
+
}, [maxRows, minRows, props.placeholder]);
|
|
106
|
+
var syncHeight = React.useCallback(function () {
|
|
107
|
+
var textareaStyles = calculateTextareaStyles();
|
|
108
|
+
if (isEmpty(textareaStyles)) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
var outerHeightStyle = textareaStyles.outerHeightStyle;
|
|
112
|
+
var input = inputRef.current;
|
|
113
|
+
if (heightRef.current !== outerHeightStyle) {
|
|
114
|
+
heightRef.current = outerHeightStyle;
|
|
115
|
+
input.style.height = "".concat(outerHeightStyle, "px");
|
|
116
|
+
}
|
|
117
|
+
input.style.overflow = textareaStyles.overflowing ? 'hidden' : '';
|
|
118
|
+
}, [calculateTextareaStyles]);
|
|
119
|
+
useEnhancedEffect(function () {
|
|
120
|
+
var handleResize = function handleResize() {
|
|
121
|
+
syncHeight();
|
|
122
|
+
};
|
|
123
|
+
// Workaround a "ResizeObserver loop completed with undelivered notifications" error
|
|
124
|
+
// in test.
|
|
125
|
+
// Note that we might need to use this logic in production per https://github.com/WICG/resize-observer/issues/38
|
|
126
|
+
// Also see https://github.com/mui/mui-x/issues/8733
|
|
127
|
+
var rAF;
|
|
128
|
+
var rAFHandleResize = function rAFHandleResize() {
|
|
129
|
+
cancelAnimationFrame(rAF);
|
|
130
|
+
rAF = requestAnimationFrame(function () {
|
|
131
|
+
handleResize();
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
var debounceHandleResize = debounce(handleResize);
|
|
135
|
+
var input = inputRef.current;
|
|
136
|
+
var containerWindow = ownerWindow(input);
|
|
137
|
+
containerWindow.addEventListener('resize', debounceHandleResize);
|
|
138
|
+
var resizeObserver;
|
|
139
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
140
|
+
resizeObserver = new ResizeObserver(process.env.NODE_ENV === 'test' ? rAFHandleResize : handleResize);
|
|
141
|
+
resizeObserver.observe(input);
|
|
142
|
+
}
|
|
143
|
+
return function () {
|
|
144
|
+
debounceHandleResize.clear();
|
|
145
|
+
cancelAnimationFrame(rAF);
|
|
146
|
+
containerWindow.removeEventListener('resize', debounceHandleResize);
|
|
147
|
+
if (resizeObserver) {
|
|
148
|
+
resizeObserver.disconnect();
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
}, [calculateTextareaStyles, syncHeight]);
|
|
152
|
+
useEnhancedEffect(function () {
|
|
153
|
+
syncHeight();
|
|
154
|
+
});
|
|
155
|
+
var handleChange = function handleChange(event) {
|
|
156
|
+
if (!isControlled) {
|
|
157
|
+
syncHeight();
|
|
158
|
+
}
|
|
159
|
+
if (onChange) {
|
|
160
|
+
onChange(event);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
164
|
+
children: [/*#__PURE__*/_jsx("textarea", _extends({
|
|
165
|
+
value: value,
|
|
166
|
+
onChange: handleChange,
|
|
167
|
+
ref: handleRef
|
|
168
|
+
// Apply the rows prop to get a "correct" first SSR paint
|
|
169
|
+
,
|
|
170
|
+
rows: minRows,
|
|
171
|
+
style: style
|
|
172
|
+
}, other)), /*#__PURE__*/_jsx("textarea", {
|
|
173
|
+
"aria-hidden": true,
|
|
174
|
+
className: props.className,
|
|
175
|
+
readOnly: true,
|
|
176
|
+
ref: shadowRef,
|
|
177
|
+
tabIndex: -1,
|
|
178
|
+
style: _extends({}, styles.shadow, style, {
|
|
179
|
+
paddingTop: 0,
|
|
180
|
+
paddingBottom: 0
|
|
181
|
+
})
|
|
182
|
+
})]
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
process.env.NODE_ENV !== "production" ? TextareaAutosize.propTypes /* remove-proptypes */ = {
|
|
186
|
+
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
187
|
+
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
188
|
+
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
|
189
|
+
// └─────────────────────────────────────────────────────────────────────┘
|
|
190
|
+
/**
|
|
191
|
+
* @ignore
|
|
192
|
+
*/
|
|
193
|
+
className: PropTypes.string,
|
|
194
|
+
/**
|
|
195
|
+
* Maximum number of rows to display.
|
|
196
|
+
*/
|
|
197
|
+
maxRows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
198
|
+
/**
|
|
199
|
+
* Minimum number of rows to display.
|
|
200
|
+
* @default 1
|
|
201
|
+
*/
|
|
202
|
+
minRows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
203
|
+
/**
|
|
204
|
+
* @ignore
|
|
205
|
+
*/
|
|
206
|
+
onChange: PropTypes.func,
|
|
207
|
+
/**
|
|
208
|
+
* @ignore
|
|
209
|
+
*/
|
|
210
|
+
placeholder: PropTypes.string,
|
|
211
|
+
/**
|
|
212
|
+
* @ignore
|
|
213
|
+
*/
|
|
214
|
+
style: PropTypes.object,
|
|
215
|
+
/**
|
|
216
|
+
* @ignore
|
|
217
|
+
*/
|
|
218
|
+
value: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.number, PropTypes.string])
|
|
219
|
+
} : void 0;
|
|
220
|
+
export default TextareaAutosize;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { default } from './TextareaAutosize';
|
|
@@ -9,12 +9,11 @@ import PropTypes from 'prop-types';
|
|
|
9
9
|
import clsx from 'clsx';
|
|
10
10
|
import useTimeout, { Timeout } from '@mui/utils/useTimeout';
|
|
11
11
|
import elementAcceptingRef from '@mui/utils/elementAcceptingRef';
|
|
12
|
-
import { appendOwnerState } from '@mui/base/utils';
|
|
13
12
|
import composeClasses from '@mui/utils/composeClasses';
|
|
14
13
|
import { alpha } from '@mui/system/colorManipulator';
|
|
15
14
|
import { useRtl } from '@mui/system/RtlProvider';
|
|
16
|
-
import
|
|
17
|
-
import useTheme from '../styles
|
|
15
|
+
import appendOwnerState from '@mui/utils/appendOwnerState';
|
|
16
|
+
import { styled, useTheme } from '../styles';
|
|
18
17
|
import { useDefaultProps } from '../DefaultPropsProvider';
|
|
19
18
|
import capitalize from '../utils/capitalize';
|
|
20
19
|
import Grow from '../Grow';
|