react-modal-sheet 1.5.1 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,18 +1,8 @@
1
1
  import { MotionValue } from 'framer-motion';
2
- import Sheet from './sheet';
3
- import SheetContainer from './SheetContainer';
4
- import SheetContent from './SheetContent';
5
- import SheetHeader from './SheetHeader';
6
- import SheetBackdrop from './SheetBackdrop';
2
+ import { SheetCompound } from './types';
7
3
  export declare type SheetRef = {
8
4
  y: MotionValue<number>;
9
5
  snapTo: (index: number) => void;
10
6
  };
11
- declare type SheetCompoundComponent = {
12
- Container: typeof SheetContainer;
13
- Header: typeof SheetHeader;
14
- Content: typeof SheetContent;
15
- Backdrop: typeof SheetBackdrop;
16
- };
17
- declare const SheetCompound: typeof Sheet & SheetCompoundComponent;
18
- export default SheetCompound;
7
+ declare const _default: SheetCompound;
8
+ export default _default;
@@ -555,12 +555,11 @@ var SheetBackdrop = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
555
555
  }));
556
556
  });
557
557
 
558
- var _Sheet = Sheet;
559
- _Sheet.Container = SheetContainer;
560
- _Sheet.Header = SheetHeader;
561
- _Sheet.Content = SheetContent;
562
- _Sheet.Backdrop = SheetBackdrop;
563
- var SheetCompound = _Sheet;
564
-
565
- exports.default = SheetCompound;
558
+ var _SheetCompound = Sheet;
559
+ _SheetCompound.Container = SheetContainer;
560
+ _SheetCompound.Header = SheetHeader;
561
+ _SheetCompound.Content = SheetContent;
562
+ _SheetCompound.Backdrop = SheetBackdrop;
563
+
564
+ exports.default = _SheetCompound;
566
565
  //# sourceMappingURL=react-modal-sheet.cjs.development.js.map
