react-modal-sheet 5.2.3 → 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.js +17 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -13
- package/src/SheetHeader.tsx +1 -1
- package/src/debug.ts +2 -2
- package/src/sheet.tsx +34 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "5.
|
|
2
|
+
"version": "5.3.0",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "react-modal-sheet",
|
|
5
5
|
"description": "Flexible bottom sheet component for your React apps",
|
|
@@ -57,23 +57,23 @@
|
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@arethetypeswrong/cli": "0.18.2",
|
|
60
|
-
"@biomejs/biome": "2.
|
|
61
|
-
"@types/react": "19.2.
|
|
62
|
-
"@types/react-dom": "19.2.
|
|
63
|
-
"@vitejs/plugin-react": "5.
|
|
60
|
+
"@biomejs/biome": "2.4.5",
|
|
61
|
+
"@types/react": "19.2.14",
|
|
62
|
+
"@types/react-dom": "19.2.3",
|
|
63
|
+
"@vitejs/plugin-react": "5.1.4",
|
|
64
64
|
"husky": "9.1.7",
|
|
65
|
-
"jsdom": "
|
|
66
|
-
"motion": "12.
|
|
65
|
+
"jsdom": "28.1.0",
|
|
66
|
+
"motion": "12.35.0",
|
|
67
67
|
"npm-run-all": "4.1.5",
|
|
68
|
-
"react": "19.2.
|
|
69
|
-
"react-dom": "19.2.
|
|
70
|
-
"tsup": "8.5.
|
|
68
|
+
"react": "19.2.4",
|
|
69
|
+
"react-dom": "19.2.4",
|
|
70
|
+
"tsup": "8.5.1",
|
|
71
71
|
"typescript": "5.9.3",
|
|
72
|
-
"vite": "7.1
|
|
73
|
-
"vitest": "
|
|
72
|
+
"vite": "7.3.1",
|
|
73
|
+
"vitest": "4.0.18"
|
|
74
74
|
},
|
|
75
75
|
"engines": {
|
|
76
|
-
"node": ">=
|
|
76
|
+
"node": ">=20"
|
|
77
77
|
},
|
|
78
78
|
"prettier": {
|
|
79
79
|
"printWidth": 80,
|
package/src/SheetHeader.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { motion } from 'motion/react';
|
|
2
2
|
import React, { forwardRef } from 'react';
|
|
3
3
|
|
|
4
|
-
import { SheetDragIndicator } from './SheetDragIndicator';
|
|
5
4
|
import { useSheetContext } from './context';
|
|
6
5
|
import { useDragConstraints } from './hooks/use-drag-constraints';
|
|
6
|
+
import { SheetDragIndicator } from './SheetDragIndicator';
|
|
7
7
|
import { styles } from './styles';
|
|
8
8
|
import { type SheetHeaderProps } from './types';
|
|
9
9
|
import { applyStyles, mergeRefs } from './utils';
|
package/src/debug.ts
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
* and hide it when that element is clicked. Create the element if it doesn't exist,
|
|
5
5
|
* and update its content with the payload (any JSON data).
|
|
6
6
|
*/
|
|
7
|
-
export function debug(payload: any) {
|
|
7
|
+
export function debug(payload: any, placement: 'top' | 'bottom' = 'bottom') {
|
|
8
8
|
let debugElement = document.getElementById('debug-element');
|
|
9
9
|
|
|
10
10
|
if (!debugElement) {
|
|
11
11
|
debugElement = document.createElement('div');
|
|
12
12
|
debugElement.id = 'debug-element';
|
|
13
13
|
debugElement.style.position = 'fixed';
|
|
14
|
-
debugElement.style
|
|
14
|
+
debugElement.style[placement] = '0';
|
|
15
15
|
debugElement.style.left = '0';
|
|
16
16
|
debugElement.style.width = '100%';
|
|
17
17
|
debugElement.style.maxHeight = '50%';
|
package/src/sheet.tsx
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
} from 'motion/react';
|
|
10
10
|
import React, {
|
|
11
11
|
forwardRef,
|
|
12
|
+
useEffect,
|
|
12
13
|
useImperativeHandle,
|
|
13
14
|
useRef,
|
|
14
15
|
useState,
|
|
@@ -276,6 +277,39 @@ export const Sheet = forwardRef<any, SheetProps>(
|
|
|
276
277
|
snapTo,
|
|
277
278
|
}));
|
|
278
279
|
|
|
280
|
+
/**
|
|
281
|
+
* If the keyboard is opened while we are in a snap point we need to ensure
|
|
282
|
+
* the sheet content is not covered by the keyboard due to being at a lower
|
|
283
|
+
* snap point. We move the sheet up enough to ensure the content is visible
|
|
284
|
+
* and move it back down when the keyboard closes.
|
|
285
|
+
*/
|
|
286
|
+
useEffect(() => {
|
|
287
|
+
if (
|
|
288
|
+
isOpen &&
|
|
289
|
+
snapPoints.length > 0 &&
|
|
290
|
+
avoidKeyboard &&
|
|
291
|
+
keyboard.isKeyboardOpen
|
|
292
|
+
) {
|
|
293
|
+
const visibleSheetHeight = yInverted.get() - keyboard.keyboardHeight;
|
|
294
|
+
|
|
295
|
+
if (visibleSheetHeight <= 0) {
|
|
296
|
+
const currentY = y.get();
|
|
297
|
+
const adjustedY = Math.max(
|
|
298
|
+
// 50 for some extra spacing between keyboard and sheet content
|
|
299
|
+
currentY - Math.abs(visibleSheetHeight) - 50,
|
|
300
|
+
0
|
|
301
|
+
);
|
|
302
|
+
|
|
303
|
+
animate(y, adjustedY, animationOptions);
|
|
304
|
+
|
|
305
|
+
// When keyboard closes animate back to the original snap point
|
|
306
|
+
return () => {
|
|
307
|
+
animate(y, currentY, animationOptions);
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}, [isOpen, keyboard.isKeyboardOpen]);
|
|
312
|
+
|
|
279
313
|
useModalEffect({
|
|
280
314
|
y,
|
|
281
315
|
detent,
|