react-modal-sheet 5.3.1 → 5.4.1
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 +9 -6
- package/dist/index.d.mts +0 -5
- package/dist/index.d.ts +0 -5
- package/dist/index.js +253 -160
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +254 -161
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/SheetBackdrop.tsx +10 -4
- package/src/SheetContent.tsx +9 -3
- package/src/debug.ts +3 -2
- package/src/hooks/use-keyboard-avoidance.ts +75 -0
- package/src/hooks/use-prevent-scroll.ts +5 -27
- package/src/hooks/use-scroll-position.ts +0 -1
- package/src/hooks/use-virtual-keyboard.ts +127 -52
- package/src/sheet.tsx +59 -73
- package/src/types.tsx +2 -2
- package/src/utils.ts +26 -0
package/src/types.tsx
CHANGED
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
} from 'motion/react';
|
|
8
8
|
import {
|
|
9
9
|
type ComponentPropsWithoutRef,
|
|
10
|
-
type CSSProperties,
|
|
11
10
|
type ForwardRefExoticComponent,
|
|
12
11
|
type FunctionComponent,
|
|
13
12
|
type HTMLAttributes,
|
|
@@ -108,9 +107,10 @@ export interface SheetContextType {
|
|
|
108
107
|
currentSnap?: number;
|
|
109
108
|
detent: SheetDetent;
|
|
110
109
|
disableDrag: boolean;
|
|
111
|
-
dragProps
|
|
110
|
+
dragProps: SheetDragProps;
|
|
112
111
|
indicatorRotation: MotionValue<number>;
|
|
113
112
|
avoidKeyboard: boolean;
|
|
113
|
+
prefersReducedMotion: boolean;
|
|
114
114
|
sheetBoundsRef: (node: HTMLDivElement | null) => void;
|
|
115
115
|
sheetRef: RefObject<any>;
|
|
116
116
|
unstyled: boolean;
|
package/src/utils.ts
CHANGED
|
@@ -88,3 +88,29 @@ export function waitForElement(
|
|
|
88
88
|
}, interval);
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
|
+
|
|
92
|
+
// HTML input types that do not cause the software keyboard to appear.
|
|
93
|
+
const nonTextInputTypes = new Set([
|
|
94
|
+
'checkbox',
|
|
95
|
+
'radio',
|
|
96
|
+
'range',
|
|
97
|
+
'color',
|
|
98
|
+
'file',
|
|
99
|
+
'image',
|
|
100
|
+
'button',
|
|
101
|
+
'submit',
|
|
102
|
+
'reset',
|
|
103
|
+
]);
|
|
104
|
+
|
|
105
|
+
export function willOpenKeyboard(target: Element) {
|
|
106
|
+
return (
|
|
107
|
+
(target instanceof HTMLInputElement &&
|
|
108
|
+
!nonTextInputTypes.has(target.type)) ||
|
|
109
|
+
target instanceof HTMLTextAreaElement ||
|
|
110
|
+
(target instanceof HTMLElement && target.isContentEditable)
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function isHTTPS() {
|
|
115
|
+
return typeof window !== 'undefined' && window.isSecureContext;
|
|
116
|
+
}
|