@@ -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 springConfig = { stiffness: 300, damping: 30, mass: 0.2 },\n disableDrag = false,\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 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 = 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 // 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(snapValue);\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,\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, 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';\n\nexport type SheetRef = {\n y: MotionValue<number>;\n snapTo: (index: number) => void;\n};\n\ntype SheetCompoundComponent = {\n Container: typeof SheetContainer;\n Header: typeof SheetHeader;\n Content: typeof SheetContent;\n Backdrop: typeof SheetBackdrop;\n};\n\n// HACK: this is needed to get the typing to work properly...\nconst _Sheet: any = Sheet;\n_Sheet.Container = SheetContainer;\n_Sheet.Header = SheetHeader;\n_Sheet.Content = SheetContent;\n_Sheet.Backdrop = SheetBackdrop;\n\nconst SheetCompound: typeof Sheet & SheetCompoundComponent = _Sheet;\n\nexport default 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","springConfig","stiffness","damping","mass","disableDrag","rest","sheetRef","indicatorRotation","useMotionValue","y","map","point","console","assert","handleDrag","_","delta","velocity","getVelocity","set","max","get","handleDragEnd","sheetEl","contentHeight","getBoundingClientRect","snapTo","animate","type","snapValue","round","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","_Sheet","Container","Header","Content","Backdrop","SheetCompound"],"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,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GAAkBP,aAAlB;AAEA,IAAMQ,aAAa,GAA0CL,MAA7D;;;;"}
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 springConfig = { stiffness: 300, damping: 30, mass: 0.2 },\n disableDrag = false,\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 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 = 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 // 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(snapValue);\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,\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, 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","springConfig","stiffness","damping","mass","disableDrag","rest","sheetRef","indicatorRotation","useMotionValue","y","map","point","console","assert","handleDrag","_","delta","velocity","getVelocity","set","max","get","handleDragEnd","sheetEl","contentHeight","getBoundingClientRect","snapTo","animate","type","snapValue","round","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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B;AACAwB,cAAc,CAACE,MAAf,GAAwBf,WAAxB;AACAa,cAAc,CAACG,OAAf,GAAyBjB,YAAzB;AACAc,cAAc,CAACI,QAAf,GAA0BP,aAA1B;;;;"}
@@ -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 springConfig = { stiffness: 300, damping: 30, mass: 0.2 },\n disableDrag = false,\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 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 = 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 // 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(snapValue);\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,\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, 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';\n\nexport type SheetRef = {\n y: MotionValue<number>;\n snapTo: (index: number) => void;\n};\n\ntype SheetCompoundComponent = {\n Container: typeof SheetContainer;\n Header: typeof SheetHeader;\n Content: typeof SheetContent;\n Backdrop: typeof SheetBackdrop;\n};\n\n// HACK: this is needed to get the typing to work properly...\nconst _Sheet: any = Sheet;\n_Sheet.Container = SheetContainer;\n_Sheet.Header = SheetHeader;\n_Sheet.Content = SheetContent;\n_Sheet.Backdrop = SheetBackdrop;\n\nconst SheetCompound: typeof Sheet & SheetCompoundComponent = _Sheet;\n\nexport default SheetCompound;\n"],"names":["isSSR","window","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","springConfig","stiffness","damping","mass","disableDrag","rest","sheetRef","callbacks","indicatorRotation","useMotionValue","windowHeight","useState","setWindowHeight","updateHeight","innerHeight","useWindowHeight","y","map","point","console","assert","arr","i","length","inDescendingOrder","handleDrag","_","delta","velocity","getVelocity","set","Math","max","get","handleDragEnd","nums","goal","contentHeight","getBoundingClientRect","snapTo","p","reduce","prev","curr","abs","animate","type","snapValue","round","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","_Sheet","Container","Header","Content","Backdrop"],"mappings":"mjBAEO,IAAMA,EAA0B,oBAAXC,gBA4CZC,EAAkBC,OAC1BC,EAAOC,SAASC,cAAc,QAC9BC,EAAOF,SAASG,eAAeL,GAC/BM,EAAYJ,SAASG,eAvCT,+BAkDdD,GAAQE,IAEVF,EAAKG,MAAMC,eAAe,2BAC1BJ,EAAKG,MAAMC,eAAe,0BAC1BJ,EAAKG,MAAMC,eAAe,aAC1BF,EAAUC,MAAME,QAAU,IAG1BL,EAAKM,iBAAiB,0BAjBfC,UACPP,EAAKG,MAAMC,eAAe,YAC1BJ,EAAKG,MAAMC,eAAe,eAC1BJ,EAAKG,MAAMC,eAAe,cAC1BP,EAAKM,MAAMC,eAAe,oBAC1BJ,EAAKQ,oBAAoB,gBAAiBD,YAC1CL,EAAUO,eAAYC,YAAYR,OAetC,IAAMS,EAA4BlB,EAAQmB,YAAYC,kBCrEzCC,EAAeC,qBA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,MAAAA,aAAQ,KAAOkE,4CACNpD,IAAjCuD,IAAAA,kBAAmByD,IAAAA,UAErB+B,EAAsBC,eAC1BzF,GACA,SAAA0F,mCAA+BA,YAG3BC,EAAsBF,eAC1BzF,GACA,SAAA0F,qCAAiC,EAAIA,mBAIrCnJ,gBAACwI,SAAOC,qBACFnF,GACJ/C,IAAKA,EACLnB,WAAYqB,EAAOqB,cAAkB1C,IAChCiE,EAAc,GAAK6D,GAEvB3E,GACCvC,uBAAK2I,UAAU,2BAA2BvJ,MAAOqB,EAAOsB,QACtD/B,gBAACwI,SAAOa,MACNV,UAAU,mCACVvJ,WAAYqB,EAAOyB,WAAWwE,UAAWuC,MAE3CjJ,gBAACwI,SAAOa,MACNV,UAAU,mCACVvJ,WAAYqB,EAAOyB,WAAWwE,UAAW0C,WC9BjDE,EAAc,SAACC,WAAiBA,EAAMC,WAAaD,EAAME,OAEzDC,EAAgB1J,cACpB,WAA0BO,WAAvBnB,MAAAA,aAAQ,KAAOkE,iBACVqG,EAAOL,EAAYhG,GAAQkF,SAAOoB,OAASpB,SAAOC,IAClDvH,EAAgBoI,EAAYhG,GAAQ,OAAS,cAGjDtD,gBAAC2J,mBACKrG,GACJ/C,IAAKA,EACLoI,UAAU,6BACVvJ,WAAYqB,EAAOU,SAAa/B,GAAO8B,cAAAA,IACvC0H,QAAS,CAAEtJ,QAAS,GACpBwG,QAAS,CAAExG,QAAS,GACpBuJ,KAAM,CAAEvJ,QAAS,SCAnBuK,EAAcvH,EACpBuH,EAAOC,UAAY5B,EACnB2B,EAAOE,OAASf,EAChBa,EAAOG,QAAUjB,EACjBc,EAAOI,SAAWP,kBAE2CG"}
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 springConfig = { stiffness: 300, damping: 30, mass: 0.2 },\n disableDrag = false,\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 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 = 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 // 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(snapValue);\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,\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, 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","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","springConfig","stiffness","damping","mass","disableDrag","rest","sheetRef","callbacks","indicatorRotation","useMotionValue","windowHeight","useState","setWindowHeight","updateHeight","innerHeight","useWindowHeight","y","map","point","console","assert","arr","i","length","inDescendingOrder","handleDrag","_","delta","velocity","getVelocity","set","Math","max","get","handleDragEnd","nums","goal","contentHeight","getBoundingClientRect","snapTo","p","reduce","prev","curr","abs","animate","type","snapValue","round","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,gBA4CZC,EAAkBC,OAC1BC,EAAOC,SAASC,cAAc,QAC9BC,EAAOF,SAASG,eAAeL,GAC/BM,EAAYJ,SAASG,eAvCT,+BAkDdD,GAAQE,IAEVF,EAAKG,MAAMC,eAAe,2BAC1BJ,EAAKG,MAAMC,eAAe,0BAC1BJ,EAAKG,MAAMC,eAAe,aAC1BF,EAAUC,MAAME,QAAU,IAG1BL,EAAKM,iBAAiB,0BAjBfC,UACPP,EAAKG,MAAMC,eAAe,YAC1BJ,EAAKG,MAAMC,eAAe,eAC1BJ,EAAKG,MAAMC,eAAe,cAC1BP,EAAKM,MAAMC,eAAe,oBAC1BJ,EAAKQ,oBAAoB,gBAAiBD,YAC1CL,EAAUO,eAAYC,YAAYR,OAetC,IAAMS,EAA4BlB,EAAQmB,YAAYC,kBCrEzCC,EAAeC,qBAC1BC,GAGWC,EAAkB,eACvBC,EAAUH,aAAiBD,OAC5BI,EAAS,MAAMC,MAAM,8BACnBD,GC8CHE,EAAc,SAAKC,OACjBC,EAAMP,kBAEZA,aAAgB,WACdO,EAAIC,QAAUF,KAGTC,EAAIC,SC7DPC,EAA4C,CAChDC,QAAS,CACPC,SAAU,QACVC,IAAK,EACLC,OAAQ,EACRC,KAAM,EACNC,MAAO,EACPC,OAAQ,QACRC,SAAU,SACVC,cAAe,QAEjBC,SAAU,CACRH,OAAQ,EACRL,SAAU,QACVC,IAAK,EACLE,KAAM,EACNM,MAAO,OACPC,OAAQ,OACRC,gBAAiB,wBACjBC,YAAa,QAEfC,UAAW,CACTR,OAAQ,EACRL,SAAU,WACV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AAU,mCACVvJ,WAAYqB,EAAOyB,WAAWwE,UAAW0C,WC9BjDE,EAAc,SAACC,WAAiBA,EAAMC,WAAaD,EAAME,OAEzDC,EAAgB1J,cACpB,WAA0BO,WAAvBnB,MAAAA,aAAQ,KAAOkE,iBACVqG,EAAOL,EAAYhG,GAAQkF,SAAOoB,OAASpB,SAAOC,IAClDvH,EAAgBoI,EAAYhG,GAAQ,OAAS,cAGjDtD,gBAAC2J,mBACKrG,GACJ/C,IAAKA,EACLoI,UAAU,6BACVvJ,WAAYqB,EAAOU,SAAa/B,GAAO8B,cAAAA,IACvC0H,QAAS,CAAEtJ,QAAS,GACpBwG,QAAS,CAAExG,QAAS,GACpBuJ,KAAM,CAAEvJ,QAAS,SCNnBuK,EAAsBvH,EAC5BuH,EAAeC,UAAY5B,EAC3B2B,EAAeE,OAASf,EACxBa,EAAeG,QAAUjB,EACzBc,EAAeI,SAAWP"}
@@ -1,4 +1,4 @@
1
- import { useState, useEffect, useLayoutEffect, useContext, createContext, useRef, useCallback, forwardRef, useImperativeHandle, createElement, Children, cloneElement } from 'react';
1
+ import { useState, useEffect, useLayoutEffect, createContext, useContext, useRef, useCallback, forwardRef, useImperativeHandle, createElement, Children, cloneElement } from 'react';
2
2
  import { createPortal } from 'react-dom';
