react-modal-sheet 3.4.1 → 4.0.0

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
@@ -23,23 +23,37 @@
23
23
  npm install react-modal-sheet
24
24
  ```
25
25
 
26
- or if you use `yarn`:
26
+ ### Peer dependencies
27
+
28
+ The gestures and animations are handled by the excellent [Motion](https://motion.dev/) library so before you can start using this library you need to install `motion`:
27
29
 
28
30
  ```sh
29
- yarn add react-modal-sheet
31
+ npm install motion
30
32
  ```
31
33
 
32
- ### Peer dependencies
34
+ > [!IMPORTANT]
35
+ > If you are still using the old `framer-motion` package you need to upgrade to `motion` as `react-modal-sheet` is now built on top of the new `motion` package. **Version `v3.5.0` and older are compatible with `framer-motion`**.
33
36
 
34
- The gestures and animations are handled by the excellent [Framer Motion](https://github.com/framer/motion) library so before you can start using this library you need to install `framer-motion`:
37
+ ---
35
38
 
36
- ```sh
37
- npm install framer-motion
38
- ```
39
+ <details>
40
+ <summary><strong>📚 Table of contents</strong></summary>
41
+
42
+ - [Usage](#-usage)
43
+ - [Props](#%EF%B8%8F-props)
44
+ - [Methods and properties](#%EF%B8%8F-methods-and-properties)
45
+ - [Compound Components](#-compound-components)
46
+ - [Advanced usage](#-advanced-usage)
47
+ - [Customization](#-customization)
48
+ - [Accessibility](#%EF%B8%8F-accessibility)
49
+ - [Troubleshooting](#-troubleshooting)
50
+ </details>
51
+
52
+ ---
39
53
 
40
54
  ## 💻 Usage
41
55
 
42
- ```jsx
56
+ ```tsx
43
57
  import { Sheet } from 'react-modal-sheet';
44
58
  import { useState } from 'react';
45
59
 
@@ -86,7 +100,7 @@ Also, by constructing the sheet from smaller pieces makes it easier to apply any
86
100
  | `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
101
  | `initialSnap` | no | 0 | Initial snap point when sheet is opened (index from `snapPoints`). |
88
102
  | `rootId` | no | | The id of the element where the main app is mounted, eg. "root". Enables iOS modal effect. |
