react-modal-sheet 1.8.1 → 1.10.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.
- package/dist/SheetBackdrop.d.ts +3 -1
- package/dist/SheetContainer.d.ts +3 -1
- package/dist/SheetContent.d.ts +3 -1
- package/dist/SheetHeader.d.ts +3 -1
- package/dist/react-modal-sheet.cjs.development.js +260 -13
- package/dist/react-modal-sheet.cjs.development.js.map +1 -1
- package/dist/react-modal-sheet.cjs.production.min.js +1 -1
- package/dist/react-modal-sheet.cjs.production.min.js.map +1 -1
- package/dist/react-modal-sheet.esm.js +258 -9
- package/dist/react-modal-sheet.esm.js.map +1 -1
- package/dist/sheet.d.ts +1 -1
- package/dist/types.d.ts +9 -5
- package/dist/use-prevent-scroll.d.ts +11 -0
- package/package.json +14 -15
- package/src/SheetBackdrop.tsx +2 -2
- package/src/SheetContainer.tsx +3 -3
- package/src/SheetContent.tsx +2 -2
- package/src/sheet.tsx +2 -1
- package/src/styles.ts +1 -0
- package/src/types.tsx +10 -5
- package/src/use-prevent-scroll.ts +303 -0
package/dist/SheetBackdrop.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
declare const SheetBackdrop: React.ForwardRefExoticComponent<Pick<import("framer-motion").MotionProps
|
|
2
|
+
declare const SheetBackdrop: React.ForwardRefExoticComponent<Pick<import("framer-motion").MotionProps & {
|
|
3
|
+
className?: string | undefined;
|
|
4
|
+
}, "style" | "transformTemplate" | "transformValues" | "children" | "variants" | "transition" | "onBeforeLayoutMeasure" | "onLayoutMeasure" | "onUpdate" | "onAnimationStart" | "onAnimationComplete" | "onPan" | "onPanStart" | "onPanSessionStart" | "onPanEnd" | "onTap" | "onTapStart" | "onTapCancel" | "whileTap" | "whileHover" | "onHoverStart" | "onHoverEnd" | "whileFocus" | "whileInView" | "onViewportEnter" | "onViewportLeave" | "viewport" | "drag" | "whileDrag" | "dragDirectionLock" | "dragPropagation" | "dragConstraints" | "dragElastic" | "dragMomentum" | "dragTransition" | "dragControls" | "dragSnapToOrigin" | "dragListener" | "onMeasureDragConstraints" | "_dragX" | "_dragY" | "onDragStart" | "onDragEnd" | "onDrag" | "onDirectionLock" | "onDragTransitionEnd" | "layout" | "layoutId" | "onLayoutAnimationStart" | "onLayoutAnimationComplete" | "layoutDependency" | "layoutScroll" | "custom" | "inherit" | "className"> & React.RefAttributes<any>>;
|
|
3
5
|
export default SheetBackdrop;
|
package/dist/SheetContainer.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
declare const SheetContainer: React.ForwardRefExoticComponent<Pick<import("framer-motion").MotionProps
|
|
2
|
+
declare const SheetContainer: React.ForwardRefExoticComponent<Pick<import("framer-motion").MotionProps & {
|
|
3
|
+
className?: string | undefined;
|
|
4
|
+
}, "style" | "transformTemplate" | "transformValues" | "children" | "variants" | "transition" | "onBeforeLayoutMeasure" | "onLayoutMeasure" | "onUpdate" | "onAnimationStart" | "onPan" | "onPanStart" | "onPanSessionStart" | "onPanEnd" | "onTap" | "onTapStart" | "onTapCancel" | "whileTap" | "whileHover" | "onHoverStart" | "onHoverEnd" | "whileFocus" | "whileInView" | "onViewportEnter" | "onViewportLeave" | "viewport" | "drag" | "whileDrag" | "dragDirectionLock" | "dragPropagation" | "dragConstraints" | "dragElastic" | "dragMomentum" | "dragTransition" | "dragControls" | "dragSnapToOrigin" | "dragListener" | "onMeasureDragConstraints" | "_dragX" | "_dragY" | "onDragStart" | "onDragEnd" | "onDrag" | "onDirectionLock" | "onDragTransitionEnd" | "layout" | "layoutId" | "onLayoutAnimationStart" | "onLayoutAnimationComplete" | "layoutDependency" | "layoutScroll" | "custom" | "inherit" | "className"> & {
|
|
3
5
|
children: React.ReactNode;
|
|
4
6
|
} & React.RefAttributes<any>>;
|
|
5
7
|
export default SheetContainer;
|
package/dist/SheetContent.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
declare const SheetContent: React.ForwardRefExoticComponent<Pick<import("framer-motion").MotionProps
|
|
2
|
+
declare const SheetContent: React.ForwardRefExoticComponent<Pick<import("framer-motion").MotionProps & {
|
|
3
|
+
className?: string | undefined;
|
|
4
|
+
}, "style" | "transformTemplate" | "transformValues" | "children" | "initial" | "animate" | "exit" | "variants" | "transition" | "onBeforeLayoutMeasure" | "onLayoutMeasure" | "onUpdate" | "onAnimationStart" | "onAnimationComplete" | "onPan" | "onPanStart" | "onPanSessionStart" | "onPanEnd" | "onTap" | "onTapStart" | "onTapCancel" | "whileTap" | "whileHover" | "onHoverStart" | "onHoverEnd" | "whileFocus" | "whileInView" | "onViewportEnter" | "onViewportLeave" | "viewport" | "whileDrag" | "dragDirectionLock" | "dragPropagation" | "dragTransition" | "dragControls" | "dragSnapToOrigin" | "dragListener" | "onMeasureDragConstraints" | "_dragX" | "_dragY" | "onDirectionLock" | "onDragTransitionEnd" | "layout" | "layoutId" | "onLayoutAnimationStart" | "onLayoutAnimationComplete" | "layoutDependency" | "layoutScroll" | "custom" | "inherit" | "className"> & {
|
|
3
5
|
children?: React.ReactNode;
|
|
4
6
|
disableDrag?: boolean | undefined;
|
|
5
7
|
} & React.RefAttributes<any>>;
|
package/dist/SheetHeader.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
declare const SheetHeader: React.ForwardRefExoticComponent<Pick<import("framer-motion").MotionProps
|
|
2
|
+
declare const SheetHeader: React.ForwardRefExoticComponent<Pick<import("framer-motion").MotionProps & {
|
|
3
|
+
className?: string | undefined;
|
|
4
|
+
}, "style" | "transformTemplate" | "transformValues" | "children" | "initial" | "animate" | "exit" | "variants" | "transition" | "onBeforeLayoutMeasure" | "onLayoutMeasure" | "onUpdate" | "onAnimationStart" | "onAnimationComplete" | "onPan" | "onPanStart" | "onPanSessionStart" | "onPanEnd" | "onTap" | "onTapStart" | "onTapCancel" | "whileTap" | "whileHover" | "onHoverStart" | "onHoverEnd" | "whileFocus" | "whileInView" | "onViewportEnter" | "onViewportLeave" | "viewport" | "whileDrag" | "dragDirectionLock" | "dragPropagation" | "dragTransition" | "dragControls" | "dragSnapToOrigin" | "dragListener" | "onMeasureDragConstraints" | "_dragX" | "_dragY" | "onDirectionLock" | "onDragTransitionEnd" | "layout" | "layoutId" | "onLayoutAnimationStart" | "onLayoutAnimationComplete" | "layoutDependency" | "layoutScroll" | "custom" | "inherit" | "className"> & {
|
|
3
5
|
children?: React.ReactNode;
|
|
4
6
|
disableDrag?: boolean | undefined;
|
|
5
7
|
} & React.RefAttributes<any>>;
|
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
-
|
|
7
5
|
var React = require('react');
|
|
8
6
|
var ReactDOM = require('react-dom');
|
|
9
|
-
var overlays = require('@react-aria/overlays');
|
|
10
7
|
var framerMotion = require('framer-motion');
|
|
11
|
-
var
|
|
8
|
+
var utils = require('@react-aria/utils');
|
|
9
|
+
var reactMergeRefs = require('react-merge-refs');
|
|
12
10
|
|
|
13
11
|
function _extends() {
|
|
14
12
|
_extends = Object.assign || function (target) {
|
|
@@ -234,6 +232,247 @@ var useSheetContext = function useSheetContext() {
|
|
|
234
232
|
return context;
|
|
235
233
|
};
|
|
236
234
|
|
|
235
|
+
// Source: https://github.com/adobe/react-spectrum/blob/main/packages/@react-aria/overlays/src/usePreventScroll.ts
|
|
236
|
+
|
|
237
|
+
var visualViewport = typeof window !== 'undefined' && window.visualViewport; // HTML input types that do not cause the software keyboard to appear.
|
|
238
|
+
|
|
239
|
+
var nonTextInputTypes = /*#__PURE__*/new Set(['checkbox', 'radio', 'range', 'color', 'file', 'image', 'button', 'submit', 'reset']); // The number of active usePreventScroll calls. Used to determine whether to revert back to the original page style/scroll position
|
|
240
|
+
|
|
241
|
+
var preventScrollCount = 0;
|
|
242
|
+
var restore;
|
|
243
|
+
/**
|
|
244
|
+
* Prevents scrolling on the document body on mount, and
|
|
245
|
+
* restores it on unmount. Also ensures that content does not
|
|
246
|
+
* shift due to the scrollbars disappearing.
|
|
247
|
+
*/
|
|
248
|
+
|
|
249
|
+
function usePreventScroll(options) {
|
|
250
|
+
if (options === void 0) {
|
|
251
|
+
options = {};
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
var _options = options,
|
|
255
|
+
isDisabled = _options.isDisabled;
|
|
256
|
+
utils.useLayoutEffect(function () {
|
|
257
|
+
if (isDisabled) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
preventScrollCount++;
|
|
262
|
+
|
|
263
|
+
if (preventScrollCount === 1) {
|
|
264
|
+
if (utils.isIOS()) {
|
|
265
|
+
restore = preventScrollMobileSafari();
|
|
266
|
+
} else {
|
|
267
|
+
restore = preventScrollStandard();
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
return function () {
|
|
272
|
+
preventScrollCount--;
|
|
273
|
+
|
|
274
|
+
if (preventScrollCount === 0) {
|
|
275
|
+
restore();
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
}, [isDisabled]);
|
|
279
|
+
} // For most browsers, all we need to do is set `overflow: hidden` on the root element, and
|
|
280
|
+
// add some padding to prevent the page from shifting when the scrollbar is hidden.
|
|
281
|
+
|
|
282
|
+
function preventScrollStandard() {
|
|
283
|
+
return utils.chain(setStyle(document.documentElement, 'paddingRight', window.innerWidth - document.documentElement.clientWidth + "px"), setStyle(document.documentElement, 'overflow', 'hidden'));
|
|
284
|
+
} // Mobile Safari is a whole different beast. Even with overflow: hidden,
|
|
285
|
+
// it still scrolls the page in many situations:
|
|
286
|
+
//
|
|
287
|
+
// 1. When the bottom toolbar and address bar are collapsed, page scrolling is always allowed.
|
|
288
|
+
// 2. When the keyboard is visible, the viewport does not resize. Instead, the keyboard covers part of
|
|
289
|
+
// it, so it becomes scrollable.
|
|
290
|
+
// 3. When tapping on an input, the page always scrolls so that the input is centered in the visual viewport.
|
|
291
|
+
// This may cause even fixed position elements to scroll off the screen.
|
|
292
|
+
// 4. When using the next/previous buttons in the keyboard to navigate between inputs, the whole page always
|
|
293
|
+
// scrolls, even if the input is inside a nested scrollable element that could be scrolled instead.
|
|
294
|
+
//
|
|
295
|
+
// In order to work around these cases, and prevent scrolling without jankiness, we do a few things:
|
|
296
|
+
//
|
|
297
|
+
// 1. Prevent default on `touchmove` events that are not in a scrollable element. This prevents touch scrolling
|
|
298
|
+
// on the window.
|
|
299
|
+
// 2. Prevent default on `touchmove` events inside a scrollable element when the scroll position is at the
|
|
300
|
+
// top or bottom. This avoids the whole page scrolling instead, but does prevent overscrolling.
|
|
301
|
+
// 3. Prevent default on `touchend` events on input elements and handle focusing the element ourselves.
|
|
302
|
+
// 4. When focusing an input, apply a transform to trick Safari into thinking the input is at the top
|
|
303
|
+
// of the page, which prevents it from scrolling the page. After the input is focused, scroll the element
|
|
304
|
+
// into view ourselves, without scrolling the whole page.
|
|
305
|
+
// 5. Offset the body by the scroll position using a negative margin and scroll to the top. This should appear the
|
|
306
|
+
// same visually, but makes the actual scroll position always zero. This is required to make all of the
|
|
307
|
+
// above work or Safari will still try to scroll the page when focusing an input.
|
|
308
|
+
// 6. As a last resort, handle window scroll events, and scroll back to the top. This can happen when attempting
|
|
309
|
+
// to navigate to an input with the next/previous buttons that's outside a modal.
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
function preventScrollMobileSafari() {
|
|
313
|
+
var scrollable;
|
|
314
|
+
var lastY = 0;
|
|
315
|
+
|
|
316
|
+
var onTouchStart = function onTouchStart(e) {
|
|
317
|
+
// Store the nearest scrollable parent element from the element that the user touched.
|
|
318
|
+
scrollable = utils.getScrollParent(e.target);
|
|
319
|
+
|
|
320
|
+
if (scrollable === document.documentElement && scrollable === document.body) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
lastY = e.changedTouches[0].pageY;
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
var onTouchMove = function onTouchMove(e) {
|
|
328
|
+
// Prevent scrolling the window.
|
|
329
|
+
if (scrollable === document.documentElement || scrollable === document.body) {
|
|
330
|
+
e.preventDefault();
|
|
331
|
+
return;
|
|
332
|
+
} // Prevent scrolling up when at the top and scrolling down when at the bottom
|
|
333
|
+
// of a nested scrollable area, otherwise mobile Safari will start scrolling
|
|
334
|
+
// the window instead. Unfortunately, this disables bounce scrolling when at
|
|
335
|
+
// the top but it's the best we can do.
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
var y = e.changedTouches[0].pageY;
|
|
339
|
+
var scrollTop = scrollable.scrollTop;
|
|
340
|
+
var bottom = scrollable.scrollHeight - scrollable.clientHeight; // Fix for: https://github.com/adobe/react-spectrum/pull/3780/files
|
|
341
|
+
|
|
342
|
+
if (bottom === 0) {
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
if (scrollTop <= 0 && y > lastY || scrollTop >= bottom && y < lastY) {
|
|
347
|
+
e.preventDefault();
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
lastY = y;
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
var onTouchEnd = function onTouchEnd(e) {
|
|
354
|
+
var target = e.target; // Apply this change if we're not already focused on the target element
|
|
355
|
+
|
|
356
|
+
if (willOpenKeyboard(target) && target !== document.activeElement) {
|
|
357
|
+
e.preventDefault(); // Apply a transform to trick Safari into thinking the input is at the top of the page
|
|
358
|
+
// so it doesn't try to scroll it into view. When tapping on an input, this needs to
|
|
359
|
+
// be done before the "focus" event, so we have to focus the element ourselves.
|
|
360
|
+
|
|
361
|
+
target.style.transform = 'translateY(-2000px)';
|
|
362
|
+
target.focus();
|
|
363
|
+
requestAnimationFrame(function () {
|
|
364
|
+
target.style.transform = '';
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
var onFocus = function onFocus(e) {
|
|
370
|
+
var target = e.target;
|
|
371
|
+
|
|
372
|
+
if (willOpenKeyboard(target)) {
|
|
373
|
+
// Transform also needs to be applied in the focus event in cases where focus moves
|
|
374
|
+
// other than tapping on an input directly, e.g. the next/previous buttons in the
|
|
375
|
+
// software keyboard. In these cases, it seems applying the transform in the focus event
|
|
376
|
+
// is good enough, whereas when tapping an input, it must be done before the focus event. 🤷♂️
|
|
377
|
+
target.style.transform = 'translateY(-2000px)';
|
|
378
|
+
requestAnimationFrame(function () {
|
|
379
|
+
target.style.transform = ''; // This will have prevented the browser from scrolling the focused element into view,
|
|
380
|
+
// so we need to do this ourselves in a way that doesn't cause the whole page to scroll.
|
|
381
|
+
|
|
382
|
+
if (visualViewport) {
|
|
383
|
+
if (visualViewport.height < window.innerHeight) {
|
|
384
|
+
// If the keyboard is already visible, do this after one additional frame
|
|
385
|
+
// to wait for the transform to be removed.
|
|
386
|
+
requestAnimationFrame(function () {
|
|
387
|
+
scrollIntoView(target);
|
|
388
|
+
});
|
|
389
|
+
} else {
|
|
390
|
+
// Otherwise, wait for the visual viewport to resize before scrolling so we can
|
|
391
|
+
// measure the correct position to scroll to.
|
|
392
|
+
visualViewport.addEventListener('resize', function () {
|
|
393
|
+
return scrollIntoView(target);
|
|
394
|
+
}, {
|
|
395
|
+
once: true
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
var onWindowScroll = function onWindowScroll() {
|
|
404
|
+
// Last resort. If the window scrolled, scroll it back to the top.
|
|
405
|
+
// It should always be at the top because the body will have a negative margin (see below).
|
|
406
|
+
window.scrollTo(0, 0);
|
|
407
|
+
}; // Record the original scroll position so we can restore it.
|
|
408
|
+
// Then apply a negative margin to the body to offset it by the scroll position. This will
|
|
409
|
+
// enable us to scroll the window to the top, which is required for the rest of this to work.
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
var scrollX = window.pageXOffset;
|
|
413
|
+
var scrollY = window.pageYOffset;
|
|
414
|
+
var restoreStyles = utils.chain(setStyle(document.documentElement, 'paddingRight', window.innerWidth - document.documentElement.clientWidth + "px"), setStyle(document.documentElement, 'overflow', 'hidden'), setStyle(document.body, 'marginTop', "-" + scrollY + "px")); // Scroll to the top. The negative margin on the body will make this appear the same.
|
|
415
|
+
|
|
416
|
+
window.scrollTo(0, 0);
|
|
417
|
+
var removeEvents = utils.chain(addEvent(document, 'touchstart', onTouchStart, {
|
|
418
|
+
passive: false,
|
|
419
|
+
capture: true
|
|
420
|
+
}), addEvent(document, 'touchmove', onTouchMove, {
|
|
421
|
+
passive: false,
|
|
422
|
+
capture: true
|
|
423
|
+
}), addEvent(document, 'touchend', onTouchEnd, {
|
|
424
|
+
passive: false,
|
|
425
|
+
capture: true
|
|
426
|
+
}), addEvent(document, 'focus', onFocus, true), addEvent(window, 'scroll', onWindowScroll));
|
|
427
|
+
return function () {
|
|
428
|
+
// Restore styles and scroll the page back to where it was.
|
|
429
|
+
restoreStyles();
|
|
430
|
+
removeEvents();
|
|
431
|
+
window.scrollTo(scrollX, scrollY);
|
|
432
|
+
};
|
|
433
|
+
} // Sets a CSS property on an element, and returns a function to revert it to the previous value.
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
function setStyle(element, style, value) {
|
|
437
|
+
var cur = element.style[style];
|
|
438
|
+
element.style[style] = value;
|
|
439
|
+
return function () {
|
|
440
|
+
element.style[style] = cur;
|
|
441
|
+
};
|
|
442
|
+
} // Adds an event listener to an element, and returns a function to remove it.
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
function addEvent(target, event, handler, options) {
|
|
446
|
+
target.addEventListener(event, handler, options);
|
|
447
|
+
return function () {
|
|
448
|
+
target.removeEventListener(event, handler, options);
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
function scrollIntoView(target) {
|
|
453
|
+
var root = document.scrollingElement || document.documentElement;
|
|
454
|
+
|
|
455
|
+
while (target && target !== root) {
|
|
456
|
+
// Find the parent scrollable element and adjust the scroll position if the target is not already in view.
|
|
457
|
+
var scrollable = utils.getScrollParent(target);
|
|
458
|
+
|
|
459
|
+
if (scrollable !== document.documentElement && scrollable !== document.body && scrollable !== target) {
|
|
460
|
+
var scrollableTop = scrollable.getBoundingClientRect().top;
|
|
461
|
+
var targetTop = target.getBoundingClientRect().top;
|
|
462
|
+
|
|
463
|
+
if (targetTop > scrollableTop + target.clientHeight) {
|
|
464
|
+
scrollable.scrollTop += targetTop - scrollableTop;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
target = scrollable.parentElement;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
function willOpenKeyboard(target) {
|
|
473
|
+
return target instanceof HTMLInputElement && !nonTextInputTypes.has(target.type) || target instanceof HTMLTextAreaElement || target instanceof HTMLElement && target.isContentEditable;
|
|
474
|
+
}
|
|
475
|
+
|
|
237
476
|
var styles = {
|
|
238
477
|
wrapper: {
|
|
239
478
|
position: 'fixed',
|
|
@@ -253,7 +492,8 @@ var styles = {
|
|
|
253
492
|
width: '100%',
|
|
254
493
|
height: '100%',
|
|
255
494
|
backgroundColor: 'rgba(51, 51, 51, 0.5)',
|
|
256
|
-
touchAction: 'none'
|
|
495
|
+
touchAction: 'none',
|
|
496
|
+
border: 'none'
|
|
257
497
|
},
|
|
258
498
|
container: {
|
|
259
499
|
zIndex: 2,
|
|
@@ -450,7 +690,7 @@ var Sheet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
450
690
|
useModalEffect(isOpen, rootId); // Framer Motion should handle body scroll locking but it's not working
|
|
451
691
|
// properly on iOS. Scroll locking from React Aria seems to work much better.
|
|
452
692
|
|
|
453
|
-
|
|
693
|
+
usePreventScroll({
|
|
454
694
|
isDisabled: !isOpen
|
|
455
695
|
});
|
|
456
696
|
var dragProps = React.useMemo(function () {
|
|
@@ -462,6 +702,7 @@ var Sheet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
462
702
|
bottom: 0
|
|
463
703
|
},
|
|
464
704
|
dragMomentum: false,
|
|
705
|
+
dragPropagation: false,
|
|
465
706
|
onDrag: onDrag,
|
|
466
707
|
onDragEnd: onDragEnd
|
|
467
708
|
};
|
|
@@ -500,7 +741,9 @@ var SheetContainer = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
500
741
|
var children = _ref.children,
|
|
501
742
|
_ref$style = _ref.style,
|
|
502
743
|
style = _ref$style === void 0 ? {} : _ref$style,
|
|
503
|
-
|
|
744
|
+
_ref$className = _ref.className,
|
|
745
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
746
|
+
rest = _objectWithoutPropertiesLoose(_ref, ["children", "style", "className"]);
|
|
504
747
|
|
|
505
748
|
var _useSheetContext = useSheetContext(),
|
|
506
749
|
y = _useSheetContext.y,
|
|
@@ -522,8 +765,8 @@ var SheetContainer = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
522
765
|
var maxSnapHeight = snapPoints ? snapPoints[0] : null;
|
|
523
766
|
var height = maxSnapHeight !== null ? "min(" + maxSnapHeight + "px, " + MAX_HEIGHT + ")" : MAX_HEIGHT;
|
|
524
767
|
return React.createElement(framerMotion.motion.div, Object.assign({}, rest, {
|
|
525
|
-
ref: mergeRefs([sheetRef, ref]),
|
|
526
|
-
className: "react-modal-sheet-container",
|
|
768
|
+
ref: reactMergeRefs.mergeRefs([sheetRef, ref]),
|
|
769
|
+
className: "react-modal-sheet-container " + className,
|
|
527
770
|
style: _extends({}, styles.container, style, detent === 'full-height' && {
|
|
528
771
|
height: height
|
|
529
772
|
}, detent === 'content-height' && {
|
|
@@ -550,7 +793,9 @@ var SheetContent = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
550
793
|
var children = _ref.children,
|
|
551
794
|
style = _ref.style,
|
|
552
795
|
disableDrag = _ref.disableDrag,
|
|
553
|
-
|
|
796
|
+
_ref$className = _ref.className,
|
|
797
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
798
|
+
rest = _objectWithoutPropertiesLoose(_ref, ["children", "style", "disableDrag", "className"]);
|
|
554
799
|
|
|
555
800
|
var _useSheetContext = useSheetContext(),
|
|
556
801
|
dragProps = _useSheetContext.dragProps;
|
|
@@ -559,7 +804,7 @@ var SheetContent = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
559
804
|
|
|
560
805
|
return React.createElement(framerMotion.motion.div, Object.assign({}, rest, {
|
|
561
806
|
ref: ref,
|
|
562
|
-
className: "react-modal-sheet-content",
|
|
807
|
+
className: "react-modal-sheet-content " + className,
|
|
563
808
|
style: _extends({}, styles.content, style)
|
|
564
809
|
}, _dragProps), children);
|
|
565
810
|
});
|
|
@@ -608,13 +853,15 @@ var isClickable = function isClickable(props) {
|
|
|
608
853
|
var SheetBackdrop = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
609
854
|
var _ref$style = _ref.style,
|
|
610
855
|
style = _ref$style === void 0 ? {} : _ref$style,
|
|
611
|
-
|
|
856
|
+
_ref$className = _ref.className,
|
|
857
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
858
|
+
rest = _objectWithoutPropertiesLoose(_ref, ["style", "className"]);
|
|
612
859
|
|
|
613
860
|
var Comp = isClickable(rest) ? framerMotion.motion.button : framerMotion.motion.div;
|
|
614
861
|
var pointerEvents = isClickable(rest) ? 'auto' : 'none';
|
|
615
862
|
return React.createElement(Comp, Object.assign({}, rest, {
|
|
616
863
|
ref: ref,
|
|
617
|
-
className: "react-modal-sheet-backdrop",
|
|
864
|
+
className: "react-modal-sheet-backdrop " + className,
|
|
618
865
|
style: _extends({}, styles.backdrop, style, {
|
|
619
866
|
pointerEvents: pointerEvents
|
|
620
867
|
}),
|