3
3
  import { useMotionValue, animate, AnimatePresence, motion, useTransform } from 'framer-motion';
4
4
  import mergeRefs from 'react-merge-refs';
@@ -549,12 +549,11 @@ var SheetBackdrop = /*#__PURE__*/forwardRef(function (_ref, ref) {
549
549
  }));
550
550
  });
551
551
 
552
- var _Sheet = Sheet;
553
- _Sheet.Container = SheetContainer;
554
- _Sheet.Header = SheetHeader;
555
- _Sheet.Content = SheetContent;
556
- _Sheet.Backdrop = SheetBackdrop;
557
- var SheetCompound = _Sheet;
552
+ var _SheetCompound = Sheet;
553
+ _SheetCompound.Container = SheetContainer;
554
+ _SheetCompound.Header = SheetHeader;
555
+ _SheetCompound.Content = SheetContent;
556
+ _SheetCompound.Backdrop = SheetBackdrop;
558
557
 
559
- export default SheetCompound;
558
+ export default _SheetCompound;
560
559
  //# sourceMappingURL=react-modal-sheet.esm.js.map
@@ -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 springConfig = { stiffness: 300, damping: 30, mass: 0.2 },\n disableDrag = false,\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 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 = 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 // 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(snapValue);\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,\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, 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';\n\nexport type SheetRef = {\n y: MotionValue<number>;\n snapTo: (index: number) => void;\n};\n\ntype SheetCompoundComponent = {\n Container: typeof SheetContainer;\n Header: typeof SheetHeader;\n Content: typeof SheetContent;\n Backdrop: typeof SheetBackdrop;\n};\n\n// HACK: this is needed to get the typing to work properly...\nconst _Sheet: any = Sheet;\n_Sheet.Container = SheetContainer;\n_Sheet.Header = SheetHeader;\n_Sheet.Content = SheetContent;\n_Sheet.Backdrop = SheetBackdrop;\n\nconst SheetCompound: typeof Sheet & SheetCompoundComponent = _Sheet;\n\nexport default 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","springConfig","stiffness","damping","mass","disableDrag","rest","sheetRef","indicatorRotation","useMotionValue","y","map","point","console","assert","handleDrag","_","delta","velocity","getVelocity","set","max","get","handleDragEnd","sheetEl","contentHeight","getBoundingClientRect","snapTo","animate","type","snapValue","round","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","_Sheet","Container","Header","Content","Backdrop","SheetCompound"],"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,MA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AWD,CAhBmB,CAAtB;;ACaA,IAAM+I,MAAM,GAAQ/E,KAApB;AACA+E,MAAM,CAACC,SAAP,GAAmBzB,cAAnB;AACAwB,MAAM,CAACE,MAAP,GAAgBf,WAAhB;AACAa,MAAM,CAACG,OAAP,GAAiBjB,YAAjB;AACAc,MAAM,CAACI,QAAP,GAAkBP,aAAlB;AAEA,IAAMQ,aAAa,GAA0CL,MAA7D;;;;"}
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 springConfig = { stiffness: 300, damping: 30, mass: 0.2 },\n disableDrag = false,\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 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 = 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 // 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(snapValue);\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,\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, 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","springConfig","stiffness","damping","mass","disableDrag","rest","sheetRef","indicatorRotation","useMotionValue","y","map","point","console","assert","handleDrag","_","delta","velocity","getVelocity","set","max","get","handleDragEnd","sheetEl","contentHeight","getBoundingClientRect","snapTo","animate","type","snapValue","round","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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EAAE;AAAE/H,MAAAA,OAAO,EAAE;AAAX;IAPR,CADF;AAWD,CAhBmB,CAAtB;;ACOA,IAAM+I,cAAc,GAAQ/E,KAA5B;AACA+E,cAAc,CAACC,SAAf,GAA2BzB,cAA3B;AACAwB,cAAc,CAACE,MAAf,GAAwBf,WAAxB;AACAa,cAAc,CAACG,OAAf,GAAyBjB,YAAzB;AACAc,cAAc,CAACI,QAAf,GAA0BP,aAA1B;;;;"}
package/dist/types.d.ts CHANGED
@@ -46,3 +46,15 @@ export declare type SheetContextType = {
46
46
  windowHeight: number;
47
47
  springConfig: Parameters<typeof useSpring>[1];
48
48
  };
