@mui/material 9.0.0-beta.1 → 9.0.1
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 +3 -3
- package/Accordion/Accordion.d.ts +3 -3
- package/AccordionActions/AccordionActions.d.mts +2 -2
- package/AccordionActions/AccordionActions.d.ts +2 -2
- package/AccordionDetails/AccordionDetails.d.mts +2 -2
- package/AccordionDetails/AccordionDetails.d.ts +2 -2
- package/AccordionSummary/AccordionSummary.d.mts +3 -3
- package/AccordionSummary/AccordionSummary.d.ts +3 -3
- package/Alert/Alert.d.mts +3 -3
- package/Alert/Alert.d.ts +3 -3
- package/AlertTitle/AlertTitle.d.mts +3 -3
- package/AlertTitle/AlertTitle.d.ts +3 -3
- package/AppBar/AppBar.d.mts +3 -3
- package/AppBar/AppBar.d.ts +3 -3
- package/Autocomplete/Autocomplete.d.mts +2 -2
- package/Autocomplete/Autocomplete.d.ts +2 -2
- package/Autocomplete/Autocomplete.js +65 -11
- package/Autocomplete/Autocomplete.mjs +65 -11
- package/Avatar/Avatar.d.mts +2 -2
- package/Avatar/Avatar.d.ts +2 -2
- package/Avatar/Avatar.js +4 -0
- package/Avatar/Avatar.mjs +4 -0
- package/AvatarGroup/AvatarGroup.d.mts +2 -2
- package/AvatarGroup/AvatarGroup.d.ts +2 -2
- package/Backdrop/Backdrop.d.mts +3 -3
- package/Backdrop/Backdrop.d.ts +3 -3
- package/Badge/Badge.d.mts +3 -3
- package/Badge/Badge.d.ts +3 -3
- package/Badge/Badge.js +3 -0
- package/Badge/Badge.mjs +3 -0
- package/BottomNavigation/BottomNavigation.d.mts +2 -2
- package/BottomNavigation/BottomNavigation.d.ts +2 -2
- package/BottomNavigationAction/BottomNavigationAction.d.mts +3 -3
- package/BottomNavigationAction/BottomNavigationAction.d.ts +3 -3
- package/Box/Box.d.mts +3 -3
- package/Box/Box.d.ts +3 -3
- package/Breadcrumbs/Breadcrumbs.d.mts +3 -3
- package/Breadcrumbs/Breadcrumbs.d.ts +3 -3
- package/Button/Button.d.mts +6 -6
- package/Button/Button.d.ts +6 -6
- package/Button/Button.js +19 -2
- package/Button/Button.mjs +19 -2
- package/ButtonBase/ButtonBase.d.mts +9 -2
- package/ButtonBase/ButtonBase.d.ts +9 -2
- package/ButtonBase/ButtonBase.js +5 -2
- package/ButtonBase/ButtonBase.mjs +5 -2
- package/ButtonGroup/ButtonGroup.d.mts +2 -2
- package/ButtonGroup/ButtonGroup.d.ts +2 -2
- package/CHANGELOG.md +160 -1245
- package/Card/Card.d.mts +3 -3
- package/Card/Card.d.ts +3 -3
- package/CardActionArea/CardActionArea.d.mts +3 -3
- package/CardActionArea/CardActionArea.d.ts +3 -3
- package/CardActions/CardActions.d.mts +2 -2
- package/CardActions/CardActions.d.ts +2 -2
- package/CardContent/CardContent.d.mts +2 -2
- package/CardContent/CardContent.d.ts +2 -2
- package/CardHeader/CardHeader.d.mts +2 -2
- package/CardHeader/CardHeader.d.ts +2 -2
- package/CardMedia/CardMedia.d.mts +2 -2
- package/CardMedia/CardMedia.d.ts +2 -2
- package/Checkbox/Checkbox.d.mts +4 -4
- package/Checkbox/Checkbox.d.ts +4 -4
- package/Checkbox/Checkbox.js +2 -1
- package/Checkbox/Checkbox.mjs +2 -1
- package/Chip/Chip.d.mts +2 -2
- package/Chip/Chip.d.ts +2 -2
- package/CircularProgress/CircularProgress.d.mts +14 -4
- package/CircularProgress/CircularProgress.d.ts +14 -4
- package/CircularProgress/CircularProgress.js +33 -6
- package/CircularProgress/CircularProgress.mjs +33 -6
- package/ClickAwayListener/ClickAwayListener.d.mts +3 -3
- package/ClickAwayListener/ClickAwayListener.d.ts +3 -3
- package/ClickAwayListener/ClickAwayListener.js +6 -9
- package/ClickAwayListener/ClickAwayListener.mjs +6 -9
- package/Collapse/Collapse.d.mts +5 -5
- package/Collapse/Collapse.d.ts +5 -5
- package/Collapse/Collapse.js +6 -18
- package/Collapse/Collapse.mjs +7 -19
- package/Container/Container.d.mts +2 -2
- package/Container/Container.d.ts +2 -2
- package/CssBaseline/CssBaseline.d.mts +2 -2
- package/CssBaseline/CssBaseline.d.ts +2 -2
- package/Dialog/Dialog.d.mts +3 -3
- package/Dialog/Dialog.d.ts +3 -3
- package/Dialog/Dialog.js +11 -6
- package/Dialog/Dialog.mjs +11 -6
- package/DialogActions/DialogActions.d.mts +2 -2
- package/DialogActions/DialogActions.d.ts +2 -2
- package/DialogContent/DialogContent.d.mts +2 -2
- package/DialogContent/DialogContent.d.ts +2 -2
- package/DialogContentText/DialogContentText.d.mts +3 -3
- package/DialogContentText/DialogContentText.d.ts +3 -3
- package/DialogTitle/DialogTitle.d.mts +3 -3
- package/DialogTitle/DialogTitle.d.ts +3 -3
- package/Divider/Divider.d.mts +4 -4
- package/Divider/Divider.d.ts +4 -4
- package/Drawer/Drawer.d.mts +3 -3
- package/Drawer/Drawer.d.ts +3 -3
- package/Drawer/Drawer.js +19 -8
- package/Drawer/Drawer.mjs +19 -8
- package/Fab/Fab.d.mts +3 -3
- package/Fab/Fab.d.ts +3 -3
- package/Fab/Fab.js +7 -1
- package/Fab/Fab.mjs +7 -1
- package/Fade/Fade.d.mts +3 -3
- package/Fade/Fade.d.ts +3 -3
- package/Fade/Fade.js +28 -32
- package/Fade/Fade.mjs +29 -33
- package/FilledInput/FilledInput.d.mts +7 -3
- package/FilledInput/FilledInput.d.ts +7 -3
- package/FilledInput/FilledInput.js +18 -20
- package/FilledInput/FilledInput.mjs +18 -20
- package/FormControl/FormControl.d.mts +7 -7
- package/FormControl/FormControl.d.ts +7 -7
- 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.d.mts +4 -4
- package/FormControlLabel/FormControlLabel.d.ts +4 -4
- package/FormControlLabel/FormControlLabel.js +5 -8
- package/FormControlLabel/FormControlLabel.mjs +5 -8
- package/FormGroup/FormGroup.d.mts +3 -3
- package/FormGroup/FormGroup.d.ts +3 -3
- package/FormGroup/FormGroup.js +2 -5
- package/FormGroup/FormGroup.mjs +2 -5
- package/FormHelperText/FormHelperText.d.mts +3 -3
- package/FormHelperText/FormHelperText.d.ts +3 -3
- package/FormHelperText/FormHelperText.js +2 -5
- package/FormHelperText/FormHelperText.mjs +2 -5
- package/FormLabel/FormLabel.d.mts +5 -5
- package/FormLabel/FormLabel.d.ts +5 -5
- package/FormLabel/FormLabel.js +2 -5
- package/FormLabel/FormLabel.mjs +2 -5
- package/GlobalStyles/GlobalStyles.d.mts +2 -2
- package/GlobalStyles/GlobalStyles.d.ts +2 -2
- package/Grid/Grid.d.mts +2 -2
- package/Grid/Grid.d.ts +2 -2
- package/Grid/Grid.js +2 -2
- package/Grid/Grid.mjs +2 -2
- package/Grow/Grow.d.mts +5 -5
- package/Grow/Grow.d.ts +5 -5
- package/Grow/Grow.js +30 -38
- package/Grow/Grow.mjs +31 -39
- package/Icon/Icon.d.mts +3 -3
- package/Icon/Icon.d.ts +3 -3
- package/IconButton/IconButton.d.mts +5 -5
- package/IconButton/IconButton.d.ts +5 -5
- package/IconButton/IconButton.js +1 -8
- package/IconButton/IconButton.mjs +1 -8
- package/ImageList/ImageList.d.mts +2 -2
- package/ImageList/ImageList.d.ts +2 -2
- package/ImageListItem/ImageListItem.d.mts +2 -2
- package/ImageListItem/ImageListItem.d.ts +2 -2
- package/ImageListItemBar/ImageListItemBar.d.mts +2 -2
- package/ImageListItemBar/ImageListItemBar.d.ts +2 -2
- package/InitColorSchemeScript/InitColorSchemeScript.d.mts +2 -2
- package/InitColorSchemeScript/InitColorSchemeScript.d.ts +2 -2
- package/InitColorSchemeScript/InitColorSchemeScript.js +2 -2
- package/InitColorSchemeScript/InitColorSchemeScript.mjs +2 -2
- package/Input/Input.d.mts +7 -3
- package/Input/Input.d.ts +7 -3
- package/Input/Input.js +6 -0
- package/Input/Input.mjs +6 -0
- package/InputAdornment/InputAdornment.d.mts +2 -2
- package/InputAdornment/InputAdornment.d.ts +2 -2
- package/InputBase/InputBase.d.mts +4 -3
- package/InputBase/InputBase.d.ts +4 -3
- package/InputBase/InputBase.js +50 -15
- package/InputBase/InputBase.mjs +50 -15
- package/InputLabel/InputLabel.d.mts +4 -4
- package/InputLabel/InputLabel.d.ts +4 -4
- package/InputLabel/InputLabel.js +5 -8
- package/InputLabel/InputLabel.mjs +5 -8
- package/LinearProgress/LinearProgress.d.mts +14 -4
- package/LinearProgress/LinearProgress.d.ts +14 -4
- package/LinearProgress/LinearProgress.js +42 -10
- package/LinearProgress/LinearProgress.mjs +42 -10
- package/Link/Link.d.mts +4 -4
- package/Link/Link.d.ts +4 -4
- package/List/List.d.mts +4 -4
- package/List/List.d.ts +4 -4
- package/List/List.js +2 -1
- package/List/List.mjs +2 -1
- package/ListItem/ListItem.d.mts +3 -3
- package/ListItem/ListItem.d.ts +3 -3
- package/ListItem/ListItem.js +1 -2
- package/ListItem/ListItem.mjs +1 -2
- package/ListItemAvatar/ListItemAvatar.d.mts +2 -2
- package/ListItemAvatar/ListItemAvatar.d.ts +2 -2
- package/ListItemButton/ListItemButton.d.mts +4 -4
- package/ListItemButton/ListItemButton.d.ts +4 -4
- package/ListItemButton/ListItemButton.js +7 -1
- package/ListItemButton/ListItemButton.mjs +7 -1
- package/ListItemIcon/ListItemIcon.d.mts +3 -3
- package/ListItemIcon/ListItemIcon.d.ts +3 -3
- package/ListItemSecondaryAction/ListItemSecondaryAction.d.mts +2 -2
- package/ListItemSecondaryAction/ListItemSecondaryAction.d.ts +2 -2
- package/ListItemText/ListItemText.d.mts +3 -3
- package/ListItemText/ListItemText.d.ts +3 -3
- package/ListSubheader/ListSubheader.d.mts +3 -3
- package/ListSubheader/ListSubheader.d.ts +3 -3
- package/Menu/Menu.d.mts +4 -4
- package/Menu/Menu.d.ts +4 -4
- package/MenuItem/MenuItem.d.mts +3 -3
- package/MenuItem/MenuItem.d.ts +3 -3
- package/MenuItem/MenuItem.js +7 -1
- package/MenuItem/MenuItem.mjs +7 -1
- package/MenuList/MenuList.d.mts +4 -4
- package/MenuList/MenuList.d.ts +4 -4
- package/MenuList/MenuList.js +2 -1
- package/MenuList/MenuList.mjs +2 -1
- package/MobileStepper/MobileStepper.d.mts +3 -3
- package/MobileStepper/MobileStepper.d.ts +3 -3
- package/Modal/Modal.d.mts +7 -7
- package/Modal/Modal.d.ts +7 -7
- package/NativeSelect/NativeSelect.d.mts +3 -3
- package/NativeSelect/NativeSelect.d.ts +3 -3
- package/NativeSelect/NativeSelect.js +2 -5
- package/NativeSelect/NativeSelect.mjs +2 -5
- package/NoSsr/NoSsr.d.mts +2 -2
- package/NoSsr/NoSsr.d.ts +2 -2
- package/NoSsr/NoSsr.js +2 -2
- package/NoSsr/NoSsr.mjs +2 -2
- package/OutlinedInput/OutlinedInput.d.mts +4 -4
- package/OutlinedInput/OutlinedInput.d.ts +4 -4
- package/OutlinedInput/OutlinedInput.js +13 -23
- package/OutlinedInput/OutlinedInput.mjs +13 -23
- package/Pagination/Pagination.d.mts +2 -2
- package/Pagination/Pagination.d.ts +2 -2
- package/PaginationItem/PaginationItem.d.mts +3 -3
- package/PaginationItem/PaginationItem.d.ts +3 -3
- package/Paper/Paper.d.mts +4 -4
- package/Paper/Paper.d.ts +4 -4
- package/PigmentContainer/PigmentContainer.d.mts +2 -2
- package/PigmentContainer/PigmentContainer.d.ts +2 -2
- package/PigmentContainer/PigmentContainer.js +2 -3
- package/PigmentContainer/PigmentContainer.mjs +2 -3
- package/PigmentGrid/PigmentGrid.d.mts +2 -2
- package/PigmentGrid/PigmentGrid.d.ts +2 -2
- package/PigmentGrid/PigmentGrid.js +2 -2
- package/PigmentGrid/PigmentGrid.mjs +2 -2
- package/PigmentStack/PigmentStack.d.mts +2 -2
- package/PigmentStack/PigmentStack.d.ts +2 -2
- package/PigmentStack/PigmentStack.js +2 -2
- package/PigmentStack/PigmentStack.mjs +2 -2
- package/Popover/Popover.d.mts +4 -4
- package/Popover/Popover.d.ts +4 -4
- package/Popper/BasePopper.js +23 -1
- package/Popper/BasePopper.mjs +23 -1
- package/Popper/Popper.d.mts +4 -4
- package/Popper/Popper.d.ts +4 -4
- package/Popper/Popper.js +4 -4
- package/Popper/Popper.mjs +4 -4
- package/Portal/Portal.d.mts +2 -2
- package/Portal/Portal.d.ts +2 -2
- package/Portal/Portal.js +2 -2
- package/Portal/Portal.mjs +2 -2
- package/README.md +3 -3
- package/Radio/Radio.d.mts +3 -3
- package/Radio/Radio.d.ts +3 -3
- package/RadioGroup/RadioGroup.d.mts +3 -3
- package/RadioGroup/RadioGroup.d.ts +3 -3
- package/Rating/Rating.d.mts +2 -2
- package/Rating/Rating.d.ts +2 -2
- package/ScopedCssBaseline/ScopedCssBaseline.d.mts +2 -2
- package/ScopedCssBaseline/ScopedCssBaseline.d.ts +2 -2
- package/Select/Select.d.mts +3 -3
- package/Select/Select.d.ts +3 -3
- package/Select/Select.js +2 -5
- package/Select/Select.mjs +2 -5
- package/Select/SelectInput.js +164 -2
- package/Select/SelectInput.mjs +164 -2
- package/Skeleton/Skeleton.d.mts +2 -2
- package/Skeleton/Skeleton.d.ts +2 -2
- package/Slide/Slide.d.mts +4 -4
- package/Slide/Slide.d.ts +4 -4
- package/Slide/Slide.js +73 -50
- package/Slide/Slide.mjs +74 -52
- package/Slider/Slider.d.mts +4 -4
- package/Slider/Slider.d.ts +4 -4
- package/Slider/Slider.js +11 -2
- package/Slider/Slider.mjs +11 -2
- package/Slider/useSlider.d.mts +1 -1
- package/Slider/useSlider.d.ts +1 -1
- package/Slider/useSlider.js +236 -209
- package/Slider/useSlider.mjs +236 -209
- package/Slider/useSlider.types.d.mts +2 -2
- package/Slider/useSlider.types.d.ts +2 -2
- package/Snackbar/Snackbar.d.mts +2 -2
- package/Snackbar/Snackbar.d.ts +2 -2
- package/SnackbarContent/SnackbarContent.d.mts +3 -3
- package/SnackbarContent/SnackbarContent.d.ts +3 -3
- package/SpeedDial/SpeedDial.d.mts +2 -2
- package/SpeedDial/SpeedDial.d.ts +2 -2
- package/SpeedDialAction/SpeedDialAction.d.mts +3 -3
- package/SpeedDialAction/SpeedDialAction.d.ts +3 -3
- package/SpeedDialIcon/SpeedDialIcon.d.mts +2 -2
- package/SpeedDialIcon/SpeedDialIcon.d.ts +2 -2
- package/Stack/Stack.d.mts +2 -2
- package/Stack/Stack.d.ts +2 -2
- package/Step/Step.d.mts +2 -2
- package/Step/Step.d.ts +2 -2
- package/StepButton/StepButton.d.mts +3 -3
- package/StepButton/StepButton.d.ts +3 -3
- package/StepConnector/StepConnector.d.mts +2 -2
- package/StepConnector/StepConnector.d.ts +2 -2
- package/StepConnector/StepConnector.js +1 -2
- package/StepConnector/StepConnector.mjs +1 -2
- package/StepContent/StepContent.d.mts +2 -2
- package/StepContent/StepContent.d.ts +2 -2
- package/StepIcon/StepIcon.d.mts +3 -3
- package/StepIcon/StepIcon.d.ts +3 -3
- package/StepLabel/StepLabel.d.mts +2 -2
- package/StepLabel/StepLabel.d.ts +2 -2
- package/Stepper/Stepper.d.mts +2 -2
- package/Stepper/Stepper.d.ts +2 -2
- package/SvgIcon/SvgIcon.d.mts +3 -3
- package/SvgIcon/SvgIcon.d.ts +3 -3
- package/SwipeableDrawer/SwipeableDrawer.d.mts +3 -3
- package/SwipeableDrawer/SwipeableDrawer.d.ts +3 -3
- package/SwipeableDrawer/SwipeableDrawer.js +7 -6
- package/SwipeableDrawer/SwipeableDrawer.mjs +7 -6
- package/Switch/Switch.d.mts +4 -4
- package/Switch/Switch.d.ts +4 -4
- package/Switch/Switch.js +9 -4
- package/Switch/Switch.mjs +9 -4
- package/Tab/Tab.d.mts +3 -3
- package/Tab/Tab.d.ts +3 -3
- package/TabScrollButton/TabScrollButton.d.mts +2 -2
- package/TabScrollButton/TabScrollButton.d.ts +2 -2
- package/Table/Table.d.mts +2 -2
- package/Table/Table.d.ts +2 -2
- package/TableBody/TableBody.d.mts +2 -2
- package/TableBody/TableBody.d.ts +2 -2
- package/TableCell/TableCell.d.mts +2 -2
- package/TableCell/TableCell.d.ts +2 -2
- package/TableContainer/TableContainer.d.mts +2 -2
- package/TableContainer/TableContainer.d.ts +2 -2
- package/TableFooter/TableFooter.d.mts +2 -2
- package/TableFooter/TableFooter.d.ts +2 -2
- package/TableHead/TableHead.d.mts +2 -2
- package/TableHead/TableHead.d.ts +2 -2
- package/TablePagination/TablePagination.d.mts +4 -4
- package/TablePagination/TablePagination.d.ts +4 -4
- package/TablePaginationActions/TablePaginationActions.d.mts +2 -2
- package/TablePaginationActions/TablePaginationActions.d.ts +2 -2
- package/TableRow/TableRow.d.mts +2 -2
- package/TableRow/TableRow.d.ts +2 -2
- package/TableSortLabel/TableSortLabel.d.mts +3 -3
- package/TableSortLabel/TableSortLabel.d.ts +3 -3
- package/TableSortLabel/TableSortLabel.js +1 -2
- package/TableSortLabel/TableSortLabel.mjs +1 -2
- package/Tabs/ScrollbarSize.js +2 -1
- package/Tabs/ScrollbarSize.mjs +2 -1
- package/Tabs/Tabs.d.mts +2 -2
- package/Tabs/Tabs.d.ts +2 -2
- package/Tabs/Tabs.js +2 -1
- package/Tabs/Tabs.mjs +2 -1
- package/TextField/TextField.d.mts +10 -10
- package/TextField/TextField.d.ts +10 -10
- package/TextareaAutosize/TextareaAutosize.d.mts +2 -2
- package/TextareaAutosize/TextareaAutosize.d.ts +2 -2
- package/TextareaAutosize/TextareaAutosize.js +2 -2
- package/TextareaAutosize/TextareaAutosize.mjs +2 -2
- package/ToggleButton/ToggleButton.d.mts +3 -3
- package/ToggleButton/ToggleButton.d.ts +3 -3
- package/ToggleButtonGroup/ToggleButtonGroup.d.mts +2 -2
- package/ToggleButtonGroup/ToggleButtonGroup.d.ts +2 -2
- package/Toolbar/Toolbar.d.mts +2 -2
- package/Toolbar/Toolbar.d.ts +2 -2
- package/Tooltip/Tooltip.d.mts +2 -2
- package/Tooltip/Tooltip.d.ts +2 -2
- package/Tooltip/Tooltip.js +26 -108
- package/Tooltip/Tooltip.mjs +26 -108
- package/Typography/Typography.d.mts +4 -4
- package/Typography/Typography.d.ts +4 -4
- package/Unstable_TrapFocus/FocusTrap.js +18 -14
- package/Unstable_TrapFocus/FocusTrap.mjs +18 -14
- package/Zoom/Zoom.d.mts +3 -3
- package/Zoom/Zoom.d.ts +3 -3
- package/Zoom/Zoom.js +24 -30
- package/Zoom/Zoom.mjs +25 -31
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/package.json +7 -7
- package/styles/createThemeNoVars.js +1 -1
- package/styles/createThemeNoVars.mjs +1 -1
- package/styles/responsiveFontSizes.js +19 -8
- package/styles/responsiveFontSizes.mjs +19 -8
- package/styles/useThemeProps.d.mts +3 -3
- package/styles/useThemeProps.d.ts +3 -3
- package/transitions/utils.d.mts +24 -0
- package/transitions/utils.d.ts +24 -0
- package/transitions/utils.js +91 -0
- package/transitions/utils.mjs +88 -0
- package/useAutocomplete/useAutocomplete.d.mts +4 -5
- package/useAutocomplete/useAutocomplete.d.ts +4 -5
- package/useAutocomplete/useAutocomplete.js +166 -53
- package/useAutocomplete/useAutocomplete.mjs +166 -53
- 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 +3 -3
- package/version/index.mjs +3 -3
- package/FormControl/formControlState.js +0 -21
- package/FormControl/formControlState.mjs +0 -15
package/Slider/useSlider.mjs
CHANGED
|
@@ -11,35 +11,46 @@ import visuallyHidden from '@mui/utils/visuallyHidden';
|
|
|
11
11
|
import clamp from '@mui/utils/clamp';
|
|
12
12
|
import extractEventHandlers from '@mui/utils/extractEventHandlers';
|
|
13
13
|
import areArraysEqual from "../utils/areArraysEqual.mjs";
|
|
14
|
+
import contains from "../utils/contains.mjs";
|
|
15
|
+
import getActiveElement from "../utils/getActiveElement.mjs";
|
|
14
16
|
const INTENTIONAL_DRAG_COUNT_THRESHOLD = 2;
|
|
17
|
+
const EMPTY_MARKS = [];
|
|
18
|
+
const EMPTY_OBJ = {};
|
|
15
19
|
function getNewValue(currentValue, step, direction, min, max) {
|
|
16
20
|
return direction === 1 ? Math.min(currentValue + step, max) : Math.max(currentValue - step, min);
|
|
17
21
|
}
|
|
18
22
|
function asc(a, b) {
|
|
19
23
|
return a - b;
|
|
20
24
|
}
|
|
21
|
-
function findClosest(values, currentValue) {
|
|
22
|
-
const {
|
|
23
|
-
index: closestIndex
|
|
24
|
-
} = values.reduce((acc, value, index) => {
|
|
25
|
+
function findClosest(values, currentValue, preferredIndex = -1) {
|
|
26
|
+
const closestValue = values.reduce((acc, value, index) => {
|
|
25
27
|
const distance = Math.abs(currentValue - value);
|
|
26
|
-
if (acc
|
|
28
|
+
if (acc == null || distance <= acc.distance) {
|
|
27
29
|
return {
|
|
28
30
|
distance,
|
|
29
31
|
index
|
|
30
32
|
};
|
|
31
33
|
}
|
|
32
34
|
return acc;
|
|
33
|
-
}, null) ??
|
|
35
|
+
}, null) ?? EMPTY_OBJ;
|
|
36
|
+
const {
|
|
37
|
+
index: closestIndex
|
|
38
|
+
} = closestValue;
|
|
39
|
+
if (closestIndex == null) {
|
|
40
|
+
return closestIndex;
|
|
41
|
+
}
|
|
42
|
+
if (preferredIndex >= 0 && values[preferredIndex] === values[closestIndex]) {
|
|
43
|
+
return preferredIndex;
|
|
44
|
+
}
|
|
34
45
|
return closestIndex;
|
|
35
46
|
}
|
|
36
|
-
function trackFinger(event,
|
|
47
|
+
function trackFinger(event, touchIdRef) {
|
|
37
48
|
// The event is TouchEvent
|
|
38
|
-
if (
|
|
49
|
+
if (touchIdRef.current != null && event.changedTouches) {
|
|
39
50
|
const touchEvent = event;
|
|
40
51
|
for (let i = 0; i < touchEvent.changedTouches.length; i += 1) {
|
|
41
52
|
const touch = touchEvent.changedTouches[i];
|
|
42
|
-
if (touch.identifier ===
|
|
53
|
+
if (touch.identifier === touchIdRef.current) {
|
|
43
54
|
return {
|
|
44
55
|
x: touch.clientX,
|
|
45
56
|
y: touch.clientY
|
|
@@ -49,7 +60,7 @@ function trackFinger(event, touchId) {
|
|
|
49
60
|
return false;
|
|
50
61
|
}
|
|
51
62
|
|
|
52
|
-
// The event is MouseEvent
|
|
63
|
+
// The event is PointerEvent or MouseEvent
|
|
53
64
|
return {
|
|
54
65
|
x: event.clientX,
|
|
55
66
|
y: event.clientY
|
|
@@ -76,26 +87,18 @@ function roundValueToStep(value, step, min) {
|
|
|
76
87
|
const nearest = Math.round((value - min) / step) * step + min;
|
|
77
88
|
return Number(nearest.toFixed(getDecimalPrecision(step)));
|
|
78
89
|
}
|
|
79
|
-
function setValueIndex({
|
|
80
|
-
values,
|
|
81
|
-
newValue,
|
|
82
|
-
index
|
|
83
|
-
}) {
|
|
90
|
+
function setValueIndex(values, newValue, index) {
|
|
84
91
|
const output = values.slice();
|
|
85
92
|
output[index] = newValue;
|
|
86
93
|
return output.sort(asc);
|
|
87
94
|
}
|
|
88
|
-
function focusThumb({
|
|
89
|
-
sliderRef,
|
|
90
|
-
activeIndex,
|
|
91
|
-
setActive,
|
|
92
|
-
focusVisible
|
|
93
|
-
}) {
|
|
95
|
+
function focusThumb(sliderRef, activeIndex, setActive, focusVisible) {
|
|
94
96
|
const doc = ownerDocument(sliderRef.current);
|
|
95
|
-
|
|
97
|
+
const activeElement = getActiveElement(doc);
|
|
98
|
+
if (!contains(sliderRef.current, activeElement) || Number(activeElement?.getAttribute('data-index')) !== activeIndex) {
|
|
96
99
|
const input = sliderRef.current?.querySelector(`[type="range"][data-index="${activeIndex}"]`);
|
|
97
100
|
if (input != null) {
|
|
98
|
-
if (focusVisible
|
|
101
|
+
if (focusVisible == null) {
|
|
99
102
|
input.focus({
|
|
100
103
|
preventScroll: true
|
|
101
104
|
});
|
|
@@ -104,7 +107,7 @@ function focusThumb({
|
|
|
104
107
|
preventScroll: true,
|
|
105
108
|
// Prevent pointer-driven focus rings in browsers that support this option.
|
|
106
109
|
// Chrome 144+ supports `focusVisible` in `HTMLElement.focus()` options.
|
|
107
|
-
// @ts-
|
|
110
|
+
// @ts-expect-error `focusVisible` is not yet in TypeScript's lib.dom FocusOptions.
|
|
108
111
|
focusVisible
|
|
109
112
|
});
|
|
110
113
|
}
|
|
@@ -150,28 +153,6 @@ const axisProps = {
|
|
|
150
153
|
}
|
|
151
154
|
};
|
|
152
155
|
export const Identity = x => x;
|
|
153
|
-
|
|
154
|
-
// TODO: remove support for Safari < 13.
|
|
155
|
-
// https://caniuse.com/#search=touch-action
|
|
156
|
-
//
|
|
157
|
-
// Safari, on iOS, supports touch action since v13.
|
|
158
|
-
// Over 80% of the iOS phones are compatible
|
|
159
|
-
// in August 2020.
|
|
160
|
-
// Utilizing the CSS.supports method to check if touch-action is supported.
|
|
161
|
-
// Since CSS.supports is supported on all but Edge@12 and IE and touch-action
|
|
162
|
-
// is supported on both Edge@12 and IE if CSS.supports is not available that means that
|
|
163
|
-
// touch-action will be supported
|
|
164
|
-
let cachedSupportsTouchActionNone;
|
|
165
|
-
function doesSupportTouchActionNone() {
|
|
166
|
-
if (cachedSupportsTouchActionNone === undefined) {
|
|
167
|
-
if (typeof CSS !== 'undefined' && typeof CSS.supports === 'function') {
|
|
168
|
-
cachedSupportsTouchActionNone = CSS.supports('touch-action', 'none');
|
|
169
|
-
} else {
|
|
170
|
-
cachedSupportsTouchActionNone = true;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return cachedSupportsTouchActionNone;
|
|
174
|
-
}
|
|
175
156
|
export function useSlider(parameters) {
|
|
176
157
|
const {
|
|
177
158
|
'aria-labelledby': ariaLabelledby,
|
|
@@ -193,35 +174,42 @@ export function useSlider(parameters) {
|
|
|
193
174
|
tabIndex,
|
|
194
175
|
value: valueProp
|
|
195
176
|
} = parameters;
|
|
196
|
-
const
|
|
197
|
-
const
|
|
177
|
+
const touchIdRef = React.useRef(undefined);
|
|
178
|
+
const focusFrameRef = React.useRef(null);
|
|
198
179
|
// We can't use the :active browser pseudo-classes.
|
|
199
180
|
// - The active state isn't triggered when clicking on the rail.
|
|
200
181
|
// - The active state isn't transferred when inversing a range slider.
|
|
201
182
|
const [active, setActive] = React.useState(-1);
|
|
202
183
|
const [open, setOpen] = React.useState(-1);
|
|
203
184
|
const [dragging, setDragging] = React.useState(false);
|
|
204
|
-
const
|
|
185
|
+
const moveCountRef = React.useRef(0);
|
|
186
|
+
// Ref (not state) because setActive() always accompanies updates, providing the re-render.
|
|
187
|
+
const lastUsedThumbIndexRef = React.useRef(-1);
|
|
188
|
+
// Prevents duplicate listener registration when both pointer and touch events fire
|
|
189
|
+
// for the same physical touch interaction.
|
|
190
|
+
const pointerDownHandledRef = React.useRef(false);
|
|
191
|
+
// Tracks which pointer owns the current drag session, so stray pointerup/pointermove
|
|
192
|
+
// events from a second pointer don't interfere.
|
|
193
|
+
const activePointerIdRef = React.useRef(-1);
|
|
205
194
|
const cancelFocusFrame = useEventCallback(() => {
|
|
206
|
-
if (
|
|
207
|
-
cancelAnimationFrame(
|
|
208
|
-
|
|
195
|
+
if (focusFrameRef.current != null) {
|
|
196
|
+
cancelAnimationFrame(focusFrameRef.current);
|
|
197
|
+
focusFrameRef.current = null;
|
|
209
198
|
}
|
|
210
199
|
});
|
|
211
|
-
//
|
|
212
|
-
const
|
|
200
|
+
// lastChangedValueRef is updated whenever onChange is triggered.
|
|
201
|
+
const lastChangedValueRef = React.useRef(null);
|
|
213
202
|
const [valueDerived, setValueState] = useControlled({
|
|
214
203
|
controlled: valueProp,
|
|
215
204
|
default: defaultValue ?? min,
|
|
216
205
|
name: 'Slider'
|
|
217
206
|
});
|
|
218
|
-
const handleChange =
|
|
207
|
+
const handleChange = useEventCallback((event, value, thumbIndex) => {
|
|
219
208
|
// Redefine target to allow name and value to be read.
|
|
220
209
|
// This allows seamless integration with the most popular form libraries.
|
|
221
210
|
// https://github.com/mui/material-ui/issues/13485#issuecomment-676048492
|
|
222
211
|
// Clone the event to not override `target` of the original event.
|
|
223
|
-
const nativeEvent = event.nativeEvent
|
|
224
|
-
// @ts-ignore The nativeEvent is function, not object
|
|
212
|
+
const nativeEvent = 'nativeEvent' in event ? event.nativeEvent : event;
|
|
225
213
|
const clonedEvent = new nativeEvent.constructor(nativeEvent.type, nativeEvent);
|
|
226
214
|
Object.defineProperty(clonedEvent, 'target', {
|
|
227
215
|
writable: true,
|
|
@@ -230,16 +218,43 @@ export function useSlider(parameters) {
|
|
|
230
218
|
name
|
|
231
219
|
}
|
|
232
220
|
});
|
|
233
|
-
|
|
234
|
-
onChange(clonedEvent, value, thumbIndex);
|
|
221
|
+
lastChangedValueRef.current = value;
|
|
222
|
+
onChange?.(clonedEvent, value, thumbIndex);
|
|
235
223
|
});
|
|
236
224
|
const range = Array.isArray(valueDerived);
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
225
|
+
const values = React.useMemo(() => {
|
|
226
|
+
if (typeof valueDerived === 'number') {
|
|
227
|
+
return [clamp(valueDerived, min, max)];
|
|
228
|
+
}
|
|
229
|
+
if (valueDerived == null) {
|
|
230
|
+
return [min];
|
|
231
|
+
}
|
|
232
|
+
const sortedValues = valueDerived.slice().sort(asc);
|
|
233
|
+
for (let i = 0; i < sortedValues.length; i += 1) {
|
|
234
|
+
const value = sortedValues[i];
|
|
235
|
+
sortedValues[i] = value == null ? min : clamp(value, min, max);
|
|
236
|
+
}
|
|
237
|
+
return sortedValues;
|
|
238
|
+
}, [valueDerived, min, max]);
|
|
239
|
+
const marks = React.useMemo(() => {
|
|
240
|
+
if (marksProp === true && step != null) {
|
|
241
|
+
const generatedMarks = new Array(Math.floor((max - min) / step) + 1);
|
|
242
|
+
for (let i = 0; i < generatedMarks.length; i += 1) {
|
|
243
|
+
generatedMarks[i] = {
|
|
244
|
+
value: min + step * i
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
return generatedMarks;
|
|
248
|
+
}
|
|
249
|
+
return Array.isArray(marksProp) ? marksProp : EMPTY_MARKS;
|
|
250
|
+
}, [marksProp, step, min, max]);
|
|
251
|
+
const marksValues = React.useMemo(() => {
|
|
252
|
+
const markValues = new Array(marks.length);
|
|
253
|
+
for (let i = 0; i < marks.length; i += 1) {
|
|
254
|
+
markValues[i] = marks[i].value;
|
|
255
|
+
}
|
|
256
|
+
return markValues;
|
|
257
|
+
}, [marks]);
|
|
243
258
|
const [focusedThumbIndex, setFocusedThumbIndex] = React.useState(-1);
|
|
244
259
|
const sliderRef = React.useRef(null);
|
|
245
260
|
const handleRef = useForkRef(ref, sliderRef);
|
|
@@ -280,29 +295,22 @@ export function useSlider(parameters) {
|
|
|
280
295
|
newValue = clamp(newValue, values[index - 1] || -Infinity, values[index + 1] || Infinity);
|
|
281
296
|
}
|
|
282
297
|
const previousValue = newValue;
|
|
283
|
-
newValue = setValueIndex(
|
|
284
|
-
values,
|
|
285
|
-
newValue,
|
|
286
|
-
index
|
|
287
|
-
});
|
|
298
|
+
newValue = setValueIndex(values, newValue, index);
|
|
288
299
|
let activeIndex = index;
|
|
289
300
|
|
|
290
301
|
// Potentially swap the index if needed.
|
|
291
302
|
if (!disableSwap) {
|
|
292
303
|
activeIndex = newValue.indexOf(previousValue);
|
|
293
304
|
}
|
|
294
|
-
focusThumb(
|
|
295
|
-
sliderRef,
|
|
296
|
-
activeIndex
|
|
297
|
-
});
|
|
305
|
+
focusThumb(sliderRef, activeIndex);
|
|
298
306
|
}
|
|
299
307
|
setValueState(newValue);
|
|
300
308
|
setFocusedThumbIndex(index);
|
|
301
|
-
if (
|
|
309
|
+
if (onChange && !areValuesEqual(newValue, valueDerived)) {
|
|
302
310
|
handleChange(event, newValue, index);
|
|
303
311
|
}
|
|
304
312
|
if (onChangeCommitted) {
|
|
305
|
-
onChangeCommitted(event,
|
|
313
|
+
onChangeCommitted(event, lastChangedValueRef.current ?? newValue);
|
|
306
314
|
}
|
|
307
315
|
};
|
|
308
316
|
const createHandleHiddenInputKeyDown = otherHandlers => event => {
|
|
@@ -370,12 +378,14 @@ export function useSlider(parameters) {
|
|
|
370
378
|
otherHandlers?.onKeyDown?.(event);
|
|
371
379
|
};
|
|
372
380
|
useEnhancedEffect(() => {
|
|
373
|
-
|
|
381
|
+
const activeElement = getActiveElement(ownerDocument(sliderRef.current));
|
|
382
|
+
if (disabled && contains(sliderRef.current, activeElement)) {
|
|
374
383
|
// This is necessary because Firefox and Safari will keep focus
|
|
375
384
|
// on a disabled element:
|
|
376
385
|
// https://codesandbox.io/p/sandbox/mui-pr-22247-forked-h151h?file=/src/App.js
|
|
377
|
-
|
|
378
|
-
|
|
386
|
+
if (activeElement != null && 'blur' in activeElement) {
|
|
387
|
+
activeElement.blur();
|
|
388
|
+
}
|
|
379
389
|
}
|
|
380
390
|
}, [disabled]);
|
|
381
391
|
if (disabled && active !== -1) {
|
|
@@ -386,22 +396,27 @@ export function useSlider(parameters) {
|
|
|
386
396
|
}
|
|
387
397
|
const createHandleHiddenInputChange = otherHandlers => event => {
|
|
388
398
|
otherHandlers.onChange?.(event);
|
|
389
|
-
//
|
|
390
|
-
|
|
391
|
-
changeValue(event, event.target.valueAsNumber);
|
|
399
|
+
// Handles value changes reported through the hidden range input.
|
|
400
|
+
changeValue(event, event.currentTarget.valueAsNumber);
|
|
392
401
|
};
|
|
393
|
-
const
|
|
402
|
+
const previousIndexRef = React.useRef(undefined);
|
|
394
403
|
let axis = orientation;
|
|
395
404
|
if (isRtl && orientation === 'horizontal') {
|
|
396
405
|
axis += '-reverse';
|
|
397
406
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
407
|
+
|
|
408
|
+
// Converts finger coordinates to a slider value and determines the active thumb.
|
|
409
|
+
// For range sliders, reads `previousIndexRef.current` to decide which thumb is active:
|
|
410
|
+
// -1 = initial press → find closest thumb
|
|
411
|
+
// ≥0 = drag in progress → keep same thumb
|
|
412
|
+
// Callers must reset `previousIndexRef.current = -1` before calling on a new interaction.
|
|
413
|
+
const getValueAtFinger = finger => {
|
|
402
414
|
const {
|
|
403
415
|
current: slider
|
|
404
416
|
} = sliderRef;
|
|
417
|
+
if (!slider) {
|
|
418
|
+
return null;
|
|
419
|
+
}
|
|
405
420
|
const {
|
|
406
421
|
width,
|
|
407
422
|
height,
|
|
@@ -428,27 +443,20 @@ export function useSlider(parameters) {
|
|
|
428
443
|
newValue = clamp(newValue, min, max);
|
|
429
444
|
let activeIndex = 0;
|
|
430
445
|
if (range) {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
} else {
|
|
434
|
-
activeIndex = previousIndex.current;
|
|
435
|
-
}
|
|
446
|
+
const isDragging = previousIndexRef.current !== -1;
|
|
447
|
+
activeIndex = isDragging ? previousIndexRef.current : findClosest(values, newValue, lastUsedThumbIndexRef.current);
|
|
436
448
|
|
|
437
449
|
// Bound the new value to the thumb's neighbours.
|
|
438
450
|
if (disableSwap) {
|
|
439
451
|
newValue = clamp(newValue, values[activeIndex - 1] || -Infinity, values[activeIndex + 1] || Infinity);
|
|
440
452
|
}
|
|
441
453
|
const previousValue = newValue;
|
|
442
|
-
newValue = setValueIndex(
|
|
443
|
-
values,
|
|
444
|
-
newValue,
|
|
445
|
-
index: activeIndex
|
|
446
|
-
});
|
|
454
|
+
newValue = setValueIndex(values, newValue, activeIndex);
|
|
447
455
|
|
|
448
456
|
// Potentially swap the index if needed.
|
|
449
|
-
if (!(disableSwap &&
|
|
457
|
+
if (!(disableSwap && isDragging)) {
|
|
450
458
|
activeIndex = newValue.indexOf(previousValue);
|
|
451
|
-
|
|
459
|
+
previousIndexRef.current = activeIndex;
|
|
452
460
|
}
|
|
453
461
|
}
|
|
454
462
|
return {
|
|
@@ -457,60 +465,61 @@ export function useSlider(parameters) {
|
|
|
457
465
|
};
|
|
458
466
|
};
|
|
459
467
|
const handleTouchMove = useEventCallback(nativeEvent => {
|
|
460
|
-
|
|
468
|
+
// Ignore pointer events from a different pointer than the one that started the drag.
|
|
469
|
+
if ('pointerId' in nativeEvent && nativeEvent.pointerId !== activePointerIdRef.current) {
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
const finger = trackFinger(nativeEvent, touchIdRef);
|
|
461
473
|
if (!finger) {
|
|
462
474
|
return;
|
|
463
475
|
}
|
|
464
|
-
|
|
476
|
+
moveCountRef.current += 1;
|
|
465
477
|
|
|
466
|
-
// Cancel move in case some other element consumed a
|
|
467
|
-
|
|
468
|
-
if (nativeEvent.type === 'mousemove' && nativeEvent.buttons === 0) {
|
|
478
|
+
// Cancel move in case some other element consumed a pointerup event and it was not fired.
|
|
479
|
+
if (nativeEvent.type === 'pointermove' && nativeEvent.buttons === 0) {
|
|
469
480
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
470
481
|
handleTouchEnd(nativeEvent);
|
|
471
482
|
return;
|
|
472
483
|
}
|
|
473
|
-
const
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
sliderRef,
|
|
482
|
-
activeIndex,
|
|
483
|
-
setActive,
|
|
484
|
-
focusVisible: false
|
|
485
|
-
});
|
|
486
|
-
setValueState(newValue);
|
|
487
|
-
if (!dragging && moveCount.current > INTENTIONAL_DRAG_COUNT_THRESHOLD) {
|
|
484
|
+
const newFingerValue = getValueAtFinger(finger);
|
|
485
|
+
if (!newFingerValue) {
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
focusThumb(sliderRef, newFingerValue.activeIndex, setActive, false);
|
|
489
|
+
lastUsedThumbIndexRef.current = newFingerValue.activeIndex;
|
|
490
|
+
setValueState(newFingerValue.newValue);
|
|
491
|
+
if (!dragging && moveCountRef.current > INTENTIONAL_DRAG_COUNT_THRESHOLD) {
|
|
488
492
|
setDragging(true);
|
|
489
493
|
}
|
|
490
|
-
if (
|
|
491
|
-
handleChange(nativeEvent, newValue, activeIndex);
|
|
494
|
+
if (onChange && !areValuesEqual(newFingerValue.newValue, valueDerived)) {
|
|
495
|
+
handleChange(nativeEvent, newFingerValue.newValue, newFingerValue.activeIndex);
|
|
492
496
|
}
|
|
493
497
|
});
|
|
494
498
|
const handleTouchEnd = useEventCallback(nativeEvent => {
|
|
495
|
-
|
|
499
|
+
// Ignore pointer events from a different pointer than the one that started the drag.
|
|
500
|
+
if ('pointerId' in nativeEvent && nativeEvent.pointerId !== activePointerIdRef.current) {
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
const finger = trackFinger(nativeEvent, touchIdRef);
|
|
496
504
|
setDragging(false);
|
|
497
505
|
if (!finger) {
|
|
498
506
|
return;
|
|
499
507
|
}
|
|
500
|
-
const
|
|
501
|
-
newValue
|
|
502
|
-
} = getFingerNewValue({
|
|
503
|
-
finger,
|
|
504
|
-
move: true
|
|
505
|
-
});
|
|
508
|
+
const newFingerValue = getValueAtFinger(finger);
|
|
506
509
|
setActive(-1);
|
|
507
510
|
if (nativeEvent.type === 'touchend') {
|
|
508
511
|
setOpen(-1);
|
|
509
512
|
}
|
|
510
|
-
if (onChangeCommitted) {
|
|
511
|
-
onChangeCommitted(nativeEvent,
|
|
513
|
+
if (newFingerValue && onChangeCommitted) {
|
|
514
|
+
onChangeCommitted(nativeEvent, lastChangedValueRef.current ?? newFingerValue.newValue);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
// Release pointer capture if applicable
|
|
518
|
+
if ('pointerType' in nativeEvent && sliderRef.current?.hasPointerCapture(nativeEvent.pointerId)) {
|
|
519
|
+
sliderRef.current.releasePointerCapture(nativeEvent.pointerId);
|
|
512
520
|
}
|
|
513
|
-
|
|
521
|
+
touchIdRef.current = undefined;
|
|
522
|
+
activePointerIdRef.current = -1;
|
|
514
523
|
|
|
515
524
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
516
525
|
stopListening();
|
|
@@ -519,35 +528,36 @@ export function useSlider(parameters) {
|
|
|
519
528
|
if (disabled) {
|
|
520
529
|
return;
|
|
521
530
|
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
531
|
+
|
|
532
|
+
// If the pointer path already handled this interaction,
|
|
533
|
+
// only record the touch identifier and skip duplicate listener registration.
|
|
534
|
+
if (pointerDownHandledRef.current) {
|
|
535
|
+
pointerDownHandledRef.current = false;
|
|
536
|
+
const touch = nativeEvent.changedTouches[0];
|
|
537
|
+
if (touch != null) {
|
|
538
|
+
touchIdRef.current = touch.identifier;
|
|
539
|
+
}
|
|
540
|
+
return;
|
|
525
541
|
}
|
|
526
542
|
const touch = nativeEvent.changedTouches[0];
|
|
527
543
|
if (touch != null) {
|
|
528
544
|
// A number that uniquely identifies the current finger in the touch session.
|
|
529
|
-
|
|
545
|
+
touchIdRef.current = touch.identifier;
|
|
530
546
|
}
|
|
531
|
-
const finger = trackFinger(nativeEvent,
|
|
547
|
+
const finger = trackFinger(nativeEvent, touchIdRef);
|
|
532
548
|
if (finger !== false) {
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
setActive,
|
|
543
|
-
focusVisible: false
|
|
544
|
-
});
|
|
545
|
-
setValueState(newValue);
|
|
546
|
-
if (handleChange && !areValuesEqual(newValue, valueDerived)) {
|
|
547
|
-
handleChange(nativeEvent, newValue, activeIndex);
|
|
549
|
+
previousIndexRef.current = -1;
|
|
550
|
+
const newFingerValue = getValueAtFinger(finger);
|
|
551
|
+
if (newFingerValue) {
|
|
552
|
+
focusThumb(sliderRef, newFingerValue.activeIndex, setActive, false);
|
|
553
|
+
lastUsedThumbIndexRef.current = newFingerValue.activeIndex;
|
|
554
|
+
setValueState(newFingerValue.newValue);
|
|
555
|
+
if (onChange && !areValuesEqual(newFingerValue.newValue, valueDerived)) {
|
|
556
|
+
handleChange(nativeEvent, newFingerValue.newValue, newFingerValue.activeIndex);
|
|
557
|
+
}
|
|
548
558
|
}
|
|
549
559
|
}
|
|
550
|
-
|
|
560
|
+
moveCountRef.current = 0;
|
|
551
561
|
const doc = ownerDocument(sliderRef.current);
|
|
552
562
|
doc.addEventListener('touchmove', handleTouchMove, {
|
|
553
563
|
passive: true
|
|
@@ -558,17 +568,18 @@ export function useSlider(parameters) {
|
|
|
558
568
|
});
|
|
559
569
|
const stopListening = React.useCallback(() => {
|
|
560
570
|
const doc = ownerDocument(sliderRef.current);
|
|
561
|
-
doc.removeEventListener('
|
|
562
|
-
doc.removeEventListener('
|
|
571
|
+
doc.removeEventListener('pointermove', handleTouchMove);
|
|
572
|
+
doc.removeEventListener('pointerup', handleTouchEnd);
|
|
563
573
|
doc.removeEventListener('touchmove', handleTouchMove);
|
|
564
574
|
doc.removeEventListener('touchend', handleTouchEnd);
|
|
565
575
|
}, [handleTouchEnd, handleTouchMove]);
|
|
566
576
|
React.useEffect(() => {
|
|
567
|
-
const
|
|
568
|
-
|
|
569
|
-
|
|
577
|
+
const slider = sliderRef.current;
|
|
578
|
+
if (!slider) {
|
|
579
|
+
return undefined;
|
|
580
|
+
}
|
|
570
581
|
slider.addEventListener('touchstart', handleTouchStart, {
|
|
571
|
-
passive:
|
|
582
|
+
passive: true
|
|
572
583
|
});
|
|
573
584
|
return () => {
|
|
574
585
|
slider.removeEventListener('touchstart', handleTouchStart);
|
|
@@ -582,62 +593,67 @@ export function useSlider(parameters) {
|
|
|
582
593
|
cancelFocusFrame();
|
|
583
594
|
}
|
|
584
595
|
}, [disabled, stopListening, cancelFocusFrame]);
|
|
585
|
-
const
|
|
586
|
-
otherHandlers.
|
|
587
|
-
if (disabled) {
|
|
588
|
-
return;
|
|
589
|
-
}
|
|
590
|
-
if (event.defaultPrevented) {
|
|
591
|
-
return;
|
|
592
|
-
}
|
|
596
|
+
const createHandlePointerDown = otherHandlers => event => {
|
|
597
|
+
otherHandlers.onPointerDown?.(event);
|
|
593
598
|
|
|
594
|
-
//
|
|
595
|
-
|
|
599
|
+
// On touch devices, the browser fires both pointerdown and touchstart for the
|
|
600
|
+
// same physical touch. Mark this BEFORE early returns so handleTouchStart always
|
|
601
|
+
// knows the pointer path saw this interaction — even if it was prevented or disabled.
|
|
602
|
+
if (event.pointerType === 'touch') {
|
|
603
|
+
pointerDownHandledRef.current = true;
|
|
604
|
+
}
|
|
605
|
+
if (disabled || event.defaultPrevented || event.button !== 0) {
|
|
596
606
|
return;
|
|
597
607
|
}
|
|
598
|
-
const finger = trackFinger(event,
|
|
608
|
+
const finger = trackFinger(event, touchIdRef);
|
|
599
609
|
if (finger !== false) {
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
focusFrame.current = null;
|
|
616
|
-
focusThumb({
|
|
617
|
-
sliderRef,
|
|
618
|
-
activeIndex,
|
|
619
|
-
focusVisible: false
|
|
610
|
+
previousIndexRef.current = -1;
|
|
611
|
+
const newFingerValue = getValueAtFinger(finger);
|
|
612
|
+
if (newFingerValue) {
|
|
613
|
+
const thumbInput = sliderRef.current?.querySelector(`input[type="range"][data-index="${newFingerValue.activeIndex}"]`);
|
|
614
|
+
const doc = ownerDocument(sliderRef.current);
|
|
615
|
+
const pressedOnFocusedThumb = thumbInput != null && thumbInput === getActiveElement(doc);
|
|
616
|
+
setActive(newFingerValue.activeIndex);
|
|
617
|
+
lastUsedThumbIndexRef.current = newFingerValue.activeIndex;
|
|
618
|
+
if (pressedOnFocusedThumb) {
|
|
619
|
+
event.preventDefault();
|
|
620
|
+
} else {
|
|
621
|
+
cancelFocusFrame();
|
|
622
|
+
focusFrameRef.current = requestAnimationFrame(() => {
|
|
623
|
+
focusFrameRef.current = null;
|
|
624
|
+
focusThumb(sliderRef, newFingerValue.activeIndex, undefined, false);
|
|
620
625
|
});
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
+
}
|
|
627
|
+
setValueState(newFingerValue.newValue);
|
|
628
|
+
if (onChange && !areValuesEqual(newFingerValue.newValue, valueDerived)) {
|
|
629
|
+
handleChange(event, newFingerValue.newValue, newFingerValue.activeIndex);
|
|
630
|
+
}
|
|
626
631
|
}
|
|
627
632
|
}
|
|
628
|
-
|
|
633
|
+
moveCountRef.current = 0;
|
|
634
|
+
activePointerIdRef.current = event.pointerId;
|
|
629
635
|
const doc = ownerDocument(sliderRef.current);
|
|
630
|
-
|
|
636
|
+
|
|
637
|
+
// Use pointer capture for reliable drag tracking
|
|
638
|
+
try {
|
|
639
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
640
|
+
} catch {
|
|
641
|
+
// setPointerCapture can throw if the pointerId is invalid (e.g. synthetic
|
|
642
|
+
// events in tests, or the pointer was already released). The slider still
|
|
643
|
+
// works via document-level listeners; pointer capture is a progressive
|
|
644
|
+
// enhancement for reliable drag tracking.
|
|
645
|
+
}
|
|
646
|
+
doc.addEventListener('pointermove', handleTouchMove, {
|
|
631
647
|
passive: true
|
|
632
648
|
});
|
|
633
|
-
doc.addEventListener('
|
|
649
|
+
doc.addEventListener('pointerup', handleTouchEnd);
|
|
634
650
|
};
|
|
635
651
|
const trackOffset = valueToPercent(range ? values[0] : min, min, max);
|
|
636
652
|
const trackLeap = valueToPercent(values[values.length - 1], min, max) - trackOffset;
|
|
637
|
-
const getRootProps = (externalProps =
|
|
653
|
+
const getRootProps = (externalProps = EMPTY_OBJ) => {
|
|
638
654
|
const externalHandlers = extractEventHandlers(externalProps);
|
|
639
655
|
const ownEventHandlers = {
|
|
640
|
-
|
|
656
|
+
onPointerDown: createHandlePointerDown(externalHandlers)
|
|
641
657
|
};
|
|
642
658
|
const mergedEventHandlers = {
|
|
643
659
|
...externalHandlers,
|
|
@@ -658,11 +674,11 @@ export function useSlider(parameters) {
|
|
|
658
674
|
otherHandlers.onMouseLeave?.(event);
|
|
659
675
|
setOpen(-1);
|
|
660
676
|
};
|
|
661
|
-
const getThumbProps = (externalProps =
|
|
677
|
+
const getThumbProps = (externalProps = EMPTY_OBJ) => {
|
|
662
678
|
const externalHandlers = extractEventHandlers(externalProps);
|
|
663
679
|
const ownEventHandlers = {
|
|
664
|
-
onMouseOver: createHandleMouseOver(externalHandlers
|
|
665
|
-
onMouseLeave: createHandleMouseLeave(externalHandlers
|
|
680
|
+
onMouseOver: createHandleMouseOver(externalHandlers),
|
|
681
|
+
onMouseLeave: createHandleMouseLeave(externalHandlers)
|
|
666
682
|
};
|
|
667
683
|
return {
|
|
668
684
|
...externalProps,
|
|
@@ -671,22 +687,33 @@ export function useSlider(parameters) {
|
|
|
671
687
|
};
|
|
672
688
|
};
|
|
673
689
|
const getThumbStyle = index => {
|
|
690
|
+
let zIndex;
|
|
691
|
+
if (range) {
|
|
692
|
+
if (active === index) {
|
|
693
|
+
zIndex = 2;
|
|
694
|
+
} else if (lastUsedThumbIndexRef.current === index) {
|
|
695
|
+
zIndex = 1;
|
|
696
|
+
}
|
|
697
|
+
} else if (active === index) {
|
|
698
|
+
zIndex = 1;
|
|
699
|
+
}
|
|
674
700
|
return {
|
|
675
701
|
// So the non active thumb doesn't show its label on hover.
|
|
676
|
-
pointerEvents: active !== -1 && active !== index ? 'none' : undefined
|
|
702
|
+
pointerEvents: active !== -1 && active !== index ? 'none' : undefined,
|
|
703
|
+
zIndex
|
|
677
704
|
};
|
|
678
705
|
};
|
|
679
706
|
let cssWritingMode;
|
|
680
707
|
if (orientation === 'vertical') {
|
|
681
708
|
cssWritingMode = isRtl ? 'vertical-rl' : 'vertical-lr';
|
|
682
709
|
}
|
|
683
|
-
const getHiddenInputProps = (externalProps =
|
|
710
|
+
const getHiddenInputProps = (externalProps = EMPTY_OBJ) => {
|
|
684
711
|
const externalHandlers = extractEventHandlers(externalProps);
|
|
685
712
|
const ownEventHandlers = {
|
|
686
|
-
onChange: createHandleHiddenInputChange(externalHandlers
|
|
687
|
-
onFocus: createHandleHiddenInputFocus(externalHandlers
|
|
688
|
-
onBlur: createHandleHiddenInputBlur(externalHandlers
|
|
689
|
-
onKeyDown: createHandleHiddenInputKeyDown(externalHandlers
|
|
713
|
+
onChange: createHandleHiddenInputChange(externalHandlers),
|
|
714
|
+
onFocus: createHandleHiddenInputFocus(externalHandlers),
|
|
715
|
+
onBlur: createHandleHiddenInputBlur(externalHandlers),
|
|
716
|
+
onKeyDown: createHandleHiddenInputKeyDown(externalHandlers)
|
|
690
717
|
};
|
|
691
718
|
const mergedEventHandlers = {
|
|
692
719
|
...externalHandlers,
|
|
@@ -725,7 +752,7 @@ export function useSlider(parameters) {
|
|
|
725
752
|
getHiddenInputProps,
|
|
726
753
|
getRootProps,
|
|
727
754
|
getThumbProps,
|
|
728
|
-
marks
|
|
755
|
+
marks,
|
|
729
756
|
open,
|
|
730
757
|
range,
|
|
731
758
|
rootRef: handleRef,
|