@mui/material 5.11.4 → 5.11.6

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 (53) hide show
  1. package/Autocomplete/Autocomplete.d.ts +3 -3
  2. package/Box/Box.d.ts +6 -22
  3. package/Button/Button.js +0 -2
  4. package/CHANGELOG.md +132 -0
  5. package/Slider/Slider.d.ts +215 -36
  6. package/Slider/Slider.js +225 -66
  7. package/Slider/SliderValueLabel.d.ts +15 -0
  8. package/Slider/SliderValueLabel.js +52 -0
  9. package/Slider/SliderValueLabel.types.d.ts +24 -0
  10. package/Slider/SliderValueLabel.types.js +1 -0
  11. package/Slider/index.d.ts +3 -0
  12. package/Slider/index.js +3 -1
  13. package/Slider/sliderClasses.d.ts +58 -0
  14. package/Slider/sliderClasses.js +7 -0
  15. package/SwipeableDrawer/SwipeableDrawer.d.ts +15 -0
  16. package/SwipeableDrawer/SwipeableDrawer.js +48 -17
  17. package/index.js +1 -1
  18. package/legacy/Button/Button.js +0 -2
  19. package/legacy/Slider/Slider.js +253 -74
  20. package/legacy/Slider/SliderValueLabel.js +48 -0
  21. package/legacy/Slider/SliderValueLabel.types.js +1 -0
  22. package/legacy/Slider/index.js +3 -1
  23. package/legacy/Slider/sliderClasses.js +7 -0
  24. package/legacy/SwipeableDrawer/SwipeableDrawer.js +50 -17
  25. package/legacy/index.js +1 -1
  26. package/legacy/locale/index.js +230 -144
  27. package/legacy/styles/experimental_extendTheme.js +16 -8
  28. package/locale/index.d.ts +1 -0
  29. package/locale/index.js +85 -0
  30. package/modern/Button/Button.js +0 -2
  31. package/modern/Slider/Slider.js +224 -65
  32. package/modern/Slider/SliderValueLabel.js +52 -0
  33. package/modern/Slider/SliderValueLabel.types.js +1 -0
  34. package/modern/Slider/index.js +3 -1
  35. package/modern/Slider/sliderClasses.js +7 -0
  36. package/modern/SwipeableDrawer/SwipeableDrawer.js +47 -17
  37. package/modern/index.js +1 -1
  38. package/modern/locale/index.js +85 -0
  39. package/modern/styles/experimental_extendTheme.js +16 -8
  40. package/node/Button/Button.js +0 -2
  41. package/node/Slider/Slider.js +231 -74
  42. package/node/Slider/SliderValueLabel.js +60 -0
  43. package/node/Slider/SliderValueLabel.types.js +5 -0
  44. package/node/Slider/index.js +21 -1
  45. package/node/Slider/sliderClasses.js +16 -0
  46. package/node/SwipeableDrawer/SwipeableDrawer.js +48 -17
  47. package/node/index.js +1 -1
  48. package/node/locale/index.js +87 -1
  49. package/node/styles/experimental_extendTheme.js +16 -8
  50. package/package.json +4 -4
  51. package/styles/experimental_extendTheme.js +16 -8
  52. package/umd/material-ui.development.js +556 -799
  53. package/umd/material-ui.production.min.js +21 -21
