@simoneggert/react-modal-sheet 5.4.3

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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/context.tsx","../src/styles.ts","../src/constants.ts","../src/utils.ts","../src/SheetBackdrop.tsx","../src/SheetContainer.tsx","../src/hooks/use-drag-constraints.ts","../src/hooks/use-isomorphic-layout-effect.ts","../src/hooks/use-stable-callback.ts","../src/hooks/use-scroll-position.ts","../src/SheetContent.tsx","../src/SheetDragIndicator.tsx","../src/SheetHeader.tsx","../src/hooks/use-dimensions.ts","../src/hooks/use-virtual-keyboard.ts","../src/hooks/use-keyboard-avoidance.ts","../src/hooks/use-safe-area-insets.ts","../src/hooks/use-modal-effect.ts","../src/hooks/use-prevent-scroll.ts","../src/hooks/use-sheet-state.ts","../src/snap.ts","../src/sheet.tsx","../src/index.tsx"],"names":["styles","React","forwardRef","motion","useRef","useCallback","element","isScrollable","useEffect","useState","useTransform","Sheet"],"mappings":";;;;;;;AAGO,IAAM,YAAA,GAAe,aAAA;AAAA,EAC1B;AACF,CAAA;AAEO,SAAS,eAAA,GAAkB;AAChC,EAAA,MAAM,OAAA,GAAU,WAAW,YAAY,CAAA;AACvC,EAAA,IAAI,CAAC,OAAA,EAAS,MAAM,IAAI,MAAM,qBAAqB,CAAA;AACnD,EAAA,OAAO,OAAA;AACT;;;ACTO,IAAM,MAAA,GAAS;AAAA,EACpB,IAAA,EAAM;AAAA,IACJ,IAAA,EAAM;AAAA,MACJ,QAAA,EAAU,OAAA;AAAA,MACV,GAAA,EAAK,CAAA;AAAA,MACL,MAAA,EAAQ,CAAA;AAAA,MACR,IAAA,EAAM,CAAA;AAAA,MACN,KAAA,EAAO,CAAA;AAAA,MACP,QAAA,EAAU,QAAA;AAAA,MACV,aAAA,EAAe;AAAA,KACjB;AAAA,IACA,YAAY;AAAC,GACf;AAAA,EACA,QAAA,EAAU;AAAA,IACR,IAAA,EAA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MACA,oBAAA;AAAA,MACA,cAAA;AAAA,MACA,QAAA;AAAA,MACA,QAAA;AAAA,MACA;AAAA,KACF;AAEA,IAAA,MAAM,KAAA,mBACJT,MAAAA,CAAA,aAAA,CAAC,YAAA,CAAa,UAAb,EAAsB,KAAA,EAAO,OAAA,EAAA,kBAC5BA,MAAAA,CAAA,aAAA;AAAA,MAACE,MAAAA,CAAO,GAAA;AAAA,MAAP;AAAA,QACE,GAAG,IAAA;AAAA,QACJ,GAAA;AAAA,QACA,kBAAA,EAAkB,KAAA;AAAA,QAClB,SAAA,EAAW,0BAA0B,SAAS,CAAA,CAAA;AAAA,QAC9C,KAAA,EAAO;AAAA,UACL,GAAG,WAAA,CAAY,MAAA,CAAO,IAAA,EAAM,QAAQ,CAAA;AAAA,UACpC,MAAA;AAAA,UACA,UAAA;AAAA,UACA,GAAG;AAAA;AACL,OAAA;AAAA,MAEC,KAAA,KAAU,WAAW,QAAA,GAAW;AAAA,KAErC,CAAA;AAGF,IAAA,IAAI,QAAQ,OAAO,KAAA;AAEnB,IAAA,OAAO,YAAA,CAAa,KAAA,EAAO,UAAA,IAAc,QAAA,CAAS,IAAI,CAAA;AAAA,EACxD;AACF,CAAA;AAEA,KAAA,CAAM,WAAA,GAAc,OAAA;;;AC5Yb,IAAMQ,MAAAA,GAAuB,MAAA,CAAO,MAAA,CAAO,KAAA,EAAW;AAAA,EAC3D,SAAA,EAAW,cAAA;AAAA,EACX,MAAA,EAAQ,WAAA;AAAA,EACR,aAAA,EAAe,kBAAA;AAAA,EACf,OAAA,EAAS,YAAA;AAAA,EACT,QAAA,EAAU;AACZ,CAAC","file":"index.mjs","sourcesContent":["import { createContext, useContext } from 'react';\nimport { type SheetContextType } from './types';\n\nexport const SheetContext = createContext<SheetContextType | undefined>(\n undefined\n);\n\nexport function useSheetContext() {\n const context = useContext(SheetContext);\n if (!context) throw new Error('Sheet context error');\n return context;\n}\n","import type { CSSProperties } from 'react';\n\nexport const styles = {\n root: {\n base: {\n position: 'fixed',\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n overflow: 'hidden',\n pointerEvents: 'none',\n },\n decorative: {},\n },\n backdrop: {\n base: {\n zIndex: 1,\n position: 'fixed',\n top: 0,\n left: 0,\n width: '100%',\n height: '100%',\n touchAction: 'none',\n userSelect: 'none',\n },\n decorative: {\n backgroundColor: 'rgba(0, 0, 0, 0.2)',\n border: 'none',\n WebkitTapHighlightColor: 'transparent',\n },\n },\n container: {\n base: {\n zIndex: 2,\n position: 'absolute',\n left: 0,\n bottom: 0,\n width: '100%',\n pointerEvents: 'auto',\n display: 'flex',\n flexDirection: 'column',\n },\n decorative: {\n backgroundColor: '#fff',\n borderTopRightRadius: '8px',\n borderTopLeftRadius: '8px',\n boxShadow: '0px -2px 16px rgba(0, 0, 0, 0.3)',\n },\n },\n headerWrapper: {\n base: {\n width: '100%',\n },\n decorative: {},\n },\n header: {\n base: {\n width: '100%',\n position: 'relative',\n },\n decorative: {\n height: '40px',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n },\n },\n indicatorWrapper: {\n base: {\n display: 'flex',\n },\n decorative: {},\n },\n indicator: {\n base: {\n display: 'inline-block',\n },\n decorative: {\n width: '18px',\n height: '4px',\n borderRadius: '99px',\n backgroundColor: '#ddd',\n },\n },\n content: {\n base: {\n minHeight: '0px',\n position: 'relative',\n flexGrow: 1,\n display: 'flex',\n flexDirection: 'column',\n },\n decorative: {},\n },\n scroller: {\n base: {\n height: '100%',\n overflowY: 'auto',\n overscrollBehaviorY: 'none',\n },\n decorative: {},\n },\n} satisfies Record<\n string,\n {\n base: CSSProperties;\n decorative: CSSProperties;\n }\n>;\n","import type { SheetTweenConfig } from './types';\n\nexport const DEFAULT_HEIGHT = 'calc(100% - env(safe-area-inset-top) - 34px)';\n\nexport const IS_SSR = typeof window === 'undefined';\n\nexport const DEFAULT_TWEEN_CONFIG: SheetTweenConfig = {\n ease: 'easeOut',\n duration: 0.2,\n};\n\nexport const REDUCED_MOTION_TWEEN_CONFIG: SheetTweenConfig = {\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 CSSProperties, type ForwardedRef, type RefCallback } from 'react';\nimport { IS_SSR } from './constants';\n\nexport function applyStyles(\n styles: { base: CSSProperties; decorative: CSSProperties },\n unstyled: boolean\n) {\n return unstyled ? styles.base : { ...styles.base, ...styles.decorative };\n}\n\nexport function isAscendingOrder(arr: number[]) {\n for (let i = 0; i < arr.length; i++) {\n if (arr[i + 1] < arr[i]) return false;\n }\n return true;\n}\n\nexport function mergeRefs<T = any>(refs: ForwardedRef<T>[]): 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 (IS_SSR) return false;\n return 'ontouchstart' in window || navigator.maxTouchPoints > 0;\n}\n\nfunction testPlatform(re: RegExp) {\n return typeof window !== 'undefined' && window.navigator != null\n ? re.test(\n // @ts-expect-error\n window.navigator.userAgentData?.platform || window.navigator.platform\n )\n : false;\n}\n\nfunction cached(fn: () => boolean) {\n let res: boolean | null = null;\n return () => {\n if (res == null) {\n res = fn();\n }\n return res;\n };\n}\n\nconst isMac = cached(function () {\n return testPlatform(/^Mac/i);\n});\n\nconst isIPhone = cached(function () {\n return testPlatform(/^iPhone/i);\n});\n\nconst isIPad = cached(function () {\n // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.\n return testPlatform(/^iPad/i) || (isMac() && navigator.maxTouchPoints > 1);\n});\n\nexport const isIOS = cached(function () {\n return isIPhone() || isIPad();\n});\n\n/** Wait for an element to be rendered and visible */\nexport function waitForElement(\n className: string,\n interval = 50,\n maxAttempts = 20\n) {\n return new Promise<HTMLElement | null>((resolve) => {\n let attempts = 0;\n const timer = setInterval(() => {\n const element = document.getElementsByClassName(\n className\n )[0] as HTMLElement;\n attempts++;\n if (element || attempts >= maxAttempts) {\n clearInterval(timer);\n resolve(element);\n }\n }, interval);\n });\n}\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\nexport function 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\nexport function isHTTPS() {\n return typeof window !== 'undefined' && window.isSecureContext;\n}\n","import { type MotionStyle, motion } from 'motion/react';\nimport React, { forwardRef } from 'react';\n\nimport { useSheetContext } from './context';\nimport { styles } from './styles';\nimport { type SheetBackdropProps } from './types';\nimport { applyStyles } from './utils';\n\nconst isClickable = (props: any) => !!props.onClick || !!props.onTap;\n\nexport const SheetBackdrop = forwardRef<any, SheetBackdropProps>(\n ({ style, className = '', unstyled, ...rest }, ref) => {\n const sheetContext = useSheetContext();\n const clickable = isClickable(rest);\n const Comp = clickable ? motion.button : motion.div;\n const pointerEvents = clickable ? 'auto' : 'none';\n const isUnstyled = unstyled ?? sheetContext.unstyled;\n\n const backdropStyle: MotionStyle = {\n ...applyStyles(styles.backdrop, isUnstyled),\n ...style,\n pointerEvents,\n };\n\n const animationProps = sheetContext.prefersReducedMotion\n ? {}\n : {\n initial: { opacity: 0 },\n animate: { opacity: 1 },\n exit: { opacity: 0 },\n transition: { duration: 1 },\n };\n\n return (\n <Comp\n {...animationProps}\n {...(rest as any)}\n ref={ref}\n className={`react-modal-sheet-backdrop ${className}`}\n style={backdropStyle}\n />\n );\n }\n);\n\nSheetBackdrop.displayName = 'SheetBackdrop';\n","import { type MotionStyle, motion } from 'motion/react';\nimport React, { forwardRef } from 'react';\n\nimport { DEFAULT_HEIGHT } from './constants';\nimport { useSheetContext } from './context';\nimport { styles } from './styles';\nimport { type SheetContainerProps } from './types';\nimport { applyStyles, mergeRefs } from './utils';\n\nexport const SheetContainer = forwardRef<any, SheetContainerProps>(\n ({ children, style, className = '', unstyled, ...rest }, ref) => {\n const sheetContext = useSheetContext();\n\n const isUnstyled = unstyled ?? sheetContext.unstyled;\n\n const containerStyle: MotionStyle = {\n ...applyStyles(styles.container, isUnstyled),\n ...style,\n y: sheetContext.y,\n };\n\n if (sheetContext.detent === 'default') {\n containerStyle.height = DEFAULT_HEIGHT;\n }\n\n if (sheetContext.detent === 'full') {\n containerStyle.height = '100%';\n containerStyle.maxHeight = '100%';\n }\n\n if (sheetContext.detent === 'content') {\n containerStyle.height = 'auto';\n containerStyle.maxHeight = DEFAULT_HEIGHT;\n }\n\n return (\n <motion.div\n {...rest}\n ref={mergeRefs([\n ref,\n sheetContext.sheetRef,\n sheetContext.sheetBoundsRef,\n ])}\n className={`react-modal-sheet-container ${className}`}\n style={containerStyle}\n >\n {children}\n </motion.div>\n );\n }\n);\n\nSheetContainer.displayName = 'SheetContainer';\n","import { useCallback, useRef } from 'react';\n\nimport { type BoundingBox } from 'motion/react';\n\n// This is a hacky way to fix a bug in motion/react 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 ref = useRef<any>(null);\n const onMeasure = useCallback(() => constraints, []);\n return { ref, onMeasure };\n}\n","import { useEffect, useLayoutEffect } from 'react';\n\nimport { IS_SSR } from '../constants';\n\nexport const useIsomorphicLayoutEffect = IS_SSR ? useEffect : useLayoutEffect;\n","import { useCallback, useRef } from 'react';\n\nimport { useIsomorphicLayoutEffect } from './use-isomorphic-layout-effect';\n\nexport function useStableCallback<T extends (...args: any[]) => any>(\n handler: T\n) {\n const handlerRef = useRef<T>(undefined);\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","import { useEffect, useMemo, useRef, useState } from 'react';\nimport { useStableCallback } from './use-stable-callback';\n\ntype UseScrollPositionOptions = {\n /**\n * Debounce delay in ms for scroll event handling.\n * @default 32\n */\n debounceDelay?: number;\n /**\n * Enable or disable the hook entirely.\n * @default true\n */\n isEnabled?: boolean;\n};\n\n/**\n * Hook to track the scroll position of an element.\n *\n * The scroll position can be 'top', 'bottom', 'middle', or undefined if the content is not scrollable.\n * The hook provides a `scrollRef` callback to assign to the scrollable element.\n *\n * Note that the scroll position is only updated when the user stops scrolling\n * for a short moment (debounced). You can set `debounceDelay` to `0` to disable debouncing entirely.\n *\n * @param options Configuration options for the hook.\n * @returns An object containing the `scrollRef` callback and the current `scrollPosition`.\n *\n * @example\n * ```tsx\n * import { useScrollPosition } from 'react-modal-sheet';\n *\n * function MyComponent() {\n * const { scrollRef, scrollPosition } = useScrollPosition();\n *\n * return (\n * <div>\n * <p>Scroll position: {scrollPosition}</p>\n * <div ref={scrollRef} style={{ overflowY: 'auto', maxHeight: '300px' }}>\n * ...long content...\n * </div>\n * </div>\n * );\n * }\n * ```\n */\nexport function useScrollPosition(options: UseScrollPositionOptions = {}) {\n const { debounceDelay = 32, isEnabled = true } = options;\n\n const scrollTimeoutRef = useRef<number | null>(null);\n const [element, setElement] = useState<HTMLElement | null>(null);\n const [scrollPosition, setScrollPosition] = useState<\n 'top' | 'bottom' | 'middle' | undefined\n >(undefined);\n\n const scrollRef = useMemo(\n () => (element: HTMLElement | null) => {\n setElement(element);\n },\n []\n );\n\n const determineScrollPosition = useStableCallback((element: HTMLElement) => {\n const { scrollTop, scrollHeight, clientHeight } = element;\n const isScrollable = scrollHeight > clientHeight;\n\n if (!isScrollable) {\n // Reset scroll position if the content is not scrollable anymore\n if (scrollPosition) setScrollPosition(undefined);\n return;\n }\n\n const isAtTop = scrollTop <= 0;\n const isAtBottom =\n Math.ceil(scrollHeight) - Math.ceil(scrollTop) ===\n Math.ceil(clientHeight);\n\n let position: 'top' | 'bottom' | 'middle';\n\n if (isAtTop) {\n position = 'top';\n } else if (isAtBottom) {\n position = 'bottom';\n } else {\n position = 'middle';\n }\n\n // Let browser only handle downward pan gestures (scrolling content up)\n element.style.touchAction = isAtTop ? 'pan-down' : '';\n\n if (position === scrollPosition) return;\n setScrollPosition(position);\n });\n\n const onScroll = useStableCallback((event: Event) => {\n if (event.currentTarget instanceof HTMLElement) {\n const el = event.currentTarget;\n\n if (scrollTimeoutRef.current) clearTimeout(scrollTimeoutRef.current);\n\n if (debounceDelay === 0) {\n determineScrollPosition(el);\n } else {\n // Debounce the scroll handler\n scrollTimeoutRef.current = setTimeout(\n () => determineScrollPosition(el),\n debounceDelay\n );\n }\n }\n });\n\n const onTouchStart = useStableCallback((event: Event) => {\n if (event.currentTarget instanceof HTMLElement) {\n const element = event.currentTarget;\n requestAnimationFrame(() => {\n determineScrollPosition(element);\n });\n }\n });\n\n useEffect(() => {\n if (!element || !isEnabled) return;\n\n // Determine initial scroll position\n determineScrollPosition(element);\n\n element.addEventListener('scroll', onScroll);\n element.addEventListener('touchstart', onTouchStart);\n\n return () => {\n if (scrollTimeoutRef.current) clearTimeout(scrollTimeoutRef.current);\n element.removeEventListener('scroll', onScroll);\n element.removeEventListener('touchstart', onTouchStart);\n };\n }, [element, isEnabled]);\n\n return {\n scrollRef,\n scrollPosition,\n };\n}\n","import { type MotionStyle, motion } from 'motion/react';\nimport React, { forwardRef } from 'react';\n\nimport { useSheetContext } from './context';\nimport { useDragConstraints } from './hooks/use-drag-constraints';\nimport { useScrollPosition } from './hooks/use-scroll-position';\nimport { styles } from './styles';\nimport { type SheetContentProps } from './types';\nimport { applyStyles, isHTTPS, mergeRefs } from './utils';\n\nexport const SheetContent = forwardRef<any, SheetContentProps>(\n (\n {\n disableScroll: disableScrollProp,\n disableDrag: disableDragProp,\n children,\n style: styleProp,\n className = '',\n scrollClassName = '',\n scrollStyle: scrollStyleProp,\n scrollRef: scrollRefProp = null,\n unstyled,\n ...rest\n },\n ref\n ) => {\n const sheetContext = useSheetContext();\n const dragConstraints = useDragConstraints();\n\n const scroll = useScrollPosition({\n isEnabled:\n typeof disableScrollProp === 'function' ? true : !disableScrollProp,\n });\n\n const disableScroll =\n typeof disableScrollProp === 'function'\n ? disableScrollProp({\n scrollPosition: scroll.scrollPosition,\n currentSnap: sheetContext.currentSnap,\n })\n : Boolean(disableScrollProp);\n\n const disableDragDueToScroll =\n !disableScroll &&\n scroll.scrollPosition &&\n scroll.scrollPosition !== 'top';\n\n const disableDragDueToProp =\n typeof disableDragProp === 'function'\n ? disableDragProp({\n scrollPosition: scroll.scrollPosition,\n currentSnap: sheetContext.currentSnap,\n })\n : Boolean(disableDragProp);\n\n const disableDrag =\n disableDragDueToProp ||\n disableDragDueToScroll ||\n sheetContext.disableDrag;\n\n const dragProps =\n disableDrag || sheetContext.disableDrag\n ? undefined\n : sheetContext.dragProps;\n\n const isUnstyled = unstyled ?? sheetContext.unstyled;\n\n const contentStyle: MotionStyle = {\n ...applyStyles(styles.content, isUnstyled),\n ...styleProp,\n };\n\n const scrollStyle: MotionStyle = applyStyles(styles.scroller, isUnstyled);\n\n if (sheetContext.avoidKeyboard) {\n /**\n * Virtual Keyboard API is only available in secure context (https)\n * and it will have 0px height in insecure context,\n * which causes issues when developing and testing on localhost (http).\n */\n scrollStyle.paddingBottom = isHTTPS()\n ? 'env(keyboard-inset-height, var(--keyboard-inset-height, 0px))'\n : 'var(--keyboard-inset-height, 0px)';\n }\n\n if (disableScroll) {\n scrollStyle.overflowY = 'hidden';\n }\n\n if (dragProps !== undefined) {\n // Let browser only handle downward pan gestures (scrolling content up)\n scrollStyle.touchAction = 'pan-down';\n }\n\n return (\n <motion.div\n {...rest}\n ref={mergeRefs([ref, dragConstraints.ref])}\n className={`react-modal-sheet-content ${className}`}\n style={contentStyle}\n {...dragProps}\n dragConstraints={dragConstraints.ref}\n onMeasureDragConstraints={dragConstraints.onMeasure}\n >\n <motion.div\n ref={mergeRefs([scroll.scrollRef, scrollRefProp])}\n style={{ ...scrollStyle, ...scrollStyleProp }}\n className={`react-modal-sheet-content-scroller ${scrollClassName}`}\n >\n {children}\n </motion.div>\n </motion.div>\n );\n }\n);\n\nSheetContent.displayName = 'SheetContent';\n","import { motion, useTransform } from 'motion/react';\nimport React from 'react';\n\nimport { useSheetContext } from './context';\nimport { styles } from './styles';\nimport type { SheetDragIndicatorProps } from './types';\nimport { applyStyles } from './utils';\n\nexport function SheetDragIndicator({\n style,\n className = '',\n unstyled,\n ...rest\n}: SheetDragIndicatorProps) {\n const sheetContext = useSheetContext();\n\n const indicator1Transform = useTransform(\n sheetContext.indicatorRotation,\n (r) => `translateX(2px) rotate(${r}deg)`\n );\n\n const indicator2Transform = useTransform(\n sheetContext.indicatorRotation,\n (r) => `translateX(-2px) rotate(${-1 * r}deg)`\n );\n\n const isUnstyled = unstyled ?? sheetContext.unstyled;\n\n const indicatorWrapperStyle = {\n ...applyStyles(styles.indicatorWrapper, isUnstyled),\n ...style,\n };\n\n const indicatorStyle = applyStyles(styles.indicator, isUnstyled);\n\n return (\n <div\n className={`react-modal-sheet-drag-indicator-container ${className}`}\n style={indicatorWrapperStyle}\n {...rest}\n >\n <motion.span\n className=\"react-modal-sheet-drag-indicator\"\n style={{ ...indicatorStyle, transform: indicator1Transform }}\n />\n <motion.span\n className=\"react-modal-sheet-drag-indicator\"\n style={{ ...indicatorStyle, transform: indicator2Transform }}\n />\n </div>\n );\n}\n","import { motion } from 'motion/react';\nimport React, { forwardRef } from 'react';\n\nimport { useSheetContext } from './context';\nimport { useDragConstraints } from './hooks/use-drag-constraints';\nimport { SheetDragIndicator } from './SheetDragIndicator';\nimport { styles } from './styles';\nimport { type SheetHeaderProps } from './types';\nimport { applyStyles, mergeRefs } from './utils';\n\nexport const SheetHeader = forwardRef<any, SheetHeaderProps>(\n (\n { children, style, disableDrag, unstyled, className = '', ...rest },\n ref\n ) => {\n const sheetContext = useSheetContext();\n const dragConstraints = useDragConstraints();\n const dragProps =\n disableDrag || sheetContext.disableDrag\n ? undefined\n : sheetContext.dragProps;\n\n const isUnstyled = unstyled ?? sheetContext.unstyled;\n\n const headerWrapperStyle = {\n ...applyStyles(styles.headerWrapper, isUnstyled),\n ...style,\n };\n\n const headerStyle = applyStyles(styles.header, isUnstyled);\n\n return (\n <motion.div\n {...rest}\n ref={mergeRefs([ref, dragConstraints.ref])}\n style={headerWrapperStyle}\n className={`react-modal-sheet-header-container ${className}`}\n {...dragProps}\n dragConstraints={dragConstraints.ref}\n onMeasureDragConstraints={dragConstraints.onMeasure}\n >\n {children || (\n <div className=\"react-modal-sheet-header\" style={headerStyle}>\n <SheetDragIndicator />\n </div>\n )}\n </motion.div>\n );\n }\n);\n\nSheetHeader.displayName = 'SheetHeader';\n","import { useState } from 'react';\n\nimport { IS_SSR } from '../constants';\nimport { useIsomorphicLayoutEffect } from './use-isomorphic-layout-effect';\n\nexport function useDimensions() {\n const [dimensions, setDimensions] = useState(() => ({\n windowHeight: !IS_SSR ? window.innerHeight : 0,\n windowWidth: !IS_SSR ? window.innerWidth : 0,\n }));\n\n useIsomorphicLayoutEffect(() => {\n function handler() {\n setDimensions({\n windowHeight: window.innerHeight,\n windowWidth: 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","import { type RefObject, useEffect, useRef, useState } from 'react';\nimport { isHTTPS, willOpenKeyboard } from '../utils';\n\ntype VirtualKeyboardApi = {\n overlaysContent: boolean;\n boundingRect: {\n x: number;\n y: number;\n height: number;\n width: number;\n };\n addEventListener: (\n type: 'geometrychange',\n listener: EventListenerOrEventListenerObject\n ) => void;\n removeEventListener: (\n type: 'geometrychange',\n listener: EventListenerOrEventListenerObject\n ) => void;\n};\n\ntype VirtualKeyboardState = {\n isVisible: boolean;\n height: number;\n};\n\n/**\n * Keep track of how many components are using the virtual keyboard API\n * to avoid conflicts when toggling `overlaysContent` which is a global setting.\n */\nlet virtualKeyboardOverlayUsers = 0;\nlet initialVirtualKeyboardOverlaysContent: boolean | null = null;\n\ntype UseVirtualKeyboardOptions = {\n /**\n * Ref to the container element to apply `keyboard-inset-height` CSS variable updates.\n * @default document.documentElement\n */\n containerRef?: RefObject<HTMLElement | null>;\n /**\n * Enable or disable the hook entirely.\n * @default true\n */\n isEnabled?: boolean;\n /**\n * Minimum pixel height difference to consider the keyboard visible.\n * @default 100\n */\n visualViewportThreshold?: number;\n /**\n * Delay in ms for debouncing viewport changes.\n * @default 100\n */\n debounceDelay?: number;\n};\n\n/**\n * A hook that detects virtual keyboard visibility and height.\n * It listens to focus events and visual viewport changes to determine\n * if a text input is focused and the keyboard is likely visible.\n *\n * It also sets the `--keyboard-inset-height` CSS variable on the specified container\n * (or `:root` by default) to allow for easy styling adjustments when the keyboard is open.\n *\n * @param options Configuration options for the hook.\n * @returns An object containing `isKeyboardOpen` and `keyboardHeight`.\n *\n * @example\n * ```tsx\n * import { useVirtualKeyboard } from 'react-modal-sheet';\n *\n * function MyComponent() {\n * const { isKeyboardOpen, keyboardHeight } = useVirtualKeyboard();\n *\n * return (\n * <div>\n * <p>Keyboard is {isKeyboardOpen ? 'open' : 'closed'}</p>\n * <p>Keyboard height: {keyboardHeight}px</p>\n * </div>\n * );\n * }\n * ```\n */\nexport function useVirtualKeyboard(options: UseVirtualKeyboardOptions = {}) {\n const {\n containerRef,\n isEnabled = true,\n debounceDelay = 100,\n visualViewportThreshold = 100,\n } = options;\n\n const [state, setState] = useState<VirtualKeyboardState>({\n isVisible: false,\n height: 0,\n });\n\n const focusedElementRef = useRef<HTMLElement | null>(null);\n const debounceTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(() => {\n const vv = window.visualViewport;\n const vk = getVirtualKeyboardApi();\n\n function setKeyboardInsetHeightEnv(height: number) {\n const element = containerRef?.current || document.documentElement;\n\n if (vk) {\n element.style.setProperty(\n '--keyboard-inset-height',\n `env(keyboard-inset-height, ${height}px)`\n );\n } else {\n element.style.setProperty('--keyboard-inset-height', `${height}px`);\n }\n }\n\n function setKeyboardState(nextState: VirtualKeyboardState) {\n setState((prevState) =>\n prevState.isVisible === nextState.isVisible &&\n prevState.height === nextState.height\n ? prevState\n : nextState\n );\n }\n\n function resetKeyboardState() {\n focusedElementRef.current = null;\n setKeyboardInsetHeightEnv(0);\n setKeyboardState({ isVisible: false, height: 0 });\n }\n\n if (!isEnabled) {\n resetKeyboardState();\n return;\n }\n\n function updateKeyboardState() {\n if (debounceTimer.current) {\n clearTimeout(debounceTimer.current);\n }\n\n debounceTimer.current = setTimeout(() => {\n const active = getActiveElement() ?? focusedElementRef.current;\n const inputIsFocused = active ? willOpenKeyboard(active) : false;\n\n if (!inputIsFocused) {\n resetKeyboardState();\n return;\n }\n\n focusedElementRef.current = active as HTMLElement;\n\n if (vk?.overlaysContent) {\n const keyboardHeight = vk.boundingRect.height;\n setKeyboardInsetHeightEnv(keyboardHeight);\n setKeyboardState({ isVisible: true, height: keyboardHeight });\n return;\n }\n\n if (vv) {\n const heightDiff = window.innerHeight - vv.height;\n\n if (heightDiff > visualViewportThreshold) {\n setKeyboardInsetHeightEnv(heightDiff);\n setKeyboardState({ isVisible: true, height: heightDiff });\n return;\n }\n }\n\n resetKeyboardState();\n }, debounceDelay);\n }\n\n function handleFocusIn(e: FocusEvent) {\n if (e.target instanceof HTMLElement && willOpenKeyboard(e.target)) {\n focusedElementRef.current = e.target;\n updateKeyboardState();\n }\n }\n\n function handleFocusOut() {\n requestAnimationFrame(() => {\n focusedElementRef.current = getActiveElement();\n updateKeyboardState();\n });\n }\n\n document.addEventListener('focusin', handleFocusIn);\n document.addEventListener('focusout', handleFocusOut);\n\n if (vv) {\n vv.addEventListener('resize', updateKeyboardState);\n vv.addEventListener('scroll', updateKeyboardState);\n }\n\n if (vk) {\n if (virtualKeyboardOverlayUsers === 0) {\n initialVirtualKeyboardOverlaysContent = vk.overlaysContent;\n vk.overlaysContent = true;\n }\n\n virtualKeyboardOverlayUsers++;\n vk.addEventListener('geometrychange', updateKeyboardState);\n }\n\n focusedElementRef.current = getActiveElement();\n updateKeyboardState();\n\n return () => {\n document.removeEventListener('focusin', handleFocusIn);\n document.removeEventListener('focusout', handleFocusOut);\n\n if (vv) {\n vv.removeEventListener('resize', updateKeyboardState);\n vv.removeEventListener('scroll', updateKeyboardState);\n }\n\n if (vk) {\n vk.removeEventListener('geometrychange', updateKeyboardState);\n\n virtualKeyboardOverlayUsers = Math.max(\n 0,\n virtualKeyboardOverlayUsers - 1\n );\n\n if (virtualKeyboardOverlayUsers === 0) {\n vk.overlaysContent = initialVirtualKeyboardOverlaysContent ?? false;\n initialVirtualKeyboardOverlaysContent = null;\n }\n }\n\n if (debounceTimer.current) {\n clearTimeout(debounceTimer.current);\n }\n\n resetKeyboardState();\n };\n }, [debounceDelay, isEnabled, visualViewportThreshold]);\n\n return {\n keyboardHeight: state.height,\n isKeyboardOpen: state.isVisible,\n };\n}\n\n/**\n * Virtual Keyboard API is only available in secure contexts (HTTPS)\n * and may not be supported in all browsers.\n */\nfunction getVirtualKeyboardApi() {\n return isHTTPS() && 'virtualKeyboard' in navigator\n ? (navigator.virtualKeyboard as VirtualKeyboardApi)\n : null;\n}\n\nfunction getActiveElement() {\n let activeElement: Element | null = document.activeElement;\n\n while (\n activeElement instanceof HTMLElement &&\n activeElement.shadowRoot?.activeElement\n ) {\n activeElement = activeElement.shadowRoot.activeElement;\n }\n\n return activeElement && willOpenKeyboard(activeElement)\n ? (activeElement as HTMLElement)\n : null;\n}\n","import { type RefObject, useEffect, useState } from 'react';\n\nimport { willOpenKeyboard } from '../utils';\nimport { useStableCallback } from './use-stable-callback';\nimport { useVirtualKeyboard } from './use-virtual-keyboard';\n\nexport function useKeyboardAvoidance({\n isEnabled,\n containerRef,\n onWillOpenKeyboard,\n onDidOpenKeyboard,\n}: {\n isEnabled: boolean;\n containerRef: RefObject<HTMLDivElement | null>;\n onWillOpenKeyboard?: (event: FocusEvent) => Promise<void>;\n onDidOpenKeyboard?: (focusedElement: HTMLElement) => void;\n}) {\n const [focusedElement, setFocusedElement] = useState<HTMLElement | null>(\n null\n );\n\n const keyboard = useVirtualKeyboard({\n isEnabled,\n containerRef,\n });\n\n const handleFocusIn = useStableCallback(async (event: FocusEvent) => {\n const element = event.target as HTMLElement;\n\n if (willOpenKeyboard(element) && containerRef.current?.contains(element)) {\n await onWillOpenKeyboard?.(event);\n setFocusedElement(element);\n }\n });\n\n const handleFocusOut = useStableCallback((event: FocusEvent) => {\n const element = event.target as HTMLElement;\n\n if (focusedElement === element) {\n setFocusedElement(null);\n }\n });\n\n // Keep track of the currently focused input within the container\n useEffect(() => {\n if (!isEnabled) return;\n\n document.addEventListener('focusin', handleFocusIn);\n document.addEventListener('focusout', handleFocusOut);\n\n return () => {\n document.removeEventListener('focusin', handleFocusIn);\n document.removeEventListener('focusout', handleFocusOut);\n };\n }, [isEnabled]);\n\n useEffect(() => {\n const containerElement = containerRef.current;\n\n if (\n !isEnabled ||\n !focusedElement ||\n !containerElement ||\n !keyboard.isKeyboardOpen\n ) {\n return;\n }\n\n requestAnimationFrame(() => {\n onDidOpenKeyboard?.(focusedElement);\n });\n }, [isEnabled, keyboard.isKeyboardOpen, focusedElement]);\n\n return keyboard;\n}\n","import { useState } from 'react';\n\nimport { IS_SSR } from '../constants';\n\nexport function useSafeAreaInsets() {\n const [insets] = useState(() => {\n const fallback = { top: 0, left: 0, right: 0, bottom: 0 };\n\n if (IS_SSR) return fallback;\n\n const root = document.querySelector<HTMLElement>(':root');\n\n if (!root) return fallback;\n\n root.style.setProperty('--rms-sat', 'env(safe-area-inset-top)');\n root.style.setProperty('--rms-sal', 'env(safe-area-inset-left)');\n root.style.setProperty('--rms-sar', 'env(safe-area-inset-right)');\n root.style.setProperty('--rms-sab', 'env(safe-area-inset-bottom)');\n\n const computedStyle = getComputedStyle(root);\n const sat = getComputedValue(computedStyle, '--rms-sat');\n const sal = getComputedValue(computedStyle, '--rms-sal');\n const sar = getComputedValue(computedStyle, '--rms-sar');\n const sab = getComputedValue(computedStyle, '--rms-sab');\n\n root.style.removeProperty('--rms-sat');\n root.style.removeProperty('--rms-sal');\n root.style.removeProperty('--rms-sar');\n root.style.removeProperty('--rms-sab');\n\n return { top: sat, left: sal, right: sar, bottom: sab };\n });\n\n return insets;\n}\n\nfunction getComputedValue(computed: CSSStyleDeclaration, property: string) {\n const strValue = computed.getPropertyValue(property).replace('px', '').trim();\n return parseInt(strValue, 10) || 0;\n}\n","import { type MotionValue, transform } from 'motion';\nimport { type RefObject } from 'react';\n\nimport type { SheetDetent, SheetSnapPoint } from '../types';\nimport { useIsomorphicLayoutEffect } from './use-isomorphic-layout-effect';\nimport { useSafeAreaInsets } from './use-safe-area-insets';\n\nexport function useModalEffect({\n y,\n detent,\n rootId: _rootId,\n sheetHeight,\n snapPoints,\n startThreshold,\n}: {\n y: MotionValue<number>;\n detent: SheetDetent;\n rootId?: string;\n sheetHeight: number;\n snapPoints: SheetSnapPoint[];\n startThreshold?: number;\n}) {\n const insetTop = useSafeAreaInsets().top;\n\n let rootId: string | undefined = _rootId;\n\n if (rootId && detent === 'full') {\n console.warn('Using \"full\" detent with modal effect is not supported.');\n rootId = undefined;\n }\n\n // Cleanup on unmount\n useIsomorphicLayoutEffect(() => {\n return () => {\n if (rootId) cleanupModalEffect(rootId);\n };\n }, []);\n\n useIsomorphicLayoutEffect(() => {\n if (!rootId) return;\n\n const root = document.querySelector(`#${rootId}`) as HTMLDivElement;\n if (!root) return;\n\n const removeStartListener = y.on('animationStart', () => {\n // biome-ignore lint/style/noNonNullAssertion: root is always defined here\n setupModalEffect(rootId!);\n });\n\n /**\n * NOTE: The `y` value gets smaller when the sheet is opened and larger\n * when the sheet is being closed.\n */\n const removeChangeListener = y.on('change', (yValue) => {\n if (!root) return;\n\n let progress = Math.max(0, 1 - yValue / sheetHeight);\n\n /**\n * Start the effect only if we have dragged over the second snap point\n * to make the effect more natural as the sheet will reach it's final\n * position when the user drags it over the second snap point.\n */\n const snapThresholdPoint =\n snapPoints.length > 1 ? snapPoints[snapPoints.length - 2] : undefined;\n\n /**\n * If we have snap points, we need to calculate the progress percentage\n * based on the snap point threshold. Note that the maximum value is also\n * different in this case as the range between the start of the effect\n * and its end is different.\n */\n if (snapThresholdPoint !== undefined) {\n const snapThresholdValue = snapThresholdPoint.snapValueY;\n\n if (yValue <= snapThresholdValue) {\n progress = (snapThresholdValue - yValue) / snapThresholdValue;\n } else {\n progress = 0;\n }\n }\n\n /**\n * If we have a start threshold, we need to calculate the progress\n * percentage based on the start threshold (0 to 1). For example,\n * if the start threshold is 0.5, the progress will be 0 until the sheet\n * is dragged over 50% of the complete drag distance.\n */\n if (startThreshold !== undefined) {\n const startThresholdValue =\n sheetHeight -\n Math.min(Math.floor(startThreshold * sheetHeight), sheetHeight);\n\n if (yValue <= startThresholdValue) {\n progress = (startThresholdValue - yValue) / startThresholdValue;\n } else {\n progress = 0;\n }\n }\n\n // Make sure progress is between 0 and 1\n progress = Math.max(0, Math.min(1, progress));\n\n const pageWidth = window.innerWidth;\n const ty = transform(progress, [0, 1], [0, 24 + insetTop]);\n const s = transform(progress, [0, 1], [1, (pageWidth - 16) / pageWidth]);\n const borderRadius = transform(progress, [0, 1], [0, 10]);\n\n root.style.transform = `scale(${s}) translate3d(0, ${ty}px, 0)`;\n root.style.borderTopRightRadius = `${borderRadius}px`;\n root.style.borderTopLeftRadius = `${borderRadius}px`;\n });\n\n function onCompleted() {\n // -5 just to take into account some inprecision to ensure the cleanup is done\n if (y.get() - 5 >= sheetHeight) {\n // biome-ignore lint/style/noNonNullAssertion: root is always defined here\n cleanupModalEffect(rootId!);\n }\n }\n\n const removeCompleteListener = y.on('animationComplete', onCompleted);\n const removeCancelListener = y.on('animationCancel', onCompleted);\n\n return () => {\n removeStartListener();\n removeChangeListener();\n removeCompleteListener();\n removeCancelListener();\n };\n }, [y, rootId, insetTop, startThreshold, sheetHeight]);\n}\n\nfunction setupModalEffect(rootId: string) {\n const root = document.querySelector(`#${rootId}`) as HTMLDivElement;\n const body = document.querySelector('body') as HTMLBodyElement;\n if (!root) return;\n\n body.style.backgroundColor = '#000';\n root.style.overflow = 'hidden';\n root.style.transitionTimingFunction = 'cubic-bezier(0.32, 0.72, 0, 1)';\n root.style.transitionProperty = 'transform, border-radius';\n root.style.transitionDuration = '0.5s';\n root.style.transformOrigin = 'center top';\n}\n\nfunction cleanupModalEffect(rootId: string) {\n const root = document.querySelector(`#${rootId}`) as HTMLDivElement;\n const body = document.querySelector('body') as HTMLBodyElement;\n if (!root) return;\n\n body.style.removeProperty('background-color');\n root.style.removeProperty('overflow');\n root.style.removeProperty('transition-timing-function');\n root.style.removeProperty('transition-property');\n root.style.removeProperty('transition-duration');\n root.style.removeProperty('transform-origin');\n root.style.removeProperty('transform');\n root.style.removeProperty('border-top-right-radius');\n root.style.removeProperty('border-top-left-radius');\n}\n","// This code originates from https://github.com/adobe/react-spectrum/blob/main/packages/%40react-aria/overlays/src/usePreventScroll.ts\n\nimport { isIOS, willOpenKeyboard } from '../utils';\nimport { useIsomorphicLayoutEffect } from './use-isomorphic-layout-effect';\n\nconst KEYBOARD_BUFFER = 24;\n\ninterface PreventScrollOptions {\n /** Whether the scroll lock is disabled. */\n isDisabled?: boolean;\n}\n\nfunction chain(...callbacks: any[]): (...args: any[]) => void {\n return (...args: any[]) => {\n for (const callback of callbacks) {\n if (typeof callback === 'function') {\n callback(...args);\n }\n }\n };\n}\n\nconst visualViewport = typeof document !== 'undefined' && window.visualViewport;\n\nexport function isScrollable(\n node: Element | null,\n checkForOverflow?: boolean\n): boolean {\n if (!node) {\n return false;\n }\n\n const style = window.getComputedStyle(node);\n\n let scrollable = /(auto|scroll)/.test(\n style.overflow + style.overflowX + style.overflowY\n );\n\n if (scrollable && checkForOverflow) {\n scrollable =\n node.scrollHeight !== node.clientHeight ||\n node.scrollWidth !== node.clientWidth;\n }\n\n return scrollable;\n}\n\nexport function getScrollParent(\n node: Element,\n checkForOverflow?: boolean\n): Element {\n let scrollableNode: Element | null = node;\n\n if (isScrollable(scrollableNode, checkForOverflow)) {\n scrollableNode = scrollableNode.parentElement;\n }\n\n while (scrollableNode && !isScrollable(scrollableNode, checkForOverflow)) {\n scrollableNode = scrollableNode.parentElement;\n }\n\n return (\n scrollableNode || document.scrollingElement || document.documentElement\n );\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: () => void;\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 useIsomorphicLayoutEffect(() => {\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 // Use `composedPath` to support shadow DOM.\n const target = e.composedPath()?.[0] as HTMLElement;\n\n // Store the nearest scrollable parent element from the element that the user touched.\n scrollable = getScrollParent(target, true);\n\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 ||\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 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 // Use `composedPath` to support shadow DOM.\n const target = e.composedPath()?.[0] 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 // Use `composedPath` to support shadow DOM.\n const target = e.composedPath()?.[0] as HTMLElement;\n\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 () => scrollIntoView(target),\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 // This produces a flicker on Safari iOS, so we skip the `marginTop` and this altogether for now.\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 // https://github.com/microsoft/TypeScript/issues/17827#issuecomment-391663310\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 // @ts-expect-error\n target.addEventListener(event, handler, options);\n\n return () => {\n // @ts-expect-error\n target.removeEventListener(event, handler, 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 const targetBottom = target.getBoundingClientRect().bottom;\n // Buffer is needed for some edge cases\n const keyboardHeight =\n scrollable.getBoundingClientRect().bottom + KEYBOARD_BUFFER;\n\n if (targetBottom > keyboardHeight) {\n scrollable.scrollTop += targetTop - scrollableTop;\n }\n }\n\n // @ts-expect-error\n target = scrollable.parentElement;\n }\n}\n","import { useEffect, useState } from 'react';\nimport { useStableCallback } from './use-stable-callback';\n\ntype SheetState = 'closed' | 'opening' | 'open' | 'closing';\n\ntype UseSheetStatesProps = {\n isOpen: boolean;\n onClosed?: () => Promise<void> | void;\n onOpening?: () => Promise<void> | void;\n onOpen?: () => Promise<void> | void;\n onClosing?: () => Promise<void> | void;\n};\n\nexport function useSheetState({\n isOpen,\n onClosed: _onClosed,\n onOpening: _onOpening,\n onOpen: _onOpen,\n onClosing: _onClosing,\n}: UseSheetStatesProps) {\n const [state, setState] = useState<SheetState>(isOpen ? 'opening' : 'closed');\n const onClosed = useStableCallback(() => _onClosed?.());\n const onOpening = useStableCallback(() => _onOpening?.());\n const onOpen = useStableCallback(() => _onOpen?.());\n const onClosing = useStableCallback(() => _onClosing?.());\n\n useEffect(() => {\n if (isOpen && state === 'closed') {\n setState('opening');\n } else if (!isOpen && (state === 'open' || state === 'opening')) {\n setState('closing');\n }\n }, [isOpen, state]);\n\n useEffect(() => {\n async function handle() {\n switch (state) {\n case 'closed':\n await onClosed?.();\n break;\n\n case 'opening':\n await onOpening?.();\n setState('open');\n break;\n\n case 'open':\n await onOpen?.();\n break;\n\n case 'closing':\n await onClosing?.();\n setState('closed');\n break;\n }\n }\n handle().catch((error) => {\n console.error('Internal sheet state error:', error);\n });\n }, [state]);\n\n return state;\n}\n","import type { SheetSnapPoint } from './types';\nimport { isAscendingOrder } from './utils';\n\n/**\n * Convert negative / percentage snap points to absolute values\n *\n * Example output:\n *\n * ```json\n * [\n * {\n * \"snapIndex\": 0, // <-- bottom snap point\n * \"snapValue\": 0,\n * \"snapValueY\": 810\n * },\n * {\n * \"snapIndex\": 1,\n * \"snapValue\": 170,\n * \"snapValueY\": 640\n * },\n * {\n * \"snapIndex\": 2,\n * \"snapValue\": 405,\n * \"snapValueY\": 405\n * },\n * {\n * \"snapIndex\": 3,\n * \"snapValue\": 760,\n * \"snapValueY\": 50\n * },\n * {\n * \"snapIndex\": 4, // <-- top snap point\n * \"snapValue\": 810,\n * \"snapValueY\": 0\n * }\n * ]\n * ```\n */\nexport function computeSnapPoints({\n snapPointsProp,\n sheetHeight,\n}: {\n snapPointsProp: number[];\n sheetHeight: number;\n}): SheetSnapPoint[] {\n if (snapPointsProp[0] !== 0) {\n console.error(\n 'First snap point should be 0 to ensure the sheet can be fully closed. ' +\n `Got: [${snapPointsProp.join(', ')}]`\n );\n snapPointsProp.unshift(0);\n }\n\n if (snapPointsProp[snapPointsProp.length - 1] !== 1) {\n console.error(\n 'Last snap point should be 1 to ensure the sheet can be fully opened. ' +\n `Got: [${snapPointsProp.join(', ')}]`\n );\n snapPointsProp.push(1);\n }\n\n if (sheetHeight <= 0) {\n console.error(\n `Sheet height is ${sheetHeight}, cannot compute snap points. ` +\n 'Make sure the sheet is mounted and has a valid height.'\n );\n return [];\n }\n\n const snapPointValues = snapPointsProp.map((point) => {\n // Percentage values e.g. between 0.0 and 1.0\n if (point > 0 && point <= 1) {\n return Math.round(point * sheetHeight);\n }\n\n return point < 0 ? sheetHeight + point : point; // negative values\n });\n\n console.assert(\n isAscendingOrder(snapPointValues),\n `Snap points need to be in ascending order got: [${snapPointsProp.join(', ')}]`\n );\n\n // Make sure all snap points are within the sheet height\n snapPointValues.forEach((snap) => {\n if (snap < 0 || snap > sheetHeight) {\n console.warn(\n `Snap point ${snap} is outside of the sheet height ${sheetHeight}. ` +\n 'This can cause unexpected behavior. Consider adjusting your snap points.'\n );\n }\n });\n\n if (!snapPointValues.includes(sheetHeight)) {\n console.warn(\n 'Snap points do not include the sheet height.' +\n 'Please include `1` as the last snap point or it will be included automatically.' +\n 'This is to ensure the sheet can be fully opened.'\n );\n snapPointValues.push(sheetHeight);\n }\n\n return snapPointValues.map((snap, index) => ({\n snapIndex: index,\n snapValue: snap, // Absolute value from the bottom of the sheet\n snapValueY: sheetHeight - snap, // Y value is inverted as `y = 0` means sheet is at the top\n }));\n}\n\nfunction findClosestSnapPoint({\n snapPoints,\n currentY,\n}: {\n snapPoints: SheetSnapPoint[];\n currentY: number;\n}) {\n return snapPoints.reduce((closest, snap) =>\n Math.abs(snap.snapValueY - currentY) <\n Math.abs(closest.snapValueY - currentY)\n ? snap\n : closest\n );\n}\n\nfunction findNextSnapPointInDirection({\n y,\n snapPoints,\n dragDirection,\n}: {\n y: number;\n snapPoints: SheetSnapPoint[];\n dragDirection: 'up' | 'down';\n}) {\n // NOTE: lower Y means higher in the sheet position!\n if (dragDirection === 'down') {\n /**\n * Example:\n *\n * [\n * { snapIndex: 0, snapValueY: 810 },\n * { snapIndex: 1, snapValueY: 640 },\n * { snapIndex: 2, snapValueY: 405 }, <-- next down\n * ------------- Y = 60 ------------\n * { snapIndex: 3, snapValueY: 50 },\n * { snapIndex: 4, snapValueY: 0 },\n * ]\n */\n return snapPoints\n .slice()\n .reverse()\n .find((s) => s.snapValueY > y);\n } else {\n /**\n * Example:\n * [\n * { snapIndex: 0, snapValueY: 810 },\n * { snapIndex: 1, snapValueY: 640 },\n * { snapIndex: 2, snapValueY: 405 },\n * ------------- Y = 60 ------------\n * { snapIndex: 3, snapValueY: 50 }, <-- next up\n * { snapIndex: 4, snapValueY: 0 },\n * ]\n */\n return snapPoints.find((s) => s.snapValueY < y);\n }\n}\nexport function handleHighVelocityDrag({\n dragDirection,\n snapPoints,\n}: {\n dragDirection: 'up' | 'down';\n snapPoints: SheetSnapPoint[];\n}) {\n // Go to either the last or the first snap point depending on the direction\n const bottomSnapPoint = snapPoints[0];\n const topSnapPoint = snapPoints[snapPoints.length - 1];\n\n if (dragDirection === 'down') {\n return {\n yTo: bottomSnapPoint.snapValueY,\n snapIndex: bottomSnapPoint.snapIndex,\n };\n }\n return {\n yTo: topSnapPoint.snapValueY,\n snapIndex: topSnapPoint.snapIndex,\n };\n}\n\nexport function handleLowVelocityDrag({\n currentSnapPoint,\n currentY,\n dragDirection,\n snapPoints,\n velocity,\n}: {\n currentSnapPoint: SheetSnapPoint;\n currentY: number;\n dragDirection: 'up' | 'down';\n snapPoints: SheetSnapPoint[];\n velocity: number;\n}) {\n const closestSnapRelativeToCurrentY = findClosestSnapPoint({\n snapPoints,\n currentY,\n });\n\n /**\n * If velocity is very low the user has stopped the sheet to a specific\n * position and we should snap to the closest snap point as there is no\n * \"momentum\" that would push the sheet further to the given direction\n */\n if (Math.abs(velocity) < 20) {\n return {\n yTo: closestSnapRelativeToCurrentY.snapValueY,\n snapIndex: closestSnapRelativeToCurrentY.snapIndex,\n };\n }\n\n /**\n * If the dragging has a bit more velocity, we instead want to go to\n * the next snap point in the given direction if it exists\n */\n const nextSnapInDirectionRelativeToCurrentY = findNextSnapPointInDirection({\n y: currentY,\n snapPoints,\n dragDirection,\n });\n\n if (nextSnapInDirectionRelativeToCurrentY) {\n return {\n yTo: nextSnapInDirectionRelativeToCurrentY.snapValueY,\n snapIndex: nextSnapInDirectionRelativeToCurrentY.snapIndex,\n };\n }\n\n // No snap point down, stay at current\n return {\n yTo: currentSnapPoint.snapValueY,\n snapIndex: currentSnapPoint.snapIndex,\n };\n}\n","import {\n animate,\n type DragHandler,\n motion,\n type Transition,\n useMotionValue,\n useReducedMotion,\n useTransform,\n} from 'motion/react';\nimport React, {\n forwardRef,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport useMeasure from 'react-use-measure';\n\nimport {\n DEFAULT_DRAG_CLOSE_THRESHOLD,\n DEFAULT_DRAG_VELOCITY_THRESHOLD,\n DEFAULT_TWEEN_CONFIG,\n IS_SSR,\n REDUCED_MOTION_TWEEN_CONFIG,\n} from './constants';\nimport { SheetContext } from './context';\nimport { useDimensions } from './hooks/use-dimensions';\nimport { useKeyboardAvoidance } from './hooks/use-keyboard-avoidance';\nimport { useModalEffect } from './hooks/use-modal-effect';\nimport { usePreventScroll } from './hooks/use-prevent-scroll';\nimport { useSheetState } from './hooks/use-sheet-state';\nimport { useStableCallback } from './hooks/use-stable-callback';\nimport {\n computeSnapPoints,\n handleHighVelocityDrag,\n handleLowVelocityDrag,\n} from './snap';\nimport { styles } from './styles';\nimport { type SheetContextType, type SheetProps } from './types';\nimport { applyStyles, waitForElement, willOpenKeyboard } from './utils';\n\nexport const Sheet = forwardRef<any, SheetProps>(\n (\n {\n avoidKeyboard = true,\n children,\n className = '',\n detent = 'default',\n disableDismiss = false,\n disableDrag: disableDragProp = false,\n disableScrollLocking = false,\n dragCloseThreshold = DEFAULT_DRAG_CLOSE_THRESHOLD,\n dragVelocityThreshold = DEFAULT_DRAG_VELOCITY_THRESHOLD,\n initialSnap,\n isOpen,\n modalEffectRootId,\n modalEffectThreshold,\n mountPoint,\n prefersReducedMotion = false,\n snapPoints: snapPointsProp,\n style,\n tweenConfig = DEFAULT_TWEEN_CONFIG,\n unstyled = false,\n onOpenStart,\n onOpenEnd,\n onClose,\n onCloseStart,\n onCloseEnd,\n onSnap,\n onDrag: onDragProp,\n onDragStart: onDragStartProp,\n onDragEnd: onDragEndProp,\n ...rest\n },\n ref\n ) => {\n const [sheetBoundsRef, sheetBounds] = useMeasure();\n const sheetRef = useRef<HTMLDivElement>(null);\n const sheetHeight = Math.round(sheetBounds.height);\n const [currentSnap, setCurrentSnap] = useState(initialSnap);\n const snapPoints =\n snapPointsProp && sheetHeight > 0\n ? computeSnapPoints({ sheetHeight, snapPointsProp })\n : [];\n\n const { windowHeight } = useDimensions();\n const closedY = sheetHeight > 0 ? sheetHeight : windowHeight;\n const y = useMotionValue(closedY);\n const yInverted = useTransform(y, (val) => Math.max(sheetHeight - val, 0));\n const indicatorRotation = useMotionValue(0);\n\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 // +2 for tolerance in case the animated value is slightly off\n const zIndex = useTransform(y, (val) =>\n val + 2 >= closedY ? -1 : (style?.zIndex ?? 9999)\n );\n const visibility = useTransform(y, (val) =>\n val + 2 >= closedY ? 'hidden' : 'visible'\n );\n\n const updateSnap = useStableCallback((snapIndex: number) => {\n setCurrentSnap(snapIndex);\n onSnap?.(snapIndex);\n });\n\n const getSnapPoint = useStableCallback((snapIndex: number) => {\n if (snapPointsProp && snapPoints) {\n if (snapIndex < 0 || snapIndex >= snapPoints.length) {\n console.warn(\n `Invalid snap index ${snapIndex}. Snap points are: [${snapPointsProp.join(', ')}] and their computed values are: [${snapPoints\n .map((point) => point.snapValue)\n .join(', ')}]`\n );\n return null;\n }\n return snapPoints[snapIndex];\n }\n return null;\n });\n\n const snapTo = useStableCallback(async (snapIndex: number) => {\n if (!snapPointsProp) {\n console.warn('Snapping is not possible without `snapPoints` prop.');\n return;\n }\n\n const snapPoint = getSnapPoint(snapIndex);\n\n if (snapPoint === null) {\n console.warn(`Invalid snap index ${snapIndex}.`);\n return;\n }\n\n if (snapIndex === 0) {\n onClose();\n return;\n }\n\n await animate(y, snapPoint.snapValueY, {\n ...animationOptions,\n onComplete: () => updateSnap(snapIndex),\n });\n });\n\n const keyboard = useKeyboardAvoidance({\n isEnabled: isOpen && avoidKeyboard,\n containerRef: sheetRef,\n onWillOpenKeyboard: async () => {\n const lastSnapPoint = snapPoints[snapPoints.length - 1];\n\n /**\n * If there are snap points and the sheet is not already at the last snap point,\n * move it there to make sure the focused input is not covered by the keyboard\n */\n if (lastSnapPoint && lastSnapPoint.snapIndex !== currentSnap) {\n await animate(y, lastSnapPoint.snapValueY, animationOptions);\n updateSnap(lastSnapPoint.snapIndex);\n }\n },\n onDidOpenKeyboard: (focusedElement) => {\n const sheetElement = sheetRef.current;\n if (!sheetElement) return;\n\n const inputRect = focusedElement.getBoundingClientRect();\n const containerRect = sheetElement.getBoundingClientRect();\n const scroller = sheetElement.querySelector(\n '.react-modal-sheet-content-scroller'\n ) as HTMLElement;\n\n const scrollTarget = Math.max(\n inputRect.top -\n containerRect.top +\n scroller.scrollTop -\n inputRect.height,\n 0\n );\n\n requestAnimationFrame(() => {\n scroller.scrollTo({ top: scrollTarget, behavior: 'smooth' });\n });\n },\n });\n\n // Disable drag if the keyboard is open to avoid weird behavior\n const disableDrag = keyboard.isKeyboardOpen || disableDragProp;\n\n const blurActiveInput = useStableCallback(() => {\n /**\n * Find focused input inside the sheet and blur it when dragging starts\n * to prevent a weird ghost caret \"bug\" on mobile\n */\n const focusedElement = document.activeElement as HTMLElement | null;\n\n // Only blur the focused element if it's inside the sheet\n if (\n focusedElement &&\n willOpenKeyboard(focusedElement) &&\n sheetRef.current?.contains(focusedElement)\n ) {\n focusedElement.blur();\n }\n });\n\n const onDragStart = useStableCallback<DragHandler>((event, info) => {\n blurActiveInput();\n onDragStartProp?.(event, info);\n });\n\n const onDrag = useStableCallback<DragHandler>((event, info) => {\n onDragProp?.(event, info);\n\n const currentY = y.get();\n\n // Update drag indicator rotation based on drag velocity\n const velocity = y.getVelocity();\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(currentY + info.delta.y, 0));\n });\n\n const onDragEnd = useStableCallback<DragHandler>((event, info) => {\n blurActiveInput();\n onDragEndProp?.(event, info);\n\n const currentY = y.get();\n\n let yTo = 0;\n\n const currentSnapPoint =\n currentSnap !== undefined ? getSnapPoint(currentSnap) : null;\n\n if (currentSnapPoint) {\n const dragOffsetDirection = info.offset.y > 0 ? 'down' : 'up';\n const dragVelocityDirection = info.velocity.y > 0 ? 'down' : 'up';\n const isHighVelocity =\n Math.abs(info.velocity.y) > dragVelocityThreshold;\n\n let result: { yTo: number; snapIndex: number | undefined };\n\n if (isHighVelocity) {\n result = handleHighVelocityDrag({\n snapPoints,\n dragDirection: dragVelocityDirection,\n });\n } else {\n result = handleLowVelocityDrag({\n currentSnapPoint,\n currentY,\n dragDirection: dragOffsetDirection,\n snapPoints,\n velocity: info.velocity.y,\n });\n }\n\n yTo = result.yTo;\n\n // If disableDismiss is true, prevent closing via gesture\n if (disableDismiss && yTo + 1 >= sheetHeight) {\n // Use the bottom-most open snap point\n const bottomSnapPoint = snapPoints.find((s) => s.snapValue > 0);\n\n if (bottomSnapPoint) {\n yTo = bottomSnapPoint.snapValueY;\n updateSnap(bottomSnapPoint.snapIndex);\n } else {\n // If no open snap points available, stay at current position\n yTo = currentY;\n }\n } else if (result.snapIndex !== undefined) {\n updateSnap(result.snapIndex);\n }\n } else if (\n info.velocity.y > dragVelocityThreshold ||\n currentY > sheetHeight * dragCloseThreshold\n ) {\n // Close the sheet if dragged past the threshold or if the velocity is high enough\n // But only if disableDismiss is false\n if (disableDismiss) {\n // If disableDismiss, snap back to the open position\n yTo = 0;\n } else {\n yTo = closedY;\n }\n }\n\n // Update the spring value so that the sheet is animated to the snap point\n animate(y, yTo, animationOptions);\n\n // +1px for imprecision tolerance\n // Only call onClose if disableDismiss is false or if we're actually closing\n if (yTo + 1 >= sheetHeight && !disableDismiss) {\n onClose();\n }\n\n // Reset indicator rotation after dragging\n indicatorRotation.set(0);\n });\n\n useImperativeHandle(ref, () => ({\n y,\n yInverted,\n height: sheetHeight,\n snapTo,\n }));\n\n useModalEffect({\n y,\n detent,\n sheetHeight,\n snapPoints,\n rootId: modalEffectRootId,\n startThreshold: modalEffectThreshold,\n });\n\n /**\n * Motion should handle body scroll locking but it's not working properly on iOS.\n * Scroll locking from React Aria seems to work much better 🤷‍♂️\n */\n usePreventScroll({\n isDisabled: disableScrollLocking || !isOpen,\n });\n\n const state = useSheetState({\n isOpen,\n onOpen: async () => {\n onOpenStart?.();\n\n /**\n * This is not very React-y but we need to wait for the sheet\n * but we need to wait for the sheet to be rendered and visible\n * before we can measure it and animate it to the initial snap point.\n */\n await waitForElement('react-modal-sheet-container');\n\n const initialSnapPoint =\n initialSnap !== undefined ? getSnapPoint(initialSnap) : null;\n\n const yTo = initialSnapPoint?.snapValueY ?? 0;\n\n await animate(y, yTo, animationOptions);\n\n if (initialSnap !== undefined) {\n updateSnap(initialSnap);\n }\n\n onOpenEnd?.();\n },\n onClosing: async () => {\n onCloseStart?.();\n\n await animate(y, closedY, animationOptions);\n\n onCloseEnd?.();\n },\n });\n\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 const context: SheetContextType = {\n currentSnap,\n detent,\n disableDrag,\n dragProps,\n indicatorRotation,\n avoidKeyboard,\n prefersReducedMotion,\n sheetBoundsRef,\n sheetRef,\n unstyled,\n y,\n };\n\n const sheet = (\n <SheetContext.Provider value={context}>\n <motion.div\n {...rest}\n ref={ref}\n data-sheet-state={state}\n className={`react-modal-sheet-root ${className}`}\n style={{\n ...applyStyles(styles.root, unstyled),\n zIndex,\n visibility,\n ...style,\n }}\n >\n {state !== 'closed' ? children : null}\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","import type { MotionValue } from 'motion/react';\n\nimport { SheetBackdrop } from './SheetBackdrop';\nimport { SheetContainer } from './SheetContainer';\nimport { SheetContent } from './SheetContent';\nimport { SheetDragIndicator } from './SheetDragIndicator';\nimport { SheetHeader } from './SheetHeader';\nimport { Sheet as SheetBase } from './sheet';\nimport type { SheetCompound } from './types';\n\nexport interface SheetRef {\n y: MotionValue<number>;\n yInverted: MotionValue<number>;\n height: number;\n snapTo: (index: number) => Promise<void>;\n}\n\nexport const Sheet: SheetCompound = Object.assign(SheetBase, {\n Container: SheetContainer,\n Header: SheetHeader,\n DragIndicator: SheetDragIndicator,\n Content: SheetContent,\n Backdrop: SheetBackdrop,\n});\n\nexport { useScrollPosition } from './hooks/use-scroll-position';\nexport { useVirtualKeyboard } from './hooks/use-virtual-keyboard';\n\n// Export types\nexport type {\n SheetBackdropProps,\n SheetContainerProps,\n SheetContentProps,\n SheetDetent,\n SheetDragIndicatorProps,\n SheetHeaderProps,\n SheetProps,\n SheetSnapPoint,\n SheetStateInfo,\n SheetTweenConfig,\n} from './types';\n"]}
package/package.json ADDED
@@ -0,0 +1,87 @@
1
+ {
2
+ "version": "5.4.3",
3
+ "license": "MIT",
4
+ "name": "@simoneggert/react-modal-sheet",
5
+ "description": "Flexible bottom sheet component for your React apps",
6
+ "author": "Teemu Taskula",
7
+ "repository": "https://github.com/SimonEggert/react-modal-sheet",
8
+ "homepage": "https://temzasse.github.io/react-modal-sheet",
9
+ "keywords": [
10
+ "react",
11
+ "modal",
12
+ "motion",
13
+ "bottom-sheet",
14
+ "accessibility",
15
+ "framer-motion"
16
+ ],
17
+ "exports": {
18
+ ".": {
19
+ "import": {
20
+ "types": "./dist/index.d.mts",
21
+ "default": "./dist/index.mjs"
22
+ },
23
+ "require": {
24
+ "types": "./dist/index.d.ts",
25
+ "default": "./dist/index.js"
26
+ }
27
+ }
28
+ },
29
+ "main": "./dist/index.js",
30
+ "module": "./dist/index.mjs",
31
+ "types": "./dist/index.d.ts",
32
+ "files": [
33
+ "dist",
34
+ "src"
35
+ ],
36
+ "scripts": {
37
+ "dev": "tsup --watch --onSuccess \"npm run link:update\"",
38
+ "build": "tsup",
39
+ "build:verify": "attw --pack .",
40
+ "format:check": "biome format ./src",
41
+ "format:write": "biome format --write ./src",
42
+ "lint:check": "biome lint --error-on-warnings ./src",
43
+ "lint:write": "biome lint --error-on-warnings --write ./src",
44
+ "link": "yalc publish && npm run link:example && npm run link:example-ssr",
45
+ "link:example": "cd example && yalc add react-modal-sheet && npm i",
46
+ "link:example-ssr": "cd example-ssr && yalc add react-modal-sheet && npm i",
47
+ "link:update": "tsup --dts-only && yalc push --replace",
48
+ "test": "vitest run",
49
+ "typecheck": "tsc --noEmit",
50
+ "verify": "run-p format:check lint:check typecheck",
51
+ "release": "npm run verify && npm run build && npm run build:verify && np",
52
+ "prepare": "husky"
53
+ },
54
+ "peerDependencies": {
55
+ "motion": ">=11",
56
+ "react": ">=16"
57
+ },
58
+ "devDependencies": {
59
+ "@arethetypeswrong/cli": "0.18.2",
60
+ "@biomejs/biome": "2.4.5",
61
+ "@types/react": "19.2.14",
62
+ "@types/react-dom": "19.2.3",
63
+ "@vitejs/plugin-react": "5.1.4",
64
+ "husky": "9.1.7",
65
+ "jsdom": "28.1.0",
66
+ "motion": "12.35.0",
67
+ "npm-run-all": "4.1.5",
68
+ "react": "19.2.4",
69
+ "react-dom": "19.2.4",
70
+ "tsup": "8.5.1",
71
+ "typescript": "5.9.3",
72
+ "vite": "7.3.1",
73
+ "vitest": "4.0.18"
74
+ },
75
+ "engines": {
76
+ "node": ">=20"
77
+ },
78
+ "prettier": {
79
+ "printWidth": 80,
80
+ "semi": true,
81
+ "singleQuote": true,
82
+ "trailingComma": "es5"
83
+ },
84
+ "dependencies": {
85
+ "react-use-measure": "2.1.7"
86
+ }
87
+ }
@@ -0,0 +1,46 @@
1
+ import { type MotionStyle, motion } from 'motion/react';
2
+ import React, { forwardRef } from 'react';
3
+
4
+ import { useSheetContext } from './context';
5
+ import { styles } from './styles';
6
+ import { type SheetBackdropProps } from './types';
7
+ import { applyStyles } from './utils';
8
+
9
+ const isClickable = (props: any) => !!props.onClick || !!props.onTap;
10
+
11
+ export const SheetBackdrop = forwardRef<any, SheetBackdropProps>(
12
+ ({ style, className = '', unstyled, ...rest }, ref) => {
13
+ const sheetContext = useSheetContext();
14
+ const clickable = isClickable(rest);
15
+ const Comp = clickable ? motion.button : motion.div;
16
+ const pointerEvents = clickable ? 'auto' : 'none';
17
+ const isUnstyled = unstyled ?? sheetContext.unstyled;
18
+
19
+ const backdropStyle: MotionStyle = {
20
+ ...applyStyles(styles.backdrop, isUnstyled),
21
+ ...style,
22
+ pointerEvents,
23
+ };
24
+
25
+ const animationProps = sheetContext.prefersReducedMotion
26
+ ? {}
27
+ : {
28
+ initial: { opacity: 0 },
29
+ animate: { opacity: 1 },
30
+ exit: { opacity: 0 },
31
+ transition: { duration: 1 },
32
+ };
33
+
34
+ return (
35
+ <Comp
36
+ {...animationProps}
37
+ {...(rest as any)}
38
+ ref={ref}
39
+ className={`react-modal-sheet-backdrop ${className}`}
40
+ style={backdropStyle}
41
+ />
42
+ );
43
+ }
44
+ );
45
+
46
+ SheetBackdrop.displayName = 'SheetBackdrop';
@@ -0,0 +1,53 @@
1
+ import { type MotionStyle, motion } from 'motion/react';
2
+ import React, { forwardRef } from 'react';
3
+
4
+ import { DEFAULT_HEIGHT } from './constants';
5
+ import { useSheetContext } from './context';
6
+ import { styles } from './styles';
7
+ import { type SheetContainerProps } from './types';
8
+ import { applyStyles, mergeRefs } from './utils';
9
+
10
+ export const SheetContainer = forwardRef<any, SheetContainerProps>(
11
+ ({ children, style, className = '', unstyled, ...rest }, ref) => {
12
+ const sheetContext = useSheetContext();
13
+
14
+ const isUnstyled = unstyled ?? sheetContext.unstyled;
15
+
16
+ const containerStyle: MotionStyle = {
17
+ ...applyStyles(styles.container, isUnstyled),
18
+ ...style,
19
+ y: sheetContext.y,
20
+ };
21
+
22
+ if (sheetContext.detent === 'default') {
23
+ containerStyle.height = DEFAULT_HEIGHT;
24
+ }
25
+
26
+ if (sheetContext.detent === 'full') {
27
+ containerStyle.height = '100%';
28
+ containerStyle.maxHeight = '100%';
29
+ }
30
+
31
+ if (sheetContext.detent === 'content') {
32
+ containerStyle.height = 'auto';
33
+ containerStyle.maxHeight = DEFAULT_HEIGHT;
34
+ }
35
+
36
+ return (
37
+ <motion.div
38
+ {...rest}
39
+ ref={mergeRefs([
40
+ ref,
41
+ sheetContext.sheetRef,
42
+ sheetContext.sheetBoundsRef,
43
+ ])}
44
+ className={`react-modal-sheet-container ${className}`}
45
+ style={containerStyle}
46
+ >
47
+ {children}
48
+ </motion.div>
49
+ );
50
+ }
51
+ );
52
+
53
+ SheetContainer.displayName = 'SheetContainer';
@@ -0,0 +1,117 @@
1
+ import { type MotionStyle, motion } from 'motion/react';
2
+ import React, { forwardRef } from 'react';
3
+
4
+ import { useSheetContext } from './context';
5
+ import { useDragConstraints } from './hooks/use-drag-constraints';
6
+ import { useScrollPosition } from './hooks/use-scroll-position';
7
+ import { styles } from './styles';
8
+ import { type SheetContentProps } from './types';
9
+ import { applyStyles, isHTTPS, mergeRefs } from './utils';
10
+
11
+ export const SheetContent = forwardRef<any, SheetContentProps>(
12
+ (
13
+ {
14
+ disableScroll: disableScrollProp,
15
+ disableDrag: disableDragProp,
16
+ children,
17
+ style: styleProp,
18
+ className = '',
19
+ scrollClassName = '',
20
+ scrollStyle: scrollStyleProp,
21
+ scrollRef: scrollRefProp = null,
22
+ unstyled,
23
+ ...rest
24
+ },
25
+ ref
26
+ ) => {
27
+ const sheetContext = useSheetContext();
28
+ const dragConstraints = useDragConstraints();
29
+
30
+ const scroll = useScrollPosition({
31
+ isEnabled:
32
+ typeof disableScrollProp === 'function' ? true : !disableScrollProp,
33
+ });
34
+
35
+ const disableScroll =
36
+ typeof disableScrollProp === 'function'
37
+ ? disableScrollProp({
38
+ scrollPosition: scroll.scrollPosition,
39
+ currentSnap: sheetContext.currentSnap,
40
+ })
41
+ : Boolean(disableScrollProp);
42
+
43
+ const disableDragDueToScroll =
44
+ !disableScroll &&
45
+ scroll.scrollPosition &&
46
+ scroll.scrollPosition !== 'top';
47
+
48
+ const disableDragDueToProp =
49
+ typeof disableDragProp === 'function'
50
+ ? disableDragProp({
51
+ scrollPosition: scroll.scrollPosition,
52
+ currentSnap: sheetContext.currentSnap,
53
+ })
54
+ : Boolean(disableDragProp);
55
+
56
+ const disableDrag =
57
+ disableDragDueToProp ||
58
+ disableDragDueToScroll ||
59
+ sheetContext.disableDrag;
60
+
61
+ const dragProps =
62
+ disableDrag || sheetContext.disableDrag
63
+ ? undefined
64
+ : sheetContext.dragProps;
65
+
66
+ const isUnstyled = unstyled ?? sheetContext.unstyled;
67
+
68
+ const contentStyle: MotionStyle = {
69
+ ...applyStyles(styles.content, isUnstyled),
70
+ ...styleProp,
71
+ };
72
+
73
+ const scrollStyle: MotionStyle = applyStyles(styles.scroller, isUnstyled);
74
+
75
+ if (sheetContext.avoidKeyboard) {
76
+ /**
77
+ * Virtual Keyboard API is only available in secure context (https)
78
+ * and it will have 0px height in insecure context,
79
+ * which causes issues when developing and testing on localhost (http).
80
+ */
81
+ scrollStyle.paddingBottom = isHTTPS()
82
+ ? 'env(keyboard-inset-height, var(--keyboard-inset-height, 0px))'
83
+ : 'var(--keyboard-inset-height, 0px)';
84
+ }
85
+
86
+ if (disableScroll) {
87
+ scrollStyle.overflowY = 'hidden';
88
+ }
89
+
90
+ if (dragProps !== undefined) {
91
+ // Let browser only handle downward pan gestures (scrolling content up)
92
+ scrollStyle.touchAction = 'pan-down';
93
+ }
94
+
95
+ return (
96
+ <motion.div
97
+ {...rest}
98
+ ref={mergeRefs([ref, dragConstraints.ref])}
99
+ className={`react-modal-sheet-content ${className}`}
100
+ style={contentStyle}
101
+ {...dragProps}
102
+ dragConstraints={dragConstraints.ref}
103
+ onMeasureDragConstraints={dragConstraints.onMeasure}
104
+ >
105
+ <motion.div
106
+ ref={mergeRefs([scroll.scrollRef, scrollRefProp])}
107
+ style={{ ...scrollStyle, ...scrollStyleProp }}
108
+ className={`react-modal-sheet-content-scroller ${scrollClassName}`}
109
+ >
110
+ {children}
111
+ </motion.div>
112
+ </motion.div>
113
+ );
114
+ }
115
+ );
116
+
117
+ SheetContent.displayName = 'SheetContent';