react-modal-sheet 1.6.1 → 1.6.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.
- package/README.md +10 -5
- package/dist/react-modal-sheet.cjs.development.js +7 -1
- package/dist/react-modal-sheet.cjs.development.js.map +1 -1
- package/dist/react-modal-sheet.cjs.production.min.js +1 -1
- package/dist/react-modal-sheet.cjs.production.min.js.map +1 -1
- package/dist/react-modal-sheet.esm.js +7 -1
- package/dist/react-modal-sheet.esm.js.map +1 -1
- package/package.json +2 -1
- package/src/SheetContainer.tsx +6 -1
- package/src/sheet.tsx +5 -0
package/README.md
CHANGED
|
@@ -353,11 +353,16 @@ The example below utilizes React Aria to achieve an accessible modal-like bottom
|
|
|
353
353
|
```jsx
|
|
354
354
|
import React from 'react';
|
|
355
355
|
import Sheet from 'react-modal-sheet';
|
|
356
|
-
import { useOverlayTriggerState } from '
|
|
357
|
-
|
|
358
|
-
import {
|
|
359
|
-
|
|
360
|
-
|
|
356
|
+
import { useOverlayTriggerState } from 'react-stately';
|
|
357
|
+
|
|
358
|
+
import {
|
|
359
|
+
useOverlay,
|
|
360
|
+
useModal,
|
|
361
|
+
OverlayProvider,
|
|
362
|
+
FocusScope,
|
|
363
|
+
useButton,
|
|
364
|
+
useDialog,
|
|
365
|
+
} from 'react-aria';
|
|
361
366
|
|
|
362
367
|
const A11yExample = () => {
|
|
363
368
|
const sheetState = useOverlayTriggerState({});
|
|
@@ -6,6 +6,7 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
|
|
|
6
6
|
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var ReactDOM = require('react-dom');
|
|
9
|
+
var overlays = require('@react-aria/overlays');
|
|
9
10
|
var framerMotion = require('framer-motion');
|
|
10
11
|
var mergeRefs = _interopDefault(require('react-merge-refs'));
|
|
11
12
|
|
|
@@ -385,7 +386,12 @@ var Sheet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
385
386
|
}
|
|
386
387
|
};
|
|
387
388
|
});
|
|
388
|
-
useModalEffect(isOpen, rootId);
|
|
389
|
+
useModalEffect(isOpen, rootId); // Framer Motion should handle body scroll locking but it's not working
|
|
390
|
+
// properly on iOS. Scroll locking from React Aria seems to work much better.
|
|
391
|
+
|
|
392
|
+
overlays.usePreventScroll({
|
|
393
|
+
isDisabled: !isOpen
|
|
394
|
+
});
|
|
389
395
|
var dragProps = disableDrag ? {} : {
|
|
390
396
|
drag: 'y',
|
|
391
397
|
dragElastic: 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-modal-sheet.cjs.development.js","sources":["../src/utils.ts","../src/context.tsx","../src/hooks.tsx","../src/styles.ts","../src/sheet.tsx","../src/SheetContainer.tsx","../src/SheetContent.tsx","../src/SheetHeader.tsx","../src/SheetBackdrop.tsx","../src/index.tsx"],"sourcesContent":["import { useEffect, useLayoutEffect, useState } from 'react';\n\nexport const isSSR = typeof window === 'undefined';\n\nexport const getClosest = (nums: number[], goal: number) => {\n return nums.reduce((prev, curr) => {\n return Math.abs(curr - goal) < Math.abs(prev - goal) ? curr : prev;\n });\n};\n\nconst highlightId = 'react-modal-sheet-highlight';\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 = 'transform 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 // Add highlighed overlay to emphasize the modality effect\n const highlight = document.createElement('div');\n highlight.setAttribute('aria-hidden', 'true');\n highlight.id = highlightId;\n highlight.style.position = 'absolute';\n highlight.style.top = '0px';\n highlight.style.left = '0px';\n highlight.style.bottom = '0px';\n highlight.style.right = '0px';\n highlight.style.opacity = '0';\n highlight.style.transition = 'opacity 200ms linear';\n highlight.style.backgroundColor = 'rgba(150, 150, 150, 0.1)';\n\n root.appendChild(highlight);\n requestAnimationFrame(() => (highlight.style.opacity = '1'));\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 const highlight = document.getElementById(highlightId) 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 highlight.parentNode?.removeChild(highlight);\n }\n\n if (root && highlight) {\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 highlight.style.opacity = '0';\n\n // Remove temp properties after animation is finished\n root.addEventListener('transitionend', onTransitionEnd);\n }\n}\n\nconst useIsomorphicLayoutEffect = isSSR ? useEffect : useLayoutEffect;\n\nexport function useWindowHeight() {\n const [windowHeight, setWindowHeight] = useState(0);\n\n useIsomorphicLayoutEffect(() => {\n const updateHeight = () => setWindowHeight(window.innerHeight);\n window.addEventListener('resize', updateHeight);\n updateHeight();\n return () => window.removeEventListener('resize', updateHeight);\n }, []);\n\n return windowHeight;\n}\n\nexport const 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","import * as React from 'react';\nimport { SheetContextType } from './types';\n\nexport const SheetContext = React.createContext<SheetContextType | undefined>(\n undefined\n);\n\nexport const useSheetContext = () => {\n const context = React.useContext(SheetContext);\n if (!context) throw Error('Sheet context error');\n return context;\n};\n","import * as React from 'react';\n\nimport { SheetEvents } from './types';\nimport { applyRootStyles, cleanupRootStyles } from './utils';\n\nexport const 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 React.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 React.useEffect(() => {\n return () => {\n if (rootId && isOpen) cleanupRootStyles(rootId);\n };\n }, [isOpen]); // eslint-disable-line\n};\n\nexport const useEventCallbacks = (\n isOpen: boolean,\n callbacks: React.MutableRefObject<SheetEvents>\n) => {\n const prevOpen = usePrevious(isOpen);\n const didOpen = React.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 = React.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 React.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\nconst usePrevious = <T,>(state: T): T | undefined => {\n const ref = React.useRef<T>();\n\n React.useEffect(() => {\n ref.current = state;\n });\n\n return ref.current;\n};\n","import * as CSS from 'csstype';\n\nconst styles: { [key: string]: CSS.Properties } = {\n wrapper: {\n position: 'fixed',\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n zIndex: 9999999,\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(51, 51, 51, 0.5)',\n touchAction: 'none', // Disable iOS body scrolling\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 flex: 1,\n overflow: 'auto',\n position: 'relative',\n },\n};\n\nexport default styles;\n","import * as React from 'react';\nimport * as ReactDOM from 'react-dom';\n\nimport {\n animate,\n useMotionValue,\n PanInfo,\n AnimatePresence,\n} from 'framer-motion';\n\nimport { SheetContextType, SheetProps } from './types';\nimport { getClosest, inDescendingOrder, isSSR, useWindowHeight } from './utils';\nimport { SheetContext } from './context';\nimport { useModalEffect } from './hooks';\nimport styles from './styles';\n\nconst Sheet = React.forwardRef<any, SheetProps>(\n (\n {\n children,\n isOpen,\n onClose,\n onOpenStart,\n onOpenEnd,\n onCloseStart,\n onCloseEnd,\n onSnap,\n snapPoints,\n initialSnap = 0,\n rootId,\n mountPoint,\n springConfig = { stiffness: 300, damping: 30, mass: 0.2 },\n disableDrag = false,\n style,\n ...rest\n },\n ref\n ) => {\n const sheetRef = React.useRef<any>(null);\n const callbacks = React.useRef({ onOpenStart, onOpenEnd, onCloseStart, onCloseEnd }); // prettier-ignore\n const indicatorRotation = useMotionValue(0);\n const windowHeight = useWindowHeight();\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 if (snapPoints) {\n // Convert negative / percentage snap points to absolute values\n snapPoints = snapPoints.map(point => {\n if (point > 0 && point <= 1) return Math.round(point * windowHeight); // percentage values e.g. between 0.0 and 1.0\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}]`\n );\n }\n\n const handleDrag = React.useCallback((_, { delta }: PanInfo) => {\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(y.get() + delta.y, 0));\n }, []); // eslint-disable-line\n\n const handleDragEnd = React.useCallback(\n (_, { velocity }: PanInfo) => {\n if (velocity.y > 500) {\n // User flicked the sheet down\n onClose();\n } else {\n const sheetEl = sheetRef.current as HTMLDivElement;\n const contentHeight = sheetEl.getBoundingClientRect().height;\n const snapTo = Math.round(\n snapPoints\n ? getClosest(snapPoints.map(p => contentHeight - p), y.get()) // prettier-ignore\n : y.get() / contentHeight > 0.6 // Close if dragged over 60%\n ? contentHeight\n : 0\n );\n\n // Update the spring value so that the sheet is animated to the snap point\n animate(y, snapTo, { type: 'spring', ...springConfig });\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 if (snapTo >= contentHeight) onClose();\n }\n\n // Reset indicator rotation after dragging\n indicatorRotation.set(0);\n },\n [onClose, onSnap] // eslint-disable-line\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 React.useEffect(() => {\n callbacks.current = { onOpenStart, onOpenEnd, onCloseStart, onCloseEnd };\n });\n\n // Trigger onSnap callback when sheet is opened or closed\n React.useEffect(() => {\n if (!snapPoints || !onSnap) return;\n const snapIndex = isOpen ? initialSnap : snapPoints.length - 1;\n onSnap(snapIndex);\n }, [isOpen]); // eslint-disable-line\n\n React.useImperativeHandle(ref, () => ({\n y,\n snapTo: (snapIndex: number) => {\n const sheetEl = sheetRef.current as HTMLDivElement | null;\n if (\n snapPoints &&\n snapPoints[snapIndex] !== undefined &&\n sheetEl !== null\n ) {\n const contentHeight = sheetEl.getBoundingClientRect().height;\n const snapTo = contentHeight - snapPoints[snapIndex];\n animate(y, snapTo, { type: 'spring', ...springConfig });\n if (onSnap) onSnap(snapIndex);\n if (snapTo >= contentHeight) onClose();\n }\n },\n }));\n\n useModalEffect(isOpen, rootId);\n\n const dragProps = disableDrag\n ? ({} as any)\n : {\n drag: 'y' as const,\n dragElastic: 0,\n dragConstraints: { top: 0, bottom: 0 },\n dragMomentum: false,\n onDrag: handleDrag,\n onDragEnd: handleDragEnd,\n };\n\n const context: SheetContextType = {\n y,\n sheetRef,\n isOpen,\n initialSnap,\n snapPoints,\n indicatorRotation,\n callbacks,\n dragProps,\n windowHeight,\n springConfig,\n };\n\n const wrapperProps = {\n ...rest,\n ref,\n style: { ...styles.wrapper, ...style },\n };\n\n const sheet = (\n <SheetContext.Provider value={context}>\n <div {...wrapperProps}>\n <AnimatePresence>\n {/* NOTE: AnimatePresence requires us to set keys to children */}\n {isOpen\n ? React.Children.map(children, (child: any, i) =>\n React.cloneElement(child, { key: `sheet-child-${i}` })\n )\n : null}\n </AnimatePresence>\n </div>\n </SheetContext.Provider>\n );\n\n if (isSSR) return sheet;\n\n return ReactDOM.createPortal(sheet, mountPoint ?? document.body);\n }\n);\n\nexport default Sheet;\n","import * as React from 'react';\nimport { motion } from 'framer-motion';\nimport mergeRefs from 'react-merge-refs';\n\nimport { SheetContainerProps } from './types';\nimport { useSheetContext } from './context';\nimport { useEventCallbacks } from './hooks';\nimport styles from './styles';\n\nconst MAX_HEIGHT = 'calc(100% - env(safe-area-inset-top) - 34px)';\n\nconst SheetContainer = React.forwardRef<any, SheetContainerProps>(\n ({ children, style = {}, ...rest }, ref) => {\n const {\n y,\n isOpen,\n callbacks,\n snapPoints,\n initialSnap = 0,\n sheetRef,\n windowHeight,\n springConfig,\n } = useSheetContext();\n\n const { handleAnimationComplete } = useEventCallbacks(isOpen, callbacks);\n const initialY = snapPoints ? snapPoints[0] - snapPoints[initialSnap] : 0;\n const h = snapPoints ? snapPoints[0] : null;\n const sheetHeight = h ? `min(${h}px, ${MAX_HEIGHT})` : MAX_HEIGHT;\n\n return (\n <motion.div\n {...rest}\n ref={mergeRefs([sheetRef, ref])}\n className=\"react-modal-sheet-container\"\n style={{ ...styles.container, height: sheetHeight, ...style, y }}\n initial={{ y: windowHeight }}\n animate={{\n y: initialY,\n transition: { type: 'spring', ...springConfig },\n }}\n exit={{ y: windowHeight }}\n onAnimationComplete={handleAnimationComplete}\n >\n {children}\n </motion.div>\n );\n }\n);\n\nexport default SheetContainer;\n","import * as React from 'react';\nimport { motion } from 'framer-motion';\n\nimport { SheetDraggableProps } from './types';\nimport styles from './styles';\nimport { useSheetContext } from './context';\n\nconst SheetContent = React.forwardRef<any, SheetDraggableProps>(\n ({ children, disableDrag = false, style = {}, ...rest }, ref) => {\n const { dragProps } = useSheetContext();\n\n return (\n <motion.div\n {...rest}\n ref={ref}\n className=\"react-modal-sheet-content\"\n style={{ ...styles.content, ...style }}\n {...(disableDrag ? {} : dragProps)}\n >\n {children}\n </motion.div>\n );\n }\n);\n\nexport default SheetContent;\n","import * as React from 'react';\nimport { motion, useTransform } from 'framer-motion';\n\nimport { SheetDraggableProps } from './types';\nimport { useSheetContext } from './context';\nimport styles from './styles';\n\nconst SheetHeader = React.forwardRef<any, SheetDraggableProps>(\n ({ children, disableDrag = false, style = {}, ...rest }, ref) => {\n const { indicatorRotation, dragProps } = useSheetContext();\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={ref}\n style={{ ...styles.headerWrapper, ...style }}\n {...(disableDrag ? {} : dragProps)}\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\nexport default SheetHeader;\n","import * as React from 'react';\nimport { motion } from 'framer-motion';\n\nimport { SheetBackdropProps } from './types';\nimport styles from './styles';\n\nconst isClickable = (props: any) => !!props.onClick || !!props.onTap;\n\nconst SheetBackdrop = React.forwardRef<any, SheetBackdropProps>(\n ({ style = {}, ...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\"\n style={{ ...styles.backdrop, ...style, pointerEvents }}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n />\n );\n }\n);\n\nexport default SheetBackdrop;\n","import { 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 { SheetCompound } from './types';\n\nexport type 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\nexport default _SheetCompound as SheetCompound;\n"],"names":["isSSR","window","getClosest","nums","goal","reduce","prev","curr","Math","abs","highlightId","applyRootStyles","rootId","body","document","querySelector","root","p","h","innerHeight","s","style","backgroundColor","overflow","willChange","transition","transform","borderTopRightRadius","borderTopLeftRadius","highlight","createElement","setAttribute","id","position","top","left","bottom","right","opacity","appendChild","requestAnimationFrame","cleanupRootStyles","getElementById","onTransitionEnd","removeProperty","removeEventListener","parentNode","removeChild","addEventListener","useIsomorphicLayoutEffect","useEffect","useLayoutEffect","useWindowHeight","useState","windowHeight","setWindowHeight","updateHeight","inDescendingOrder","arr","i","length","SheetContext","React","undefined","useSheetContext","context","Error","useModalEffect","isOpen","prevOpen","usePrevious","useEventCallbacks","callbacks","didOpen","handleAnimationComplete","current","onOpenEnd","onCloseEnd","onOpenStart","onCloseStart","state","ref","styles","wrapper","zIndex","pointerEvents","backdrop","width","height","touchAction","container","boxShadow","display","flexDirection","headerWrapper","header","alignItems","justifyContent","indicator","borderRadius","content","flex","Sheet","children","onClose","onSnap","snapPoints","initialSnap","mountPoint","springConfig","stiffness","damping","mass","disableDrag","rest","sheetRef","indicatorRotation","useMotionValue","y","map","point","round","console","assert","handleDrag","_","delta","velocity","getVelocity","set","max","get","handleDragEnd","sheetEl","contentHeight","getBoundingClientRect","snapTo","animate","type","snapValue","snapIndex","indexOf","dragProps","drag","dragElastic","dragConstraints","dragMomentum","onDrag","onDragEnd","wrapperProps","sheet","Provider","value","AnimatePresence","child","key","ReactDOM","MAX_HEIGHT","SheetContainer","initialY","sheetHeight","motion","div","mergeRefs","className","initial","exit","onAnimationComplete","SheetContent","SheetHeader","indicator1Transform","useTransform","r","indicator2Transform","span","isClickable","props","onClick","onTap","SheetBackdrop","Comp","button","_SheetCompound","Container","Header","Content","Backdrop"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,IAAMA,KAAK,GAAG,OAAOC,MAAP,KAAkB,WAAhC;AAEA,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAACC,IAAD,EAAiBC,IAAjB;AACxB,SAAOD,IAAI,CAACE,MAAL,CAAY,UAACC,IAAD,EAAOC,IAAP;AACjB,WAAOC,IAAI,CAACC,GAAL,CAASF,IAAI,GAAGH,IAAhB,IAAwBI,IAAI,CAACC,GAAL,CAASH,IAAI,GAAGF,IAAhB,CA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AM,CAACC,GAAxD;AACA,MAAM7E,aAAa,GAAG0F,WAAW,CAAC7D,IAAD,CAAX,GAAoB,MAApB,GAA6B,MAAnD;AAEA,SACEpD,mBAAA,CAACsH,IAAD,oBACMlE;AACJjC,IAAAA,GAAG,EAAEA;AACLmF,IAAAA,SAAS,EAAC;AACV/I,IAAAA,KAAK,eAAO6D,MAAM,CAACI,QAAd,EAA2BjE,KAA3B;AAAkCgE,MAAAA,aAAa,EAAbA;AAAlC;AACLgF,IAAAA,OAAO,EAAE;AAAE/H,MAAAA,OAAO,EAAE;AAAX;AACTmG,IAAAA,OAAO,EAAE;AAAEnG,MAAAA,OAAO,EAAE;AAAX;AACTgI,IAAAA,IAAI,EAAE;AAAEhI,MAAAA,OAAO,EAAE;AAAX;IAPR,CADF;AAWD,CAhBmB,CAAtB;;ACOA,IAAMgJ,cAAc,GAAQhF,KAA5B;AACAgF,cAAc,CAACC,SAAf,GAA2BzB,cAA3B;AACAwB,cAAc,CAACE,MAAf,GAAwBf,WAAxB;AACAa,cAAc,CAACG,OAAf,GAAyBjB,YAAzB;AACAc,cAAc,CAACI,QAAf,GAA0BP,aAA1B;;;;"}
|
|
1
|
+
{"version":3,"file":"react-modal-sheet.cjs.development.js","sources":["../src/utils.ts","../src/context.tsx","../src/hooks.tsx","../src/styles.ts","../src/sheet.tsx","../src/SheetContainer.tsx","../src/SheetContent.tsx","../src/SheetHeader.tsx","../src/SheetBackdrop.tsx","../src/index.tsx"],"sourcesContent":["import { useEffect, useLayoutEffect, useState } from 'react';\n\nexport const isSSR = typeof window === 'undefined';\n\nexport const getClosest = (nums: number[], goal: number) => {\n return nums.reduce((prev, curr) => {\n return Math.abs(curr - goal) < Math.abs(prev - goal) ? curr : prev;\n });\n};\n\nconst highlightId = 'react-modal-sheet-highlight';\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 = 'transform 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 // Add highlighed overlay to emphasize the modality effect\n const highlight = document.createElement('div');\n highlight.setAttribute('aria-hidden', 'true');\n highlight.id = highlightId;\n highlight.style.position = 'absolute';\n highlight.style.top = '0px';\n highlight.style.left = '0px';\n highlight.style.bottom = '0px';\n highlight.style.right = '0px';\n highlight.style.opacity = '0';\n highlight.style.transition = 'opacity 200ms linear';\n highlight.style.backgroundColor = 'rgba(150, 150, 150, 0.1)';\n\n root.appendChild(highlight);\n requestAnimationFrame(() => (highlight.style.opacity = '1'));\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 const highlight = document.getElementById(highlightId) 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 highlight.parentNode?.removeChild(highlight);\n }\n\n if (root && highlight) {\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 highlight.style.opacity = '0';\n\n // Remove temp properties after animation is finished\n root.addEventListener('transitionend', onTransitionEnd);\n }\n}\n\nconst useIsomorphicLayoutEffect = isSSR ? useEffect : useLayoutEffect;\n\nexport function useWindowHeight() {\n const [windowHeight, setWindowHeight] = useState(0);\n\n useIsomorphicLayoutEffect(() => {\n const updateHeight = () => setWindowHeight(window.innerHeight);\n window.addEventListener('resize', updateHeight);\n updateHeight();\n return () => window.removeEventListener('resize', updateHeight);\n }, []);\n\n return windowHeight;\n}\n\nexport const 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","import * as React from 'react';\nimport { SheetContextType } from './types';\n\nexport const SheetContext = React.createContext<SheetContextType | undefined>(\n undefined\n);\n\nexport const useSheetContext = () => {\n const context = React.useContext(SheetContext);\n if (!context) throw Error('Sheet context error');\n return context;\n};\n","import * as React from 'react';\n\nimport { SheetEvents } from './types';\nimport { applyRootStyles, cleanupRootStyles } from './utils';\n\nexport const 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 React.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 React.useEffect(() => {\n return () => {\n if (rootId && isOpen) cleanupRootStyles(rootId);\n };\n }, [isOpen]); // eslint-disable-line\n};\n\nexport const useEventCallbacks = (\n isOpen: boolean,\n callbacks: React.MutableRefObject<SheetEvents>\n) => {\n const prevOpen = usePrevious(isOpen);\n const didOpen = React.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 = React.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 React.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\nconst usePrevious = <T,>(state: T): T | undefined => {\n const ref = React.useRef<T>();\n\n React.useEffect(() => {\n ref.current = state;\n });\n\n return ref.current;\n};\n","import * as CSS from 'csstype';\n\nconst styles: { [key: string]: CSS.Properties } = {\n wrapper: {\n position: 'fixed',\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n zIndex: 9999999,\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(51, 51, 51, 0.5)',\n touchAction: 'none', // Disable iOS body scrolling\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 flex: 1,\n overflow: 'auto',\n position: 'relative',\n },\n};\n\nexport default styles;\n","import * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport { usePreventScroll } from '@react-aria/overlays';\n\nimport {\n animate,\n useMotionValue,\n PanInfo,\n AnimatePresence,\n} from 'framer-motion';\n\nimport { SheetContextType, SheetProps } from './types';\nimport { getClosest, inDescendingOrder, isSSR, useWindowHeight } from './utils';\nimport { SheetContext } from './context';\nimport { useModalEffect } from './hooks';\nimport styles from './styles';\n\nconst Sheet = React.forwardRef<any, SheetProps>(\n (\n {\n children,\n isOpen,\n onClose,\n onOpenStart,\n onOpenEnd,\n onCloseStart,\n onCloseEnd,\n onSnap,\n snapPoints,\n initialSnap = 0,\n rootId,\n mountPoint,\n springConfig = { stiffness: 300, damping: 30, mass: 0.2 },\n disableDrag = false,\n style,\n ...rest\n },\n ref\n ) => {\n const sheetRef = React.useRef<any>(null);\n const callbacks = React.useRef({ onOpenStart, onOpenEnd, onCloseStart, onCloseEnd }); // prettier-ignore\n const indicatorRotation = useMotionValue(0);\n const windowHeight = useWindowHeight();\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 if (snapPoints) {\n // Convert negative / percentage snap points to absolute values\n snapPoints = snapPoints.map(point => {\n if (point > 0 && point <= 1) return Math.round(point * windowHeight); // percentage values e.g. between 0.0 and 1.0\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}]`\n );\n }\n\n const handleDrag = React.useCallback((_, { delta }: PanInfo) => {\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(y.get() + delta.y, 0));\n }, []); // eslint-disable-line\n\n const handleDragEnd = React.useCallback(\n (_, { velocity }: PanInfo) => {\n if (velocity.y > 500) {\n // User flicked the sheet down\n onClose();\n } else {\n const sheetEl = sheetRef.current as HTMLDivElement;\n const contentHeight = sheetEl.getBoundingClientRect().height;\n const snapTo = Math.round(\n snapPoints\n ? getClosest(snapPoints.map(p => contentHeight - p), y.get()) // prettier-ignore\n : y.get() / contentHeight > 0.6 // Close if dragged over 60%\n ? contentHeight\n : 0\n );\n\n // Update the spring value so that the sheet is animated to the snap point\n animate(y, snapTo, { type: 'spring', ...springConfig });\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 if (snapTo >= contentHeight) onClose();\n }\n\n // Reset indicator rotation after dragging\n indicatorRotation.set(0);\n },\n [onClose, onSnap] // eslint-disable-line\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 React.useEffect(() => {\n callbacks.current = { onOpenStart, onOpenEnd, onCloseStart, onCloseEnd };\n });\n\n // Trigger onSnap callback when sheet is opened or closed\n React.useEffect(() => {\n if (!snapPoints || !onSnap) return;\n const snapIndex = isOpen ? initialSnap : snapPoints.length - 1;\n onSnap(snapIndex);\n }, [isOpen]); // eslint-disable-line\n\n React.useImperativeHandle(ref, () => ({\n y,\n snapTo: (snapIndex: number) => {\n const sheetEl = sheetRef.current as HTMLDivElement | null;\n if (\n snapPoints &&\n snapPoints[snapIndex] !== undefined &&\n sheetEl !== null\n ) {\n const contentHeight = sheetEl.getBoundingClientRect().height;\n const snapTo = contentHeight - snapPoints[snapIndex];\n animate(y, snapTo, { type: 'spring', ...springConfig });\n if (onSnap) onSnap(snapIndex);\n if (snapTo >= contentHeight) 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: !isOpen });\n\n const dragProps = disableDrag\n ? ({} as any)\n : {\n drag: 'y' as const,\n dragElastic: 0,\n dragConstraints: { top: 0, bottom: 0 },\n dragMomentum: false,\n onDrag: handleDrag,\n onDragEnd: handleDragEnd,\n };\n\n const context: SheetContextType = {\n y,\n sheetRef,\n isOpen,\n initialSnap,\n snapPoints,\n indicatorRotation,\n callbacks,\n dragProps,\n windowHeight,\n springConfig,\n };\n\n const wrapperProps = {\n ...rest,\n ref,\n style: { ...styles.wrapper, ...style },\n };\n\n const sheet = (\n <SheetContext.Provider value={context}>\n <div {...wrapperProps}>\n <AnimatePresence>\n {/* NOTE: AnimatePresence requires us to set keys to children */}\n {isOpen\n ? React.Children.map(children, (child: any, i) =>\n React.cloneElement(child, { key: `sheet-child-${i}` })\n )\n : null}\n </AnimatePresence>\n </div>\n </SheetContext.Provider>\n );\n\n if (isSSR) return sheet;\n\n return ReactDOM.createPortal(sheet, mountPoint ?? document.body);\n }\n);\n\nexport default Sheet;\n","import * as React from 'react';\nimport { motion } from 'framer-motion';\nimport mergeRefs from 'react-merge-refs';\n\nimport { SheetContainerProps } from './types';\nimport { useSheetContext } from './context';\nimport { useEventCallbacks } from './hooks';\nimport styles from './styles';\n\nconst MAX_HEIGHT = 'calc(100% - env(safe-area-inset-top) - 34px)';\n\nconst SheetContainer = React.forwardRef<any, SheetContainerProps>(\n ({ children, style = {}, ...rest }, ref) => {\n const {\n y,\n isOpen,\n callbacks,\n snapPoints,\n initialSnap = 0,\n sheetRef,\n windowHeight,\n springConfig,\n } = useSheetContext();\n\n const { handleAnimationComplete } = useEventCallbacks(isOpen, callbacks);\n const initialY = snapPoints ? snapPoints[0] - snapPoints[initialSnap] : 0;\n const h = snapPoints ? snapPoints[0] : null;\n const sheetHeight = h ? `min(${h}px, ${MAX_HEIGHT})` : MAX_HEIGHT;\n\n return (\n <motion.div\n {...rest}\n ref={mergeRefs([sheetRef, ref])}\n className=\"react-modal-sheet-container\"\n style={{\n ...styles.container,\n height: sheetHeight,\n ...style,\n y,\n }}\n initial={{ y: windowHeight }}\n animate={{\n y: initialY,\n transition: { type: 'spring', ...springConfig },\n }}\n exit={{ y: windowHeight }}\n onAnimationComplete={handleAnimationComplete}\n >\n {children}\n </motion.div>\n );\n }\n);\n\nexport default SheetContainer;\n","import * as React from 'react';\nimport { motion } from 'framer-motion';\n\nimport { SheetDraggableProps } from './types';\nimport styles from './styles';\nimport { useSheetContext } from './context';\n\nconst SheetContent = React.forwardRef<any, SheetDraggableProps>(\n ({ children, disableDrag = false, style = {}, ...rest }, ref) => {\n const { dragProps } = useSheetContext();\n\n return (\n <motion.div\n {...rest}\n ref={ref}\n className=\"react-modal-sheet-content\"\n style={{ ...styles.content, ...style }}\n {...(disableDrag ? {} : dragProps)}\n >\n {children}\n </motion.div>\n );\n }\n);\n\nexport default SheetContent;\n","import * as React from 'react';\nimport { motion, useTransform } from 'framer-motion';\n\nimport { SheetDraggableProps } from './types';\nimport { useSheetContext } from './context';\nimport styles from './styles';\n\nconst SheetHeader = React.forwardRef<any, SheetDraggableProps>(\n ({ children, disableDrag = false, style = {}, ...rest }, ref) => {\n const { indicatorRotation, dragProps } = useSheetContext();\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={ref}\n style={{ ...styles.headerWrapper, ...style }}\n {...(disableDrag ? {} : dragProps)}\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\nexport default SheetHeader;\n","import * as React from 'react';\nimport { motion } from 'framer-motion';\n\nimport { SheetBackdropProps } from './types';\nimport styles from './styles';\n\nconst isClickable = (props: any) => !!props.onClick || !!props.onTap;\n\nconst SheetBackdrop = React.forwardRef<any, SheetBackdropProps>(\n ({ style = {}, ...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\"\n style={{ ...styles.backdrop, ...style, pointerEvents }}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n />\n );\n }\n);\n\nexport default SheetBackdrop;\n","import { 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 { SheetCompound } from './types';\n\nexport type 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\nexport default _SheetCompound as SheetCompound;\n"],"names":["isSSR","window","getClosest","nums","goal","reduce","prev","curr","Math","abs","highlightId","applyRootStyles","rootId","body","document","querySelector","root","p","h","innerHeight","s","style","backgroundColor","overflow","willChange","transition","transform","borderTopRightRadius","borderTopLeftRadius","highlight","createElement","setAttribute","id","position","top","left","bottom","right","opacity","appendChild","requestAnimationFrame","cleanupRootStyles","getElementById","onTransitionEnd","removeProperty","removeEventListener","parentNode","removeChild","addEventListener","useIsomorphicLayoutEffect","useEffect","useLayoutEffect","useWindowHeight","useState","windowHeight","setWindowHeight","updateHeight","inDescendingOrder","arr","i","length","SheetContext","React","undefined","useSheetContext","context","Error","useModalEffect","isOpen","prevOpen","usePrevious","useEventCallbacks","callbacks","didOpen","handleAnimationComplete","current","onOpenEnd","onCloseEnd","onOpenStart","onCloseStart","state","ref","styles","wrapper","zIndex","pointerEvents","backdrop","width","height","touchAction","container","boxShadow","display","flexDirection","headerWrapper","header","alignItems","justifyContent","indicator","borderRadius","content","flex","Sheet","children","onClose","onSnap","snapPoints","initialSnap","mountPoint","springConfig","stiffness","damping","mass","disableDrag","rest","sheetRef","indicatorRotation","useMotionValue","y","map","point","round","console","assert","handleDrag","_","delta","velocity","getVelocity","set","max","get","handleDragEnd","sheetEl","contentHeight","getBoundingClientRect","snapTo","animate","type","snapValue","snapIndex","indexOf","usePreventScroll","isDisabled","dragProps","drag","dragElastic","dragConstraints","dragMomentum","onDrag","onDragEnd","wrapperProps","sheet","Provider","value","AnimatePresence","child","key","ReactDOM","MAX_HEIGHT","SheetContainer","initialY","sheetHeight","motion","div","mergeRefs","className","initial","exit","onAnimationComplete","SheetContent","SheetHeader","indicator1Transform","useTransform","r","indicator2Transform","span","isClickable","props","onClick","onTap","SheetBackdrop","Comp","button","_SheetCompound","Container","Header","Content","Backdrop"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,IAAMA,KAAK,GAAG,OAAOC,MAAP,KAAkB,WAAhC;AAEA,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAACC,IAAD,EAAiBC,IAAjB;AACxB,SAAOD,IAAI,CAACE,MAAL,CAAY,UAACC,IAAD,EAAOC,IAAP;AACjB,WAAOC,IAAI,CAACC,GAAL,CAASF,IAAI,GAAGH,IAAhB,IAAwBI,IAAI,CAACC,GAAL,CAASH,IAAI,GAAGF,IAAhB,CAAxB,GAAgDG,IAAhD,GAAuDD,IAA9D;AACD,GAFM,CAAP;AAGD,CAJM;AAMP,IAAMI,WAAW,GAAG,6BAApB;SAEgBC,gBAAgBC;AAC9B,MAAMC,IAAI,GAAGC,QAAQ,CAACC,aAAT,CAAuB,MAAvB,CAAb;AACA,MAAMC,IAAI,GAAGF,QAAQ,CAACC,aAAT,OAA2BH,MAA3B,CAAb;;AAEA,MAAII,IAAJ,EAAU;AACR,QAAMC,CAAC,GAAG,EAAV;AACA,QAAMC,CAAC,GAAGjB,MAAM,CAACkB,WAAjB;AACA,QAAMC,CAAC,GAAG,CAACF,CAAC,GAAGD,CAAL,IAAUC,CAApB;AACAL,IAAAA,IAAI,CAACQ,KAAL,CAAWC,eAAX,GAA6B,MAA7B;AACAN,IAAAA,IAAI,CAACK,KAAL,CAAWE,QAAX,GAAsB,QAAtB;AACAP,IAAAA,IAAI,CAACK,KAAL,CAAWG,UAAX,GAAwB,WAAxB;AACAR,IAAAA,IAAI,CAACK,KAAL,CAAWI,UAAX,GAAwB,wBAAxB;AACAT,IAAAA,IAAI,CAACK,KAAL,CAAWK,SAAX,mDAAqET,CAAC,GA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xB;AACAa,cAAc,CAACG,OAAf,GAAyBjB,YAAzB;AACAc,cAAc,CAACI,QAAf,GAA0BP,aAA1B;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),n=require("react-dom"),r=require("framer-motion"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),n=require("react-dom"),r=require("@react-aria/overlays"),o=require("framer-motion"),a=(e=require("react-merge-refs"))&&"object"==typeof e&&"default"in e?e.default:e;function i(){return(i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function s(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||(o[n]=e[n]);return o}var l="undefined"==typeof window,c=function(e,t){return e.reduce((function(e,n){return Math.abs(n-t)<Math.abs(e-t)?n:e}))};function d(e){var t=document.querySelector("body"),n=document.getElementById(e),r=document.getElementById("react-modal-sheet-highlight");n&&r&&(n.style.removeProperty("border-top-right-radius"),n.style.removeProperty("border-top-left-radius"),n.style.removeProperty("transform"),r.style.opacity="0",n.addEventListener("transitionend",(function e(){var o;n.style.removeProperty("overflow"),n.style.removeProperty("will-change"),n.style.removeProperty("transition"),t.style.removeProperty("background-color"),n.removeEventListener("transitionend",e),null==(o=r.parentNode)||o.removeChild(r)})))}var u=l?t.useEffect:t.useLayoutEffect,f=t.createContext(void 0),p=function(){var e=t.useContext(f);if(!e)throw Error("Sheet context error");return e},m=function(e){var n=t.useRef();return t.useEffect((function(){n.current=e})),n.current},y={wrapper:{position:"fixed",top:0,bottom:0,left:0,right:0,zIndex:9999999,overflow:"hidden",pointerEvents:"none"},backdrop:{zIndex:1,position:"fixed",top:0,left:0,width:"100%",height:"100%",backgroundColor:"rgba(51, 51, 51, 0.5)",touchAction:"none"},container:{zIndex:2,position:"absolute",left:0,bottom:0,width:"100%",backgroundColor:"#fff",borderTopRightRadius:"8px",borderTopLeftRadius:"8px",boxShadow:"0px -2px 16px rgba(0, 0, 0, 0.3)",display:"flex",flexDirection:"column",pointerEvents:"auto"},headerWrapper:{width:"100%"},header:{height:"40px",width:"100%",position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},indicator:{width:"18px",height:"4px",borderRadius:"99px",backgroundColor:"#ddd"},content:{flex:1,overflow:"auto",position:"relative"}},g=t.forwardRef((function(e,a){var p=e.children,g=e.isOpen,h=e.onClose,v=e.onOpenStart,b=e.onOpenEnd,E=e.onCloseStart,C=e.onCloseEnd,x=e.onSnap,w=e.snapPoints,O=e.initialSnap,S=void 0===O?0:O,P=e.rootId,R=e.mountPoint,k=e.springConfig,j=void 0===k?{stiffness:300,damping:30,mass:.2}:k,M=e.disableDrag,D=void 0!==M&&M,q=e.style,I=s(e,["children","isOpen","onClose","onOpenStart","onOpenEnd","onCloseStart","onCloseEnd","onSnap","snapPoints","initialSnap","rootId","mountPoint","springConfig","disableDrag","style"]),T=t.useRef(null),A=t.useRef({onOpenStart:v,onOpenEnd:b,onCloseStart:E,onCloseEnd:C}),L=o.useMotionValue(0),N=function(){var e=t.useState(0),n=e[0],r=e[1];return u((function(){var e=function(){return r(window.innerHeight)};return window.addEventListener("resize",e),e(),function(){return window.removeEventListener("resize",e)}}),[]),n}(),H=o.useMotionValue(0);w&&(w=w.map((function(e){return e>0&&e<=1?Math.round(e*N):e<0?N+e:e})),console.assert(function(e){for(var t=0;t<e.length;t++)if(e[t+1]>e[t])return!1;return!0}(w)||0===N,"Snap points need to be in descending order got: ["+w+"]"));var z=t.useCallback((function(e,t){var n=t.delta,r=H.getVelocity();r>0&&L.set(10),r<0&&L.set(-10),H.set(Math.max(H.get()+n.y,0))}),[]),B=t.useCallback((function(e,t){if(t.velocity.y>500)h();else{var n=T.current.getBoundingClientRect().height,r=Math.round(w?c(w.map((function(e){return n-e})),H.get()):H.get()/n>.6?n:0);if(o.animate(H,r,i({type:"spring"},j)),w&&x){var a=Math.abs(Math.round(w[0]-r)),s=w.indexOf(c(w,a));x(s)}r>=n&&h()}L.set(0)}),[h,x]);t.useEffect((function(){A.current={onOpenStart:v,onOpenEnd:b,onCloseStart:E,onCloseEnd:C}})),t.useEffect((function(){w&&x&&x(g?S:w.length-1)}),[g]),t.useImperativeHandle(a,(function(){return{y:H,snapTo:function(e){var t=T.current;if(w&&void 0!==w[e]&&null!==t){var n=t.getBoundingClientRect().height,r=n-w[e];o.animate(H,r,i({type:"spring"},j)),x&&x(e),r>=n&&h()}}}})),function(e,n){var r=m(e);t.useEffect((function(){n&&!r&&e?function(e){var t=document.querySelector("body"),n=document.querySelector("#"+e);if(n){var r=window.innerHeight,o=(r-24)/r;t.style.backgroundColor="#000",n.style.overflow="hidden",n.style.willChange="transform",n.style.transition="transform 200ms linear",n.style.transform="translateY(calc(env(safe-area-inset-top) + 12px)) scale("+o+")",n.style.borderTopRightRadius="10px",n.style.borderTopLeftRadius="10px";var a=document.createElement("div");a.setAttribute("aria-hidden","true"),a.id="react-modal-sheet-highlight",a.style.position="absolute",a.style.top="0px",a.style.left="0px",a.style.bottom="0px",a.style.right="0px",a.style.opacity="0",a.style.transition="opacity 200ms linear",a.style.backgroundColor="rgba(150, 150, 150, 0.1)",n.appendChild(a),requestAnimationFrame((function(){return a.style.opacity="1"}))}}(n):n&&!e&&r&&d(n)}),[e,r]),t.useEffect((function(){return function(){n&&e&&d(n)}}),[e])}(g,P),r.usePreventScroll({isDisabled:!g});var V={y:H,sheetRef:T,isOpen:g,initialSnap:S,snapPoints:w,indicatorRotation:L,callbacks:A,dragProps:D?{}:{drag:"y",dragElastic:0,dragConstraints:{top:0,bottom:0},dragMomentum:!1,onDrag:z,onDragEnd:B},windowHeight:N,springConfig:j},W=i({},I,{ref:a,style:i({},y.wrapper,q)}),X=t.createElement(f.Provider,{value:V},t.createElement("div",Object.assign({},W),t.createElement(o.AnimatePresence,null,g?t.Children.map(p,(function(e,n){return t.cloneElement(e,{key:"sheet-child-"+n})})):null)));return l?X:n.createPortal(X,null!=R?R:document.body)})),h="calc(100% - env(safe-area-inset-top) - 34px)",v=t.forwardRef((function(e,n){var r=e.children,l=e.style,c=void 0===l?{}:l,d=s(e,["children","style"]),u=p(),f=u.y,g=u.snapPoints,v=u.initialSnap,b=void 0===v?0:v,E=u.sheetRef,C=u.windowHeight,x=u.springConfig,w=function(e,n){var r=m(e),o=t.useRef(!1),a=t.useCallback((function(){o.current?(null==n.current.onCloseEnd||n.current.onCloseEnd(),o.current=!1):(null==n.current.onOpenEnd||n.current.onOpenEnd(),o.current=!0)}),[e,r]);return t.useEffect((function(){!r&&e?null==n.current.onOpenStart||n.current.onOpenStart():!e&&r&&(null==n.current.onCloseStart||n.current.onCloseStart())}),[e,r]),{handleAnimationComplete:a}}(u.isOpen,u.callbacks).handleAnimationComplete,O=g?g[0]-g[b]:0,S=g?g[0]:null,P=S?"min("+S+"px, "+h+")":h;return t.createElement(o.motion.div,Object.assign({},d,{ref:a([E,n]),className:"react-modal-sheet-container",style:i({},y.container,{height:P},c,{y:f}),initial:{y:C},animate:{y:O,transition:i({type:"spring"},x)},exit:{y:C},onAnimationComplete:w}),r)})),b=t.forwardRef((function(e,n){var r=e.children,a=e.disableDrag,l=void 0!==a&&a,c=e.style,d=void 0===c?{}:c,u=s(e,["children","disableDrag","style"]),f=p().dragProps;return t.createElement(o.motion.div,Object.assign({},u,{ref:n,className:"react-modal-sheet-content",style:i({},y.content,d)},l?{}:f),r)})),E=t.forwardRef((function(e,n){var r=e.children,a=e.disableDrag,l=void 0!==a&&a,c=e.style,d=void 0===c?{}:c,u=s(e,["children","disableDrag","style"]),f=p(),m=f.indicatorRotation,g=f.dragProps,h=o.useTransform(m,(function(e){return"translateX(2px) rotate("+e+"deg)"})),v=o.useTransform(m,(function(e){return"translateX(-2px) rotate("+-1*e+"deg)"}));return t.createElement(o.motion.div,Object.assign({},u,{ref:n,style:i({},y.headerWrapper,d)},l?{}:g),r||t.createElement("div",{className:"react-modal-sheet-header",style:y.header},t.createElement(o.motion.span,{className:"react-modal-sheet-drag-indicator",style:i({},y.indicator,{transform:h})}),t.createElement(o.motion.span,{className:"react-modal-sheet-drag-indicator",style:i({},y.indicator,{transform:v})})))})),C=function(e){return!!e.onClick||!!e.onTap},x=t.forwardRef((function(e,n){var r=e.style,a=void 0===r?{}:r,l=s(e,["style"]),c=C(l)?o.motion.button:o.motion.div,d=C(l)?"auto":"none";return t.createElement(c,Object.assign({},l,{ref:n,className:"react-modal-sheet-backdrop",style:i({},y.backdrop,a,{pointerEvents:d}),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}}))})),w=g;w.Container=v,w.Header=E,w.Content=b,w.Backdrop=x,exports.default=w;
|
|
2
2
|
//# sourceMappingURL=react-modal-sheet.cjs.production.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-modal-sheet.cjs.production.min.js","sources":["../src/utils.ts","../src/context.tsx","../src/hooks.tsx","../src/styles.ts","../src/sheet.tsx","../src/SheetContainer.tsx","../src/SheetContent.tsx","../src/SheetHeader.tsx","../src/SheetBackdrop.tsx","../src/index.tsx"],"sourcesContent":["import { useEffect, useLayoutEffect, useState } from 'react';\n\nexport const isSSR = typeof window === 'undefined';\n\nexport const getClosest = (nums: number[], goal: number) => {\n return nums.reduce((prev, curr) => {\n return Math.abs(curr - goal) < Math.abs(prev - goal) ? curr : prev;\n });\n};\n\nconst highlightId = 'react-modal-sheet-highlight';\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 = 'transform 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 // Add highlighed overlay to emphasize the modality effect\n const highlight = document.createElement('div');\n highlight.setAttribute('aria-hidden', 'true');\n highlight.id = highlightId;\n highlight.style.position = 'absolute';\n highlight.style.top = '0px';\n highlight.style.left = '0px';\n highlight.style.bottom = '0px';\n highlight.style.right = '0px';\n highlight.style.opacity = '0';\n highlight.style.transition = 'opacity 200ms linear';\n highlight.style.backgroundColor = 'rgba(150, 150, 150, 0.1)';\n\n root.appendChild(highlight);\n requestAnimationFrame(() => (highlight.style.opacity = '1'));\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 const highlight = document.getElementById(highlightId) 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 highlight.parentNode?.removeChild(highlight);\n }\n\n if (root && highlight) {\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 highlight.style.opacity = '0';\n\n // Remove temp properties after animation is finished\n root.addEventListener('transitionend', onTransitionEnd);\n }\n}\n\nconst useIsomorphicLayoutEffect = isSSR ? useEffect : useLayoutEffect;\n\nexport function useWindowHeight() {\n const [windowHeight, setWindowHeight] = useState(0);\n\n useIsomorphicLayoutEffect(() => {\n const updateHeight = () => setWindowHeight(window.innerHeight);\n window.addEventListener('resize', updateHeight);\n updateHeight();\n return () => window.removeEventListener('resize', updateHeight);\n }, []);\n\n return windowHeight;\n}\n\nexport const 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","import * as React from 'react';\nimport { SheetContextType } from './types';\n\nexport const SheetContext = React.createContext<SheetContextType | undefined>(\n undefined\n);\n\nexport const useSheetContext = () => {\n const context = React.useContext(SheetContext);\n if (!context) throw Error('Sheet context error');\n return context;\n};\n","import * as React from 'react';\n\nimport { SheetEvents } from './types';\nimport { applyRootStyles, cleanupRootStyles } from './utils';\n\nexport const 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 React.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 React.useEffect(() => {\n return () => {\n if (rootId && isOpen) cleanupRootStyles(rootId);\n };\n }, [isOpen]); // eslint-disable-line\n};\n\nexport const useEventCallbacks = (\n isOpen: boolean,\n callbacks: React.MutableRefObject<SheetEvents>\n) => {\n const prevOpen = usePrevious(isOpen);\n const didOpen = React.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 = React.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 React.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\nconst usePrevious = <T,>(state: T): T | undefined => {\n const ref = React.useRef<T>();\n\n React.useEffect(() => {\n ref.current = state;\n });\n\n return ref.current;\n};\n","import * as CSS from 'csstype';\n\nconst styles: { [key: string]: CSS.Properties } = {\n wrapper: {\n position: 'fixed',\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n zIndex: 9999999,\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(51, 51, 51, 0.5)',\n touchAction: 'none', // Disable iOS body scrolling\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 flex: 1,\n overflow: 'auto',\n position: 'relative',\n },\n};\n\nexport default styles;\n","import * as React from 'react';\nimport * as ReactDOM from 'react-dom';\n\nimport {\n animate,\n useMotionValue,\n PanInfo,\n AnimatePresence,\n} from 'framer-motion';\n\nimport { SheetContextType, SheetProps } from './types';\nimport { getClosest, inDescendingOrder, isSSR, useWindowHeight } from './utils';\nimport { SheetContext } from './context';\nimport { useModalEffect } from './hooks';\nimport styles from './styles';\n\nconst Sheet = React.forwardRef<any, SheetProps>(\n (\n {\n children,\n isOpen,\n onClose,\n onOpenStart,\n onOpenEnd,\n onCloseStart,\n onCloseEnd,\n onSnap,\n snapPoints,\n initialSnap = 0,\n rootId,\n mountPoint,\n springConfig = { stiffness: 300, damping: 30, mass: 0.2 },\n disableDrag = false,\n style,\n ...rest\n },\n ref\n ) => {\n const sheetRef = React.useRef<any>(null);\n const callbacks = React.useRef({ onOpenStart, onOpenEnd, onCloseStart, onCloseEnd }); // prettier-ignore\n const indicatorRotation = useMotionValue(0);\n const windowHeight = useWindowHeight();\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 if (snapPoints) {\n // Convert negative / percentage snap points to absolute values\n snapPoints = snapPoints.map(point => {\n if (point > 0 && point <= 1) return Math.round(point * windowHeight); // percentage values e.g. between 0.0 and 1.0\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}]`\n );\n }\n\n const handleDrag = React.useCallback((_, { delta }: PanInfo) => {\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(y.get() + delta.y, 0));\n }, []); // eslint-disable-line\n\n const handleDragEnd = React.useCallback(\n (_, { velocity }: PanInfo) => {\n if (velocity.y > 500) {\n // User flicked the sheet down\n onClose();\n } else {\n const sheetEl = sheetRef.current as HTMLDivElement;\n const contentHeight = sheetEl.getBoundingClientRect().height;\n const snapTo = Math.round(\n snapPoints\n ? getClosest(snapPoints.map(p => contentHeight - p), y.get()) // prettier-ignore\n : y.get() / contentHeight > 0.6 // Close if dragged over 60%\n ? contentHeight\n : 0\n );\n\n // Update the spring value so that the sheet is animated to the snap point\n animate(y, snapTo, { type: 'spring', ...springConfig });\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 if (snapTo >= contentHeight) onClose();\n }\n\n // Reset indicator rotation after dragging\n indicatorRotation.set(0);\n },\n [onClose, onSnap] // eslint-disable-line\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 React.useEffect(() => {\n callbacks.current = { onOpenStart, onOpenEnd, onCloseStart, onCloseEnd };\n });\n\n // Trigger onSnap callback when sheet is opened or closed\n React.useEffect(() => {\n if (!snapPoints || !onSnap) return;\n const snapIndex = isOpen ? initialSnap : snapPoints.length - 1;\n onSnap(snapIndex);\n }, [isOpen]); // eslint-disable-line\n\n React.useImperativeHandle(ref, () => ({\n y,\n snapTo: (snapIndex: number) => {\n const sheetEl = sheetRef.current as HTMLDivElement | null;\n if (\n snapPoints &&\n snapPoints[snapIndex] !== undefined &&\n sheetEl !== null\n ) {\n const contentHeight = sheetEl.getBoundingClientRect().height;\n const snapTo = contentHeight - snapPoints[snapIndex];\n animate(y, snapTo, { type: 'spring', ...springConfig });\n if (onSnap) onSnap(snapIndex);\n if (snapTo >= contentHeight) onClose();\n }\n },\n }));\n\n useModalEffect(isOpen, rootId);\n\n const dragProps = disableDrag\n ? ({} as any)\n : {\n drag: 'y' as const,\n dragElastic: 0,\n dragConstraints: { top: 0, bottom: 0 },\n dragMomentum: false,\n onDrag: handleDrag,\n onDragEnd: handleDragEnd,\n };\n\n const context: SheetContextType = {\n y,\n sheetRef,\n isOpen,\n initialSnap,\n snapPoints,\n indicatorRotation,\n callbacks,\n dragProps,\n windowHeight,\n springConfig,\n };\n\n const wrapperProps = {\n ...rest,\n ref,\n style: { ...styles.wrapper, ...style },\n };\n\n const sheet = (\n <SheetContext.Provider value={context}>\n <div {...wrapperProps}>\n <AnimatePresence>\n {/* NOTE: AnimatePresence requires us to set keys to children */}\n {isOpen\n ? React.Children.map(children, (child: any, i) =>\n React.cloneElement(child, { key: `sheet-child-${i}` })\n )\n : null}\n </AnimatePresence>\n </div>\n </SheetContext.Provider>\n );\n\n if (isSSR) return sheet;\n\n return ReactDOM.createPortal(sheet, mountPoint ?? document.body);\n }\n);\n\nexport default Sheet;\n","import * as React from 'react';\nimport { motion } from 'framer-motion';\nimport mergeRefs from 'react-merge-refs';\n\nimport { SheetContainerProps } from './types';\nimport { useSheetContext } from './context';\nimport { useEventCallbacks } from './hooks';\nimport styles from './styles';\n\nconst MAX_HEIGHT = 'calc(100% - env(safe-area-inset-top) - 34px)';\n\nconst SheetContainer = React.forwardRef<any, SheetContainerProps>(\n ({ children, style = {}, ...rest }, ref) => {\n const {\n y,\n isOpen,\n callbacks,\n snapPoints,\n initialSnap = 0,\n sheetRef,\n windowHeight,\n springConfig,\n } = useSheetContext();\n\n const { handleAnimationComplete } = useEventCallbacks(isOpen, callbacks);\n const initialY = snapPoints ? snapPoints[0] - snapPoints[initialSnap] : 0;\n const h = snapPoints ? snapPoints[0] : null;\n const sheetHeight = h ? `min(${h}px, ${MAX_HEIGHT})` : MAX_HEIGHT;\n\n return (\n <motion.div\n {...rest}\n ref={mergeRefs([sheetRef, ref])}\n className=\"react-modal-sheet-container\"\n style={{ ...styles.container, height: sheetHeight, ...style, y }}\n initial={{ y: windowHeight }}\n animate={{\n y: initialY,\n transition: { type: 'spring', ...springConfig },\n }}\n exit={{ y: windowHeight }}\n onAnimationComplete={handleAnimationComplete}\n >\n {children}\n </motion.div>\n );\n }\n);\n\nexport default SheetContainer;\n","import * as React from 'react';\nimport { motion } from 'framer-motion';\n\nimport { SheetDraggableProps } from './types';\nimport styles from './styles';\nimport { useSheetContext } from './context';\n\nconst SheetContent = React.forwardRef<any, SheetDraggableProps>(\n ({ children, disableDrag = false, style = {}, ...rest }, ref) => {\n const { dragProps } = useSheetContext();\n\n return (\n <motion.div\n {...rest}\n ref={ref}\n className=\"react-modal-sheet-content\"\n style={{ ...styles.content, ...style }}\n {...(disableDrag ? {} : dragProps)}\n >\n {children}\n </motion.div>\n );\n }\n);\n\nexport default SheetContent;\n","import * as React from 'react';\nimport { motion, useTransform } from 'framer-motion';\n\nimport { SheetDraggableProps } from './types';\nimport { useSheetContext } from './context';\nimport styles from './styles';\n\nconst SheetHeader = React.forwardRef<any, SheetDraggableProps>(\n ({ children, disableDrag = false, style = {}, ...rest }, ref) => {\n const { indicatorRotation, dragProps } = useSheetContext();\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={ref}\n style={{ ...styles.headerWrapper, ...style }}\n {...(disableDrag ? {} : dragProps)}\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\nexport default SheetHeader;\n","import * as React from 'react';\nimport { motion } from 'framer-motion';\n\nimport { SheetBackdropProps } from './types';\nimport styles from './styles';\n\nconst isClickable = (props: any) => !!props.onClick || !!props.onTap;\n\nconst SheetBackdrop = React.forwardRef<any, SheetBackdropProps>(\n ({ style = {}, ...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\"\n style={{ ...styles.backdrop, ...style, pointerEvents }}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n />\n );\n }\n);\n\nexport default SheetBackdrop;\n","import { 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 { SheetCompound } from './types';\n\nexport type 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\nexport default _SheetCompound as SheetCompound;\n"],"names":["isSSR","window","getClosest","nums","goal","reduce","prev","curr","Math","abs","cleanupRootStyles","rootId","body","document","querySelector","root","getElementById","highlight","style","removeProperty","opacity","addEventListener","onTransitionEnd","removeEventListener","parentNode","removeChild","useIsomorphicLayoutEffect","useEffect","useLayoutEffect","SheetContext","React","undefined","useSheetContext","context","Error","usePrevious","state","ref","current","styles","wrapper","position","top","bottom","left","right","zIndex","overflow","pointerEvents","backdrop","width","height","backgroundColor","touchAction","container","borderTopRightRadius","borderTopLeftRadius","boxShadow","display","flexDirection","headerWrapper","header","alignItems","justifyContent","indicator","borderRadius","content","flex","Sheet","children","isOpen","onClose","onOpenStart","onOpenEnd","onCloseStart","onCloseEnd","onSnap","snapPoints","initialSnap","mountPoint","springConfig","stiffness","damping","mass","disableDrag","rest","sheetRef","callbacks","indicatorRotation","useMotionValue","windowHeight","useState","setWindowHeight","updateHeight","innerHeight","useWindowHeight","y","map","point","round","console","assert","arr","i","length","inDescendingOrder","handleDrag","_","delta","velocity","getVelocity","set","max","get","handleDragEnd","contentHeight","getBoundingClientRect","snapTo","p","animate","type","snapValue","snapIndex","indexOf","sheetEl","prevOpen","h","s","willChange","transition","transform","createElement","setAttribute","id","appendChild","requestAnimationFrame","applyRootStyles","useModalEffect","dragProps","drag","dragElastic","dragConstraints","dragMomentum","onDrag","onDragEnd","wrapperProps","sheet","Provider","value","AnimatePresence","child","key","ReactDOM","MAX_HEIGHT","SheetContainer","handleAnimationComplete","didOpen","useEventCallbacks","initialY","sheetHeight","motion","div","mergeRefs","className","initial","exit","onAnimationComplete","SheetContent","SheetHeader","indicator1Transform","useTransform","r","indicator2Transform","span","isClickable","props","onClick","onTap","SheetBackdrop","Comp","button","_SheetCompound","Container","Header","Content","Backdrop"],"mappings":"mjBAEO,IAAMA,EAA0B,oBAAXC,OAEfC,EAAa,SAACC,EAAgBC,UAClCD,EAAKE,QAAO,SAACC,EAAMC,UACjBC,KAAKC,IAAIF,EAAOH,GAAQI,KAAKC,IAA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IAAKA,EACL8H,UAAU,6BACVjJ,WAAYqB,EAAOU,SAAa/B,GAAO8B,cAAAA,IACvCoH,QAAS,CAAEhJ,QAAS,GACpBmG,QAAS,CAAEnG,QAAS,GACpBiJ,KAAM,CAAEjJ,QAAS,SCNnBiK,EAAsBjH,EAC5BiH,EAAeC,UAAY5B,EAC3B2B,EAAeE,OAASf,EACxBa,EAAeG,QAAUjB,EACzBc,EAAeI,SAAWP"}
|
|
1
|
+
{"version":3,"file":"react-modal-sheet.cjs.production.min.js","sources":["../src/utils.ts","../src/context.tsx","../src/hooks.tsx","../src/styles.ts","../src/sheet.tsx","../src/SheetContainer.tsx","../src/SheetContent.tsx","../src/SheetHeader.tsx","../src/SheetBackdrop.tsx","../src/index.tsx"],"sourcesContent":["import { useEffect, useLayoutEffect, useState } from 'react';\n\nexport const isSSR = typeof window === 'undefined';\n\nexport const getClosest = (nums: number[], goal: number) => {\n return nums.reduce((prev, curr) => {\n return Math.abs(curr - goal) < Math.abs(prev - goal) ? curr : prev;\n });\n};\n\nconst highlightId = 'react-modal-sheet-highlight';\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 = 'transform 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 // Add highlighed overlay to emphasize the modality effect\n const highlight = document.createElement('div');\n highlight.setAttribute('aria-hidden', 'true');\n highlight.id = highlightId;\n highlight.style.position = 'absolute';\n highlight.style.top = '0px';\n highlight.style.left = '0px';\n highlight.style.bottom = '0px';\n highlight.style.right = '0px';\n highlight.style.opacity = '0';\n highlight.style.transition = 'opacity 200ms linear';\n highlight.style.backgroundColor = 'rgba(150, 150, 150, 0.1)';\n\n root.appendChild(highlight);\n requestAnimationFrame(() => (highlight.style.opacity = '1'));\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 const highlight = document.getElementById(highlightId) 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 highlight.parentNode?.removeChild(highlight);\n }\n\n if (root && highlight) {\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 highlight.style.opacity = '0';\n\n // Remove temp properties after animation is finished\n root.addEventListener('transitionend', onTransitionEnd);\n }\n}\n\nconst useIsomorphicLayoutEffect = isSSR ? useEffect : useLayoutEffect;\n\nexport function useWindowHeight() {\n const [windowHeight, setWindowHeight] = useState(0);\n\n useIsomorphicLayoutEffect(() => {\n const updateHeight = () => setWindowHeight(window.innerHeight);\n window.addEventListener('resize', updateHeight);\n updateHeight();\n return () => window.removeEventListener('resize', updateHeight);\n }, []);\n\n return windowHeight;\n}\n\nexport const 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","import * as React from 'react';\nimport { SheetContextType } from './types';\n\nexport const SheetContext = React.createContext<SheetContextType | undefined>(\n undefined\n);\n\nexport const useSheetContext = () => {\n const context = React.useContext(SheetContext);\n if (!context) throw Error('Sheet context error');\n return context;\n};\n","import * as React from 'react';\n\nimport { SheetEvents } from './types';\nimport { applyRootStyles, cleanupRootStyles } from './utils';\n\nexport const 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 React.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 React.useEffect(() => {\n return () => {\n if (rootId && isOpen) cleanupRootStyles(rootId);\n };\n }, [isOpen]); // eslint-disable-line\n};\n\nexport const useEventCallbacks = (\n isOpen: boolean,\n callbacks: React.MutableRefObject<SheetEvents>\n) => {\n const prevOpen = usePrevious(isOpen);\n const didOpen = React.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 = React.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 React.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\nconst usePrevious = <T,>(state: T): T | undefined => {\n const ref = React.useRef<T>();\n\n React.useEffect(() => {\n ref.current = state;\n });\n\n return ref.current;\n};\n","import * as CSS from 'csstype';\n\nconst styles: { [key: string]: CSS.Properties } = {\n wrapper: {\n position: 'fixed',\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n zIndex: 9999999,\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(51, 51, 51, 0.5)',\n touchAction: 'none', // Disable iOS body scrolling\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 flex: 1,\n overflow: 'auto',\n position: 'relative',\n },\n};\n\nexport default styles;\n","import * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport { usePreventScroll } from '@react-aria/overlays';\n\nimport {\n animate,\n useMotionValue,\n PanInfo,\n AnimatePresence,\n} from 'framer-motion';\n\nimport { SheetContextType, SheetProps } from './types';\nimport { getClosest, inDescendingOrder, isSSR, useWindowHeight } from './utils';\nimport { SheetContext } from './context';\nimport { useModalEffect } from './hooks';\nimport styles from './styles';\n\nconst Sheet = React.forwardRef<any, SheetProps>(\n (\n {\n children,\n isOpen,\n onClose,\n onOpenStart,\n onOpenEnd,\n onCloseStart,\n onCloseEnd,\n onSnap,\n snapPoints,\n initialSnap = 0,\n rootId,\n mountPoint,\n springConfig = { stiffness: 300, damping: 30, mass: 0.2 },\n disableDrag = false,\n style,\n ...rest\n },\n ref\n ) => {\n const sheetRef = React.useRef<any>(null);\n const callbacks = React.useRef({ onOpenStart, onOpenEnd, onCloseStart, onCloseEnd }); // prettier-ignore\n const indicatorRotation = useMotionValue(0);\n const windowHeight = useWindowHeight();\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 if (snapPoints) {\n // Convert negative / percentage snap points to absolute values\n snapPoints = snapPoints.map(point => {\n if (point > 0 && point <= 1) return Math.round(point * windowHeight); // percentage values e.g. between 0.0 and 1.0\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}]`\n );\n }\n\n const handleDrag = React.useCallback((_, { delta }: PanInfo) => {\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(y.get() + delta.y, 0));\n }, []); // eslint-disable-line\n\n const handleDragEnd = React.useCallback(\n (_, { velocity }: PanInfo) => {\n if (velocity.y > 500) {\n // User flicked the sheet down\n onClose();\n } else {\n const sheetEl = sheetRef.current as HTMLDivElement;\n const contentHeight = sheetEl.getBoundingClientRect().height;\n const snapTo = Math.round(\n snapPoints\n ? getClosest(snapPoints.map(p => contentHeight - p), y.get()) // prettier-ignore\n : y.get() / contentHeight > 0.6 // Close if dragged over 60%\n ? contentHeight\n : 0\n );\n\n // Update the spring value so that the sheet is animated to the snap point\n animate(y, snapTo, { type: 'spring', ...springConfig });\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 if (snapTo >= contentHeight) onClose();\n }\n\n // Reset indicator rotation after dragging\n indicatorRotation.set(0);\n },\n [onClose, onSnap] // eslint-disable-line\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 React.useEffect(() => {\n callbacks.current = { onOpenStart, onOpenEnd, onCloseStart, onCloseEnd };\n });\n\n // Trigger onSnap callback when sheet is opened or closed\n React.useEffect(() => {\n if (!snapPoints || !onSnap) return;\n const snapIndex = isOpen ? initialSnap : snapPoints.length - 1;\n onSnap(snapIndex);\n }, [isOpen]); // eslint-disable-line\n\n React.useImperativeHandle(ref, () => ({\n y,\n snapTo: (snapIndex: number) => {\n const sheetEl = sheetRef.current as HTMLDivElement | null;\n if (\n snapPoints &&\n snapPoints[snapIndex] !== undefined &&\n sheetEl !== null\n ) {\n const contentHeight = sheetEl.getBoundingClientRect().height;\n const snapTo = contentHeight - snapPoints[snapIndex];\n animate(y, snapTo, { type: 'spring', ...springConfig });\n if (onSnap) onSnap(snapIndex);\n if (snapTo >= contentHeight) 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: !isOpen });\n\n const dragProps = disableDrag\n ? ({} as any)\n : {\n drag: 'y' as const,\n dragElastic: 0,\n dragConstraints: { top: 0, bottom: 0 },\n dragMomentum: false,\n onDrag: handleDrag,\n onDragEnd: handleDragEnd,\n };\n\n const context: SheetContextType = {\n y,\n sheetRef,\n isOpen,\n initialSnap,\n snapPoints,\n indicatorRotation,\n callbacks,\n dragProps,\n windowHeight,\n springConfig,\n };\n\n const wrapperProps = {\n ...rest,\n ref,\n style: { ...styles.wrapper, ...style },\n };\n\n const sheet = (\n <SheetContext.Provider value={context}>\n <div {...wrapperProps}>\n <AnimatePresence>\n {/* NOTE: AnimatePresence requires us to set keys to children */}\n {isOpen\n ? React.Children.map(children, (child: any, i) =>\n React.cloneElement(child, { key: `sheet-child-${i}` })\n )\n : null}\n </AnimatePresence>\n </div>\n </SheetContext.Provider>\n );\n\n if (isSSR) return sheet;\n\n return ReactDOM.createPortal(sheet, mountPoint ?? document.body);\n }\n);\n\nexport default Sheet;\n","import * as React from 'react';\nimport { motion } from 'framer-motion';\nimport mergeRefs from 'react-merge-refs';\n\nimport { SheetContainerProps } from './types';\nimport { useSheetContext } from './context';\nimport { useEventCallbacks } from './hooks';\nimport styles from './styles';\n\nconst MAX_HEIGHT = 'calc(100% - env(safe-area-inset-top) - 34px)';\n\nconst SheetContainer = React.forwardRef<any, SheetContainerProps>(\n ({ children, style = {}, ...rest }, ref) => {\n const {\n y,\n isOpen,\n callbacks,\n snapPoints,\n initialSnap = 0,\n sheetRef,\n windowHeight,\n springConfig,\n } = useSheetContext();\n\n const { handleAnimationComplete } = useEventCallbacks(isOpen, callbacks);\n const initialY = snapPoints ? snapPoints[0] - snapPoints[initialSnap] : 0;\n const h = snapPoints ? snapPoints[0] : null;\n const sheetHeight = h ? `min(${h}px, ${MAX_HEIGHT})` : MAX_HEIGHT;\n\n return (\n <motion.div\n {...rest}\n ref={mergeRefs([sheetRef, ref])}\n className=\"react-modal-sheet-container\"\n style={{\n ...styles.container,\n height: sheetHeight,\n ...style,\n y,\n }}\n initial={{ y: windowHeight }}\n animate={{\n y: initialY,\n transition: { type: 'spring', ...springConfig },\n }}\n exit={{ y: windowHeight }}\n onAnimationComplete={handleAnimationComplete}\n >\n {children}\n </motion.div>\n );\n }\n);\n\nexport default SheetContainer;\n","import * as React from 'react';\nimport { motion } from 'framer-motion';\n\nimport { SheetDraggableProps } from './types';\nimport styles from './styles';\nimport { useSheetContext } from './context';\n\nconst SheetContent = React.forwardRef<any, SheetDraggableProps>(\n ({ children, disableDrag = false, style = {}, ...rest }, ref) => {\n const { dragProps } = useSheetContext();\n\n return (\n <motion.div\n {...rest}\n ref={ref}\n className=\"react-modal-sheet-content\"\n style={{ ...styles.content, ...style }}\n {...(disableDrag ? {} : dragProps)}\n >\n {children}\n </motion.div>\n );\n }\n);\n\nexport default SheetContent;\n","import * as React from 'react';\nimport { motion, useTransform } from 'framer-motion';\n\nimport { SheetDraggableProps } from './types';\nimport { useSheetContext } from './context';\nimport styles from './styles';\n\nconst SheetHeader = React.forwardRef<any, SheetDraggableProps>(\n ({ children, disableDrag = false, style = {}, ...rest }, ref) => {\n const { indicatorRotation, dragProps } = useSheetContext();\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={ref}\n style={{ ...styles.headerWrapper, ...style }}\n {...(disableDrag ? {} : dragProps)}\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\nexport default SheetHeader;\n","import * as React from 'react';\nimport { motion } from 'framer-motion';\n\nimport { SheetBackdropProps } from './types';\nimport styles from './styles';\n\nconst isClickable = (props: any) => !!props.onClick || !!props.onTap;\n\nconst SheetBackdrop = React.forwardRef<any, SheetBackdropProps>(\n ({ style = {}, ...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\"\n style={{ ...styles.backdrop, ...style, pointerEvents }}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n />\n );\n }\n);\n\nexport default SheetBackdrop;\n","import { 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 { SheetCompound } from './types';\n\nexport type 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\nexport default _SheetCompound as SheetCompound;\n"],"names":["isSSR","window","getClosest","nums","goal","reduce","prev","curr","Math","abs","cleanupRootStyles","rootId","body","document","querySelector","root","getElementById","highlight","style","removeProperty","opacity","addEventListener","onTransitionEnd","removeEventListener","parentNode","removeChild","useIsomorphicLayoutEffect","useEffect","useLayoutEffect","SheetContext","React","undefined","useSheetContext","context","Error","usePrevious","state","ref","current","styles","wrapper","position","top","bottom","left","right","zIndex","overflow","pointerEvents","backdrop","width","height","backgroundColor","touchAction","container","borderTopRightRadius","borderTopLeftRadius","boxShadow","display","flexDirection","headerWrapper","header","alignItems","justifyContent","indicator","borderRadius","content","flex","Sheet","children","isOpen","onClose","onOpenStart","onOpenEnd","onCloseStart","onCloseEnd","onSnap","snapPoints","initialSnap","mountPoint","springConfig","stiffness","damping","mass","disableDrag","rest","sheetRef","callbacks","indicatorRotation","useMotionValue","windowHeight","useState","setWindowHeight","updateHeight","innerHeight","useWindowHeight","y","map","point","round","console","assert","arr","i","length","inDescendingOrder","handleDrag","_","delta","velocity","getVelocity","set","max","get","handleDragEnd","contentHeight","getBoundingClientRect","snapTo","p","animate","type","snapValue","snapIndex","indexOf","sheetEl","prevOpen","h","s","willChange","transition","transform","createElement","setAttribute","id","appendChild","requestAnimationFrame","applyRootStyles","useModalEffect","usePreventScroll","isDisabled","dragProps","drag","dragElastic","dragConstraints","dragMomentum","onDrag","onDragEnd","wrapperProps","sheet","Provider","value","AnimatePresence","child","key","ReactDOM","MAX_HEIGHT","SheetContainer","handleAnimationComplete","didOpen","useEventCallbacks","initialY","sheetHeight","motion","div","mergeRefs","className","initial","exit","onAnimationComplete","SheetContent","SheetHeader","indicator1Transform","useTransform","r","indicator2Transform","span","isClickable","props","onClick","onTap","SheetBackdrop","Comp","button","_SheetCompound","Container","Header","Content","Backdrop"],"mappings":"qlBAEO,IAAMA,EAA0B,oBAAXC,OAEfC,EAAa,SAACC,EAAgBC,UAClCD,EAAKE,QAAO,SAACC,EAAMC,UACjBC,KAAKC,IAAIF,EAAOH,GAAQI,KAAKC,IAAIH,EAAOF,GAAQG,EAAOD,eAwClDI,EAAkBC,OAC1BC,EAAOC,SAASC,cAAc,QAC9BC,EAAOF,SAASG,eAAeL,GAC/BM,EAAYJ,SAASG,eAvCT,+BAkDdD,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AS,CAAEnG,QAAS,GACpBmJ,KAAM,CAAEnJ,QAAS,SCNnBmK,EAAsBnH,EAC5BmH,EAAeC,UAAY5B,EAC3B2B,EAAeE,OAASf,EACxBa,EAAeG,QAAUjB,EACzBc,EAAeI,SAAWP"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useState, useEffect, useLayoutEffect, createContext, useContext, useRef, useCallback, forwardRef, useImperativeHandle, createElement, Children, cloneElement } from 'react';
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
|
+
import { usePreventScroll } from '@react-aria/overlays';
|
|
3
4
|
import { useMotionValue, animate, AnimatePresence, motion, useTransform } from 'framer-motion';
|
|
4
5
|
import mergeRefs from 'react-merge-refs';
|
|
5
6
|
|
|
@@ -379,7 +380,12 @@ var Sheet = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
379
380
|
}
|
|
380
381
|
};
|
|
381
382
|
});
|
|
382
|
-
useModalEffect(isOpen, rootId);
|
|
383
|
+
useModalEffect(isOpen, rootId); // Framer Motion should handle body scroll locking but it's not working
|
|
384
|
+
// properly on iOS. Scroll locking from React Aria seems to work much better.
|
|
385
|
+
|
|
386
|
+
usePreventScroll({
|
|
387
|
+
isDisabled: !isOpen
|
|
388
|
+
});
|
|
383
389
|
var dragProps = disableDrag ? {} : {
|
|
384
390
|
drag: 'y',
|
|
385
391
|
dragElastic: 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-modal-sheet.esm.js","sources":["../src/utils.ts","../src/context.tsx","../src/hooks.tsx","../src/styles.ts","../src/sheet.tsx","../src/SheetContainer.tsx","../src/SheetContent.tsx","../src/SheetHeader.tsx","../src/SheetBackdrop.tsx","../src/index.tsx"],"sourcesContent":["import { useEffect, useLayoutEffect, useState } from 'react';\n\nexport const isSSR = typeof window === 'undefined';\n\nexport const getClosest = (nums: number[], goal: number) => {\n return nums.reduce((prev, curr) => {\n return Math.abs(curr - goal) < Math.abs(prev - goal) ? curr : prev;\n });\n};\n\nconst highlightId = 'react-modal-sheet-highlight';\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 = 'transform 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 // Add highlighed overlay to emphasize the modality effect\n const highlight = document.createElement('div');\n highlight.setAttribute('aria-hidden', 'true');\n highlight.id = highlightId;\n highlight.style.position = 'absolute';\n highlight.style.top = '0px';\n highlight.style.left = '0px';\n highlight.style.bottom = '0px';\n highlight.style.right = '0px';\n highlight.style.opacity = '0';\n highlight.style.transition = 'opacity 200ms linear';\n highlight.style.backgroundColor = 'rgba(150, 150, 150, 0.1)';\n\n root.appendChild(highlight);\n requestAnimationFrame(() => (highlight.style.opacity = '1'));\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 const highlight = document.getElementById(highlightId) 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 highlight.parentNode?.removeChild(highlight);\n }\n\n if (root && highlight) {\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 highlight.style.opacity = '0';\n\n // Remove temp properties after animation is finished\n root.addEventListener('transitionend', onTransitionEnd);\n }\n}\n\nconst useIsomorphicLayoutEffect = isSSR ? useEffect : useLayoutEffect;\n\nexport function useWindowHeight() {\n const [windowHeight, setWindowHeight] = useState(0);\n\n useIsomorphicLayoutEffect(() => {\n const updateHeight = () => setWindowHeight(window.innerHeight);\n window.addEventListener('resize', updateHeight);\n updateHeight();\n return () => window.removeEventListener('resize', updateHeight);\n }, []);\n\n return windowHeight;\n}\n\nexport const 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","import * as React from 'react';\nimport { SheetContextType } from './types';\n\nexport const SheetContext = React.createContext<SheetContextType | undefined>(\n undefined\n);\n\nexport const useSheetContext = () => {\n const context = React.useContext(SheetContext);\n if (!context) throw Error('Sheet context error');\n return context;\n};\n","import * as React from 'react';\n\nimport { SheetEvents } from './types';\nimport { applyRootStyles, cleanupRootStyles } from './utils';\n\nexport const 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 React.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 React.useEffect(() => {\n return () => {\n if (rootId && isOpen) cleanupRootStyles(rootId);\n };\n }, [isOpen]); // eslint-disable-line\n};\n\nexport const useEventCallbacks = (\n isOpen: boolean,\n callbacks: React.MutableRefObject<SheetEvents>\n) => {\n const prevOpen = usePrevious(isOpen);\n const didOpen = React.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 = React.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 React.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\nconst usePrevious = <T,>(state: T): T | undefined => {\n const ref = React.useRef<T>();\n\n React.useEffect(() => {\n ref.current = state;\n });\n\n return ref.current;\n};\n","import * as CSS from 'csstype';\n\nconst styles: { [key: string]: CSS.Properties } = {\n wrapper: {\n position: 'fixed',\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n zIndex: 9999999,\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(51, 51, 51, 0.5)',\n touchAction: 'none', // Disable iOS body scrolling\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 flex: 1,\n overflow: 'auto',\n position: 'relative',\n },\n};\n\nexport default styles;\n","import * as React from 'react';\nimport * as ReactDOM from 'react-dom';\n\nimport {\n animate,\n useMotionValue,\n PanInfo,\n AnimatePresence,\n} from 'framer-motion';\n\nimport { SheetContextType, SheetProps } from './types';\nimport { getClosest, inDescendingOrder, isSSR, useWindowHeight } from './utils';\nimport { SheetContext } from './context';\nimport { useModalEffect } from './hooks';\nimport styles from './styles';\n\nconst Sheet = React.forwardRef<any, SheetProps>(\n (\n {\n children,\n isOpen,\n onClose,\n onOpenStart,\n onOpenEnd,\n onCloseStart,\n onCloseEnd,\n onSnap,\n snapPoints,\n initialSnap = 0,\n rootId,\n mountPoint,\n springConfig = { stiffness: 300, damping: 30, mass: 0.2 },\n disableDrag = false,\n style,\n ...rest\n },\n ref\n ) => {\n const sheetRef = React.useRef<any>(null);\n const callbacks = React.useRef({ onOpenStart, onOpenEnd, onCloseStart, onCloseEnd }); // prettier-ignore\n const indicatorRotation = useMotionValue(0);\n const windowHeight = useWindowHeight();\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 if (snapPoints) {\n // Convert negative / percentage snap points to absolute values\n snapPoints = snapPoints.map(point => {\n if (point > 0 && point <= 1) return Math.round(point * windowHeight); // percentage values e.g. between 0.0 and 1.0\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}]`\n );\n }\n\n const handleDrag = React.useCallback((_, { delta }: PanInfo) => {\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(y.get() + delta.y, 0));\n }, []); // eslint-disable-line\n\n const handleDragEnd = React.useCallback(\n (_, { velocity }: PanInfo) => {\n if (velocity.y > 500) {\n // User flicked the sheet down\n onClose();\n } else {\n const sheetEl = sheetRef.current as HTMLDivElement;\n const contentHeight = sheetEl.getBoundingClientRect().height;\n const snapTo = Math.round(\n snapPoints\n ? getClosest(snapPoints.map(p => contentHeight - p), y.get()) // prettier-ignore\n : y.get() / contentHeight > 0.6 // Close if dragged over 60%\n ? contentHeight\n : 0\n );\n\n // Update the spring value so that the sheet is animated to the snap point\n animate(y, snapTo, { type: 'spring', ...springConfig });\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 if (snapTo >= contentHeight) onClose();\n }\n\n // Reset indicator rotation after dragging\n indicatorRotation.set(0);\n },\n [onClose, onSnap] // eslint-disable-line\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 React.useEffect(() => {\n callbacks.current = { onOpenStart, onOpenEnd, onCloseStart, onCloseEnd };\n });\n\n // Trigger onSnap callback when sheet is opened or closed\n React.useEffect(() => {\n if (!snapPoints || !onSnap) return;\n const snapIndex = isOpen ? initialSnap : snapPoints.length - 1;\n onSnap(snapIndex);\n }, [isOpen]); // eslint-disable-line\n\n React.useImperativeHandle(ref, () => ({\n y,\n snapTo: (snapIndex: number) => {\n const sheetEl = sheetRef.current as HTMLDivElement | null;\n if (\n snapPoints &&\n snapPoints[snapIndex] !== undefined &&\n sheetEl !== null\n ) {\n const contentHeight = sheetEl.getBoundingClientRect().height;\n const snapTo = contentHeight - snapPoints[snapIndex];\n animate(y, snapTo, { type: 'spring', ...springConfig });\n if (onSnap) onSnap(snapIndex);\n if (snapTo >= contentHeight) onClose();\n }\n },\n }));\n\n useModalEffect(isOpen, rootId);\n\n const dragProps = disableDrag\n ? ({} as any)\n : {\n drag: 'y' as const,\n dragElastic: 0,\n dragConstraints: { top: 0, bottom: 0 },\n dragMomentum: false,\n onDrag: handleDrag,\n onDragEnd: handleDragEnd,\n };\n\n const context: SheetContextType = {\n y,\n sheetRef,\n isOpen,\n initialSnap,\n snapPoints,\n indicatorRotation,\n callbacks,\n dragProps,\n windowHeight,\n springConfig,\n };\n\n const wrapperProps = {\n ...rest,\n ref,\n style: { ...styles.wrapper, ...style },\n };\n\n const sheet = (\n <SheetContext.Provider value={context}>\n <div {...wrapperProps}>\n <AnimatePresence>\n {/* NOTE: AnimatePresence requires us to set keys to children */}\n {isOpen\n ? React.Children.map(children, (child: any, i) =>\n React.cloneElement(child, { key: `sheet-child-${i}` })\n )\n : null}\n </AnimatePresence>\n </div>\n </SheetContext.Provider>\n );\n\n if (isSSR) return sheet;\n\n return ReactDOM.createPortal(sheet, mountPoint ?? document.body);\n }\n);\n\nexport default Sheet;\n","import * as React from 'react';\nimport { motion } from 'framer-motion';\nimport mergeRefs from 'react-merge-refs';\n\nimport { SheetContainerProps } from './types';\nimport { useSheetContext } from './context';\nimport { useEventCallbacks } from './hooks';\nimport styles from './styles';\n\nconst MAX_HEIGHT = 'calc(100% - env(safe-area-inset-top) - 34px)';\n\nconst SheetContainer = React.forwardRef<any, SheetContainerProps>(\n ({ children, style = {}, ...rest }, ref) => {\n const {\n y,\n isOpen,\n callbacks,\n snapPoints,\n initialSnap = 0,\n sheetRef,\n windowHeight,\n springConfig,\n } = useSheetContext();\n\n const { handleAnimationComplete } = useEventCallbacks(isOpen, callbacks);\n const initialY = snapPoints ? snapPoints[0] - snapPoints[initialSnap] : 0;\n const h = snapPoints ? snapPoints[0] : null;\n const sheetHeight = h ? `min(${h}px, ${MAX_HEIGHT})` : MAX_HEIGHT;\n\n return (\n <motion.div\n {...rest}\n ref={mergeRefs([sheetRef, ref])}\n className=\"react-modal-sheet-container\"\n style={{ ...styles.container, height: sheetHeight, ...style, y }}\n initial={{ y: windowHeight }}\n animate={{\n y: initialY,\n transition: { type: 'spring', ...springConfig },\n }}\n exit={{ y: windowHeight }}\n onAnimationComplete={handleAnimationComplete}\n >\n {children}\n </motion.div>\n );\n }\n);\n\nexport default SheetContainer;\n","import * as React from 'react';\nimport { motion } from 'framer-motion';\n\nimport { SheetDraggableProps } from './types';\nimport styles from './styles';\nimport { useSheetContext } from './context';\n\nconst SheetContent = React.forwardRef<any, SheetDraggableProps>(\n ({ children, disableDrag = false, style = {}, ...rest }, ref) => {\n const { dragProps } = useSheetContext();\n\n return (\n <motion.div\n {...rest}\n ref={ref}\n className=\"react-modal-sheet-content\"\n style={{ ...styles.content, ...style }}\n {...(disableDrag ? {} : dragProps)}\n >\n {children}\n </motion.div>\n );\n }\n);\n\nexport default SheetContent;\n","import * as React from 'react';\nimport { motion, useTransform } from 'framer-motion';\n\nimport { SheetDraggableProps } from './types';\nimport { useSheetContext } from './context';\nimport styles from './styles';\n\nconst SheetHeader = React.forwardRef<any, SheetDraggableProps>(\n ({ children, disableDrag = false, style = {}, ...rest }, ref) => {\n const { indicatorRotation, dragProps } = useSheetContext();\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={ref}\n style={{ ...styles.headerWrapper, ...style }}\n {...(disableDrag ? {} : dragProps)}\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\nexport default SheetHeader;\n","import * as React from 'react';\nimport { motion } from 'framer-motion';\n\nimport { SheetBackdropProps } from './types';\nimport styles from './styles';\n\nconst isClickable = (props: any) => !!props.onClick || !!props.onTap;\n\nconst SheetBackdrop = React.forwardRef<any, SheetBackdropProps>(\n ({ style = {}, ...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\"\n style={{ ...styles.backdrop, ...style, pointerEvents }}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n />\n );\n }\n);\n\nexport default SheetBackdrop;\n","import { 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 { SheetCompound } from './types';\n\nexport type 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\nexport default _SheetCompound as SheetCompound;\n"],"names":["isSSR","window","getClosest","nums","goal","reduce","prev","curr","Math","abs","highlightId","applyRootStyles","rootId","body","document","querySelector","root","p","h","innerHeight","s","style","backgroundColor","overflow","willChange","transition","transform","borderTopRightRadius","borderTopLeftRadius","highlight","createElement","setAttribute","id","position","top","left","bottom","right","opacity","appendChild","requestAnimationFrame","cleanupRootStyles","getElementById","onTransitionEnd","removeProperty","removeEventListener","parentNode","removeChild","addEventListener","useIsomorphicLayoutEffect","useEffect","useLayoutEffect","useWindowHeight","useState","windowHeight","setWindowHeight","updateHeight","inDescendingOrder","arr","i","length","SheetContext","React","undefined","useSheetContext","context","Error","useModalEffect","isOpen","prevOpen","usePrevious","useEventCallbacks","callbacks","didOpen","handleAnimationComplete","current","onOpenEnd","onCloseEnd","onOpenStart","onCloseStart","state","ref","styles","wrapper","zIndex","pointerEvents","backdrop","width","height","touchAction","container","boxShadow","display","flexDirection","headerWrapper","header","alignItems","justifyContent","indicator","borderRadius","content","flex","Sheet","children","onClose","onSnap","snapPoints","initialSnap","mountPoint","springConfig","stiffness","damping","mass","disableDrag","rest","sheetRef","indicatorRotation","useMotionValue","y","map","point","round","console","assert","handleDrag","_","delta","velocity","getVelocity","set","max","get","handleDragEnd","sheetEl","contentHeight","getBoundingClientRect","snapTo","animate","type","snapValue","snapIndex","indexOf","dragProps","drag","dragElastic","dragConstraints","dragMomentum","onDrag","onDragEnd","wrapperProps","sheet","Provider","value","AnimatePresence","child","key","ReactDOM","MAX_HEIGHT","SheetContainer","initialY","sheetHeight","motion","div","mergeRefs","className","initial","exit","onAnimationComplete","SheetContent","SheetHeader","indicator1Transform","useTransform","r","indicator2Transform","span","isClickable","props","onClick","onTap","SheetBackdrop","Comp","button","_SheetCompound","Container","Header","Content","Backdrop"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,IAAMA,KAAK,GAAG,OAAOC,MAAP,KAAkB,WAAhC;AAEA,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAACC,IAAD,EAAiBC,IAAjB;AACxB,SAAOD,IAAI,CAACE,MAAL,CAAY,UAACC,IAAD,EAAOC,IAAP;AACjB,WAAOC,IAAI,CAACC,GAAL,CAASF,IAAI,GAAGH,IAAhB,IAAwBI,IAAI,CAACC,GAAL,CAASH,IAAI,GAAGF,IAAhB,CAAxB,GAAgDG,IAAhD,GAAuDD,IAA9D;AACD,GAFM,CAAP;AAGD,CAJM;AAMP,IAAMI,WAAW,GAAG,6BAApB;SAEgBC,gBAAgBC;AAC9B,MAAMC,IAAI,GAAGC,QAAQ,CAACC,aAAT,CAAuB,MAAvB,CAAb;AACA,MAAMC,IAAI,GAAGF,QAAQ,CAACC,aAAT,OAA2BH,MAA3B,CAAb;;AAEA,MAAII,IAAJ,EAAU;AACR,QAAMC,CAAC,GAAG,EAAV;AACA,QAAMC,CAAC,GAAGjB,MAAM,CAACkB,WAAjB;AACA,QAAMC,CAAC,GAAG,CAACF,CAAC,GAAGD,CAAL,IAAUC,CAApB;AACAL,IAAAA,IAAI,CAACQ,KAAL,CAAWC,eAAX,GAA6B,MAA7B;AACAN,IAAAA,IAAI,CAACK,KAAL,CAAWE,QAAX,GAAsB,QAAtB;AACAP,IAAAA,IAAI,CAACK,KAAL,CAAWG,UAAX,GAAwB,WAAxB;AACAR,IAAAA,IAAI,CAACK,KAAL,CAAWI,UAAX,GAAwB,wBAAxB;AACAT,IAAAA,IAAI,CAACK,KAAL,CAAWK,SAAX,mDAAqET,CAAC,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js","sources":["../src/utils.ts","../src/context.tsx","../src/hooks.tsx","../src/styles.ts","../src/sheet.tsx","../src/SheetContainer.tsx","../src/SheetContent.tsx","../src/SheetHeader.tsx","../src/SheetBackdrop.tsx","../src/index.tsx"],"sourcesContent":["import { useEffect, useLayoutEffect, useState } from 'react';\n\nexport const isSSR = typeof window === 'undefined';\n\nexport const getClosest = (nums: number[], goal: number) => {\n return nums.reduce((prev, curr) => {\n return Math.abs(curr - goal) < Math.abs(prev - goal) ? curr : prev;\n });\n};\n\nconst highlightId = 'react-modal-sheet-highlight';\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 = 'transform 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 // Add highlighed overlay to emphasize the modality effect\n const highlight = document.createElement('div');\n highlight.setAttribute('aria-hidden', 'true');\n highlight.id = highlightId;\n highlight.style.position = 'absolute';\n highlight.style.top = '0px';\n highlight.style.left = '0px';\n highlight.style.bottom = '0px';\n highlight.style.right = '0px';\n highlight.style.opacity = '0';\n highlight.style.transition = 'opacity 200ms linear';\n highlight.style.backgroundColor = 'rgba(150, 150, 150, 0.1)';\n\n root.appendChild(highlight);\n requestAnimationFrame(() => (highlight.style.opacity = '1'));\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 const highlight = document.getElementById(highlightId) 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 highlight.parentNode?.removeChild(highlight);\n }\n\n if (root && highlight) {\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 highlight.style.opacity = '0';\n\n // Remove temp properties after animation is finished\n root.addEventListener('transitionend', onTransitionEnd);\n }\n}\n\nconst useIsomorphicLayoutEffect = isSSR ? useEffect : useLayoutEffect;\n\nexport function useWindowHeight() {\n const [windowHeight, setWindowHeight] = useState(0);\n\n useIsomorphicLayoutEffect(() => {\n const updateHeight = () => setWindowHeight(window.innerHeight);\n window.addEventListener('resize', updateHeight);\n updateHeight();\n return () => window.removeEventListener('resize', updateHeight);\n }, []);\n\n return windowHeight;\n}\n\nexport const 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","import * as React from 'react';\nimport { SheetContextType } from './types';\n\nexport const SheetContext = React.createContext<SheetContextType | undefined>(\n undefined\n);\n\nexport const useSheetContext = () => {\n const context = React.useContext(SheetContext);\n if (!context) throw Error('Sheet context error');\n return context;\n};\n","import * as React from 'react';\n\nimport { SheetEvents } from './types';\nimport { applyRootStyles, cleanupRootStyles } from './utils';\n\nexport const 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 React.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 React.useEffect(() => {\n return () => {\n if (rootId && isOpen) cleanupRootStyles(rootId);\n };\n }, [isOpen]); // eslint-disable-line\n};\n\nexport const useEventCallbacks = (\n isOpen: boolean,\n callbacks: React.MutableRefObject<SheetEvents>\n) => {\n const prevOpen = usePrevious(isOpen);\n const didOpen = React.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 = React.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 React.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\nconst usePrevious = <T,>(state: T): T | undefined => {\n const ref = React.useRef<T>();\n\n React.useEffect(() => {\n ref.current = state;\n });\n\n return ref.current;\n};\n","import * as CSS from 'csstype';\n\nconst styles: { [key: string]: CSS.Properties } = {\n wrapper: {\n position: 'fixed',\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n zIndex: 9999999,\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(51, 51, 51, 0.5)',\n touchAction: 'none', // Disable iOS body scrolling\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 flex: 1,\n overflow: 'auto',\n position: 'relative',\n },\n};\n\nexport default styles;\n","import * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport { usePreventScroll } from '@react-aria/overlays';\n\nimport {\n animate,\n useMotionValue,\n PanInfo,\n AnimatePresence,\n} from 'framer-motion';\n\nimport { SheetContextType, SheetProps } from './types';\nimport { getClosest, inDescendingOrder, isSSR, useWindowHeight } from './utils';\nimport { SheetContext } from './context';\nimport { useModalEffect } from './hooks';\nimport styles from './styles';\n\nconst Sheet = React.forwardRef<any, SheetProps>(\n (\n {\n children,\n isOpen,\n onClose,\n onOpenStart,\n onOpenEnd,\n onCloseStart,\n onCloseEnd,\n onSnap,\n snapPoints,\n initialSnap = 0,\n rootId,\n mountPoint,\n springConfig = { stiffness: 300, damping: 30, mass: 0.2 },\n disableDrag = false,\n style,\n ...rest\n },\n ref\n ) => {\n const sheetRef = React.useRef<any>(null);\n const callbacks = React.useRef({ onOpenStart, onOpenEnd, onCloseStart, onCloseEnd }); // prettier-ignore\n const indicatorRotation = useMotionValue(0);\n const windowHeight = useWindowHeight();\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 if (snapPoints) {\n // Convert negative / percentage snap points to absolute values\n snapPoints = snapPoints.map(point => {\n if (point > 0 && point <= 1) return Math.round(point * windowHeight); // percentage values e.g. between 0.0 and 1.0\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}]`\n );\n }\n\n const handleDrag = React.useCallback((_, { delta }: PanInfo) => {\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(y.get() + delta.y, 0));\n }, []); // eslint-disable-line\n\n const handleDragEnd = React.useCallback(\n (_, { velocity }: PanInfo) => {\n if (velocity.y > 500) {\n // User flicked the sheet down\n onClose();\n } else {\n const sheetEl = sheetRef.current as HTMLDivElement;\n const contentHeight = sheetEl.getBoundingClientRect().height;\n const snapTo = Math.round(\n snapPoints\n ? getClosest(snapPoints.map(p => contentHeight - p), y.get()) // prettier-ignore\n : y.get() / contentHeight > 0.6 // Close if dragged over 60%\n ? contentHeight\n : 0\n );\n\n // Update the spring value so that the sheet is animated to the snap point\n animate(y, snapTo, { type: 'spring', ...springConfig });\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 if (snapTo >= contentHeight) onClose();\n }\n\n // Reset indicator rotation after dragging\n indicatorRotation.set(0);\n },\n [onClose, onSnap] // eslint-disable-line\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 React.useEffect(() => {\n callbacks.current = { onOpenStart, onOpenEnd, onCloseStart, onCloseEnd };\n });\n\n // Trigger onSnap callback when sheet is opened or closed\n React.useEffect(() => {\n if (!snapPoints || !onSnap) return;\n const snapIndex = isOpen ? initialSnap : snapPoints.length - 1;\n onSnap(snapIndex);\n }, [isOpen]); // eslint-disable-line\n\n React.useImperativeHandle(ref, () => ({\n y,\n snapTo: (snapIndex: number) => {\n const sheetEl = sheetRef.current as HTMLDivElement | null;\n if (\n snapPoints &&\n snapPoints[snapIndex] !== undefined &&\n sheetEl !== null\n ) {\n const contentHeight = sheetEl.getBoundingClientRect().height;\n const snapTo = contentHeight - snapPoints[snapIndex];\n animate(y, snapTo, { type: 'spring', ...springConfig });\n if (onSnap) onSnap(snapIndex);\n if (snapTo >= contentHeight) 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: !isOpen });\n\n const dragProps = disableDrag\n ? ({} as any)\n : {\n drag: 'y' as const,\n dragElastic: 0,\n dragConstraints: { top: 0, bottom: 0 },\n dragMomentum: false,\n onDrag: handleDrag,\n onDragEnd: handleDragEnd,\n };\n\n const context: SheetContextType = {\n y,\n sheetRef,\n isOpen,\n initialSnap,\n snapPoints,\n indicatorRotation,\n callbacks,\n dragProps,\n windowHeight,\n springConfig,\n };\n\n const wrapperProps = {\n ...rest,\n ref,\n style: { ...styles.wrapper, ...style },\n };\n\n const sheet = (\n <SheetContext.Provider value={context}>\n <div {...wrapperProps}>\n <AnimatePresence>\n {/* NOTE: AnimatePresence requires us to set keys to children */}\n {isOpen\n ? React.Children.map(children, (child: any, i) =>\n React.cloneElement(child, { key: `sheet-child-${i}` })\n )\n : null}\n </AnimatePresence>\n </div>\n </SheetContext.Provider>\n );\n\n if (isSSR) return sheet;\n\n return ReactDOM.createPortal(sheet, mountPoint ?? document.body);\n }\n);\n\nexport default Sheet;\n","import * as React from 'react';\nimport { motion } from 'framer-motion';\nimport mergeRefs from 'react-merge-refs';\n\nimport { SheetContainerProps } from './types';\nimport { useSheetContext } from './context';\nimport { useEventCallbacks } from './hooks';\nimport styles from './styles';\n\nconst MAX_HEIGHT = 'calc(100% - env(safe-area-inset-top) - 34px)';\n\nconst SheetContainer = React.forwardRef<any, SheetContainerProps>(\n ({ children, style = {}, ...rest }, ref) => {\n const {\n y,\n isOpen,\n callbacks,\n snapPoints,\n initialSnap = 0,\n sheetRef,\n windowHeight,\n springConfig,\n } = useSheetContext();\n\n const { handleAnimationComplete } = useEventCallbacks(isOpen, callbacks);\n const initialY = snapPoints ? snapPoints[0] - snapPoints[initialSnap] : 0;\n const h = snapPoints ? snapPoints[0] : null;\n const sheetHeight = h ? `min(${h}px, ${MAX_HEIGHT})` : MAX_HEIGHT;\n\n return (\n <motion.div\n {...rest}\n ref={mergeRefs([sheetRef, ref])}\n className=\"react-modal-sheet-container\"\n style={{\n ...styles.container,\n height: sheetHeight,\n ...style,\n y,\n }}\n initial={{ y: windowHeight }}\n animate={{\n y: initialY,\n transition: { type: 'spring', ...springConfig },\n }}\n exit={{ y: windowHeight }}\n onAnimationComplete={handleAnimationComplete}\n >\n {children}\n </motion.div>\n );\n }\n);\n\nexport default SheetContainer;\n","import * as React from 'react';\nimport { motion } from 'framer-motion';\n\nimport { SheetDraggableProps } from './types';\nimport styles from './styles';\nimport { useSheetContext } from './context';\n\nconst SheetContent = React.forwardRef<any, SheetDraggableProps>(\n ({ children, disableDrag = false, style = {}, ...rest }, ref) => {\n const { dragProps } = useSheetContext();\n\n return (\n <motion.div\n {...rest}\n ref={ref}\n className=\"react-modal-sheet-content\"\n style={{ ...styles.content, ...style }}\n {...(disableDrag ? {} : dragProps)}\n >\n {children}\n </motion.div>\n );\n }\n);\n\nexport default SheetContent;\n","import * as React from 'react';\nimport { motion, useTransform } from 'framer-motion';\n\nimport { SheetDraggableProps } from './types';\nimport { useSheetContext } from './context';\nimport styles from './styles';\n\nconst SheetHeader = React.forwardRef<any, SheetDraggableProps>(\n ({ children, disableDrag = false, style = {}, ...rest }, ref) => {\n const { indicatorRotation, dragProps } = useSheetContext();\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={ref}\n style={{ ...styles.headerWrapper, ...style }}\n {...(disableDrag ? {} : dragProps)}\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\nexport default SheetHeader;\n","import * as React from 'react';\nimport { motion } from 'framer-motion';\n\nimport { SheetBackdropProps } from './types';\nimport styles from './styles';\n\nconst isClickable = (props: any) => !!props.onClick || !!props.onTap;\n\nconst SheetBackdrop = React.forwardRef<any, SheetBackdropProps>(\n ({ style = {}, ...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\"\n style={{ ...styles.backdrop, ...style, pointerEvents }}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n />\n );\n }\n);\n\nexport default SheetBackdrop;\n","import { 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 { SheetCompound } from './types';\n\nexport type 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\nexport default _SheetCompound as SheetCompound;\n"],"names":["isSSR","window","getClosest","nums","goal","reduce","prev","curr","Math","abs","highlightId","applyRootStyles","rootId","body","document","querySelector","root","p","h","innerHeight","s","style","backgroundColor","overflow","willChange","transition","transform","borderTopRightRadius","borderTopLeftRadius","highlight","createElement","setAttribute","id","position","top","left","bottom","right","opacity","appendChild","requestAnimationFrame","cleanupRootStyles","getElementById","onTransitionEnd","removeProperty","removeEventListener","parentNode","removeChild","addEventListener","useIsomorphicLayoutEffect","useEffect","useLayoutEffect","useWindowHeight","useState","windowHeight","setWindowHeight","updateHeight","inDescendingOrder","arr","i","length","SheetContext","React","undefined","useSheetContext","context","Error","useModalEffect","isOpen","prevOpen","usePrevious","useEventCallbacks","callbacks","didOpen","handleAnimationComplete","current","onOpenEnd","onCloseEnd","onOpenStart","onCloseStart","state","ref","styles","wrapper","zIndex","pointerEvents","backdrop","width","height","touchAction","container","boxShadow","display","flexDirection","headerWrapper","header","alignItems","justifyContent","indicator","borderRadius","content","flex","Sheet","children","onClose","onSnap","snapPoints","initialSnap","mountPoint","springConfig","stiffness","damping","mass","disableDrag","rest","sheetRef","indicatorRotation","useMotionValue","y","map","point","round","console","assert","handleDrag","_","delta","velocity","getVelocity","set","max","get","handleDragEnd","sheetEl","contentHeight","getBoundingClientRect","snapTo","animate","type","snapValue","snapIndex","indexOf","usePreventScroll","isDisabled","dragProps","drag","dragElastic","dragConstraints","dragMomentum","onDrag","onDragEnd","wrapperProps","sheet","Provider","value","AnimatePresence","child","key","ReactDOM","MAX_HEIGHT","SheetContainer","initialY","sheetHeight","motion","div","mergeRefs","className","initial","exit","onAnimationComplete","SheetContent","SheetHeader","indicator1Transform","useTransform","r","indicator2Transform","span","isClickable","props","onClick","onTap","SheetBackdrop","Comp","button","_SheetCompound","Container","Header","Content","Backdrop"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,IAAMA,KAAK,GAAG,OAAOC,MAAP,KAAkB,WAAhC;AAEA,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAACC,IAAD,EAAiBC,IAAjB;AACxB,SAAOD,IAAI,CAACE,MAAL,CAAY,UAACC,IAAD,EAAOC,IAAP;AACjB,WAAOC,IAAI,CAACC,GAAL,CAASF,IAAI,GAAGH,IAAhB,IAAwBI,IAAI,CAACC,GAAL,CAASH,IAAI,GAAGF,IAAhB,CAAxB,GAAgDG,IAAhD,GAAuDD,IAA9D;AACD,GAFM,CAAP;AAGD,CAJM;AAMP,IAAMI,WAAW,GAAG,6BAApB;SAEgBC,gBAAgBC;AAC9B,MAAMC,IAAI,GAAGC,QAAQ,CAACC,aAAT,CAAuB,MAAvB,CAAb;AACA,MAAMC,IAAI,GAAGF,QAAQ,CAACC,aAAT,OAA2BH,MAA3B,CAAb;;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AA,KAAK,eAAO6D,MAAM,CAACI,QAAd,EAA2BjE,KAA3B;AAAkCgE,MAAAA,aAAa,EAAbA;AAAlC;AACLkF,IAAAA,OAAO,EAAE;AAAEjI,MAAAA,OAAO,EAAE;AAAX;AACTmG,IAAAA,OAAO,EAAE;AAAEnG,MAAAA,OAAO,EAAE;AAAX;AACTkI,IAAAA,IAAI,EAAE;AAAElI,MAAAA,OAAO,EAAE;AAAX;IAPR,CADF;AAWD,CAhBmB,CAAtB;;ACOA,IAAMkJ,cAAc,GAAQlF,KAA5B;AACAkF,cAAc,CAACC,SAAf,GAA2BzB,cAA3B;AACAwB,cAAc,CAACE,MAAf,GAAwBf,WAAxB;AACAa,cAAc,CAACG,OAAf,GAAyBjB,YAAzB;AACAc,cAAc,CAACI,QAAf,GAA0BP,aAA1B;;;;"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.6.
|
|
2
|
+
"version": "1.6.3",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "react-modal-sheet",
|
|
5
5
|
"description": "Flexible bottom sheet component for your React apps",
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
"typescript": "4.7.3"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
+
"@react-aria/overlays": "3.11.0",
|
|
67
68
|
"react-merge-refs": "1.1.0"
|
|
68
69
|
}
|
|
69
70
|
}
|
package/src/SheetContainer.tsx
CHANGED
|
@@ -32,7 +32,12 @@ const SheetContainer = React.forwardRef<any, SheetContainerProps>(
|
|
|
32
32
|
{...rest}
|
|
33
33
|
ref={mergeRefs([sheetRef, ref])}
|
|
34
34
|
className="react-modal-sheet-container"
|
|
35
|
-
style={{
|
|
35
|
+
style={{
|
|
36
|
+
...styles.container,
|
|
37
|
+
height: sheetHeight,
|
|
38
|
+
...style,
|
|
39
|
+
y,
|
|
40
|
+
}}
|
|
36
41
|
initial={{ y: windowHeight }}
|
|
37
42
|
animate={{
|
|
38
43
|
y: initialY,
|
package/src/sheet.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import * as ReactDOM from 'react-dom';
|
|
3
|
+
import { usePreventScroll } from '@react-aria/overlays';
|
|
3
4
|
|
|
4
5
|
import {
|
|
5
6
|
animate,
|
|
@@ -136,6 +137,10 @@ const Sheet = React.forwardRef<any, SheetProps>(
|
|
|
136
137
|
|
|
137
138
|
useModalEffect(isOpen, rootId);
|
|
138
139
|
|
|
140
|
+
// Framer Motion should handle body scroll locking but it's not working
|
|
141
|
+
// properly on iOS. Scroll locking from React Aria seems to work much better.
|
|
142
|
+
usePreventScroll({ isDisabled: !isOpen });
|
|
143
|
+
|
|
139
144
|
const dragProps = disableDrag
|
|
140
145
|
? ({} as any)
|
|
141
146
|
: {
|