UNPKG

25.1 kBJavaScriptView Raw
1"use strict";
2'use client';
3
4var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
6Object.defineProperty(exports, "__esModule", {
7 value: true
8});
9exports.default = void 0;
10exports.reset = reset;
11var React = _interopRequireWildcard(require("react"));
12var ReactDOM = _interopRequireWildcard(require("react-dom"));
13var _propTypes = _interopRequireDefault(require("prop-types"));
14var _elementTypeAcceptingRef = _interopRequireDefault(require("@mui/utils/elementTypeAcceptingRef"));
15var _NoSsr = _interopRequireDefault(require("../NoSsr"));
16var _Drawer = _interopRequireWildcard(require("../Drawer/Drawer"));
17var _useForkRef = _interopRequireDefault(require("../utils/useForkRef"));
18var _ownerDocument = _interopRequireDefault(require("../utils/ownerDocument"));
19var _ownerWindow = _interopRequireDefault(require("../utils/ownerWindow"));
20var _useEventCallback = _interopRequireDefault(require("../utils/useEventCallback"));
21var _useEnhancedEffect = _interopRequireDefault(require("../utils/useEnhancedEffect"));
22var _zeroStyled = require("../zero-styled");
23var _DefaultPropsProvider = require("../DefaultPropsProvider");
24var _utils = require("../transitions/utils");
25var _SwipeArea = _interopRequireDefault(require("./SwipeArea"));
26var _jsxRuntime = require("react/jsx-runtime");
27// This value is closed to what browsers are using internally to
28// trigger a native scroll.
29const UNCERTAINTY_THRESHOLD = 3; // px
30
31// This is the part of the drawer displayed on touch start.
32const DRAG_STARTED_SIGNAL = 20; // px
33
34// We can only have one instance at the time claiming ownership for handling the swipe.
35// Otherwise, the UX would be confusing.
36// That's why we use a singleton here.
37let claimedSwipeInstance = null;
38
39// Exported for test purposes.
40function reset() {
41 claimedSwipeInstance = null;
42}
43function calculateCurrentX(anchor, touches, doc) {
44 return anchor === 'right' ? doc.body.offsetWidth - touches[0].pageX : touches[0].pageX;
45}
46function calculateCurrentY(anchor, touches, containerWindow) {
47 return anchor === 'bottom' ? containerWindow.innerHeight - touches[0].clientY : touches[0].clientY;
48}
49function getMaxTranslate(horizontalSwipe, paperInstance) {
50 return horizontalSwipe ? paperInstance.clientWidth : paperInstance.clientHeight;
51}
52function getTranslate(currentTranslate, startLocation, open, maxTranslate) {
53 return Math.min(Math.max(open ? startLocation - currentTranslate : maxTranslate + startLocation - currentTranslate, 0), maxTranslate);
54}
55
56/**
57 * @param {Element | null} element
58 * @param {Element} rootNode
59 */
60function getDomTreeShapes(element, rootNode) {
61 // Adapted from https://github.com/oliviertassinari/react-swipeable-views/blob/7666de1dba253b896911adf2790ce51467670856/packages/react-swipeable-views/src/SwipeableViews.js#L129
62 const domTreeShapes = [];
63 while (element && element !== rootNode.parentElement) {
64 const style = (0, _ownerWindow.default)(rootNode).getComputedStyle(element);
65 if (
66 // Ignore the scroll children if the element is absolute positioned.
67 style.getPropertyValue('position') === 'absolute' ||
68 // Ignore the scroll children if the element has an overflowX hidden
69 style.getPropertyValue('overflow-x') === 'hidden') {
70 // noop
71 } else if (element.clientWidth > 0 && element.scrollWidth > element.clientWidth || element.clientHeight > 0 && element.scrollHeight > element.clientHeight) {
72 // Ignore the nodes that have no width.
73 // Keep elements with a scroll
74 domTreeShapes.push(element);
75 }
76 element = element.parentElement;
77 }
78 return domTreeShapes;
79}
80
81/**
82 * @param {object} param0
83 * @param {ReturnType<getDomTreeShapes>} param0.domTreeShapes
84 */
85function computeHasNativeHandler({
86 domTreeShapes,
87 start,
88 current,
89 anchor
90}) {
91 // Adapted from https://github.com/oliviertassinari/react-swipeable-views/blob/7666de1dba253b896911adf2790ce51467670856/packages/react-swipeable-views/src/SwipeableViews.js#L175
92 const axisProperties = {
93 scrollPosition: {
94 x: 'scrollLeft',
95 y: 'scrollTop'
96 },
97 scrollLength: {
98 x: 'scrollWidth',
99 y: 'scrollHeight'
100 },
101 clientLength: {
102 x: 'clientWidth',
103 y: 'clientHeight'
104 }
105 };
106 return domTreeShapes.some(shape => {
107 // Determine if we are going backward or forward.
108 let goingForward = current >= start;
109 if (anchor === 'top' || anchor === 'left') {
110 goingForward = !goingForward;
111 }
112 const axis = anchor === 'left' || anchor === 'right' ? 'x' : 'y';
113 const scrollPosition = Math.round(shape[axisProperties.scrollPosition[axis]]);
114 const areNotAtStart = scrollPosition > 0;
115 const areNotAtEnd = scrollPosition + shape[axisProperties.clientLength[axis]] < shape[axisProperties.scrollLength[axis]];
116 if (goingForward && areNotAtEnd || !goingForward && areNotAtStart) {
117 return true;
118 }
119 return false;
120 });
121}
122const iOS = typeof navigator !== 'undefined' && /iPad|iPhone|iPod/.test(navigator.userAgent);
123const SwipeableDrawer = /*#__PURE__*/React.forwardRef(function SwipeableDrawer(inProps, ref) {
124 const props = (0, _DefaultPropsProvider.useDefaultProps)({
125 name: 'MuiSwipeableDrawer',
126 props: inProps
127 });
128 const theme = (0, _zeroStyled.useTheme)();
129 const transitionDurationDefault = {
130 enter: theme.transitions.duration.enteringScreen,
131 exit: theme.transitions.duration.leavingScreen
132 };
133 const {
134 anchor = 'left',
135 disableBackdropTransition = false,
136 disableDiscovery = false,
137 disableSwipeToOpen = iOS,
138 hideBackdrop,
139 hysteresis = 0.52,
140 allowSwipeInChildren = false,
141 minFlingVelocity = 450,
142 ModalProps: {
143 BackdropProps,
144 ...ModalPropsProp
145 } = {},
146 onClose,
147 onOpen,
148 open = false,
149 PaperProps = {},
150 SwipeAreaProps,
151 swipeAreaWidth = 20,
152 transitionDuration = transitionDurationDefault,
153 variant = 'temporary',
154 // Mobile first.
155 ...other
156 } = props;
157 const [maybeSwiping, setMaybeSwiping] = React.useState(false);
158 const swipeInstance = React.useRef({
159 isSwiping: null
160 });
161 const swipeAreaRef = React.useRef();
162 const backdropRef = React.useRef();
163 const paperRef = React.useRef();
164 const handleRef = (0, _useForkRef.default)(PaperProps.ref, paperRef);
165 const touchDetected = React.useRef(false);
166
167 // Ref for transition duration based on / to match swipe speed
168 const calculatedDurationRef = React.useRef();
169
170 // Use a ref so the open value used is always up to date inside useCallback.
171 (0, _useEnhancedEffect.default)(() => {
172 calculatedDurationRef.current = null;
173 }, [open]);
174 const setPosition = React.useCallback((translate, options = {}) => {
175 const {
176 mode = null,
177 changeTransition = true
178 } = options;
179 const anchorRtl = (0, _Drawer.getAnchor)(theme, anchor);
180 const rtlTranslateMultiplier = ['right', 'bottom'].includes(anchorRtl) ? 1 : -1;
181 const horizontalSwipe = (0, _Drawer.isHorizontal)(anchor);
182 const transform = horizontalSwipe ? `translate(${rtlTranslateMultiplier * translate}px, 0)` : `translate(0, ${rtlTranslateMultiplier * translate}px)`;
183 const drawerStyle = paperRef.current.style;
184 drawerStyle.webkitTransform = transform;
185 drawerStyle.transform = transform;
186 let transition = '';
187 if (mode) {
188 transition = theme.transitions.create('all', (0, _utils.getTransitionProps)({
189 easing: undefined,
190 style: undefined,
191 timeout: transitionDuration
192 }, {
193 mode
194 }));
195 }
196 if (changeTransition) {
197 drawerStyle.webkitTransition = transition;
198 drawerStyle.transition = transition;
199 }
200 if (!disableBackdropTransition && !hideBackdrop) {
201 const backdropStyle = backdropRef.current.style;
202 backdropStyle.opacity = 1 - translate / getMaxTranslate(horizontalSwipe, paperRef.current);
203 if (changeTransition) {
204 backdropStyle.webkitTransition = transition;
205 backdropStyle.transition = transition;
206 }
207 }
208 }, [anchor, disableBackdropTransition, hideBackdrop, theme, transitionDuration]);
209 const handleBodyTouchEnd = (0, _useEventCallback.default)(nativeEvent => {
210 if (!touchDetected.current) {
211 return;
212 }
213 // TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- claimedSwipeInstance is a singleton
214 claimedSwipeInstance = null;
215 touchDetected.current = false;
216 ReactDOM.flushSync(() => {
217 setMaybeSwiping(false);
218 });
219
220 // The swipe wasn't started.
221 if (!swipeInstance.current.isSwiping) {
222 swipeInstance.current.isSwiping = null;
223 return;
224 }
225 swipeInstance.current.isSwiping = null;
226 const anchorRtl = (0, _Drawer.getAnchor)(theme, anchor);
227 const horizontal = (0, _Drawer.isHorizontal)(anchor);
228 let current;
229 if (horizontal) {
230 current = calculateCurrentX(anchorRtl, nativeEvent.changedTouches, (0, _ownerDocument.default)(nativeEvent.currentTarget));
231 } else {
232 current = calculateCurrentY(anchorRtl, nativeEvent.changedTouches, (0, _ownerWindow.default)(nativeEvent.currentTarget));
233 }
234 const startLocation = horizontal ? swipeInstance.current.startX : swipeInstance.current.startY;
235 const maxTranslate = getMaxTranslate(horizontal, paperRef.current);
236 const currentTranslate = getTranslate(current, startLocation, open, maxTranslate);
237 const translateRatio = currentTranslate / maxTranslate;
238 if (Math.abs(swipeInstance.current.velocity) > minFlingVelocity) {
239 // Calculate transition duration to match swipe speed
240 calculatedDurationRef.current = Math.abs((maxTranslate - currentTranslate) / swipeInstance.current.velocity) * 1000;
241 }
242 if (open) {
243 if (swipeInstance.current.velocity > minFlingVelocity || translateRatio > hysteresis) {
244 onClose();
245 } else {
246 // Reset the position, the swipe was aborted.
247 setPosition(0, {
248 mode: 'exit'
249 });
250 }
251 return;
252 }
253 if (swipeInstance.current.velocity < -minFlingVelocity || 1 - translateRatio > hysteresis) {
254 onOpen();
255 } else {
256 // Reset the position, the swipe was aborted.
257 setPosition(getMaxTranslate(horizontal, paperRef.current), {
258 mode: 'enter'
259 });
260 }
261 });
262 const startMaybeSwiping = (force = false) => {
263 if (!maybeSwiping) {
264 // 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.
265 // this is because Safari Mobile will not fire any mouse events (still fires touch though) if the DOM changes during mousemove.
266 // so do this change on first touchmove instead of touchstart
267 if (force || !(disableDiscovery && allowSwipeInChildren)) {
268 ReactDOM.flushSync(() => {
269 setMaybeSwiping(true);
270 });
271 }
272 const horizontalSwipe = (0, _Drawer.isHorizontal)(anchor);
273 if (!open && paperRef.current) {
274 // The ref may be null when a parent component updates while swiping.
275 setPosition(getMaxTranslate(horizontalSwipe, paperRef.current) + (disableDiscovery ? 15 : -DRAG_STARTED_SIGNAL), {
276 changeTransition: false
277 });
278 }
279 swipeInstance.current.velocity = 0;
280 swipeInstance.current.lastTime = null;
281 swipeInstance.current.lastTranslate = null;
282 swipeInstance.current.paperHit = false;
283 touchDetected.current = true;
284 }
285 };
286 const handleBodyTouchMove = (0, _useEventCallback.default)(nativeEvent => {
287 // the ref may be null when a parent component updates while swiping
288 if (!paperRef.current || !touchDetected.current) {
289 return;
290 }
291
292 // We are not supposed to handle this touch move because the swipe was started in a scrollable container in the drawer
293 if (claimedSwipeInstance !== null && claimedSwipeInstance !== swipeInstance.current) {
294 return;
295 }
296 startMaybeSwiping(true);
297 const anchorRtl = (0, _Drawer.getAnchor)(theme, anchor);
298 const horizontalSwipe = (0, _Drawer.isHorizontal)(anchor);
299 const currentX = calculateCurrentX(anchorRtl, nativeEvent.touches, (0, _ownerDocument.default)(nativeEvent.currentTarget));
300 const currentY = calculateCurrentY(anchorRtl, nativeEvent.touches, (0, _ownerWindow.default)(nativeEvent.currentTarget));
301 if (open && paperRef.current.contains(nativeEvent.target) && claimedSwipeInstance === null) {
302 const domTreeShapes = getDomTreeShapes(nativeEvent.target, paperRef.current);
303 const hasNativeHandler = computeHasNativeHandler({
304 domTreeShapes,
305 start: horizontalSwipe ? swipeInstance.current.startX : swipeInstance.current.startY,
306 current: horizontalSwipe ? currentX : currentY,
307 anchor
308 });
309 if (hasNativeHandler) {
310 claimedSwipeInstance = true;
311 return;
312 }
313 claimedSwipeInstance = swipeInstance.current;
314 }
315
316 // We don't know yet.
317 if (swipeInstance.current.isSwiping == null) {
318 const dx = Math.abs(currentX - swipeInstance.current.startX);
319 const dy = Math.abs(currentY - swipeInstance.current.startY);
320 const definitelySwiping = horizontalSwipe ? dx > dy && dx > UNCERTAINTY_THRESHOLD : dy > dx && dy > UNCERTAINTY_THRESHOLD;
321 if (definitelySwiping && nativeEvent.cancelable) {
322 nativeEvent.preventDefault();
323 }
324 if (definitelySwiping === true || (horizontalSwipe ? dy > UNCERTAINTY_THRESHOLD : dx > UNCERTAINTY_THRESHOLD)) {
325 swipeInstance.current.isSwiping = definitelySwiping;
326 if (!definitelySwiping) {
327 handleBodyTouchEnd(nativeEvent);
328 return;
329 }
330
331 // Shift the starting point.
332 swipeInstance.current.startX = currentX;
333 swipeInstance.current.startY = currentY;
334
335 // Compensate for the part of the drawer displayed on touch start.
336 if (!disableDiscovery && !open) {
337 if (horizontalSwipe) {
338 swipeInstance.current.startX -= DRAG_STARTED_SIGNAL;
339 } else {
340 swipeInstance.current.startY -= DRAG_STARTED_SIGNAL;
341 }
342 }
343 }
344 }
345 if (!swipeInstance.current.isSwiping) {
346 return;
347 }
348 const maxTranslate = getMaxTranslate(horizontalSwipe, paperRef.current);
349 let startLocation = horizontalSwipe ? swipeInstance.current.startX : swipeInstance.current.startY;
350 if (open && !swipeInstance.current.paperHit) {
351 startLocation = Math.min(startLocation, maxTranslate);
352 }
353 const translate = getTranslate(horizontalSwipe ? currentX : currentY, startLocation, open, maxTranslate);
354 if (open) {
355 if (!swipeInstance.current.paperHit) {
356 const paperHit = horizontalSwipe ? currentX < maxTranslate : currentY < maxTranslate;
357 if (paperHit) {
358 swipeInstance.current.paperHit = true;
359 swipeInstance.current.startX = currentX;
360 swipeInstance.current.startY = currentY;
361 } else {
362 return;
363 }
364 } else if (translate === 0) {
365 swipeInstance.current.startX = currentX;
366 swipeInstance.current.startY = currentY;
367 }
368 }
369 if (swipeInstance.current.lastTranslate === null) {
370 swipeInstance.current.lastTranslate = translate;
371 swipeInstance.current.lastTime = performance.now() + 1;
372 }
373 const velocity = (translate - swipeInstance.current.lastTranslate) / (performance.now() - swipeInstance.current.lastTime) * 1e3;
374
375 // Low Pass filter.
376 swipeInstance.current.velocity = swipeInstance.current.velocity * 0.4 + velocity * 0.6;
377 swipeInstance.current.lastTranslate = translate;
378 swipeInstance.current.lastTime = performance.now();
379
380 // We are swiping, let's prevent the scroll event on iOS.
381 if (nativeEvent.cancelable) {
382 nativeEvent.preventDefault();
383 }
384 setPosition(translate);
385 });
386 const handleBodyTouchStart = (0, _useEventCallback.default)(nativeEvent => {
387 // We are not supposed to handle this touch move.
388 // Example of use case: ignore the event if there is a Slider.
389 if (nativeEvent.defaultPrevented) {
390 return;
391 }
392
393 // We can only have one node at the time claiming ownership for handling the swipe.
394 if (nativeEvent.defaultMuiPrevented) {
395 return;
396 }
397
398 // At least one element clogs the drawer interaction zone.
399 if (open && (hideBackdrop || !backdropRef.current.contains(nativeEvent.target)) && !paperRef.current.contains(nativeEvent.target)) {
400 return;
401 }
402 const anchorRtl = (0, _Drawer.getAnchor)(theme, anchor);
403 const horizontalSwipe = (0, _Drawer.isHorizontal)(anchor);
404 const currentX = calculateCurrentX(anchorRtl, nativeEvent.touches, (0, _ownerDocument.default)(nativeEvent.currentTarget));
405 const currentY = calculateCurrentY(anchorRtl, nativeEvent.touches, (0, _ownerWindow.default)(nativeEvent.currentTarget));
406 if (!open) {
407 // logic for if swipe should be ignored:
408 // if disableSwipeToOpen
409 // if target != swipeArea, and target is not a child of paper ref
410 // if is a child of paper ref, and `allowSwipeInChildren` does not allow it
411 if (disableSwipeToOpen || !(nativeEvent.target === swipeAreaRef.current || paperRef.current?.contains(nativeEvent.target) && (typeof allowSwipeInChildren === 'function' ? allowSwipeInChildren(nativeEvent, swipeAreaRef.current, paperRef.current) : allowSwipeInChildren))) {
412 return;
413 }
414 if (horizontalSwipe) {
415 if (currentX > swipeAreaWidth) {
416 return;
417 }
418 } else if (currentY > swipeAreaWidth) {
419 return;
420 }
421 }
422 nativeEvent.defaultMuiPrevented = true;
423 claimedSwipeInstance = null;
424 swipeInstance.current.startX = currentX;
425 swipeInstance.current.startY = currentY;
426 startMaybeSwiping();
427 });
428 React.useEffect(() => {
429 if (variant === 'temporary') {
430 const doc = (0, _ownerDocument.default)(paperRef.current);
431 doc.addEventListener('touchstart', handleBodyTouchStart);
432 // A blocking listener prevents Firefox's navbar to auto-hide on scroll.
433 // It only needs to prevent scrolling on the drawer's content when open.
434 // When closed, the overlay prevents scrolling.
435 doc.addEventListener('touchmove', handleBodyTouchMove, {
436 passive: !open
437 });
438 doc.addEventListener('touchend', handleBodyTouchEnd);
439 return () => {
440 doc.removeEventListener('touchstart', handleBodyTouchStart);
441 doc.removeEventListener('touchmove', handleBodyTouchMove, {
442 passive: !open
443 });
444 doc.removeEventListener('touchend', handleBodyTouchEnd);
445 };
446 }
447 return undefined;
448 }, [variant, open, handleBodyTouchStart, handleBodyTouchMove, handleBodyTouchEnd]);
449 React.useEffect(() => () => {
450 // We need to release the lock.
451 if (claimedSwipeInstance === swipeInstance.current) {
452 claimedSwipeInstance = null;
453 }
454 }, []);
455 React.useEffect(() => {
456 if (!open) {
457 setMaybeSwiping(false);
458 }
459 }, [open]);
460 return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
461 children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Drawer.default, {
462 open: variant === 'temporary' && maybeSwiping ? true : open,
463 variant: variant,
464 ModalProps: {
465 BackdropProps: {
466 ...BackdropProps,
467 ref: backdropRef
468 },
469 // Ensures that paperRef.current will be defined inside the touch start event handler
470 // See https://github.com/mui/material-ui/issues/30414 for more information
471 ...(variant === 'temporary' && {
472 keepMounted: true
473 }),
474 ...ModalPropsProp
475 },
476 hideBackdrop: hideBackdrop,
477 PaperProps: {
478 ...PaperProps,
479 style: {
480 pointerEvents: variant === 'temporary' && !open && !allowSwipeInChildren ? 'none' : '',
481 ...PaperProps.style
482 },
483 ref: handleRef
484 },
485 anchor: anchor,
486 transitionDuration: calculatedDurationRef.current || transitionDuration,
487 onClose: onClose,
488 ref: ref,
489 ...other
490 }), !disableSwipeToOpen && variant === 'temporary' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_NoSsr.default, {
491 children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_SwipeArea.default, {
492 anchor: anchor,
493 ref: swipeAreaRef,
494 width: swipeAreaWidth,
495 ...SwipeAreaProps
496 })
497 })]
498 });
499});
500process.env.NODE_ENV !== "production" ? SwipeableDrawer.propTypes /* remove-proptypes */ = {
501 // ┌────────────────────────────── Warning ──────────────────────────────┐
502 // │ These PropTypes are generated from the TypeScript type definitions. │
503 // │ To update them, edit the d.ts file and run `pnpm proptypes`. │
504 // └─────────────────────────────────────────────────────────────────────┘
505 /**
506 * 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.
507 * This can be useful in scenarios where the drawer is partially visible.
508 * You can customize it further with a callback that determines which children the user can drag over to open the drawer
509 * (for example, to ignore other elements that handle touch move events, like sliders).
510 *
511 * @param {TouchEvent} event The 'touchstart' event
512 * @param {HTMLDivElement} swipeArea The swipe area element
513 * @param {HTMLDivElement} paper The drawer's paper element
514 *
515 * @default false
516 */
517 allowSwipeInChildren: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.bool]),
518 /**
519 * @ignore
520 */
521 anchor: _propTypes.default.oneOf(['bottom', 'left', 'right', 'top']),
522 /**
523 * The content of the component.
524 */
525 children: _propTypes.default.node,
526 /**
527 * Disable the backdrop transition.
528 * This can improve the FPS on low-end devices.
529 * @default false
530 */
531 disableBackdropTransition: _propTypes.default.bool,
532 /**
533 * If `true`, touching the screen near the edge of the drawer will not slide in the drawer a bit
534 * to promote accidental discovery of the swipe gesture.
535 * @default false
536 */
537 disableDiscovery: _propTypes.default.bool,
538 /**
539 * If `true`, swipe to open is disabled. This is useful in browsers where swiping triggers
540 * navigation actions. Swipe to open is disabled on iOS browsers by default.
541 * @default typeof navigator !== 'undefined' && /iPad|iPhone|iPod/.test(navigator.userAgent)
542 */
543 disableSwipeToOpen: _propTypes.default.bool,
544 /**
545 * @ignore
546 */
547 hideBackdrop: _propTypes.default.bool,
548 /**
549 * Affects how far the drawer must be opened/closed to change its state.
550 * Specified as percent (0-1) of the width of the drawer
551 * @default 0.52
552 */
553 hysteresis: _propTypes.default.number,
554 /**
555 * Defines, from which (average) velocity on, the swipe is
556 * defined as complete although hysteresis isn't reached.
557 * Good threshold is between 250 - 1000 px/s
558 * @default 450
559 */
560 minFlingVelocity: _propTypes.default.number,
561 /**
562 * @ignore
563 */
564 ModalProps: _propTypes.default /* @typescript-to-proptypes-ignore */.shape({
565 BackdropProps: _propTypes.default.shape({
566 component: _elementTypeAcceptingRef.default
567 })
568 }),
569 /**
570 * Callback fired when the component requests to be closed.
571 *
572 * @param {React.SyntheticEvent<{}>} event The event source of the callback.
573 */
574 onClose: _propTypes.default.func.isRequired,
575 /**
576 * Callback fired when the component requests to be opened.
577 *
578 * @param {React.SyntheticEvent<{}>} event The event source of the callback.
579 */
580 onOpen: _propTypes.default.func.isRequired,
581 /**
582 * If `true`, the component is shown.
583 * @default false
584 */
585 open: _propTypes.default.bool,
586 /**
587 * @ignore
588 */
589 PaperProps: _propTypes.default /* @typescript-to-proptypes-ignore */.shape({
590 component: _elementTypeAcceptingRef.default,
591 style: _propTypes.default.object
592 }),
593 /**
594 * The element is used to intercept the touch events on the edge.
595 */
596 SwipeAreaProps: _propTypes.default.object,
597 /**
598 * The width of the left most (or right most) area in `px` that
599 * the drawer can be swiped open from.
600 * @default 20
601 */
602 swipeAreaWidth: _propTypes.default.number,
603 /**
604 * The duration for the transition, in milliseconds.
605 * You may specify a single timeout for all transitions, or individually with an object.
606 * @default {
607 * enter: theme.transitions.duration.enteringScreen,
608 * exit: theme.transitions.duration.leavingScreen,
609 * }
610 */
611 transitionDuration: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.shape({
612 appear: _propTypes.default.number,
613 enter: _propTypes.default.number,
614 exit: _propTypes.default.number
615 })]),
616 /**
617 * @ignore
618 */
619 variant: _propTypes.default.oneOf(['permanent', 'persistent', 'temporary'])
620} : void 0;
621var _default = exports.default = SwipeableDrawer;
\No newline at end of file