@mui/material 9.0.0-beta.1 → 9.0.0

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