@mui/material 9.0.0 → 9.1.0
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/Accordion/Accordion.d.mts +2 -2
- package/Accordion/Accordion.d.ts +2 -2
- package/Accordion/Accordion.js +3 -2
- package/Accordion/Accordion.mjs +3 -2
- package/AccordionSummary/AccordionSummary.js +27 -29
- package/AccordionSummary/AccordionSummary.mjs +27 -29
- package/Autocomplete/Autocomplete.js +73 -17
- package/Autocomplete/Autocomplete.mjs +73 -17
- package/Avatar/Avatar.js +4 -0
- package/Avatar/Avatar.mjs +4 -0
- package/Backdrop/Backdrop.d.mts +2 -2
- package/Backdrop/Backdrop.d.ts +2 -2
- package/Badge/Badge.js +31 -24
- package/Badge/Badge.mjs +31 -24
- package/BottomNavigationAction/BottomNavigationAction.js +6 -2
- package/BottomNavigationAction/BottomNavigationAction.mjs +6 -2
- package/Button/Button.js +19 -6
- package/Button/Button.mjs +19 -6
- package/ButtonBase/ButtonBase.d.mts +7 -0
- package/ButtonBase/ButtonBase.d.ts +7 -0
- package/ButtonBase/ButtonBase.js +5 -2
- package/ButtonBase/ButtonBase.mjs +5 -2
- package/ButtonBase/Ripple.js +21 -11
- package/ButtonBase/Ripple.mjs +21 -11
- package/ButtonBase/TouchRipple.js +252 -116
- package/ButtonBase/TouchRipple.mjs +253 -117
- package/CHANGELOG.md +216 -1245
- package/CardActionArea/CardActionArea.js +2 -1
- package/CardActionArea/CardActionArea.mjs +2 -1
- package/Checkbox/Checkbox.js +2 -1
- package/Checkbox/Checkbox.mjs +2 -1
- package/Chip/Chip.js +2 -1
- package/Chip/Chip.mjs +2 -1
- package/CircularProgress/CircularProgress.d.mts +12 -2
- package/CircularProgress/CircularProgress.d.ts +12 -2
- package/CircularProgress/CircularProgress.js +115 -58
- package/CircularProgress/CircularProgress.mjs +114 -58
- package/ClickAwayListener/ClickAwayListener.js +3 -6
- package/ClickAwayListener/ClickAwayListener.mjs +3 -6
- package/Collapse/Collapse.d.mts +15 -3
- package/Collapse/Collapse.d.ts +15 -3
- package/Collapse/Collapse.js +44 -31
- package/Collapse/Collapse.mjs +43 -30
- package/Dialog/Dialog.d.mts +2 -2
- package/Dialog/Dialog.d.ts +2 -2
- package/Dialog/Dialog.js +13 -6
- package/Dialog/Dialog.mjs +13 -6
- package/Drawer/Drawer.d.mts +2 -2
- package/Drawer/Drawer.d.ts +2 -2
- package/Drawer/Drawer.js +18 -4
- package/Drawer/Drawer.mjs +18 -4
- package/Fab/Fab.js +9 -2
- package/Fab/Fab.mjs +9 -2
- package/Fade/Fade.d.mts +15 -2
- package/Fade/Fade.d.ts +15 -2
- package/Fade/Fade.js +46 -19
- package/Fade/Fade.mjs +45 -18
- package/FilledInput/FilledInput.d.mts +4 -0
- package/FilledInput/FilledInput.d.ts +4 -0
- package/FilledInput/FilledInput.js +22 -23
- package/FilledInput/FilledInput.mjs +22 -23
- package/FormControl/useFormControl.d.mts +12 -2
- package/FormControl/useFormControl.d.ts +12 -2
- package/FormControl/useFormControl.js +13 -0
- package/FormControl/useFormControl.mjs +12 -0
- package/FormControlLabel/FormControlLabel.js +5 -8
- package/FormControlLabel/FormControlLabel.mjs +5 -8
- package/FormGroup/FormGroup.js +2 -5
- package/FormGroup/FormGroup.mjs +2 -5
- package/FormHelperText/FormHelperText.js +2 -5
- package/FormHelperText/FormHelperText.mjs +2 -5
- package/FormLabel/FormLabel.js +2 -5
- package/FormLabel/FormLabel.mjs +2 -5
- package/Grow/Grow.d.mts +15 -2
- package/Grow/Grow.d.ts +15 -2
- package/Grow/Grow.js +45 -28
- package/Grow/Grow.mjs +44 -27
- package/IconButton/IconButton.js +3 -9
- package/IconButton/IconButton.mjs +3 -9
- package/Input/Input.d.mts +4 -0
- package/Input/Input.d.ts +4 -0
- package/Input/Input.js +9 -2
- package/Input/Input.mjs +9 -2
- package/InputBase/InputBase.d.mts +2 -1
- package/InputBase/InputBase.d.ts +2 -1
- package/InputBase/InputBase.js +52 -16
- package/InputBase/InputBase.mjs +52 -16
- package/InputLabel/InputLabel.js +7 -9
- package/InputLabel/InputLabel.mjs +7 -9
- package/LICENSE +1 -1
- package/LinearProgress/LinearProgress.d.mts +12 -2
- package/LinearProgress/LinearProgress.d.ts +12 -2
- package/LinearProgress/LinearProgress.js +225 -126
- package/LinearProgress/LinearProgress.mjs +224 -126
- package/List/List.js +2 -1
- package/List/List.mjs +2 -1
- package/ListItem/ListItem.js +2 -1
- package/ListItem/ListItem.mjs +2 -1
- package/ListItemButton/ListItemButton.js +9 -2
- package/ListItemButton/ListItemButton.mjs +9 -2
- package/Menu/Menu.d.mts +1 -1
- package/Menu/Menu.d.ts +1 -1
- package/MenuItem/MenuItem.js +7 -1
- package/MenuItem/MenuItem.mjs +7 -1
- package/MenuList/MenuList.js +2 -1
- package/MenuList/MenuList.mjs +2 -1
- package/MobileStepper/MobileStepper.js +2 -1
- package/MobileStepper/MobileStepper.mjs +2 -1
- package/NativeSelect/NativeSelect.js +2 -5
- package/NativeSelect/NativeSelect.mjs +2 -5
- package/OutlinedInput/NotchedOutline.js +4 -3
- package/OutlinedInput/NotchedOutline.mjs +4 -3
- package/OutlinedInput/OutlinedInput.js +13 -23
- package/OutlinedInput/OutlinedInput.mjs +13 -23
- package/PaginationItem/PaginationItem.js +2 -1
- package/PaginationItem/PaginationItem.mjs +2 -1
- package/Paper/Paper.js +2 -1
- package/Paper/Paper.mjs +2 -1
- package/PigmentContainer/PigmentContainer.js +0 -1
- package/PigmentContainer/PigmentContainer.mjs +0 -1
- package/Popover/Popover.d.mts +1 -1
- package/Popover/Popover.d.ts +1 -1
- package/Popper/BasePopper.js +23 -1
- package/Popper/BasePopper.mjs +23 -1
- package/README.md +3 -2
- package/Radio/RadioButtonIcon.js +3 -2
- package/Radio/RadioButtonIcon.mjs +3 -2
- package/Rating/Rating.js +2 -1
- package/Rating/Rating.mjs +2 -1
- package/Select/Select.js +2 -5
- package/Select/Select.mjs +2 -5
- package/Select/SelectInput.js +276 -24
- package/Select/SelectInput.mjs +276 -24
- package/Select/utils/closedTypeahead.js +73 -0
- package/Select/utils/closedTypeahead.mjs +63 -0
- package/Skeleton/Skeleton.js +22 -2
- package/Skeleton/Skeleton.mjs +22 -2
- package/Slide/Slide.d.mts +15 -2
- package/Slide/Slide.d.ts +15 -2
- package/Slide/Slide.js +97 -47
- package/Slide/Slide.mjs +97 -47
- package/Slider/Slider.js +14 -4
- package/Slider/Slider.mjs +14 -4
- package/Slider/useSlider.js +4 -3
- package/Slider/useSlider.mjs +4 -3
- package/Snackbar/Snackbar.d.mts +2 -2
- package/Snackbar/Snackbar.d.ts +2 -2
- package/SpeedDial/SpeedDial.d.mts +1 -1
- package/SpeedDial/SpeedDial.d.ts +1 -1
- package/SpeedDial/SpeedDial.js +6 -2
- package/SpeedDial/SpeedDial.mjs +6 -2
- package/SpeedDialAction/SpeedDialAction.js +11 -2
- package/SpeedDialAction/SpeedDialAction.mjs +12 -3
- package/SpeedDialIcon/SpeedDialIcon.js +40 -37
- package/SpeedDialIcon/SpeedDialIcon.mjs +40 -37
- package/Step/Step.js +47 -15
- package/Step/Step.mjs +47 -15
- package/StepButton/StepButton.js +9 -3
- package/StepButton/StepButton.mjs +9 -3
- package/StepConnector/StepConnector.js +10 -0
- package/StepConnector/StepConnector.mjs +10 -0
- package/StepContent/StepContent.d.mts +2 -2
- package/StepContent/StepContent.d.ts +2 -2
- package/StepContent/StepContent.js +26 -2
- package/StepContent/StepContent.mjs +26 -2
- package/StepIcon/StepIcon.js +2 -1
- package/StepIcon/StepIcon.mjs +2 -1
- package/StepLabel/StepLabel.js +52 -7
- package/StepLabel/StepLabel.mjs +52 -7
- package/Stepper/Stepper.d.mts +2 -0
- package/Stepper/Stepper.d.ts +2 -0
- package/Stepper/Stepper.js +18 -0
- package/Stepper/Stepper.mjs +18 -0
- package/SvgIcon/SvgIcon.js +2 -1
- package/SvgIcon/SvgIcon.mjs +2 -1
- package/SwipeableDrawer/SwipeableDrawer.js +21 -6
- package/SwipeableDrawer/SwipeableDrawer.mjs +21 -6
- package/Switch/Switch.js +10 -8
- package/Switch/Switch.mjs +10 -8
- package/TableSortLabel/TableSortLabel.js +2 -1
- package/TableSortLabel/TableSortLabel.mjs +2 -1
- package/Tabs/ScrollbarSize.js +2 -1
- package/Tabs/ScrollbarSize.mjs +2 -1
- package/Tabs/Tabs.js +16 -4
- package/Tabs/Tabs.mjs +16 -4
- package/Tooltip/Tooltip.d.mts +2 -2
- package/Tooltip/Tooltip.d.ts +2 -2
- package/Tooltip/Tooltip.js +29 -108
- package/Tooltip/Tooltip.mjs +29 -108
- package/Unstable_TrapFocus/FocusTrap.js +60 -22
- package/Unstable_TrapFocus/FocusTrap.mjs +60 -22
- package/Zoom/Zoom.d.mts +15 -2
- package/Zoom/Zoom.d.ts +15 -2
- package/Zoom/Zoom.js +43 -16
- package/Zoom/Zoom.mjs +42 -15
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/internal/Transition.d.mts +34 -0
- package/internal/Transition.d.ts +34 -0
- package/internal/Transition.js +444 -0
- package/internal/Transition.mjs +436 -0
- package/internal/react-transition-group.d.mts +8 -0
- package/internal/react-transition-group.d.ts +8 -0
- package/package.json +50 -50
- package/styles/createMotion.d.mts +8 -0
- package/styles/createMotion.d.ts +8 -0
- package/styles/createMotion.js +13 -0
- package/styles/createMotion.mjs +7 -0
- package/styles/createThemeFoundation.d.mts +2 -0
- package/styles/createThemeFoundation.d.ts +2 -0
- package/styles/createThemeNoVars.d.mts +3 -0
- package/styles/createThemeNoVars.d.ts +3 -0
- package/styles/createThemeNoVars.js +5 -0
- package/styles/createThemeNoVars.mjs +5 -0
- package/styles/createTransitions.d.mts +6 -2
- package/styles/createTransitions.d.ts +6 -2
- package/styles/createTransitions.js +12 -4
- package/styles/createTransitions.mjs +12 -4
- package/styles/enhanceHighContrast.d.mts +70 -0
- package/styles/enhanceHighContrast.d.ts +70 -0
- package/styles/enhanceHighContrast.js +502 -0
- package/styles/enhanceHighContrast.mjs +495 -0
- package/styles/index.d.mts +2 -0
- package/styles/index.d.ts +2 -0
- package/styles/index.js +8 -0
- package/styles/index.mjs +1 -0
- package/styles/reducedMotion.d.mts +7 -0
- package/styles/reducedMotion.d.ts +7 -0
- package/styles/reducedMotion.js +21 -0
- package/styles/reducedMotion.mjs +14 -0
- package/styles/responsiveFontSizes.js +19 -8
- package/styles/responsiveFontSizes.mjs +19 -8
- package/styles/shouldSkipGeneratingVar.js +1 -1
- package/styles/shouldSkipGeneratingVar.mjs +1 -1
- package/styles/stringifyTheme.js +1 -0
- package/styles/stringifyTheme.mjs +1 -0
- package/styles/useThemeProps.d.mts +3 -3
- package/styles/useThemeProps.d.ts +3 -3
- package/transitions/index.d.mts +1 -1
- package/transitions/index.d.ts +1 -1
- package/transitions/index.js +0 -11
- package/transitions/index.mjs +1 -1
- package/transitions/transition.d.mts +1 -12
- package/transitions/transition.d.ts +1 -12
- package/transitions/types.d.mts +73 -0
- package/transitions/types.d.ts +73 -0
- package/transitions/useReducedMotion.d.mts +14 -0
- package/transitions/useReducedMotion.d.ts +14 -0
- package/transitions/useReducedMotion.js +117 -0
- package/transitions/useReducedMotion.mjs +110 -0
- package/transitions/utils.d.mts +51 -2
- package/transitions/utils.d.ts +51 -2
- package/transitions/utils.js +97 -4
- package/transitions/utils.mjs +94 -4
- package/useAutocomplete/useAutocomplete.d.mts +12 -6
- package/useAutocomplete/useAutocomplete.d.ts +12 -6
- package/useAutocomplete/useAutocomplete.js +230 -55
- package/useAutocomplete/useAutocomplete.mjs +230 -55
- package/utils/contains.d.mts +2 -0
- package/utils/contains.d.ts +2 -0
- package/utils/contains.js +9 -0
- package/utils/contains.mjs +2 -0
- package/utils/focusable.d.mts +7 -0
- package/utils/focusable.d.ts +7 -0
- package/utils/focusable.js +20 -0
- package/utils/focusable.mjs +13 -0
- package/utils/getEventTarget.d.mts +2 -0
- package/utils/getEventTarget.d.ts +2 -0
- package/utils/getEventTarget.js +9 -0
- package/utils/getEventTarget.mjs +2 -0
- package/utils/mergeSlotProps.js +2 -8
- package/utils/mergeSlotProps.mjs +1 -8
- package/version/index.js +2 -2
- package/version/index.mjs +2 -2
- package/FormControl/formControlState.js +0 -21
- package/FormControl/formControlState.mjs +0 -15
- /package/transitions/{transition.js → types.js} +0 -0
- /package/transitions/{transition.mjs → types.mjs} +0 -0
package/transitions/utils.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { defaultStyles } from "../styles/reducedMotion.js";
|
|
3
|
+
import type { ReducedMotionMode } from "../styles/createMotion.js";
|
|
2
4
|
export declare const reflow: (node: Element) => number;
|
|
3
5
|
interface ComponentProps {
|
|
4
6
|
easing: string | {
|
|
@@ -19,12 +21,59 @@ interface TransitionProps {
|
|
|
19
21
|
easing: string | undefined;
|
|
20
22
|
delay: string | undefined;
|
|
21
23
|
}
|
|
24
|
+
interface TransitionCreateOptions {
|
|
25
|
+
duration: number | string;
|
|
26
|
+
easing: string;
|
|
27
|
+
delay: number | string;
|
|
28
|
+
}
|
|
29
|
+
interface TranslateOffset {
|
|
30
|
+
offsetX: number;
|
|
31
|
+
offsetY: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Extracts the x/y translation from a CSS transform string.
|
|
35
|
+
*
|
|
36
|
+
* Transition components use these offsets when calculating off-screen positions:
|
|
37
|
+
* if an element is already translated, the distance needed to hide it must start
|
|
38
|
+
* from that visual position instead of its untransformed layout position.
|
|
39
|
+
*
|
|
40
|
+
* CSSOM commonly serializes translations as matrix() or matrix3d(), while inline
|
|
41
|
+
* gesture styles may use translate(), translate3d(), translateX(), or
|
|
42
|
+
* translateY(). This helper normalizes those supported forms into numeric pixel
|
|
43
|
+
* offsets and returns zero offsets for empty, none, or unsupported transforms.
|
|
44
|
+
*/
|
|
45
|
+
export declare function getTranslateOffsets(transform: string | undefined): TranslateOffset;
|
|
22
46
|
export declare function normalizedTransitionCallback(nodeRef: React.RefObject<HTMLElement | null>, callback: ((node: HTMLElement, isAppearing?: boolean) => void) | undefined): (maybeIsAppearing?: boolean) => void;
|
|
23
47
|
type TransitionState = 'entering' | 'entered' | 'exiting' | 'exited';
|
|
24
48
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
49
|
+
* Return the child style for a transition. Reuse predefined style objects when
|
|
50
|
+
* no custom styles are present so memoized children see the same object.
|
|
27
51
|
*/
|
|
28
52
|
export declare function getTransitionChildStyle(state: TransitionState, inProp: boolean | undefined, baseStyles: Record<string, React.CSSProperties>, hiddenStyles: React.CSSProperties, styleProp: React.CSSProperties | undefined, childStyle: React.CSSProperties | undefined): React.CSSProperties | undefined;
|
|
29
53
|
export declare function getTransitionProps(props: ComponentProps, options: Options): TransitionProps;
|
|
54
|
+
/**
|
|
55
|
+
* Returns CSS that disables component-owned transitions when reduced motion is active.
|
|
56
|
+
* Pass custom styles only when the default `transition: none` reset is not enough.
|
|
57
|
+
*/
|
|
58
|
+
export declare function getReducedMotionStyles<Styles extends object = typeof defaultStyles>(theme: {
|
|
59
|
+
motion?: {
|
|
60
|
+
reducedMotion?: ReducedMotionMode | undefined;
|
|
61
|
+
} | undefined;
|
|
62
|
+
}, styles?: Styles): Styles | {
|
|
63
|
+
'@media (prefers-reduced-motion: reduce)': Styles;
|
|
64
|
+
} | null;
|
|
65
|
+
export declare function getTransitionStyles(theme: {
|
|
66
|
+
transitions?: {
|
|
67
|
+
create: (props?: string | string[], options?: Partial<TransitionCreateOptions>) => string;
|
|
68
|
+
} | undefined;
|
|
69
|
+
motion?: {
|
|
70
|
+
reducedMotion?: ReducedMotionMode | undefined;
|
|
71
|
+
} | undefined;
|
|
72
|
+
}, props?: string | string[], options?: Partial<TransitionCreateOptions>): React.CSSProperties | {
|
|
73
|
+
transition: string;
|
|
74
|
+
} | {
|
|
75
|
+
'@media (prefers-reduced-motion: reduce)': {
|
|
76
|
+
transition: string;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
30
79
|
export {};
|
package/transitions/utils.js
CHANGED
|
@@ -3,17 +3,87 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.getReducedMotionStyles = getReducedMotionStyles;
|
|
6
7
|
exports.getTransitionChildStyle = getTransitionChildStyle;
|
|
7
8
|
exports.getTransitionProps = getTransitionProps;
|
|
9
|
+
exports.getTransitionStyles = getTransitionStyles;
|
|
10
|
+
exports.getTranslateOffsets = getTranslateOffsets;
|
|
8
11
|
exports.normalizedTransitionCallback = normalizedTransitionCallback;
|
|
9
12
|
exports.reflow = void 0;
|
|
13
|
+
var _reducedMotion = require("../styles/reducedMotion");
|
|
10
14
|
const reflow = node => node.scrollTop;
|
|
11
15
|
exports.reflow = reflow;
|
|
16
|
+
const DEFAULT_TRANSLATE_OFFSET = {
|
|
17
|
+
offsetX: 0,
|
|
18
|
+
offsetY: 0
|
|
19
|
+
};
|
|
20
|
+
const EMPTY_STYLE = {};
|
|
21
|
+
const DEFAULT_TRANSITION_PROPS = ['all'];
|
|
22
|
+
const EMPTY_OPTIONS = {};
|
|
23
|
+
const transformOffsetIndexes = {
|
|
24
|
+
matrix: [4, 5],
|
|
25
|
+
matrix3d: [12, 13],
|
|
26
|
+
translate: [0, 1],
|
|
27
|
+
translate3d: [0, 1],
|
|
28
|
+
translateX: [0, null],
|
|
29
|
+
translateY: [null, 0]
|
|
30
|
+
};
|
|
31
|
+
function parseTranslateValue(value) {
|
|
32
|
+
const parsedValue = parseFloat(value ?? '');
|
|
33
|
+
return Number.isNaN(parsedValue) ? 0 : parsedValue;
|
|
34
|
+
}
|
|
35
|
+
function parseTransform(transform) {
|
|
36
|
+
const match = transform.match(/^(matrix|matrix3d|translate|translate3d|translateX|translateY)\((.+)\)$/);
|
|
37
|
+
if (!match) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
type: match[1],
|
|
42
|
+
values: match[2].split(',').map(parseTranslateValue)
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function getTranslateOffsetValue(values, index) {
|
|
46
|
+
return index === null ? 0 : values[index] || 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Extracts the x/y translation from a CSS transform string.
|
|
51
|
+
*
|
|
52
|
+
* Transition components use these offsets when calculating off-screen positions:
|
|
53
|
+
* if an element is already translated, the distance needed to hide it must start
|
|
54
|
+
* from that visual position instead of its untransformed layout position.
|
|
55
|
+
*
|
|
56
|
+
* CSSOM commonly serializes translations as matrix() or matrix3d(), while inline
|
|
57
|
+
* gesture styles may use translate(), translate3d(), translateX(), or
|
|
58
|
+
* translateY(). This helper normalizes those supported forms into numeric pixel
|
|
59
|
+
* offsets and returns zero offsets for empty, none, or unsupported transforms.
|
|
60
|
+
*/
|
|
61
|
+
function getTranslateOffsets(transform) {
|
|
62
|
+
if (!transform || transform === 'none') {
|
|
63
|
+
return DEFAULT_TRANSLATE_OFFSET;
|
|
64
|
+
}
|
|
65
|
+
const parsedTransform = parseTransform(transform);
|
|
66
|
+
if (!parsedTransform) {
|
|
67
|
+
return DEFAULT_TRANSLATE_OFFSET;
|
|
68
|
+
}
|
|
69
|
+
const {
|
|
70
|
+
type,
|
|
71
|
+
values
|
|
72
|
+
} = parsedTransform;
|
|
73
|
+
const offsetIndexes = transformOffsetIndexes[type];
|
|
74
|
+
if (!offsetIndexes) {
|
|
75
|
+
return DEFAULT_TRANSLATE_OFFSET;
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
offsetX: getTranslateOffsetValue(values, offsetIndexes[0]),
|
|
79
|
+
offsetY: getTranslateOffsetValue(values, offsetIndexes[1])
|
|
80
|
+
};
|
|
81
|
+
}
|
|
12
82
|
function normalizedTransitionCallback(nodeRef, callback) {
|
|
13
83
|
return maybeIsAppearing => {
|
|
14
84
|
if (callback) {
|
|
15
85
|
const node = nodeRef.current;
|
|
16
|
-
//
|
|
86
|
+
// Enter callbacks receive isAppearing; exit callbacks do not.
|
|
17
87
|
if (maybeIsAppearing === undefined) {
|
|
18
88
|
callback(node);
|
|
19
89
|
} else {
|
|
@@ -23,8 +93,8 @@ function normalizedTransitionCallback(nodeRef, callback) {
|
|
|
23
93
|
};
|
|
24
94
|
}
|
|
25
95
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
96
|
+
* Return the child style for a transition. Reuse predefined style objects when
|
|
97
|
+
* no custom styles are present so memoized children see the same object.
|
|
28
98
|
*/
|
|
29
99
|
function getTransitionChildStyle(state, inProp, baseStyles, hiddenStyles, styleProp, childStyle) {
|
|
30
100
|
const base = state === 'exited' && !inProp ? hiddenStyles : baseStyles[state] || baseStyles.exited;
|
|
@@ -38,11 +108,34 @@ function getTransitionProps(props, options) {
|
|
|
38
108
|
const {
|
|
39
109
|
timeout,
|
|
40
110
|
easing,
|
|
41
|
-
style =
|
|
111
|
+
style = EMPTY_STYLE
|
|
42
112
|
} = props;
|
|
43
113
|
return {
|
|
44
114
|
duration: style.transitionDuration ?? (typeof timeout === 'number' ? timeout : timeout[options.mode] || 0),
|
|
45
115
|
easing: style.transitionTimingFunction ?? (typeof easing === 'object' ? easing[options.mode] : easing),
|
|
46
116
|
delay: style.transitionDelay
|
|
47
117
|
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Returns CSS that disables component-owned transitions when reduced motion is active.
|
|
122
|
+
* Pass custom styles only when the default `transition: none` reset is not enough.
|
|
123
|
+
*/
|
|
124
|
+
function getReducedMotionStyles(theme, styles) {
|
|
125
|
+
const resolvedStyles = styles ?? _reducedMotion.defaultStyles;
|
|
126
|
+
return (0, _reducedMotion.resolveReducedMotionStyles)(theme.motion?.reducedMotion, resolvedStyles);
|
|
127
|
+
}
|
|
128
|
+
function getTransitionStyles(theme, props = DEFAULT_TRANSITION_PROPS, options = EMPTY_OPTIONS) {
|
|
129
|
+
const transition = theme.transitions?.create?.(props, options);
|
|
130
|
+
const reducedMotionStyles = getReducedMotionStyles(theme);
|
|
131
|
+
if (transition === undefined) {
|
|
132
|
+
return reducedMotionStyles ?? EMPTY_STYLE;
|
|
133
|
+
}
|
|
134
|
+
const transitionStyles = {
|
|
135
|
+
transition
|
|
136
|
+
};
|
|
137
|
+
return reducedMotionStyles ? {
|
|
138
|
+
...transitionStyles,
|
|
139
|
+
...reducedMotionStyles
|
|
140
|
+
} : transitionStyles;
|
|
48
141
|
}
|
package/transitions/utils.mjs
CHANGED
|
@@ -1,9 +1,76 @@
|
|
|
1
|
+
import { defaultStyles, resolveReducedMotionStyles } from "../styles/reducedMotion.mjs";
|
|
1
2
|
export const reflow = node => node.scrollTop;
|
|
3
|
+
const DEFAULT_TRANSLATE_OFFSET = {
|
|
4
|
+
offsetX: 0,
|
|
5
|
+
offsetY: 0
|
|
6
|
+
};
|
|
7
|
+
const EMPTY_STYLE = {};
|
|
8
|
+
const DEFAULT_TRANSITION_PROPS = ['all'];
|
|
9
|
+
const EMPTY_OPTIONS = {};
|
|
10
|
+
const transformOffsetIndexes = {
|
|
11
|
+
matrix: [4, 5],
|
|
12
|
+
matrix3d: [12, 13],
|
|
13
|
+
translate: [0, 1],
|
|
14
|
+
translate3d: [0, 1],
|
|
15
|
+
translateX: [0, null],
|
|
16
|
+
translateY: [null, 0]
|
|
17
|
+
};
|
|
18
|
+
function parseTranslateValue(value) {
|
|
19
|
+
const parsedValue = parseFloat(value ?? '');
|
|
20
|
+
return Number.isNaN(parsedValue) ? 0 : parsedValue;
|
|
21
|
+
}
|
|
22
|
+
function parseTransform(transform) {
|
|
23
|
+
const match = transform.match(/^(matrix|matrix3d|translate|translate3d|translateX|translateY)\((.+)\)$/);
|
|
24
|
+
if (!match) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
type: match[1],
|
|
29
|
+
values: match[2].split(',').map(parseTranslateValue)
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function getTranslateOffsetValue(values, index) {
|
|
33
|
+
return index === null ? 0 : values[index] || 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Extracts the x/y translation from a CSS transform string.
|
|
38
|
+
*
|
|
39
|
+
* Transition components use these offsets when calculating off-screen positions:
|
|
40
|
+
* if an element is already translated, the distance needed to hide it must start
|
|
41
|
+
* from that visual position instead of its untransformed layout position.
|
|
42
|
+
*
|
|
43
|
+
* CSSOM commonly serializes translations as matrix() or matrix3d(), while inline
|
|
44
|
+
* gesture styles may use translate(), translate3d(), translateX(), or
|
|
45
|
+
* translateY(). This helper normalizes those supported forms into numeric pixel
|
|
46
|
+
* offsets and returns zero offsets for empty, none, or unsupported transforms.
|
|
47
|
+
*/
|
|
48
|
+
export function getTranslateOffsets(transform) {
|
|
49
|
+
if (!transform || transform === 'none') {
|
|
50
|
+
return DEFAULT_TRANSLATE_OFFSET;
|
|
51
|
+
}
|
|
52
|
+
const parsedTransform = parseTransform(transform);
|
|
53
|
+
if (!parsedTransform) {
|
|
54
|
+
return DEFAULT_TRANSLATE_OFFSET;
|
|
55
|
+
}
|
|
56
|
+
const {
|
|
57
|
+
type,
|
|
58
|
+
values
|
|
59
|
+
} = parsedTransform;
|
|
60
|
+
const offsetIndexes = transformOffsetIndexes[type];
|
|
61
|
+
if (!offsetIndexes) {
|
|
62
|
+
return DEFAULT_TRANSLATE_OFFSET;
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
offsetX: getTranslateOffsetValue(values, offsetIndexes[0]),
|
|
66
|
+
offsetY: getTranslateOffsetValue(values, offsetIndexes[1])
|
|
67
|
+
};
|
|
68
|
+
}
|
|
2
69
|
export function normalizedTransitionCallback(nodeRef, callback) {
|
|
3
70
|
return maybeIsAppearing => {
|
|
4
71
|
if (callback) {
|
|
5
72
|
const node = nodeRef.current;
|
|
6
|
-
//
|
|
73
|
+
// Enter callbacks receive isAppearing; exit callbacks do not.
|
|
7
74
|
if (maybeIsAppearing === undefined) {
|
|
8
75
|
callback(node);
|
|
9
76
|
} else {
|
|
@@ -13,8 +80,8 @@ export function normalizedTransitionCallback(nodeRef, callback) {
|
|
|
13
80
|
};
|
|
14
81
|
}
|
|
15
82
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
83
|
+
* Return the child style for a transition. Reuse predefined style objects when
|
|
84
|
+
* no custom styles are present so memoized children see the same object.
|
|
18
85
|
*/
|
|
19
86
|
export function getTransitionChildStyle(state, inProp, baseStyles, hiddenStyles, styleProp, childStyle) {
|
|
20
87
|
const base = state === 'exited' && !inProp ? hiddenStyles : baseStyles[state] || baseStyles.exited;
|
|
@@ -28,11 +95,34 @@ export function getTransitionProps(props, options) {
|
|
|
28
95
|
const {
|
|
29
96
|
timeout,
|
|
30
97
|
easing,
|
|
31
|
-
style =
|
|
98
|
+
style = EMPTY_STYLE
|
|
32
99
|
} = props;
|
|
33
100
|
return {
|
|
34
101
|
duration: style.transitionDuration ?? (typeof timeout === 'number' ? timeout : timeout[options.mode] || 0),
|
|
35
102
|
easing: style.transitionTimingFunction ?? (typeof easing === 'object' ? easing[options.mode] : easing),
|
|
36
103
|
delay: style.transitionDelay
|
|
37
104
|
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Returns CSS that disables component-owned transitions when reduced motion is active.
|
|
109
|
+
* Pass custom styles only when the default `transition: none` reset is not enough.
|
|
110
|
+
*/
|
|
111
|
+
export function getReducedMotionStyles(theme, styles) {
|
|
112
|
+
const resolvedStyles = styles ?? defaultStyles;
|
|
113
|
+
return resolveReducedMotionStyles(theme.motion?.reducedMotion, resolvedStyles);
|
|
114
|
+
}
|
|
115
|
+
export function getTransitionStyles(theme, props = DEFAULT_TRANSITION_PROPS, options = EMPTY_OPTIONS) {
|
|
116
|
+
const transition = theme.transitions?.create?.(props, options);
|
|
117
|
+
const reducedMotionStyles = getReducedMotionStyles(theme);
|
|
118
|
+
if (transition === undefined) {
|
|
119
|
+
return reducedMotionStyles ?? EMPTY_STYLE;
|
|
120
|
+
}
|
|
121
|
+
const transitionStyles = {
|
|
122
|
+
transition
|
|
123
|
+
};
|
|
124
|
+
return reducedMotionStyles ? {
|
|
125
|
+
...transitionStyles,
|
|
126
|
+
...reducedMotionStyles
|
|
127
|
+
} : transitionStyles;
|
|
38
128
|
}
|
|
@@ -47,12 +47,11 @@ export interface UseAutocompleteProps<Value, Multiple extends boolean | undefine
|
|
|
47
47
|
*/
|
|
48
48
|
autoHighlight?: boolean | undefined;
|
|
49
49
|
/**
|
|
50
|
-
* If `true`, the
|
|
51
|
-
* when the Autocomplete loses focus unless the user chooses
|
|
52
|
-
* a different option or changes the character string in the input.
|
|
50
|
+
* If `true`, the value is updated when the input loses focus under one of these conditions:
|
|
53
51
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
52
|
+
* - An option highlighted via keyboard navigation or `autoHighlight` is selected.
|
|
53
|
+
* Hover and touch highlights are ignored.
|
|
54
|
+
* - Otherwise, in `freeSolo` mode, the typed text becomes the value.
|
|
56
55
|
* @default false
|
|
57
56
|
*/
|
|
58
57
|
autoSelect?: boolean | undefined;
|
|
@@ -261,6 +260,12 @@ export interface UseAutocompleteProps<Value, Multiple extends boolean | undefine
|
|
|
261
260
|
* @default false
|
|
262
261
|
*/
|
|
263
262
|
readOnly?: boolean | undefined;
|
|
263
|
+
/**
|
|
264
|
+
* If `true`, clears an option highlighted by mouse movement when the mouse leaves the listbox.
|
|
265
|
+
* This behavior will be enabled by default in the next major version.
|
|
266
|
+
* @default false
|
|
267
|
+
*/
|
|
268
|
+
resetHighlightOnMouseLeave?: boolean | undefined;
|
|
264
269
|
/**
|
|
265
270
|
* If `true`, the input's text is selected on focus.
|
|
266
271
|
* It helps the user clear the selected value.
|
|
@@ -348,9 +353,10 @@ export interface UseAutocompleteReturnValue<Value, Multiple extends boolean | un
|
|
|
348
353
|
getPopupIndicatorProps: () => React.HTMLAttributes<HTMLButtonElement>;
|
|
349
354
|
/**
|
|
350
355
|
* Resolver for the listbox component's props.
|
|
356
|
+
* @param externalProps props for the listbox component
|
|
351
357
|
* @returns props that should be spread on the listbox component
|
|
352
358
|
*/
|
|
353
|
-
getListboxProps: () => React.HTMLAttributes<HTMLUListElement>;
|
|
359
|
+
getListboxProps: (externalProps?: any) => React.HTMLAttributes<HTMLUListElement>;
|
|
354
360
|
/**
|
|
355
361
|
* Resolver for the rendered option element's props.
|
|
356
362
|
* @param renderedOption option rendered on the Autocomplete
|
|
@@ -47,12 +47,11 @@ export interface UseAutocompleteProps<Value, Multiple extends boolean | undefine
|
|
|
47
47
|
*/
|
|
48
48
|
autoHighlight?: boolean | undefined;
|
|
49
49
|
/**
|
|
50
|
-
* If `true`, the
|
|
51
|
-
* when the Autocomplete loses focus unless the user chooses
|
|
52
|
-
* a different option or changes the character string in the input.
|
|
50
|
+
* If `true`, the value is updated when the input loses focus under one of these conditions:
|
|
53
51
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
52
|
+
* - An option highlighted via keyboard navigation or `autoHighlight` is selected.
|
|
53
|
+
* Hover and touch highlights are ignored.
|
|
54
|
+
* - Otherwise, in `freeSolo` mode, the typed text becomes the value.
|
|
56
55
|
* @default false
|
|
57
56
|
*/
|
|
58
57
|
autoSelect?: boolean | undefined;
|
|
@@ -261,6 +260,12 @@ export interface UseAutocompleteProps<Value, Multiple extends boolean | undefine
|
|
|
261
260
|
* @default false
|
|
262
261
|
*/
|
|
263
262
|
readOnly?: boolean | undefined;
|
|
263
|
+
/**
|
|
264
|
+
* If `true`, clears an option highlighted by mouse movement when the mouse leaves the listbox.
|
|
265
|
+
* This behavior will be enabled by default in the next major version.
|
|
266
|
+
* @default false
|
|
267
|
+
*/
|
|
268
|
+
resetHighlightOnMouseLeave?: boolean | undefined;
|
|
264
269
|
/**
|
|
265
270
|
* If `true`, the input's text is selected on focus.
|
|
266
271
|
* It helps the user clear the selected value.
|
|
@@ -348,9 +353,10 @@ export interface UseAutocompleteReturnValue<Value, Multiple extends boolean | un
|
|
|
348
353
|
getPopupIndicatorProps: () => React.HTMLAttributes<HTMLButtonElement>;
|
|
349
354
|
/**
|
|
350
355
|
* Resolver for the listbox component's props.
|
|
356
|
+
* @param externalProps props for the listbox component
|
|
351
357
|
* @returns props that should be spread on the listbox component
|
|
352
358
|
*/
|
|
353
|
-
getListboxProps: () => React.HTMLAttributes<HTMLUListElement>;
|
|
359
|
+
getListboxProps: (externalProps?: any) => React.HTMLAttributes<HTMLUListElement>;
|
|
354
360
|
/**
|
|
355
361
|
* Resolver for the rendered option element's props.
|
|
356
362
|
* @param renderedOption option rendered on the Autocomplete
|