react-modal-sheet 1.7.0 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,8 @@
1
+ <p align='center'>
2
+ <img src="media/banner.jpg" alt="React Modal Sheet logo"/>
3
+ <p/>
4
+
1
5
  <div align="center" >
2
- <br/>
3
- <br/>
4
- <h1>🪐 React Modal Sheet</h1>
5
6
  &middot;
6
7
  <i>Flexible bottom sheet component for your React apps</i>
7
8
  &middot;
@@ -71,23 +72,24 @@ Also, by constructing the sheet from smaller pieces makes it easier to apply any
71
72
 
72
73
  ## Props
73
74
 
74
- | Name | Required | Default | Description |
75
- | -------------- | -------- | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
76
- | `children` | yes | | Use `Sheet.Container/Content/Header/Backdrop` to compose your bottom sheet. |
77
- | `isOpen` | yes | | Boolean that indicates whether the sheet is open or not. |
78
- | `onClose` | yes | | Callback fn that is called when the sheet is closed by the user. |
79
- | `disableDrag` | no | false | Disable drag for the whole sheet. |
80
- | `detent` | no | `'full-height'` | The [detent](https://developer.apple.com/design/human-interface-guidelines/components/presentation/sheets#ios-ipados) in which the sheet should be in when opened. Available values: `'full-height'` or `'content-height'`. |
81
- | `onOpenStart` | no | | Callback fn that is called when the sheet opening animation starts. |
82
- | `onOpenEnd` | no | | Callback fn that is called when the sheet opening animation is completed. |
83
- | `onCloseStart` | no | | Callback fn that is called when the sheet closing animation starts. |
84
- | `onCloseEnd` | no | | Callback fn that is called when the sheet closing animation is completed. |
85
- | `onSnap` | no | | Callback fn that is called with the current snap point index when the sheet snaps to a new snap point. Requires `snapPoints` prop. |
86
- | `snapPoints` | no | | Eg. `[-50, 0.5, 100, 0]` - where positive values are pixels from the bottom of the screen and negative from the top. Values between 0-1 represent percentages, eg. `0.5` means 50% of window height from the bottom of the sceen. |
87
- | `initialSnap` | no | 0 | Initial snap point when sheet is opened (index from `snapPoints`). |
88
- | `rootId` | no | | The id of the element where the main app is mounted, eg. "root". Enables iOS modal effect. |
89
- | `springConfig` | no | `DEFAULT_SPRING` | Overrides the config for the [spring animation](https://www.framer.com/api/motion/types/#spring). |
90
- | `mountPoint` | no | `document.body` | HTML element that should be used as the mount point for the sheet. |
75
+ | Name | Required | Default | Description |
76
+ |------------------------|----------|------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
77
+ | `children` | yes | | Use `Sheet.Container/Content/Header/Backdrop` to compose your bottom sheet. |
78
+ | `isOpen` | yes | | Boolean that indicates whether the sheet is open or not. |
79
+ | `onClose` | yes | | Callback fn that is called when the sheet is closed by the user. |
80
+ | `disableDrag` | no | false | Disable drag for the whole sheet. |
81
+ | `detent` | no | `'full-height'` | The [detent](https://developer.apple.com/design/human-interface-guidelines/components/presentation/sheets#ios-ipados) in which the sheet should be in when opened. Available values: `'full-height'` or `'content-height'`. |
82
+ | `onOpenStart` | no | | Callback fn that is called when the sheet opening animation starts. |
83
+ | `onOpenEnd` | no | | Callback fn that is called when the sheet opening animation is completed. |
84
+ | `onCloseStart` | no | | Callback fn that is called when the sheet closing animation starts. |
85
+ | `onCloseEnd` | no | | Callback fn that is called when the sheet closing animation is completed. |
86
+ | `onSnap` | no | | Callback fn that is called with the current snap point index when the sheet snaps to a new snap point. Requires `snapPoints` prop. |
87
+ | `snapPoints` | no | | Eg. `[-50, 0.5, 100, 0]` - where positive values are pixels from the bottom of the screen and negative from the top. Values between 0-1 represent percentages, eg. `0.5` means 50% of window height from the bottom of the sceen. |
88
+ | `initialSnap` | no | 0 | Initial snap point when sheet is opened (index from `snapPoints`). |
89
+ | `rootId` | no | | The id of the element where the main app is mounted, eg. "root". Enables iOS modal effect. |
90
+ | `springConfig` | no | `DEFAULT_SPRING` | Overrides the config for the [spring animation](https://www.framer.com/api/motion/types/#spring). |
91
+ | `mountPoint` | no | `document.body` | HTML element that should be used as the mount point for the sheet. |
92
+ | `prefersReducedMotion` | no | false | Skip sheet animations (sheet instantly snaps to desired location). |
91
93
 
92
94
  **`DEFAULT_SPRING`**
93
95
 
@@ -218,7 +220,7 @@ If the sheet height changes dynamically the sheet will grow until it hits the ma
218
220
 
219
221
  It is possible to use snap points with `detent="content-height"` **but** the snap points are restricted by the content height. For example if one of the snap points is 800px and the sheet height is only 700px then snapping to the 800px snap point would only snap to 700px since otherwise the sheet would become detached from the bottom.
220
222
 
221
- > ℹ️ If you are wondering where the term `detent` comes from it's from Apple's [Human Interface Guidelines](<[detent](https://developer.apple.com/design/human-interface-guidelines/components/presentation/sheets#ios-ipados)>).
223
+ > ℹ️ If you are wondering where the term `detent` comes from it's from Apple's [Human Interface Guidelines](https://developer.apple.com/design/human-interface-guidelines/components/presentation/sheets#ios-ipados).
222
224
 
223
225
  ## Compound Components
224
226
 
@@ -237,7 +239,7 @@ Sheet content acts as a drag target and makes sure that content which doesn't fi
237
239
  #### Content props
238
240
 
239
241
  | Name | Required | Default | Description |
240
- | ------------- | -------- | ------- | ----------------------------------- |
242
+ |---------------|----------|---------|-------------------------------------|
241
243
  | `disableDrag` | no | false | Disable drag for the sheet content. |
242
244
 
243
245
  ### `Sheet.Header`
@@ -249,7 +251,7 @@ Sheet header acts as a drag target and has a dragging direction indicator. Rende
249
251
  #### Header props
250
252
 
251
253
  | Name | Required | Default | Description |
252
- | ------------- | -------- | ------- | ---------------------------------- |
254
+ |---------------|----------|---------|------------------------------------|
253
255
  | `disableDrag` | no | false | Disable drag for the sheet header. |
254
256
 
255
257
  ### `Sheet.Backdrop`
@@ -303,21 +303,32 @@ var Sheet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
303
303
  children = _ref.children,
304
304
  isOpen = _ref.isOpen,
305
305
  snapPoints = _ref.snapPoints,
306
- detent = _ref.detent,
307
- _ref$initialSnap = _ref.initialSnap,
308
- initialSnap = _ref$initialSnap === void 0 ? 0 : _ref$initialSnap,
309
306
  rootId = _ref.rootId,
310
307
  mountPoint = _ref.mountPoint,
308
+ style = _ref.style,
309
+ _ref$detent = _ref.detent,
310
+ detent = _ref$detent === void 0 ? 'full-height' : _ref$detent,
311
+ _ref$initialSnap = _ref.initialSnap,
312
+ initialSnap = _ref$initialSnap === void 0 ? 0 : _ref$initialSnap,
311
313
  _ref$springConfig = _ref.springConfig,
312
314
  springConfig = _ref$springConfig === void 0 ? DEFAULT_SPRING_CONFIG : _ref$springConfig,
313
315
  _ref$disableDrag = _ref.disableDrag,
314
316
  disableDrag = _ref$disableDrag === void 0 ? false : _ref$disableDrag,
315
- style = _ref.style,
316
- rest = _objectWithoutPropertiesLoose(_ref, ["onOpenStart", "onOpenEnd", "onClose", "onCloseStart", "onCloseEnd", "onSnap", "children", "isOpen", "snapPoints", "detent", "initialSnap", "rootId", "mountPoint", "springConfig", "disableDrag", "style"]);
317
+ _ref$prefersReducedMo = _ref.prefersReducedMotion,
318
+ prefersReducedMotion = _ref$prefersReducedMo === void 0 ? false : _ref$prefersReducedMo,
319
+ rest = _objectWithoutPropertiesLoose(_ref, ["onOpenStart", "onOpenEnd", "onClose", "onCloseStart", "onCloseEnd", "onSnap", "children", "isOpen", "snapPoints", "rootId", "mountPoint", "style", "detent", "initialSnap", "springConfig", "disableDrag", "prefersReducedMotion"]);
317
320
 
318
321
  var sheetRef = React.useRef(null);
319
322
  var indicatorRotation = framerMotion.useMotionValue(0);
320
- var windowHeight = useWindowHeight(); // NOTE: the inital value for `y` doesn't matter since it is overwritten by
323
+ var windowHeight = useWindowHeight();
324
+ var shouldReduceMotion = framerMotion.useReducedMotion();
325
+ var reduceMotion = Boolean(prefersReducedMotion || shouldReduceMotion);
326
+ var animationOptions = reduceMotion ? {
327
+ type: 'tween',
328
+ duration: 0.01
329
+ } : _extends({
330
+ type: 'spring'
331
+ }, springConfig); // NOTE: the inital value for `y` doesn't matter since it is overwritten by
321
332
  // the value driven by the `AnimatePresence` component when the sheet is opened
322
333
  // and after that it is driven by the gestures and/or snapping
323
334
 
@@ -394,9 +405,7 @@ var Sheet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
394
405
  sheetHeight: sheetHeight
395
406
  }); // Update the spring value so that the sheet is animated to the snap point
396
407
 
397
- framerMotion.animate(y, snapTo, _extends({
398
- type: 'spring'
399
- }, springConfig));
408
+ framerMotion.animate(y, snapTo, animationOptions);
400
409
 
401
410
  if (snapPoints && onSnap) {
402
411
  var snapValue = Math.abs(Math.round(snapPoints[0] - snapTo));
@@ -431,9 +440,7 @@ var Sheet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
431
440
  snapTo: sheetHeight - snapPoint,
432
441
  sheetHeight: sheetHeight
433
442
  });
434
- framerMotion.animate(y, snapTo, _extends({
435
- type: 'spring'
436
- }, springConfig));
443
+ framerMotion.animate(y, snapTo, animationOptions);
437
444
  if (onSnap) onSnap(snapIndex);
438
445
  if (snapTo >= sheetHeight) onClose();
439
446
  }
@@ -472,7 +479,8 @@ var Sheet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
472
479
  callbacks: callbacks,
473
480
  dragProps: dragProps,
474
481
  windowHeight: windowHeight,
475
- springConfig: springConfig
482
+ animationOptions: animationOptions,
483
+ reduceMotion: reduceMotion
476
484
  };
477
485
  var sheet = React.createElement(SheetContext.Provider, {
478
486
  value: context
@@ -503,9 +511,9 @@ var SheetContainer = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
503
511
  initialSnap = _useSheetContext$init === void 0 ? 0 : _useSheetContext$init,
504
512
  sheetRef = _useSheetContext.sheetRef,
505
513
  windowHeight = _useSheetContext.windowHeight,
506
- springConfig = _useSheetContext.springConfig,
507
- _useSheetContext$dete = _useSheetContext.detent,
508
- detent = _useSheetContext$dete === void 0 ? 'full-height' : _useSheetContext$dete;
514
+ detent = _useSheetContext.detent,
515
+ animationOptions = _useSheetContext.animationOptions,
516
+ reduceMotion = _useSheetContext.reduceMotion;
509
517
 
510
518
  var _useEventCallbacks = useEventCallbacks(isOpen, callbacks),
511
519
  handleAnimationComplete = _useEventCallbacks.handleAnimationComplete;
@@ -523,17 +531,16 @@ var SheetContainer = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
523
531
  }, {
524
532
  y: y
525
533
  }),
526
- initial: {
534
+ initial: reduceMotion ? false : {
527
535
  y: windowHeight
528
536
  },
529
537
  animate: {
530
538
  y: initialY,
531
- transition: _extends({
532
- type: 'spring'
533
- }, springConfig)
539
+ transition: animationOptions
534
540
  },
535
541
  exit: {
536
- y: windowHeight
542
+ y: windowHeight,
543
+ transition: animationOptions
537
544
  },
538
545
  onAnimationComplete: handleAnimationComplete
539
546
  }), children);
