react-modal-sheet 2.2.0 → 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 +6 -6
- package/dist/index.d.mts +64 -0
- package/dist/index.d.ts +64 -8
- package/dist/index.js +827 -5
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +824 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +59 -36
- package/src/SheetBackdrop.tsx +5 -3
- package/src/SheetContainer.tsx +5 -3
- package/src/SheetContent.tsx +5 -3
- package/src/SheetHeader.tsx +7 -5
- package/src/SheetScroller.tsx +7 -5
- package/src/context.tsx +8 -10
- package/src/hooks.tsx +30 -23
- package/src/index.tsx +7 -7
- package/src/sheet.tsx +47 -32
- package/src/styles.ts +2 -2
- package/src/types.tsx +44 -35
- package/src/use-prevent-scroll.ts +34 -24
- package/src/utils.ts +2 -4
- package/dist/SheetBackdrop.d.ts +0 -5
- package/dist/SheetContainer.d.ts +0 -7
- package/dist/SheetContent.d.ts +0 -8
- package/dist/SheetHeader.d.ts +0 -8
- package/dist/SheetScroller.d.ts +0 -5
- package/dist/constants.d.ts +0 -12
- package/dist/context.d.ts +0 -9
- package/dist/hooks.d.ts +0 -15
- package/dist/react-modal-sheet.cjs.development.js +0 -934
- package/dist/react-modal-sheet.cjs.development.js.map +0 -1
- package/dist/react-modal-sheet.cjs.production.min.js +0 -2
- package/dist/react-modal-sheet.cjs.production.min.js.map +0 -1
- package/dist/react-modal-sheet.esm.js +0 -930
- package/dist/react-modal-sheet.esm.js.map +0 -1
- package/dist/sheet.d.ts +0 -279
- package/dist/styles.d.ts +0 -5
- package/dist/types.d.ts +0 -84
- package/dist/use-prevent-scroll.d.ts +0 -11
- package/dist/utils.d.ts +0 -11
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() {
|
|
@@ -77,7 +77,7 @@ Also, by constructing the sheet from smaller pieces makes it easier to apply any
|
|
|
77
77
|
| `isOpen` | yes | | Boolean that indicates whether the sheet is open or not. |
|
|
78
78
|
| `onClose` | yes | | Callback fn that is called when the sheet is closed by the user. |
|
|
79
79
|
| `disableDrag` | no | false | Disable drag for the whole sheet. |
|
|
80
|
-
| `disableScrollLocking` | no | false | Disable
|
|
80
|
+
| `disableScrollLocking` | no | false | Disable scroll locking for the `body` element while sheet is open. Can be useful if you face issues with input elements and the iOS virtual keyboard. See related [issue](https://github.com/Temzasse/react-modal-sheet/issues/135). |
|
|
81
81
|
| `detent` | no | `'full-height'` | The [detent](https://developer.apple.com/design/human-interface-guidelines/components/presentation/sheets#ios-ipados) in which the sheet should be in when opened. Available values: `'full-height'` or `'content-height'`. |
|
|
82
82
|
| `onOpenStart` | no | | Callback fn that is called when the sheet opening animation starts. |
|
|
83
83
|
| `onOpenEnd` | no | | Callback fn that is called when the sheet opening animation is completed. |
|
|
@@ -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,
|
|
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,
|
|
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
|
|
package/dist/index.d.mts
ADDED
|
@@ -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 {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 };
|