49
+ declare type ContainerComponent = React.ForwardRefExoticComponent<SheetContainerProps & React.RefAttributes<any>>;
50
+ declare type DraggableComponent = React.ForwardRefExoticComponent<SheetDraggableProps & React.RefAttributes<any>>;
51
+ declare type BackdropComponent = React.ForwardRefExoticComponent<SheetBackdropProps & React.RefAttributes<any>>;
52
+ declare type SheetComponent = React.ForwardRefExoticComponent<SheetProps & React.RefAttributes<any>>;
53
+ declare type SheetCompoundComponent = {
54
+ Container: ContainerComponent;
55
+ Header: DraggableComponent;
56
+ Content: DraggableComponent;
57
+ Backdrop: BackdropComponent;
58
+ };
59
+ export declare type SheetCompound = SheetComponent & SheetCompoundComponent;
60
+ export {};
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.5.1",
2
+ "version": "1.5.2",
3
3
  "license": "MIT",
4
4
  "name": "react-modal-sheet",
5
5
  "description": "Flexible bottom sheet component for your React apps",
@@ -32,7 +32,7 @@
32
32
  "release": "np"
33
33
  },
34
34
  "peerDependencies": {
35
- "framer-motion": "2.x || 3.x || 4.x || 5.x || 6.x",
35
+ "framer-motion": ">=2",
36
36
  "react": ">=16"
37
37
  },