@@ -542,27 +549,33 @@ var SheetContainer = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
542
549
  var SheetContent = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
543
550
  var children = _ref.children,
544
551
  style = _ref.style,
545
- rest = _objectWithoutPropertiesLoose(_ref, ["children", "style"]);
552
+ disableDrag = _ref.disableDrag,
553
+ rest = _objectWithoutPropertiesLoose(_ref, ["children", "style", "disableDrag"]);
546
554
 
547
555
  var _useSheetContext = useSheetContext(),
548
556
  dragProps = _useSheetContext.dragProps;
549
557
 
558
+ var _dragProps = disableDrag ? undefined : dragProps;
559
+
550
560
  return React.createElement(framerMotion.motion.div, Object.assign({}, rest, {
551
561
  ref: ref,
552
562
  className: "react-modal-sheet-content",
553
563
  style: _extends({}, styles.content, style)
554
- }, dragProps), children);
564
+ }, _dragProps), children);
555
565
  });
556
566
 
557
567
  var SheetHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
558
568
  var children = _ref.children,
559
569
  style = _ref.style,
560
- rest = _objectWithoutPropertiesLoose(_ref, ["children", "style"]);
570
+ disableDrag = _ref.disableDrag,
571
+ rest = _objectWithoutPropertiesLoose(_ref, ["children", "style", "disableDrag"]);
561
572
 
562
573
  var _useSheetContext = useSheetContext(),
563
574
  indicatorRotation = _useSheetContext.indicatorRotation,
564
575
  dragProps = _useSheetContext.dragProps;
565
576
 
577
+ var _dragProps = disableDrag ? undefined : dragProps;
578
+
566
579
  var indicator1Transform = framerMotion.useTransform(indicatorRotation, function (r) {
567
580
  return "translateX(2px) rotate(" + r + "deg)";
568
581
  });
