@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.js
CHANGED
|
@@ -20,35 +20,46 @@ var _visuallyHidden = _interopRequireDefault(require("@mui/utils/visuallyHidden"
|
|
|
20
20
|
var _clamp = _interopRequireDefault(require("@mui/utils/clamp"));
|
|
21
21
|
var _extractEventHandlers = _interopRequireDefault(require("@mui/utils/extractEventHandlers"));
|
|
22
22
|
var _areArraysEqual = _interopRequireDefault(require("../utils/areArraysEqual"));
|
|
23
|
+
var _contains = _interopRequireDefault(require("../utils/contains"));
|
|
24
|
+
var _getActiveElement = _interopRequireDefault(require("../utils/getActiveElement"));
|
|
23
25
|
const INTENTIONAL_DRAG_COUNT_THRESHOLD = 2;
|
|
26
|
+
const EMPTY_MARKS = [];
|
|
27
|
+
const EMPTY_OBJ = {};
|
|
24
28
|
function getNewValue(currentValue, step, direction, min, max) {
|
|
25
29
|
return direction === 1 ? Math.min(currentValue + step, max) : Math.max(currentValue - step, min);
|
|
26
30
|
}
|
|
27
31
|
function asc(a, b) {
|
|
28
32
|
return a - b;
|
|
29
33
|
}
|
|
30
|
-
function findClosest(values, currentValue) {
|
|
31
|
-
const {
|
|
32
|
-
index: closestIndex
|
|
33
|
-
} = values.reduce((acc, value, index) => {
|
|
34
|
+
function findClosest(values, currentValue, preferredIndex = -1) {
|
|
35
|
+
const closestValue = values.reduce((acc, value, index) => {
|
|
34
36
|
const distance = Math.abs(currentValue - value);
|
|
35
|
-
if (acc
|
|
37
|
+
if (acc == null || distance <= acc.distance) {
|
|
36
38
|
return {
|
|
37
39
|
distance,
|
|
38
40
|
index
|
|
39
41
|
};
|
|
40
42
|
}
|
|
41
43
|
return acc;
|
|
42
|
-
}, null) ??
|
|
44
|
+
}, null) ?? EMPTY_OBJ;
|
|
45
|
+
const {
|
|
46
|
+
index: closestIndex
|
|
47
|
+
} = closestValue;
|
|
48
|
+
if (closestIndex == null) {
|
|
49
|
+
return closestIndex;
|
|
50
|
+
}
|
|
51
|
+
if (preferredIndex >= 0 && values[preferredIndex] === values[closestIndex]) {
|
|
52
|
+
return preferredIndex;
|
|
53
|
+
}
|
|
43
54
|
return closestIndex;
|
|
44
55
|
}
|
|
45
|
-
function trackFinger(event,
|
|
56
|
+
function trackFinger(event, touchIdRef) {
|
|
46
57
|
// The event is TouchEvent
|
|
47
|
-
if (
|
|
58
|
+
if (touchIdRef.current != null && event.changedTouches) {
|
|
48
59
|
const touchEvent = event;
|
|
49
60
|
for (let i = 0; i < touchEvent.changedTouches.length; i += 1) {
|
|
50
61
|
const touch = touchEvent.changedTouches[i];
|
|
51
|
-
if (touch.identifier ===
|
|
62
|
+
if (touch.identifier === touchIdRef.current) {
|
|
52
63
|
return {
|
|
53
64
|
x: touch.clientX,
|
|
54
65
|
y: touch.clientY
|
|
@@ -58,7 +69,7 @@ function trackFinger(event, touchId) {
|
|
|
58
69
|
return false;
|
|
59
70
|
}
|
|
60
71
|
|
|
61
|
-
// The event is MouseEvent
|
|
72
|
+
// The event is PointerEvent or MouseEvent
|
|
62
73
|
return {
|
|
63
74
|
x: event.clientX,
|
|
64
75
|
y: event.clientY
|
|
@@ -85,26 +96,18 @@ function roundValueToStep(value, step, min) {
|
|
|
85
96
|
const nearest = Math.round((value - min) / step) * step + min;
|
|
86
97
|
return Number(nearest.toFixed(getDecimalPrecision(step)));
|
|
87
98
|
}
|
|
88
|
-
function setValueIndex({
|
|
89
|
-
values,
|
|
90
|
-
newValue,
|
|
91
|
-
index
|
|
92
|
-
}) {
|
|
99
|
+
function setValueIndex(values, newValue, index) {
|
|
93
100
|
const output = values.slice();
|
|
94
101
|
output[index] = newValue;
|
|
95
102
|
return output.sort(asc);
|
|
96
103
|
}
|
|
97
|
-
function focusThumb({
|
|
98
|
-
sliderRef,
|
|
99
|
-
activeIndex,
|
|
100
|
-
setActive,
|
|
101
|
-
focusVisible
|
|
102
|
-
}) {
|
|
104
|
+
function focusThumb(sliderRef, activeIndex, setActive, focusVisible) {
|
|
103
105
|
const doc = (0, _ownerDocument.default)(sliderRef.current);
|
|
104
|
-
|
|
106
|
+
const activeElement = (0, _getActiveElement.default)(doc);
|
|
107
|
+
if (!(0, _contains.default)(sliderRef.current, activeElement) || Number(activeElement?.getAttribute('data-index')) !== activeIndex) {
|
|
105
108
|
const input = sliderRef.current?.querySelector(`[type="range"][data-index="${activeIndex}"]`);
|
|
106
109
|
if (input != null) {
|
|
107
|
-
if (focusVisible
|
|
110
|
+
if (focusVisible == null) {
|
|
108
111
|
input.focus({
|
|
109
112
|
preventScroll: true
|
|
110
113
|
});
|
|
@@ -113,7 +116,7 @@ function focusThumb({
|
|
|
113
116
|
preventScroll: true,
|
|
114
117
|
// Prevent pointer-driven focus rings in browsers that support this option.
|
|
115
118
|
// Chrome 144+ supports `focusVisible` in `HTMLElement.focus()` options.
|
|
116
|
-
// @ts-
|
|
119
|
+
// @ts-expect-error `focusVisible` is not yet in TypeScript's lib.dom FocusOptions.
|
|
117
120
|
focusVisible
|
|
118
121
|
});
|
|
119
122
|
}
|
|
@@ -159,29 +162,7 @@ const axisProps = {
|
|
|
159
162
|
}
|
|
160
163
|
};
|
|
161
164
|
const Identity = x => x;
|
|
162
|
-
|
|
163
|
-
// TODO: remove support for Safari < 13.
|
|
164
|
-
// https://caniuse.com/#search=touch-action
|
|
165
|
-
//
|
|
166
|
-
// Safari, on iOS, supports touch action since v13.
|
|
167
|
-
// Over 80% of the iOS phones are compatible
|
|
168
|
-
// in August 2020.
|
|
169
|
-
// Utilizing the CSS.supports method to check if touch-action is supported.
|
|
170
|
-
// Since CSS.supports is supported on all but Edge@12 and IE and touch-action
|
|
171
|
-
// is supported on both Edge@12 and IE if CSS.supports is not available that means that
|
|
172
|
-
// touch-action will be supported
|
|
173
165
|
exports.Identity = Identity;
|
|
174
|
-
let cachedSupportsTouchActionNone;
|
|
175
|
-
function doesSupportTouchActionNone() {
|
|
176
|
-
if (cachedSupportsTouchActionNone === undefined) {
|
|
177
|
-
if (typeof CSS !== 'undefined' && typeof CSS.supports === 'function') {
|
|
178
|
-
cachedSupportsTouchActionNone = CSS.supports('touch-action', 'none');
|
|
179
|
-
} else {
|
|
180
|
-
cachedSupportsTouchActionNone = true;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
return cachedSupportsTouchActionNone;
|
|
184
|
-
}
|
|
185
166
|
function useSlider(parameters) {
|
|
186
167
|
const {
|
|
187
168
|
'aria-labelledby': ariaLabelledby,
|
|
@@ -203,35 +184,42 @@ function useSlider(parameters) {
|
|
|
203
184
|
tabIndex,
|
|
204
185
|
value: valueProp
|
|
205
186
|
} = parameters;
|
|
206
|
-
const
|
|
207
|
-
const
|
|
187
|
+
const touchIdRef = React.useRef(undefined);
|
|
188
|
+
const focusFrameRef = React.useRef(null);
|
|
208
189
|
// We can't use the :active browser pseudo-classes.
|
|
209
190
|
// - The active state isn't triggered when clicking on the rail.
|
|
210
191
|
// - The active state isn't transferred when inversing a range slider.
|
|
211
192
|
const [active, setActive] = React.useState(-1);
|
|
212
193
|
const [open, setOpen] = React.useState(-1);
|
|
213
194
|
const [dragging, setDragging] = React.useState(false);
|
|
214
|
-
const
|
|
195
|
+
const moveCountRef = React.useRef(0);
|
|
196
|
+
// Ref (not state) because setActive() always accompanies updates, providing the re-render.
|
|
197
|
+
const lastUsedThumbIndexRef = React.useRef(-1);
|
|
198
|
+
// Prevents duplicate listener registration when both pointer and touch events fire
|
|
199
|
+
// for the same physical touch interaction.
|
|
200
|
+
const pointerDownHandledRef = React.useRef(false);
|
|
201
|
+
// Tracks which pointer owns the current drag session, so stray pointerup/pointermove
|
|
202
|
+
// events from a second pointer don't interfere.
|
|
203
|
+
const activePointerIdRef = React.useRef(-1);
|
|
215
204
|
const cancelFocusFrame = (0, _useEventCallback.default)(() => {
|
|
216
|
-
if (
|
|
217
|
-
cancelAnimationFrame(
|
|
218
|
-
|
|
205
|
+
if (focusFrameRef.current != null) {
|
|
206
|
+
cancelAnimationFrame(focusFrameRef.current);
|
|
207
|
+
focusFrameRef.current = null;
|
|
219
208
|
}
|
|
220
209
|
});
|
|
221
|
-
//
|
|
222
|
-
const
|
|
210
|
+
// lastChangedValueRef is updated whenever onChange is triggered.
|
|
211
|
+
const lastChangedValueRef = React.useRef(null);
|
|
223
212
|
const [valueDerived, setValueState] = (0, _useControlled.default)({
|
|
224
213
|
controlled: valueProp,
|
|
225
214
|
default: defaultValue ?? min,
|
|
226
215
|
name: 'Slider'
|
|
227
216
|
});
|
|
228
|
-
const handleChange =
|
|
217
|
+
const handleChange = (0, _useEventCallback.default)((event, value, thumbIndex) => {
|
|
229
218
|
// Redefine target to allow name and value to be read.
|
|
230
219
|
// This allows seamless integration with the most popular form libraries.
|
|
231
220
|
// https://github.com/mui/material-ui/issues/13485#issuecomment-676048492
|
|
232
221
|
// Clone the event to not override `target` of the original event.
|
|
233
|
-
const nativeEvent = event.nativeEvent
|
|
234
|
-
// @ts-ignore The nativeEvent is function, not object
|
|
222
|
+
const nativeEvent = 'nativeEvent' in event ? event.nativeEvent : event;
|
|
235
223
|
const clonedEvent = new nativeEvent.constructor(nativeEvent.type, nativeEvent);
|
|
236
224
|
Object.defineProperty(clonedEvent, 'target', {
|
|
237
225
|
writable: true,
|
|
@@ -240,16 +228,43 @@ function useSlider(parameters) {
|
|
|
240
228
|
name
|
|
241
229
|
}
|
|
242
230
|
});
|
|
243
|
-
|
|
244
|
-
onChange(clonedEvent, value, thumbIndex);
|
|
231
|
+
lastChangedValueRef.current = value;
|
|
232
|
+
onChange?.(clonedEvent, value, thumbIndex);
|
|
245
233
|
});
|
|
246
234
|
const range = Array.isArray(valueDerived);
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
235
|
+
const values = React.useMemo(() => {
|
|
236
|
+
if (typeof valueDerived === 'number') {
|
|
237
|
+
return [(0, _clamp.default)(valueDerived, min, max)];
|
|
238
|
+
}
|
|
239
|
+
if (valueDerived == null) {
|
|
240
|
+
return [min];
|
|
241
|
+
}
|
|
242
|
+
const sortedValues = valueDerived.slice().sort(asc);
|
|
243
|
+
for (let i = 0; i < sortedValues.length; i += 1) {
|
|
244
|
+
const value = sortedValues[i];
|
|
245
|
+
sortedValues[i] = value == null ? min : (0, _clamp.default)(value, min, max);
|
|
246
|
+
}
|
|
247
|
+
return sortedValues;
|
|
248
|
+
}, [valueDerived, min, max]);
|
|
249
|
+
const marks = React.useMemo(() => {
|
|
250
|
+
if (marksProp === true && step != null) {
|
|
251
|
+
const generatedMarks = new Array(Math.floor((max - min) / step) + 1);
|
|
252
|
+
for (let i = 0; i < generatedMarks.length; i += 1) {
|
|
253
|
+
generatedMarks[i] = {
|
|
254
|
+
value: min + step * i
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
return generatedMarks;
|
|
258
|
+
}
|
|
259
|
+
return Array.isArray(marksProp) ? marksProp : EMPTY_MARKS;
|
|
260
|
+
}, [marksProp, step, min, max]);
|
|
261
|
+
const marksValues = React.useMemo(() => {
|
|
262
|
+
const markValues = new Array(marks.length);
|
|
263
|
+
for (let i = 0; i < marks.length; i += 1) {
|
|
264
|
+
markValues[i] = marks[i].value;
|
|
265
|
+
}
|
|
266
|
+
return markValues;
|
|
267
|
+
}, [marks]);
|
|
253
268
|
const [focusedThumbIndex, setFocusedThumbIndex] = React.useState(-1);
|
|
254
269
|
const sliderRef = React.useRef(null);
|
|
255
270
|
const handleRef = (0, _useForkRef.default)(ref, sliderRef);
|
|
@@ -290,29 +305,22 @@ function useSlider(parameters) {
|
|
|
290
305
|
newValue = (0, _clamp.default)(newValue, values[index - 1] || -Infinity, values[index + 1] || Infinity);
|
|
291
306
|
}
|
|
292
307
|
const previousValue = newValue;
|
|
293
|
-
newValue = setValueIndex(
|
|
294
|
-
values,
|
|
295
|
-
newValue,
|
|
296
|
-
index
|
|
297
|
-
});
|
|
308
|
+
newValue = setValueIndex(values, newValue, index);
|
|
298
309
|
let activeIndex = index;
|
|
299
310
|
|
|
300
311
|
// Potentially swap the index if needed.
|
|
301
312
|
if (!disableSwap) {
|
|
302
313
|
activeIndex = newValue.indexOf(previousValue);
|
|
303
314
|
}
|
|
304
|
-
focusThumb(
|
|
305
|
-
sliderRef,
|
|
306
|
-
activeIndex
|
|
307
|
-
});
|
|
315
|
+
focusThumb(sliderRef, activeIndex);
|
|
308
316
|
}
|
|
309
317
|
setValueState(newValue);
|
|
310
318
|
setFocusedThumbIndex(index);
|
|
311
|
-
if (
|
|
319
|
+
if (onChange && !areValuesEqual(newValue, valueDerived)) {
|
|
312
320
|
handleChange(event, newValue, index);
|
|
313
321
|
}
|
|
314
322
|
if (onChangeCommitted) {
|
|
315
|
-
onChangeCommitted(event,
|
|
323
|
+
onChangeCommitted(event, lastChangedValueRef.current ?? newValue);
|
|
316
324
|
}
|
|
317
325
|
};
|
|
318
326
|
const createHandleHiddenInputKeyDown = otherHandlers => event => {
|
|
@@ -380,12 +388,14 @@ function useSlider(parameters) {
|
|
|
380
388
|
otherHandlers?.onKeyDown?.(event);
|
|
381
389
|
};
|
|
382
390
|
(0, _useEnhancedEffect.default)(() => {
|
|
383
|
-
|
|
391
|
+
const activeElement = (0, _getActiveElement.default)((0, _ownerDocument.default)(sliderRef.current));
|
|
392
|
+
if (disabled && (0, _contains.default)(sliderRef.current, activeElement)) {
|
|
384
393
|
// This is necessary because Firefox and Safari will keep focus
|
|
385
394
|
// on a disabled element:
|
|
386
395
|
// https://codesandbox.io/p/sandbox/mui-pr-22247-forked-h151h?file=/src/App.js
|
|
387
|
-
|
|
388
|
-
|
|
396
|
+
if (activeElement != null && 'blur' in activeElement) {
|
|
397
|
+
activeElement.blur();
|
|
398
|
+
}
|
|
389
399
|
}
|
|
390
400
|
}, [disabled]);
|
|
391
401
|
if (disabled && active !== -1) {
|
|
@@ -396,22 +406,27 @@ function useSlider(parameters) {
|
|
|
396
406
|
}
|
|
397
407
|
const createHandleHiddenInputChange = otherHandlers => event => {
|
|
398
408
|
otherHandlers.onChange?.(event);
|
|
399
|
-
//
|
|
400
|
-
|
|
401
|
-
changeValue(event, event.target.valueAsNumber);
|
|
409
|
+
// Handles value changes reported through the hidden range input.
|
|
410
|
+
changeValue(event, event.currentTarget.valueAsNumber);
|
|
402
411
|
};
|
|
403
|
-
const
|
|
412
|
+
const previousIndexRef = React.useRef(undefined);
|
|
404
413
|
let axis = orientation;
|
|
405
414
|
if (isRtl && orientation === 'horizontal') {
|
|
406
415
|
axis += '-reverse';
|
|
407
416
|
}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
417
|
+
|
|
418
|
+
// Converts finger coordinates to a slider value and determines the active thumb.
|
|
419
|
+
// For range sliders, reads `previousIndexRef.current` to decide which thumb is active:
|
|
420
|
+
// -1 = initial press → find closest thumb
|
|
421
|
+
// ≥0 = drag in progress → keep same thumb
|
|
422
|
+
// Callers must reset `previousIndexRef.current = -1` before calling on a new interaction.
|
|
423
|
+
const getValueAtFinger = finger => {
|
|
412
424
|
const {
|
|
413
425
|
current: slider
|
|
414
426
|
} = sliderRef;
|
|
427
|
+
if (!slider) {
|
|
428
|
+
return null;
|
|
429
|
+
}
|
|
415
430
|
const {
|
|
416
431
|
width,
|
|
417
432
|
height,
|
|
@@ -438,27 +453,20 @@ function useSlider(parameters) {
|
|
|
438
453
|
newValue = (0, _clamp.default)(newValue, min, max);
|
|
439
454
|
let activeIndex = 0;
|
|
440
455
|
if (range) {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
} else {
|
|
444
|
-
activeIndex = previousIndex.current;
|
|
445
|
-
}
|
|
456
|
+
const isDragging = previousIndexRef.current !== -1;
|
|
457
|
+
activeIndex = isDragging ? previousIndexRef.current : findClosest(values, newValue, lastUsedThumbIndexRef.current);
|
|
446
458
|
|
|
447
459
|
// Bound the new value to the thumb's neighbours.
|
|
448
460
|
if (disableSwap) {
|
|
449
461
|
newValue = (0, _clamp.default)(newValue, values[activeIndex - 1] || -Infinity, values[activeIndex + 1] || Infinity);
|
|
450
462
|
}
|
|
451
463
|
const previousValue = newValue;
|
|
452
|
-
newValue = setValueIndex(
|
|
453
|
-
values,
|
|
454
|
-
newValue,
|
|
455
|
-
index: activeIndex
|
|
456
|
-
});
|
|
464
|
+
newValue = setValueIndex(values, newValue, activeIndex);
|
|
457
465
|
|
|
458
466
|
// Potentially swap the index if needed.
|
|
459
|
-
if (!(disableSwap &&
|
|
467
|
+
if (!(disableSwap && isDragging)) {
|
|
460
468
|
activeIndex = newValue.indexOf(previousValue);
|
|
461
|
-
|
|
469
|
+
previousIndexRef.current = activeIndex;
|
|
462
470
|
}
|
|
463
471
|
}
|
|
464
472
|
return {
|
|
@@ -467,60 +475,61 @@ function useSlider(parameters) {
|
|
|
467
475
|
};
|
|
468
476
|
};
|
|
469
477
|
const handleTouchMove = (0, _useEventCallback.default)(nativeEvent => {
|
|
470
|
-
|
|
478
|
+
// Ignore pointer events from a different pointer than the one that started the drag.
|
|
479
|
+
if ('pointerId' in nativeEvent && nativeEvent.pointerId !== activePointerIdRef.current) {
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
const finger = trackFinger(nativeEvent, touchIdRef);
|
|
471
483
|
if (!finger) {
|
|
472
484
|
return;
|
|
473
485
|
}
|
|
474
|
-
|
|
486
|
+
moveCountRef.current += 1;
|
|
475
487
|
|
|
476
|
-
// Cancel move in case some other element consumed a
|
|
477
|
-
|
|
478
|
-
if (nativeEvent.type === 'mousemove' && nativeEvent.buttons === 0) {
|
|
488
|
+
// Cancel move in case some other element consumed a pointerup event and it was not fired.
|
|
489
|
+
if (nativeEvent.type === 'pointermove' && nativeEvent.buttons === 0) {
|
|
479
490
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
480
491
|
handleTouchEnd(nativeEvent);
|
|
481
492
|
return;
|
|
482
493
|
}
|
|
483
|
-
const
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
sliderRef,
|
|
492
|
-
activeIndex,
|
|
493
|
-
setActive,
|
|
494
|
-
focusVisible: false
|
|
495
|
-
});
|
|
496
|
-
setValueState(newValue);
|
|
497
|
-
if (!dragging && moveCount.current > INTENTIONAL_DRAG_COUNT_THRESHOLD) {
|
|
494
|
+
const newFingerValue = getValueAtFinger(finger);
|
|
495
|
+
if (!newFingerValue) {
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
focusThumb(sliderRef, newFingerValue.activeIndex, setActive, false);
|
|
499
|
+
lastUsedThumbIndexRef.current = newFingerValue.activeIndex;
|
|
500
|
+
setValueState(newFingerValue.newValue);
|
|
501
|
+
if (!dragging && moveCountRef.current > INTENTIONAL_DRAG_COUNT_THRESHOLD) {
|
|
498
502
|
setDragging(true);
|
|
499
503
|
}
|
|
500
|
-
if (
|
|
501
|
-
handleChange(nativeEvent, newValue, activeIndex);
|
|
504
|
+
if (onChange && !areValuesEqual(newFingerValue.newValue, valueDerived)) {
|
|
505
|
+
handleChange(nativeEvent, newFingerValue.newValue, newFingerValue.activeIndex);
|
|
502
506
|
}
|
|
503
507
|
});
|
|
504
508
|
const handleTouchEnd = (0, _useEventCallback.default)(nativeEvent => {
|
|
505
|
-
|
|
509
|
+
// Ignore pointer events from a different pointer than the one that started the drag.
|
|
510
|
+
if ('pointerId' in nativeEvent && nativeEvent.pointerId !== activePointerIdRef.current) {
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
const finger = trackFinger(nativeEvent, touchIdRef);
|
|
506
514
|
setDragging(false);
|
|
507
515
|
if (!finger) {
|
|
508
516
|
return;
|
|
509
517
|
}
|
|
510
|
-
const
|
|
511
|
-
newValue
|
|
512
|
-
} = getFingerNewValue({
|
|
513
|
-
finger,
|
|
514
|
-
move: true
|
|
515
|
-
});
|
|
518
|
+
const newFingerValue = getValueAtFinger(finger);
|
|
516
519
|
setActive(-1);
|
|
517
520
|
if (nativeEvent.type === 'touchend') {
|
|
518
521
|
setOpen(-1);
|
|
519
522
|
}
|
|
520
|
-
if (onChangeCommitted) {
|
|
521
|
-
onChangeCommitted(nativeEvent,
|
|
523
|
+
if (newFingerValue && onChangeCommitted) {
|
|
524
|
+
onChangeCommitted(nativeEvent, lastChangedValueRef.current ?? newFingerValue.newValue);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
// Release pointer capture if applicable
|
|
528
|
+
if ('pointerType' in nativeEvent && sliderRef.current?.hasPointerCapture(nativeEvent.pointerId)) {
|
|
529
|
+
sliderRef.current.releasePointerCapture(nativeEvent.pointerId);
|
|
522
530
|
}
|
|
523
|
-
|
|
531
|
+
touchIdRef.current = undefined;
|
|
532
|
+
activePointerIdRef.current = -1;
|
|
524
533
|
|
|
525
534
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
526
535
|
stopListening();
|
|
@@ -529,35 +538,36 @@ function useSlider(parameters) {
|
|
|
529
538
|
if (disabled) {
|
|
530
539
|
return;
|
|
531
540
|
}
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
541
|
+
|
|
542
|
+
// If the pointer path already handled this interaction,
|
|
543
|
+
// only record the touch identifier and skip duplicate listener registration.
|
|
544
|
+
if (pointerDownHandledRef.current) {
|
|
545
|
+
pointerDownHandledRef.current = false;
|
|
546
|
+
const touch = nativeEvent.changedTouches[0];
|
|
547
|
+
if (touch != null) {
|
|
548
|
+
touchIdRef.current = touch.identifier;
|
|
549
|
+
}
|
|
550
|
+
return;
|
|
535
551
|
}
|
|
536
552
|
const touch = nativeEvent.changedTouches[0];
|
|
537
553
|
if (touch != null) {
|
|
538
554
|
// A number that uniquely identifies the current finger in the touch session.
|
|
539
|
-
|
|
555
|
+
touchIdRef.current = touch.identifier;
|
|
540
556
|
}
|
|
541
|
-
const finger = trackFinger(nativeEvent,
|
|
557
|
+
const finger = trackFinger(nativeEvent, touchIdRef);
|
|
542
558
|
if (finger !== false) {
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
setActive,
|
|
553
|
-
focusVisible: false
|
|
554
|
-
});
|
|
555
|
-
setValueState(newValue);
|
|
556
|
-
if (handleChange && !areValuesEqual(newValue, valueDerived)) {
|
|
557
|
-
handleChange(nativeEvent, newValue, activeIndex);
|
|
559
|
+
previousIndexRef.current = -1;
|
|
560
|
+
const newFingerValue = getValueAtFinger(finger);
|
|
561
|
+
if (newFingerValue) {
|
|
562
|
+
focusThumb(sliderRef, newFingerValue.activeIndex, setActive, false);
|
|
563
|
+
lastUsedThumbIndexRef.current = newFingerValue.activeIndex;
|
|
564
|
+
setValueState(newFingerValue.newValue);
|
|
565
|
+
if (onChange && !areValuesEqual(newFingerValue.newValue, valueDerived)) {
|
|
566
|
+
handleChange(nativeEvent, newFingerValue.newValue, newFingerValue.activeIndex);
|
|
567
|
+
}
|
|
558
568
|
}
|
|
559
569
|
}
|
|
560
|
-
|
|
570
|
+
moveCountRef.current = 0;
|
|
561
571
|
const doc = (0, _ownerDocument.default)(sliderRef.current);
|
|
562
572
|
doc.addEventListener('touchmove', handleTouchMove, {
|
|
563
573
|
passive: true
|
|
@@ -568,17 +578,18 @@ function useSlider(parameters) {
|
|
|
568
578
|
});
|
|
569
579
|
const stopListening = React.useCallback(() => {
|
|
570
580
|
const doc = (0, _ownerDocument.default)(sliderRef.current);
|
|
571
|
-
doc.removeEventListener('
|
|
572
|
-
doc.removeEventListener('
|
|
581
|
+
doc.removeEventListener('pointermove', handleTouchMove);
|
|
582
|
+
doc.removeEventListener('pointerup', handleTouchEnd);
|
|
573
583
|
doc.removeEventListener('touchmove', handleTouchMove);
|
|
574
584
|
doc.removeEventListener('touchend', handleTouchEnd);
|
|
575
585
|
}, [handleTouchEnd, handleTouchMove]);
|
|
576
586
|
React.useEffect(() => {
|
|
577
|
-
const
|
|
578
|
-
|
|
579
|
-
|
|
587
|
+
const slider = sliderRef.current;
|
|
588
|
+
if (!slider) {
|
|
589
|
+
return undefined;
|
|
590
|
+
}
|
|
580
591
|
slider.addEventListener('touchstart', handleTouchStart, {
|
|
581
|
-
passive:
|
|
592
|
+
passive: true
|
|
582
593
|
});
|
|
583
594
|
return () => {
|
|
584
595
|
slider.removeEventListener('touchstart', handleTouchStart);
|
|
@@ -592,62 +603,67 @@ function useSlider(parameters) {
|
|
|
592
603
|
cancelFocusFrame();
|
|
593
604
|
}
|
|
594
605
|
}, [disabled, stopListening, cancelFocusFrame]);
|
|
595
|
-
const
|
|
596
|
-
otherHandlers.
|
|
597
|
-
if (disabled) {
|
|
598
|
-
return;
|
|
599
|
-
}
|
|
600
|
-
if (event.defaultPrevented) {
|
|
601
|
-
return;
|
|
602
|
-
}
|
|
606
|
+
const createHandlePointerDown = otherHandlers => event => {
|
|
607
|
+
otherHandlers.onPointerDown?.(event);
|
|
603
608
|
|
|
604
|
-
//
|
|
605
|
-
|
|
609
|
+
// On touch devices, the browser fires both pointerdown and touchstart for the
|
|
610
|
+
// same physical touch. Mark this BEFORE early returns so handleTouchStart always
|
|
611
|
+
// knows the pointer path saw this interaction — even if it was prevented or disabled.
|
|
612
|
+
if (event.pointerType === 'touch') {
|
|
613
|
+
pointerDownHandledRef.current = true;
|
|
614
|
+
}
|
|
615
|
+
if (disabled || event.defaultPrevented || event.button !== 0) {
|
|
606
616
|
return;
|
|
607
617
|
}
|
|
608
|
-
const finger = trackFinger(event,
|
|
618
|
+
const finger = trackFinger(event, touchIdRef);
|
|
609
619
|
if (finger !== false) {
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
focusFrame.current = null;
|
|
626
|
-
focusThumb({
|
|
627
|
-
sliderRef,
|
|
628
|
-
activeIndex,
|
|
629
|
-
focusVisible: false
|
|
620
|
+
previousIndexRef.current = -1;
|
|
621
|
+
const newFingerValue = getValueAtFinger(finger);
|
|
622
|
+
if (newFingerValue) {
|
|
623
|
+
const thumbInput = sliderRef.current?.querySelector(`input[type="range"][data-index="${newFingerValue.activeIndex}"]`);
|
|
624
|
+
const doc = (0, _ownerDocument.default)(sliderRef.current);
|
|
625
|
+
const pressedOnFocusedThumb = thumbInput != null && thumbInput === (0, _getActiveElement.default)(doc);
|
|
626
|
+
setActive(newFingerValue.activeIndex);
|
|
627
|
+
lastUsedThumbIndexRef.current = newFingerValue.activeIndex;
|
|
628
|
+
if (pressedOnFocusedThumb) {
|
|
629
|
+
event.preventDefault();
|
|
630
|
+
} else {
|
|
631
|
+
cancelFocusFrame();
|
|
632
|
+
focusFrameRef.current = requestAnimationFrame(() => {
|
|
633
|
+
focusFrameRef.current = null;
|
|
634
|
+
focusThumb(sliderRef, newFingerValue.activeIndex, undefined, false);
|
|
630
635
|
});
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
+
}
|
|
637
|
+
setValueState(newFingerValue.newValue);
|
|
638
|
+
if (onChange && !areValuesEqual(newFingerValue.newValue, valueDerived)) {
|
|
639
|
+
handleChange(event, newFingerValue.newValue, newFingerValue.activeIndex);
|
|
640
|
+
}
|
|
636
641
|
}
|
|
637
642
|
}
|
|
638
|
-
|
|
643
|
+
moveCountRef.current = 0;
|
|
644
|
+
activePointerIdRef.current = event.pointerId;
|
|
639
645
|
const doc = (0, _ownerDocument.default)(sliderRef.current);
|
|
640
|
-
|
|
646
|
+
|
|
647
|
+
// Use pointer capture for reliable drag tracking
|
|
648
|
+
try {
|
|
649
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
650
|
+
} catch {
|
|
651
|
+
// setPointerCapture can throw if the pointerId is invalid (e.g. synthetic
|
|
652
|
+
// events in tests, or the pointer was already released). The slider still
|
|
653
|
+
// works via document-level listeners; pointer capture is a progressive
|
|
654
|
+
// enhancement for reliable drag tracking.
|
|
655
|
+
}
|
|
656
|
+
doc.addEventListener('pointermove', handleTouchMove, {
|
|
641
657
|
passive: true
|
|
642
658
|
});
|
|
643
|
-
doc.addEventListener('
|
|
659
|
+
doc.addEventListener('pointerup', handleTouchEnd);
|
|
644
660
|
};
|
|
645
661
|
const trackOffset = valueToPercent(range ? values[0] : min, min, max);
|
|
646
662
|
const trackLeap = valueToPercent(values[values.length - 1], min, max) - trackOffset;
|
|
647
|
-
const getRootProps = (externalProps =
|
|
663
|
+
const getRootProps = (externalProps = EMPTY_OBJ) => {
|
|
648
664
|
const externalHandlers = (0, _extractEventHandlers.default)(externalProps);
|
|
649
665
|
const ownEventHandlers = {
|
|
650
|
-
|
|
666
|
+
onPointerDown: createHandlePointerDown(externalHandlers)
|
|
651
667
|
};
|
|
652
668
|
const mergedEventHandlers = {
|
|
653
669
|
...externalHandlers,
|
|
@@ -668,11 +684,11 @@ function useSlider(parameters) {
|
|
|
668
684
|
otherHandlers.onMouseLeave?.(event);
|
|
669
685
|
setOpen(-1);
|
|
670
686
|
};
|
|
671
|
-
const getThumbProps = (externalProps =
|
|
687
|
+
const getThumbProps = (externalProps = EMPTY_OBJ) => {
|
|
672
688
|
const externalHandlers = (0, _extractEventHandlers.default)(externalProps);
|
|
673
689
|
const ownEventHandlers = {
|
|
674
|
-
onMouseOver: createHandleMouseOver(externalHandlers
|
|
675
|
-
onMouseLeave: createHandleMouseLeave(externalHandlers
|
|
690
|
+
onMouseOver: createHandleMouseOver(externalHandlers),
|
|
691
|
+
onMouseLeave: createHandleMouseLeave(externalHandlers)
|
|
676
692
|
};
|
|
677
693
|
return {
|
|
678
694
|
...externalProps,
|
|
@@ -681,22 +697,33 @@ function useSlider(parameters) {
|
|
|
681
697
|
};
|
|
682
698
|
};
|
|
683
699
|
const getThumbStyle = index => {
|
|
700
|
+
let zIndex;
|
|
701
|
+
if (range) {
|
|
702
|
+
if (active === index) {
|
|
703
|
+
zIndex = 2;
|
|
704
|
+
} else if (lastUsedThumbIndexRef.current === index) {
|
|
705
|
+
zIndex = 1;
|
|
706
|
+
}
|
|
707
|
+
} else if (active === index) {
|
|
708
|
+
zIndex = 1;
|
|
709
|
+
}
|
|
684
710
|
return {
|
|
685
711
|
// So the non active thumb doesn't show its label on hover.
|
|
686
|
-
pointerEvents: active !== -1 && active !== index ? 'none' : undefined
|
|
712
|
+
pointerEvents: active !== -1 && active !== index ? 'none' : undefined,
|
|
713
|
+
zIndex
|
|
687
714
|
};
|
|
688
715
|
};
|
|
689
716
|
let cssWritingMode;
|
|
690
717
|
if (orientation === 'vertical') {
|
|
691
718
|
cssWritingMode = isRtl ? 'vertical-rl' : 'vertical-lr';
|
|
692
719
|
}
|
|
693
|
-
const getHiddenInputProps = (externalProps =
|
|
720
|
+
const getHiddenInputProps = (externalProps = EMPTY_OBJ) => {
|
|
694
721
|
const externalHandlers = (0, _extractEventHandlers.default)(externalProps);
|
|
695
722
|
const ownEventHandlers = {
|
|
696
|
-
onChange: createHandleHiddenInputChange(externalHandlers
|
|
697
|
-
onFocus: createHandleHiddenInputFocus(externalHandlers
|
|
698
|
-
onBlur: createHandleHiddenInputBlur(externalHandlers
|
|
699
|
-
onKeyDown: createHandleHiddenInputKeyDown(externalHandlers
|
|
723
|
+
onChange: createHandleHiddenInputChange(externalHandlers),
|
|
724
|
+
onFocus: createHandleHiddenInputFocus(externalHandlers),
|
|
725
|
+
onBlur: createHandleHiddenInputBlur(externalHandlers),
|
|
726
|
+
onKeyDown: createHandleHiddenInputKeyDown(externalHandlers)
|
|
700
727
|
};
|
|
701
728
|
const mergedEventHandlers = {
|
|
702
729
|
...externalHandlers,
|
|
@@ -735,7 +762,7 @@ function useSlider(parameters) {
|
|
|
735
762
|
getHiddenInputProps,
|
|
736
763
|
getRootProps,
|
|
737
764
|
getThumbProps,
|
|
738
|
-
marks
|
|
765
|
+
marks,
|
|
739
766
|
open,
|
|
740
767
|
range,
|
|
741
768
|
rootRef: handleRef,
|