@@ -134,6 +134,8 @@ var SwipeableDrawer = /*#__PURE__*/React.forwardRef(function SwipeableDrawer(inP
134
134
  hideBackdrop = props.hideBackdrop,
135
135
  _props$hysteresis = props.hysteresis,
136
136
  hysteresis = _props$hysteresis === void 0 ? 0.52 : _props$hysteresis,
137
+ _props$allowSwipeInCh = props.allowSwipeInChildren,
138
+ allowSwipeInChildren = _props$allowSwipeInCh === void 0 ? false : _props$allowSwipeInCh,
137
139
  _props$minFlingVeloci = props.minFlingVelocity,
138
140
  minFlingVelocity = _props$minFlingVeloci === void 0 ? 450 : _props$minFlingVeloci,
139
141
  _props$ModalProps = props.ModalProps;
@@ -153,7 +155,7 @@ var SwipeableDrawer = /*#__PURE__*/React.forwardRef(function SwipeableDrawer(inP
153
155
  transitionDuration = _props$transitionDura === void 0 ? transitionDurationDefault : _props$transitionDura,
154
156
  _props$variant = props.variant,
155
157
  variant = _props$variant === void 0 ? 'temporary' : _props$variant,
156
- other = _objectWithoutProperties(props, ["anchor", "disableBackdropTransition", "disableDiscovery", "disableSwipeToOpen", "hideBackdrop", "hysteresis", "minFlingVelocity", "ModalProps", "onClose", "onOpen", "open", "PaperProps", "SwipeAreaProps", "swipeAreaWidth", "transitionDuration", "variant"]);
158
+ other = _objectWithoutProperties(props, ["anchor", "disableBackdropTransition", "disableDiscovery", "disableSwipeToOpen", "hideBackdrop", "hysteresis", "allowSwipeInChildren", "minFlingVelocity", "ModalProps", "onClose", "onOpen", "open", "PaperProps", "SwipeAreaProps", "swipeAreaWidth", "transitionDuration", "variant"]);
157
159
  var _React$useState = React.useState(false),
158
160
  maybeSwiping = _React$useState[0],
159
161
  setMaybeSwiping = _React$useState[1];
@@ -261,6 +263,31 @@ var SwipeableDrawer = /*#__PURE__*/React.forwardRef(function SwipeableDrawer(inP
261
263
  });
262
264
  }
263
265
  });
266
+ var startMaybeSwiping = function startMaybeSwiping() {
267
+ var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
268
+ if (!maybeSwiping) {
269
+ // on Safari Mobile, if you want to be able to have the 'click' event fired on child elements, nothing in the DOM can be changed.
270
+ // this is because Safari Mobile will not fire any mouse events (still fires touch though) if the DOM changes during mousemove.
271
+ // so do this change on first touchmove instead of touchstart
272
+ if (force || !(disableDiscovery && allowSwipeInChildren)) {
273
+ flushSync(function () {
274
+ setMaybeSwiping(true);
275
+ });
276
+ }
277
+ var horizontalSwipe = isHorizontal(anchor);
278
+ if (!open && paperRef.current) {
279
+ // The ref may be null when a parent component updates while swiping.
280
+ setPosition(getMaxTranslate(horizontalSwipe, paperRef.current) + (disableDiscovery ? 15 : -DRAG_STARTED_SIGNAL), {
281
+ changeTransition: false
282
+ });
283
+ }
284
+ swipeInstance.current.velocity = 0;
285
+ swipeInstance.current.lastTime = null;
286
+ swipeInstance.current.lastTranslate = null;
287
+ swipeInstance.current.paperHit = false;
288
+ touchDetected.current = true;
289
+ }
290
+ };
264
291
  var handleBodyTouchMove = useEventCallback(function (nativeEvent) {
265
292
  // the ref may be null when a parent component updates while swiping
266
293
  if (!paperRef.current || !touchDetected.current) {
@@ -271,6 +298,7 @@ var SwipeableDrawer = /*#__PURE__*/React.forwardRef(function SwipeableDrawer(inP
271
298
  if (claimedSwipeInstance !== null && claimedSwipeInstance !== swipeInstance.current) {
272
299
  return;
273
300
  }
301
+ startMaybeSwiping(true);
274
302
  var anchorRtl = getAnchor(theme, anchor);
275
303
  var horizontalSwipe = isHorizontal(anchor);
276
304
  var currentX = calculateCurrentX(anchorRtl, nativeEvent.touches, ownerDocument(nativeEvent.currentTarget));
@@ -381,7 +409,12 @@ var SwipeableDrawer = /*#__PURE__*/React.forwardRef(function SwipeableDrawer(inP
381
409
  var currentX = calculateCurrentX(anchorRtl, nativeEvent.touches, ownerDocument(nativeEvent.currentTarget));
382
410
  var currentY = calculateCurrentY(anchorRtl, nativeEvent.touches, ownerWindow(nativeEvent.currentTarget));
383
411
  if (!open) {
384
- if (disableSwipeToOpen || nativeEvent.target !== swipeAreaRef.current) {
412
+ var _paperRef$current;
413
+ // logic for if swipe should be ignored:
414
+ // if disableSwipeToOpen
415
+ // if target != swipeArea, and target is not a child of paper ref
416
+ // if is a child of paper ref, and `allowSwipeInChildren` does not allow it
417
+ if (disableSwipeToOpen || !(nativeEvent.target === swipeAreaRef.current || (_paperRef$current = paperRef.current) != null && _paperRef$current.contains(nativeEvent.target) && (typeof allowSwipeInChildren === 'function' ? allowSwipeInChildren(nativeEvent, swipeAreaRef.current, paperRef.current) : allowSwipeInChildren))) {
385
418
  return;
386
419
  }
387
420
  if (horizontalSwipe) {
@@ -396,20 +429,7 @@ var SwipeableDrawer = /*#__PURE__*/React.forwardRef(function SwipeableDrawer(inP
396
429
  claimedSwipeInstance = null;
397
430
  swipeInstance.current.startX = currentX;
398
431
  swipeInstance.current.startY = currentY;
399
- flushSync(function () {
400
- setMaybeSwiping(true);
401
- });
402
- if (!open && paperRef.current) {
403
- // The ref may be null when a parent component updates while swiping.
404
- setPosition(getMaxTranslate(horizontalSwipe, paperRef.current) + (disableDiscovery ? 15 : -DRAG_STARTED_SIGNAL), {
405
- changeTransition: false
406
- });
407
- }
408
- swipeInstance.current.velocity = 0;
409
- swipeInstance.current.lastTime = null;
410
- swipeInstance.current.lastTranslate = null;
411
- swipeInstance.current.paperHit = false;
412
- touchDetected.current = true;
432
+ startMaybeSwiping();
413
433
  });
414
434
  React.useEffect(function () {
415
435
  if (variant === 'temporary') {
@@ -459,7 +479,7 @@ var SwipeableDrawer = /*#__PURE__*/React.forwardRef(function SwipeableDrawer(inP
459
479
  hideBackdrop: hideBackdrop,
460
480
  PaperProps: _extends({}, PaperProps, {
461
481
  style: _extends({
462
- pointerEvents: variant === 'temporary' && !open ? 'none' : ''
482
+ pointerEvents: variant === 'temporary' && !open && !allowSwipeInChildren ? 'none' : ''
463
483
  }, PaperProps.style),
464
484
  ref: handleRef
465
485
  }),
@@ -481,6 +501,19 @@ process.env.NODE_ENV !== "production" ? SwipeableDrawer.propTypes /* remove-prop
481
501
  // | These PropTypes are generated from the TypeScript type definitions |
482
502
  // | To update them edit the d.ts file and run "yarn proptypes" |
483
503
  // ----------------------------------------------------------------------
504
+ /**
505
+ * If set to true, the swipe event will open the drawer even if the user begins the swipe on one of the drawer's children.
506
+ * This can be useful in scenarios where the drawer is partially visible.
507
+ * You can customize it further with a callback that determines which children the user can drag over to open the drawer
508
+ * (for example, to ignore other elements that handle touch move events, like sliders).
509
+ *
510
+ * @param {TouchEvent} event The 'touchstart' event
511
+ * @param {HTMLDivElement} swipeArea The swipe area element
512
+ * @param {HTMLDivElement} paper The drawer's paper element
513
+ *
514
+ * @default false
515
+ */
516
+ allowSwipeInChildren: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
484
517
  /**
485
518
  * @ignore
486
519
  */
package/legacy/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/material v5.11.4
2
+ * @mui/material v5.11.6
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the