89
- | `tweenConfig` | no | `{ ease: 'easeOut', duration: 0.2 }` | Overrides the config for the sheet [tween](https://www.framer.com/motion/transition/#tween) transition when the sheet is opened, closed, or snapped to a point. |
103
+ | `tweenConfig` | no | `{ ease: 'easeOut', duration: 0.2 }` | Overrides the config for the sheet [tween](https://motion.dev/docs/react-transitions#tween) transition when the sheet is opened, closed, or snapped to a point. |
90
104
  | `mountPoint` | no | `document.body` | HTML element that should be used as the mount point for the sheet. |
91
105
  | `prefersReducedMotion` | no | false | Skip sheet animations (sheet instantly snaps to desired location). |
92
106
  | `dragVelocityThreshold` | no | 500 | How fast the sheet must be flicked down to close. Higher values make the sheet harder to close. |
@@ -104,7 +118,7 @@ import { useState, useRef } from 'react';
104
118
 
105
119
  function Example() {
106
120
  const [isOpen, setOpen] = useState(false);
107
- const ref = useRef<SheetRef>();
121
+ const ref = useRef<SheetRef>(null);
108
122
  const snapTo = (i: number) => ref.current?.snapTo(i);
109
123
 
110
124
  return (
@@ -150,7 +164,7 @@ import { useState, useRef } from 'react';
150
164
 
151
165
  function Example() {
152
166
  const [isOpen, setOpen] = useState(false);
153
- const ref = useRef<SheetRef>();
167
+ const ref = useRef<SheetRef>(null);
154
168
 
155
169
  return (
156
170
  <>
@@ -269,7 +283,7 @@ Sheet scroller can be used to make the whole sheet content or parts of it scroll
269
283
 
270
284
  Sheet backdrop is a translucent overlay that helps to separate the sheet from it's background. By default the backdrop doesn't have any interaction attached to it but if you, for example, want to close the sheet when the backdrop is clicked you can provide tap handler to it which will change the rendered element from `div` to `button`.
271
285
 
272
- **⚠️ Note:** as the element is a motion component you need to use [`onTap`](https://www.framer.com/motion/gestures/#tap) instead of `onClick` if you want to add a click handler to it.
286
+ **⚠️ Note:** as the element is a motion component you need to use [`onTap`](https://motion.dev/docs/react-gestures#tap) instead of `onClick` if you want to add a click handler to it.
273
287
 
274
288
  > 🖥 Rendered element: `motion.div` or `motion.button`.
275
289
 
@@ -305,7 +319,7 @@ The scroller component is in-between these states when the user has scrolled onl
305
319
 
306
320
  The default value for the `draggableAt` prop is `top` which should be a good default for most use cases. You shouldn't need `bottom` or `both` unless you have scrollable content inside a sheet that also has snap points.
307
321
 
308
- ```jsx
322
+ ```tsx
309
323
  function ScrollableExample() {
310
324
  return (
311
325
  <Sheet>
@@ -330,7 +344,7 @@ In addition to the `Sheet.Backdrop` it's possible to apply a scaling effect to t
330
344
 
331
345
  To enable this effect you can provide the id of the root element where your application is mounted:
332
346
 
333
- ```jsx
347
+ ```tsx
334
348
  function Example() {
335
349
  return <Sheet rootId="root">{/*...*/}</Sheet>;
336
350
  }
@@ -346,7 +360,7 @@ The default styles for the `Sheet` component somewhat follows the styles of the
346
360
 
347
361
  Adding a custom header is as simple as providing your own header as the child component to `Sheet.Header`:
348
362
 
349
- ```jsx
363
+ ```tsx
350
364
  function Example() {
351
365
  return (
352
366
  <Sheet>
@@ -388,7 +402,7 @@ You can add your own styles or override the default sheet styles via the exposed
388
402
 
389
403
  #### CSS-in-JS
390
404
 
391
- ```jsx
405
+ ```tsx
392
406
  import { Sheet } from 'react-modal-sheet';
393
407
  import { styled } from 'styled-components';
394
408
  import { useState } from 'react';
@@ -438,7 +452,7 @@ The example below utilizes React Aria to achieve an accessible modal-like bottom
438
452
 
439
453
  > ℹ️ The example was built by following the React Aria's [useDialog](https://react-spectrum.adobe.com/react-aria/useDialog.html) documentation.
440
454
 
441
- ```jsx
455
+ ```tsx
442
456
  import { Sheet } from 'react-modal-sheet';
443
457
  import { useRef } from 'react';
444
458
  import { useOverlayTriggerState } from 'react-stately';
@@ -519,3 +533,9 @@ If you want to see a more real-world-like implementation you can take a look at
519
533
  ### 🔩 Building a reusable sheet
520
534
 
521
535
  In your projects it might make sense to build a reusable bottom sheet that has all the accessibility features included and can then be easily used in various places in the project. Take a look at the [A11ySheet](example/components/a11y/A11ySheet.tsx) example to get some insight on how to build such a component. By incorporating all the accessibility features inside your own reusable component you don't need to repeat them every time you want to use a bottom sheet in your app.
536
+
537
+ ## 🐛 Troubleshooting
538
+
539
+ ### The sheet doesn't open when using `StrictMode`
540
+
541
+ If you are using React [StrictMode](https://react.dev/reference/react/StrictMode) the sheet animations might not work as expected. This seems to be an issue in the `motion` library and I haven't been able to find a good solution for it yet. You see all `motion` issues related to the `StrictMode` [here](https://github.com/motiondivision/motion/issues?q=is%3Aissue+StrictMode). Easiest solution is to just not to use `StrictMode` 🤷‍♂️
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { motion, EasingDefinition, MotionProps, MotionValue } from 'framer-motion';
2
- import { ForwardRefExoticComponent, RefAttributes, ReactNode, ComponentPropsWithoutRef, HTMLAttributes } from 'react';
1
+ import { motion, MotionProps, EasingDefinition, MotionValue } from 'motion/react';
2
+ import { ReactNode, ComponentPropsWithoutRef, HTMLAttributes, ForwardRefExoticComponent, RefAttributes } from 'react';
3
3
 
4
4
  interface SheetEvents {
5
5
  onOpenStart?: () => void;
@@ -62,5 +62,7 @@ interface SheetRef {
62
62
  snapTo: (index: number) => void;
63
63
  }
64
64
  declare const Sheet: SheetCompound;
65
+ type SheetHeaderProps = SheetDraggableProps;
66
+ type SheetContentProps = SheetDraggableProps;
65
67
 
66
- export { Sheet, type SheetRef };
68
+ export { Sheet, type SheetBackdropProps, type SheetContainerProps, type SheetContentProps, type SheetHeaderProps, type SheetProps, type SheetRef, type SheetScrollerProps };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { motion, EasingDefinition, MotionProps, MotionValue } from 'framer-motion';
2
- import { ForwardRefExoticComponent, RefAttributes, ReactNode, ComponentPropsWithoutRef, HTMLAttributes } from 'react';
1
+ import { motion, MotionProps, EasingDefinition, MotionValue } from 'motion/react';
2
+ import { ReactNode, ComponentPropsWithoutRef, HTMLAttributes, ForwardRefExoticComponent, RefAttributes } from 'react';
3
3
 
4
4
  interface SheetEvents {
5
5
  onOpenStart?: () => void;
@@ -62,5 +62,7 @@ interface SheetRef {
62
62
  snapTo: (index: number) => void;
63
63
  }
64
64
  declare const Sheet: SheetCompound;
65
+ type SheetHeaderProps = SheetDraggableProps;
66
+ type SheetContentProps = SheetDraggableProps;
65
67
 
66
- export { Sheet, type SheetRef };
68
+ export { Sheet, type SheetBackdropProps, type SheetContainerProps, type SheetContentProps, type SheetHeaderProps, type SheetProps, type SheetRef, type SheetScrollerProps };
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  var React2 = require('react');
4
4
  var reactDom = require('react-dom');
5
- var framerMotion = require('framer-motion');
5
+ var react = require('motion/react');
6
6
 
7
7
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
8
 
@@ -35,8 +35,7 @@ function useModalEffect({
35
35
  function setup() {
36
36
  const root = document.querySelector(`#${rootId}`);
37
37
  const body = document.querySelector("body");
38
- if (!root)
39
- return;
38
+ if (!root) return;
40
39
  body.style.backgroundColor = "#000";
41
40
  root.style.overflow = "hidden";
42
41
  root.style.transitionTimingFunction = "cubic-bezier(0.32, 0.72, 0, 1)";
@@ -47,8 +46,7 @@ function useModalEffect({
47
46
  function cleanup() {
48
47
  const root = document.querySelector(`#${rootId}`);
49
48
  const body = document.querySelector("body");
50
- if (!root)
51
- return;
49
+ if (!root) return;
52
50
  setTimeout(() => {
53
51
  body.style.removeProperty("background-color");
54
52
  root.style.removeProperty("overflow");
@@ -63,17 +61,14 @@ function useModalEffect({
63
61
  }
64
62
  useIsomorphicLayoutEffect(() => {
65
63
  return () => {
66
- if (rootId)
67
- cleanup();
64
+ if (rootId) cleanup();
68
65
  };
69
66
  }, []);
70
67
  React2.useEffect(() => {
71
68
  const root = document.querySelector(`#${rootId}`);
72
- if (!root)
73
- return;
69
+ if (!root) return;
74
70
  function onCompleted() {
75
- if (y.get() - 10 >= heightRef.current)
76
- cleanup();
71
+ if (y.get() - 10 >= heightRef.current) cleanup();
77
72
  }
78
73
  const removeStartListener = y.on("animationStart", () => {
79
74
  var _a;
@@ -85,9 +80,9 @@ function useModalEffect({
85
80
  const progress = Math.max(0, 1 - value / heightRef.current);
86
81
  const pageWidth = window.innerWidth;
87
82
  const scale = (pageWidth - 16) / pageWidth;
88
- const ty = framerMotion.transform(progress, [0, 1], [0, 24]);
89
- const s = framerMotion.transform(progress, [0, 1], [1, scale]);
90
- const borderRadius = framerMotion.transform(progress, [0, 1], [0, 10]);
83
+ const ty = react.transform(progress, [0, 1], [0, 24]);
84
+ const s = react.transform(progress, [0, 1], [1, scale]);
85
+ const borderRadius = react.transform(progress, [0, 1], [0, 10]);
91
86
  const inset = "env(safe-area-inset-top)";
92
87
  root.style.transform = `scale(${s}) translate3d(0, calc(${inset} + ${ty}px), 0)`;
93
88
  root.style.borderTopRightRadius = `${borderRadius}px`;
@@ -148,14 +143,14 @@ function useDimensions() {
148
143
  return dimensions;
149
144
  }
150
145
  function usePrevious(state) {
151
- const ref = React2.useRef();
146
+ const ref = React2.useRef(void 0);
152
147
  React2.useEffect(() => {
153
148
  ref.current = state;
154
149
  });
155
150
  return ref.current;
156
151
  }
157
152
  function useEffectEvent(handler) {
158
- const handlerRef = React2.useRef();
153
+ const handlerRef = React2.useRef(void 0);
159
154
  useIsomorphicLayoutEffect(() => {
160
155
  handlerRef.current = handler;
161
156
  });
@@ -175,8 +170,7 @@ var SheetContext = React2.createContext(
175
170
  );
176
171
  var useSheetContext = () => {
177
172
  const context = React2.useContext(SheetContext);
178
- if (!context)
179
- throw Error("Sheet context error");
173
+ if (!context) throw new Error("Sheet context error");
180
174
  return context;
181
175
  };
182
176
  var SheetScrollerContext = React2.createContext(void 0);
@@ -186,12 +180,10 @@ function SheetScrollerContextProvider({
186
180
  const sheetContext = useSheetContext();
187
181
  const [disableDrag, setDisableDrag] = React2.useState(!!sheetContext.disableDrag);
188
182
  function setDragEnabled() {
189
- if (!sheetContext.disableDrag)
190
- setDisableDrag(false);
183
+ if (!sheetContext.disableDrag) setDisableDrag(false);
191
184
  }
192
185
  function setDragDisabled() {
193
- if (!disableDrag)
194
- setDisableDrag(true);
186
+ if (!disableDrag) setDisableDrag(true);
195
187
  }
196
188
  return /* @__PURE__ */ React2__default.default.createElement(
197
189
  SheetScrollerContext.Provider,
@@ -203,8 +195,7 @@ function SheetScrollerContextProvider({
203
195
  }
204
196
  var useSheetScrollerContext = () => {
205
197
  const context = React2.useContext(SheetScrollerContext);
206
- if (!context)
207
- throw Error("Sheet scroller context error");
198
+ if (!context) throw new Error("Sheet scroller context error");
208
199
  return context;
209
200
  };
210
201
 
@@ -223,8 +214,7 @@ function getClosest(nums, goal) {
223
214
  }
224
215
  function inDescendingOrder(arr) {
225
216
  for (let i = 0; i < arr.length; i++) {
226
- if (arr[i + 1] > arr[i])
227
- return false;
217
+ if (arr[i + 1] > arr[i]) return false;
228
218
  }
229
219
  return true;
230
220
  }
@@ -251,16 +241,14 @@ function mergeRefs(refs) {
251
241
  };
252
242
  }
253
243
  function isTouchDevice() {
254
- if (typeof window === "undefined")
255
- return false;
244
+ if (typeof window === "undefined") return false;
256
245
  return "ontouchstart" in window || navigator.maxTouchPoints > 0;
257
246
  }
258
247
  function testPlatform(re) {
259
248
  var _a;
260
249
  return typeof window !== "undefined" && window.navigator != null ? re.test(
261
250
  // @ts-expect-error
262
- // eslint-disable-next-line @typescript-eslint/dot-notation
263
- ((_a = window.navigator["userAgentData"]) == null ? void 0 : _a.platform) || window.navigator.platform
251
+ ((_a = window.navigator.userAgentData) == null ? void 0 : _a.platform) || window.navigator.platform
264
252
  ) : false;
265
253
  }
266
254
  function cached(fn) {
@@ -370,7 +358,9 @@ function preventScrollMobileSafari() {
370
358
  let scrollable;
371
359
  let lastY = 0;
372
360
  const onTouchStart = (e) => {
373
- scrollable = getScrollParent(e.target, true);
361
+ var _a;
362
+ const target = (_a = e.composedPath()) == null ? void 0 : _a[0];
363
+ scrollable = getScrollParent(target, true);
374
364
  if (scrollable === document.documentElement && scrollable === document.body) {
375
365
  return;
376
366
  }
@@ -396,7 +386,8 @@ function preventScrollMobileSafari() {
396
386
  lastY = y;
397
387
  };
398
388
  const onTouchEnd = (e) => {
399
- const target = e.target;
389
+ var _a;
390
+ const target = (_a = e.composedPath()) == null ? void 0 : _a[0];
400
391
  if (willOpenKeyboard(target) && target !== document.activeElement) {
401
392
  e.preventDefault();
402
393
  target.style.transform = "translateY(-2000px)";
@@ -407,7 +398,8 @@ function preventScrollMobileSafari() {
407
398
  }
408
399
  };
409
400
  const onFocus = (e) => {
410
- const target = e.target;
401
+ var _a;
402
+ const target = (_a = e.composedPath()) == null ? void 0 : _a[0];
411
403
  if (willOpenKeyboard(target)) {
412
404
  target.style.transform = "translateY(-2000px)";
413
405
  requestAnimationFrame(() => {
@@ -519,7 +511,8 @@ var styles = {
519
511
  backgroundColor: "rgba(0, 0, 0, 0.2)",
520
512
  touchAction: "none",
521
513
  // Disable iOS body scrolling
522
- border: "none"
514
+ border: "none",
515
+ WebkitTapHighlightColor: "transparent"
523
516
  },
524
517
  container: {
525
518
  zIndex: 2,
@@ -564,7 +557,6 @@ var styles = {
564
557
  overflowY: "auto"
565
558
  }
566
559
  };
567
- var styles_default = styles;
568
560
 
569
561
  // src/sheet.tsx
570
562
  var Sheet = React2.forwardRef(
@@ -592,20 +584,20 @@ var Sheet = React2.forwardRef(
592
584
  ...rest
593
585
  }, ref) => {
594
586
  const sheetRef = React2.useRef(null);
595
- const indicatorRotation = framerMotion.useMotionValue(0);
587
+ const indicatorRotation = react.useMotionValue(0);
596
588
  const { height: windowHeight } = useDimensions();
597
- const shouldReduceMotion = framerMotion.useReducedMotion();
589
+ const shouldReduceMotion = react.useReducedMotion();
598
590
  const reduceMotion = Boolean(prefersReducedMotion || shouldReduceMotion);
599
591
  const animationOptions = {
600
592
  type: "tween",
601
593
  ...reduceMotion ? REDUCED_MOTION_TWEEN_CONFIG : tweenConfig
602
594
  };
603
- const y = framerMotion.useMotionValue(windowHeight);
604
- const zIndex = framerMotion.useTransform(
595
+ const y = react.useMotionValue(windowHeight);
596
+ const zIndex = react.useTransform(
605
597
  y,
606
- (value) => value + 2 >= windowHeight ? -1 : 9999999
598
+ (value) => value + 2 >= windowHeight ? -1 : (style == null ? void 0 : style.zIndex) ?? 9999
607
599
  );
608
- const visibility = framerMotion.useTransform(
600
+ const visibility = react.useTransform(
609
601
  y,
610
602
  (value) => value + 2 >= windowHeight ? "hidden" : "visible"
611
603
  );
@@ -626,8 +618,7 @@ var Sheet = React2.forwardRef(
626
618
  let snapPoints = snapPointsProp;
627
619
  if (snapPoints) {
628
620
  snapPoints = snapPoints.map((point) => {
629
- if (point > 0 && point <= 1)
630
- return Math.round(point * windowHeight);
621
+ if (point > 0 && point <= 1) return Math.round(point * windowHeight);
631
622
  return point < 0 ? windowHeight + point : point;
632
623
  });
633
624
  console.assert(
@@ -639,16 +630,13 @@ var Sheet = React2.forwardRef(
639
630
  }
640
631
  const onDrag = useEffectEvent((_, { delta }) => {
641
632
  const velocity = y.getVelocity();
642
- if (velocity > 0)
643
- indicatorRotation.set(10);
644
- if (velocity < 0)
645
- indicatorRotation.set(-10);
633
+ if (velocity > 0) indicatorRotation.set(10);
634
+ if (velocity < 0) indicatorRotation.set(-10);
646
635
  y.set(Math.max(y.get() + delta.y, 0));
647
636
  });
648
637
  const onDragStart = useEffectEvent(() => {
649
638
  const focusedElement = document.activeElement;
650
- if (!focusedElement || !sheetRef.current)
651
- return;
639
+ if (!focusedElement || !sheetRef.current) return;
652
640
  const isInput = focusedElement.tagName === "INPUT" || focusedElement.tagName === "TEXTAREA";
653
641
  if (isInput && sheetRef.current.contains(focusedElement)) {
654
642
  focusedElement.blur();
@@ -673,22 +661,22 @@ var Sheet = React2.forwardRef(
673
661
  snapTo = sheetHeight;
674
662
  }
675
663
  snapTo = validateSnapTo({ snapTo, sheetHeight });
676
- void framerMotion.animate(y, snapTo, animationOptions);
664
+ react.animate(y, snapTo, animationOptions);
677
665
  if (snapPoints && onSnap) {
678
666
  const snapValue = Math.abs(Math.round(snapPoints[0] - snapTo));
679
- const snapIndex = snapPoints.indexOf(getClosest(snapPoints, snapValue));
667
+ const snapIndex = snapPoints.indexOf(
668
+ getClosest(snapPoints, snapValue)
669
+ );
680
670
  onSnap(snapIndex);
681
671
  }
682
672
  const roundedSheetHeight = Math.round(sheetHeight);
683
673
  const shouldClose = snapTo + 2 >= roundedSheetHeight;
684
- if (shouldClose)
685
- onClose();
674
+ if (shouldClose) onClose();
686
675
  }
687
676
  indicatorRotation.set(0);
688
677
  });
689
678
  React2.useEffect(() => {
690
- if (!snapPoints || !onSnap)
691
- return;
679
+ if (!snapPoints || !onSnap) return;
692
680
  const snapIndex = isOpen ? initialSnap : snapPoints.length - 1;
693
681
  onSnap(snapIndex);
694
682
  }, [isOpen]);
@@ -703,11 +691,9 @@ var Sheet = React2.forwardRef(
703
691
  snapTo: sheetHeight - snapPoint,
704
692
  sheetHeight
705
693
  });
706
- void framerMotion.animate(y, snapTo, animationOptions);
707
- if (onSnap)
708
- onSnap(snapIndex);
709
- if (snapTo >= sheetHeight)
710
- onClose();
694
+ react.animate(y, snapTo, animationOptions);
695
+ if (onSnap) onSnap(snapIndex);
696
+ if (snapTo >= sheetHeight) onClose();
711
697
  }
712
698
  }
713
699
  }));
@@ -745,24 +731,22 @@ var Sheet = React2.forwardRef(
745
731
  disableDrag
746
732
  };
747
733
  const sheet = /* @__PURE__ */ React2__default.default.createElement(SheetContext.Provider, { value: context }, /* @__PURE__ */ React2__default.default.createElement(
748
- framerMotion.motion.div,
734
+ react.motion.div,
749
735
  {
750
736
  ...rest,
751
737
  ref,
752
- style: { ...styles_default.wrapper, zIndex, visibility, ...style }
738
+ style: { ...styles.wrapper, zIndex, visibility, ...style }
753
739
  },
754
- /* @__PURE__ */ React2__default.default.createElement(framerMotion.AnimatePresence, null, isOpen ? /* @__PURE__ */ React2__default.default.createElement(SheetScrollerContextProvider, null, React2.Children.map(
740
+ /* @__PURE__ */ React2__default.default.createElement(react.AnimatePresence, null, isOpen ? /* @__PURE__ */ React2__default.default.createElement(SheetScrollerContextProvider, null, React2.Children.map(
755
741
  children,
756
742
  (child, i) => React2.cloneElement(child, { key: `sheet-child-${i}` })
757
743
  )) : null)
758
744
  ));
759
- if (IS_SSR)
760
- return sheet;
745
+ if (IS_SSR) return sheet;
761
746
  return reactDom.createPortal(sheet, mountPoint ?? document.body);
762
747
  }
763
748
  );
764
749
  Sheet.displayName = "Sheet";
765
- var sheet_default = Sheet;
766
750
  var SheetContainer = React2.forwardRef(
767
751
  ({ children, style = {}, className = "", ...rest }, ref) => {
768
752
  const {
@@ -782,13 +766,13 @@ var SheetContainer = React2.forwardRef(
782
766
  const maxSnapHeight = snapPoints ? snapPoints[0] : null;
783
767
  const height = maxSnapHeight !== null ? `min(${maxSnapHeight}px, ${MAX_HEIGHT})` : MAX_HEIGHT;
784
768
  return /* @__PURE__ */ React2__default.default.createElement(
785
- framerMotion.motion.div,
769
+ react.motion.div,
786
770
  {
787
771
  ...rest,
788
772
  ref: mergeRefs([sheetRef, ref]),
789
773
  className: `react-modal-sheet-container ${className}`,
790
774
  style: {
791
- ...styles_default.container,
775
+ ...styles.container,
792
776
  ...style,
793
777
  ...detent === "full-height" && { height },
794
778
  ...detent === "content-height" && { maxHeight: height },
@@ -804,7 +788,6 @@ var SheetContainer = React2.forwardRef(
804
788
  }
805
789
  );
806
790
  SheetContainer.displayName = "SheetContainer";
807
- var SheetContainer_default = SheetContainer;
808
791
  var SheetContent = React2.forwardRef(
809
792
  ({ children, style, disableDrag, className = "", ...rest }, ref) => {
810
793
  const sheetContext = useSheetContext();
@@ -812,12 +795,12 @@ var SheetContent = React2.forwardRef(
812
795
  const { constraintsRef, onMeasureDragConstraints } = useDragConstraints();
813
796
  const dragProps = disableDrag || sheetScrollerContext.disableDrag ? void 0 : sheetContext.dragProps;
814
797
  return /* @__PURE__ */ React2__default.default.createElement(
815
- framerMotion.motion.div,
798
+ react.motion.div,
816
799
  {
817
800
  ...rest,
818
801
  ref: mergeRefs([ref, constraintsRef]),
819
802
  className: `react-modal-sheet-content ${className}`,
820
- style: { ...styles_default.content, ...style },
803
+ style: { ...styles.content, ...style },
821
804
  ...dragProps,
822
805
  dragConstraints: constraintsRef,
823
806
  onMeasureDragConstraints
@@ -827,52 +810,50 @@ var SheetContent = React2.forwardRef(
827
810
  }
828
811
  );
829
812
  SheetContent.displayName = "SheetContent";
830
- var SheetContent_default = SheetContent;
831
813
  var SheetHeader = React2.forwardRef(
832
814
  ({ children, style, disableDrag, ...rest }, ref) => {
833
815
  const { indicatorRotation, dragProps } = useSheetContext();
834
816
  const { constraintsRef, onMeasureDragConstraints } = useDragConstraints();
835
817
  const _dragProps = disableDrag ? void 0 : dragProps;
836
- const indicator1Transform = framerMotion.useTransform(
818
+ const indicator1Transform = react.useTransform(
837
819
  indicatorRotation,
838
820
  (r) => `translateX(2px) rotate(${r}deg)`
839
821
  );
840
- const indicator2Transform = framerMotion.useTransform(
822
+ const indicator2Transform = react.useTransform(
841
823
  indicatorRotation,
842
824
  (r) => `translateX(-2px) rotate(${-1 * r}deg)`
843
825
  );
844
826
  return /* @__PURE__ */ React2__default.default.createElement(
845
- framerMotion.motion.div,
827
+ react.motion.div,
846
828
  {
847
829
  ...rest,
848
830
  ref: mergeRefs([ref, constraintsRef]),
849
- style: { ...styles_default.headerWrapper, ...style },
831
+ style: { ...styles.headerWrapper, ...style },
850
832
  ..._dragProps,
851
833
  dragConstraints: constraintsRef,
852
834
  onMeasureDragConstraints
853
835
  },
854
- children || /* @__PURE__ */ React2__default.default.createElement("div", { className: "react-modal-sheet-header", style: styles_default.header }, /* @__PURE__ */ React2__default.default.createElement(
855
- framerMotion.motion.span,
836
+ children || /* @__PURE__ */ React2__default.default.createElement("div", { className: "react-modal-sheet-header", style: styles.header }, /* @__PURE__ */ React2__default.default.createElement(
837
+ react.motion.span,
856
838
  {
857
839
  className: "react-modal-sheet-drag-indicator",
858
- style: { ...styles_default.indicator, transform: indicator1Transform }
840
+ style: { ...styles.indicator, transform: indicator1Transform }
859
841
  }
860
842
  ), /* @__PURE__ */ React2__default.default.createElement(
861
- framerMotion.motion.span,
843
+ react.motion.span,
862
844
  {
863
845
  className: "react-modal-sheet-drag-indicator",
864
- style: { ...styles_default.indicator, transform: indicator2Transform }
846
+ style: { ...styles.indicator, transform: indicator2Transform }
865
847
  }
866
848
  ))
867
849
  );
868
850
  }
869
851
  );
870
852
  SheetHeader.displayName = "SheetHeader";
871
- var SheetHeader_default = SheetHeader;
872
853
  var isClickable = (props) => !!props.onClick || !!props.onTap;
873
854
  var SheetBackdrop = React2.forwardRef(
874
855
  ({ style = {}, className = "", ...rest }, ref) => {
875
- const Comp = isClickable(rest) ? framerMotion.motion.button : framerMotion.motion.div;
856
+ const Comp = isClickable(rest) ? react.motion.button : react.motion.div;
876
857
  const pointerEvents = isClickable(rest) ? "auto" : "none";
877
858
  return /* @__PURE__ */ React2__default.default.createElement(
878
859
  Comp,
@@ -880,7 +861,7 @@ var SheetBackdrop = React2.forwardRef(
880
861
  ...rest,
881
862
  ref,
882
863
  className: `react-modal-sheet-backdrop ${className}`,
883
- style: { ...styles_default.backdrop, ...style, pointerEvents },
864
+ style: { ...styles.backdrop, ...style, pointerEvents },
884
865
  initial: { opacity: 0 },
885
866
  animate: { opacity: 1 },
886
867
  exit: { opacity: 0 }
@@ -889,15 +870,13 @@ var SheetBackdrop = React2.forwardRef(
889
870
  }
890
871
  );
891
872
  SheetBackdrop.displayName = "SheetBackdrop";
892
- var SheetBackdrop_default = SheetBackdrop;
893
873
  var SheetScroller = React2.forwardRef(
894
874
  ({ draggableAt = "top", children, style, className = "", ...rest }, ref) => {
895
875
  const sheetScrollerContext = useSheetScrollerContext();
896
876
  function determineDragState(element) {
897
877
  const { scrollTop, scrollHeight, clientHeight } = element;
898
878
  const isScrollable2 = scrollHeight > clientHeight;
899
- if (!isScrollable2)
900
- return;
879
+ if (!isScrollable2) return;
901
880
  const isAtTop = scrollTop <= 0;
902
881
  const isAtBottom = scrollHeight - scrollTop === clientHeight;
903
882
  const shouldEnable = draggableAt === "top" && isAtTop || draggableAt === "bottom" && isAtBottom || draggableAt === "both" && (isAtTop || isAtBottom);
@@ -926,7 +905,7 @@ var SheetScroller = React2.forwardRef(
926
905
  ...rest,
927
906
  ref,
928
907
  className: `react-modal-sheet-scroller ${className}`,
929
- style: { ...styles_default.scroller, ...style },
908
+ style: { ...styles.scroller, ...style },
930
909
  ...scrollProps
931
910
  },
932
911
  children
@@ -934,17 +913,16 @@ var SheetScroller = React2.forwardRef(
934
913
  }
935
914
  );
936
915
  SheetScroller.displayName = "SheetScroller";
937
- var SheetScroller_default = SheetScroller;
938
916
 
939
917
  // src/index.tsx
940
- var _SheetCompound = sheet_default;
941
- _SheetCompound.Container = SheetContainer_default;
942
- _SheetCompound.Header = SheetHeader_default;
943
- _SheetCompound.Content = SheetContent_default;
944
- _SheetCompound.Backdrop = SheetBackdrop_default;
945
- _SheetCompound.Scroller = SheetScroller_default;
946
- var Sheet2 = _SheetCompound;
918
+ var Sheet2 = Object.assign(Sheet, {
919
+ Container: SheetContainer,
920
+ Header: SheetHeader,
921
+ Content: SheetContent,
922
+ Backdrop: SheetBackdrop,
923
+ Scroller: SheetScroller
924
+ });
947
925
 
948
926
  exports.Sheet = Sheet2;
949
- //# sourceMappingURL=out.js.map
927
+ //# sourceMappingURL=index.js.map
950
928
  //# sourceMappingURL=index.js.map