react-modal-sheet 2.2.1 → 3.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
@@ -41,7 +41,7 @@ npm install framer-motion
41
41
  ## Usage
42
42
 
43
43
  ```jsx
44
- import Sheet from 'react-modal-sheet';
44
+ import { Sheet } from 'react-modal-sheet';
45
45
  import { useState } from 'react';
46
46
 
47
47
  function Example() {
@@ -98,7 +98,7 @@ Also, by constructing the sheet from smaller pieces makes it easier to apply any
98
98
  Imperative method that can be accessed via a ref for snapping to a snap point in given index.
99
99
 
100
100
  ```tsx
101
- import Sheet, { SheetRef } from 'react-modal-sheet';
101
+ import { Sheet, SheetRef } from 'react-modal-sheet';
102
102
  import { useState, useRef } from 'react';
103
103
 
104
104
  function Example() {
@@ -144,7 +144,7 @@ Similarly to the `snapTo` method the `y` value can be accessed via a ref.
144
144
  The `y` value can be useful for certain situtation eg. when you want to combine snap points with scrollable sheet content and ensure that the content stays properly scrollable in any snap point. Below you can see a simplified example of this situation and for a more detailed example take a look at the [ScrollableSnapPoints](example/components/ScrollableSnapPoints.tsx) component in the example app.
145
145
 
146
146
  ```tsx
147
- import Sheet, { SheetRef } from 'react-modal-sheet';
147
+ import { Sheet, SheetRef } from 'react-modal-sheet';
148
148
  import { useState, useRef } from 'react';
149
149
 
150
150
  function Example() {
@@ -371,7 +371,7 @@ You can add your own styles or override the default sheet styles via the exposed
371
371
  #### CSS-in-JS
372
372
 
373
373
  ```jsx
374
- import Sheet from 'react-modal-sheet';
374
+ import { Sheet } from 'react-modal-sheet';
375
375
  import styled from 'styled-components';
376
376
  import { useState } from 'react';
377
377
 
@@ -421,7 +421,7 @@ The example below utilizes React Aria to achieve an accessible modal-like bottom
421
421
  > ℹ️ The example was built by following the React Aria's [useDialog](https://react-spectrum.adobe.com/react-aria/useDialog.html) documentation.
422
422
 
423
423
  ```jsx
424
- import Sheet from 'react-modal-sheet';
424
+ import { Sheet } from 'react-modal-sheet';
425
425
  import { useRef } from 'react';
426
426
  import { useOverlayTriggerState } from 'react-stately';
427
427
 
@@ -0,0 +1,64 @@
1
+ import { motion, EasingDefinition, MotionProps, MotionValue } from 'framer-motion';
2
+ import { ForwardRefExoticComponent, RefAttributes, ReactNode, ComponentPropsWithoutRef, HTMLAttributes } from 'react';
3
+
4
+ interface SheetEvents {
5
+ onOpenStart?: () => void;
6
+ onOpenEnd?: () => void;
7
+ onCloseStart?: () => void;
8
+ onCloseEnd?: () => void;
9
+ onSnap?: (index: number) => void;
10
+ }
11
+ type SheetDetent = 'full-height' | 'content-height';
12
+ type CommonProps = MotionProps & {
13
+ className?: string;
14
+ };
15
+ interface SheetTweenConfig {
16
+ ease: EasingDefinition;
17
+ duration: number;
18
+ }
19
+ type SheetProps = {
20
+ isOpen: boolean;
21
+ children: ReactNode;
22
+ onClose: () => void;
23
+ rootId?: string;
24
+ mountPoint?: Element;
25
+ snapPoints?: number[];
26
+ detent?: SheetDetent;
27
+ initialSnap?: number;
28
+ tweenConfig?: SheetTweenConfig;
29
+ disableDrag?: boolean;
30
+ disableScrollLocking?: boolean;
31
+ prefersReducedMotion?: boolean;
32
+ } & SheetEvents & ComponentPropsWithoutRef<typeof motion.div>;
33
+ type SheetContainerProps = Omit<CommonProps, 'initial' | 'animate' | 'exit' | 'onAnimationComplete'> & {
34
+ children: ReactNode;
35
+ };
36
+ type SheetDraggableProps = Omit<CommonProps, 'drag' | 'dragElastic' | 'dragConstraints' | 'dragMomentum' | 'onDrag' | 'onDragStart' | 'onDragEnd'> & {
37
+ children?: ReactNode;
38
+ disableDrag?: boolean;
39
+ };
40
+ type SheetBackdropProps = Omit<CommonProps, 'initial' | 'animate' | 'exit'>;
41
+ type SheetScrollerProps = HTMLAttributes<HTMLDivElement> & {
42
+ draggableAt?: 'top' | 'bottom' | 'both';
43
+ };
44
+ type ContainerComponent = ForwardRefExoticComponent<SheetContainerProps & RefAttributes<any>>;
45
+ type DraggableComponent = ForwardRefExoticComponent<SheetDraggableProps & RefAttributes<any>>;
46
+ type BackdropComponent = ForwardRefExoticComponent<SheetBackdropProps & RefAttributes<any>>;
47
+ type SheetComponent = ForwardRefExoticComponent<SheetProps & RefAttributes<any>>;
48
+ type ScrollerComponent = ForwardRefExoticComponent<SheetScrollerProps & RefAttributes<any>>;
49
+ interface SheetCompoundComponent {
50
+ Container: ContainerComponent;
51
+ Header: DraggableComponent;
52
+ Content: DraggableComponent;
53
+ Backdrop: BackdropComponent;
54
+ Scroller: ScrollerComponent;
55
+ }
56
+ type SheetCompound = SheetComponent & SheetCompoundComponent;
57
+
58
+ interface SheetRef {
59
+ y: MotionValue<number>;
60
+ snapTo: (index: number) => void;
61
+ }
62
+ declare const Sheet: SheetCompound;
63
+
64
+ export { Sheet, type SheetRef };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,64 @@
1
- import { MotionValue } from 'framer-motion';
2
- import { SheetCompound } from './types';
3
- export declare type SheetRef = {
4
- y: MotionValue<number>;
5
- snapTo: (index: number) => void;
6
- };
7
- declare const _default: SheetCompound;
8
- export default _default;
1
+ import { motion, EasingDefinition, MotionProps, MotionValue } from 'framer-motion';
2
+ import { ForwardRefExoticComponent, RefAttributes, ReactNode, ComponentPropsWithoutRef, HTMLAttributes } from 'react';
3
+
4
+ interface SheetEvents {
5
+ onOpenStart?: () => void;
6
+ onOpenEnd?: () => void;
7
+ onCloseStart?: () => void;
8
+ onCloseEnd?: () => void;
9
+ onSnap?: (index: number) => void;
10
+ }
11
+ type SheetDetent = 'full-height' | 'content-height';
12
+ type CommonProps = MotionProps & {
13
+ className?: string;
14
+ };
15
+ interface SheetTweenConfig {
16
+ ease: EasingDefinition;
17
+ duration: number;
18
+ }
19
+ type SheetProps = {
20
+ isOpen: boolean;
21
+ children: ReactNode;
22
+ onClose: () => void;
23
+ rootId?: string;
24
+ mountPoint?: Element;
25
+ snapPoints?: number[];
26
+ detent?: SheetDetent;
27
+ initialSnap?: number;
28
+ tweenConfig?: SheetTweenConfig;
29
+ disableDrag?: boolean;
30
+ disableScrollLocking?: boolean;
31
+ prefersReducedMotion?: boolean;
32
+ } & SheetEvents & ComponentPropsWithoutRef<typeof motion.div>;
33
+ type SheetContainerProps = Omit<CommonProps, 'initial' | 'animate' | 'exit' | 'onAnimationComplete'> & {
34
+ children: ReactNode;
35
+ };
36
+ type SheetDraggableProps = Omit<CommonProps, 'drag' | 'dragElastic' | 'dragConstraints' | 'dragMomentum' | 'onDrag' | 'onDragStart' | 'onDragEnd'> & {
37
+ children?: ReactNode;
38
+ disableDrag?: boolean;
39
+ };
40
+ type SheetBackdropProps = Omit<CommonProps, 'initial' | 'animate' | 'exit'>;
41
+ type SheetScrollerProps = HTMLAttributes<HTMLDivElement> & {
42
+ draggableAt?: 'top' | 'bottom' | 'both';
43
+ };
44
+ type ContainerComponent = ForwardRefExoticComponent<SheetContainerProps & RefAttributes<any>>;
45
+ type DraggableComponent = ForwardRefExoticComponent<SheetDraggableProps & RefAttributes<any>>;
46
+ type BackdropComponent = ForwardRefExoticComponent<SheetBackdropProps & RefAttributes<any>>;
47
+ type SheetComponent = ForwardRefExoticComponent<SheetProps & RefAttributes<any>>;
48
+ type ScrollerComponent = ForwardRefExoticComponent<SheetScrollerProps & RefAttributes<any>>;
49
+ interface SheetCompoundComponent {
50
+ Container: ContainerComponent;
51
+ Header: DraggableComponent;
52
+ Content: DraggableComponent;
53
+ Backdrop: BackdropComponent;
54
+ Scroller: ScrollerComponent;
55
+ }
56
+ type SheetCompound = SheetComponent & SheetCompoundComponent;
57
+
58
+ interface SheetRef {
59
+ y: MotionValue<number>;
60
+ snapTo: (index: number) => void;
61
+ }
62
+ declare const Sheet: SheetCompound;
63
+
64
+ export { Sheet, type SheetRef };