react-modal-sheet 3.1.0 → 3.3.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/README.md +21 -19
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +13 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/src/constants.ts +2 -2
- package/src/hooks.tsx +5 -2
- package/src/sheet.tsx +10 -6
- package/src/types.tsx +2 -0
package/README.md
CHANGED
|
@@ -70,25 +70,27 @@ Also, by constructing the sheet from smaller pieces makes it easier to apply any
|
|
|
70
70
|
|
|
71
71
|
## 🎛️ Props
|
|
72
72
|
|
|
73
|
-
| Name
|
|
74
|
-
|
|
|
75
|
-
| `children`
|
|
76
|
-
| `isOpen`
|
|
77
|
-
| `onClose`
|
|
78
|
-
| `disableDrag`
|
|
79
|
-
| `disableScrollLocking`
|
|
80
|
-
| `detent`
|
|
81
|
-
| `onOpenStart`
|
|
82
|
-
| `onOpenEnd`
|
|
83
|
-
| `onCloseStart`
|
|
84
|
-
| `onCloseEnd`
|
|
85
|
-
| `onSnap`
|
|
86
|
-
| `snapPoints`
|
|
87
|
-
| `initialSnap`
|
|
88
|
-
| `rootId`
|
|
89
|
-
| `tweenConfig`
|
|
90
|
-
| `mountPoint`
|
|
91
|
-
| `prefersReducedMotion`
|
|
73
|
+
| Name | Required | Default | Description |
|
|
74
|
+
| ----------------------- | -------- | ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
75
|
+
| `children` | yes | | Use `Sheet.Container/Content/Header/Backdrop` to compose your bottom sheet. |
|
|
76
|
+
| `isOpen` | yes | | Boolean that indicates whether the sheet is open or not. |
|
|
77
|
+
| `onClose` | yes | | Callback fn that is called when the sheet is closed by the user. |
|
|
78
|
+
| `disableDrag` | no | false | Disable drag for the whole sheet. |
|
|
79
|
+
| `disableScrollLocking` | no | false | Disable scroll locking for the `body` element while sheet is open. Can be useful if you face issues with input elements and the iOS virtual keyboard. See related [issue](https://github.com/Temzasse/react-modal-sheet/issues/135). |
|
|
80
|
+
| `detent` | no | `'full-height'` | The [detent](https://developer.apple.com/design/human-interface-guidelines/components/presentation/sheets#ios-ipados) in which the sheet should be in when opened. Available values: `'full-height'` or `'content-height'`. |
|
|
81
|
+
| `onOpenStart` | no | | Callback fn that is called when the sheet opening animation starts. |
|
|
82
|
+
| `onOpenEnd` | no | | Callback fn that is called when the sheet opening animation is completed. |
|
|
83
|
+
| `onCloseStart` | no | | Callback fn that is called when the sheet closing animation starts. |
|
|
84
|
+
| `onCloseEnd` | no | | Callback fn that is called when the sheet closing animation is completed. |
|
|
85
|
+
| `onSnap` | no | | Callback fn that is called with the current snap point index when the sheet snaps to a new snap point. Requires `snapPoints` prop. |
|
|
86
|
+
| `snapPoints` | no | | Eg. `[-50, 0.5, 100, 0]` - where positive values are pixels from the bottom of the screen and negative from the top. Values between 0-1 represent percentages, eg. `0.5` means 50% of window height from the bottom of the sceen. |
|
|
87
|
+
| `initialSnap` | no | 0 | Initial snap point when sheet is opened (index from `snapPoints`). |
|
|
88
|
+
| `rootId` | no | | The id of the element where the main app is mounted, eg. "root". Enables iOS modal effect. |
|
|
89
|
+
| `tweenConfig` | no | `{ ease: 'easeOut', duration: 0.2 }` | Overrides the config for the sheet [tween](https://www.framer.com/motion/transition/#tween) transition when the sheet is opened, closed, or snapped to a point. |
|
|
90
|
+
| `mountPoint` | no | `document.body` | HTML element that should be used as the mount point for the sheet. |
|
|
91
|
+
| `prefersReducedMotion` | no | false | Skip sheet animations (sheet instantly snaps to desired location). |
|
|
92
|
+
| `dragVelocityThreshold` | no | 500 | How fast the sheet must be flicked down to close. Higher values make the sheet harder to close. |
|
|
93
|
+
| `dragCloseThreshold` | no | 0.6 | The portion of the sheet which must be dragged off-screen before it will close. |
|
|
92
94
|
|
|
93
95
|
## ⚙️ Methods and properties
|
|
94
96
|
|
package/dist/index.d.mts
CHANGED
|
@@ -29,6 +29,8 @@ type SheetProps = {
|
|
|
29
29
|
disableDrag?: boolean;
|
|
30
30
|
disableScrollLocking?: boolean;
|
|
31
31
|
prefersReducedMotion?: boolean;
|
|
32
|
+
dragVelocityThreshold?: number;
|
|
33
|
+
dragCloseThreshold?: number;
|
|
32
34
|
} & SheetEvents & ComponentPropsWithoutRef<typeof motion.div>;
|
|
33
35
|
type SheetContainerProps = Omit<CommonProps, 'initial' | 'animate' | 'exit' | 'onAnimationComplete'> & {
|
|
34
36
|
children: ReactNode;
|
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,8 @@ type SheetProps = {
|
|
|
29
29
|
disableDrag?: boolean;
|
|
30
30
|
disableScrollLocking?: boolean;
|
|
31
31
|
prefersReducedMotion?: boolean;
|
|
32
|
+
dragVelocityThreshold?: number;
|
|
33
|
+
dragCloseThreshold?: number;
|
|
32
34
|
} & SheetEvents & ComponentPropsWithoutRef<typeof motion.div>;
|
|
33
35
|
type SheetContainerProps = Omit<CommonProps, 'initial' | 'animate' | 'exit' | 'onAnimationComplete'> & {
|
|
34
36
|
children: ReactNode;
|
package/dist/index.js
CHANGED
|
@@ -22,8 +22,8 @@ var REDUCED_MOTION_TWEEN_CONFIG = {
|
|
|
22
22
|
ease: "linear",
|
|
23
23
|
duration: 0.01
|
|
24
24
|
};
|
|
25
|
-
var
|
|
26
|
-
var
|
|
25
|
+
var DEFAULT_DRAG_CLOSE_THRESHOLD = 0.6;
|
|
26
|
+
var DEFAULT_DRAG_VELOCITY_THRESHOLD = 500;
|
|
27
27
|
|
|
28
28
|
// src/utils.ts
|
|
29
29
|
function getClosest(nums, goal) {
|
|
@@ -148,7 +148,10 @@ function useEventCallbacks(isOpen, callbacks) {
|
|
|
148
148
|
return { handleAnimationComplete };
|
|
149
149
|
}
|
|
150
150
|
function useDimensions() {
|
|
151
|
-
const [dimensions, setDimensions] = React2.useState({
|
|
151
|
+
const [dimensions, setDimensions] = React2.useState({
|
|
152
|
+
height: framerMotion.isBrowser ? window.innerHeight : 0,
|
|
153
|
+
width: framerMotion.isBrowser ? window.innerWidth : 0
|
|
154
|
+
});
|
|
152
155
|
useIsomorphicLayoutEffect(() => {
|
|
153
156
|
function handler() {
|
|
154
157
|
setDimensions({
|
|
@@ -482,7 +485,7 @@ var Sheet = React2.forwardRef(
|
|
|
482
485
|
children,
|
|
483
486
|
disableScrollLocking = false,
|
|
484
487
|
isOpen,
|
|
485
|
-
snapPoints,
|
|
488
|
+
snapPoints: snapPointsProp,
|
|
486
489
|
rootId,
|
|
487
490
|
mountPoint,
|
|
488
491
|
style,
|
|
@@ -491,6 +494,8 @@ var Sheet = React2.forwardRef(
|
|
|
491
494
|
disableDrag = false,
|
|
492
495
|
prefersReducedMotion = false,
|
|
493
496
|
tweenConfig = DEFAULT_TWEEN_CONFIG,
|
|
497
|
+
dragVelocityThreshold = DEFAULT_DRAG_VELOCITY_THRESHOLD,
|
|
498
|
+
dragCloseThreshold = DEFAULT_DRAG_CLOSE_THRESHOLD,
|
|
494
499
|
...rest
|
|
495
500
|
}, ref) => {
|
|
496
501
|
const sheetRef = React2.useRef(null);
|
|
@@ -502,7 +507,7 @@ var Sheet = React2.forwardRef(
|
|
|
502
507
|
type: "tween",
|
|
503
508
|
...reduceMotion ? REDUCED_MOTION_TWEEN_CONFIG : tweenConfig
|
|
504
509
|
};
|
|
505
|
-
const y = framerMotion.useMotionValue(
|
|
510
|
+
const y = framerMotion.useMotionValue(windowHeight);
|
|
506
511
|
const zIndex = framerMotion.useTransform(
|
|
507
512
|
y,
|
|
508
513
|
(value) => value + 2 >= windowHeight ? -1 : 9999999
|
|
@@ -525,6 +530,7 @@ var Sheet = React2.forwardRef(
|
|
|
525
530
|
onCloseEnd
|
|
526
531
|
};
|
|
527
532
|
});
|
|
533
|
+
let snapPoints = snapPointsProp;
|
|
528
534
|
if (snapPoints) {
|
|
529
535
|
snapPoints = snapPoints.map((point) => {
|
|
530
536
|
if (point > 0 && point <= 1)
|
|
@@ -556,7 +562,7 @@ var Sheet = React2.forwardRef(
|
|
|
556
562
|
}
|
|
557
563
|
});
|
|
558
564
|
const onDragEnd = useEffectEvent((_, { velocity }) => {
|
|
559
|
-
if (velocity.y >
|
|
565
|
+
if (velocity.y > dragVelocityThreshold) {
|
|
560
566
|
onClose();
|
|
561
567
|
} else {
|
|
562
568
|
const sheetHeight = sheetRef.current.getBoundingClientRect().height;
|
|
@@ -570,7 +576,7 @@ var Sheet = React2.forwardRef(
|
|
|
570
576
|
snapToValues.unshift(0);
|
|
571
577
|
}
|
|
572
578
|
snapTo = getClosest(snapToValues, currentY);
|
|
573
|
-
} else if (currentY / sheetHeight >
|
|
579
|
+
} else if (currentY / sheetHeight > dragCloseThreshold) {
|
|
574
580
|
snapTo = sheetHeight;
|
|
575
581
|
}
|
|
576
582
|
snapTo = validateSnapTo({ snapTo, sheetHeight });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/sheet.tsx","../src/hooks.tsx","../src/constants.ts","../src/utils.ts","../src/context.tsx","../src/use-prevent-scroll.ts","../src/styles.ts","../src/SheetContainer.tsx","../src/SheetContent.tsx","../src/SheetHeader.tsx","../src/SheetBackdrop.tsx","../src/SheetScroller.tsx","../src/index.tsx"],"names":["React","useEffect","useRef","useState","useLayoutEffect","dragProps","forwardRef","motion","useTransform","Sheet"],"mappings":";AAAA,OAAOA;AAAA,EACL;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAAC;AAAA,OACK;AAEP,SAAS,oBAAoB;AAE7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACrBP;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACPA,IAAM,aAAa;AAEnB,IAAM,SAAS,OAAO,W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aAAa;AAAA,IACpC;AAEA,aAAS,aAAa,GAA+B;AACnD,yBAAmB,EAAE,aAAa;AAAA,IACpC;AAEA,UAAM,cAAc,cAAc,IAC9B,EAAE,UAAU,aAAa,IACzB;AAEJ,WACE,gBAAAN,OAAA;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACJ;AAAA,QACA,WAAW,8BAA8B,SAAS;AAAA,QAClD,OAAO,EAAE,GAAG,eAAO,UAAU,GAAG,MAAM;AAAA,QACrC,GAAG;AAAA;AAAA,MAEH;AAAA,IACH;AAAA,EAEJ;AACF;AAEA,cAAc,cAAc;AAE5B,IAAO,wBAAQ;;;AC5Cf,IAAM,iBAAsB;AAC5B,eAAe,YAAY;AAC3B,eAAe,SAAS;AACxB,eAAe,UAAU;AACzB,eAAe,WAAW;AAC1B,eAAe,WAAW;AAEnB,IAAMS,SAAQ","sourcesContent":["import React, {\n Children,\n cloneElement,\n forwardRef,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n} from 'react';\n\nimport { createPortal } from 'react-dom';\n\nimport {\n animate,\n AnimatePresence,\n motion,\n type PanInfo,\n type Transition,\n useMotionValue,\n useReducedMotion,\n useTransform,\n} from 'framer-motion';\n\nimport {\n useModalEffect,\n useDimensions,\n useIsomorphicLayoutEffect,\n useEffectEvent,\n} from './hooks';\n\nimport {\n REDUCED_MOTION_TWEEN_CONFIG,\n DEFAULT_TWEEN_CONFIG,\n DRAG_CLOSE_THRESHOLD,\n DRAG_VELOCITY_THRESHOLD,\n IS_SSR,\n} from './constants';\n\nimport { type SheetContextType, type SheetProps } from './types';\nimport { SheetScrollerContextProvider, SheetContext } from './context';\nimport { getClosest, inDescendingOrder, validateSnapTo } from './utils';\nimport { usePreventScroll } from './use-prevent-scroll';\nimport styles from './styles';\n\nconst Sheet = forwardRef<any, SheetProps>(\n (\n {\n onOpenStart,\n onOpenEnd,\n onClose,\n onCloseStart,\n onCloseEnd,\n onSnap,\n children,\n disableScrollLocking = false,\n isOpen,\n snapPoints,\n rootId,\n mountPoint,\n style,\n detent = 'full-height',\n initialSnap = 0,\n disableDrag = false,\n prefersReducedMotion = false,\n tweenConfig = DEFAULT_TWEEN_CONFIG,\n ...rest\n },\n ref\n ) => {\n const sheetRef = useRef<HTMLDivElement>(null);\n const indicatorRotation = useMotionValue(0);\n const { height: windowHeight } = useDimensions();\n const shouldReduceMotion = useReducedMotion();\n const reduceMotion = Boolean(prefersReducedMotion || shouldReduceMotion);\n const animationOptions: Transition = {\n type: 'tween',\n ...(reduceMotion ? REDUCED_MOTION_TWEEN_CONFIG : tweenConfig),\n };\n\n // NOTE: the inital value for `y` doesn't matter since it is overwritten by\n // the value driven by the `AnimatePresence` component when the sheet is opened\n // and after that it is driven by the gestures and/or snapping\n const y = useMotionValue(0);\n\n // +2 for tolerance in case the animated value is slightly off\n const zIndex = useTransform(y, (value) =>\n value + 2 >= windowHeight ? -1 : 9999999\n );\n const visibility = useTransform(y, (value) =>\n value + 2 >= windowHeight ? 'hidden' : 'visible'\n );\n\n // Keep the callback fns up-to-date so that they can be accessed inside\n // the effect without including them to the dependencies array\n const callbacks = useRef({\n onOpenStart,\n onOpenEnd,\n onCloseStart,\n onCloseEnd,\n });\n\n useIsomorphicLayoutEffect(() => {\n callbacks.current = {\n onOpenStart,\n onOpenEnd,\n onCloseStart,\n onCloseEnd,\n };\n });\n\n if (snapPoints) {\n // Convert negative / percentage snap points to absolute values\n snapPoints = snapPoints.map((point) => {\n // Percentage values e.g. between 0.0 and 1.0\n if (point > 0 && point <= 1) return Math.round(point * windowHeight);\n return point < 0 ? windowHeight + point : point; // negative values\n });\n\n console.assert(\n inDescendingOrder(snapPoints) || windowHeight === 0,\n `Snap points need to be in descending order got: [${snapPoints.join(\n ', '\n )}]`\n );\n }\n\n const onDrag = useEffectEvent((_, { delta }: PanInfo) => {\n // Update drag indicator rotation based on drag velocity\n const velocity = y.getVelocity();\n\n if (velocity > 0) indicatorRotation.set(10);\n if (velocity < 0) indicatorRotation.set(-10);\n\n // Make sure user cannot drag beyond the top of the sheet\n y.set(Math.max(y.get() + delta.y, 0));\n });\n\n const onDragStart = useEffectEvent(() => {\n // Find focused input inside the sheet and blur it when dragging starts\n // to prevent a weird ghost caret \"bug\" on mobile\n const focusedElement = document.activeElement as HTMLElement | null;\n if (!focusedElement || !sheetRef.current) return;\n\n const isInput =\n focusedElement.tagName === 'INPUT' ||\n focusedElement.tagName === 'TEXTAREA';\n\n // Only blur the focused element if it's inside the sheet\n if (isInput && sheetRef.current.contains(focusedElement)) {\n focusedElement.blur();\n }\n });\n\n const onDragEnd = useEffectEvent((_, { velocity }: PanInfo) => {\n if (velocity.y > DRAG_VELOCITY_THRESHOLD) {\n // User flicked the sheet down\n onClose();\n } else {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const sheetHeight = sheetRef.current!.getBoundingClientRect().height;\n const currentY = y.get();\n\n let snapTo = 0;\n\n if (snapPoints) {\n const snapToValues = snapPoints.map(\n (p) => sheetHeight - Math.min(p, sheetHeight)\n );\n\n // Allow snapping to the top of the sheet if detent is set to `content-height`\n if (detent === 'content-height' && !snapToValues.includes(0)) {\n snapToValues.unshift(0);\n }\n\n // Get the closest snap point\n snapTo = getClosest(snapToValues, currentY);\n } else if (currentY / sheetHeight > DRAG_CLOSE_THRESHOLD) {\n // Close if dragged over enough far\n snapTo = sheetHeight;\n }\n\n snapTo = validateSnapTo({ snapTo, sheetHeight });\n\n // Update the spring value so that the sheet is animated to the snap point\n void animate(y, snapTo, animationOptions);\n\n if (snapPoints && onSnap) {\n const snapValue = Math.abs(Math.round(snapPoints[0] - snapTo));\n const snapIndex = snapPoints.indexOf(getClosest(snapPoints, snapValue)); // prettier-ignore\n onSnap(snapIndex);\n }\n\n const roundedSheetHeight = Math.round(sheetHeight);\n const shouldClose = snapTo + 2 >= roundedSheetHeight; // 2px tolerance\n\n if (shouldClose) onClose();\n }\n\n // Reset indicator rotation after dragging\n indicatorRotation.set(0);\n });\n\n // Trigger onSnap callback when sheet is opened or closed\n useEffect(() => {\n if (!snapPoints || !onSnap) return;\n const snapIndex = isOpen ? initialSnap : snapPoints.length - 1;\n onSnap(snapIndex);\n }, [isOpen]); // eslint-disable-line\n\n useImperativeHandle(ref, () => ({\n y,\n snapTo: (snapIndex: number) => {\n const sheetEl = sheetRef.current;\n\n if (snapPoints?.[snapIndex] !== undefined && sheetEl) {\n const sheetHeight = sheetEl.getBoundingClientRect().height;\n const snapPoint = snapPoints[snapIndex];\n const snapTo = validateSnapTo({\n snapTo: sheetHeight - snapPoint,\n sheetHeight,\n });\n\n void animate(y, snapTo, animationOptions);\n if (onSnap) onSnap(snapIndex);\n if (snapTo >= sheetHeight) onClose();\n }\n },\n }));\n\n useModalEffect(isOpen, rootId);\n\n // Framer Motion should handle body scroll locking but it's not working\n // properly on iOS. Scroll locking from React Aria seems to work much better.\n usePreventScroll({ isDisabled: disableScrollLocking || !isOpen });\n\n const dragProps = useMemo(() => {\n const dragProps: SheetContextType['dragProps'] = {\n drag: 'y',\n dragElastic: 0,\n dragMomentum: false,\n dragPropagation: false,\n onDrag,\n onDragStart,\n onDragEnd,\n };\n\n return disableDrag ? undefined : dragProps;\n }, [disableDrag, windowHeight]); // eslint-disable-line\n\n const context: SheetContextType = {\n y,\n sheetRef,\n isOpen,\n initialSnap,\n snapPoints,\n detent,\n indicatorRotation,\n callbacks,\n dragProps,\n windowHeight,\n animationOptions,\n reduceMotion,\n disableDrag,\n };\n\n const sheet = (\n <SheetContext.Provider value={context}>\n <motion.div\n {...rest}\n ref={ref}\n style={{ ...styles.wrapper, zIndex, visibility, ...style }}\n >\n <AnimatePresence>\n {/* NOTE: AnimatePresence requires us to set keys to children */}\n {isOpen ? (\n <SheetScrollerContextProvider>\n {Children.map(children, (child: any, i) =>\n cloneElement(child, { key: `sheet-child-${i}` })\n )}\n </SheetScrollerContextProvider>\n ) : null}\n </AnimatePresence>\n </motion.div>\n </SheetContext.Provider>\n );\n\n if (IS_SSR) return sheet;\n\n return createPortal(sheet, mountPoint ?? document.body);\n }\n);\n\nSheet.displayName = 'Sheet';\n\nexport default Sheet;\n","import {\n type MutableRefObject,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { type BoundingBox } from 'framer-motion';\n\nimport { IS_SSR } from './constants';\nimport { type SheetEvents } from './types';\nimport { applyRootStyles, cleanupRootStyles } from './utils';\n\nexport const useIsomorphicLayoutEffect = IS_SSR ? useEffect : useLayoutEffect;\n\nexport function useModalEffect(isOpen: boolean, rootId?: string) {\n const prevOpen = usePrevious(isOpen);\n\n // Automatically apply the iOS modal effect to the body when sheet opens/closes\n useEffect(() => {\n if (rootId && !prevOpen && isOpen) {\n applyRootStyles(rootId);\n } else if (rootId && !isOpen && prevOpen) {\n cleanupRootStyles(rootId);\n }\n }, [isOpen, prevOpen]); // eslint-disable-line\n\n // Make sure to cleanup modal styles on unmount\n useEffect(() => {\n return () => {\n if (rootId && isOpen) cleanupRootStyles(rootId);\n };\n }, [isOpen]); // eslint-disable-line\n}\n\nexport function useEventCallbacks(\n isOpen: boolean,\n callbacks: MutableRefObject<SheetEvents>\n) {\n const prevOpen = usePrevious(isOpen);\n const didOpen = useRef(false);\n\n // Because of AnimatePrecence we don't have access to latest isOpen value\n // so we need to read and write to a ref to determine if we are\n // opening or closing the sheet\n const handleAnimationComplete = useCallback(() => {\n if (!didOpen.current) {\n callbacks.current.onOpenEnd?.();\n didOpen.current = true;\n } else {\n callbacks.current.onCloseEnd?.();\n didOpen.current = false;\n }\n }, [isOpen, prevOpen]); // eslint-disable-line\n\n useEffect(() => {\n if (!prevOpen && isOpen) {\n callbacks.current.onOpenStart?.();\n } else if (!isOpen && prevOpen) {\n callbacks.current.onCloseStart?.();\n }\n }, [isOpen, prevOpen]); // eslint-disable-line\n\n return { handleAnimationComplete };\n}\n\nexport function useDimensions() {\n const [dimensions, setDimensions] = useState({ height: 0, width: 0 });\n\n useIsomorphicLayoutEffect(() => {\n function handler() {\n setDimensions({\n height: window.innerHeight,\n width: window.innerWidth,\n });\n }\n\n handler();\n\n window.addEventListener('resize', handler);\n\n return () => {\n window.removeEventListener('resize', handler);\n };\n }, []);\n\n return dimensions;\n}\n\nexport function usePrevious<T>(state: T): T | undefined {\n const ref = useRef<T>();\n\n useEffect(() => {\n ref.current = state;\n });\n\n return ref.current;\n}\n\n// Userland version of the `useEffectEvent` React hook:\n// RFC: https://react.dev/reference/react/experimental_useEffectEvent\nexport function useEffectEvent<T extends (...args: any[]) => any>(handler: T) {\n const handlerRef = useRef<T>();\n\n useIsomorphicLayoutEffect(() => {\n handlerRef.current = handler;\n });\n\n return useCallback((...args: any[]) => {\n const fn = handlerRef.current;\n return fn?.(...args);\n }, []) as T;\n}\n\n// This is a hacky way to fix a bug in framer-motion where the drag\n// constraints are not updated when window is resized.\n// https://github.com/framer/motion/issues/1659\nconst constraints: BoundingBox = { bottom: 0, top: 0, left: 0, right: 0 };\n\nexport function useDragConstraints() {\n const constraintsRef = useRef<any>(null);\n const onMeasureDragConstraints = useCallback(() => constraints, []);\n return { constraintsRef, onMeasureDragConstraints };\n}\n","export const MAX_HEIGHT = 'calc(100% - env(safe-area-inset-top) - 34px)';\n\nexport const IS_SSR = typeof window === 'undefined';\n\nexport const DEFAULT_TWEEN_CONFIG = {\n ease: 'easeOut',\n duration: 0.2,\n};\n\nexport const REDUCED_MOTION_TWEEN_CONFIG = {\n ease: 'linear',\n duration: 0.01,\n};\n\nexport const DRAG_CLOSE_THRESHOLD = 0.6;\n\nexport const DRAG_VELOCITY_THRESHOLD = 500;\n","import { type ForwardedRef, type RefCallback } from 'react';\n\nexport function getClosest(nums: number[], goal: number) {\n let closest = nums[0];\n let minDifference = Math.abs(nums[0] - goal);\n\n for (let i = 1; i < nums.length; i++) {\n const difference = Math.abs(nums[i] - goal);\n if (difference < minDifference) {\n closest = nums[i];\n minDifference = difference;\n }\n }\n\n return closest;\n}\n\nexport function applyRootStyles(rootId: string) {\n const body = document.querySelector('body') as HTMLBodyElement;\n const root = document.querySelector(`#${rootId}`) as HTMLDivElement;\n\n if (root) {\n const p = 24;\n const h = window.innerHeight;\n const s = (h - p) / h;\n body.style.backgroundColor = '#000';\n root.style.overflow = 'hidden';\n root.style.willChange = 'transform';\n root.style.transition =\n 'transform 200ms ease-in-out, border-radius 200ms linear';\n root.style.transform = `translateY(calc(env(safe-area-inset-top) + ${p / 2}px)) scale(${s})`; // prettier-ignore\n root.style.borderTopRightRadius = '10px';\n root.style.borderTopLeftRadius = '10px';\n }\n}\n\nexport function cleanupRootStyles(rootId: string) {\n const body = document.querySelector('body') as HTMLBodyElement;\n const root = document.getElementById(rootId) as HTMLDivElement;\n\n function onTransitionEnd() {\n root.style.removeProperty('overflow');\n root.style.removeProperty('will-change');\n root.style.removeProperty('transition');\n body.style.removeProperty('background-color');\n root.removeEventListener('transitionend', onTransitionEnd);\n }\n\n if (root) {\n // Start animating back\n root.style.removeProperty('border-top-right-radius');\n root.style.removeProperty('border-top-left-radius');\n root.style.removeProperty('transform');\n\n // Remove temp properties after animation is finished\n root.addEventListener('transitionend', onTransitionEnd);\n }\n}\n\nexport function inDescendingOrder(arr: number[]) {\n for (let i = 0; i < arr.length; i++) {\n if (arr[i + 1] > arr[i]) return false;\n }\n\n return true;\n}\n\nexport function validateSnapTo({\n snapTo,\n sheetHeight,\n}: {\n snapTo: number;\n sheetHeight: number;\n}) {\n if (snapTo < 0) {\n console.warn(\n `Snap point is out of bounds. Sheet height is ${sheetHeight} but snap point is ${\n sheetHeight + Math.abs(snapTo)\n }.`\n );\n }\n\n return Math.max(Math.round(snapTo), 0);\n}\n\nexport function mergeRefs<T = any>(\n refs: Array<ForwardedRef<T>>\n): RefCallback<T> {\n return (value: any) => {\n refs.forEach((ref: any) => {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref) {\n ref.current = value;\n }\n });\n };\n}\n\nexport function isTouchDevice() {\n if (typeof window === 'undefined') return false;\n return 'ontouchstart' in window || navigator.maxTouchPoints > 0;\n}\n","import React, { type ReactNode, createContext, useContext, useState } from 'react';\nimport { type SheetScrollerContextType, type SheetContextType } from './types';\n\nexport const SheetContext = createContext<SheetContextType | undefined>(\n undefined\n);\n\nexport const useSheetContext = () => {\n const context = useContext(SheetContext);\n if (!context) throw Error('Sheet context error');\n return context;\n};\n\nexport const SheetScrollerContext = createContext<\n SheetScrollerContextType | undefined\n>(undefined);\n\nexport function SheetScrollerContextProvider({\n children,\n}: {\n children: ReactNode;\n}) {\n const sheetContext = useSheetContext();\n const [disableDrag, setDisableDrag] = useState(!!sheetContext.disableDrag);\n\n function setDragEnabled() {\n if (!sheetContext.disableDrag) setDisableDrag(false);\n }\n\n function setDragDisabled() {\n if (!disableDrag) setDisableDrag(true);\n }\n\n return (\n <SheetScrollerContext.Provider\n value={{ disableDrag, setDragEnabled, setDragDisabled }}\n >\n {children}\n </SheetScrollerContext.Provider>\n );\n}\n\nexport const useSheetScrollerContext = () => {\n const context = useContext(SheetScrollerContext);\n if (!context) throw Error('Sheet scroller context error');\n return context;\n};\n","// Source: https://github.com/adobe/react-spectrum/blob/main/packages/@react-aria/overlays/src/usePreventScroll.ts\nimport {\n chain,\n getScrollParent,\n isIOS,\n useLayoutEffect,\n} from '@react-aria/utils';\n\ninterface PreventScrollOptions {\n /** Whether the scroll lock is disabled. */\n isDisabled?: boolean;\n}\n\nconst visualViewport =\n typeof window !== 'undefined' ? (window as any).visualViewport : undefined;\n\n// HTML input types that do not cause the software keyboard to appear.\nconst nonTextInputTypes = new Set([\n 'checkbox',\n 'radio',\n 'range',\n 'color',\n 'file',\n 'image',\n 'button',\n 'submit',\n 'reset',\n]);\n\n// The number of active usePreventScroll calls. Used to determine whether to revert back to the original page style/scroll position\nlet preventScrollCount = 0;\nlet restore: any;\n\n/**\n * Prevents scrolling on the document body on mount, and\n * restores it on unmount. Also ensures that content does not\n * shift due to the scrollbars disappearing.\n */\nexport function usePreventScroll(options: PreventScrollOptions = {}) {\n const { isDisabled } = options;\n\n useLayoutEffect(() => {\n if (isDisabled) {\n return;\n }\n\n preventScrollCount++;\n if (preventScrollCount === 1) {\n if (isIOS()) {\n restore = preventScrollMobileSafari();\n } else {\n restore = preventScrollStandard();\n }\n }\n\n return () => {\n preventScrollCount--;\n if (preventScrollCount === 0) {\n restore();\n }\n };\n }, [isDisabled]);\n}\n\n// For most browsers, all we need to do is set `overflow: hidden` on the root element, and\n// add some padding to prevent the page from shifting when the scrollbar is hidden.\nfunction preventScrollStandard() {\n return chain(\n setStyle(\n document.documentElement,\n 'paddingRight',\n `${window.innerWidth - document.documentElement.clientWidth}px`\n ),\n setStyle(document.documentElement, 'overflow', 'hidden')\n );\n}\n\n// Mobile Safari is a whole different beast. Even with overflow: hidden,\n// it still scrolls the page in many situations:\n//\n// 1. When the bottom toolbar and address bar are collapsed, page scrolling is always allowed.\n// 2. When the keyboard is visible, the viewport does not resize. Instead, the keyboard covers part of\n// it, so it becomes scrollable.\n// 3. When tapping on an input, the page always scrolls so that the input is centered in the visual viewport.\n// This may cause even fixed position elements to scroll off the screen.\n// 4. When using the next/previous buttons in the keyboard to navigate between inputs, the whole page always\n// scrolls, even if the input is inside a nested scrollable element that could be scrolled instead.\n//\n// In order to work around these cases, and prevent scrolling without jankiness, we do a few things:\n//\n// 1. Prevent default on `touchmove` events that are not in a scrollable element. This prevents touch scrolling\n// on the window.\n// 2. Prevent default on `touchmove` events inside a scrollable element when the scroll position is at the\n// top or bottom. This avoids the whole page scrolling instead, but does prevent overscrolling.\n// 3. Prevent default on `touchend` events on input elements and handle focusing the element ourselves.\n// 4. When focusing an input, apply a transform to trick Safari into thinking the input is at the top\n// of the page, which prevents it from scrolling the page. After the input is focused, scroll the element\n// into view ourselves, without scrolling the whole page.\n// 5. Offset the body by the scroll position using a negative margin and scroll to the top. This should appear the\n// same visually, but makes the actual scroll position always zero. This is required to make all of the\n// above work or Safari will still try to scroll the page when focusing an input.\n// 6. As a last resort, handle window scroll events, and scroll back to the top. This can happen when attempting\n// to navigate to an input with the next/previous buttons that's outside a modal.\nfunction preventScrollMobileSafari() {\n let scrollable: Element | undefined;\n let lastY = 0;\n\n const onTouchStart = (e: TouchEvent) => {\n // Store the nearest scrollable parent element from the element that the user touched.\n scrollable = getScrollParent(e.target as Element);\n if (\n scrollable === document.documentElement &&\n scrollable === document.body\n ) {\n return;\n }\n\n lastY = e.changedTouches[0].pageY;\n };\n\n const onTouchMove = (e: TouchEvent) => {\n // In special situations, `onTouchStart` may be called without `onTouchStart` being called.\n // (e.g. when the user places a finger on the screen before the <Sheet> is mounted and then moves the finger after it is mounted).\n // If `onTouchStart` is not called, `scrollable` is `undefined`. Therefore, such cases are ignored.\n if (scrollable === undefined) {\n return;\n }\n\n // Prevent scrolling the window.\n if (\n scrollable === document.documentElement ||\n scrollable === document.body\n ) {\n e.preventDefault();\n return;\n }\n\n // Prevent scrolling up when at the top and scrolling down when at the bottom\n // of a nested scrollable area, otherwise mobile Safari will start scrolling\n // the window instead. Unfortunately, this disables bounce scrolling when at\n // the top but it's the best we can do.\n const y = e.changedTouches[0].pageY;\n const scrollTop = scrollable.scrollTop;\n const bottom = scrollable.scrollHeight - scrollable.clientHeight;\n\n // Fix for: https://github.com/adobe/react-spectrum/pull/3780/files\n if (bottom === 0) {\n return;\n }\n\n if ((scrollTop <= 0 && y > lastY) || (scrollTop >= bottom && y < lastY)) {\n e.preventDefault();\n }\n\n lastY = y;\n };\n\n const onTouchEnd = (e: TouchEvent) => {\n const target = e.target as HTMLElement;\n\n // Apply this change if we're not already focused on the target element\n if (willOpenKeyboard(target) && target !== document.activeElement) {\n e.preventDefault();\n\n // Apply a transform to trick Safari into thinking the input is at the top of the page\n // so it doesn't try to scroll it into view. When tapping on an input, this needs to\n // be done before the \"focus\" event, so we have to focus the element ourselves.\n target.style.transform = 'translateY(-2000px)';\n target.focus();\n requestAnimationFrame(() => {\n target.style.transform = '';\n });\n }\n };\n\n const onFocus = (e: FocusEvent) => {\n const target = e.target as HTMLElement;\n if (willOpenKeyboard(target)) {\n // Transform also needs to be applied in the focus event in cases where focus moves\n // other than tapping on an input directly, e.g. the next/previous buttons in the\n // software keyboard. In these cases, it seems applying the transform in the focus event\n // is good enough, whereas when tapping an input, it must be done before the focus event. 🤷♂️\n target.style.transform = 'translateY(-2000px)';\n requestAnimationFrame(() => {\n target.style.transform = '';\n\n // This will have prevented the browser from scrolling the focused element into view,\n // so we need to do this ourselves in a way that doesn't cause the whole page to scroll.\n if (visualViewport) {\n if (visualViewport.height < window.innerHeight) {\n // If the keyboard is already visible, do this after one additional frame\n // to wait for the transform to be removed.\n requestAnimationFrame(() => {\n scrollIntoView(target);\n });\n } else {\n // Otherwise, wait for the visual viewport to resize before scrolling so we can\n // measure the correct position to scroll to.\n visualViewport.addEventListener(\n 'resize',\n () => {\n scrollIntoView(target);\n },\n { once: true }\n );\n }\n }\n });\n }\n };\n\n const onWindowScroll = () => {\n // Last resort. If the window scrolled, scroll it back to the top.\n // It should always be at the top because the body will have a negative margin (see below).\n window.scrollTo(0, 0);\n };\n\n // Record the original scroll position so we can restore it.\n // Then apply a negative margin to the body to offset it by the scroll position. This will\n // enable us to scroll the window to the top, which is required for the rest of this to work.\n const scrollX = window.pageXOffset;\n const scrollY = window.pageYOffset;\n\n const restoreStyles = chain(\n setStyle(\n document.documentElement,\n 'paddingRight',\n `${window.innerWidth - document.documentElement.clientWidth}px`\n ),\n setStyle(document.documentElement, 'overflow', 'hidden'),\n setStyle(document.body, 'marginTop', `-${scrollY}px`)\n );\n\n // Scroll to the top. The negative margin on the body will make this appear the same.\n window.scrollTo(0, 0);\n\n const removeEvents = chain(\n addEvent(document, 'touchstart', onTouchStart, {\n passive: false,\n capture: true,\n }),\n addEvent(document, 'touchmove', onTouchMove, {\n passive: false,\n capture: true,\n }),\n addEvent(document, 'touchend', onTouchEnd, {\n passive: false,\n capture: true,\n }),\n addEvent(document, 'focus', onFocus, true),\n addEvent(window, 'scroll', onWindowScroll)\n );\n\n return () => {\n // Restore styles and scroll the page back to where it was.\n restoreStyles();\n removeEvents();\n window.scrollTo(scrollX, scrollY);\n };\n}\n\n// Sets a CSS property on an element, and returns a function to revert it to the previous value.\nfunction setStyle(element: any, style: string, value: string) {\n const cur = element.style[style];\n element.style[style] = value;\n\n return () => {\n element.style[style] = cur;\n };\n}\n\n// Adds an event listener to an element, and returns a function to remove it.\nfunction addEvent<K extends keyof GlobalEventHandlersEventMap>(\n target: EventTarget,\n event: K,\n handler: (this: Document, ev: GlobalEventHandlersEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n) {\n target.addEventListener(event, handler as any, options);\n return () => {\n target.removeEventListener(event, handler as any, options);\n };\n}\n\nfunction scrollIntoView(target: Element) {\n const root = document.scrollingElement || document.documentElement;\n while (target && target !== root) {\n // Find the parent scrollable element and adjust the scroll position if the target is not already in view.\n const scrollable = getScrollParent(target);\n if (\n scrollable !== document.documentElement &&\n scrollable !== document.body &&\n scrollable !== target\n ) {\n const scrollableTop = scrollable.getBoundingClientRect().top;\n const targetTop = target.getBoundingClientRect().top;\n if (targetTop > scrollableTop + target.clientHeight) {\n scrollable.scrollTop += targetTop - scrollableTop;\n }\n }\n\n target = scrollable.parentElement as any;\n }\n}\n\nfunction willOpenKeyboard(target: Element) {\n return (\n (target instanceof HTMLInputElement &&\n !nonTextInputTypes.has(target.type)) ||\n target instanceof HTMLTextAreaElement ||\n (target instanceof HTMLElement && target.isContentEditable)\n );\n}\n","import { type Properties } from 'csstype';\n\nconst styles: Record<string, Properties> = {\n wrapper: {\n position: 'fixed',\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n overflow: 'hidden',\n pointerEvents: 'none',\n },\n backdrop: {\n zIndex: 1,\n position: 'fixed',\n top: 0,\n left: 0,\n width: '100%',\n height: '100%',\n backgroundColor: 'rgba(0, 0, 0, 0.2)',\n touchAction: 'none', // Disable iOS body scrolling\n border: 'none',\n },\n container: {\n zIndex: 2,\n position: 'absolute',\n left: 0,\n bottom: 0,\n width: '100%',\n backgroundColor: '#fff',\n borderTopRightRadius: '8px',\n borderTopLeftRadius: '8px',\n boxShadow: '0px -2px 16px rgba(0, 0, 0, 0.3)',\n display: 'flex',\n flexDirection: 'column',\n pointerEvents: 'auto',\n },\n headerWrapper: {\n width: '100%',\n },\n header: {\n height: '40px',\n width: '100%',\n position: 'relative',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n },\n indicator: {\n width: '18px',\n height: '4px',\n borderRadius: '99px',\n backgroundColor: '#ddd',\n },\n content: {\n flexGrow: 1,\n display: 'flex',\n flexDirection: 'column',\n minHeight: '0px',\n position: 'relative',\n },\n scroller: {\n height: '100%',\n overflowY: 'auto',\n },\n};\n\nexport default styles;\n","import React, { forwardRef } from 'react';\nimport { motion } from 'framer-motion';\n\nimport { type SheetContainerProps } from './types';\nimport { useSheetContext } from './context';\nimport { useEventCallbacks } from './hooks';\nimport { MAX_HEIGHT } from './constants';\nimport { mergeRefs } from './utils';\nimport styles from './styles';\n\nconst SheetContainer = forwardRef<any, SheetContainerProps>(\n ({ children, style = {}, className = '', ...rest }, ref) => {\n const {\n y,\n isOpen,\n callbacks,\n snapPoints,\n initialSnap = 0,\n sheetRef,\n windowHeight,\n detent,\n animationOptions,\n reduceMotion,\n } = useSheetContext();\n\n const { handleAnimationComplete } = useEventCallbacks(isOpen, callbacks);\n const initialY = snapPoints ? snapPoints[0] - snapPoints[initialSnap] : 0;\n const maxSnapHeight = snapPoints ? snapPoints[0] : null;\n\n const height =\n maxSnapHeight !== null\n ? `min(${maxSnapHeight}px, ${MAX_HEIGHT})`\n : MAX_HEIGHT;\n\n return (\n <motion.div\n {...rest}\n ref={mergeRefs([sheetRef, ref])}\n className={`react-modal-sheet-container ${className}`}\n style={{\n ...styles.container,\n ...style,\n ...(detent === 'full-height' && { height }),\n ...(detent === 'content-height' && { maxHeight: height }),\n y,\n }}\n initial={reduceMotion ? false : { y: windowHeight }}\n animate={{ y: initialY, transition: animationOptions }}\n exit={{ y: windowHeight, transition: animationOptions }}\n onAnimationComplete={handleAnimationComplete}\n >\n {children}\n </motion.div>\n );\n }\n);\n\nSheetContainer.displayName = 'SheetContainer';\n\nexport default SheetContainer;\n","import React, { forwardRef } from 'react';\nimport { motion } from 'framer-motion';\n\nimport { type SheetDraggableProps } from './types';\nimport { useSheetScrollerContext, useSheetContext } from './context';\nimport { useDragConstraints } from './hooks';\nimport { mergeRefs } from './utils';\nimport styles from './styles';\n\nconst SheetContent = forwardRef<any, SheetDraggableProps>(\n ({ children, style, disableDrag, className = '', ...rest }, ref) => {\n const sheetContext = useSheetContext();\n const sheetScrollerContext = useSheetScrollerContext();\n const { constraintsRef, onMeasureDragConstraints } = useDragConstraints();\n\n const dragProps =\n disableDrag || sheetScrollerContext.disableDrag\n ? undefined\n : sheetContext.dragProps;\n\n return (\n <motion.div\n {...rest}\n ref={mergeRefs([ref, constraintsRef])}\n className={`react-modal-sheet-content ${className}`}\n style={{ ...styles.content, ...style }}\n {...dragProps}\n dragConstraints={constraintsRef}\n onMeasureDragConstraints={onMeasureDragConstraints}\n >\n {children}\n </motion.div>\n );\n }\n);\n\nSheetContent.displayName = 'SheetContent';\n\nexport default SheetContent;\n","import React, { forwardRef } from 'react';\nimport { motion, useTransform } from 'framer-motion';\n\nimport { type SheetDraggableProps } from './types';\nimport { useSheetContext } from './context';\nimport { useDragConstraints } from './hooks';\nimport { mergeRefs } from './utils';\nimport styles from './styles';\n\nconst SheetHeader = forwardRef<any, SheetDraggableProps>(\n ({ children, style, disableDrag, ...rest }, ref) => {\n const { indicatorRotation, dragProps } = useSheetContext();\n const { constraintsRef, onMeasureDragConstraints } = useDragConstraints();\n const _dragProps = disableDrag ? undefined : dragProps;\n\n const indicator1Transform = useTransform(\n indicatorRotation,\n (r) => `translateX(2px) rotate(${r}deg)`\n );\n\n const indicator2Transform = useTransform(\n indicatorRotation,\n (r) => `translateX(-2px) rotate(${-1 * r}deg)`\n );\n\n return (\n <motion.div\n {...rest}\n ref={mergeRefs([ref, constraintsRef])}\n style={{ ...styles.headerWrapper, ...style }}\n {..._dragProps}\n dragConstraints={constraintsRef}\n onMeasureDragConstraints={onMeasureDragConstraints}\n >\n {children || (\n <div className=\"react-modal-sheet-header\" style={styles.header}>\n <motion.span\n className=\"react-modal-sheet-drag-indicator\"\n style={{ ...styles.indicator, transform: indicator1Transform }}\n />\n <motion.span\n className=\"react-modal-sheet-drag-indicator\"\n style={{ ...styles.indicator, transform: indicator2Transform }}\n />\n </div>\n )}\n </motion.div>\n );\n }\n);\n\nSheetHeader.displayName = 'SheetHeader';\n\nexport default SheetHeader;\n","import React, { forwardRef } from 'react';\nimport { motion } from 'framer-motion';\n\nimport { type SheetBackdropProps } from './types';\nimport styles from './styles';\n\nconst isClickable = (props: any) => !!props.onClick || !!props.onTap;\n\nconst SheetBackdrop = forwardRef<any, SheetBackdropProps>(\n ({ style = {}, className = '', ...rest }, ref) => {\n const Comp = isClickable(rest) ? motion.button : motion.div;\n const pointerEvents = isClickable(rest) ? 'auto' : 'none';\n\n return (\n <Comp\n {...rest}\n ref={ref}\n className={`react-modal-sheet-backdrop ${className}`}\n style={{ ...styles.backdrop, ...style, pointerEvents }}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n />\n );\n }\n);\n\nSheetBackdrop.displayName = 'SheetBackdrop';\n\nexport default SheetBackdrop;\n","import React, { type TouchEvent, type UIEvent, forwardRef } from 'react';\n\nimport { useSheetScrollerContext } from './context';\nimport { type SheetScrollerProps } from './types';\nimport { isTouchDevice } from './utils';\nimport styles from './styles';\n\nconst SheetScroller = forwardRef<any, SheetScrollerProps>(\n ({ draggableAt = 'top', children, style, className = '', ...rest }, ref) => {\n const sheetScrollerContext = useSheetScrollerContext();\n\n function determineDragState(element: HTMLDivElement) {\n const { scrollTop, scrollHeight, clientHeight } = element;\n const isScrollable = scrollHeight > clientHeight;\n\n if (!isScrollable) return;\n\n const isAtTop = scrollTop <= 0;\n const isAtBottom = scrollHeight - scrollTop === clientHeight;\n\n const shouldEnable =\n (draggableAt === 'top' && isAtTop) ||\n (draggableAt === 'bottom' && isAtBottom) ||\n (draggableAt === 'both' && (isAtTop || isAtBottom));\n\n if (shouldEnable) {\n sheetScrollerContext.setDragEnabled();\n } else {\n sheetScrollerContext.setDragDisabled();\n }\n }\n\n function onScroll(e: UIEvent<HTMLDivElement>) {\n determineDragState(e.currentTarget);\n }\n\n function onTouchStart(e: TouchEvent<HTMLDivElement>) {\n determineDragState(e.currentTarget);\n }\n\n const scrollProps = isTouchDevice()\n ? { onScroll, onTouchStart }\n : undefined;\n\n return (\n <div\n {...rest}\n ref={ref}\n className={`react-modal-sheet-scroller ${className}`}\n style={{ ...styles.scroller, ...style }}\n {...scrollProps}\n >\n {children}\n </div>\n );\n }\n);\n\nSheetScroller.displayName = 'SheetScroller';\n\nexport default SheetScroller;\n","import { type MotionValue } from 'framer-motion';\n\nimport _Sheet from './sheet';\nimport SheetContainer from './SheetContainer';\nimport SheetContent from './SheetContent';\nimport SheetHeader from './SheetHeader';\nimport SheetBackdrop from './SheetBackdrop';\nimport SheetScroller from './SheetScroller';\nimport { type SheetCompound } from './types';\n\nexport interface SheetRef {\n y: MotionValue<number>;\n snapTo: (index: number) => void;\n}\n\n// HACK: this is needed to get the typing to work properly...\nconst _SheetCompound: any = _Sheet;\n_SheetCompound.Container = SheetContainer;\n_SheetCompound.Header = SheetHeader;\n_SheetCompound.Content = SheetContent;\n_SheetCompound.Backdrop = SheetBackdrop;\n_SheetCompound.Scroller = SheetScroller;\n\nexport const Sheet = _SheetCompound as SheetCompound;\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/sheet.tsx","../src/hooks.tsx","../src/constants.ts","../src/utils.ts","../src/context.tsx","../src/use-prevent-scroll.ts","../src/styles.ts","../src/SheetContainer.tsx","../src/SheetContent.tsx","../src/SheetHeader.tsx","../src/SheetBackdrop.tsx","../src/SheetScroller.tsx","../src/index.tsx"],"names":["React","useEffect","useRef","useState","useLayoutEffect","dragProps","forwardRef","motion","useTransform","Sheet"],"mappings":";AAAA,OAAOA;A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YAAY,IAAI,GAAG,KAAK,GAAG,QAAQ;AAC1E,UAAM,uBAAuB,wBAAwB;AAErD,aAAS,mBAAmB,SAAyB;AACnD,YAAM,EAAE,WAAW,cAAc,aAAa,IAAI;AAClD,YAAM,eAAe,eAAe;AAEpC,UAAI,CAAC;AAAc;AAEnB,YAAM,UAAU,aAAa;AAC7B,YAAM,aAAa,eAAe,cAAc;AAEhD,YAAM,eACH,gBAAgB,SAAS,WACzB,gBAAgB,YAAY,cAC5B,gBAAgB,WAAW,WAAW;AAEzC,UAAI,cAAc;AAChB,6BAAqB,eAAe;AAAA,MACtC,OAAO;AACL,6BAAqB,gBAAgB;AAAA,MACvC;AAAA,IACF;AAEA,aAAS,SAAS,GAA4B;AAC5C,yBAAmB,EAAE,aAAa;AAAA,IACpC;AAEA,aAAS,aAAa,GAA+B;AACnD,yBAAmB,EAAE,aAAa;AAAA,IACpC;AAEA,UAAM,cAAc,cAAc,IAC9B,EAAE,UAAU,aAAa,IACzB;AAEJ,WACE,gBAAAN,OAAA;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACJ;AAAA,QACA,WAAW,8BAA8B,SAAS;AAAA,QAClD,OAAO,EAAE,GAAG,eAAO,UAAU,GAAG,MAAM;AAAA,QACrC,GAAG;AAAA;AAAA,MAEH;AAAA,IACH;AAAA,EAEJ;AACF;AAEA,cAAc,cAAc;AAE5B,IAAO,wBAAQ;;;AC5Cf,IAAM,iBAAsB;AAC5B,eAAe,YAAY;AAC3B,eAAe,SAAS;AACxB,eAAe,UAAU;AACzB,eAAe,WAAW;AAC1B,eAAe,WAAW;AAEnB,IAAMS,SAAQ","sourcesContent":["import React, {\n Children,\n cloneElement,\n forwardRef,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n} from 'react';\n\nimport { createPortal } from 'react-dom';\n\nimport {\n animate,\n AnimatePresence,\n motion,\n type PanInfo,\n type Transition,\n useMotionValue,\n useReducedMotion,\n useTransform,\n} from 'framer-motion';\n\nimport {\n useModalEffect,\n useDimensions,\n useIsomorphicLayoutEffect,\n useEffectEvent,\n} from './hooks';\n\nimport {\n REDUCED_MOTION_TWEEN_CONFIG,\n DEFAULT_TWEEN_CONFIG,\n DEFAULT_DRAG_CLOSE_THRESHOLD,\n DEFAULT_DRAG_VELOCITY_THRESHOLD,\n IS_SSR,\n} from './constants';\n\nimport { type SheetContextType, type SheetProps } from './types';\nimport { SheetScrollerContextProvider, SheetContext } from './context';\nimport { getClosest, inDescendingOrder, validateSnapTo } from './utils';\nimport { usePreventScroll } from './use-prevent-scroll';\nimport styles from './styles';\n\nconst Sheet = forwardRef<any, SheetProps>(\n (\n {\n onOpenStart,\n onOpenEnd,\n onClose,\n onCloseStart,\n onCloseEnd,\n onSnap,\n children,\n disableScrollLocking = false,\n isOpen,\n snapPoints: snapPointsProp,\n rootId,\n mountPoint,\n style,\n detent = 'full-height',\n initialSnap = 0,\n disableDrag = false,\n prefersReducedMotion = false,\n tweenConfig = DEFAULT_TWEEN_CONFIG,\n dragVelocityThreshold = DEFAULT_DRAG_VELOCITY_THRESHOLD,\n dragCloseThreshold = DEFAULT_DRAG_CLOSE_THRESHOLD,\n ...rest\n },\n ref\n ) => {\n const sheetRef = useRef<HTMLDivElement>(null);\n const indicatorRotation = useMotionValue(0);\n const { height: windowHeight } = useDimensions();\n const shouldReduceMotion = useReducedMotion();\n const reduceMotion = Boolean(prefersReducedMotion || shouldReduceMotion);\n const animationOptions: Transition = {\n type: 'tween',\n ...(reduceMotion ? REDUCED_MOTION_TWEEN_CONFIG : tweenConfig),\n };\n\n // NOTE: the inital value for `y` doesn't matter since it is overwritten by\n // the value driven by the `AnimatePresence` component when the sheet is opened\n // and after that it is driven by the gestures and/or snapping\n const y = useMotionValue(windowHeight);\n\n // +2 for tolerance in case the animated value is slightly off\n const zIndex = useTransform(y, (value) =>\n value + 2 >= windowHeight ? -1 : 9999999\n );\n const visibility = useTransform(y, (value) =>\n value + 2 >= windowHeight ? 'hidden' : 'visible'\n );\n\n // Keep the callback fns up-to-date so that they can be accessed inside\n // the effect without including them to the dependencies array\n const callbacks = useRef({\n onOpenStart,\n onOpenEnd,\n onCloseStart,\n onCloseEnd,\n });\n\n useIsomorphicLayoutEffect(() => {\n callbacks.current = {\n onOpenStart,\n onOpenEnd,\n onCloseStart,\n onCloseEnd,\n };\n });\n\n let snapPoints: number[] | undefined = snapPointsProp;\n\n if (snapPoints) {\n // Convert negative / percentage snap points to absolute values\n snapPoints = snapPoints.map((point) => {\n // Percentage values e.g. between 0.0 and 1.0\n if (point > 0 && point <= 1) return Math.round(point * windowHeight);\n return point < 0 ? windowHeight + point : point; // negative values\n });\n\n console.assert(\n inDescendingOrder(snapPoints) || windowHeight === 0,\n `Snap points need to be in descending order got: [${snapPoints.join(\n ', '\n )}]`\n );\n }\n\n const onDrag = useEffectEvent((_, { delta }: PanInfo) => {\n // Update drag indicator rotation based on drag velocity\n const velocity = y.getVelocity();\n\n if (velocity > 0) indicatorRotation.set(10);\n if (velocity < 0) indicatorRotation.set(-10);\n\n // Make sure user cannot drag beyond the top of the sheet\n y.set(Math.max(y.get() + delta.y, 0));\n });\n\n const onDragStart = useEffectEvent(() => {\n // Find focused input inside the sheet and blur it when dragging starts\n // to prevent a weird ghost caret \"bug\" on mobile\n const focusedElement = document.activeElement as HTMLElement | null;\n if (!focusedElement || !sheetRef.current) return;\n\n const isInput =\n focusedElement.tagName === 'INPUT' ||\n focusedElement.tagName === 'TEXTAREA';\n\n // Only blur the focused element if it's inside the sheet\n if (isInput && sheetRef.current.contains(focusedElement)) {\n focusedElement.blur();\n }\n });\n\n const onDragEnd = useEffectEvent((_, { velocity }: PanInfo) => {\n if (velocity.y > dragVelocityThreshold) {\n // User flicked the sheet down\n onClose();\n } else {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const sheetHeight = sheetRef.current!.getBoundingClientRect().height;\n const currentY = y.get();\n\n let snapTo = 0;\n\n if (snapPoints) {\n const snapToValues = snapPoints.map(\n (p) => sheetHeight - Math.min(p, sheetHeight)\n );\n\n // Allow snapping to the top of the sheet if detent is set to `content-height`\n if (detent === 'content-height' && !snapToValues.includes(0)) {\n snapToValues.unshift(0);\n }\n\n // Get the closest snap point\n snapTo = getClosest(snapToValues, currentY);\n } else if (currentY / sheetHeight > dragCloseThreshold) {\n // Close if dragged over enough far\n snapTo = sheetHeight;\n }\n\n snapTo = validateSnapTo({ snapTo, sheetHeight });\n\n // Update the spring value so that the sheet is animated to the snap point\n void animate(y, snapTo, animationOptions);\n\n if (snapPoints && onSnap) {\n const snapValue = Math.abs(Math.round(snapPoints[0] - snapTo));\n const snapIndex = snapPoints.indexOf(getClosest(snapPoints, snapValue)); // prettier-ignore\n onSnap(snapIndex);\n }\n\n const roundedSheetHeight = Math.round(sheetHeight);\n const shouldClose = snapTo + 2 >= roundedSheetHeight; // 2px tolerance\n\n if (shouldClose) onClose();\n }\n\n // Reset indicator rotation after dragging\n indicatorRotation.set(0);\n });\n\n // Trigger onSnap callback when sheet is opened or closed\n useEffect(() => {\n if (!snapPoints || !onSnap) return;\n const snapIndex = isOpen ? initialSnap : snapPoints.length - 1;\n onSnap(snapIndex);\n }, [isOpen]); // eslint-disable-line\n\n useImperativeHandle(ref, () => ({\n y,\n snapTo: (snapIndex: number) => {\n const sheetEl = sheetRef.current;\n\n if (snapPoints?.[snapIndex] !== undefined && sheetEl) {\n const sheetHeight = sheetEl.getBoundingClientRect().height;\n const snapPoint = snapPoints[snapIndex];\n const snapTo = validateSnapTo({\n snapTo: sheetHeight - snapPoint,\n sheetHeight,\n });\n\n void animate(y, snapTo, animationOptions);\n if (onSnap) onSnap(snapIndex);\n if (snapTo >= sheetHeight) onClose();\n }\n },\n }));\n\n useModalEffect(isOpen, rootId);\n\n // Framer Motion should handle body scroll locking but it's not working\n // properly on iOS. Scroll locking from React Aria seems to work much better.\n usePreventScroll({ isDisabled: disableScrollLocking || !isOpen });\n\n const dragProps = useMemo(() => {\n const dragProps: SheetContextType['dragProps'] = {\n drag: 'y',\n dragElastic: 0,\n dragMomentum: false,\n dragPropagation: false,\n onDrag,\n onDragStart,\n onDragEnd,\n };\n\n return disableDrag ? undefined : dragProps;\n }, [disableDrag, windowHeight]); // eslint-disable-line\n\n const context: SheetContextType = {\n y,\n sheetRef,\n isOpen,\n initialSnap,\n snapPoints,\n detent,\n indicatorRotation,\n callbacks,\n dragProps,\n windowHeight,\n animationOptions,\n reduceMotion,\n disableDrag,\n };\n\n const sheet = (\n <SheetContext.Provider value={context}>\n <motion.div\n {...rest}\n ref={ref}\n style={{ ...styles.wrapper, zIndex, visibility, ...style }}\n >\n <AnimatePresence>\n {/* NOTE: AnimatePresence requires us to set keys to children */}\n {isOpen ? (\n <SheetScrollerContextProvider>\n {Children.map(children, (child: any, i) =>\n cloneElement(child, { key: `sheet-child-${i}` })\n )}\n </SheetScrollerContextProvider>\n ) : null}\n </AnimatePresence>\n </motion.div>\n </SheetContext.Provider>\n );\n\n if (IS_SSR) return sheet;\n\n return createPortal(sheet, mountPoint ?? document.body);\n }\n);\n\nSheet.displayName = 'Sheet';\n\nexport default Sheet;\n","import {\n type MutableRefObject,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { isBrowser, type BoundingBox } from 'framer-motion';\n\nimport { IS_SSR } from './constants';\nimport { type SheetEvents } from './types';\nimport { applyRootStyles, cleanupRootStyles } from './utils';\n\nexport const useIsomorphicLayoutEffect = IS_SSR ? useEffect : useLayoutEffect;\n\nexport function useModalEffect(isOpen: boolean, rootId?: string) {\n const prevOpen = usePrevious(isOpen);\n\n // Automatically apply the iOS modal effect to the body when sheet opens/closes\n useEffect(() => {\n if (rootId && !prevOpen && isOpen) {\n applyRootStyles(rootId);\n } else if (rootId && !isOpen && prevOpen) {\n cleanupRootStyles(rootId);\n }\n }, [isOpen, prevOpen]); // eslint-disable-line\n\n // Make sure to cleanup modal styles on unmount\n useEffect(() => {\n return () => {\n if (rootId && isOpen) cleanupRootStyles(rootId);\n };\n }, [isOpen]); // eslint-disable-line\n}\n\nexport function useEventCallbacks(\n isOpen: boolean,\n callbacks: MutableRefObject<SheetEvents>\n) {\n const prevOpen = usePrevious(isOpen);\n const didOpen = useRef(false);\n\n // Because of AnimatePrecence we don't have access to latest isOpen value\n // so we need to read and write to a ref to determine if we are\n // opening or closing the sheet\n const handleAnimationComplete = useCallback(() => {\n if (!didOpen.current) {\n callbacks.current.onOpenEnd?.();\n didOpen.current = true;\n } else {\n callbacks.current.onCloseEnd?.();\n didOpen.current = false;\n }\n }, [isOpen, prevOpen]); // eslint-disable-line\n\n useEffect(() => {\n if (!prevOpen && isOpen) {\n callbacks.current.onOpenStart?.();\n } else if (!isOpen && prevOpen) {\n callbacks.current.onCloseStart?.();\n }\n }, [isOpen, prevOpen]); // eslint-disable-line\n\n return { handleAnimationComplete };\n}\n\nexport function useDimensions() {\n const [dimensions, setDimensions] = useState({\n height: isBrowser ? window.innerHeight : 0,\n width: isBrowser ? window.innerWidth : 0,\n });\n\n useIsomorphicLayoutEffect(() => {\n function handler() {\n setDimensions({\n height: window.innerHeight,\n width: window.innerWidth,\n });\n }\n\n handler();\n\n window.addEventListener('resize', handler);\n\n return () => {\n window.removeEventListener('resize', handler);\n };\n }, []);\n\n return dimensions;\n}\n\nexport function usePrevious<T>(state: T): T | undefined {\n const ref = useRef<T>();\n\n useEffect(() => {\n ref.current = state;\n });\n\n return ref.current;\n}\n\n// Userland version of the `useEffectEvent` React hook:\n// RFC: https://react.dev/reference/react/experimental_useEffectEvent\nexport function useEffectEvent<T extends (...args: any[]) => any>(handler: T) {\n const handlerRef = useRef<T>();\n\n useIsomorphicLayoutEffect(() => {\n handlerRef.current = handler;\n });\n\n return useCallback((...args: any[]) => {\n const fn = handlerRef.current;\n return fn?.(...args);\n }, []) as T;\n}\n\n// This is a hacky way to fix a bug in framer-motion where the drag\n// constraints are not updated when window is resized.\n// https://github.com/framer/motion/issues/1659\nconst constraints: BoundingBox = { bottom: 0, top: 0, left: 0, right: 0 };\n\nexport function useDragConstraints() {\n const constraintsRef = useRef<any>(null);\n const onMeasureDragConstraints = useCallback(() => constraints, []);\n return { constraintsRef, onMeasureDragConstraints };\n}\n","export const MAX_HEIGHT = 'calc(100% - env(safe-area-inset-top) - 34px)';\n\nexport const IS_SSR = typeof window === 'undefined';\n\nexport const DEFAULT_TWEEN_CONFIG = {\n ease: 'easeOut',\n duration: 0.2,\n};\n\nexport const REDUCED_MOTION_TWEEN_CONFIG = {\n ease: 'linear',\n duration: 0.01,\n};\n\nexport const DEFAULT_DRAG_CLOSE_THRESHOLD = 0.6;\n\nexport const DEFAULT_DRAG_VELOCITY_THRESHOLD = 500;\n","import { type ForwardedRef, type RefCallback } from 'react';\n\nexport function getClosest(nums: number[], goal: number) {\n let closest = nums[0];\n let minDifference = Math.abs(nums[0] - goal);\n\n for (let i = 1; i < nums.length; i++) {\n const difference = Math.abs(nums[i] - goal);\n if (difference < minDifference) {\n closest = nums[i];\n minDifference = difference;\n }\n }\n\n return closest;\n}\n\nexport function applyRootStyles(rootId: string) {\n const body = document.querySelector('body') as HTMLBodyElement;\n const root = document.querySelector(`#${rootId}`) as HTMLDivElement;\n\n if (root) {\n const p = 24;\n const h = window.innerHeight;\n const s = (h - p) / h;\n body.style.backgroundColor = '#000';\n root.style.overflow = 'hidden';\n root.style.willChange = 'transform';\n root.style.transition =\n 'transform 200ms ease-in-out, border-radius 200ms linear';\n root.style.transform = `translateY(calc(env(safe-area-inset-top) + ${p / 2}px)) scale(${s})`; // prettier-ignore\n root.style.borderTopRightRadius = '10px';\n root.style.borderTopLeftRadius = '10px';\n }\n}\n\nexport function cleanupRootStyles(rootId: string) {\n const body = document.querySelector('body') as HTMLBodyElement;\n const root = document.getElementById(rootId) as HTMLDivElement;\n\n function onTransitionEnd() {\n root.style.removeProperty('overflow');\n root.style.removeProperty('will-change');\n root.style.removeProperty('transition');\n body.style.removeProperty('background-color');\n root.removeEventListener('transitionend', onTransitionEnd);\n }\n\n if (root) {\n // Start animating back\n root.style.removeProperty('border-top-right-radius');\n root.style.removeProperty('border-top-left-radius');\n root.style.removeProperty('transform');\n\n // Remove temp properties after animation is finished\n root.addEventListener('transitionend', onTransitionEnd);\n }\n}\n\nexport function inDescendingOrder(arr: number[]) {\n for (let i = 0; i < arr.length; i++) {\n if (arr[i + 1] > arr[i]) return false;\n }\n\n return true;\n}\n\nexport function validateSnapTo({\n snapTo,\n sheetHeight,\n}: {\n snapTo: number;\n sheetHeight: number;\n}) {\n if (snapTo < 0) {\n console.warn(\n `Snap point is out of bounds. Sheet height is ${sheetHeight} but snap point is ${\n sheetHeight + Math.abs(snapTo)\n }.`\n );\n }\n\n return Math.max(Math.round(snapTo), 0);\n}\n\nexport function mergeRefs<T = any>(\n refs: Array<ForwardedRef<T>>\n): RefCallback<T> {\n return (value: any) => {\n refs.forEach((ref: any) => {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref) {\n ref.current = value;\n }\n });\n };\n}\n\nexport function isTouchDevice() {\n if (typeof window === 'undefined') return false;\n return 'ontouchstart' in window || navigator.maxTouchPoints > 0;\n}\n","import React, { type ReactNode, createContext, useContext, useState } from 'react';\nimport { type SheetScrollerContextType, type SheetContextType } from './types';\n\nexport const SheetContext = createContext<SheetContextType | undefined>(\n undefined\n);\n\nexport const useSheetContext = () => {\n const context = useContext(SheetContext);\n if (!context) throw Error('Sheet context error');\n return context;\n};\n\nexport const SheetScrollerContext = createContext<\n SheetScrollerContextType | undefined\n>(undefined);\n\nexport function SheetScrollerContextProvider({\n children,\n}: {\n children: ReactNode;\n}) {\n const sheetContext = useSheetContext();\n const [disableDrag, setDisableDrag] = useState(!!sheetContext.disableDrag);\n\n function setDragEnabled() {\n if (!sheetContext.disableDrag) setDisableDrag(false);\n }\n\n function setDragDisabled() {\n if (!disableDrag) setDisableDrag(true);\n }\n\n return (\n <SheetScrollerContext.Provider\n value={{ disableDrag, setDragEnabled, setDragDisabled }}\n >\n {children}\n </SheetScrollerContext.Provider>\n );\n}\n\nexport const useSheetScrollerContext = () => {\n const context = useContext(SheetScrollerContext);\n if (!context) throw Error('Sheet scroller context error');\n return context;\n};\n","// Source: https://github.com/adobe/react-spectrum/blob/main/packages/@react-aria/overlays/src/usePreventScroll.ts\nimport {\n chain,\n getScrollParent,\n isIOS,\n useLayoutEffect,\n} from '@react-aria/utils';\n\ninterface PreventScrollOptions {\n /** Whether the scroll lock is disabled. */\n isDisabled?: boolean;\n}\n\nconst visualViewport =\n typeof window !== 'undefined' ? (window as any).visualViewport : undefined;\n\n// HTML input types that do not cause the software keyboard to appear.\nconst nonTextInputTypes = new Set([\n 'checkbox',\n 'radio',\n 'range',\n 'color',\n 'file',\n 'image',\n 'button',\n 'submit',\n 'reset',\n]);\n\n// The number of active usePreventScroll calls. Used to determine whether to revert back to the original page style/scroll position\nlet preventScrollCount = 0;\nlet restore: any;\n\n/**\n * Prevents scrolling on the document body on mount, and\n * restores it on unmount. Also ensures that content does not\n * shift due to the scrollbars disappearing.\n */\nexport function usePreventScroll(options: PreventScrollOptions = {}) {\n const { isDisabled } = options;\n\n useLayoutEffect(() => {\n if (isDisabled) {\n return;\n }\n\n preventScrollCount++;\n if (preventScrollCount === 1) {\n if (isIOS()) {\n restore = preventScrollMobileSafari();\n } else {\n restore = preventScrollStandard();\n }\n }\n\n return () => {\n preventScrollCount--;\n if (preventScrollCount === 0) {\n restore();\n }\n };\n }, [isDisabled]);\n}\n\n// For most browsers, all we need to do is set `overflow: hidden` on the root element, and\n// add some padding to prevent the page from shifting when the scrollbar is hidden.\nfunction preventScrollStandard() {\n return chain(\n setStyle(\n document.documentElement,\n 'paddingRight',\n `${window.innerWidth - document.documentElement.clientWidth}px`\n ),\n setStyle(document.documentElement, 'overflow', 'hidden')\n );\n}\n\n// Mobile Safari is a whole different beast. Even with overflow: hidden,\n// it still scrolls the page in many situations:\n//\n// 1. When the bottom toolbar and address bar are collapsed, page scrolling is always allowed.\n// 2. When the keyboard is visible, the viewport does not resize. Instead, the keyboard covers part of\n// it, so it becomes scrollable.\n// 3. When tapping on an input, the page always scrolls so that the input is centered in the visual viewport.\n// This may cause even fixed position elements to scroll off the screen.\n// 4. When using the next/previous buttons in the keyboard to navigate between inputs, the whole page always\n// scrolls, even if the input is inside a nested scrollable element that could be scrolled instead.\n//\n// In order to work around these cases, and prevent scrolling without jankiness, we do a few things:\n//\n// 1. Prevent default on `touchmove` events that are not in a scrollable element. This prevents touch scrolling\n// on the window.\n// 2. Prevent default on `touchmove` events inside a scrollable element when the scroll position is at the\n// top or bottom. This avoids the whole page scrolling instead, but does prevent overscrolling.\n// 3. Prevent default on `touchend` events on input elements and handle focusing the element ourselves.\n// 4. When focusing an input, apply a transform to trick Safari into thinking the input is at the top\n// of the page, which prevents it from scrolling the page. After the input is focused, scroll the element\n// into view ourselves, without scrolling the whole page.\n// 5. Offset the body by the scroll position using a negative margin and scroll to the top. This should appear the\n// same visually, but makes the actual scroll position always zero. This is required to make all of the\n// above work or Safari will still try to scroll the page when focusing an input.\n// 6. As a last resort, handle window scroll events, and scroll back to the top. This can happen when attempting\n// to navigate to an input with the next/previous buttons that's outside a modal.\nfunction preventScrollMobileSafari() {\n let scrollable: Element | undefined;\n let lastY = 0;\n\n const onTouchStart = (e: TouchEvent) => {\n // Store the nearest scrollable parent element from the element that the user touched.\n scrollable = getScrollParent(e.target as Element);\n if (\n scrollable === document.documentElement &&\n scrollable === document.body\n ) {\n return;\n }\n\n lastY = e.changedTouches[0].pageY;\n };\n\n const onTouchMove = (e: TouchEvent) => {\n // In special situations, `onTouchStart` may be called without `onTouchStart` being called.\n // (e.g. when the user places a finger on the screen before the <Sheet> is mounted and then moves the finger after it is mounted).\n // If `onTouchStart` is not called, `scrollable` is `undefined`. Therefore, such cases are ignored.\n if (scrollable === undefined) {\n return;\n }\n\n // Prevent scrolling the window.\n if (\n scrollable === document.documentElement ||\n scrollable === document.body\n ) {\n e.preventDefault();\n return;\n }\n\n // Prevent scrolling up when at the top and scrolling down when at the bottom\n // of a nested scrollable area, otherwise mobile Safari will start scrolling\n // the window instead. Unfortunately, this disables bounce scrolling when at\n // the top but it's the best we can do.\n const y = e.changedTouches[0].pageY;\n const scrollTop = scrollable.scrollTop;\n const bottom = scrollable.scrollHeight - scrollable.clientHeight;\n\n // Fix for: https://github.com/adobe/react-spectrum/pull/3780/files\n if (bottom === 0) {\n return;\n }\n\n if ((scrollTop <= 0 && y > lastY) || (scrollTop >= bottom && y < lastY)) {\n e.preventDefault();\n }\n\n lastY = y;\n };\n\n const onTouchEnd = (e: TouchEvent) => {\n const target = e.target as HTMLElement;\n\n // Apply this change if we're not already focused on the target element\n if (willOpenKeyboard(target) && target !== document.activeElement) {\n e.preventDefault();\n\n // Apply a transform to trick Safari into thinking the input is at the top of the page\n // so it doesn't try to scroll it into view. When tapping on an input, this needs to\n // be done before the \"focus\" event, so we have to focus the element ourselves.\n target.style.transform = 'translateY(-2000px)';\n target.focus();\n requestAnimationFrame(() => {\n target.style.transform = '';\n });\n }\n };\n\n const onFocus = (e: FocusEvent) => {\n const target = e.target as HTMLElement;\n if (willOpenKeyboard(target)) {\n // Transform also needs to be applied in the focus event in cases where focus moves\n // other than tapping on an input directly, e.g. the next/previous buttons in the\n // software keyboard. In these cases, it seems applying the transform in the focus event\n // is good enough, whereas when tapping an input, it must be done before the focus event. 🤷♂️\n target.style.transform = 'translateY(-2000px)';\n requestAnimationFrame(() => {\n target.style.transform = '';\n\n // This will have prevented the browser from scrolling the focused element into view,\n // so we need to do this ourselves in a way that doesn't cause the whole page to scroll.\n if (visualViewport) {\n if (visualViewport.height < window.innerHeight) {\n // If the keyboard is already visible, do this after one additional frame\n // to wait for the transform to be removed.\n requestAnimationFrame(() => {\n scrollIntoView(target);\n });\n } else {\n // Otherwise, wait for the visual viewport to resize before scrolling so we can\n // measure the correct position to scroll to.\n visualViewport.addEventListener(\n 'resize',\n () => {\n scrollIntoView(target);\n },\n { once: true }\n );\n }\n }\n });\n }\n };\n\n const onWindowScroll = () => {\n // Last resort. If the window scrolled, scroll it back to the top.\n // It should always be at the top because the body will have a negative margin (see below).\n window.scrollTo(0, 0);\n };\n\n // Record the original scroll position so we can restore it.\n // Then apply a negative margin to the body to offset it by the scroll position. This will\n // enable us to scroll the window to the top, which is required for the rest of this to work.\n const scrollX = window.pageXOffset;\n const scrollY = window.pageYOffset;\n\n const restoreStyles = chain(\n setStyle(\n document.documentElement,\n 'paddingRight',\n `${window.innerWidth - document.documentElement.clientWidth}px`\n ),\n setStyle(document.documentElement, 'overflow', 'hidden'),\n setStyle(document.body, 'marginTop', `-${scrollY}px`)\n );\n\n // Scroll to the top. The negative margin on the body will make this appear the same.\n window.scrollTo(0, 0);\n\n const removeEvents = chain(\n addEvent(document, 'touchstart', onTouchStart, {\n passive: false,\n capture: true,\n }),\n addEvent(document, 'touchmove', onTouchMove, {\n passive: false,\n capture: true,\n }),\n addEvent(document, 'touchend', onTouchEnd, {\n passive: false,\n capture: true,\n }),\n addEvent(document, 'focus', onFocus, true),\n addEvent(window, 'scroll', onWindowScroll)\n );\n\n return () => {\n // Restore styles and scroll the page back to where it was.\n restoreStyles();\n removeEvents();\n window.scrollTo(scrollX, scrollY);\n };\n}\n\n// Sets a CSS property on an element, and returns a function to revert it to the previous value.\nfunction setStyle(element: any, style: string, value: string) {\n const cur = element.style[style];\n element.style[style] = value;\n\n return () => {\n element.style[style] = cur;\n };\n}\n\n// Adds an event listener to an element, and returns a function to remove it.\nfunction addEvent<K extends keyof GlobalEventHandlersEventMap>(\n target: EventTarget,\n event: K,\n handler: (this: Document, ev: GlobalEventHandlersEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n) {\n target.addEventListener(event, handler as any, options);\n return () => {\n target.removeEventListener(event, handler as any, options);\n };\n}\n\nfunction scrollIntoView(target: Element) {\n const root = document.scrollingElement || document.documentElement;\n while (target && target !== root) {\n // Find the parent scrollable element and adjust the scroll position if the target is not already in view.\n const scrollable = getScrollParent(target);\n if (\n scrollable !== document.documentElement &&\n scrollable !== document.body &&\n scrollable !== target\n ) {\n const scrollableTop = scrollable.getBoundingClientRect().top;\n const targetTop = target.getBoundingClientRect().top;\n if (targetTop > scrollableTop + target.clientHeight) {\n scrollable.scrollTop += targetTop - scrollableTop;\n }\n }\n\n target = scrollable.parentElement as any;\n }\n}\n\nfunction willOpenKeyboard(target: Element) {\n return (\n (target instanceof HTMLInputElement &&\n !nonTextInputTypes.has(target.type)) ||\n target instanceof HTMLTextAreaElement ||\n (target instanceof HTMLElement && target.isContentEditable)\n );\n}\n","import { type Properties } from 'csstype';\n\nconst styles: Record<string, Properties> = {\n wrapper: {\n position: 'fixed',\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n overflow: 'hidden',\n pointerEvents: 'none',\n },\n backdrop: {\n zIndex: 1,\n position: 'fixed',\n top: 0,\n left: 0,\n width: '100%',\n height: '100%',\n backgroundColor: 'rgba(0, 0, 0, 0.2)',\n touchAction: 'none', // Disable iOS body scrolling\n border: 'none',\n },\n container: {\n zIndex: 2,\n position: 'absolute',\n left: 0,\n bottom: 0,\n width: '100%',\n backgroundColor: '#fff',\n borderTopRightRadius: '8px',\n borderTopLeftRadius: '8px',\n boxShadow: '0px -2px 16px rgba(0, 0, 0, 0.3)',\n display: 'flex',\n flexDirection: 'column',\n pointerEvents: 'auto',\n },\n headerWrapper: {\n width: '100%',\n },\n header: {\n height: '40px',\n width: '100%',\n position: 'relative',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n },\n indicator: {\n width: '18px',\n height: '4px',\n borderRadius: '99px',\n backgroundColor: '#ddd',\n },\n content: {\n flexGrow: 1,\n display: 'flex',\n flexDirection: 'column',\n minHeight: '0px',\n position: 'relative',\n },\n scroller: {\n height: '100%',\n overflowY: 'auto',\n },\n};\n\nexport default styles;\n","import React, { forwardRef } from 'react';\nimport { motion } from 'framer-motion';\n\nimport { type SheetContainerProps } from './types';\nimport { useSheetContext } from './context';\nimport { useEventCallbacks } from './hooks';\nimport { MAX_HEIGHT } from './constants';\nimport { mergeRefs } from './utils';\nimport styles from './styles';\n\nconst SheetContainer = forwardRef<any, SheetContainerProps>(\n ({ children, style = {}, className = '', ...rest }, ref) => {\n const {\n y,\n isOpen,\n callbacks,\n snapPoints,\n initialSnap = 0,\n sheetRef,\n windowHeight,\n detent,\n animationOptions,\n reduceMotion,\n } = useSheetContext();\n\n const { handleAnimationComplete } = useEventCallbacks(isOpen, callbacks);\n const initialY = snapPoints ? snapPoints[0] - snapPoints[initialSnap] : 0;\n const maxSnapHeight = snapPoints ? snapPoints[0] : null;\n\n const height =\n maxSnapHeight !== null\n ? `min(${maxSnapHeight}px, ${MAX_HEIGHT})`\n : MAX_HEIGHT;\n\n return (\n <motion.div\n {...rest}\n ref={mergeRefs([sheetRef, ref])}\n className={`react-modal-sheet-container ${className}`}\n style={{\n ...styles.container,\n ...style,\n ...(detent === 'full-height' && { height }),\n ...(detent === 'content-height' && { maxHeight: height }),\n y,\n }}\n initial={reduceMotion ? false : { y: windowHeight }}\n animate={{ y: initialY, transition: animationOptions }}\n exit={{ y: windowHeight, transition: animationOptions }}\n onAnimationComplete={handleAnimationComplete}\n >\n {children}\n </motion.div>\n );\n }\n);\n\nSheetContainer.displayName = 'SheetContainer';\n\nexport default SheetContainer;\n","import React, { forwardRef } from 'react';\nimport { motion } from 'framer-motion';\n\nimport { type SheetDraggableProps } from './types';\nimport { useSheetScrollerContext, useSheetContext } from './context';\nimport { useDragConstraints } from './hooks';\nimport { mergeRefs } from './utils';\nimport styles from './styles';\n\nconst SheetContent = forwardRef<any, SheetDraggableProps>(\n ({ children, style, disableDrag, className = '', ...rest }, ref) => {\n const sheetContext = useSheetContext();\n const sheetScrollerContext = useSheetScrollerContext();\n const { constraintsRef, onMeasureDragConstraints } = useDragConstraints();\n\n const dragProps =\n disableDrag || sheetScrollerContext.disableDrag\n ? undefined\n : sheetContext.dragProps;\n\n return (\n <motion.div\n {...rest}\n ref={mergeRefs([ref, constraintsRef])}\n className={`react-modal-sheet-content ${className}`}\n style={{ ...styles.content, ...style }}\n {...dragProps}\n dragConstraints={constraintsRef}\n onMeasureDragConstraints={onMeasureDragConstraints}\n >\n {children}\n </motion.div>\n );\n }\n);\n\nSheetContent.displayName = 'SheetContent';\n\nexport default SheetContent;\n","import React, { forwardRef } from 'react';\nimport { motion, useTransform } from 'framer-motion';\n\nimport { type SheetDraggableProps } from './types';\nimport { useSheetContext } from './context';\nimport { useDragConstraints } from './hooks';\nimport { mergeRefs } from './utils';\nimport styles from './styles';\n\nconst SheetHeader = forwardRef<any, SheetDraggableProps>(\n ({ children, style, disableDrag, ...rest }, ref) => {\n const { indicatorRotation, dragProps } = useSheetContext();\n const { constraintsRef, onMeasureDragConstraints } = useDragConstraints();\n const _dragProps = disableDrag ? undefined : dragProps;\n\n const indicator1Transform = useTransform(\n indicatorRotation,\n (r) => `translateX(2px) rotate(${r}deg)`\n );\n\n const indicator2Transform = useTransform(\n indicatorRotation,\n (r) => `translateX(-2px) rotate(${-1 * r}deg)`\n );\n\n return (\n <motion.div\n {...rest}\n ref={mergeRefs([ref, constraintsRef])}\n style={{ ...styles.headerWrapper, ...style }}\n {..._dragProps}\n dragConstraints={constraintsRef}\n onMeasureDragConstraints={onMeasureDragConstraints}\n >\n {children || (\n <div className=\"react-modal-sheet-header\" style={styles.header}>\n <motion.span\n className=\"react-modal-sheet-drag-indicator\"\n style={{ ...styles.indicator, transform: indicator1Transform }}\n />\n <motion.span\n className=\"react-modal-sheet-drag-indicator\"\n style={{ ...styles.indicator, transform: indicator2Transform }}\n />\n </div>\n )}\n </motion.div>\n );\n }\n);\n\nSheetHeader.displayName = 'SheetHeader';\n\nexport default SheetHeader;\n","import React, { forwardRef } from 'react';\nimport { motion } from 'framer-motion';\n\nimport { type SheetBackdropProps } from './types';\nimport styles from './styles';\n\nconst isClickable = (props: any) => !!props.onClick || !!props.onTap;\n\nconst SheetBackdrop = forwardRef<any, SheetBackdropProps>(\n ({ style = {}, className = '', ...rest }, ref) => {\n const Comp = isClickable(rest) ? motion.button : motion.div;\n const pointerEvents = isClickable(rest) ? 'auto' : 'none';\n\n return (\n <Comp\n {...rest}\n ref={ref}\n className={`react-modal-sheet-backdrop ${className}`}\n style={{ ...styles.backdrop, ...style, pointerEvents }}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n />\n );\n }\n);\n\nSheetBackdrop.displayName = 'SheetBackdrop';\n\nexport default SheetBackdrop;\n","import React, { type TouchEvent, type UIEvent, forwardRef } from 'react';\n\nimport { useSheetScrollerContext } from './context';\nimport { type SheetScrollerProps } from './types';\nimport { isTouchDevice } from './utils';\nimport styles from './styles';\n\nconst SheetScroller = forwardRef<any, SheetScrollerProps>(\n ({ draggableAt = 'top', children, style, className = '', ...rest }, ref) => {\n const sheetScrollerContext = useSheetScrollerContext();\n\n function determineDragState(element: HTMLDivElement) {\n const { scrollTop, scrollHeight, clientHeight } = element;\n const isScrollable = scrollHeight > clientHeight;\n\n if (!isScrollable) return;\n\n const isAtTop = scrollTop <= 0;\n const isAtBottom = scrollHeight - scrollTop === clientHeight;\n\n const shouldEnable =\n (draggableAt === 'top' && isAtTop) ||\n (draggableAt === 'bottom' && isAtBottom) ||\n (draggableAt === 'both' && (isAtTop || isAtBottom));\n\n if (shouldEnable) {\n sheetScrollerContext.setDragEnabled();\n } else {\n sheetScrollerContext.setDragDisabled();\n }\n }\n\n function onScroll(e: UIEvent<HTMLDivElement>) {\n determineDragState(e.currentTarget);\n }\n\n function onTouchStart(e: TouchEvent<HTMLDivElement>) {\n determineDragState(e.currentTarget);\n }\n\n const scrollProps = isTouchDevice()\n ? { onScroll, onTouchStart }\n : undefined;\n\n return (\n <div\n {...rest}\n ref={ref}\n className={`react-modal-sheet-scroller ${className}`}\n style={{ ...styles.scroller, ...style }}\n {...scrollProps}\n >\n {children}\n </div>\n );\n }\n);\n\nSheetScroller.displayName = 'SheetScroller';\n\nexport default SheetScroller;\n","import { type MotionValue } from 'framer-motion';\n\nimport _Sheet from './sheet';\nimport SheetContainer from './SheetContainer';\nimport SheetContent from './SheetContent';\nimport SheetHeader from './SheetHeader';\nimport SheetBackdrop from './SheetBackdrop';\nimport SheetScroller from './SheetScroller';\nimport { type SheetCompound } from './types';\n\nexport interface SheetRef {\n y: MotionValue<number>;\n snapTo: (index: number) => void;\n}\n\n// HACK: this is needed to get the typing to work properly...\nconst _SheetCompound: any = _Sheet;\n_SheetCompound.Container = SheetContainer;\n_SheetCompound.Header = SheetHeader;\n_SheetCompound.Content = SheetContent;\n_SheetCompound.Backdrop = SheetBackdrop;\n_SheetCompound.Scroller = SheetScroller;\n\nexport const Sheet = _SheetCompound as SheetCompound;\n"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React2, { createContext, forwardRef, useRef, useEffect, useImperativeHandle, useMemo, Children, cloneElement, useLayoutEffect, useCallback, useState, useContext } from 'react';
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
|
-
import { useMotionValue, useReducedMotion, useTransform, animate, motion, AnimatePresence } from 'framer-motion';
|
|
3
|
+
import { useMotionValue, useReducedMotion, useTransform, animate, motion, AnimatePresence, isBrowser } from 'framer-motion';
|
|
4
4
|
import { useLayoutEffect as useLayoutEffect$1, isIOS, chain, getScrollParent } from '@react-aria/utils';
|
|
5
5
|
|
|
6
6
|
// src/sheet.tsx
|
|
@@ -16,8 +16,8 @@ var REDUCED_MOTION_TWEEN_CONFIG = {
|
|
|
16
16
|
ease: "linear",
|
|
17
17
|
duration: 0.01
|
|
18
18
|
};
|
|
19
|
-
var
|
|
20
|
-
var
|
|
19
|
+
var DEFAULT_DRAG_CLOSE_THRESHOLD = 0.6;
|
|
20
|
+
var DEFAULT_DRAG_VELOCITY_THRESHOLD = 500;
|
|
21
21
|
|
|
22
22
|
// src/utils.ts
|
|
23
23
|
function getClosest(nums, goal) {
|
|
@@ -142,7 +142,10 @@ function useEventCallbacks(isOpen, callbacks) {
|
|
|
142
142
|
return { handleAnimationComplete };
|
|
143
143
|
}
|
|
144
144
|
function useDimensions() {
|
|
145
|
-
const [dimensions, setDimensions] = useState({
|
|
145
|
+
const [dimensions, setDimensions] = useState({
|
|
146
|
+
height: isBrowser ? window.innerHeight : 0,
|
|
147
|
+
width: isBrowser ? window.innerWidth : 0
|
|
148
|
+
});
|
|
146
149
|
useIsomorphicLayoutEffect(() => {
|
|
147
150
|
function handler() {
|
|
148
151
|
setDimensions({
|
|
@@ -476,7 +479,7 @@ var Sheet = forwardRef(
|
|
|
476
479
|
children,
|
|
477
480
|
disableScrollLocking = false,
|
|
478
481
|
isOpen,
|
|
479
|
-
snapPoints,
|
|
482
|
+
snapPoints: snapPointsProp,
|
|
480
483
|
rootId,
|
|
481
484
|
mountPoint,
|
|
482
485
|
style,
|
|
@@ -485,6 +488,8 @@ var Sheet = forwardRef(
|
|
|
485
488
|
disableDrag = false,
|
|
486
489
|
prefersReducedMotion = false,
|
|
487
490
|
tweenConfig = DEFAULT_TWEEN_CONFIG,
|
|
491
|
+
dragVelocityThreshold = DEFAULT_DRAG_VELOCITY_THRESHOLD,
|
|
492
|
+
dragCloseThreshold = DEFAULT_DRAG_CLOSE_THRESHOLD,
|
|
488
493
|
...rest
|
|
489
494
|
}, ref) => {
|
|
490
495
|
const sheetRef = useRef(null);
|
|
@@ -496,7 +501,7 @@ var Sheet = forwardRef(
|
|
|
496
501
|
type: "tween",
|
|
497
502
|
...reduceMotion ? REDUCED_MOTION_TWEEN_CONFIG : tweenConfig
|
|
498
503
|
};
|
|
499
|
-
const y = useMotionValue(
|
|
504
|
+
const y = useMotionValue(windowHeight);
|
|
500
505
|
const zIndex = useTransform(
|
|
501
506
|
y,
|
|
502
507
|
(value) => value + 2 >= windowHeight ? -1 : 9999999
|
|
@@ -519,6 +524,7 @@ var Sheet = forwardRef(
|
|
|
519
524
|
onCloseEnd
|
|
520
525
|
};
|
|
521
526
|
});
|
|
527
|
+
let snapPoints = snapPointsProp;
|
|
522
528
|
if (snapPoints) {
|
|
523
529
|
snapPoints = snapPoints.map((point) => {
|
|
524
530
|
if (point > 0 && point <= 1)
|
|
@@ -550,7 +556,7 @@ var Sheet = forwardRef(
|
|
|
550
556
|
}
|
|
551
557
|
});
|
|
552
558
|
const onDragEnd = useEffectEvent((_, { velocity }) => {
|
|
553
|
-
if (velocity.y >
|
|
559
|
+
if (velocity.y > dragVelocityThreshold) {
|
|
554
560
|
onClose();
|
|
555
561
|
} else {
|
|
556
562
|
const sheetHeight = sheetRef.current.getBoundingClientRect().height;
|
|
@@ -564,7 +570,7 @@ var Sheet = forwardRef(
|
|
|
564
570
|
snapToValues.unshift(0);
|
|
565
571
|
}
|
|
566
572
|
snapTo = getClosest(snapToValues, currentY);
|
|
567
|
-
} else if (currentY / sheetHeight >
|
|
573
|
+
} else if (currentY / sheetHeight > dragCloseThreshold) {
|
|
568
574
|
snapTo = sheetHeight;
|
|
569
575
|
}
|
|
570
576
|
snapTo = validateSnapTo({ snapTo, sheetHeight });
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/sheet.tsx","../src/hooks.tsx","../src/constants.ts","../src/utils.ts","../src/context.tsx","../src/use-prevent-scroll.ts","../src/styles.ts","../src/SheetContainer.tsx","../src/SheetContent.tsx","../src/SheetHeader.tsx","../src/SheetBackdrop.tsx","../src/SheetScroller.tsx","../src/index.tsx"],"names":["React","useEffect","useRef","useState","useLayoutEffect","dragProps","forwardRef","motion","useTransform","Sheet"],"mappings":";AAAA,OAAOA;AAAA,EACL;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAAC;AAAA,OACK;AAEP,SAAS,oBAAoB;AAE7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACrBP;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACPA,IAAM,aAAa;AAEnB,IAAM,SAAS,OAAO,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,aAAa;AAAA,IACpC;AAEA,aAAS,aAAa,GAA+B;AACnD,yBAAmB,EAAE,aAAa;AAAA,IACpC;AAEA,UAAM,cAAc,cAAc,IAC9B,EAAE,UAAU,aAAa,IACzB;AAEJ,WACE,gBAAAN,OAAA;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACJ;AAAA,QACA,WAAW,8BAA8B,SAAS;AAAA,QAClD,OAAO,EAAE,GAAG,eAAO,UAAU,GAAG,MAAM;AAAA,QACrC,GAAG;AAAA;AAAA,MAEH;AAAA,IACH;AAAA,EAEJ;AACF;AAEA,cAAc,cAAc;AAE5B,IAAO,wBAAQ;;;AC5Cf,IAAM,iBAAsB;AAC5B,eAAe,YAAY;AAC3B,eAAe,SAAS;AACxB,eAAe,UAAU;AACzB,eAAe,WAAW;AAC1B,eAAe,WAAW;AAEnB,IAAMS,SAAQ","sourcesContent":["import React, {\n Children,\n cloneElement,\n forwardRef,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n} from 'react';\n\nimport { createPortal } from 'react-dom';\n\nimport {\n animate,\n AnimatePresence,\n motion,\n type PanInfo,\n type Transition,\n useMotionValue,\n useReducedMotion,\n useTransform,\n} from 'framer-motion';\n\nimport {\n useModalEffect,\n useDimensions,\n useIsomorphicLayoutEffect,\n useEffectEvent,\n} from './hooks';\n\nimport {\n REDUCED_MOTION_TWEEN_CONFIG,\n DEFAULT_TWEEN_CONFIG,\n DRAG_CLOSE_THRESHOLD,\n DRAG_VELOCITY_THRESHOLD,\n IS_SSR,\n} from './constants';\n\nimport { type SheetContextType, type SheetProps } from './types';\nimport { SheetScrollerContextProvider, SheetContext } from './context';\nimport { getClosest, inDescendingOrder, validateSnapTo } from './utils';\nimport { usePreventScroll } from './use-prevent-scroll';\nimport styles from './styles';\n\nconst Sheet = forwardRef<any, SheetProps>(\n (\n {\n onOpenStart,\n onOpenEnd,\n onClose,\n onCloseStart,\n onCloseEnd,\n onSnap,\n children,\n disableScrollLocking = false,\n isOpen,\n snapPoints,\n rootId,\n mountPoint,\n style,\n detent = 'full-height',\n initialSnap = 0,\n disableDrag = false,\n prefersReducedMotion = false,\n tweenConfig = DEFAULT_TWEEN_CONFIG,\n ...rest\n },\n ref\n ) => {\n const sheetRef = useRef<HTMLDivElement>(null);\n const indicatorRotation = useMotionValue(0);\n const { height: windowHeight } = useDimensions();\n const shouldReduceMotion = useReducedMotion();\n const reduceMotion = Boolean(prefersReducedMotion || shouldReduceMotion);\n const animationOptions: Transition = {\n type: 'tween',\n ...(reduceMotion ? REDUCED_MOTION_TWEEN_CONFIG : tweenConfig),\n };\n\n // NOTE: the inital value for `y` doesn't matter since it is overwritten by\n // the value driven by the `AnimatePresence` component when the sheet is opened\n // and after that it is driven by the gestures and/or snapping\n const y = useMotionValue(0);\n\n // +2 for tolerance in case the animated value is slightly off\n const zIndex = useTransform(y, (value) =>\n value + 2 >= windowHeight ? -1 : 9999999\n );\n const visibility = useTransform(y, (value) =>\n value + 2 >= windowHeight ? 'hidden' : 'visible'\n );\n\n // Keep the callback fns up-to-date so that they can be accessed inside\n // the effect without including them to the dependencies array\n const callbacks = useRef({\n onOpenStart,\n onOpenEnd,\n onCloseStart,\n onCloseEnd,\n });\n\n useIsomorphicLayoutEffect(() => {\n callbacks.current = {\n onOpenStart,\n onOpenEnd,\n onCloseStart,\n onCloseEnd,\n };\n });\n\n if (snapPoints) {\n // Convert negative / percentage snap points to absolute values\n snapPoints = snapPoints.map((point) => {\n // Percentage values e.g. between 0.0 and 1.0\n if (point > 0 && point <= 1) return Math.round(point * windowHeight);\n return point < 0 ? windowHeight + point : point; // negative values\n });\n\n console.assert(\n inDescendingOrder(snapPoints) || windowHeight === 0,\n `Snap points need to be in descending order got: [${snapPoints.join(\n ', '\n )}]`\n );\n }\n\n const onDrag = useEffectEvent((_, { delta }: PanInfo) => {\n // Update drag indicator rotation based on drag velocity\n const velocity = y.getVelocity();\n\n if (velocity > 0) indicatorRotation.set(10);\n if (velocity < 0) indicatorRotation.set(-10);\n\n // Make sure user cannot drag beyond the top of the sheet\n y.set(Math.max(y.get() + delta.y, 0));\n });\n\n const onDragStart = useEffectEvent(() => {\n // Find focused input inside the sheet and blur it when dragging starts\n // to prevent a weird ghost caret \"bug\" on mobile\n const focusedElement = document.activeElement as HTMLElement | null;\n if (!focusedElement || !sheetRef.current) return;\n\n const isInput =\n focusedElement.tagName === 'INPUT' ||\n focusedElement.tagName === 'TEXTAREA';\n\n // Only blur the focused element if it's inside the sheet\n if (isInput && sheetRef.current.contains(focusedElement)) {\n focusedElement.blur();\n }\n });\n\n const onDragEnd = useEffectEvent((_, { velocity }: PanInfo) => {\n if (velocity.y > DRAG_VELOCITY_THRESHOLD) {\n // User flicked the sheet down\n onClose();\n } else {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const sheetHeight = sheetRef.current!.getBoundingClientRect().height;\n const currentY = y.get();\n\n let snapTo = 0;\n\n if (snapPoints) {\n const snapToValues = snapPoints.map(\n (p) => sheetHeight - Math.min(p, sheetHeight)\n );\n\n // Allow snapping to the top of the sheet if detent is set to `content-height`\n if (detent === 'content-height' && !snapToValues.includes(0)) {\n snapToValues.unshift(0);\n }\n\n // Get the closest snap point\n snapTo = getClosest(snapToValues, currentY);\n } else if (currentY / sheetHeight > DRAG_CLOSE_THRESHOLD) {\n // Close if dragged over enough far\n snapTo = sheetHeight;\n }\n\n snapTo = validateSnapTo({ snapTo, sheetHeight });\n\n // Update the spring value so that the sheet is animated to the snap point\n void animate(y, snapTo, animationOptions);\n\n if (snapPoints && onSnap) {\n const snapValue = Math.abs(Math.round(snapPoints[0] - snapTo));\n const snapIndex = snapPoints.indexOf(getClosest(snapPoints, snapValue)); // prettier-ignore\n onSnap(snapIndex);\n }\n\n const roundedSheetHeight = Math.round(sheetHeight);\n const shouldClose = snapTo + 2 >= roundedSheetHeight; // 2px tolerance\n\n if (shouldClose) onClose();\n }\n\n // Reset indicator rotation after dragging\n indicatorRotation.set(0);\n });\n\n // Trigger onSnap callback when sheet is opened or closed\n useEffect(() => {\n if (!snapPoints || !onSnap) return;\n const snapIndex = isOpen ? initialSnap : snapPoints.length - 1;\n onSnap(snapIndex);\n }, [isOpen]); // eslint-disable-line\n\n useImperativeHandle(ref, () => ({\n y,\n snapTo: (snapIndex: number) => {\n const sheetEl = sheetRef.current;\n\n if (snapPoints?.[snapIndex] !== undefined && sheetEl) {\n const sheetHeight = sheetEl.getBoundingClientRect().height;\n const snapPoint = snapPoints[snapIndex];\n const snapTo = validateSnapTo({\n snapTo: sheetHeight - snapPoint,\n sheetHeight,\n });\n\n void animate(y, snapTo, animationOptions);\n if (onSnap) onSnap(snapIndex);\n if (snapTo >= sheetHeight) onClose();\n }\n },\n }));\n\n useModalEffect(isOpen, rootId);\n\n // Framer Motion should handle body scroll locking but it's not working\n // properly on iOS. Scroll locking from React Aria seems to work much better.\n usePreventScroll({ isDisabled: disableScrollLocking || !isOpen });\n\n const dragProps = useMemo(() => {\n const dragProps: SheetContextType['dragProps'] = {\n drag: 'y',\n dragElastic: 0,\n dragMomentum: false,\n dragPropagation: false,\n onDrag,\n onDragStart,\n onDragEnd,\n };\n\n return disableDrag ? undefined : dragProps;\n }, [disableDrag, windowHeight]); // eslint-disable-line\n\n const context: SheetContextType = {\n y,\n sheetRef,\n isOpen,\n initialSnap,\n snapPoints,\n detent,\n indicatorRotation,\n callbacks,\n dragProps,\n windowHeight,\n animationOptions,\n reduceMotion,\n disableDrag,\n };\n\n const sheet = (\n <SheetContext.Provider value={context}>\n <motion.div\n {...rest}\n ref={ref}\n style={{ ...styles.wrapper, zIndex, visibility, ...style }}\n >\n <AnimatePresence>\n {/* NOTE: AnimatePresence requires us to set keys to children */}\n {isOpen ? (\n <SheetScrollerContextProvider>\n {Children.map(children, (child: any, i) =>\n cloneElement(child, { key: `sheet-child-${i}` })\n )}\n </SheetScrollerContextProvider>\n ) : null}\n </AnimatePresence>\n </motion.div>\n </SheetContext.Provider>\n );\n\n if (IS_SSR) return sheet;\n\n return createPortal(sheet, mountPoint ?? document.body);\n }\n);\n\nSheet.displayName = 'Sheet';\n\nexport default Sheet;\n","import {\n type MutableRefObject,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { type BoundingBox } from 'framer-motion';\n\nimport { IS_SSR } from './constants';\nimport { type SheetEvents } from './types';\nimport { applyRootStyles, cleanupRootStyles } from './utils';\n\nexport const useIsomorphicLayoutEffect = IS_SSR ? useEffect : useLayoutEffect;\n\nexport function useModalEffect(isOpen: boolean, rootId?: string) {\n const prevOpen = usePrevious(isOpen);\n\n // Automatically apply the iOS modal effect to the body when sheet opens/closes\n useEffect(() => {\n if (rootId && !prevOpen && isOpen) {\n applyRootStyles(rootId);\n } else if (rootId && !isOpen && prevOpen) {\n cleanupRootStyles(rootId);\n }\n }, [isOpen, prevOpen]); // eslint-disable-line\n\n // Make sure to cleanup modal styles on unmount\n useEffect(() => {\n return () => {\n if (rootId && isOpen) cleanupRootStyles(rootId);\n };\n }, [isOpen]); // eslint-disable-line\n}\n\nexport function useEventCallbacks(\n isOpen: boolean,\n callbacks: MutableRefObject<SheetEvents>\n) {\n const prevOpen = usePrevious(isOpen);\n const didOpen = useRef(false);\n\n // Because of AnimatePrecence we don't have access to latest isOpen value\n // so we need to read and write to a ref to determine if we are\n // opening or closing the sheet\n const handleAnimationComplete = useCallback(() => {\n if (!didOpen.current) {\n callbacks.current.onOpenEnd?.();\n didOpen.current = true;\n } else {\n callbacks.current.onCloseEnd?.();\n didOpen.current = false;\n }\n }, [isOpen, prevOpen]); // eslint-disable-line\n\n useEffect(() => {\n if (!prevOpen && isOpen) {\n callbacks.current.onOpenStart?.();\n } else if (!isOpen && prevOpen) {\n callbacks.current.onCloseStart?.();\n }\n }, [isOpen, prevOpen]); // eslint-disable-line\n\n return { handleAnimationComplete };\n}\n\nexport function useDimensions() {\n const [dimensions, setDimensions] = useState({ height: 0, width: 0 });\n\n useIsomorphicLayoutEffect(() => {\n function handler() {\n setDimensions({\n height: window.innerHeight,\n width: window.innerWidth,\n });\n }\n\n handler();\n\n window.addEventListener('resize', handler);\n\n return () => {\n window.removeEventListener('resize', handler);\n };\n }, []);\n\n return dimensions;\n}\n\nexport function usePrevious<T>(state: T): T | undefined {\n const ref = useRef<T>();\n\n useEffect(() => {\n ref.current = state;\n });\n\n return ref.current;\n}\n\n// Userland version of the `useEffectEvent` React hook:\n// RFC: https://react.dev/reference/react/experimental_useEffectEvent\nexport function useEffectEvent<T extends (...args: any[]) => any>(handler: T) {\n const handlerRef = useRef<T>();\n\n useIsomorphicLayoutEffect(() => {\n handlerRef.current = handler;\n });\n\n return useCallback((...args: any[]) => {\n const fn = handlerRef.current;\n return fn?.(...args);\n }, []) as T;\n}\n\n// This is a hacky way to fix a bug in framer-motion where the drag\n// constraints are not updated when window is resized.\n// https://github.com/framer/motion/issues/1659\nconst constraints: BoundingBox = { bottom: 0, top: 0, left: 0, right: 0 };\n\nexport function useDragConstraints() {\n const constraintsRef = useRef<any>(null);\n const onMeasureDragConstraints = useCallback(() => constraints, []);\n return { constraintsRef, onMeasureDragConstraints };\n}\n","export const MAX_HEIGHT = 'calc(100% - env(safe-area-inset-top) - 34px)';\n\nexport const IS_SSR = typeof window === 'undefined';\n\nexport const DEFAULT_TWEEN_CONFIG = {\n ease: 'easeOut',\n duration: 0.2,\n};\n\nexport const REDUCED_MOTION_TWEEN_CONFIG = {\n ease: 'linear',\n duration: 0.01,\n};\n\nexport const DRAG_CLOSE_THRESHOLD = 0.6;\n\nexport const DRAG_VELOCITY_THRESHOLD = 500;\n","import { type ForwardedRef, type RefCallback } from 'react';\n\nexport function getClosest(nums: number[], goal: number) {\n let closest = nums[0];\n let minDifference = Math.abs(nums[0] - goal);\n\n for (let i = 1; i < nums.length; i++) {\n const difference = Math.abs(nums[i] - goal);\n if (difference < minDifference) {\n closest = nums[i];\n minDifference = difference;\n }\n }\n\n return closest;\n}\n\nexport function applyRootStyles(rootId: string) {\n const body = document.querySelector('body') as HTMLBodyElement;\n const root = document.querySelector(`#${rootId}`) as HTMLDivElement;\n\n if (root) {\n const p = 24;\n const h = window.innerHeight;\n const s = (h - p) / h;\n body.style.backgroundColor = '#000';\n root.style.overflow = 'hidden';\n root.style.willChange = 'transform';\n root.style.transition =\n 'transform 200ms ease-in-out, border-radius 200ms linear';\n root.style.transform = `translateY(calc(env(safe-area-inset-top) + ${p / 2}px)) scale(${s})`; // prettier-ignore\n root.style.borderTopRightRadius = '10px';\n root.style.borderTopLeftRadius = '10px';\n }\n}\n\nexport function cleanupRootStyles(rootId: string) {\n const body = document.querySelector('body') as HTMLBodyElement;\n const root = document.getElementById(rootId) as HTMLDivElement;\n\n function onTransitionEnd() {\n root.style.removeProperty('overflow');\n root.style.removeProperty('will-change');\n root.style.removeProperty('transition');\n body.style.removeProperty('background-color');\n root.removeEventListener('transitionend', onTransitionEnd);\n }\n\n if (root) {\n // Start animating back\n root.style.removeProperty('border-top-right-radius');\n root.style.removeProperty('border-top-left-radius');\n root.style.removeProperty('transform');\n\n // Remove temp properties after animation is finished\n root.addEventListener('transitionend', onTransitionEnd);\n }\n}\n\nexport function inDescendingOrder(arr: number[]) {\n for (let i = 0; i < arr.length; i++) {\n if (arr[i + 1] > arr[i]) return false;\n }\n\n return true;\n}\n\nexport function validateSnapTo({\n snapTo,\n sheetHeight,\n}: {\n snapTo: number;\n sheetHeight: number;\n}) {\n if (snapTo < 0) {\n console.warn(\n `Snap point is out of bounds. Sheet height is ${sheetHeight} but snap point is ${\n sheetHeight + Math.abs(snapTo)\n }.`\n );\n }\n\n return Math.max(Math.round(snapTo), 0);\n}\n\nexport function mergeRefs<T = any>(\n refs: Array<ForwardedRef<T>>\n): RefCallback<T> {\n return (value: any) => {\n refs.forEach((ref: any) => {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref) {\n ref.current = value;\n }\n });\n };\n}\n\nexport function isTouchDevice() {\n if (typeof window === 'undefined') return false;\n return 'ontouchstart' in window || navigator.maxTouchPoints > 0;\n}\n","import React, { type ReactNode, createContext, useContext, useState } from 'react';\nimport { type SheetScrollerContextType, type SheetContextType } from './types';\n\nexport const SheetContext = createContext<SheetContextType | undefined>(\n undefined\n);\n\nexport const useSheetContext = () => {\n const context = useContext(SheetContext);\n if (!context) throw Error('Sheet context error');\n return context;\n};\n\nexport const SheetScrollerContext = createContext<\n SheetScrollerContextType | undefined\n>(undefined);\n\nexport function SheetScrollerContextProvider({\n children,\n}: {\n children: ReactNode;\n}) {\n const sheetContext = useSheetContext();\n const [disableDrag, setDisableDrag] = useState(!!sheetContext.disableDrag);\n\n function setDragEnabled() {\n if (!sheetContext.disableDrag) setDisableDrag(false);\n }\n\n function setDragDisabled() {\n if (!disableDrag) setDisableDrag(true);\n }\n\n return (\n <SheetScrollerContext.Provider\n value={{ disableDrag, setDragEnabled, setDragDisabled }}\n >\n {children}\n </SheetScrollerContext.Provider>\n );\n}\n\nexport const useSheetScrollerContext = () => {\n const context = useContext(SheetScrollerContext);\n if (!context) throw Error('Sheet scroller context error');\n return context;\n};\n","// Source: https://github.com/adobe/react-spectrum/blob/main/packages/@react-aria/overlays/src/usePreventScroll.ts\nimport {\n chain,\n getScrollParent,\n isIOS,\n useLayoutEffect,\n} from '@react-aria/utils';\n\ninterface PreventScrollOptions {\n /** Whether the scroll lock is disabled. */\n isDisabled?: boolean;\n}\n\nconst visualViewport =\n typeof window !== 'undefined' ? (window as any).visualViewport : undefined;\n\n// HTML input types that do not cause the software keyboard to appear.\nconst nonTextInputTypes = new Set([\n 'checkbox',\n 'radio',\n 'range',\n 'color',\n 'file',\n 'image',\n 'button',\n 'submit',\n 'reset',\n]);\n\n// The number of active usePreventScroll calls. Used to determine whether to revert back to the original page style/scroll position\nlet preventScrollCount = 0;\nlet restore: any;\n\n/**\n * Prevents scrolling on the document body on mount, and\n * restores it on unmount. Also ensures that content does not\n * shift due to the scrollbars disappearing.\n */\nexport function usePreventScroll(options: PreventScrollOptions = {}) {\n const { isDisabled } = options;\n\n useLayoutEffect(() => {\n if (isDisabled) {\n return;\n }\n\n preventScrollCount++;\n if (preventScrollCount === 1) {\n if (isIOS()) {\n restore = preventScrollMobileSafari();\n } else {\n restore = preventScrollStandard();\n }\n }\n\n return () => {\n preventScrollCount--;\n if (preventScrollCount === 0) {\n restore();\n }\n };\n }, [isDisabled]);\n}\n\n// For most browsers, all we need to do is set `overflow: hidden` on the root element, and\n// add some padding to prevent the page from shifting when the scrollbar is hidden.\nfunction preventScrollStandard() {\n return chain(\n setStyle(\n document.documentElement,\n 'paddingRight',\n `${window.innerWidth - document.documentElement.clientWidth}px`\n ),\n setStyle(document.documentElement, 'overflow', 'hidden')\n );\n}\n\n// Mobile Safari is a whole different beast. Even with overflow: hidden,\n// it still scrolls the page in many situations:\n//\n// 1. When the bottom toolbar and address bar are collapsed, page scrolling is always allowed.\n// 2. When the keyboard is visible, the viewport does not resize. Instead, the keyboard covers part of\n// it, so it becomes scrollable.\n// 3. When tapping on an input, the page always scrolls so that the input is centered in the visual viewport.\n// This may cause even fixed position elements to scroll off the screen.\n// 4. When using the next/previous buttons in the keyboard to navigate between inputs, the whole page always\n// scrolls, even if the input is inside a nested scrollable element that could be scrolled instead.\n//\n// In order to work around these cases, and prevent scrolling without jankiness, we do a few things:\n//\n// 1. Prevent default on `touchmove` events that are not in a scrollable element. This prevents touch scrolling\n// on the window.\n// 2. Prevent default on `touchmove` events inside a scrollable element when the scroll position is at the\n// top or bottom. This avoids the whole page scrolling instead, but does prevent overscrolling.\n// 3. Prevent default on `touchend` events on input elements and handle focusing the element ourselves.\n// 4. When focusing an input, apply a transform to trick Safari into thinking the input is at the top\n// of the page, which prevents it from scrolling the page. After the input is focused, scroll the element\n// into view ourselves, without scrolling the whole page.\n// 5. Offset the body by the scroll position using a negative margin and scroll to the top. This should appear the\n// same visually, but makes the actual scroll position always zero. This is required to make all of the\n// above work or Safari will still try to scroll the page when focusing an input.\n// 6. As a last resort, handle window scroll events, and scroll back to the top. This can happen when attempting\n// to navigate to an input with the next/previous buttons that's outside a modal.\nfunction preventScrollMobileSafari() {\n let scrollable: Element | undefined;\n let lastY = 0;\n\n const onTouchStart = (e: TouchEvent) => {\n // Store the nearest scrollable parent element from the element that the user touched.\n scrollable = getScrollParent(e.target as Element);\n if (\n scrollable === document.documentElement &&\n scrollable === document.body\n ) {\n return;\n }\n\n lastY = e.changedTouches[0].pageY;\n };\n\n const onTouchMove = (e: TouchEvent) => {\n // In special situations, `onTouchStart` may be called without `onTouchStart` being called.\n // (e.g. when the user places a finger on the screen before the <Sheet> is mounted and then moves the finger after it is mounted).\n // If `onTouchStart` is not called, `scrollable` is `undefined`. Therefore, such cases are ignored.\n if (scrollable === undefined) {\n return;\n }\n\n // Prevent scrolling the window.\n if (\n scrollable === document.documentElement ||\n scrollable === document.body\n ) {\n e.preventDefault();\n return;\n }\n\n // Prevent scrolling up when at the top and scrolling down when at the bottom\n // of a nested scrollable area, otherwise mobile Safari will start scrolling\n // the window instead. Unfortunately, this disables bounce scrolling when at\n // the top but it's the best we can do.\n const y = e.changedTouches[0].pageY;\n const scrollTop = scrollable.scrollTop;\n const bottom = scrollable.scrollHeight - scrollable.clientHeight;\n\n // Fix for: https://github.com/adobe/react-spectrum/pull/3780/files\n if (bottom === 0) {\n return;\n }\n\n if ((scrollTop <= 0 && y > lastY) || (scrollTop >= bottom && y < lastY)) {\n e.preventDefault();\n }\n\n lastY = y;\n };\n\n const onTouchEnd = (e: TouchEvent) => {\n const target = e.target as HTMLElement;\n\n // Apply this change if we're not already focused on the target element\n if (willOpenKeyboard(target) && target !== document.activeElement) {\n e.preventDefault();\n\n // Apply a transform to trick Safari into thinking the input is at the top of the page\n // so it doesn't try to scroll it into view. When tapping on an input, this needs to\n // be done before the \"focus\" event, so we have to focus the element ourselves.\n target.style.transform = 'translateY(-2000px)';\n target.focus();\n requestAnimationFrame(() => {\n target.style.transform = '';\n });\n }\n };\n\n const onFocus = (e: FocusEvent) => {\n const target = e.target as HTMLElement;\n if (willOpenKeyboard(target)) {\n // Transform also needs to be applied in the focus event in cases where focus moves\n // other than tapping on an input directly, e.g. the next/previous buttons in the\n // software keyboard. In these cases, it seems applying the transform in the focus event\n // is good enough, whereas when tapping an input, it must be done before the focus event. 🤷♂️\n target.style.transform = 'translateY(-2000px)';\n requestAnimationFrame(() => {\n target.style.transform = '';\n\n // This will have prevented the browser from scrolling the focused element into view,\n // so we need to do this ourselves in a way that doesn't cause the whole page to scroll.\n if (visualViewport) {\n if (visualViewport.height < window.innerHeight) {\n // If the keyboard is already visible, do this after one additional frame\n // to wait for the transform to be removed.\n requestAnimationFrame(() => {\n scrollIntoView(target);\n });\n } else {\n // Otherwise, wait for the visual viewport to resize before scrolling so we can\n // measure the correct position to scroll to.\n visualViewport.addEventListener(\n 'resize',\n () => {\n scrollIntoView(target);\n },\n { once: true }\n );\n }\n }\n });\n }\n };\n\n const onWindowScroll = () => {\n // Last resort. If the window scrolled, scroll it back to the top.\n // It should always be at the top because the body will have a negative margin (see below).\n window.scrollTo(0, 0);\n };\n\n // Record the original scroll position so we can restore it.\n // Then apply a negative margin to the body to offset it by the scroll position. This will\n // enable us to scroll the window to the top, which is required for the rest of this to work.\n const scrollX = window.pageXOffset;\n const scrollY = window.pageYOffset;\n\n const restoreStyles = chain(\n setStyle(\n document.documentElement,\n 'paddingRight',\n `${window.innerWidth - document.documentElement.clientWidth}px`\n ),\n setStyle(document.documentElement, 'overflow', 'hidden'),\n setStyle(document.body, 'marginTop', `-${scrollY}px`)\n );\n\n // Scroll to the top. The negative margin on the body will make this appear the same.\n window.scrollTo(0, 0);\n\n const removeEvents = chain(\n addEvent(document, 'touchstart', onTouchStart, {\n passive: false,\n capture: true,\n }),\n addEvent(document, 'touchmove', onTouchMove, {\n passive: false,\n capture: true,\n }),\n addEvent(document, 'touchend', onTouchEnd, {\n passive: false,\n capture: true,\n }),\n addEvent(document, 'focus', onFocus, true),\n addEvent(window, 'scroll', onWindowScroll)\n );\n\n return () => {\n // Restore styles and scroll the page back to where it was.\n restoreStyles();\n removeEvents();\n window.scrollTo(scrollX, scrollY);\n };\n}\n\n// Sets a CSS property on an element, and returns a function to revert it to the previous value.\nfunction setStyle(element: any, style: string, value: string) {\n const cur = element.style[style];\n element.style[style] = value;\n\n return () => {\n element.style[style] = cur;\n };\n}\n\n// Adds an event listener to an element, and returns a function to remove it.\nfunction addEvent<K extends keyof GlobalEventHandlersEventMap>(\n target: EventTarget,\n event: K,\n handler: (this: Document, ev: GlobalEventHandlersEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n) {\n target.addEventListener(event, handler as any, options);\n return () => {\n target.removeEventListener(event, handler as any, options);\n };\n}\n\nfunction scrollIntoView(target: Element) {\n const root = document.scrollingElement || document.documentElement;\n while (target && target !== root) {\n // Find the parent scrollable element and adjust the scroll position if the target is not already in view.\n const scrollable = getScrollParent(target);\n if (\n scrollable !== document.documentElement &&\n scrollable !== document.body &&\n scrollable !== target\n ) {\n const scrollableTop = scrollable.getBoundingClientRect().top;\n const targetTop = target.getBoundingClientRect().top;\n if (targetTop > scrollableTop + target.clientHeight) {\n scrollable.scrollTop += targetTop - scrollableTop;\n }\n }\n\n target = scrollable.parentElement as any;\n }\n}\n\nfunction willOpenKeyboard(target: Element) {\n return (\n (target instanceof HTMLInputElement &&\n !nonTextInputTypes.has(target.type)) ||\n target instanceof HTMLTextAreaElement ||\n (target instanceof HTMLElement && target.isContentEditable)\n );\n}\n","import { type Properties } from 'csstype';\n\nconst styles: Record<string, Properties> = {\n wrapper: {\n position: 'fixed',\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n overflow: 'hidden',\n pointerEvents: 'none',\n },\n backdrop: {\n zIndex: 1,\n position: 'fixed',\n top: 0,\n left: 0,\n width: '100%',\n height: '100%',\n backgroundColor: 'rgba(0, 0, 0, 0.2)',\n touchAction: 'none', // Disable iOS body scrolling\n border: 'none',\n },\n container: {\n zIndex: 2,\n position: 'absolute',\n left: 0,\n bottom: 0,\n width: '100%',\n backgroundColor: '#fff',\n borderTopRightRadius: '8px',\n borderTopLeftRadius: '8px',\n boxShadow: '0px -2px 16px rgba(0, 0, 0, 0.3)',\n display: 'flex',\n flexDirection: 'column',\n pointerEvents: 'auto',\n },\n headerWrapper: {\n width: '100%',\n },\n header: {\n height: '40px',\n width: '100%',\n position: 'relative',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n },\n indicator: {\n width: '18px',\n height: '4px',\n borderRadius: '99px',\n backgroundColor: '#ddd',\n },\n content: {\n flexGrow: 1,\n display: 'flex',\n flexDirection: 'column',\n minHeight: '0px',\n position: 'relative',\n },\n scroller: {\n height: '100%',\n overflowY: 'auto',\n },\n};\n\nexport default styles;\n","import React, { forwardRef } from 'react';\nimport { motion } from 'framer-motion';\n\nimport { type SheetContainerProps } from './types';\nimport { useSheetContext } from './context';\nimport { useEventCallbacks } from './hooks';\nimport { MAX_HEIGHT } from './constants';\nimport { mergeRefs } from './utils';\nimport styles from './styles';\n\nconst SheetContainer = forwardRef<any, SheetContainerProps>(\n ({ children, style = {}, className = '', ...rest }, ref) => {\n const {\n y,\n isOpen,\n callbacks,\n snapPoints,\n initialSnap = 0,\n sheetRef,\n windowHeight,\n detent,\n animationOptions,\n reduceMotion,\n } = useSheetContext();\n\n const { handleAnimationComplete } = useEventCallbacks(isOpen, callbacks);\n const initialY = snapPoints ? snapPoints[0] - snapPoints[initialSnap] : 0;\n const maxSnapHeight = snapPoints ? snapPoints[0] : null;\n\n const height =\n maxSnapHeight !== null\n ? `min(${maxSnapHeight}px, ${MAX_HEIGHT})`\n : MAX_HEIGHT;\n\n return (\n <motion.div\n {...rest}\n ref={mergeRefs([sheetRef, ref])}\n className={`react-modal-sheet-container ${className}`}\n style={{\n ...styles.container,\n ...style,\n ...(detent === 'full-height' && { height }),\n ...(detent === 'content-height' && { maxHeight: height }),\n y,\n }}\n initial={reduceMotion ? false : { y: windowHeight }}\n animate={{ y: initialY, transition: animationOptions }}\n exit={{ y: windowHeight, transition: animationOptions }}\n onAnimationComplete={handleAnimationComplete}\n >\n {children}\n </motion.div>\n );\n }\n);\n\nSheetContainer.displayName = 'SheetContainer';\n\nexport default SheetContainer;\n","import React, { forwardRef } from 'react';\nimport { motion } from 'framer-motion';\n\nimport { type SheetDraggableProps } from './types';\nimport { useSheetScrollerContext, useSheetContext } from './context';\nimport { useDragConstraints } from './hooks';\nimport { mergeRefs } from './utils';\nimport styles from './styles';\n\nconst SheetContent = forwardRef<any, SheetDraggableProps>(\n ({ children, style, disableDrag, className = '', ...rest }, ref) => {\n const sheetContext = useSheetContext();\n const sheetScrollerContext = useSheetScrollerContext();\n const { constraintsRef, onMeasureDragConstraints } = useDragConstraints();\n\n const dragProps =\n disableDrag || sheetScrollerContext.disableDrag\n ? undefined\n : sheetContext.dragProps;\n\n return (\n <motion.div\n {...rest}\n ref={mergeRefs([ref, constraintsRef])}\n className={`react-modal-sheet-content ${className}`}\n style={{ ...styles.content, ...style }}\n {...dragProps}\n dragConstraints={constraintsRef}\n onMeasureDragConstraints={onMeasureDragConstraints}\n >\n {children}\n </motion.div>\n );\n }\n);\n\nSheetContent.displayName = 'SheetContent';\n\nexport default SheetContent;\n","import React, { forwardRef } from 'react';\nimport { motion, useTransform } from 'framer-motion';\n\nimport { type SheetDraggableProps } from './types';\nimport { useSheetContext } from './context';\nimport { useDragConstraints } from './hooks';\nimport { mergeRefs } from './utils';\nimport styles from './styles';\n\nconst SheetHeader = forwardRef<any, SheetDraggableProps>(\n ({ children, style, disableDrag, ...rest }, ref) => {\n const { indicatorRotation, dragProps } = useSheetContext();\n const { constraintsRef, onMeasureDragConstraints } = useDragConstraints();\n const _dragProps = disableDrag ? undefined : dragProps;\n\n const indicator1Transform = useTransform(\n indicatorRotation,\n (r) => `translateX(2px) rotate(${r}deg)`\n );\n\n const indicator2Transform = useTransform(\n indicatorRotation,\n (r) => `translateX(-2px) rotate(${-1 * r}deg)`\n );\n\n return (\n <motion.div\n {...rest}\n ref={mergeRefs([ref, constraintsRef])}\n style={{ ...styles.headerWrapper, ...style }}\n {..._dragProps}\n dragConstraints={constraintsRef}\n onMeasureDragConstraints={onMeasureDragConstraints}\n >\n {children || (\n <div className=\"react-modal-sheet-header\" style={styles.header}>\n <motion.span\n className=\"react-modal-sheet-drag-indicator\"\n style={{ ...styles.indicator, transform: indicator1Transform }}\n />\n <motion.span\n className=\"react-modal-sheet-drag-indicator\"\n style={{ ...styles.indicator, transform: indicator2Transform }}\n />\n </div>\n )}\n </motion.div>\n );\n }\n);\n\nSheetHeader.displayName = 'SheetHeader';\n\nexport default SheetHeader;\n","import React, { forwardRef } from 'react';\nimport { motion } from 'framer-motion';\n\nimport { type SheetBackdropProps } from './types';\nimport styles from './styles';\n\nconst isClickable = (props: any) => !!props.onClick || !!props.onTap;\n\nconst SheetBackdrop = forwardRef<any, SheetBackdropProps>(\n ({ style = {}, className = '', ...rest }, ref) => {\n const Comp = isClickable(rest) ? motion.button : motion.div;\n const pointerEvents = isClickable(rest) ? 'auto' : 'none';\n\n return (\n <Comp\n {...rest}\n ref={ref}\n className={`react-modal-sheet-backdrop ${className}`}\n style={{ ...styles.backdrop, ...style, pointerEvents }}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n />\n );\n }\n);\n\nSheetBackdrop.displayName = 'SheetBackdrop';\n\nexport default SheetBackdrop;\n","import React, { type TouchEvent, type UIEvent, forwardRef } from 'react';\n\nimport { useSheetScrollerContext } from './context';\nimport { type SheetScrollerProps } from './types';\nimport { isTouchDevice } from './utils';\nimport styles from './styles';\n\nconst SheetScroller = forwardRef<any, SheetScrollerProps>(\n ({ draggableAt = 'top', children, style, className = '', ...rest }, ref) => {\n const sheetScrollerContext = useSheetScrollerContext();\n\n function determineDragState(element: HTMLDivElement) {\n const { scrollTop, scrollHeight, clientHeight } = element;\n const isScrollable = scrollHeight > clientHeight;\n\n if (!isScrollable) return;\n\n const isAtTop = scrollTop <= 0;\n const isAtBottom = scrollHeight - scrollTop === clientHeight;\n\n const shouldEnable =\n (draggableAt === 'top' && isAtTop) ||\n (draggableAt === 'bottom' && isAtBottom) ||\n (draggableAt === 'both' && (isAtTop || isAtBottom));\n\n if (shouldEnable) {\n sheetScrollerContext.setDragEnabled();\n } else {\n sheetScrollerContext.setDragDisabled();\n }\n }\n\n function onScroll(e: UIEvent<HTMLDivElement>) {\n determineDragState(e.currentTarget);\n }\n\n function onTouchStart(e: TouchEvent<HTMLDivElement>) {\n determineDragState(e.currentTarget);\n }\n\n const scrollProps = isTouchDevice()\n ? { onScroll, onTouchStart }\n : undefined;\n\n return (\n <div\n {...rest}\n ref={ref}\n className={`react-modal-sheet-scroller ${className}`}\n style={{ ...styles.scroller, ...style }}\n {...scrollProps}\n >\n {children}\n </div>\n );\n }\n);\n\nSheetScroller.displayName = 'SheetScroller';\n\nexport default SheetScroller;\n","import { type MotionValue } from 'framer-motion';\n\nimport _Sheet from './sheet';\nimport SheetContainer from './SheetContainer';\nimport SheetContent from './SheetContent';\nimport SheetHeader from './SheetHeader';\nimport SheetBackdrop from './SheetBackdrop';\nimport SheetScroller from './SheetScroller';\nimport { type SheetCompound } from './types';\n\nexport interface SheetRef {\n y: MotionValue<number>;\n snapTo: (index: number) => void;\n}\n\n// HACK: this is needed to get the typing to work properly...\nconst _SheetCompound: any = _Sheet;\n_SheetCompound.Container = SheetContainer;\n_SheetCompound.Header = SheetHeader;\n_SheetCompound.Content = SheetContent;\n_SheetCompound.Backdrop = SheetBackdrop;\n_SheetCompound.Scroller = SheetScroller;\n\nexport const Sheet = _SheetCompound as SheetCompound;\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/sheet.tsx","../src/hooks.tsx","../src/constants.ts","../src/utils.ts","../src/context.tsx","../src/use-prevent-scroll.ts","../src/styles.ts","../src/SheetContainer.tsx","../src/SheetContent.tsx","../src/SheetHeader.tsx","../src/SheetBackdrop.tsx","../src/SheetScroller.tsx","../src/index.tsx"],"names":["React","useEffect","useRef","useState","useLayoutEffect","dragProps","forwardRef","motion","useTransform","Sheet"],"mappings":";AAAA,OAAOA;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,YAAY,IAAI,GAAG,KAAK,GAAG,QAAQ;AAC1E,UAAM,uBAAuB,wBAAwB;AAErD,aAAS,mBAAmB,SAAyB;AACnD,YAAM,EAAE,WAAW,cAAc,aAAa,IAAI;AAClD,YAAM,eAAe,eAAe;AAEpC,UAAI,CAAC;AAAc;AAEnB,YAAM,UAAU,aAAa;AAC7B,YAAM,aAAa,eAAe,cAAc;AAEhD,YAAM,eACH,gBAAgB,SAAS,WACzB,gBAAgB,YAAY,cAC5B,gBAAgB,WAAW,WAAW;AAEzC,UAAI,cAAc;AAChB,6BAAqB,eAAe;AAAA,MACtC,OAAO;AACL,6BAAqB,gBAAgB;AAAA,MACvC;AAAA,IACF;AAEA,aAAS,SAAS,GAA4B;AAC5C,yBAAmB,EAAE,aAAa;AAAA,IACpC;AAEA,aAAS,aAAa,GAA+B;AACnD,yBAAmB,EAAE,aAAa;AAAA,IACpC;AAEA,UAAM,cAAc,cAAc,IAC9B,EAAE,UAAU,aAAa,IACzB;AAEJ,WACE,gBAAAN,OAAA;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACJ;AAAA,QACA,WAAW,8BAA8B,SAAS;AAAA,QAClD,OAAO,EAAE,GAAG,eAAO,UAAU,GAAG,MAAM;AAAA,QACrC,GAAG;AAAA;AAAA,MAEH;AAAA,IACH;AAAA,EAEJ;AACF;AAEA,cAAc,cAAc;AAE5B,IAAO,wBAAQ;;;AC5Cf,IAAM,iBAAsB;AAC5B,eAAe,YAAY;AAC3B,eAAe,SAAS;AACxB,eAAe,UAAU;AACzB,eAAe,WAAW;AAC1B,eAAe,WAAW;AAEnB,IAAMS,SAAQ","sourcesContent":["import React, {\n Children,\n cloneElement,\n forwardRef,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n} from 'react';\n\nimport { createPortal } from 'react-dom';\n\nimport {\n animate,\n AnimatePresence,\n motion,\n type PanInfo,\n type Transition,\n useMotionValue,\n useReducedMotion,\n useTransform,\n} from 'framer-motion';\n\nimport {\n useModalEffect,\n useDimensions,\n useIsomorphicLayoutEffect,\n useEffectEvent,\n} from './hooks';\n\nimport {\n REDUCED_MOTION_TWEEN_CONFIG,\n DEFAULT_TWEEN_CONFIG,\n DEFAULT_DRAG_CLOSE_THRESHOLD,\n DEFAULT_DRAG_VELOCITY_THRESHOLD,\n IS_SSR,\n} from './constants';\n\nimport { type SheetContextType, type SheetProps } from './types';\nimport { SheetScrollerContextProvider, SheetContext } from './context';\nimport { getClosest, inDescendingOrder, validateSnapTo } from './utils';\nimport { usePreventScroll } from './use-prevent-scroll';\nimport styles from './styles';\n\nconst Sheet = forwardRef<any, SheetProps>(\n (\n {\n onOpenStart,\n onOpenEnd,\n onClose,\n onCloseStart,\n onCloseEnd,\n onSnap,\n children,\n disableScrollLocking = false,\n isOpen,\n snapPoints: snapPointsProp,\n rootId,\n mountPoint,\n style,\n detent = 'full-height',\n initialSnap = 0,\n disableDrag = false,\n prefersReducedMotion = false,\n tweenConfig = DEFAULT_TWEEN_CONFIG,\n dragVelocityThreshold = DEFAULT_DRAG_VELOCITY_THRESHOLD,\n dragCloseThreshold = DEFAULT_DRAG_CLOSE_THRESHOLD,\n ...rest\n },\n ref\n ) => {\n const sheetRef = useRef<HTMLDivElement>(null);\n const indicatorRotation = useMotionValue(0);\n const { height: windowHeight } = useDimensions();\n const shouldReduceMotion = useReducedMotion();\n const reduceMotion = Boolean(prefersReducedMotion || shouldReduceMotion);\n const animationOptions: Transition = {\n type: 'tween',\n ...(reduceMotion ? REDUCED_MOTION_TWEEN_CONFIG : tweenConfig),\n };\n\n // NOTE: the inital value for `y` doesn't matter since it is overwritten by\n // the value driven by the `AnimatePresence` component when the sheet is opened\n // and after that it is driven by the gestures and/or snapping\n const y = useMotionValue(windowHeight);\n\n // +2 for tolerance in case the animated value is slightly off\n const zIndex = useTransform(y, (value) =>\n value + 2 >= windowHeight ? -1 : 9999999\n );\n const visibility = useTransform(y, (value) =>\n value + 2 >= windowHeight ? 'hidden' : 'visible'\n );\n\n // Keep the callback fns up-to-date so that they can be accessed inside\n // the effect without including them to the dependencies array\n const callbacks = useRef({\n onOpenStart,\n onOpenEnd,\n onCloseStart,\n onCloseEnd,\n });\n\n useIsomorphicLayoutEffect(() => {\n callbacks.current = {\n onOpenStart,\n onOpenEnd,\n onCloseStart,\n onCloseEnd,\n };\n });\n\n let snapPoints: number[] | undefined = snapPointsProp;\n\n if (snapPoints) {\n // Convert negative / percentage snap points to absolute values\n snapPoints = snapPoints.map((point) => {\n // Percentage values e.g. between 0.0 and 1.0\n if (point > 0 && point <= 1) return Math.round(point * windowHeight);\n return point < 0 ? windowHeight + point : point; // negative values\n });\n\n console.assert(\n inDescendingOrder(snapPoints) || windowHeight === 0,\n `Snap points need to be in descending order got: [${snapPoints.join(\n ', '\n )}]`\n );\n }\n\n const onDrag = useEffectEvent((_, { delta }: PanInfo) => {\n // Update drag indicator rotation based on drag velocity\n const velocity = y.getVelocity();\n\n if (velocity > 0) indicatorRotation.set(10);\n if (velocity < 0) indicatorRotation.set(-10);\n\n // Make sure user cannot drag beyond the top of the sheet\n y.set(Math.max(y.get() + delta.y, 0));\n });\n\n const onDragStart = useEffectEvent(() => {\n // Find focused input inside the sheet and blur it when dragging starts\n // to prevent a weird ghost caret \"bug\" on mobile\n const focusedElement = document.activeElement as HTMLElement | null;\n if (!focusedElement || !sheetRef.current) return;\n\n const isInput =\n focusedElement.tagName === 'INPUT' ||\n focusedElement.tagName === 'TEXTAREA';\n\n // Only blur the focused element if it's inside the sheet\n if (isInput && sheetRef.current.contains(focusedElement)) {\n focusedElement.blur();\n }\n });\n\n const onDragEnd = useEffectEvent((_, { velocity }: PanInfo) => {\n if (velocity.y > dragVelocityThreshold) {\n // User flicked the sheet down\n onClose();\n } else {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const sheetHeight = sheetRef.current!.getBoundingClientRect().height;\n const currentY = y.get();\n\n let snapTo = 0;\n\n if (snapPoints) {\n const snapToValues = snapPoints.map(\n (p) => sheetHeight - Math.min(p, sheetHeight)\n );\n\n // Allow snapping to the top of the sheet if detent is set to `content-height`\n if (detent === 'content-height' && !snapToValues.includes(0)) {\n snapToValues.unshift(0);\n }\n\n // Get the closest snap point\n snapTo = getClosest(snapToValues, currentY);\n } else if (currentY / sheetHeight > dragCloseThreshold) {\n // Close if dragged over enough far\n snapTo = sheetHeight;\n }\n\n snapTo = validateSnapTo({ snapTo, sheetHeight });\n\n // Update the spring value so that the sheet is animated to the snap point\n void animate(y, snapTo, animationOptions);\n\n if (snapPoints && onSnap) {\n const snapValue = Math.abs(Math.round(snapPoints[0] - snapTo));\n const snapIndex = snapPoints.indexOf(getClosest(snapPoints, snapValue)); // prettier-ignore\n onSnap(snapIndex);\n }\n\n const roundedSheetHeight = Math.round(sheetHeight);\n const shouldClose = snapTo + 2 >= roundedSheetHeight; // 2px tolerance\n\n if (shouldClose) onClose();\n }\n\n // Reset indicator rotation after dragging\n indicatorRotation.set(0);\n });\n\n // Trigger onSnap callback when sheet is opened or closed\n useEffect(() => {\n if (!snapPoints || !onSnap) return;\n const snapIndex = isOpen ? initialSnap : snapPoints.length - 1;\n onSnap(snapIndex);\n }, [isOpen]); // eslint-disable-line\n\n useImperativeHandle(ref, () => ({\n y,\n snapTo: (snapIndex: number) => {\n const sheetEl = sheetRef.current;\n\n if (snapPoints?.[snapIndex] !== undefined && sheetEl) {\n const sheetHeight = sheetEl.getBoundingClientRect().height;\n const snapPoint = snapPoints[snapIndex];\n const snapTo = validateSnapTo({\n snapTo: sheetHeight - snapPoint,\n sheetHeight,\n });\n\n void animate(y, snapTo, animationOptions);\n if (onSnap) onSnap(snapIndex);\n if (snapTo >= sheetHeight) onClose();\n }\n },\n }));\n\n useModalEffect(isOpen, rootId);\n\n // Framer Motion should handle body scroll locking but it's not working\n // properly on iOS. Scroll locking from React Aria seems to work much better.\n usePreventScroll({ isDisabled: disableScrollLocking || !isOpen });\n\n const dragProps = useMemo(() => {\n const dragProps: SheetContextType['dragProps'] = {\n drag: 'y',\n dragElastic: 0,\n dragMomentum: false,\n dragPropagation: false,\n onDrag,\n onDragStart,\n onDragEnd,\n };\n\n return disableDrag ? undefined : dragProps;\n }, [disableDrag, windowHeight]); // eslint-disable-line\n\n const context: SheetContextType = {\n y,\n sheetRef,\n isOpen,\n initialSnap,\n snapPoints,\n detent,\n indicatorRotation,\n callbacks,\n dragProps,\n windowHeight,\n animationOptions,\n reduceMotion,\n disableDrag,\n };\n\n const sheet = (\n <SheetContext.Provider value={context}>\n <motion.div\n {...rest}\n ref={ref}\n style={{ ...styles.wrapper, zIndex, visibility, ...style }}\n >\n <AnimatePresence>\n {/* NOTE: AnimatePresence requires us to set keys to children */}\n {isOpen ? (\n <SheetScrollerContextProvider>\n {Children.map(children, (child: any, i) =>\n cloneElement(child, { key: `sheet-child-${i}` })\n )}\n </SheetScrollerContextProvider>\n ) : null}\n </AnimatePresence>\n </motion.div>\n </SheetContext.Provider>\n );\n\n if (IS_SSR) return sheet;\n\n return createPortal(sheet, mountPoint ?? document.body);\n }\n);\n\nSheet.displayName = 'Sheet';\n\nexport default Sheet;\n","import {\n type MutableRefObject,\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { isBrowser, type BoundingBox } from 'framer-motion';\n\nimport { IS_SSR } from './constants';\nimport { type SheetEvents } from './types';\nimport { applyRootStyles, cleanupRootStyles } from './utils';\n\nexport const useIsomorphicLayoutEffect = IS_SSR ? useEffect : useLayoutEffect;\n\nexport function useModalEffect(isOpen: boolean, rootId?: string) {\n const prevOpen = usePrevious(isOpen);\n\n // Automatically apply the iOS modal effect to the body when sheet opens/closes\n useEffect(() => {\n if (rootId && !prevOpen && isOpen) {\n applyRootStyles(rootId);\n } else if (rootId && !isOpen && prevOpen) {\n cleanupRootStyles(rootId);\n }\n }, [isOpen, prevOpen]); // eslint-disable-line\n\n // Make sure to cleanup modal styles on unmount\n useEffect(() => {\n return () => {\n if (rootId && isOpen) cleanupRootStyles(rootId);\n };\n }, [isOpen]); // eslint-disable-line\n}\n\nexport function useEventCallbacks(\n isOpen: boolean,\n callbacks: MutableRefObject<SheetEvents>\n) {\n const prevOpen = usePrevious(isOpen);\n const didOpen = useRef(false);\n\n // Because of AnimatePrecence we don't have access to latest isOpen value\n // so we need to read and write to a ref to determine if we are\n // opening or closing the sheet\n const handleAnimationComplete = useCallback(() => {\n if (!didOpen.current) {\n callbacks.current.onOpenEnd?.();\n didOpen.current = true;\n } else {\n callbacks.current.onCloseEnd?.();\n didOpen.current = false;\n }\n }, [isOpen, prevOpen]); // eslint-disable-line\n\n useEffect(() => {\n if (!prevOpen && isOpen) {\n callbacks.current.onOpenStart?.();\n } else if (!isOpen && prevOpen) {\n callbacks.current.onCloseStart?.();\n }\n }, [isOpen, prevOpen]); // eslint-disable-line\n\n return { handleAnimationComplete };\n}\n\nexport function useDimensions() {\n const [dimensions, setDimensions] = useState({\n height: isBrowser ? window.innerHeight : 0,\n width: isBrowser ? window.innerWidth : 0,\n });\n\n useIsomorphicLayoutEffect(() => {\n function handler() {\n setDimensions({\n height: window.innerHeight,\n width: window.innerWidth,\n });\n }\n\n handler();\n\n window.addEventListener('resize', handler);\n\n return () => {\n window.removeEventListener('resize', handler);\n };\n }, []);\n\n return dimensions;\n}\n\nexport function usePrevious<T>(state: T): T | undefined {\n const ref = useRef<T>();\n\n useEffect(() => {\n ref.current = state;\n });\n\n return ref.current;\n}\n\n// Userland version of the `useEffectEvent` React hook:\n// RFC: https://react.dev/reference/react/experimental_useEffectEvent\nexport function useEffectEvent<T extends (...args: any[]) => any>(handler: T) {\n const handlerRef = useRef<T>();\n\n useIsomorphicLayoutEffect(() => {\n handlerRef.current = handler;\n });\n\n return useCallback((...args: any[]) => {\n const fn = handlerRef.current;\n return fn?.(...args);\n }, []) as T;\n}\n\n// This is a hacky way to fix a bug in framer-motion where the drag\n// constraints are not updated when window is resized.\n// https://github.com/framer/motion/issues/1659\nconst constraints: BoundingBox = { bottom: 0, top: 0, left: 0, right: 0 };\n\nexport function useDragConstraints() {\n const constraintsRef = useRef<any>(null);\n const onMeasureDragConstraints = useCallback(() => constraints, []);\n return { constraintsRef, onMeasureDragConstraints };\n}\n","export const MAX_HEIGHT = 'calc(100% - env(safe-area-inset-top) - 34px)';\n\nexport const IS_SSR = typeof window === 'undefined';\n\nexport const DEFAULT_TWEEN_CONFIG = {\n ease: 'easeOut',\n duration: 0.2,\n};\n\nexport const REDUCED_MOTION_TWEEN_CONFIG = {\n ease: 'linear',\n duration: 0.01,\n};\n\nexport const DEFAULT_DRAG_CLOSE_THRESHOLD = 0.6;\n\nexport const DEFAULT_DRAG_VELOCITY_THRESHOLD = 500;\n","import { type ForwardedRef, type RefCallback } from 'react';\n\nexport function getClosest(nums: number[], goal: number) {\n let closest = nums[0];\n let minDifference = Math.abs(nums[0] - goal);\n\n for (let i = 1; i < nums.length; i++) {\n const difference = Math.abs(nums[i] - goal);\n if (difference < minDifference) {\n closest = nums[i];\n minDifference = difference;\n }\n }\n\n return closest;\n}\n\nexport function applyRootStyles(rootId: string) {\n const body = document.querySelector('body') as HTMLBodyElement;\n const root = document.querySelector(`#${rootId}`) as HTMLDivElement;\n\n if (root) {\n const p = 24;\n const h = window.innerHeight;\n const s = (h - p) / h;\n body.style.backgroundColor = '#000';\n root.style.overflow = 'hidden';\n root.style.willChange = 'transform';\n root.style.transition =\n 'transform 200ms ease-in-out, border-radius 200ms linear';\n root.style.transform = `translateY(calc(env(safe-area-inset-top) + ${p / 2}px)) scale(${s})`; // prettier-ignore\n root.style.borderTopRightRadius = '10px';\n root.style.borderTopLeftRadius = '10px';\n }\n}\n\nexport function cleanupRootStyles(rootId: string) {\n const body = document.querySelector('body') as HTMLBodyElement;\n const root = document.getElementById(rootId) as HTMLDivElement;\n\n function onTransitionEnd() {\n root.style.removeProperty('overflow');\n root.style.removeProperty('will-change');\n root.style.removeProperty('transition');\n body.style.removeProperty('background-color');\n root.removeEventListener('transitionend', onTransitionEnd);\n }\n\n if (root) {\n // Start animating back\n root.style.removeProperty('border-top-right-radius');\n root.style.removeProperty('border-top-left-radius');\n root.style.removeProperty('transform');\n\n // Remove temp properties after animation is finished\n root.addEventListener('transitionend', onTransitionEnd);\n }\n}\n\nexport function inDescendingOrder(arr: number[]) {\n for (let i = 0; i < arr.length; i++) {\n if (arr[i + 1] > arr[i]) return false;\n }\n\n return true;\n}\n\nexport function validateSnapTo({\n snapTo,\n sheetHeight,\n}: {\n snapTo: number;\n sheetHeight: number;\n}) {\n if (snapTo < 0) {\n console.warn(\n `Snap point is out of bounds. Sheet height is ${sheetHeight} but snap point is ${\n sheetHeight + Math.abs(snapTo)\n }.`\n );\n }\n\n return Math.max(Math.round(snapTo), 0);\n}\n\nexport function mergeRefs<T = any>(\n refs: Array<ForwardedRef<T>>\n): RefCallback<T> {\n return (value: any) => {\n refs.forEach((ref: any) => {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref) {\n ref.current = value;\n }\n });\n };\n}\n\nexport function isTouchDevice() {\n if (typeof window === 'undefined') return false;\n return 'ontouchstart' in window || navigator.maxTouchPoints > 0;\n}\n","import React, { type ReactNode, createContext, useContext, useState } from 'react';\nimport { type SheetScrollerContextType, type SheetContextType } from './types';\n\nexport const SheetContext = createContext<SheetContextType | undefined>(\n undefined\n);\n\nexport const useSheetContext = () => {\n const context = useContext(SheetContext);\n if (!context) throw Error('Sheet context error');\n return context;\n};\n\nexport const SheetScrollerContext = createContext<\n SheetScrollerContextType | undefined\n>(undefined);\n\nexport function SheetScrollerContextProvider({\n children,\n}: {\n children: ReactNode;\n}) {\n const sheetContext = useSheetContext();\n const [disableDrag, setDisableDrag] = useState(!!sheetContext.disableDrag);\n\n function setDragEnabled() {\n if (!sheetContext.disableDrag) setDisableDrag(false);\n }\n\n function setDragDisabled() {\n if (!disableDrag) setDisableDrag(true);\n }\n\n return (\n <SheetScrollerContext.Provider\n value={{ disableDrag, setDragEnabled, setDragDisabled }}\n >\n {children}\n </SheetScrollerContext.Provider>\n );\n}\n\nexport const useSheetScrollerContext = () => {\n const context = useContext(SheetScrollerContext);\n if (!context) throw Error('Sheet scroller context error');\n return context;\n};\n","// Source: https://github.com/adobe/react-spectrum/blob/main/packages/@react-aria/overlays/src/usePreventScroll.ts\nimport {\n chain,\n getScrollParent,\n isIOS,\n useLayoutEffect,\n} from '@react-aria/utils';\n\ninterface PreventScrollOptions {\n /** Whether the scroll lock is disabled. */\n isDisabled?: boolean;\n}\n\nconst visualViewport =\n typeof window !== 'undefined' ? (window as any).visualViewport : undefined;\n\n// HTML input types that do not cause the software keyboard to appear.\nconst nonTextInputTypes = new Set([\n 'checkbox',\n 'radio',\n 'range',\n 'color',\n 'file',\n 'image',\n 'button',\n 'submit',\n 'reset',\n]);\n\n// The number of active usePreventScroll calls. Used to determine whether to revert back to the original page style/scroll position\nlet preventScrollCount = 0;\nlet restore: any;\n\n/**\n * Prevents scrolling on the document body on mount, and\n * restores it on unmount. Also ensures that content does not\n * shift due to the scrollbars disappearing.\n */\nexport function usePreventScroll(options: PreventScrollOptions = {}) {\n const { isDisabled } = options;\n\n useLayoutEffect(() => {\n if (isDisabled) {\n return;\n }\n\n preventScrollCount++;\n if (preventScrollCount === 1) {\n if (isIOS()) {\n restore = preventScrollMobileSafari();\n } else {\n restore = preventScrollStandard();\n }\n }\n\n return () => {\n preventScrollCount--;\n if (preventScrollCount === 0) {\n restore();\n }\n };\n }, [isDisabled]);\n}\n\n// For most browsers, all we need to do is set `overflow: hidden` on the root element, and\n// add some padding to prevent the page from shifting when the scrollbar is hidden.\nfunction preventScrollStandard() {\n return chain(\n setStyle(\n document.documentElement,\n 'paddingRight',\n `${window.innerWidth - document.documentElement.clientWidth}px`\n ),\n setStyle(document.documentElement, 'overflow', 'hidden')\n );\n}\n\n// Mobile Safari is a whole different beast. Even with overflow: hidden,\n// it still scrolls the page in many situations:\n//\n// 1. When the bottom toolbar and address bar are collapsed, page scrolling is always allowed.\n// 2. When the keyboard is visible, the viewport does not resize. Instead, the keyboard covers part of\n// it, so it becomes scrollable.\n// 3. When tapping on an input, the page always scrolls so that the input is centered in the visual viewport.\n// This may cause even fixed position elements to scroll off the screen.\n// 4. When using the next/previous buttons in the keyboard to navigate between inputs, the whole page always\n// scrolls, even if the input is inside a nested scrollable element that could be scrolled instead.\n//\n// In order to work around these cases, and prevent scrolling without jankiness, we do a few things:\n//\n// 1. Prevent default on `touchmove` events that are not in a scrollable element. This prevents touch scrolling\n// on the window.\n// 2. Prevent default on `touchmove` events inside a scrollable element when the scroll position is at the\n// top or bottom. This avoids the whole page scrolling instead, but does prevent overscrolling.\n// 3. Prevent default on `touchend` events on input elements and handle focusing the element ourselves.\n// 4. When focusing an input, apply a transform to trick Safari into thinking the input is at the top\n// of the page, which prevents it from scrolling the page. After the input is focused, scroll the element\n// into view ourselves, without scrolling the whole page.\n// 5. Offset the body by the scroll position using a negative margin and scroll to the top. This should appear the\n// same visually, but makes the actual scroll position always zero. This is required to make all of the\n// above work or Safari will still try to scroll the page when focusing an input.\n// 6. As a last resort, handle window scroll events, and scroll back to the top. This can happen when attempting\n// to navigate to an input with the next/previous buttons that's outside a modal.\nfunction preventScrollMobileSafari() {\n let scrollable: Element | undefined;\n let lastY = 0;\n\n const onTouchStart = (e: TouchEvent) => {\n // Store the nearest scrollable parent element from the element that the user touched.\n scrollable = getScrollParent(e.target as Element);\n if (\n scrollable === document.documentElement &&\n scrollable === document.body\n ) {\n return;\n }\n\n lastY = e.changedTouches[0].pageY;\n };\n\n const onTouchMove = (e: TouchEvent) => {\n // In special situations, `onTouchStart` may be called without `onTouchStart` being called.\n // (e.g. when the user places a finger on the screen before the <Sheet> is mounted and then moves the finger after it is mounted).\n // If `onTouchStart` is not called, `scrollable` is `undefined`. Therefore, such cases are ignored.\n if (scrollable === undefined) {\n return;\n }\n\n // Prevent scrolling the window.\n if (\n scrollable === document.documentElement ||\n scrollable === document.body\n ) {\n e.preventDefault();\n return;\n }\n\n // Prevent scrolling up when at the top and scrolling down when at the bottom\n // of a nested scrollable area, otherwise mobile Safari will start scrolling\n // the window instead. Unfortunately, this disables bounce scrolling when at\n // the top but it's the best we can do.\n const y = e.changedTouches[0].pageY;\n const scrollTop = scrollable.scrollTop;\n const bottom = scrollable.scrollHeight - scrollable.clientHeight;\n\n // Fix for: https://github.com/adobe/react-spectrum/pull/3780/files\n if (bottom === 0) {\n return;\n }\n\n if ((scrollTop <= 0 && y > lastY) || (scrollTop >= bottom && y < lastY)) {\n e.preventDefault();\n }\n\n lastY = y;\n };\n\n const onTouchEnd = (e: TouchEvent) => {\n const target = e.target as HTMLElement;\n\n // Apply this change if we're not already focused on the target element\n if (willOpenKeyboard(target) && target !== document.activeElement) {\n e.preventDefault();\n\n // Apply a transform to trick Safari into thinking the input is at the top of the page\n // so it doesn't try to scroll it into view. When tapping on an input, this needs to\n // be done before the \"focus\" event, so we have to focus the element ourselves.\n target.style.transform = 'translateY(-2000px)';\n target.focus();\n requestAnimationFrame(() => {\n target.style.transform = '';\n });\n }\n };\n\n const onFocus = (e: FocusEvent) => {\n const target = e.target as HTMLElement;\n if (willOpenKeyboard(target)) {\n // Transform also needs to be applied in the focus event in cases where focus moves\n // other than tapping on an input directly, e.g. the next/previous buttons in the\n // software keyboard. In these cases, it seems applying the transform in the focus event\n // is good enough, whereas when tapping an input, it must be done before the focus event. 🤷♂️\n target.style.transform = 'translateY(-2000px)';\n requestAnimationFrame(() => {\n target.style.transform = '';\n\n // This will have prevented the browser from scrolling the focused element into view,\n // so we need to do this ourselves in a way that doesn't cause the whole page to scroll.\n if (visualViewport) {\n if (visualViewport.height < window.innerHeight) {\n // If the keyboard is already visible, do this after one additional frame\n // to wait for the transform to be removed.\n requestAnimationFrame(() => {\n scrollIntoView(target);\n });\n } else {\n // Otherwise, wait for the visual viewport to resize before scrolling so we can\n // measure the correct position to scroll to.\n visualViewport.addEventListener(\n 'resize',\n () => {\n scrollIntoView(target);\n },\n { once: true }\n );\n }\n }\n });\n }\n };\n\n const onWindowScroll = () => {\n // Last resort. If the window scrolled, scroll it back to the top.\n // It should always be at the top because the body will have a negative margin (see below).\n window.scrollTo(0, 0);\n };\n\n // Record the original scroll position so we can restore it.\n // Then apply a negative margin to the body to offset it by the scroll position. This will\n // enable us to scroll the window to the top, which is required for the rest of this to work.\n const scrollX = window.pageXOffset;\n const scrollY = window.pageYOffset;\n\n const restoreStyles = chain(\n setStyle(\n document.documentElement,\n 'paddingRight',\n `${window.innerWidth - document.documentElement.clientWidth}px`\n ),\n setStyle(document.documentElement, 'overflow', 'hidden'),\n setStyle(document.body, 'marginTop', `-${scrollY}px`)\n );\n\n // Scroll to the top. The negative margin on the body will make this appear the same.\n window.scrollTo(0, 0);\n\n const removeEvents = chain(\n addEvent(document, 'touchstart', onTouchStart, {\n passive: false,\n capture: true,\n }),\n addEvent(document, 'touchmove', onTouchMove, {\n passive: false,\n capture: true,\n }),\n addEvent(document, 'touchend', onTouchEnd, {\n passive: false,\n capture: true,\n }),\n addEvent(document, 'focus', onFocus, true),\n addEvent(window, 'scroll', onWindowScroll)\n );\n\n return () => {\n // Restore styles and scroll the page back to where it was.\n restoreStyles();\n removeEvents();\n window.scrollTo(scrollX, scrollY);\n };\n}\n\n// Sets a CSS property on an element, and returns a function to revert it to the previous value.\nfunction setStyle(element: any, style: string, value: string) {\n const cur = element.style[style];\n element.style[style] = value;\n\n return () => {\n element.style[style] = cur;\n };\n}\n\n// Adds an event listener to an element, and returns a function to remove it.\nfunction addEvent<K extends keyof GlobalEventHandlersEventMap>(\n target: EventTarget,\n event: K,\n handler: (this: Document, ev: GlobalEventHandlersEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n) {\n target.addEventListener(event, handler as any, options);\n return () => {\n target.removeEventListener(event, handler as any, options);\n };\n}\n\nfunction scrollIntoView(target: Element) {\n const root = document.scrollingElement || document.documentElement;\n while (target && target !== root) {\n // Find the parent scrollable element and adjust the scroll position if the target is not already in view.\n const scrollable = getScrollParent(target);\n if (\n scrollable !== document.documentElement &&\n scrollable !== document.body &&\n scrollable !== target\n ) {\n const scrollableTop = scrollable.getBoundingClientRect().top;\n const targetTop = target.getBoundingClientRect().top;\n if (targetTop > scrollableTop + target.clientHeight) {\n scrollable.scrollTop += targetTop - scrollableTop;\n }\n }\n\n target = scrollable.parentElement as any;\n }\n}\n\nfunction willOpenKeyboard(target: Element) {\n return (\n (target instanceof HTMLInputElement &&\n !nonTextInputTypes.has(target.type)) ||\n target instanceof HTMLTextAreaElement ||\n (target instanceof HTMLElement && target.isContentEditable)\n );\n}\n","import { type Properties } from 'csstype';\n\nconst styles: Record<string, Properties> = {\n wrapper: {\n position: 'fixed',\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n overflow: 'hidden',\n pointerEvents: 'none',\n },\n backdrop: {\n zIndex: 1,\n position: 'fixed',\n top: 0,\n left: 0,\n width: '100%',\n height: '100%',\n backgroundColor: 'rgba(0, 0, 0, 0.2)',\n touchAction: 'none', // Disable iOS body scrolling\n border: 'none',\n },\n container: {\n zIndex: 2,\n position: 'absolute',\n left: 0,\n bottom: 0,\n width: '100%',\n backgroundColor: '#fff',\n borderTopRightRadius: '8px',\n borderTopLeftRadius: '8px',\n boxShadow: '0px -2px 16px rgba(0, 0, 0, 0.3)',\n display: 'flex',\n flexDirection: 'column',\n pointerEvents: 'auto',\n },\n headerWrapper: {\n width: '100%',\n },\n header: {\n height: '40px',\n width: '100%',\n position: 'relative',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n },\n indicator: {\n width: '18px',\n height: '4px',\n borderRadius: '99px',\n backgroundColor: '#ddd',\n },\n content: {\n flexGrow: 1,\n display: 'flex',\n flexDirection: 'column',\n minHeight: '0px',\n position: 'relative',\n },\n scroller: {\n height: '100%',\n overflowY: 'auto',\n },\n};\n\nexport default styles;\n","import React, { forwardRef } from 'react';\nimport { motion } from 'framer-motion';\n\nimport { type SheetContainerProps } from './types';\nimport { useSheetContext } from './context';\nimport { useEventCallbacks } from './hooks';\nimport { MAX_HEIGHT } from './constants';\nimport { mergeRefs } from './utils';\nimport styles from './styles';\n\nconst SheetContainer = forwardRef<any, SheetContainerProps>(\n ({ children, style = {}, className = '', ...rest }, ref) => {\n const {\n y,\n isOpen,\n callbacks,\n snapPoints,\n initialSnap = 0,\n sheetRef,\n windowHeight,\n detent,\n animationOptions,\n reduceMotion,\n } = useSheetContext();\n\n const { handleAnimationComplete } = useEventCallbacks(isOpen, callbacks);\n const initialY = snapPoints ? snapPoints[0] - snapPoints[initialSnap] : 0;\n const maxSnapHeight = snapPoints ? snapPoints[0] : null;\n\n const height =\n maxSnapHeight !== null\n ? `min(${maxSnapHeight}px, ${MAX_HEIGHT})`\n : MAX_HEIGHT;\n\n return (\n <motion.div\n {...rest}\n ref={mergeRefs([sheetRef, ref])}\n className={`react-modal-sheet-container ${className}`}\n style={{\n ...styles.container,\n ...style,\n ...(detent === 'full-height' && { height }),\n ...(detent === 'content-height' && { maxHeight: height }),\n y,\n }}\n initial={reduceMotion ? false : { y: windowHeight }}\n animate={{ y: initialY, transition: animationOptions }}\n exit={{ y: windowHeight, transition: animationOptions }}\n onAnimationComplete={handleAnimationComplete}\n >\n {children}\n </motion.div>\n );\n }\n);\n\nSheetContainer.displayName = 'SheetContainer';\n\nexport default SheetContainer;\n","import React, { forwardRef } from 'react';\nimport { motion } from 'framer-motion';\n\nimport { type SheetDraggableProps } from './types';\nimport { useSheetScrollerContext, useSheetContext } from './context';\nimport { useDragConstraints } from './hooks';\nimport { mergeRefs } from './utils';\nimport styles from './styles';\n\nconst SheetContent = forwardRef<any, SheetDraggableProps>(\n ({ children, style, disableDrag, className = '', ...rest }, ref) => {\n const sheetContext = useSheetContext();\n const sheetScrollerContext = useSheetScrollerContext();\n const { constraintsRef, onMeasureDragConstraints } = useDragConstraints();\n\n const dragProps =\n disableDrag || sheetScrollerContext.disableDrag\n ? undefined\n : sheetContext.dragProps;\n\n return (\n <motion.div\n {...rest}\n ref={mergeRefs([ref, constraintsRef])}\n className={`react-modal-sheet-content ${className}`}\n style={{ ...styles.content, ...style }}\n {...dragProps}\n dragConstraints={constraintsRef}\n onMeasureDragConstraints={onMeasureDragConstraints}\n >\n {children}\n </motion.div>\n );\n }\n);\n\nSheetContent.displayName = 'SheetContent';\n\nexport default SheetContent;\n","import React, { forwardRef } from 'react';\nimport { motion, useTransform } from 'framer-motion';\n\nimport { type SheetDraggableProps } from './types';\nimport { useSheetContext } from './context';\nimport { useDragConstraints } from './hooks';\nimport { mergeRefs } from './utils';\nimport styles from './styles';\n\nconst SheetHeader = forwardRef<any, SheetDraggableProps>(\n ({ children, style, disableDrag, ...rest }, ref) => {\n const { indicatorRotation, dragProps } = useSheetContext();\n const { constraintsRef, onMeasureDragConstraints } = useDragConstraints();\n const _dragProps = disableDrag ? undefined : dragProps;\n\n const indicator1Transform = useTransform(\n indicatorRotation,\n (r) => `translateX(2px) rotate(${r}deg)`\n );\n\n const indicator2Transform = useTransform(\n indicatorRotation,\n (r) => `translateX(-2px) rotate(${-1 * r}deg)`\n );\n\n return (\n <motion.div\n {...rest}\n ref={mergeRefs([ref, constraintsRef])}\n style={{ ...styles.headerWrapper, ...style }}\n {..._dragProps}\n dragConstraints={constraintsRef}\n onMeasureDragConstraints={onMeasureDragConstraints}\n >\n {children || (\n <div className=\"react-modal-sheet-header\" style={styles.header}>\n <motion.span\n className=\"react-modal-sheet-drag-indicator\"\n style={{ ...styles.indicator, transform: indicator1Transform }}\n />\n <motion.span\n className=\"react-modal-sheet-drag-indicator\"\n style={{ ...styles.indicator, transform: indicator2Transform }}\n />\n </div>\n )}\n </motion.div>\n );\n }\n);\n\nSheetHeader.displayName = 'SheetHeader';\n\nexport default SheetHeader;\n","import React, { forwardRef } from 'react';\nimport { motion } from 'framer-motion';\n\nimport { type SheetBackdropProps } from './types';\nimport styles from './styles';\n\nconst isClickable = (props: any) => !!props.onClick || !!props.onTap;\n\nconst SheetBackdrop = forwardRef<any, SheetBackdropProps>(\n ({ style = {}, className = '', ...rest }, ref) => {\n const Comp = isClickable(rest) ? motion.button : motion.div;\n const pointerEvents = isClickable(rest) ? 'auto' : 'none';\n\n return (\n <Comp\n {...rest}\n ref={ref}\n className={`react-modal-sheet-backdrop ${className}`}\n style={{ ...styles.backdrop, ...style, pointerEvents }}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n />\n );\n }\n);\n\nSheetBackdrop.displayName = 'SheetBackdrop';\n\nexport default SheetBackdrop;\n","import React, { type TouchEvent, type UIEvent, forwardRef } from 'react';\n\nimport { useSheetScrollerContext } from './context';\nimport { type SheetScrollerProps } from './types';\nimport { isTouchDevice } from './utils';\nimport styles from './styles';\n\nconst SheetScroller = forwardRef<any, SheetScrollerProps>(\n ({ draggableAt = 'top', children, style, className = '', ...rest }, ref) => {\n const sheetScrollerContext = useSheetScrollerContext();\n\n function determineDragState(element: HTMLDivElement) {\n const { scrollTop, scrollHeight, clientHeight } = element;\n const isScrollable = scrollHeight > clientHeight;\n\n if (!isScrollable) return;\n\n const isAtTop = scrollTop <= 0;\n const isAtBottom = scrollHeight - scrollTop === clientHeight;\n\n const shouldEnable =\n (draggableAt === 'top' && isAtTop) ||\n (draggableAt === 'bottom' && isAtBottom) ||\n (draggableAt === 'both' && (isAtTop || isAtBottom));\n\n if (shouldEnable) {\n sheetScrollerContext.setDragEnabled();\n } else {\n sheetScrollerContext.setDragDisabled();\n }\n }\n\n function onScroll(e: UIEvent<HTMLDivElement>) {\n determineDragState(e.currentTarget);\n }\n\n function onTouchStart(e: TouchEvent<HTMLDivElement>) {\n determineDragState(e.currentTarget);\n }\n\n const scrollProps = isTouchDevice()\n ? { onScroll, onTouchStart }\n : undefined;\n\n return (\n <div\n {...rest}\n ref={ref}\n className={`react-modal-sheet-scroller ${className}`}\n style={{ ...styles.scroller, ...style }}\n {...scrollProps}\n >\n {children}\n </div>\n );\n }\n);\n\nSheetScroller.displayName = 'SheetScroller';\n\nexport default SheetScroller;\n","import { type MotionValue } from 'framer-motion';\n\nimport _Sheet from './sheet';\nimport SheetContainer from './SheetContainer';\nimport SheetContent from './SheetContent';\nimport SheetHeader from './SheetHeader';\nimport SheetBackdrop from './SheetBackdrop';\nimport SheetScroller from './SheetScroller';\nimport { type SheetCompound } from './types';\n\nexport interface SheetRef {\n y: MotionValue<number>;\n snapTo: (index: number) => void;\n}\n\n// HACK: this is needed to get the typing to work properly...\nconst _SheetCompound: any = _Sheet;\n_SheetCompound.Container = SheetContainer;\n_SheetCompound.Header = SheetHeader;\n_SheetCompound.Content = SheetContent;\n_SheetCompound.Backdrop = SheetBackdrop;\n_SheetCompound.Scroller = SheetScroller;\n\nexport const Sheet = _SheetCompound as SheetCompound;\n"]}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "3.
|
|
2
|
+
"version": "3.3.0",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "react-modal-sheet",
|
|
5
5
|
"description": "Flexible bottom sheet component for your React apps",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"release": "npm run build && npm run build:verify && np"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@react-aria/utils": "3.
|
|
45
|
+
"@react-aria/utils": "3.25.3"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"framer-motion": ">=
|
|
48
|
+
"framer-motion": ">=10",
|
|
49
49
|
"react": ">=16"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"eslint-plugin-promise": "6.1.1",
|
|
64
64
|
"eslint-plugin-react": "7.33.2",
|
|
65
65
|
"eslint-plugin-react-hooks": "4.6.0",
|
|
66
|
-
"framer-motion": "11.
|
|
66
|
+
"framer-motion": "11.11.10",
|
|
67
67
|
"history": "5.0.0",
|
|
68
68
|
"husky": "4.2.5",
|
|
69
69
|
"jsdom": "22.1.0",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"react-stately": "3.23.0",
|
|
79
79
|
"styled-components": "6.0.8",
|
|
80
80
|
"tsup": "8.0.2",
|
|
81
|
-
"typescript": "5.
|
|
81
|
+
"typescript": "5.6.3",
|
|
82
82
|
"vite": "4.4.11",
|
|
83
83
|
"vitest": "0.34.6"
|
|
84
84
|
},
|
package/src/constants.ts
CHANGED
|
@@ -12,6 +12,6 @@ export const REDUCED_MOTION_TWEEN_CONFIG = {
|
|
|
12
12
|
duration: 0.01,
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
export const
|
|
15
|
+
export const DEFAULT_DRAG_CLOSE_THRESHOLD = 0.6;
|
|
16
16
|
|
|
17
|
-
export const
|
|
17
|
+
export const DEFAULT_DRAG_VELOCITY_THRESHOLD = 500;
|
package/src/hooks.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
useState,
|
|
8
8
|
} from 'react';
|
|
9
9
|
|
|
10
|
-
import { type BoundingBox } from 'framer-motion';
|
|
10
|
+
import { isBrowser, type BoundingBox } from 'framer-motion';
|
|
11
11
|
|
|
12
12
|
import { IS_SSR } from './constants';
|
|
13
13
|
import { type SheetEvents } from './types';
|
|
@@ -67,7 +67,10 @@ export function useEventCallbacks(
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
export function useDimensions() {
|
|
70
|
-
const [dimensions, setDimensions] = useState({
|
|
70
|
+
const [dimensions, setDimensions] = useState({
|
|
71
|
+
height: isBrowser ? window.innerHeight : 0,
|
|
72
|
+
width: isBrowser ? window.innerWidth : 0,
|
|
73
|
+
});
|
|
71
74
|
|
|
72
75
|
useIsomorphicLayoutEffect(() => {
|
|
73
76
|
function handler() {
|
package/src/sheet.tsx
CHANGED
|
@@ -31,8 +31,8 @@ import {
|
|
|
31
31
|
import {
|
|
32
32
|
REDUCED_MOTION_TWEEN_CONFIG,
|
|
33
33
|
DEFAULT_TWEEN_CONFIG,
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
DEFAULT_DRAG_CLOSE_THRESHOLD,
|
|
35
|
+
DEFAULT_DRAG_VELOCITY_THRESHOLD,
|
|
36
36
|
IS_SSR,
|
|
37
37
|
} from './constants';
|
|
38
38
|
|
|
@@ -54,7 +54,7 @@ const Sheet = forwardRef<any, SheetProps>(
|
|
|
54
54
|
children,
|
|
55
55
|
disableScrollLocking = false,
|
|
56
56
|
isOpen,
|
|
57
|
-
snapPoints,
|
|
57
|
+
snapPoints: snapPointsProp,
|
|
58
58
|
rootId,
|
|
59
59
|
mountPoint,
|
|
60
60
|
style,
|
|
@@ -63,6 +63,8 @@ const Sheet = forwardRef<any, SheetProps>(
|
|
|
63
63
|
disableDrag = false,
|
|
64
64
|
prefersReducedMotion = false,
|
|
65
65
|
tweenConfig = DEFAULT_TWEEN_CONFIG,
|
|
66
|
+
dragVelocityThreshold = DEFAULT_DRAG_VELOCITY_THRESHOLD,
|
|
67
|
+
dragCloseThreshold = DEFAULT_DRAG_CLOSE_THRESHOLD,
|
|
66
68
|
...rest
|
|
67
69
|
},
|
|
68
70
|
ref
|
|
@@ -80,7 +82,7 @@ const Sheet = forwardRef<any, SheetProps>(
|
|
|
80
82
|
// NOTE: the inital value for `y` doesn't matter since it is overwritten by
|
|
81
83
|
// the value driven by the `AnimatePresence` component when the sheet is opened
|
|
82
84
|
// and after that it is driven by the gestures and/or snapping
|
|
83
|
-
const y = useMotionValue(
|
|
85
|
+
const y = useMotionValue(windowHeight);
|
|
84
86
|
|
|
85
87
|
// +2 for tolerance in case the animated value is slightly off
|
|
86
88
|
const zIndex = useTransform(y, (value) =>
|
|
@@ -108,6 +110,8 @@ const Sheet = forwardRef<any, SheetProps>(
|
|
|
108
110
|
};
|
|
109
111
|
});
|
|
110
112
|
|
|
113
|
+
let snapPoints: number[] | undefined = snapPointsProp;
|
|
114
|
+
|
|
111
115
|
if (snapPoints) {
|
|
112
116
|
// Convert negative / percentage snap points to absolute values
|
|
113
117
|
snapPoints = snapPoints.map((point) => {
|
|
@@ -152,7 +156,7 @@ const Sheet = forwardRef<any, SheetProps>(
|
|
|
152
156
|
});
|
|
153
157
|
|
|
154
158
|
const onDragEnd = useEffectEvent((_, { velocity }: PanInfo) => {
|
|
155
|
-
if (velocity.y >
|
|
159
|
+
if (velocity.y > dragVelocityThreshold) {
|
|
156
160
|
// User flicked the sheet down
|
|
157
161
|
onClose();
|
|
158
162
|
} else {
|
|
@@ -174,7 +178,7 @@ const Sheet = forwardRef<any, SheetProps>(
|
|
|
174
178
|
|
|
175
179
|
// Get the closest snap point
|
|
176
180
|
snapTo = getClosest(snapToValues, currentY);
|
|
177
|
-
} else if (currentY / sheetHeight >
|
|
181
|
+
} else if (currentY / sheetHeight > dragCloseThreshold) {
|
|
178
182
|
// Close if dragged over enough far
|
|
179
183
|
snapTo = sheetHeight;
|
|
180
184
|
}
|
package/src/types.tsx
CHANGED
|
@@ -48,6 +48,8 @@ export type SheetProps = {
|
|
|
48
48
|
disableDrag?: boolean;
|
|
49
49
|
disableScrollLocking?: boolean;
|
|
50
50
|
prefersReducedMotion?: boolean;
|
|
51
|
+
dragVelocityThreshold?: number;
|
|
52
|
+
dragCloseThreshold?: number;
|
|
51
53
|
} & SheetEvents &
|
|
52
54
|
ComponentPropsWithoutRef<typeof motion.div>;
|
|
53
55
|
|