@@ -572,7 +585,7 @@ var SheetHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
572
585
  return React.createElement(framerMotion.motion.div, Object.assign({}, rest, {
573
586
  ref: ref,
574
587
  style: _extends({}, styles.headerWrapper, style)
575
- }, dragProps), children || React.createElement("div", {
588
+ }, _dragProps), children || React.createElement("div", {
576
589
  className: "react-modal-sheet-header",
577
590
  style: styles.header
578
591
  }, React.createElement(framerMotion.motion.span, {
@@ -1 +1 @@
1
- {"version":3,"file":"react-modal-sheet.cjs.development.js","sources":["../src/constants.ts","../src/utils.ts","../src/hooks.tsx","../src/context.tsx","../src/styles.ts","../src/sheet.tsx","../src/SheetContainer.tsx","../src/SheetContent.tsx","../src/SheetHeader.tsx","../src/SheetBackdrop.tsx","../src/index.tsx"],"sourcesContent":["export const MAX_HEIGHT = 'calc(100% - env(safe-area-inset-top) - 34px)';\n\nexport const IS_SSR = typeof window === 'undefined';\n\nexport const DEFAULT_SPRING_CONFIG = {\n stiffness: 300,\n damping: 30,\n mass: 0.2,\n};\n\nexport const DRAG_CLOSE_THRESHOLD = 0.6;\n\nexport const DRAG_VELOCITY_THRESHOLD = 500;\n","export function 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\nexport function inDescendingOrder(arr: number[]) {\n for (let i = 0; i < arr.length; i++) {\n if (arr[i + 1] > arr[i]) return false;\n }\n\n return true;\n}\n\nexport function validateSnapTo({\n snapTo,\n sheetHeight,\n}: {\n snapTo: number;\n sheetHeight: number;\n}) {\n if (snapTo < 0) {\n console.warn(\n `Snap point is out of bounds. Sheet height is ${sheetHeight} but snap point is ${sheetHeight +\n Math.abs(snapTo)}.`\n );\n }\n\n return Math.max(Math.round(snapTo), 0);\n}\n","import * as React from 'react';\n\nimport { IS_SSR } from './constants';\nimport { SheetEvents } from './types';\nimport { applyRootStyles, cleanupRootStyles } from './utils';\n\nexport const useIsomorphicLayoutEffect = IS_SSR\n ? React.useEffect\n : React.useLayoutEffect;\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\nexport function useWindowHeight() {\n const [windowHeight, setWindowHeight] = React.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 function 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\n// Userland version of the `useEvent` React hook:\n// RFC: https://github.com/reactjs/rfcs/blob/useevent/text/0000-useevent.md\nexport function useEvent<T extends (...args: any[]) => any>(handler: T) {\n const handlerRef = React.useRef<T>();\n\n useIsomorphicLayoutEffect(() => {\n handlerRef.current = handler;\n });\n\n return React.useCallback((...args: any[]) => {\n const fn = handlerRef.current;\n return fn?.(...args);\n }, []) as T;\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 CSS from 'csstype';\n\nconst styles: { [key: string]: CSS.Properties } = {\n wrapper: {\n position: 'fixed',\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n zIndex: 9999999,\n overflow: 'hidden',\n pointerEvents: 'none',\n },\n backdrop: {\n zIndex: 1,\n position: 'fixed',\n top: 0,\n left: 0,\n width: '100%',\n height: '100%',\n backgroundColor: 'rgba(51, 51, 51, 0.5)',\n touchAction: 'none', // Disable iOS body scrolling\n },\n container: {\n zIndex: 2,\n position: 'absolute',\n left: 0,\n bottom: 0,\n width: '100%',\n backgroundColor: '#fff',\n borderTopRightRadius: '8px',\n borderTopLeftRadius: '8px',\n boxShadow: '0px -2px 16px rgba(0, 0, 0, 0.3)',\n display: 'flex',\n flexDirection: 'column',\n pointerEvents: 'auto',\n },\n headerWrapper: {\n width: '100%',\n },\n header: {\n height: '40px',\n width: '100%',\n position: 'relative',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n },\n indicator: {\n width: '18px',\n height: '4px',\n borderRadius: '99px',\n backgroundColor: '#ddd',\n },\n content: {\n flex: 1,\n overflow: 'auto',\n position: 'relative',\n },\n};\n\nexport default styles;\n","import * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport { usePreventScroll } from '@react-aria/overlays';\n\nimport {\n animate,\n AnimatePresence,\n PanInfo,\n useMotionValue,\n} from 'framer-motion';\n\nimport {\n useModalEffect,\n useWindowHeight,\n useIsomorphicLayoutEffect,\n useEvent,\n} from './hooks';\n\nimport {\n DEFAULT_SPRING_CONFIG,\n DRAG_CLOSE_THRESHOLD,\n DRAG_VELOCITY_THRESHOLD,\n IS_SSR,\n} from './constants';\n\nimport { SheetContextType, SheetProps } from './types';\nimport { SheetContext } from './context';\nimport { getClosest, inDescendingOrder, validateSnapTo } from './utils';\nimport styles from './styles';\n\nconst Sheet = React.forwardRef<any, SheetProps>(\n (\n {\n onOpenStart,\n onOpenEnd,\n onClose,\n onCloseStart,\n onCloseEnd,\n onSnap,\n children,\n isOpen,\n snapPoints,\n detent,\n initialSnap = 0,\n rootId,\n mountPoint,\n springConfig = DEFAULT_SPRING_CONFIG,\n disableDrag = false,\n style,\n ...rest\n },\n ref\n ) => {\n const sheetRef = React.useRef<any>(null);\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 // Keep the callback fns up-to-date so that they can be accessed inside\n // the effect without including them to the dependencies array\n const callbacks = React.useRef({\n onOpenStart,\n onOpenEnd,\n onCloseStart,\n onCloseEnd,\n });\n\n useIsomorphicLayoutEffect(() => {\n callbacks.current = {\n onOpenStart,\n onOpenEnd,\n onCloseStart,\n onCloseEnd,\n };\n });\n\n if (snapPoints) {\n // Convert negative / percentage snap points to absolute values\n snapPoints = snapPoints.map(point => {\n // Percentage values e.g. between 0.0 and 1.0\n if (point > 0 && point <= 1) return Math.round(point * windowHeight);\n return point < 0 ? windowHeight + point : point; // negative values\n });\n\n console.assert(\n inDescendingOrder(snapPoints) || windowHeight === 0,\n `Snap points need to be in descending order got: [${snapPoints}]`\n );\n }\n\n const onDrag = useEvent((_, { delta }: PanInfo) => {\n // Update drag indicator rotation based on drag velocity\n const velocity = y.getVelocity();\n\n if (velocity > 0) indicatorRotation.set(10);\n if (velocity < 0) indicatorRotation.set(-10);\n\n // Make sure user cannot drag beyond the top of the sheet\n y.set(Math.max(y.get() + delta.y, 0));\n });\n\n const onDragEnd = useEvent((_, { velocity }: PanInfo) => {\n if (velocity.y > DRAG_VELOCITY_THRESHOLD) {\n // User flicked the sheet down\n onClose();\n } else {\n const sheetEl = sheetRef.current as HTMLDivElement;\n const sheetHeight = sheetEl.getBoundingClientRect().height;\n const currentY = y.get();\n\n let snapTo = 0;\n\n if (snapPoints) {\n const snapToValues = snapPoints\n .map(p => sheetHeight - p)\n .filter(p => p >= 0); // negative values can occur with `content-height` detent\n\n // Allow snapping to the top of the sheet if detent is set to `content-height`\n if (detent === 'content-height' && !snapToValues.includes(0)) {\n snapToValues.unshift(0);\n }\n\n // Get the closest snap point\n snapTo = getClosest(snapToValues, currentY);\n } else if (currentY / sheetHeight > DRAG_CLOSE_THRESHOLD) {\n // Close if dragged over enough far\n snapTo = sheetHeight;\n }\n\n snapTo = validateSnapTo({ snapTo, sheetHeight });\n\n // Update the spring value so that the sheet is animated to the snap point\n animate(y, snapTo, { type: 'spring', ...springConfig });\n\n if (snapPoints && onSnap) {\n const snapValue = Math.abs(Math.round(snapPoints[0] - snapTo));\n const snapIndex = snapPoints.indexOf(getClosest(snapPoints, snapValue)); // prettier-ignore\n onSnap(snapIndex);\n }\n\n if (snapTo >= sheetHeight) onClose();\n }\n\n // Reset indicator rotation after dragging\n indicatorRotation.set(0);\n });\n\n // Trigger onSnap callback when sheet is opened or closed\n 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\n if (\n snapPoints &&\n snapPoints[snapIndex] !== undefined &&\n sheetEl !== null\n ) {\n const sheetHeight = sheetEl.getBoundingClientRect().height;\n const snapPoint = snapPoints[snapIndex];\n const snapTo = validateSnapTo({\n snapTo: sheetHeight - snapPoint,\n sheetHeight,\n });\n\n animate(y, snapTo, { type: 'spring', ...springConfig });\n\n if (onSnap) onSnap(snapIndex);\n if (snapTo >= sheetHeight) onClose();\n }\n },\n }));\n\n useModalEffect(isOpen, rootId);\n\n // Framer Motion should handle body scroll locking but it's not working\n // properly on iOS. Scroll locking from React Aria seems to work much better.\n usePreventScroll({ isDisabled: !isOpen });\n\n const dragProps = React.useMemo(() => {\n const dragProps: SheetContextType['dragProps'] = {\n drag: 'y',\n dragElastic: 0,\n dragConstraints: { top: 0, bottom: 0 },\n dragMomentum: false,\n onDrag,\n onDragEnd,\n };\n\n return disableDrag ? undefined : dragProps;\n }, [disableDrag]); // eslint-disable-line\n\n const context: SheetContextType = {\n y,\n sheetRef,\n isOpen,\n initialSnap,\n snapPoints,\n detent,\n indicatorRotation,\n callbacks,\n dragProps,\n windowHeight,\n springConfig,\n };\n\n const sheet = (\n <SheetContext.Provider value={context}>\n <div {...rest} ref={ref} style={{ ...styles.wrapper, ...style }}>\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 (IS_SSR) return sheet;\n\n return ReactDOM.createPortal(sheet, mountPoint ?? document.body);\n }\n);\n\nexport default Sheet;\n","import * as React from 'react';\nimport { motion } from 'framer-motion';\nimport mergeRefs from 'react-merge-refs';\n\nimport { SheetContainerProps } from './types';\nimport { useSheetContext } from './context';\nimport { useEventCallbacks } from './hooks';\nimport { MAX_HEIGHT } from './constants';\nimport styles from './styles';\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 detent = 'full-height',\n } = useSheetContext();\n\n const { handleAnimationComplete } = useEventCallbacks(isOpen, callbacks);\n const initialY = snapPoints ? snapPoints[0] - snapPoints[initialSnap] : 0;\n const maxSnapHeight = snapPoints ? snapPoints[0] : null;\n\n const height =\n maxSnapHeight !== null\n ? `min(${maxSnapHeight}px, ${MAX_HEIGHT})`\n : MAX_HEIGHT;\n\n return (\n <motion.div\n {...rest}\n ref={mergeRefs([sheetRef, ref])}\n className=\"react-modal-sheet-container\"\n style={{\n ...styles.container,\n ...style,\n ...(detent === 'full-height' && { height }),\n ...(detent === 'content-height' && { maxHeight: height }),\n y,\n }}\n initial={{ y: windowHeight }}\n animate={{\n y: initialY,\n transition: { type: 'spring', ...springConfig },\n }}\n exit={{ y: windowHeight }}\n onAnimationComplete={handleAnimationComplete}\n >\n {children}\n </motion.div>\n );\n }\n);\n\nexport default SheetContainer;\n","import * as React from 'react';\nimport { motion } from 'framer-motion';\n\nimport { SheetDraggableProps } from './types';\nimport { useSheetContext } from './context';\nimport styles from './styles';\n\nconst SheetContent = React.forwardRef<any, SheetDraggableProps>(\n ({ children, 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 {...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, 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 {...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":["MAX_HEIGHT","IS_SSR","window","DEFAULT_SPRING_CONFIG","stiffness","damping","mass","DRAG_CLOSE_THRESHOLD","DRAG_VELOCITY_THRESHOLD","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","inDescendingOrder","arr","i","length","validateSnapTo","snapTo","sheetHeight","console","warn","max","round","useIsomorphicLayoutEffect","React","useModalEffect","isOpen","prevOpen","usePrevious","useEventCallbacks","callbacks","didOpen","handleAnimationComplete","current","onOpenEnd","onCloseEnd","onOpenStart","onCloseStart","useWindowHeight","windowHeight","setWindowHeight","updateHeight","state","ref","useEvent","handler","handlerRef","fn","args","SheetContext","undefined","useSheetContext","context","Error","styles","wrapper","zIndex","pointerEvents","backdrop","width","height","touchAction","container","boxShadow","display","flexDirection","headerWrapper","header","alignItems","justifyContent","indicator","borderRadius","content","flex","Sheet","onClose","onSnap","children","snapPoints","detent","initialSnap","mountPoint","springConfig","disableDrag","rest","sheetRef","indicatorRotation","useMotionValue","y","map","point","assert","onDrag","_","delta","velocity","getVelocity","set","get","onDragEnd","sheetEl","getBoundingClientRect","currentY","snapToValues","filter","includes","unshift","animate","type","snapValue","snapIndex","indexOf","snapPoint","usePreventScroll","isDisabled","dragProps","drag","dragElastic","dragConstraints","dragMomentum","sheet","Provider","value","AnimatePresence","child","key","ReactDOM","SheetContainer","initialY","maxSnapHeight","motion","div","mergeRefs","className","maxHeight","initial","exit","onAnimationComplete","SheetContent","SheetHeader","indicator1Transform","useTransform","r","indicator2Transform","span","isClickable","props","onClick","onTap","SheetBackdrop","Comp","button","_SheetCompound","Container","Header","Content","Backdrop"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,IAAMA,UAAU,GAAG,8CAAnB;AAEA,IAAMC,MAAM,GAAG,OAAOC,MAAP,KAAkB,WAAjC;AAEA,IAAMC,qBAAqB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utils.ts","../src/hooks.tsx","../src/context.tsx","../src/styles.ts","../src/sheet.tsx","../src/SheetContainer.tsx","../src/SheetContent.tsx","../src/SheetHeader.tsx","../src/SheetBackdrop.tsx","../src/index.tsx"],"sourcesContent":["export const MAX_HEIGHT = 'calc(100% - env(safe-area-inset-top) - 34px)';\n\nexport const IS_SSR = typeof window === 'undefined';\n\nexport const DEFAULT_SPRING_CONFIG = {\n stiffness: 300,\n damping: 30,\n mass: 0.2,\n};\n\nexport const DRAG_CLOSE_THRESHOLD = 0.6;\n\nexport const DRAG_VELOCITY_THRESHOLD = 500;\n","export function 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\nexport function inDescendingOrder(arr: number[]) {\n for (let i = 0; i < arr.length; i++) {\n if (arr[i + 1] > arr[i]) return false;\n }\n\n return true;\n}\n\nexport function validateSnapTo({\n snapTo,\n sheetHeight,\n}: {\n snapTo: number;\n sheetHeight: number;\n}) {\n if (snapTo < 0) {\n console.warn(\n `Snap point is out of bounds. Sheet height is ${sheetHeight} but snap point is ${sheetHeight +\n Math.abs(snapTo)}.`\n );\n }\n\n return Math.max(Math.round(snapTo), 0);\n}\n","import * as React from 'react';\n\nimport { IS_SSR } from './constants';\nimport { SheetEvents } from './types';\nimport { applyRootStyles, cleanupRootStyles } from './utils';\n\nexport const useIsomorphicLayoutEffect = IS_SSR\n ? React.useEffect\n : React.useLayoutEffect;\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\nexport function useWindowHeight() {\n const [windowHeight, setWindowHeight] = React.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 function 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\n// Userland version of the `useEvent` React hook:\n// RFC: https://github.com/reactjs/rfcs/blob/useevent/text/0000-useevent.md\nexport function useEvent<T extends (...args: any[]) => any>(handler: T) {\n const handlerRef = React.useRef<T>();\n\n useIsomorphicLayoutEffect(() => {\n handlerRef.current = handler;\n });\n\n return React.useCallback((...args: any[]) => {\n const fn = handlerRef.current;\n return fn?.(...args);\n }, []) as T;\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 CSS from 'csstype';\n\nconst styles: { [key: string]: CSS.Properties } = {\n wrapper: {\n position: 'fixed',\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n zIndex: 9999999,\n overflow: 'hidden',\n pointerEvents: 'none',\n },\n backdrop: {\n zIndex: 1,\n position: 'fixed',\n top: 0,\n left: 0,\n width: '100%',\n height: '100%',\n backgroundColor: 'rgba(51, 51, 51, 0.5)',\n touchAction: 'none', // Disable iOS body scrolling\n },\n container: {\n zIndex: 2,\n position: 'absolute',\n left: 0,\n bottom: 0,\n width: '100%',\n backgroundColor: '#fff',\n borderTopRightRadius: '8px',\n borderTopLeftRadius: '8px',\n boxShadow: '0px -2px 16px rgba(0, 0, 0, 0.3)',\n display: 'flex',\n flexDirection: 'column',\n pointerEvents: 'auto',\n },\n headerWrapper: {\n width: '100%',\n },\n header: {\n height: '40px',\n width: '100%',\n position: 'relative',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n },\n indicator: {\n width: '18px',\n height: '4px',\n borderRadius: '99px',\n backgroundColor: '#ddd',\n },\n content: {\n flex: 1,\n overflow: 'auto',\n position: 'relative',\n },\n};\n\nexport default styles;\n","import * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport { usePreventScroll } from '@react-aria/overlays';\n\nimport {\n animate,\n AnimatePresence,\n AnimationOptions,\n PanInfo,\n useMotionValue,\n useReducedMotion,\n} from 'framer-motion';\n\nimport {\n useModalEffect,\n useWindowHeight,\n useIsomorphicLayoutEffect,\n useEvent,\n} from './hooks';\n\nimport {\n DEFAULT_SPRING_CONFIG,\n DRAG_CLOSE_THRESHOLD,\n DRAG_VELOCITY_THRESHOLD,\n IS_SSR,\n} from './constants';\n\nimport { SheetContextType, SheetProps } from './types';\nimport { SheetContext } from './context';\nimport { getClosest, inDescendingOrder, validateSnapTo } from './utils';\nimport styles from './styles';\n\nconst Sheet = React.forwardRef<any, SheetProps>(\n (\n {\n onOpenStart,\n onOpenEnd,\n onClose,\n onCloseStart,\n onCloseEnd,\n onSnap,\n children,\n isOpen,\n snapPoints,\n rootId,\n mountPoint,\n style,\n detent = 'full-height',\n initialSnap = 0,\n springConfig = DEFAULT_SPRING_CONFIG,\n disableDrag = false,\n prefersReducedMotion = false,\n ...rest\n },\n ref\n ) => {\n const sheetRef = React.useRef<any>(null);\n const indicatorRotation = useMotionValue(0);\n const windowHeight = useWindowHeight();\n const shouldReduceMotion = useReducedMotion();\n const reduceMotion = Boolean(prefersReducedMotion || shouldReduceMotion);\n const animationOptions: AnimationOptions<number> = reduceMotion\n ? { type: 'tween', duration: 0.01 }\n : { type: 'spring', ...springConfig };\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 // Keep the callback fns up-to-date so that they can be accessed inside\n // the effect without including them to the dependencies array\n const callbacks = React.useRef({\n onOpenStart,\n onOpenEnd,\n onCloseStart,\n onCloseEnd,\n });\n\n useIsomorphicLayoutEffect(() => {\n callbacks.current = {\n onOpenStart,\n onOpenEnd,\n onCloseStart,\n onCloseEnd,\n };\n });\n\n if (snapPoints) {\n // Convert negative / percentage snap points to absolute values\n snapPoints = snapPoints.map(point => {\n // Percentage values e.g. between 0.0 and 1.0\n if (point > 0 && point <= 1) return Math.round(point * windowHeight);\n return point < 0 ? windowHeight + point : point; // negative values\n });\n\n console.assert(\n inDescendingOrder(snapPoints) || windowHeight === 0,\n `Snap points need to be in descending order got: [${snapPoints}]`\n );\n }\n\n const onDrag = useEvent((_, { delta }: PanInfo) => {\n // Update drag indicator rotation based on drag velocity\n const velocity = y.getVelocity();\n\n if (velocity > 0) indicatorRotation.set(10);\n if (velocity < 0) indicatorRotation.set(-10);\n\n // Make sure user cannot drag beyond the top of the sheet\n y.set(Math.max(y.get() + delta.y, 0));\n });\n\n const onDragEnd = useEvent((_, { velocity }: PanInfo) => {\n if (velocity.y > DRAG_VELOCITY_THRESHOLD) {\n // User flicked the sheet down\n onClose();\n } else {\n const sheetEl = sheetRef.current as HTMLDivElement;\n const sheetHeight = sheetEl.getBoundingClientRect().height;\n const currentY = y.get();\n\n let snapTo = 0;\n\n if (snapPoints) {\n const snapToValues = snapPoints\n .map(p => sheetHeight - p)\n .filter(p => p >= 0); // negative values can occur with `content-height` detent\n\n // Allow snapping to the top of the sheet if detent is set to `content-height`\n if (detent === 'content-height' && !snapToValues.includes(0)) {\n snapToValues.unshift(0);\n }\n\n // Get the closest snap point\n snapTo = getClosest(snapToValues, currentY);\n } else if (currentY / sheetHeight > DRAG_CLOSE_THRESHOLD) {\n // Close if dragged over enough far\n snapTo = sheetHeight;\n }\n\n snapTo = validateSnapTo({ snapTo, sheetHeight });\n\n // Update the spring value so that the sheet is animated to the snap point\n animate(y, snapTo, animationOptions);\n\n if (snapPoints && onSnap) {\n const snapValue = Math.abs(Math.round(snapPoints[0] - snapTo));\n const snapIndex = snapPoints.indexOf(getClosest(snapPoints, snapValue)); // prettier-ignore\n onSnap(snapIndex);\n }\n\n if (snapTo >= sheetHeight) onClose();\n }\n\n // Reset indicator rotation after dragging\n indicatorRotation.set(0);\n });\n\n // Trigger onSnap callback when sheet is opened or closed\n 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\n if (\n snapPoints &&\n snapPoints[snapIndex] !== undefined &&\n sheetEl !== null\n ) {\n const sheetHeight = sheetEl.getBoundingClientRect().height;\n const snapPoint = snapPoints[snapIndex];\n const snapTo = validateSnapTo({\n snapTo: sheetHeight - snapPoint,\n sheetHeight,\n });\n\n animate(y, snapTo, animationOptions);\n if (onSnap) onSnap(snapIndex);\n if (snapTo >= sheetHeight) onClose();\n }\n },\n }));\n\n useModalEffect(isOpen, rootId);\n\n // Framer Motion should handle body scroll locking but it's not working\n // properly on iOS. Scroll locking from React Aria seems to work much better.\n usePreventScroll({ isDisabled: !isOpen });\n\n const dragProps = React.useMemo(() => {\n const dragProps: SheetContextType['dragProps'] = {\n drag: 'y',\n dragElastic: 0,\n dragConstraints: { top: 0, bottom: 0 },\n dragMomentum: false,\n onDrag,\n onDragEnd,\n };\n\n return disableDrag ? undefined : dragProps;\n }, [disableDrag]); // eslint-disable-line\n\n const context: SheetContextType = {\n y,\n sheetRef,\n isOpen,\n initialSnap,\n snapPoints,\n detent,\n indicatorRotation,\n callbacks,\n dragProps,\n windowHeight,\n animationOptions,\n reduceMotion,\n };\n\n const sheet = (\n <SheetContext.Provider value={context}>\n <div {...rest} ref={ref} style={{ ...styles.wrapper, ...style }}>\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 (IS_SSR) return sheet;\n\n return ReactDOM.createPortal(sheet, mountPoint ?? document.body);\n }\n);\n\nexport default Sheet;\n","import * as React from 'react';\nimport { motion } from 'framer-motion';\nimport mergeRefs from 'react-merge-refs';\n\nimport { SheetContainerProps } from './types';\nimport { useSheetContext } from './context';\nimport { useEventCallbacks } from './hooks';\nimport { MAX_HEIGHT } from './constants';\nimport styles from './styles';\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 detent,\n animationOptions,\n reduceMotion,\n } = useSheetContext();\n\n const { handleAnimationComplete } = useEventCallbacks(isOpen, callbacks);\n const initialY = snapPoints ? snapPoints[0] - snapPoints[initialSnap] : 0;\n const maxSnapHeight = snapPoints ? snapPoints[0] : null;\n\n const height =\n maxSnapHeight !== null\n ? `min(${maxSnapHeight}px, ${MAX_HEIGHT})`\n : MAX_HEIGHT;\n\n return (\n <motion.div\n {...rest}\n ref={mergeRefs([sheetRef, ref])}\n className=\"react-modal-sheet-container\"\n style={{\n ...styles.container,\n ...style,\n ...(detent === 'full-height' && { height }),\n ...(detent === 'content-height' && { maxHeight: height }),\n y,\n }}\n initial={reduceMotion ? false : { y: windowHeight }}\n animate={{ y: initialY, transition: animationOptions }}\n exit={{ y: windowHeight, transition: animationOptions }}\n onAnimationComplete={handleAnimationComplete}\n >\n {children}\n </motion.div>\n );\n }\n);\n\nexport default SheetContainer;\n","import * as React from 'react';\nimport { motion } from 'framer-motion';\n\nimport { SheetDraggableProps } from './types';\nimport { useSheetContext } from './context';\nimport styles from './styles';\n\nconst SheetContent = React.forwardRef<any, SheetDraggableProps>(\n ({ children, style, disableDrag, ...rest }, ref) => {\n const { dragProps } = useSheetContext();\n const _dragProps = disableDrag ? undefined : dragProps;\n\n return (\n <motion.div\n {...rest}\n ref={ref}\n className=\"react-modal-sheet-content\"\n style={{ ...styles.content, ...style }}\n {..._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, style, disableDrag, ...rest }, ref) => {\n const { indicatorRotation, dragProps } = useSheetContext();\n const _dragProps = disableDrag ? undefined : dragProps;\n\n const indicator1Transform = useTransform(\n indicatorRotation,\n r => `translateX(2px) rotate(${r}deg)`\n );\n\n const indicator2Transform = useTransform(\n indicatorRotation,\n r => `translateX(-2px) rotate(${-1 * r}deg)`\n );\n\n return (\n <motion.div\n {...rest}\n ref={ref}\n style={{ ...styles.headerWrapper, ...style }}\n {..._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":["MAX_HEIGHT","IS_SSR","window","DEFAULT_SPRING_CONFIG","stiffness","damping","mass","DRAG_CLOSE_THRESHOLD","DRAG_VELOCITY_THRESHOLD","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","inDescendingOrder","arr","i","length","validateSnapTo","snapTo","sheetHeight","console","warn","max","round","useIsomorphicLayoutEffect","React","useModalEffect","isOpen","prevOpen","usePrevious","useEventCallbacks","callbacks","didOpen","handleAnimationComplete","current","onOpenEnd","onCloseEnd","onOpenStart","onCloseStart","useWindowHeight","windowHeight","setWindowHeight","updateHeight","state","ref","useEvent","handler","handlerRef","fn","args","SheetContext","undefined","useSheetContext","context","Error","styles","wrapper","zIndex","pointerEvents","backdrop","width","height","touchAction","container","boxShadow","display","flexDirection","headerWrapper","header","alignItems","justifyContent","indicator","borderRadius","content","flex","Sheet","onClose","onSnap","children","snapPoints","mountPoint","detent","initialSnap","springConfig","disableDrag","prefersReducedMotion","rest","sheetRef","indicatorRotation","useMotionValue","shouldReduceMotion","useReducedMotion","reduceMotion","Boolean","animationOptions","type","duration","y","map","point","assert","onDrag","_","delta","velocity","getVelocity","set","get","onDragEnd","sheetEl","getBoundingClientRect","currentY","snapToValues","filter","includes","unshift","animate","snapValue","snapIndex","indexOf","snapPoint","usePreventScroll","isDisabled","dragProps","drag","dragElastic","dragConstraints","dragMomentum","sheet","Provider","value","AnimatePresence","child","key","ReactDOM","SheetContainer","initialY","maxSnapHeight","motion","div","mergeRefs","className","maxHeight","initial","exit","onAnimationComplete","SheetContent","_dragProps","SheetHeader","indicator1Transform","useTransform","r","indicator2Transform","span","isClickable","props","onClick","onTap","SheetBackdrop","Comp","button","_SheetCompound","Container","Header","Content","Backdrop"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,IAAMA,UAAU,GAAG,8CAAnB;AAEA,IAAMC,MAAM,GAAG,OAAOC,MAAP,KAAkB,WAAjC;AAEA,IAAMC,qBAAqB,GAAG;AACnCC,EAAAA,SAAS,EAAE,GADwB;AAEnCC,EAAAA,OAAO,EAAE,EAF0B;AAGnCC,EAAAA,IAAI,EAAE;AAH6B,CAA9B;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EAAE;AAAX;AACT8I,IAAAA,IAAI,EAAE;AAAE9I,MAAAA,OAAO,EAAE;AAAX;IAPR,CADF;AAWD,CAhBmB,CAAtB;;ACOA,IAAM+J,cAAc,GAAQtF,KAA5B;AACAsF,cAAc,CAACC,SAAf,GAA2B3B,cAA3B;AACA0B,cAAc,CAACE,MAAf,GAAwBf,WAAxB;AACAa,cAAc,CAACG,OAAf,GAAyBlB,YAAzB;AACAe,cAAc,CAACI,QAAf,GAA0BP,aAA1B;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),n=require("react-dom"),r=require("@react-aria/overlays"),o=require("framer-motion"),i=(e=require("react-merge-refs"))&&"object"==typeof e&&"default"in e?e.default:e;function a(){return(a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function s(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)t.indexOf(n=i[r])>=0||(o[n]=e[n]);return o}var l="calc(100% - env(safe-area-inset-top) - 34px)",u="undefined"==typeof window,c={stiffness:300,damping:30,mass:.2};function d(e,t){return e.reduce((function(e,n){return Math.abs(n-t)<Math.abs(e-t)?n:e}))}function f(e){var t=document.querySelector("body"),n=document.getElementById(e),r=document.getElementById("react-modal-sheet-highlight");n&&r&&(n.style.removeProperty("border-top-right-radius"),n.style.removeProperty("border-top-left-radius"),n.style.removeProperty("transform"),r.style.opacity="0",n.addEventListener("transitionend",(function e(){var o;n.style.removeProperty("overflow"),n.style.removeProperty("will-change"),n.style.removeProperty("transition"),t.style.removeProperty("background-color"),n.removeEventListener("transitionend",e),null==(o=r.parentNode)||o.removeChild(r)})))}function p(e){var t=e.snapTo,n=e.sheetHeight;return t<0&&console.warn("Snap point is out of bounds. Sheet height is "+n+" but snap point is "+(n+Math.abs(t))+"."),Math.max(Math.round(t),0)}var h=u?t.useEffect:t.useLayoutEffect;function m(e){var n=t.useRef();return t.useEffect((function(){n.current=e})),n.current}function y(e){var n=t.useRef();return h((function(){n.current=e})),t.useCallback((function(){for(var e=n.current,t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];return null==e?void 0:e.apply(void 0,r)}),[])}var g=t.createContext(void 0),v=function(){var e=t.useContext(g);if(!e)throw Error("Sheet context error");return e},b={wrapper:{position:"fixed",top:0,bottom:0,left:0,right:0,zIndex:9999999,overflow:"hidden",pointerEvents:"none"},backdrop:{zIndex:1,position:"fixed",top:0,left:0,width:"100%",height:"100%",backgroundColor:"rgba(51, 51, 51, 0.5)",touchAction:"none"},container:{zIndex:2,position:"absolute",left:0,bottom:0,width:"100%",backgroundColor:"#fff",borderTopRightRadius:"8px",borderTopLeftRadius:"8px",boxShadow:"0px -2px 16px rgba(0, 0, 0, 0.3)",display:"flex",flexDirection:"column",pointerEvents:"auto"},headerWrapper:{width:"100%"},header:{height:"40px",width:"100%",position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},indicator:{width:"18px",height:"4px",borderRadius:"99px",backgroundColor:"#ddd"},content:{flex:1,overflow:"auto",position:"relative"}},E=t.forwardRef((function(e,i){var l=e.onOpenStart,v=e.onOpenEnd,E=e.onClose,x=e.onCloseStart,C=e.onCloseEnd,w=e.onSnap,O=e.children,S=e.isOpen,R=e.snapPoints,P=e.detent,k=e.initialSnap,M=void 0===k?0:k,j=e.rootId,T=e.mountPoint,H=e.springConfig,q=void 0===H?c:H,I=e.disableDrag,A=void 0!==I&&I,L=e.style,N=s(e,["onOpenStart","onOpenEnd","onClose","onCloseStart","onCloseEnd","onSnap","children","isOpen","snapPoints","detent","initialSnap","rootId","mountPoint","springConfig","disableDrag","style"]),D=t.useRef(null),z=o.useMotionValue(0),B=function(){var e=t.useState(0),n=e[0],r=e[1];return h((function(){var e=function(){return r(window.innerHeight)};return window.addEventListener("resize",e),e(),function(){return window.removeEventListener("resize",e)}}),[]),n}(),V=o.useMotionValue(0),W=t.useRef({onOpenStart:l,onOpenEnd:v,onCloseStart:x,onCloseEnd:C});h((function(){W.current={onOpenStart:l,onOpenEnd:v,onCloseStart:x,onCloseEnd:C}})),R&&(R=R.map((function(e){return e>0&&e<=1?Math.round(e*B):e<0?B+e:e})),console.assert(function(e){for(var t=0;t<e.length;t++)if(e[t+1]>e[t])return!1;return!0}(R)||0===B,"Snap points need to be in descending order got: ["+R+"]"));var X=y((function(e,t){var n=t.delta,r=V.getVelocity();r>0&&z.set(10),r<0&&z.set(-10),V.set(Math.max(V.get()+n.y,0))})),_=y((function(e,t){if(t.velocity.y>500)E();else{var n=D.current.getBoundingClientRect().height,r=V.get(),i=0;if(R){var s=R.map((function(e){return n-e})).filter((function(e){return e>=0}));"content-height"!==P||s.includes(0)||s.unshift(0),i=d(s,r)}else r/n>.6&&(i=n);if(i=p({snapTo:i,sheetHeight:n}),o.animate(V,i,a({type:"spring"},q)),R&&w){var l=Math.abs(Math.round(R[0]-i)),u=R.indexOf(d(R,l));w(u)}i>=n&&E()}z.set(0)}));t.useEffect((function(){R&&w&&w(S?M:R.length-1)}),[S]),t.useImperativeHandle(i,(function(){return{y:V,snapTo:function(e){var t=D.current;if(R&&void 0!==R[e]&&null!==t){var n=t.getBoundingClientRect().height,r=p({snapTo:n-R[e],sheetHeight:n});o.animate(V,r,a({type:"spring"},q)),w&&w(e),r>=n&&E()}}}})),function(e,n){var r=m(e);t.useEffect((function(){n&&!r&&e?function(e){var t=document.querySelector("body"),n=document.querySelector("#"+e);if(n){var r=window.innerHeight,o=(r-24)/r;t.style.backgroundColor="#000",n.style.overflow="hidden",n.style.willChange="transform",n.style.transition="transform 200ms linear",n.style.transform="translateY(calc(env(safe-area-inset-top) + 12px)) scale("+o+")",n.style.borderTopRightRadius="10px",n.style.borderTopLeftRadius="10px";var i=document.createElement("div");i.setAttribute("aria-hidden","true"),i.id="react-modal-sheet-highlight",i.style.position="absolute",i.style.top="0px",i.style.left="0px",i.style.bottom="0px",i.style.right="0px",i.style.opacity="0",i.style.transition="opacity 200ms linear",i.style.backgroundColor="rgba(150, 150, 150, 0.1)",n.appendChild(i),requestAnimationFrame((function(){return i.style.opacity="1"}))}}(n):n&&!e&&r&&f(n)}),[e,r]),t.useEffect((function(){return function(){n&&e&&f(n)}}),[e])}(S,j),r.usePreventScroll({isDisabled:!S});var F=t.useMemo((function(){return A?void 0:{drag:"y",dragElastic:0,dragConstraints:{top:0,bottom:0},dragMomentum:!1,onDrag:X,onDragEnd:_}}),[A]),Y=t.createElement(g.Provider,{value:{y:V,sheetRef:D,isOpen:S,initialSnap:M,snapPoints:R,detent:P,indicatorRotation:z,callbacks:W,dragProps:F,windowHeight:B,springConfig:q}},t.createElement("div",Object.assign({},N,{ref:i,style:a({},b.wrapper,L)}),t.createElement(o.AnimatePresence,null,S?t.Children.map(O,(function(e,n){return t.cloneElement(e,{key:"sheet-child-"+n})})):null)));return u?Y:n.createPortal(Y,null!=T?T:document.body)})),x=t.forwardRef((function(e,n){var r=e.children,u=e.style,c=void 0===u?{}:u,d=s(e,["children","style"]),f=v(),p=f.y,h=f.snapPoints,y=f.initialSnap,g=void 0===y?0:y,E=f.sheetRef,x=f.windowHeight,C=f.springConfig,w=f.detent,O=void 0===w?"full-height":w,S=function(e,n){var r=m(e),o=t.useRef(!1),i=t.useCallback((function(){o.current?(null==n.current.onCloseEnd||n.current.onCloseEnd(),o.current=!1):(null==n.current.onOpenEnd||n.current.onOpenEnd(),o.current=!0)}),[e,r]);return t.useEffect((function(){!r&&e?null==n.current.onOpenStart||n.current.onOpenStart():!e&&r&&(null==n.current.onCloseStart||n.current.onCloseStart())}),[e,r]),{handleAnimationComplete:i}}(f.isOpen,f.callbacks).handleAnimationComplete,R=h?h[0]-h[g]:0,P=h?h[0]:null,k=null!==P?"min("+P+"px, "+l+")":l;return t.createElement(o.motion.div,Object.assign({},d,{ref:i([E,n]),className:"react-modal-sheet-container",style:a({},b.container,c,"full-height"===O&&{height:k},"content-height"===O&&{maxHeight:k},{y:p}),initial:{y:x},animate:{y:R,transition:a({type:"spring"},C)},exit:{y:x},onAnimationComplete:S}),r)})),C=t.forwardRef((function(e,n){var r=e.children,i=e.style,l=s(e,["children","style"]),u=v().dragProps;return t.createElement(o.motion.div,Object.assign({},l,{ref:n,className:"react-modal-sheet-content",style:a({},b.content,i)},u),r)})),w=t.forwardRef((function(e,n){var r=e.children,i=e.style,l=s(e,["children","style"]),u=v(),c=u.indicatorRotation,d=u.dragProps,f=o.useTransform(c,(function(e){return"translateX(2px) rotate("+e+"deg)"})),p=o.useTransform(c,(function(e){return"translateX(-2px) rotate("+-1*e+"deg)"}));return t.createElement(o.motion.div,Object.assign({},l,{ref:n,style:a({},b.headerWrapper,i)},d),r||t.createElement("div",{className:"react-modal-sheet-header",style:b.header},t.createElement(o.motion.span,{className:"react-modal-sheet-drag-indicator",style:a({},b.indicator,{transform:f})}),t.createElement(o.motion.span,{className:"react-modal-sheet-drag-indicator",style:a({},b.indicator,{transform:p})})))})),O=function(e){return!!e.onClick||!!e.onTap},S=t.forwardRef((function(e,n){var r=e.style,i=void 0===r?{}:r,l=s(e,["style"]),u=O(l)?o.motion.button:o.motion.div,c=O(l)?"auto":"none";return t.createElement(u,Object.assign({},l,{ref:n,className:"react-modal-sheet-backdrop",style:a({},b.backdrop,i,{pointerEvents:c}),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}}))})),R=E;R.Container=x,R.Header=w,R.Content=C,R.Backdrop=S,exports.default=R;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),n=require("react-dom"),r=require("@react-aria/overlays"),o=require("framer-motion"),i=(e=require("react-merge-refs"))&&"object"==typeof e&&"default"in e?e.default:e;function a(){return(a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function s(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)t.indexOf(n=i[r])>=0||(o[n]=e[n]);return o}var l="calc(100% - env(safe-area-inset-top) - 34px)",u="undefined"==typeof window,d={stiffness:300,damping:30,mass:.2};function c(e,t){return e.reduce((function(e,n){return Math.abs(n-t)<Math.abs(e-t)?n:e}))}function f(e){var t=document.querySelector("body"),n=document.getElementById(e),r=document.getElementById("react-modal-sheet-highlight");n&&r&&(n.style.removeProperty("border-top-right-radius"),n.style.removeProperty("border-top-left-radius"),n.style.removeProperty("transform"),r.style.opacity="0",n.addEventListener("transitionend",(function e(){var o;n.style.removeProperty("overflow"),n.style.removeProperty("will-change"),n.style.removeProperty("transition"),t.style.removeProperty("background-color"),n.removeEventListener("transitionend",e),null==(o=r.parentNode)||o.removeChild(r)})))}function p(e){var t=e.snapTo,n=e.sheetHeight;return t<0&&console.warn("Snap point is out of bounds. Sheet height is "+n+" but snap point is "+(n+Math.abs(t))+"."),Math.max(Math.round(t),0)}var h=u?t.useEffect:t.useLayoutEffect;function m(e){var n=t.useRef();return t.useEffect((function(){n.current=e})),n.current}function y(e){var n=t.useRef();return h((function(){n.current=e})),t.useCallback((function(){for(var e=n.current,t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];return null==e?void 0:e.apply(void 0,r)}),[])}var v=t.createContext(void 0),g=function(){var e=t.useContext(v);if(!e)throw Error("Sheet context error");return e},b={wrapper:{position:"fixed",top:0,bottom:0,left:0,right:0,zIndex:9999999,overflow:"hidden",pointerEvents:"none"},backdrop:{zIndex:1,position:"fixed",top:0,left:0,width:"100%",height:"100%",backgroundColor:"rgba(51, 51, 51, 0.5)",touchAction:"none"},container:{zIndex:2,position:"absolute",left:0,bottom:0,width:"100%",backgroundColor:"#fff",borderTopRightRadius:"8px",borderTopLeftRadius:"8px",boxShadow:"0px -2px 16px rgba(0, 0, 0, 0.3)",display:"flex",flexDirection:"column",pointerEvents:"auto"},headerWrapper:{width:"100%"},header:{height:"40px",width:"100%",position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},indicator:{width:"18px",height:"4px",borderRadius:"99px",backgroundColor:"#ddd"},content:{flex:1,overflow:"auto",position:"relative"}},E=t.forwardRef((function(e,i){var l=e.onOpenStart,g=e.onOpenEnd,E=e.onClose,x=e.onCloseStart,C=e.onCloseEnd,w=e.onSnap,O=e.children,S=e.isOpen,R=e.snapPoints,P=e.rootId,M=e.mountPoint,k=e.style,j=e.detent,T=void 0===j?"full-height":j,D=e.initialSnap,H=void 0===D?0:D,q=e.springConfig,I=void 0===q?d:q,A=e.disableDrag,L=void 0!==A&&A,N=e.prefersReducedMotion,B=void 0!==N&&N,z=s(e,["onOpenStart","onOpenEnd","onClose","onCloseStart","onCloseEnd","onSnap","children","isOpen","snapPoints","rootId","mountPoint","style","detent","initialSnap","springConfig","disableDrag","prefersReducedMotion"]),V=t.useRef(null),W=o.useMotionValue(0),X=function(){var e=t.useState(0),n=e[0],r=e[1];return h((function(){var e=function(){return r(window.innerHeight)};return window.addEventListener("resize",e),e(),function(){return window.removeEventListener("resize",e)}}),[]),n}(),_=o.useReducedMotion(),F=Boolean(B||_),Y=F?{type:"tween",duration:.01}:a({type:"spring"},I),G=o.useMotionValue(0),J=t.useRef({onOpenStart:l,onOpenEnd:g,onCloseStart:x,onCloseEnd:C});h((function(){J.current={onOpenStart:l,onOpenEnd:g,onCloseStart:x,onCloseEnd:C}})),R&&(R=R.map((function(e){return e>0&&e<=1?Math.round(e*X):e<0?X+e:e})),console.assert(function(e){for(var t=0;t<e.length;t++)if(e[t+1]>e[t])return!1;return!0}(R)||0===X,"Snap points need to be in descending order got: ["+R+"]"));var K=y((function(e,t){var n=t.delta,r=G.getVelocity();r>0&&W.set(10),r<0&&W.set(-10),G.set(Math.max(G.get()+n.y,0))})),Q=y((function(e,t){if(t.velocity.y>500)E();else{var n=V.current.getBoundingClientRect().height,r=G.get(),i=0;if(R){var a=R.map((function(e){return n-e})).filter((function(e){return e>=0}));"content-height"!==T||a.includes(0)||a.unshift(0),i=c(a,r)}else r/n>.6&&(i=n);if(i=p({snapTo:i,sheetHeight:n}),o.animate(G,i,Y),R&&w){var s=Math.abs(Math.round(R[0]-i)),l=R.indexOf(c(R,s));w(l)}i>=n&&E()}W.set(0)}));t.useEffect((function(){R&&w&&w(S?H:R.length-1)}),[S]),t.useImperativeHandle(i,(function(){return{y:G,snapTo:function(e){var t=V.current;if(R&&void 0!==R[e]&&null!==t){var n=t.getBoundingClientRect().height,r=p({snapTo:n-R[e],sheetHeight:n});o.animate(G,r,Y),w&&w(e),r>=n&&E()}}}})),function(e,n){var r=m(e);t.useEffect((function(){n&&!r&&e?function(e){var t=document.querySelector("body"),n=document.querySelector("#"+e);if(n){var r=window.innerHeight,o=(r-24)/r;t.style.backgroundColor="#000",n.style.overflow="hidden",n.style.willChange="transform",n.style.transition="transform 200ms linear",n.style.transform="translateY(calc(env(safe-area-inset-top) + 12px)) scale("+o+")",n.style.borderTopRightRadius="10px",n.style.borderTopLeftRadius="10px";var i=document.createElement("div");i.setAttribute("aria-hidden","true"),i.id="react-modal-sheet-highlight",i.style.position="absolute",i.style.top="0px",i.style.left="0px",i.style.bottom="0px",i.style.right="0px",i.style.opacity="0",i.style.transition="opacity 200ms linear",i.style.backgroundColor="rgba(150, 150, 150, 0.1)",n.appendChild(i),requestAnimationFrame((function(){return i.style.opacity="1"}))}}(n):n&&!e&&r&&f(n)}),[e,r]),t.useEffect((function(){return function(){n&&e&&f(n)}}),[e])}(S,P),r.usePreventScroll({isDisabled:!S});var U=t.useMemo((function(){return L?void 0:{drag:"y",dragElastic:0,dragConstraints:{top:0,bottom:0},dragMomentum:!1,onDrag:K,onDragEnd:Q}}),[L]),Z=t.createElement(v.Provider,{value:{y:G,sheetRef:V,isOpen:S,initialSnap:H,snapPoints:R,detent:T,indicatorRotation:W,callbacks:J,dragProps:U,windowHeight:X,animationOptions:Y,reduceMotion:F}},t.createElement("div",Object.assign({},z,{ref:i,style:a({},b.wrapper,k)}),t.createElement(o.AnimatePresence,null,S?t.Children.map(O,(function(e,n){return t.cloneElement(e,{key:"sheet-child-"+n})})):null)));return u?Z:n.createPortal(Z,null!=M?M:document.body)})),x=t.forwardRef((function(e,n){var r=e.children,u=e.style,d=void 0===u?{}:u,c=s(e,["children","style"]),f=g(),p=f.y,h=f.snapPoints,y=f.initialSnap,v=void 0===y?0:y,E=f.sheetRef,x=f.windowHeight,C=f.detent,w=f.animationOptions,O=f.reduceMotion,S=function(e,n){var r=m(e),o=t.useRef(!1),i=t.useCallback((function(){o.current?(null==n.current.onCloseEnd||n.current.onCloseEnd(),o.current=!1):(null==n.current.onOpenEnd||n.current.onOpenEnd(),o.current=!0)}),[e,r]);return t.useEffect((function(){!r&&e?null==n.current.onOpenStart||n.current.onOpenStart():!e&&r&&(null==n.current.onCloseStart||n.current.onCloseStart())}),[e,r]),{handleAnimationComplete:i}}(f.isOpen,f.callbacks).handleAnimationComplete,R=h?h[0]-h[v]:0,P=h?h[0]:null,M=null!==P?"min("+P+"px, "+l+")":l;return t.createElement(o.motion.div,Object.assign({},c,{ref:i([E,n]),className:"react-modal-sheet-container",style:a({},b.container,d,"full-height"===C&&{height:M},"content-height"===C&&{maxHeight:M},{y:p}),initial:!O&&{y:x},animate:{y:R,transition:w},exit:{y:x,transition:w},onAnimationComplete:S}),r)})),C=t.forwardRef((function(e,n){var r=e.children,i=e.style,l=e.disableDrag,u=s(e,["children","style","disableDrag"]),d=g(),c=l?void 0:d.dragProps;return t.createElement(o.motion.div,Object.assign({},u,{ref:n,className:"react-modal-sheet-content",style:a({},b.content,i)},c),r)})),w=t.forwardRef((function(e,n){var r=e.children,i=e.style,l=e.disableDrag,u=s(e,["children","style","disableDrag"]),d=g(),c=d.indicatorRotation,f=l?void 0:d.dragProps,p=o.useTransform(c,(function(e){return"translateX(2px) rotate("+e+"deg)"})),h=o.useTransform(c,(function(e){return"translateX(-2px) rotate("+-1*e+"deg)"}));return t.createElement(o.motion.div,Object.assign({},u,{ref:n,style:a({},b.headerWrapper,i)},f),r||t.createElement("div",{className:"react-modal-sheet-header",style:b.header},t.createElement(o.motion.span,{className:"react-modal-sheet-drag-indicator",style:a({},b.indicator,{transform:p})}),t.createElement(o.motion.span,{className:"react-modal-sheet-drag-indicator",style:a({},b.indicator,{transform:h})})))})),O=function(e){return!!e.onClick||!!e.onTap},S=t.forwardRef((function(e,n){var r=e.style,i=void 0===r?{}:r,l=s(e,["style"]),u=O(l)?o.motion.button:o.motion.div,d=O(l)?"auto":"none";return t.createElement(u,Object.assign({},l,{ref:n,className:"react-modal-sheet-backdrop",style:a({},b.backdrop,i,{pointerEvents:d}),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}}))})),R=E;R.Container=x,R.Header=w,R.Content=C,R.Backdrop=S,exports.default=R;
2
2
  //# sourceMappingURL=react-modal-sheet.cjs.production.min.js.map