react-modal-sheet 5.2.2 → 5.3.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 +5 -4
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +22 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -13
- package/src/SheetBackdrop.tsx +4 -5
- package/src/SheetHeader.tsx +1 -1
- package/src/debug.ts +2 -2
- package/src/sheet.tsx +34 -0
- package/src/types.tsx +4 -5
package/README.md
CHANGED
|
@@ -425,10 +425,11 @@ function KeyboardExample() {
|
|
|
425
425
|
|
|
426
426
|
The keyboard avoidance feature:
|
|
427
427
|
|
|
428
|
-
- Uses the `env(keyboard-inset-height)` from [Virtual Keyboard API](https://developer.mozilla.org/en-US/docs/Web/API/VirtualKeyboard_API) and fallbacks to [Visual Viewport API](https://developer.mozilla.org/en-US/docs/Web/API/Visual_Viewport_API) and custom `keyboard-inset-height` CSS environment variable
|
|
429
|
-
- Works automatically on mobile devices with virtual keyboard support
|
|
430
|
-
- Applies dynamic padding to keep content visible when the keyboard opens
|
|
431
|
-
- Disables drag gestures while the keyboard is open to prevent glitches
|
|
428
|
+
- Uses the `env(keyboard-inset-height)` from [Virtual Keyboard API](https://developer.mozilla.org/en-US/docs/Web/API/VirtualKeyboard_API) and fallbacks to [Visual Viewport API](https://developer.mozilla.org/en-US/docs/Web/API/Visual_Viewport_API) and custom `keyboard-inset-height` CSS environment variable.
|
|
429
|
+
- Works automatically on mobile devices with virtual keyboard support.
|
|
430
|
+
- Applies dynamic padding to keep content visible when the keyboard opens.
|
|
431
|
+
- Disables drag gestures while the keyboard is open to prevent glitches.
|
|
432
|
+
- When using snap points if the sheet is at a snap point that would be covered by the keyboard, **the sheet will be automatically moved up to ensure the content is visible and then moved back down when the keyboard closes.**
|
|
432
433
|
|
|
433
434
|
If you need to disable keyboard avoidance, set `avoidKeyboard={false}`.
|
|
434
435
|
|
package/dist/index.d.mts
CHANGED
|
@@ -6,7 +6,8 @@ type CommonProps = {
|
|
|
6
6
|
className?: string;
|
|
7
7
|
unstyled?: boolean;
|
|
8
8
|
};
|
|
9
|
-
type
|
|
9
|
+
type MotionDivProps = ComponentPropsWithoutRef<typeof motion.div>;
|
|
10
|
+
type MotionCommonProps = Omit<MotionDivProps, 'initial' | 'animate' | 'exit'>;
|
|
10
11
|
interface SheetTweenConfig {
|
|
11
12
|
ease: EasingDefinition;
|
|
12
13
|
duration: number;
|
|
@@ -50,7 +51,7 @@ type SheetContentProps = MotionCommonProps & CommonProps & {
|
|
|
50
51
|
scrollClassName?: string;
|
|
51
52
|
scrollStyle?: MotionProps['style'];
|
|
52
53
|
};
|
|
53
|
-
type SheetBackdropProps =
|
|
54
|
+
type SheetBackdropProps = MotionDivProps & CommonProps;
|
|
54
55
|
type SheetDragIndicatorProps = HTMLAttributes<HTMLDivElement> & CommonProps;
|
|
55
56
|
type SheetStateInfo = {
|
|
56
57
|
scrollPosition?: 'top' | 'bottom' | 'middle';
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,8 @@ type CommonProps = {
|
|
|
6
6
|
className?: string;
|
|
7
7
|
unstyled?: boolean;
|
|
8
8
|
};
|
|
9
|
-
type
|
|
9
|
+
type MotionDivProps = ComponentPropsWithoutRef<typeof motion.div>;
|
|
10
|
+
type MotionCommonProps = Omit<MotionDivProps, 'initial' | 'animate' | 'exit'>;
|
|
10
11
|
interface SheetTweenConfig {
|
|
11
12
|
ease: EasingDefinition;
|
|
12
13
|
duration: number;
|
|
@@ -50,7 +51,7 @@ type SheetContentProps = MotionCommonProps & CommonProps & {
|
|
|
50
51
|
scrollClassName?: string;
|
|
51
52
|
scrollStyle?: MotionProps['style'];
|
|
52
53
|
};
|
|
53
|
-
type SheetBackdropProps =
|
|
54
|
+
type SheetBackdropProps = MotionDivProps & CommonProps;
|
|
54
55
|
type SheetDragIndicatorProps = HTMLAttributes<HTMLDivElement> & CommonProps;
|
|
55
56
|
type SheetStateInfo = {
|
|
56
57
|
scrollPosition?: 'top' | 'bottom' | 'middle';
|
package/dist/index.js
CHANGED
|
@@ -221,14 +221,14 @@ var SheetBackdrop = React4.forwardRef(
|
|
|
221
221
|
return /* @__PURE__ */ React4__default.default.createElement(
|
|
222
222
|
Comp,
|
|
223
223
|
{
|
|
224
|
-
...rest,
|
|
225
|
-
ref,
|
|
226
|
-
className: `react-modal-sheet-backdrop ${className}`,
|
|
227
|
-
style: backdropStyle,
|
|
228
224
|
initial: { opacity: 0 },
|
|
229
225
|
animate: { opacity: 1 },
|
|
230
226
|
exit: { opacity: 0 },
|
|
231
|
-
transition: { duration: 1 }
|
|
227
|
+
transition: { duration: 1 },
|
|
228
|
+
...rest,
|
|
229
|
+
ref,
|
|
230
|
+
className: `react-modal-sheet-backdrop ${className}`,
|
|
231
|
+
style: backdropStyle
|
|
232
232
|
}
|
|
233
233
|
);
|
|
234
234
|
}
|
|
@@ -1307,6 +1307,23 @@ var Sheet = React4.forwardRef(
|
|
|
1307
1307
|
height: sheetHeight,
|
|
1308
1308
|
snapTo
|
|
1309
1309
|
}));
|
|
1310
|
+
React4.useEffect(() => {
|
|
1311
|
+
if (isOpen && snapPoints.length > 0 && avoidKeyboard && keyboard.isKeyboardOpen) {
|
|
1312
|
+
const visibleSheetHeight = yInverted.get() - keyboard.keyboardHeight;
|
|
1313
|
+
if (visibleSheetHeight <= 0) {
|
|
1314
|
+
const currentY = y.get();
|
|
1315
|
+
const adjustedY = Math.max(
|
|
1316
|
+
// 50 for some extra spacing between keyboard and sheet content
|
|
1317
|
+
currentY - Math.abs(visibleSheetHeight) - 50,
|
|
1318
|
+
0
|
|
1319
|
+
);
|
|
1320
|
+
react.animate(y, adjustedY, animationOptions);
|
|
1321
|
+
return () => {
|
|
1322
|
+
react.animate(y, currentY, animationOptions);
|
|
1323
|
+
};
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
}, [isOpen, keyboard.isKeyboardOpen]);
|
|
1310
1327
|
useModalEffect({
|
|
1311
1328
|
y,
|
|
1312
1329
|
detent,
|