react-modal-sheet 1.3.1 → 1.4.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/README.md CHANGED
@@ -71,21 +71,21 @@ Also, by constructing the sheet from smaller pieces makes it easier to apply any
71
71
 
72
72
  ## Props
73
73
 
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
- | `onOpenStart` | no | | Callback fn that is called when the sheet opening animation starts. |
81
- | `onOpenEnd` | no | | Callback fn that is called when the sheet opening animation is completed. |
82
- | `onCloseStart` | no | | Callback fn that is called when the sheet closing animation starts. |
83
- | `onCloseEnd` | no | | Callback fn that is called when the sheet closing animation is completed. |
84
- | `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. |
85
- | `snapPoints` | no | | Eg. `[600, 400, 0]` - the distance from the bottom of the screen in px. (TODO: support % values) |
86
- | `initialSnap` | no | 0 | Initial snap point when sheet is opened (index from `snapPoints`). |
87
- | `rootId` | no | | The id of the element where the main app is mounted, eg. "root". Enables iOS modal effect. |
88
- | `springConfig` | no | `DEFAULT_SPRING` | Overrides the config for the [spring animation](https://www.framer.com/api/motion/types/#spring). |
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
+ | `onOpenStart` | no | | Callback fn that is called when the sheet opening animation starts. |
81
+ | `onOpenEnd` | no | | Callback fn that is called when the sheet opening animation is completed. |
82
+ | `onCloseStart` | no | | Callback fn that is called when the sheet closing animation starts. |
83
+ | `onCloseEnd` | no | | Callback fn that is called when the sheet closing animation is completed. |
84
+ | `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. |
85
+ | `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. |
86
+ | `initialSnap` | no | 0 | Initial snap point when sheet is opened (index from `snapPoints`). |
87
+ | `rootId` | no | | The id of the element where the main app is mounted, eg. "root". Enables iOS modal effect. |
88
+ | `springConfig` | no | `DEFAULT_SPRING` | Overrides the config for the [spring animation](https://www.framer.com/api/motion/types/#spring). |
89
89
 
90
90
  **`DEFAULT_SPRING`**
91
91
 
@@ -1,3 +1,3 @@
1
1
  import * as React from 'react';
2
- declare const SheetBackdrop: React.ForwardRefExoticComponent<Pick<import("framer-motion").MotionProps, "style" | "transformTemplate" | "transformValues" | "variants" | "transition" | "onViewportBoxUpdate" | "onBeforeLayoutMeasure" | "onLayoutMeasure" | "onUpdate" | "onAnimationStart" | "onAnimationComplete" | "onLayoutAnimationComplete" | "onPan" | "onPanStart" | "onPanSessionStart" | "onPanEnd" | "onTap" | "onTapStart" | "onTapCancel" | "whileTap" | "whileHover" | "onHoverStart" | "onHoverEnd" | "whileFocus" | "drag" | "whileDrag" | "dragDirectionLock" | "dragPropagation" | "dragConstraints" | "dragElastic" | "dragMomentum" | "dragTransition" | "dragControls" | "dragListener" | "onMeasureDragConstraints" | "_dragX" | "_dragY" | "onDragStart" | "onDragEnd" | "onDrag" | "onDirectionLock" | "onDragTransitionEnd" | "layout" | "layoutId" | "custom" | "inherit"> & React.RefAttributes<any>>;
2
+ declare const SheetBackdrop: React.ForwardRefExoticComponent<Pick<import("framer-motion").MotionProps, "style" | "transformTemplate" | "transformValues" | "variants" | "transition" | "onViewportBoxUpdate" | "onBeforeLayoutMeasure" | "onLayoutMeasure" | "onUpdate" | "onAnimationStart" | "onAnimationComplete" | "onLayoutAnimationComplete" | "onUnmount" | "onPan" | "onPanStart" | "onPanSessionStart" | "onPanEnd" | "onTap" | "onTapStart" | "onTapCancel" | "whileTap" | "whileHover" | "onHoverStart" | "onHoverEnd" | "whileFocus" | "drag" | "whileDrag" | "dragDirectionLock" | "dragPropagation" | "dragConstraints" | "dragElastic" | "dragMomentum" | "dragTransition" | "dragControls" | "dragListener" | "onMeasureDragConstraints" | "_dragX" | "_dragY" | "onDragStart" | "onDragEnd" | "onDrag" | "onDirectionLock" | "onDragTransitionEnd" | "layout" | "layoutId" | "custom" | "inherit"> & React.RefAttributes<any>>;
3
3
  export default SheetBackdrop;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- declare const SheetContainer: React.ForwardRefExoticComponent<Pick<import("framer-motion").MotionProps, "style" | "transformTemplate" | "transformValues" | "variants" | "transition" | "onViewportBoxUpdate" | "onBeforeLayoutMeasure" | "onLayoutMeasure" | "onUpdate" | "onAnimationStart" | "onLayoutAnimationComplete" | "onPan" | "onPanStart" | "onPanSessionStart" | "onPanEnd" | "onTap" | "onTapStart" | "onTapCancel" | "whileTap" | "whileHover" | "onHoverStart" | "onHoverEnd" | "whileFocus" | "drag" | "whileDrag" | "dragDirectionLock" | "dragPropagation" | "dragConstraints" | "dragElastic" | "dragMomentum" | "dragTransition" | "dragControls" | "dragListener" | "onMeasureDragConstraints" | "_dragX" | "_dragY" | "onDragStart" | "onDragEnd" | "onDrag" | "onDirectionLock" | "onDragTransitionEnd" | "layout" | "layoutId" | "custom" | "inherit"> & {
2
+ declare const SheetContainer: React.ForwardRefExoticComponent<Pick<import("framer-motion").MotionProps, "style" | "transformTemplate" | "transformValues" | "variants" | "transition" | "onViewportBoxUpdate" | "onBeforeLayoutMeasure" | "onLayoutMeasure" | "onUpdate" | "onAnimationStart" | "onLayoutAnimationComplete" | "onUnmount" | "onPan" | "onPanStart" | "onPanSessionStart" | "onPanEnd" | "onTap" | "onTapStart" | "onTapCancel" | "whileTap" | "whileHover" | "onHoverStart" | "onHoverEnd" | "whileFocus" | "drag" | "whileDrag" | "dragDirectionLock" | "dragPropagation" | "dragConstraints" | "dragElastic" | "dragMomentum" | "dragTransition" | "dragControls" | "dragListener" | "onMeasureDragConstraints" | "_dragX" | "_dragY" | "onDragStart" | "onDragEnd" | "onDrag" | "onDirectionLock" | "onDragTransitionEnd" | "layout" | "layoutId" | "custom" | "inherit"> & {
3
3
  children: React.ReactNode;
4
4
  } & React.RefAttributes<any>>;
5
5
  export default SheetContainer;
@@ -42,7 +42,7 @@ function _objectWithoutPropertiesLoose(source, excluded) {
42
42
  return target;
43
43
  }
44
44
 
45
- var isBrowser = typeof window !== 'undefined';
45
+ var isSSR = typeof window === 'undefined';
46
46
  var getClosest = function getClosest(nums, goal) {
47
47
  return nums.reduce(function (prev, curr) {
48
48
  return Math.abs(curr - goal) < Math.abs(prev - goal) ? curr : prev;
@@ -109,6 +109,32 @@ function cleanupRootStyles(rootId) {
109
109
  root.addEventListener('transitionend', onTransitionEnd);
110
110
  }
111
111
  }
112
+ var useIsomorphicLayoutEffect = isSSR ? React.useEffect : React.useLayoutEffect;
113
+ function useWindowHeight() {
114
+ var _useState = React.useState(0),
115
+ windowHeight = _useState[0],
116
+ setWindowHeight = _useState[1];
117
+
118
+ useIsomorphicLayoutEffect(function () {
119
+ var updateHeight = function updateHeight() {
120
+ return setWindowHeight(window.innerHeight);
121
+ };
122
+
123
+ window.addEventListener('resize', updateHeight);
124
+ updateHeight();
125
+ return function () {
126
+ return window.removeEventListener('resize', updateHeight);
127
+ };
128
+ }, []);
129
+ return windowHeight;
130
+ }
131
+ var inDescendingOrder = function inDescendingOrder(arr) {
132
+ for (var i = 0; i < arr.length; i++) {
133
+ if (arr[i + 1] > arr[i]) return false;
134
+ }
135
+
136
+ return true;
137
+ };
112
138
 
113
139
  var SheetContext = /*#__PURE__*/React.createContext(undefined);
114
140
  var useSheetContext = function useSheetContext() {
@@ -180,7 +206,8 @@ var styles = {
180
206
  left: 0,
181
207
  right: 0,
182
208
  zIndex: 9999999,
183
- overflow: 'hidden'
209
+ overflow: 'hidden',
210
+ pointerEvents: 'none'
184
211
  },
185
212
  backdrop: {
186
213
  zIndex: 1,
@@ -203,7 +230,8 @@ var styles = {
203
230
  borderTopLeftRadius: '8px',
204
231
  boxShadow: '0px -2px 16px rgba(0, 0, 0, 0.3)',
205
232
  display: 'flex',
206
- flexDirection: 'column'
233
+ flexDirection: 'column',
234
+ pointerEvents: 'auto'
207
235
  },
208
236
  headerWrapper: {
209
237
  width: '100%'
@@ -252,14 +280,6 @@ var Sheet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
252
280
  disableDrag = _ref$disableDrag === void 0 ? false : _ref$disableDrag,
253
281
  rest = _objectWithoutPropertiesLoose(_ref, ["children", "isOpen", "onClose", "onOpenStart", "onOpenEnd", "onCloseStart", "onCloseEnd", "onSnap", "snapPoints", "initialSnap", "rootId", "springConfig", "disableDrag"]);
254
282
 
255
- var _React$useState = React.useState(false),
256
- mounted = _React$useState[0],
257
- setMounted = _React$useState[1];
258
-
259
- var _React$useState2 = React.useState(false),
260
- isDragging = _React$useState2[0],
261
- setDragging = _React$useState2[1];
262
-
263
283
  var sheetRef = React.useRef(null);
264
284
  var callbacks = React.useRef({
265
285
  onOpenStart: onOpenStart,
@@ -269,24 +289,27 @@ var Sheet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
269
289
  }); // prettier-ignore
270
290
 
271
291
  var indicatorRotation = framerMotion.useMotionValue(0);
272
- var sheetDragY = framerMotion.useMotionValue(isBrowser ? window.innerHeight : 0);
273
- var sheetSpringY = framerMotion.useSpring(sheetDragY, springConfig);
274
- var y = isDragging ? sheetDragY : sheetSpringY;
275
- var pointerEvents = isOpen ? 'auto' : 'none';
292
+ var windowHeight = useWindowHeight();
293
+ var y = framerMotion.useMotionValue(isOpen ? windowHeight : 0);
294
+
295
+ if (snapPoints) {
296
+ // Convert negative / percentage snap points to absolute values
297
+ snapPoints = snapPoints.map(function (point) {
298
+ if (point > 0 && point <= 1) return point * windowHeight; // percentage values e.g. between 0.0 and 1.0
299
+
300
+ return point < 0 ? windowHeight + point : point; // negative values
301
+ });
302
+ console.assert(inDescendingOrder(snapPoints) || windowHeight === 0, "Snap points need to be in descending order got: [" + snapPoints + "]");
303
+ }
304
+
276
305
  var handleDrag = React.useCallback(function (_, _ref2) {
277
306
  var delta = _ref2.delta;
278
307
  // Update drag indicator rotation based on drag velocity
279
- var velocity = sheetDragY.getVelocity();
308
+ var velocity = y.getVelocity();
280
309
  if (velocity > 0) indicatorRotation.set(10);
281
310
  if (velocity < 0) indicatorRotation.set(-10); // Make sure user cannot drag beyond the top of the sheet
282
311
 
283
- sheetDragY.set(Math.max(sheetDragY.get() + delta.y, 0));
284
- }, []); // eslint-disable-line
285
-
286
- var handleDragStart = React.useCallback(function () {
287
- // Sync the drag value with the spring value so that dragging start at the correct y position
288
- sheetDragY.set(sheetSpringY.get());
289
- setDragging(true);
312
+ y.set(Math.max(y.get() + delta.y, 0));
290
313
  }, []); // eslint-disable-line
291
314
 
292
315
  var handleDragEnd = React.useCallback(function (_, _ref3) {
@@ -300,10 +323,13 @@ var Sheet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
300
323
  var contentHeight = sheetEl.getBoundingClientRect().height;
301
324
  var snapTo = snapPoints ? getClosest(snapPoints.map(function (p) {
302
325
  return contentHeight - p;
303
- }), sheetDragY.get()) : sheetDragY.get() / contentHeight > 0.6 // Close if dragged over 60%
326
+ }), y.get()) // prettier-ignore
327
+ : y.get() / contentHeight > 0.6 // Close if dragged over 60%
304
328
  ? contentHeight : 0; // Update the spring value so that the sheet is animated to the snap point
305
329
 
306
- sheetSpringY.set(snapTo);
330
+ framerMotion.animate(y, snapTo, _extends({
331
+ type: 'spring'
332
+ }, springConfig));
307
333
 
308
334
  if (snapPoints && onSnap) {
309
335
  var snapValue = Math.abs(Math.round(snapPoints[0] - snapTo));
@@ -312,7 +338,6 @@ var Sheet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
312
338
  }
313
339
 
314
340
  if (snapTo >= contentHeight) onClose();
315
- setDragging(false);
316
341
  } // Reset indicator rotation after dragging
317
342
 
318
343
 
@@ -328,16 +353,14 @@ var Sheet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
328
353
  onCloseStart: onCloseStart,
329
354
  onCloseEnd: onCloseEnd
330
355
  };
331
- });
332
- React.useEffect(function () {
333
- setMounted(true);
334
- }, []); // Trigger onSnap callback when sheet is opened or closed
356
+ }); // Trigger onSnap callback when sheet is opened or closed
335
357
 
336
358
  React.useEffect(function () {
337
- if (!snapPoints || !onSnap || !mounted) return;
359
+ if (!snapPoints || !onSnap) return;
338
360
  var snapIndex = isOpen ? initialSnap : snapPoints.length - 1;
339
361
  onSnap(snapIndex);
340
- }, [isOpen]);
362
+ }, [isOpen]); // eslint-disable-line
363
+
341
364
  React.useImperativeHandle(ref, function () {
342
365
  return {
343
366
  snapTo: function snapTo(snapIndex) {
@@ -345,7 +368,9 @@ var Sheet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
345
368
  var sheetEl = sheetRef.current;
346
369
  var contentHeight = sheetEl.getBoundingClientRect().height;
347
370
  var snapTo = contentHeight - snapPoints[snapIndex];
348
- sheetSpringY.set(snapTo);
371
+ framerMotion.animate(y, snapTo, _extends({
372
+ type: 'spring'
373
+ }, springConfig));
349
374
  if (onSnap) onSnap(snapIndex);
350
375
  if (snapTo >= contentHeight) onClose();
351
376
  }
@@ -362,37 +387,35 @@ var Sheet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
362
387
  },
363
388
  dragMomentum: false,
364
389
  onDrag: handleDrag,
365
- onDragStart: handleDragStart,
366
390
  onDragEnd: handleDragEnd
367
391
  };
368
392
  var context = {
369
393
  y: y,
370
394
  sheetRef: sheetRef,
371
395
  isOpen: isOpen,
372
- isDragging: isDragging,
373
396
  initialSnap: initialSnap,
374
397
  snapPoints: snapPoints,
375
398
  indicatorRotation: indicatorRotation,
376
399
  callbacks: callbacks,
377
- dragProps: dragProps
400
+ dragProps: dragProps,
401
+ windowHeight: windowHeight,
402
+ springConfig: springConfig
378
403
  };
379
404
 
380
405
  var wrapperProps = _extends({}, rest, {
381
406
  ref: ref,
382
- style: _extends({}, styles.wrapper, {
383
- pointerEvents: pointerEvents
384
- })
407
+ style: styles.wrapper
385
408
  });
386
409
 
387
- return mounted ? ReactDOM.createPortal(React.createElement(SheetContext.Provider, {
410
+ var sheet = React.createElement(SheetContext.Provider, {
388
411
  value: context
389
412
  }, React.createElement("div", Object.assign({}, wrapperProps), React.createElement(framerMotion.AnimatePresence, null, isOpen ? React.Children.map(children, function (child, i) {
390
413
  return React.cloneElement(child, {
391
414
  key: "sheet-child-" + i
392
415
  });
393
- }) : null))), document.body) : // NOTE: return the wrapper div so that SSR frameworks don't get confused
394
- // with the HTML structure ("Expected server HTML to contain a matching <div>...")
395
- React.createElement("div", Object.assign({}, wrapperProps));
416
+ }) : null)));
417
+ if (isSSR) return sheet;
418
+ return ReactDOM.createPortal(sheet, document.body);
396
419
  });
397
420
 
398
421
  var MAX_HEIGHT = 'calc(100% - env(safe-area-inset-top) - 34px)';
@@ -409,7 +432,9 @@ var SheetContainer = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
409
432
  snapPoints = _useSheetContext.snapPoints,
410
433
  _useSheetContext$init = _useSheetContext.initialSnap,
411
434
  initialSnap = _useSheetContext$init === void 0 ? 0 : _useSheetContext$init,
412
- sheetRef = _useSheetContext.sheetRef;
435
+ sheetRef = _useSheetContext.sheetRef,
436
+ windowHeight = _useSheetContext.windowHeight,
437
+ springConfig = _useSheetContext.springConfig;
413
438
 
414
439
  var _useEventCallbacks = useEventCallbacks(isOpen, callbacks),
415
440
  handleAnimationComplete = _useEventCallbacks.handleAnimationComplete;
@@ -426,16 +451,16 @@ var SheetContainer = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
426
451
  y: y
427
452
  }),
428
453
  initial: {
429
- y: window.innerHeight
454
+ y: windowHeight
430
455
  },
431
456
  animate: {
432
457
  y: initialY,
433
- transition: {
434
- type: 'tween'
435
- }
458
+ transition: _extends({
459
+ type: 'spring'
460
+ }, springConfig)
436
461
  },
437
462
  exit: {
438
- y: window.innerHeight
463
+ y: windowHeight
439
464
  },
440
465
  onAnimationComplete: handleAnimationComplete
441
466
  }), children);
@@ -506,10 +531,13 @@ var SheetBackdrop = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
506
531
  rest = _objectWithoutPropertiesLoose(_ref, ["style"]);
507
532
 
508
533
  var Comp = isClickable(rest) ? framerMotion.motion.button : framerMotion.motion.div;
534
+ var pointerEvents = isClickable(rest) ? 'auto' : 'none';
509
535
  return React.createElement(Comp, Object.assign({}, rest, {
510
536
  ref: ref,
511
537
  className: "react-modal-sheet-backdrop",
512
- style: _extends({}, styles.backdrop, style),
538
+ style: _extends({}, styles.backdrop, style, {
539
+ pointerEvents: pointerEvents
540
+ }),
513
541
  initial: {
514
542
  opacity: 0
515
543
  },
@@ -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":["export const isBrowser = 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","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 },\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 },\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 useSpring,\n useMotionValue,\n AnimatePresence,\n PanInfo,\n} from 'framer-motion';\n\nimport { SheetProps } from './types';\nimport { getClosest, isBrowser } 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 [mounted, setMounted] = React.useState(false);\n const [isDragging, setDragging] = React.useState(false);\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 sheetDragY = useMotionValue(isBrowser ? window.innerHeight : 0);\n const sheetSpringY = useSpring(sheetDragY, springConfig);\n const y = isDragging ? sheetDragY : sheetSpringY;\n const pointerEvents = isOpen ? 'auto' : 'none';\n\n const handleDrag = React.useCallback((_, { delta }: PanInfo) => {\n // Update drag indicator rotation based on drag velocity\n const velocity = sheetDragY.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 sheetDragY.set(Math.max(sheetDragY.get() + delta.y, 0));\n }, []); // eslint-disable-line\n\n const handleDragStart = React.useCallback(() => {\n // Sync the drag value with the spring value so that dragging start at the correct y position\n sheetDragY.set(sheetSpringY.get());\n setDragging(true);\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(\n snapPoints.map(p => contentHeight - p),\n sheetDragY.get()\n )\n : sheetDragY.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 sheetSpringY.set(snapTo);\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 setDragging(false);\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 React.useEffect(() => {\n setMounted(true);\n }, []);\n\n // Trigger onSnap callback when sheet is opened or closed\n React.useEffect(() => {\n if (!snapPoints || !onSnap || !mounted) return;\n const snapIndex = isOpen ? initialSnap : snapPoints.length - 1;\n onSnap(snapIndex);\n }, [isOpen]);\n\n React.useImperativeHandle(ref, () => ({\n snapTo: (snapIndex: number) => {\n if (snapPoints && snapPoints[snapIndex] !== undefined) {\n const sheetEl = sheetRef.current as HTMLDivElement;\n const contentHeight = sheetEl.getBoundingClientRect().height;\n const snapTo = contentHeight - snapPoints[snapIndex];\n\n sheetSpringY.set(snapTo);\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 onDragStart: handleDragStart,\n onDragEnd: handleDragEnd,\n };\n\n const context = {\n y,\n sheetRef,\n isOpen,\n isDragging,\n initialSnap,\n snapPoints,\n indicatorRotation,\n callbacks,\n dragProps,\n };\n\n const wrapperProps = {\n ...rest,\n ref,\n style: {\n ...styles.wrapper,\n pointerEvents,\n } as any,\n };\n\n return mounted ? (\n ReactDOM.createPortal(\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 document.body\n )\n ) : (\n // NOTE: return the wrapper div so that SSR frameworks don't get confused\n // with the HTML structure (\"Expected server HTML to contain a matching <div>...\")\n <div {...wrapperProps} />\n );\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 } = 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: window.innerHeight }}\n animate={{ y: initialY, transition: { type: 'tween' } }}\n exit={{ y: window.innerHeight }}\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\n return (\n <Comp\n {...rest}\n ref={ref}\n className=\"react-modal-sheet-backdrop\"\n style={{ ...styles.backdrop, ...style }}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n />\n );\n }\n);\n\nexport default SheetBackdrop;\n","import Sheet from './sheet';\nimport SheetContainer from './SheetContainer';\nimport SheetContent from './SheetContent';\nimport SheetHeader from './SheetHeader';\nimport SheetBackdrop from './SheetBackdrop';\n\nexport type SheetRef = {\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":["isBrowser","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","SheetContext","React","undefined","useSheetContext","context","Error","useModalEffect","isOpen","prevOpen","usePrevious","useEventCallbacks","callbacks","didOpen","handleAnimationComplete","current","onOpenEnd","onCloseEnd","onOpenStart","onCloseStart","state","ref","styles","wrapper","zIndex","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","mounted","setMounted","isDragging","setDragging","sheetRef","indicatorRotation","useMotionValue","sheetDragY","sheetSpringY","useSpring","y","pointerEvents","handleDrag","_","delta","velocity","getVelocity","set","max","get","handleDragStart","handleDragEnd","sheetEl","contentHeight","getBoundingClientRect","snapTo","map","snapValue","round","snapIndex","indexOf","length","dragProps","drag","dragElastic","dragConstraints","dragMomentum","onDrag","onDragStart","onDragEnd","wrapperProps","ReactDOM","Provider","value","AnimatePresence","child","i","key","MAX_HEIGHT","SheetContainer","initialY","sheetHeight","motion","div","mergeRefs","className","initial","animate","type","exit","onAnimationComplete","SheetContent","SheetHeader","indicator1Transform","useTransform","r","indicator2Transform","span","isClickable","props","onClick","onTap","SheetBackdrop","Comp","button","_Sheet","Container","Header","Content","Backdrop","SheetCompound"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,IAAMA,SAAS,GAAG,OAAOC,MAAP,KAAkB,WAApC;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;AAG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BAAGhD;MAAAA,gCAAQ;MAAO+E;;AAChB,MAAM0E,IAAI,GAAGL,WAAW,CAACrE,IAAD,CAAX,GAAoBqD,mBAAM,CAACsB,MAA3B,GAAoCtB,mBAAM,CAACC,GAAxD;AAEA,SACExG,mBAAA,CAAC4H,IAAD,oBACM1E;AACJ/B,IAAAA,GAAG,EAAEA;AACLuF,IAAAA,SAAS,EAAC;AACVvI,IAAAA,KAAK,eAAOiD,MAAM,CAACG,QAAd,EAA2BpD,KAA3B;AACLwI,IAAAA,OAAO,EAAE;AAAEvH,MAAAA,OAAO,EAAE;AAAX;AACTwH,IAAAA,OAAO,EAAE;AAAExH,MAAAA,OAAO,EAAE;AAAX;AACT0H,IAAAA,IAAI,EAAE;AAAE1H,MAAAA,OAAO,EAAE;AAAX;IAPR,CADF;AAWD,CAfmB,CAAtB;;ACUA,IAAM0I,MAAM,GAAQvF,KAApB;AACAuF,MAAM,CAACC,SAAP,GAAmB3B,cAAnB;AACA0B,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.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 const y = useMotionValue(isOpen ? windowHeight : 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 snapTo: (snapIndex: number) => {\n if (snapPoints && snapPoints[snapIndex] !== undefined) {\n const sheetEl = sheetRef.current as HTMLDivElement;\n const contentHeight = sheetEl.getBoundingClientRect().height;\n const snapTo = contentHeight - snapPoints[snapIndex];\n\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 Sheet from './sheet';\nimport SheetContainer from './SheetContainer';\nimport SheetContent from './SheetContent';\nimport SheetHeader from './SheetHeader';\nimport SheetBackdrop from './SheetBackdrop';\n\nexport type SheetRef = {\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,IAAM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oB+C,mBAAM,CAACoB,MAA3B,GAAoCpB,mBAAM,CAACC,GAAxD;AACA,MAAM5E,aAAa,GAAGyF,WAAW,CAAC7D,IAAD,CAAX,GAAoB,MAApB,GAA6B,MAAnD;AAEA,SACEnD,mBAAA,CAACqH,IAAD,oBACMlE;AACJhC,IAAAA,GAAG,EAAEA;AACLkF,IAAAA,SAAS,EAAC;AACV9I,IAAAA,KAAK,eAAO6D,MAAM,CAACI,QAAd,EAA2BjE,KAA3B;AAAkCgE,MAAAA,aAAa,EAAbA;AAAlC;AACL+E,IAAAA,OAAO,EAAE;AAAE9H,MAAAA,OAAO,EAAE;AAAX;AACTiG,IAAAA,OAAO,EAAE;AAAEjG,MAAAA,OAAO,EAAE;AAAX;AACT+H,IAAAA,IAAI,EAAE;AAAE/H,MAAAA,OAAO,EAAE;AAAX;IAPR,CADF;AAWD,CAhBmB,CAAtB;;ACUA,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,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),n=require("react-dom"),r=require("framer-motion"),o=(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 i(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||(o[n]=e[n]);return o}var s="undefined"!=typeof window;function l(e){var t=document.querySelector("body"),n=document.getElementById(e),r=document.getElementById("react-modal-sheet-highlight");n&&r&&(n.style.removeProperty("border-top-right-radius"),n.style.removeProperty("border-top-left-radius"),n.style.removeProperty("transform"),r.style.opacity="0",n.addEventListener("transitionend",(function e(){var o;n.style.removeProperty("overflow"),n.style.removeProperty("will-change"),n.style.removeProperty("transition"),t.style.removeProperty("background-color"),n.removeEventListener("transitionend",e),null==(o=r.parentNode)||o.removeChild(r)})))}var c=t.createContext(void 0),d=function(){var e=t.useContext(c);if(!e)throw Error("Sheet context error");return e},u=function(e){var n=t.useRef();return t.useEffect((function(){n.current=e})),n.current},f={wrapper:{position:"fixed",top:0,bottom:0,left:0,right:0,zIndex:9999999,overflow:"hidden"},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"},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"}},p=t.forwardRef((function(e,o){var d=e.children,p=e.isOpen,m=e.onClose,y=e.onOpenStart,g=e.onOpenEnd,h=e.onCloseStart,v=e.onCloseEnd,b=e.onSnap,C=e.snapPoints,x=e.initialSnap,E=void 0===x?0:x,w=e.rootId,O=e.springConfig,S=void 0===O?{stiffness:300,damping:30,mass:.2}:O,R=e.disableDrag,k=void 0!==R&&R,P=i(e,["children","isOpen","onClose","onOpenStart","onOpenEnd","onCloseStart","onCloseEnd","onSnap","snapPoints","initialSnap","rootId","springConfig","disableDrag"]),j=t.useState(!1),D=j[0],I=j[1],M=t.useState(!1),q=M[0],T=M[1],A=t.useRef(null),N=t.useRef({onOpenStart:y,onOpenEnd:g,onCloseStart:h,onCloseEnd:v}),H=r.useMotionValue(0),B=r.useMotionValue(s?window.innerHeight:0),L=r.useSpring(B,S),z=q?B:L,V=p?"auto":"none",W=t.useCallback((function(e,t){var n=t.delta,r=B.getVelocity();r>0&&H.set(10),r<0&&H.set(-10),B.set(Math.max(B.get()+n.y,0))}),[]),X=t.useCallback((function(){B.set(L.get()),T(!0)}),[]),_=t.useCallback((function(e,t){var n,r;if(t.velocity.y>500)m();else{var o=A.current.getBoundingClientRect().height,a=C?(n=C.map((function(e){return o-e})),r=B.get(),n.reduce((function(e,t){return Math.abs(t-r)<Math.abs(e-r)?t:e}))):B.get()/o>.6?o:0;if(L.set(a),C&&b){var i=Math.abs(Math.round(C[0]-a)),s=C.indexOf(i);b(s)}a>=o&&m(),T(!1)}H.set(0)}),[m,b]);t.useEffect((function(){N.current={onOpenStart:y,onOpenEnd:g,onCloseStart:h,onCloseEnd:v}})),t.useEffect((function(){I(!0)}),[]),t.useEffect((function(){C&&b&&D&&b(p?E:C.length-1)}),[p]),t.useImperativeHandle(o,(function(){return{snapTo:function(e){if(C&&void 0!==C[e]){var t=A.current.getBoundingClientRect().height,n=t-C[e];L.set(n),b&&b(e),n>=t&&m()}}}})),function(e,n){var r=u(e);t.useEffect((function(){n&&!r&&e?function(e){var t=document.querySelector("body"),n=document.querySelector("#"+e);if(n){var r=window.innerHeight,o=(r-24)/r;t.style.backgroundColor="#000",n.style.overflow="hidden",n.style.willChange="transform",n.style.transition="transform 200ms linear",n.style.transform="translateY(calc(env(safe-area-inset-top) + 12px)) scale("+o+")",n.style.borderTopRightRadius="10px",n.style.borderTopLeftRadius="10px";var a=document.createElement("div");a.setAttribute("aria-hidden","true"),a.id="react-modal-sheet-highlight",a.style.position="absolute",a.style.top="0px",a.style.left="0px",a.style.bottom="0px",a.style.right="0px",a.style.opacity="0",a.style.transition="opacity 200ms linear",a.style.backgroundColor="rgba(150, 150, 150, 0.1)",n.appendChild(a),requestAnimationFrame((function(){return a.style.opacity="1"}))}}(n):n&&!e&&r&&l(n)}),[e,r]),t.useEffect((function(){return function(){n&&e&&l(n)}}),[e])}(p,w);var F={y:z,sheetRef:A,isOpen:p,isDragging:q,initialSnap:E,snapPoints:C,indicatorRotation:H,callbacks:N,dragProps:k?{}:{drag:"y",dragElastic:0,dragConstraints:{top:0,bottom:0},dragMomentum:!1,onDrag:W,onDragStart:X,onDragEnd:_}},Y=a({},P,{ref:o,style:a({},f.wrapper,{pointerEvents:V})});return D?n.createPortal(t.createElement(c.Provider,{value:F},t.createElement("div",Object.assign({},Y),t.createElement(r.AnimatePresence,null,p?t.Children.map(d,(function(e,n){return t.cloneElement(e,{key:"sheet-child-"+n})})):null))),document.body):t.createElement("div",Object.assign({},Y))})),m="calc(100% - env(safe-area-inset-top) - 34px)",y=t.forwardRef((function(e,n){var s=e.children,l=e.style,c=void 0===l?{}:l,p=i(e,["children","style"]),y=d(),g=y.y,h=y.snapPoints,v=y.initialSnap,b=void 0===v?0:v,C=y.sheetRef,x=function(e,n){var r=u(e),o=t.useRef(!1),a=t.useCallback((function(){o.current?(null==n.current.onCloseEnd||n.current.onCloseEnd(),o.current=!1):(null==n.current.onOpenEnd||n.current.onOpenEnd(),o.current=!0)}),[e,r]);return t.useEffect((function(){!r&&e?null==n.current.onOpenStart||n.current.onOpenStart():!e&&r&&(null==n.current.onCloseStart||n.current.onCloseStart())}),[e,r]),{handleAnimationComplete:a}}(y.isOpen,y.callbacks).handleAnimationComplete,E=h?h[0]-h[b]:0,w=h?h[0]:null,O=w?"min("+w+"px, "+m+")":m;return t.createElement(r.motion.div,Object.assign({},p,{ref:o([C,n]),className:"react-modal-sheet-container",style:a({},f.container,{height:O},c,{y:g}),initial:{y:window.innerHeight},animate:{y:E,transition:{type:"tween"}},exit:{y:window.innerHeight},onAnimationComplete:x}),s)})),g=t.forwardRef((function(e,n){var o=e.children,s=e.disableDrag,l=void 0!==s&&s,c=e.style,u=void 0===c?{}:c,p=i(e,["children","disableDrag","style"]),m=d().dragProps;return t.createElement(r.motion.div,Object.assign({},p,{ref:n,className:"react-modal-sheet-content",style:a({},f.content,u)},l?{}:m),o)})),h=t.forwardRef((function(e,n){var o=e.children,s=e.disableDrag,l=void 0!==s&&s,c=e.style,u=void 0===c?{}:c,p=i(e,["children","disableDrag","style"]),m=d(),y=m.indicatorRotation,g=m.dragProps,h=r.useTransform(y,(function(e){return"translateX(2px) rotate("+e+"deg)"})),v=r.useTransform(y,(function(e){return"translateX(-2px) rotate("+-1*e+"deg)"}));return t.createElement(r.motion.div,Object.assign({},p,{ref:n,style:a({},f.headerWrapper,u)},l?{}:g),o||t.createElement("div",{className:"react-modal-sheet-header",style:f.header},t.createElement(r.motion.span,{className:"react-modal-sheet-drag-indicator",style:a({},f.indicator,{transform:h})}),t.createElement(r.motion.span,{className:"react-modal-sheet-drag-indicator",style:a({},f.indicator,{transform:v})})))})),v=t.forwardRef((function(e,n){var o,s=e.style,l=void 0===s?{}:s,c=i(e,["style"]),d=(o=c).onClick||o.onTap?r.motion.button:r.motion.div;return t.createElement(d,Object.assign({},c,{ref:n,className:"react-modal-sheet-backdrop",style:a({},f.backdrop,l),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}}))})),b=p;b.Container=y,b.Header=h,b.Content=g,b.Backdrop=v,exports.default=b;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),n=require("react-dom"),r=require("framer-motion"),o=(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 i(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||(o[n]=e[n]);return o}var s="undefined"==typeof window;function l(e){var t=document.querySelector("body"),n=document.getElementById(e),r=document.getElementById("react-modal-sheet-highlight");n&&r&&(n.style.removeProperty("border-top-right-radius"),n.style.removeProperty("border-top-left-radius"),n.style.removeProperty("transform"),r.style.opacity="0",n.addEventListener("transitionend",(function e(){var o;n.style.removeProperty("overflow"),n.style.removeProperty("will-change"),n.style.removeProperty("transition"),t.style.removeProperty("background-color"),n.removeEventListener("transitionend",e),null==(o=r.parentNode)||o.removeChild(r)})))}var c=s?t.useEffect:t.useLayoutEffect,d=t.createContext(void 0),u=function(){var e=t.useContext(d);if(!e)throw Error("Sheet context error");return e},f=function(e){var n=t.useRef();return t.useEffect((function(){n.current=e})),n.current},p={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"}},m=t.forwardRef((function(e,o){var u=e.children,m=e.isOpen,y=e.onClose,g=e.onOpenStart,h=e.onOpenEnd,v=e.onCloseStart,b=e.onCloseEnd,E=e.onSnap,C=e.snapPoints,x=e.initialSnap,w=void 0===x?0:x,O=e.rootId,S=e.springConfig,R=void 0===S?{stiffness:300,damping:30,mass:.2}:S,P=e.disableDrag,k=void 0!==P&&P,j=i(e,["children","isOpen","onClose","onOpenStart","onOpenEnd","onCloseStart","onCloseEnd","onSnap","snapPoints","initialSnap","rootId","springConfig","disableDrag"]),D=t.useRef(null),I=t.useRef({onOpenStart:g,onOpenEnd:h,onCloseStart:v,onCloseEnd:b}),M=r.useMotionValue(0),q=function(){var e=t.useState(0),n=e[0],r=e[1];return c((function(){var e=function(){return r(window.innerHeight)};return window.addEventListener("resize",e),e(),function(){return window.removeEventListener("resize",e)}}),[]),n}(),T=r.useMotionValue(m?q:0);C&&(C=C.map((function(e){return e>0&&e<=1?e*q:e<0?q+e:e})),console.assert(function(e){for(var t=0;t<e.length;t++)if(e[t+1]>e[t])return!1;return!0}(C)||0===q,"Snap points need to be in descending order got: ["+C+"]"));var A=t.useCallback((function(e,t){var n=t.delta,r=T.getVelocity();r>0&&M.set(10),r<0&&M.set(-10),T.set(Math.max(T.get()+n.y,0))}),[]),L=t.useCallback((function(e,t){var n,o;if(t.velocity.y>500)y();else{var i=D.current.getBoundingClientRect().height,s=C?(n=C.map((function(e){return i-e})),o=T.get(),n.reduce((function(e,t){return Math.abs(t-o)<Math.abs(e-o)?t:e}))):T.get()/i>.6?i:0;if(r.animate(T,s,a({type:"spring"},R)),C&&E){var l=Math.abs(Math.round(C[0]-s)),c=C.indexOf(l);E(c)}s>=i&&y()}M.set(0)}),[y,E]);t.useEffect((function(){I.current={onOpenStart:g,onOpenEnd:h,onCloseStart:v,onCloseEnd:b}})),t.useEffect((function(){C&&E&&E(m?w:C.length-1)}),[m]),t.useImperativeHandle(o,(function(){return{snapTo:function(e){if(C&&void 0!==C[e]){var t=D.current.getBoundingClientRect().height,n=t-C[e];r.animate(T,n,a({type:"spring"},R)),E&&E(e),n>=t&&y()}}}})),function(e,n){var r=f(e);t.useEffect((function(){n&&!r&&e?function(e){var t=document.querySelector("body"),n=document.querySelector("#"+e);if(n){var r=window.innerHeight,o=(r-24)/r;t.style.backgroundColor="#000",n.style.overflow="hidden",n.style.willChange="transform",n.style.transition="transform 200ms linear",n.style.transform="translateY(calc(env(safe-area-inset-top) + 12px)) scale("+o+")",n.style.borderTopRightRadius="10px",n.style.borderTopLeftRadius="10px";var a=document.createElement("div");a.setAttribute("aria-hidden","true"),a.id="react-modal-sheet-highlight",a.style.position="absolute",a.style.top="0px",a.style.left="0px",a.style.bottom="0px",a.style.right="0px",a.style.opacity="0",a.style.transition="opacity 200ms linear",a.style.backgroundColor="rgba(150, 150, 150, 0.1)",n.appendChild(a),requestAnimationFrame((function(){return a.style.opacity="1"}))}}(n):n&&!e&&r&&l(n)}),[e,r]),t.useEffect((function(){return function(){n&&e&&l(n)}}),[e])}(m,O);var N={y:T,sheetRef:D,isOpen:m,initialSnap:w,snapPoints:C,indicatorRotation:M,callbacks:I,dragProps:k?{}:{drag:"y",dragElastic:0,dragConstraints:{top:0,bottom:0},dragMomentum:!1,onDrag:A,onDragEnd:L},windowHeight:q,springConfig:R},H=a({},j,{ref:o,style:p.wrapper}),z=t.createElement(d.Provider,{value:N},t.createElement("div",Object.assign({},H),t.createElement(r.AnimatePresence,null,m?t.Children.map(u,(function(e,n){return t.cloneElement(e,{key:"sheet-child-"+n})})):null)));return s?z:n.createPortal(z,document.body)})),y="calc(100% - env(safe-area-inset-top) - 34px)",g=t.forwardRef((function(e,n){var s=e.children,l=e.style,c=void 0===l?{}:l,d=i(e,["children","style"]),m=u(),g=m.y,h=m.snapPoints,v=m.initialSnap,b=void 0===v?0:v,E=m.sheetRef,C=m.windowHeight,x=m.springConfig,w=function(e,n){var r=f(e),o=t.useRef(!1),a=t.useCallback((function(){o.current?(null==n.current.onCloseEnd||n.current.onCloseEnd(),o.current=!1):(null==n.current.onOpenEnd||n.current.onOpenEnd(),o.current=!0)}),[e,r]);return t.useEffect((function(){!r&&e?null==n.current.onOpenStart||n.current.onOpenStart():!e&&r&&(null==n.current.onCloseStart||n.current.onCloseStart())}),[e,r]),{handleAnimationComplete:a}}(m.isOpen,m.callbacks).handleAnimationComplete,O=h?h[0]-h[b]:0,S=h?h[0]:null,R=S?"min("+S+"px, "+y+")":y;return t.createElement(r.motion.div,Object.assign({},d,{ref:o([E,n]),className:"react-modal-sheet-container",style:a({},p.container,{height:R},c,{y:g}),initial:{y:C},animate:{y:O,transition:a({type:"spring"},x)},exit:{y:C},onAnimationComplete:w}),s)})),h=t.forwardRef((function(e,n){var o=e.children,s=e.disableDrag,l=void 0!==s&&s,c=e.style,d=void 0===c?{}:c,f=i(e,["children","disableDrag","style"]),m=u().dragProps;return t.createElement(r.motion.div,Object.assign({},f,{ref:n,className:"react-modal-sheet-content",style:a({},p.content,d)},l?{}:m),o)})),v=t.forwardRef((function(e,n){var o=e.children,s=e.disableDrag,l=void 0!==s&&s,c=e.style,d=void 0===c?{}:c,f=i(e,["children","disableDrag","style"]),m=u(),y=m.indicatorRotation,g=m.dragProps,h=r.useTransform(y,(function(e){return"translateX(2px) rotate("+e+"deg)"})),v=r.useTransform(y,(function(e){return"translateX(-2px) rotate("+-1*e+"deg)"}));return t.createElement(r.motion.div,Object.assign({},f,{ref:n,style:a({},p.headerWrapper,d)},l?{}:g),o||t.createElement("div",{className:"react-modal-sheet-header",style:p.header},t.createElement(r.motion.span,{className:"react-modal-sheet-drag-indicator",style:a({},p.indicator,{transform:h})}),t.createElement(r.motion.span,{className:"react-modal-sheet-drag-indicator",style:a({},p.indicator,{transform:v})})))})),b=function(e){return!!e.onClick||!!e.onTap},E=t.forwardRef((function(e,n){var o=e.style,s=void 0===o?{}:o,l=i(e,["style"]),c=b(l)?r.motion.button:r.motion.div,d=b(l)?"auto":"none";return t.createElement(c,Object.assign({},l,{ref:n,className:"react-modal-sheet-backdrop",style:a({},p.backdrop,s,{pointerEvents:d}),initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}}))})),C=m;C.Container=g,C.Header=v,C.Content=h,C.Backdrop=E,exports.default=C;
2
2
  //# sourceMappingURL=react-modal-sheet.cjs.production.min.js.map