38
38
  "husky": {
@@ -54,14 +54,14 @@
54
54
  "@types/react-dom": "17.0.11",
55
55
  "@types/styled-components": "5.1.7",
56
56
  "csstype": "3.0.6",
57
- "framer-motion": "6.2.1",
57
+ "framer-motion": "6.3.11",
58
58
  "husky": "4.2.5",
59
59
  "react": "17.0.2",
60
60
  "react-dom": "17.0.2",
61
61
  "styled-components": "5.3.3",
62
62
  "tsdx": "0.14.1",
63
63
  "tslib": "2.1.0",
64
- "typescript": "4.5.5"
64
+ "typescript": "4.7.3"
65
65
  },
66
66
  "dependencies": {
67
67
  "react-merge-refs": "1.1.0"
package/src/index.tsx CHANGED
@@ -5,26 +5,18 @@ import SheetContainer from './SheetContainer';
5
5
  import SheetContent from './SheetContent';
6
6
  import SheetHeader from './SheetHeader';
7
7
  import SheetBackdrop from './SheetBackdrop';
8
+ import { SheetCompound } from './types';
8
9
 
9
10
  export type SheetRef = {
10
11
  y: MotionValue<number>;
11
12
  snapTo: (index: number) => void;
12
13
  };
13
14
 
14
- type SheetCompoundComponent = {
15
- Container: typeof SheetContainer;
16
- Header: typeof SheetHeader;
17
- Content: typeof SheetContent;
18
- Backdrop: typeof SheetBackdrop;
19
- };
20
-
21
15
  // HACK: this is needed to get the typing to work properly...
22
- const _Sheet: any = Sheet;
23
- _Sheet.Container = SheetContainer;
24
- _Sheet.Header = SheetHeader;
25
- _Sheet.Content = SheetContent;
26
- _Sheet.Backdrop = SheetBackdrop;
27
-
28
- const SheetCompound: typeof Sheet & SheetCompoundComponent = _Sheet;
16
+ const _SheetCompound: any = Sheet;
17
+ _SheetCompound.Container = SheetContainer;
18
+ _SheetCompound.Header = SheetHeader;
19
+ _SheetCompound.Content = SheetContent;
20
+ _SheetCompound.Backdrop = SheetBackdrop;
29
21
 
30
- export default SheetCompound;
22
+ export default _SheetCompound as SheetCompound;
package/src/types.tsx CHANGED
@@ -28,7 +28,9 @@ export type SheetProps = {
28
28
  export type SheetContainerProps = Omit<
29
29
  MotionProps,
30
30
  'initial' | 'animate' | 'exit' | 'onAnimationComplete'
31
- > & { children: React.ReactNode };
31
+ > & {
32
+ children: React.ReactNode;
33
+ };
32
34
 
33
35
  export type SheetDraggableProps = Omit<
34
36
  MotionProps,
@@ -39,7 +41,10 @@ export type SheetDraggableProps = Omit<
39
41
  | 'onDrag'
40
42
  | 'onDragStart'
41
43
  | 'onDragEnd'
42
- > & { children?: React.ReactNode; disableDrag?: boolean };
44
+ > & {
45
+ children?: React.ReactNode;
46
+ disableDrag?: boolean;
47
+ };
43
48
 
44
49
  export type SheetBackdropProps = Omit<
45
50
  MotionProps,
@@ -68,3 +73,28 @@ export type SheetContextType = {
68
73
  windowHeight: number;
69
74
  springConfig: Parameters<typeof useSpring>[1];
70
75
  };
76
+
77
+ type ContainerComponent = React.ForwardRefExoticComponent<
78
+ SheetContainerProps & React.RefAttributes<any>
79
+ >;
80
+
81
+ type DraggableComponent = React.ForwardRefExoticComponent<
82
+ SheetDraggableProps & React.RefAttributes<any>
83
+ >;
84
+
85
+ type BackdropComponent = React.ForwardRefExoticComponent<
86
+ SheetBackdropProps & React.RefAttributes<any>
87
+ >;
88
+
89
+ type SheetComponent = React.ForwardRefExoticComponent<
90
+ SheetProps & React.RefAttributes<any>
91
+ >;
92
+
93
+ type SheetCompoundComponent = {
94
+ Container: ContainerComponent;
95
+ Header: DraggableComponent;
96
+ Content: DraggableComponent;
97
+ Backdrop: BackdropComponent;
98
+ };
99
+
100
+ export type SheetCompound = SheetComponent & SheetCompoundComponent;