@rootnative/web 0.0.0-alpha.3 → 0.0.0-alpha.4
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/CHANGELOG.md +21 -1
- package/dist/apis/AccessibilityInfo/index.d.ts +30 -0
- package/dist/apis/AccessibilityInfo/index.js +84 -0
- package/dist/apis/AccessibilityInfo/index.js.map +1 -0
- package/dist/apis/Alert/index.d.ts +22 -0
- package/dist/apis/Alert/index.js +141 -0
- package/dist/apis/Alert/index.js.map +1 -0
- package/dist/apis/AppState/index.d.ts +21 -0
- package/dist/apis/AppState/index.js +86 -0
- package/dist/apis/AppState/index.js.map +1 -0
- package/dist/apis/Appearance/index.d.ts +14 -0
- package/dist/apis/Appearance/index.js +39 -0
- package/dist/apis/Appearance/index.js.map +1 -0
- package/dist/apis/BackHandler/index.d.ts +10 -0
- package/dist/apis/BackHandler/index.js +16 -0
- package/dist/apis/BackHandler/index.js.map +1 -0
- package/dist/apis/Clipboard/index.d.ts +9 -0
- package/dist/apis/Clipboard/index.js +45 -0
- package/dist/apis/Clipboard/index.js.map +1 -0
- package/dist/apis/Dimensions/index.d.ts +19 -0
- package/dist/apis/Dimensions/index.js +66 -0
- package/dist/apis/Dimensions/index.js.map +1 -0
- package/dist/apis/I18nManager/index.d.ts +14 -0
- package/dist/apis/I18nManager/index.js +33 -0
- package/dist/apis/I18nManager/index.js.map +1 -0
- package/dist/apis/Keyboard/index.d.ts +36 -0
- package/dist/apis/Keyboard/index.js +149 -0
- package/dist/apis/Keyboard/index.js.map +1 -0
- package/dist/apis/Linking/index.d.ts +29 -0
- package/dist/apis/Linking/index.js +86 -0
- package/dist/apis/Linking/index.js.map +1 -0
- package/dist/apis/PanResponder/index.d.ts +50 -0
- package/dist/apis/PanResponder/index.js +239 -0
- package/dist/apis/PanResponder/index.js.map +1 -0
- package/dist/apis/PixelRatio/index.d.ts +8 -0
- package/dist/apis/PixelRatio/index.js +15 -0
- package/dist/apis/PixelRatio/index.js.map +1 -0
- package/dist/apis/Platform/index.d.ts +4 -0
- package/dist/apis/Platform/index.js +28 -0
- package/dist/apis/Platform/index.js.map +1 -0
- package/dist/apis/Platform/types.d.ts +19 -0
- package/dist/apis/Share/index.d.ts +30 -0
- package/dist/apis/Share/index.js +34 -0
- package/dist/apis/Share/index.js.map +1 -0
- package/dist/apis/StyleSheet/index.d.ts +23 -0
- package/dist/apis/StyleSheet/index.js +29 -0
- package/dist/apis/StyleSheet/index.js.map +1 -0
- package/dist/apis/StyleSheet/types.d.ts +328 -0
- package/dist/apis/Vibration/index.d.ts +9 -0
- package/dist/apis/Vibration/index.js +40 -0
- package/dist/apis/Vibration/index.js.map +1 -0
- package/dist/apis/processColor/index.d.ts +3 -0
- package/dist/apis/processColor/index.js +12 -0
- package/dist/apis/processColor/index.js.map +1 -0
- package/dist/apis/useColorScheme/index.d.ts +3 -0
- package/dist/apis/useColorScheme/index.js +13 -0
- package/dist/apis/useColorScheme/index.js.map +1 -0
- package/dist/apis/useWindowDimensions/index.d.ts +3 -0
- package/dist/apis/useWindowDimensions/index.js +19 -0
- package/dist/apis/useWindowDimensions/index.js.map +1 -0
- package/dist/bundler/index.js +30 -0
- package/dist/bundler/index.js.map +1 -0
- package/dist/bundler/inlinePlatformOS.js +121 -0
- package/dist/bundler/inlinePlatformOS.js.map +1 -0
- package/dist/bundler/worklets.js +61 -0
- package/dist/bundler/worklets.js.map +1 -0
- package/dist/compat/TurboModuleRegistry/index.d.ts +16 -0
- package/dist/compat/TurboModuleRegistry/index.js +14 -0
- package/dist/compat/TurboModuleRegistry/index.js.map +1 -0
- package/dist/compat/createElement/index.d.ts +9 -0
- package/dist/compat/createElement/index.js +40 -0
- package/dist/compat/createElement/index.js.map +1 -0
- package/dist/compat/findNodeHandle/index.d.ts +7 -0
- package/dist/compat/findNodeHandle/index.js +19 -0
- package/dist/compat/findNodeHandle/index.js.map +1 -0
- package/dist/components/ActivityIndicator/index.d.ts +5 -0
- package/dist/components/ActivityIndicator/index.js +74 -0
- package/dist/components/ActivityIndicator/index.js.map +1 -0
- package/dist/components/ActivityIndicator/types.d.ts +8 -0
- package/dist/components/Button/index.d.ts +5 -0
- package/dist/components/Button/index.js +48 -0
- package/dist/components/Button/index.js.map +1 -0
- package/dist/components/Button/types.d.ts +31 -0
- package/dist/components/FlatList/index.d.ts +5 -0
- package/dist/components/FlatList/index.js +433 -0
- package/dist/components/FlatList/index.js.map +1 -0
- package/dist/components/FlatList/types.d.ts +138 -0
- package/dist/components/FlatList/viewability.js +86 -0
- package/dist/components/FlatList/viewability.js.map +1 -0
- package/dist/components/Image/index.d.ts +7 -0
- package/dist/components/Image/index.js +301 -0
- package/dist/components/Image/index.js.map +1 -0
- package/dist/components/Image/source.js +97 -0
- package/dist/components/Image/source.js.map +1 -0
- package/dist/components/Image/types.d.ts +96 -0
- package/dist/components/KeyboardAvoidingView/index.d.ts +10 -0
- package/dist/components/KeyboardAvoidingView/index.js +118 -0
- package/dist/components/KeyboardAvoidingView/index.js.map +1 -0
- package/dist/components/KeyboardAvoidingView/types.d.ts +14 -0
- package/dist/components/Modal/index.d.ts +9 -0
- package/dist/components/Modal/index.js +271 -0
- package/dist/components/Modal/index.js.map +1 -0
- package/dist/components/Modal/types.d.ts +29 -0
- package/dist/components/Pressable/index.d.ts +5 -0
- package/dist/components/Pressable/index.js +106 -0
- package/dist/components/Pressable/index.js.map +1 -0
- package/dist/components/Pressable/types.d.ts +44 -0
- package/dist/components/RefreshControl/index.d.ts +5 -0
- package/dist/components/RefreshControl/index.js +176 -0
- package/dist/components/RefreshControl/index.js.map +1 -0
- package/dist/components/RefreshControl/pull.js +16 -0
- package/dist/components/RefreshControl/pull.js.map +1 -0
- package/dist/components/RefreshControl/types.d.ts +14 -0
- package/dist/components/ScrollView/index.d.ts +5 -0
- package/dist/components/ScrollView/index.js +318 -0
- package/dist/components/ScrollView/index.js.map +1 -0
- package/dist/components/ScrollView/snap.js +38 -0
- package/dist/components/ScrollView/snap.js.map +1 -0
- package/dist/components/ScrollView/types.d.ts +115 -0
- package/dist/components/StatusBar/index.d.ts +26 -0
- package/dist/components/StatusBar/index.js +113 -0
- package/dist/components/StatusBar/index.js.map +1 -0
- package/dist/components/Switch/index.d.ts +5 -0
- package/dist/components/Switch/index.js +89 -0
- package/dist/components/Switch/index.js.map +1 -0
- package/dist/components/Switch/types.d.ts +25 -0
- package/dist/components/Text/TextAncestorContext.d.ts +3 -0
- package/dist/components/Text/TextAncestorContext.js +6 -0
- package/dist/components/Text/TextAncestorContext.js.map +1 -0
- package/dist/components/Text/index.d.ts +6 -0
- package/dist/components/Text/index.js +133 -0
- package/dist/components/Text/index.js.map +1 -0
- package/dist/components/Text/types.d.ts +38 -0
- package/dist/components/TextInput/autocomplete.js +102 -0
- package/dist/components/TextInput/autocomplete.js.map +1 -0
- package/dist/components/TextInput/index.d.ts +8 -0
- package/dist/components/TextInput/index.js +290 -0
- package/dist/components/TextInput/index.js.map +1 -0
- package/dist/components/TextInput/types.d.ts +130 -0
- package/dist/components/TouchableHighlight/index.d.ts +5 -0
- package/dist/components/TouchableHighlight/index.js +109 -0
- package/dist/components/TouchableHighlight/index.js.map +1 -0
- package/dist/components/TouchableHighlight/types.d.ts +15 -0
- package/dist/components/TouchableNativeFeedback/index.d.ts +11 -0
- package/dist/components/TouchableNativeFeedback/index.js +29 -0
- package/dist/components/TouchableNativeFeedback/index.js.map +1 -0
- package/dist/components/TouchableNativeFeedback/types.d.ts +19 -0
- package/dist/components/TouchableOpacity/index.d.ts +5 -0
- package/dist/components/TouchableOpacity/index.js +122 -0
- package/dist/components/TouchableOpacity/index.js.map +1 -0
- package/dist/components/TouchableOpacity/types.d.ts +11 -0
- package/dist/components/TouchableWithoutFeedback/index.d.ts +5 -0
- package/dist/components/TouchableWithoutFeedback/index.js +70 -0
- package/dist/components/TouchableWithoutFeedback/index.js.map +1 -0
- package/dist/components/TouchableWithoutFeedback/types.d.ts +40 -0
- package/dist/components/View/index.d.ts +5 -0
- package/dist/components/View/index.js +50 -0
- package/dist/components/View/index.js.map +1 -0
- package/dist/components/View/types.d.ts +98 -0
- package/dist/dom/Head.d.ts +21 -0
- package/dist/dom/Head.js +53 -0
- package/dist/dom/Head.js.map +1 -0
- package/dist/dom/index.d.ts +2 -22
- package/dist/dom/index.js +1 -53
- package/dist/events/press/Pressability.d.ts +2 -0
- package/dist/events/press/Pressability.js +366 -0
- package/dist/events/press/Pressability.js.map +1 -0
- package/dist/events/press/cursorStyle.js +5 -0
- package/dist/events/press/cursorStyle.js.map +1 -0
- package/dist/events/press/index.d.ts +4 -0
- package/dist/events/press/mergeHandlers.js +30 -0
- package/dist/events/press/mergeHandlers.js.map +1 -0
- package/dist/events/press/types.d.ts +48 -0
- package/dist/events/press/usePressability.d.ts +4 -0
- package/dist/events/press/usePressability.js +18 -0
- package/dist/events/press/usePressability.js.map +1 -0
- package/dist/events/responderEvent.js +50 -0
- package/dist/events/responderEvent.js.map +1 -0
- package/dist/events/types.d.ts +33 -0
- package/dist/index.d.ts +66 -1597
- package/dist/index.js +42 -4864
- package/dist/reactNativeVersion.d.ts +7 -0
- package/dist/reactNativeVersion.js +10 -0
- package/dist/reactNativeVersion.js.map +1 -0
- package/dist/render/domProps.js +66 -0
- package/dist/render/domProps.js.map +1 -0
- package/dist/render/hitSlop.js +21 -0
- package/dist/render/hitSlop.js.map +1 -0
- package/dist/render/hostMethods.js +44 -0
- package/dist/render/hostMethods.js.map +1 -0
- package/dist/render/resolveTag.js +64 -0
- package/dist/render/resolveTag.js.map +1 -0
- package/dist/render/useElementLayout.js +25 -0
- package/dist/render/useElementLayout.js.map +1 -0
- package/dist/server/index.d.ts +2 -27
- package/dist/server/index.js +2 -2
- package/dist/{StyleRegistryContext-ROsMlY4O.js → style/StyleRegistryContext.js} +3 -3
- package/dist/style/StyleRegistryContext.js.map +1 -0
- package/dist/style/color.js +16 -0
- package/dist/style/color.js.map +1 -0
- package/dist/style/compile.js +72 -0
- package/dist/style/compile.js.map +1 -0
- package/dist/style/direction.js +33 -0
- package/dist/style/direction.js.map +1 -0
- package/dist/style/index.d.ts +1 -1
- package/dist/style/index.js +5 -2
- package/dist/style/index.js.map +1 -1
- package/dist/style/registry.d.ts +27 -0
- package/dist/{registry-Aa_Od5m0.js → style/registry.js} +3 -3
- package/dist/style/registry.js.map +1 -0
- package/dist/style/resolveStyle.js +181 -0
- package/dist/style/resolveStyle.js.map +1 -0
- package/dist/style/shadow.js +87 -0
- package/dist/style/shadow.js.map +1 -0
- package/dist/style/splitLayoutProps.js +52 -0
- package/dist/style/splitLayoutProps.js.map +1 -0
- package/dist/style/transform.js +35 -0
- package/dist/style/transform.js.map +1 -0
- package/dist/style/types.d.ts +4 -0
- package/dist/style/units.js +21 -0
- package/dist/style/units.js.map +1 -0
- package/dist/style/webStyle.js +9 -0
- package/dist/style/webStyle.js.map +1 -0
- package/dist/{env-DK5Mt9yX.js → utils/env.js} +2 -2
- package/dist/utils/env.js.map +1 -0
- package/dist/utils/scrollLock.js +28 -0
- package/dist/utils/scrollLock.js.map +1 -0
- package/dist/utils/warn.js +11 -0
- package/dist/utils/warn.js.map +1 -0
- package/dist/vite/index.js +4 -202
- package/dist/vite/index.js.map +1 -1
- package/llms.txt +20 -0
- package/package.json +4 -3
- package/dist/StyleRegistryContext-ROsMlY4O.js.map +0 -1
- package/dist/compile-CVUjQrR9.js +0 -400
- package/dist/compile-CVUjQrR9.js.map +0 -1
- package/dist/dom/index.js.map +0 -1
- package/dist/env-DK5Mt9yX.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/registry-Aa_Od5m0.js.map +0 -1
- package/dist/types-BxTWbdj9.d.ts +0 -5
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { ImageResizeMode, ImageStyle } from "../../apis/StyleSheet/types.js";
|
|
2
|
+
import { StyleProp } from "../../style/types.js";
|
|
3
|
+
import { AccessibilityProps, DOMEventHandlers, HostInstance, LayoutChangeEvent } from "../View/types.js";
|
|
4
|
+
import { HTMLAttributeReferrerPolicy, Ref } from "react";
|
|
5
|
+
export type ImageInstance = HostInstance;
|
|
6
|
+
export type ImageURISource = {
|
|
7
|
+
uri?: string | undefined;
|
|
8
|
+
bundle?: string | undefined;
|
|
9
|
+
method?: string | undefined;
|
|
10
|
+
headers?: Record<string, string> | undefined;
|
|
11
|
+
body?: string | undefined;
|
|
12
|
+
cache?: "default" | "reload" | "force-cache" | "only-if-cached" | undefined;
|
|
13
|
+
width?: number | undefined;
|
|
14
|
+
height?: number | undefined;
|
|
15
|
+
scale?: number | undefined;
|
|
16
|
+
};
|
|
17
|
+
export type ImageSource = ImageURISource | ReadonlyArray<ImageURISource> | number | string;
|
|
18
|
+
export type ImageResolvedAssetSource = {
|
|
19
|
+
uri: string;
|
|
20
|
+
width?: number | undefined;
|
|
21
|
+
height?: number | undefined;
|
|
22
|
+
scale: number;
|
|
23
|
+
};
|
|
24
|
+
export type ImageLoadEventData = {
|
|
25
|
+
source: {
|
|
26
|
+
uri: string;
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export type ImageLoadEvent = {
|
|
32
|
+
nativeEvent: ImageLoadEventData;
|
|
33
|
+
};
|
|
34
|
+
export type ImageErrorEvent = {
|
|
35
|
+
nativeEvent: {
|
|
36
|
+
error: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export type ImageProgressEvent = {
|
|
40
|
+
nativeEvent: {
|
|
41
|
+
loaded: number;
|
|
42
|
+
total: number;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
export type ImageSize = {
|
|
46
|
+
width: number;
|
|
47
|
+
height: number;
|
|
48
|
+
};
|
|
49
|
+
type ReservedDOMHandlers = "onLoad" | "onLoadStart" | "onError" | "onProgress";
|
|
50
|
+
export interface ImageProps extends AccessibilityProps, Omit<DOMEventHandlers<HTMLElement>, ReservedDOMHandlers> {
|
|
51
|
+
source?: ImageSource | undefined;
|
|
52
|
+
src?: string | undefined;
|
|
53
|
+
srcSet?: string | undefined;
|
|
54
|
+
alt?: string | undefined;
|
|
55
|
+
defaultSource?: ImageURISource | number | string | undefined;
|
|
56
|
+
resizeMode?: ImageResizeMode | undefined;
|
|
57
|
+
resizeMethod?: "auto" | "resize" | "scale" | "none" | undefined;
|
|
58
|
+
blurRadius?: number | undefined;
|
|
59
|
+
tintColor?: unknown;
|
|
60
|
+
width?: number | undefined;
|
|
61
|
+
height?: number | undefined;
|
|
62
|
+
crossOrigin?: "anonymous" | "use-credentials" | undefined;
|
|
63
|
+
referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
|
|
64
|
+
fadeDuration?: number | undefined;
|
|
65
|
+
progressiveRenderingEnabled?: boolean | undefined;
|
|
66
|
+
loadingIndicatorSource?: ImageURISource | number | undefined;
|
|
67
|
+
style?: StyleProp<ImageStyle> | undefined;
|
|
68
|
+
ref?: Ref<ImageInstance> | undefined;
|
|
69
|
+
id?: string | undefined;
|
|
70
|
+
nativeID?: string | undefined;
|
|
71
|
+
testID?: string | undefined;
|
|
72
|
+
onLayout?: ((event: LayoutChangeEvent) => void) | undefined;
|
|
73
|
+
onLoad?: ((event: ImageLoadEvent) => void) | undefined;
|
|
74
|
+
onLoadStart?: (() => void) | undefined;
|
|
75
|
+
onLoadEnd?: (() => void) | undefined;
|
|
76
|
+
onError?: ((event: ImageErrorEvent) => void) | undefined;
|
|
77
|
+
onProgress?: ((event: ImageProgressEvent) => void) | undefined;
|
|
78
|
+
loading?: "eager" | "lazy" | undefined;
|
|
79
|
+
fetchPriority?: "high" | "low" | "auto" | undefined;
|
|
80
|
+
decoding?: "sync" | "async" | "auto" | undefined;
|
|
81
|
+
}
|
|
82
|
+
export type ImageStatics = {
|
|
83
|
+
getSize: {
|
|
84
|
+
(uri: string): Promise<ImageSize>;
|
|
85
|
+
(uri: string, success: (width: number, height: number) => void, failure?: (error: unknown) => void): void;
|
|
86
|
+
};
|
|
87
|
+
getSizeWithHeaders: {
|
|
88
|
+
(uri: string, headers: Record<string, string>): Promise<ImageSize>;
|
|
89
|
+
(uri: string, headers: Record<string, string>, success: (width: number, height: number) => void, failure?: (error: unknown) => void): void;
|
|
90
|
+
};
|
|
91
|
+
prefetch: (url: string) => Promise<boolean>;
|
|
92
|
+
queryCache: (urls: ReadonlyArray<string>) => Promise<Record<string, "memory" | "disk" | "disk/memory">>;
|
|
93
|
+
resolveAssetSource: (source: ImageSource | undefined) => ImageResolvedAssetSource | null;
|
|
94
|
+
};
|
|
95
|
+
export type { ImageResizeMode };
|
|
96
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { KeyboardAvoidingViewInstance, KeyboardAvoidingViewProps } from "./types.js";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* A view that moves out of the way of the keyboard, with the math of React Native 0.88. As on
|
|
5
|
+
* native, the frame of the view comes from `onLayout`, so its `y` is relative to its parent.
|
|
6
|
+
* `keyboardVerticalOffset` adds the distance to the top of the window.
|
|
7
|
+
*/
|
|
8
|
+
export declare function KeyboardAvoidingView(props: KeyboardAvoidingViewProps): ReactElement;
|
|
9
|
+
export type { KeyboardAvoidingViewInstance, KeyboardAvoidingViewProps };
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Keyboard } from "../../apis/Keyboard/index.js";
|
|
2
|
+
import { View } from "../View/index.js";
|
|
3
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
// src/components/KeyboardAvoidingView/index.tsx
|
|
6
|
+
/**
|
|
7
|
+
* A view that moves out of the way of the keyboard, with the math of React Native 0.88. As on
|
|
8
|
+
* native, the frame of the view comes from `onLayout`, so its `y` is relative to its parent.
|
|
9
|
+
* `keyboardVerticalOffset` adds the distance to the top of the window.
|
|
10
|
+
*/
|
|
11
|
+
function KeyboardAvoidingView(props) {
|
|
12
|
+
const { behavior, children, contentContainerStyle, enabled = true, keyboardVerticalOffset = 0, style, onLayout, ...rest } = props;
|
|
13
|
+
const [bottom, setBottom] = useState(0);
|
|
14
|
+
const [initialFrameHeight, setInitialFrameHeight] = useState(0);
|
|
15
|
+
const frame = useRef(null);
|
|
16
|
+
const keyboard = useRef(null);
|
|
17
|
+
const latestBottom = useRef(0);
|
|
18
|
+
const shownBottom = useRef(0);
|
|
19
|
+
const initialHeight = useRef(0);
|
|
20
|
+
const latest = useRef({
|
|
21
|
+
behavior,
|
|
22
|
+
enabled,
|
|
23
|
+
keyboardVerticalOffset,
|
|
24
|
+
onLayout
|
|
25
|
+
});
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
latest.current = {
|
|
28
|
+
behavior,
|
|
29
|
+
enabled,
|
|
30
|
+
keyboardVerticalOffset,
|
|
31
|
+
onLayout
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
const [handlers] = useState(() => {
|
|
35
|
+
const relativeKeyboardHeight = (keyboardFrame) => {
|
|
36
|
+
const layout = frame.current;
|
|
37
|
+
if (layout === null) return 0;
|
|
38
|
+
const keyboardY = keyboardFrame.screenY - latest.current.keyboardVerticalOffset;
|
|
39
|
+
if (latest.current.behavior === "height") return Math.max(shownBottom.current + layout.y + layout.height - keyboardY, 0);
|
|
40
|
+
return Math.max(layout.y + layout.height - keyboardY, 0);
|
|
41
|
+
};
|
|
42
|
+
const update = () => {
|
|
43
|
+
const event = keyboard.current;
|
|
44
|
+
const next = event === null ? 0 : relativeKeyboardHeight(event.endCoordinates);
|
|
45
|
+
if (event !== null && latestBottom.current === next) return;
|
|
46
|
+
latestBottom.current = next;
|
|
47
|
+
if (latest.current.enabled) {
|
|
48
|
+
shownBottom.current = next;
|
|
49
|
+
setBottom(next);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const handleLayout = (event) => {
|
|
53
|
+
const old = frame.current;
|
|
54
|
+
frame.current = event.nativeEvent.layout;
|
|
55
|
+
if (initialHeight.current === 0) {
|
|
56
|
+
initialHeight.current = frame.current.height;
|
|
57
|
+
setInitialFrameHeight(frame.current.height);
|
|
58
|
+
}
|
|
59
|
+
if (old === null || old.height !== frame.current.height) update();
|
|
60
|
+
latest.current.onLayout?.(event);
|
|
61
|
+
};
|
|
62
|
+
return {
|
|
63
|
+
update,
|
|
64
|
+
handleLayout
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
const { update } = handlers;
|
|
69
|
+
if (!Keyboard.isVisible()) {
|
|
70
|
+
keyboard.current = null;
|
|
71
|
+
update();
|
|
72
|
+
}
|
|
73
|
+
const subscriptions = [Keyboard.addListener("keyboardDidHide", () => {
|
|
74
|
+
keyboard.current = null;
|
|
75
|
+
update();
|
|
76
|
+
}), Keyboard.addListener("keyboardDidShow", (event) => {
|
|
77
|
+
keyboard.current = event;
|
|
78
|
+
update();
|
|
79
|
+
})];
|
|
80
|
+
return () => {
|
|
81
|
+
for (const subscription of subscriptions) subscription.remove();
|
|
82
|
+
};
|
|
83
|
+
}, [handlers]);
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
if (enabled && shownBottom.current !== latestBottom.current) {
|
|
86
|
+
shownBottom.current = latestBottom.current;
|
|
87
|
+
setBottom(latestBottom.current);
|
|
88
|
+
}
|
|
89
|
+
}, [enabled]);
|
|
90
|
+
const bottomHeight = enabled ? bottom : 0;
|
|
91
|
+
const outerStyle = useMemo(() => {
|
|
92
|
+
if (behavior === "padding") return [style, { paddingBottom: bottomHeight }];
|
|
93
|
+
if (behavior === "height" && bottom > 0) return [style, {
|
|
94
|
+
height: initialFrameHeight - bottomHeight,
|
|
95
|
+
flex: 0
|
|
96
|
+
}];
|
|
97
|
+
return style;
|
|
98
|
+
}, [
|
|
99
|
+
behavior,
|
|
100
|
+
bottom,
|
|
101
|
+
bottomHeight,
|
|
102
|
+
initialFrameHeight,
|
|
103
|
+
style
|
|
104
|
+
]);
|
|
105
|
+
const innerStyle = useMemo(() => [contentContainerStyle, { bottom: bottomHeight }], [contentContainerStyle, bottomHeight]);
|
|
106
|
+
return /* @__PURE__ */ jsx(View, {
|
|
107
|
+
...rest,
|
|
108
|
+
style: outerStyle,
|
|
109
|
+
onLayout: handlers.handleLayout,
|
|
110
|
+
children: behavior === "position" ? /* @__PURE__ */ jsx(View, {
|
|
111
|
+
style: innerStyle,
|
|
112
|
+
children
|
|
113
|
+
}) : children
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
export { KeyboardAvoidingView };
|
|
117
|
+
|
|
118
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/KeyboardAvoidingView/index.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef, useState, type ReactElement } from 'react'\n\nimport { Keyboard, type KeyboardEvent, type KeyboardMetrics } from '../../apis/Keyboard'\nimport { View } from '../View'\nimport type { LayoutChangeEvent, LayoutRectangle } from '../View/types'\nimport type { KeyboardAvoidingViewProps } from './types'\n\nexport type { KeyboardAvoidingViewInstance, KeyboardAvoidingViewProps } from './types'\n\n/**\n * A view that moves out of the way of the keyboard, with the math of React Native 0.88. As on\n * native, the frame of the view comes from `onLayout`, so its `y` is relative to its parent.\n * `keyboardVerticalOffset` adds the distance to the top of the window.\n */\nexport function KeyboardAvoidingView(props: KeyboardAvoidingViewProps): ReactElement {\n const {\n behavior,\n children,\n contentContainerStyle,\n enabled = true,\n keyboardVerticalOffset = 0,\n style,\n onLayout,\n ...rest\n } = props\n\n // `bottom` is the value on screen. It changes only while the view is enabled, as on native.\n const [bottom, setBottom] = useState(0)\n const [initialFrameHeight, setInitialFrameHeight] = useState(0)\n\n const frame = useRef<LayoutRectangle | null>(null)\n const keyboard = useRef<KeyboardEvent | null>(null)\n const latestBottom = useRef(0)\n const shownBottom = useRef(0)\n const initialHeight = useRef(0)\n const latest = useRef({ behavior, enabled, keyboardVerticalOffset, onLayout })\n useEffect(() => {\n latest.current = { behavior, enabled, keyboardVerticalOffset, onLayout }\n })\n\n // Made once. They read the latest values from the refs.\n const [handlers] = useState(() => {\n const relativeKeyboardHeight = (keyboardFrame: KeyboardMetrics): number => {\n const layout = frame.current\n if (layout === null) return 0\n const keyboardY = keyboardFrame.screenY - latest.current.keyboardVerticalOffset\n if (latest.current.behavior === 'height') {\n return Math.max(shownBottom.current + layout.y + layout.height - keyboardY, 0)\n }\n // The distance that the view must move so that it no longer overlaps the keyboard.\n return Math.max(layout.y + layout.height - keyboardY, 0)\n }\n\n const update = (): void => {\n const event = keyboard.current\n const next = event === null ? 0 : relativeKeyboardHeight(event.endCoordinates)\n if (event !== null && latestBottom.current === next) return\n latestBottom.current = next\n if (latest.current.enabled) {\n shownBottom.current = next\n setBottom(next)\n }\n }\n\n const handleLayout = (event: LayoutChangeEvent): void => {\n const old = frame.current\n frame.current = event.nativeEvent.layout\n if (initialHeight.current === 0) {\n // The height before the keyboard shows.\n initialHeight.current = frame.current.height\n setInitialFrameHeight(frame.current.height)\n }\n if (old === null || old.height !== frame.current.height) update()\n latest.current.onLayout?.(event)\n }\n\n return { update, handleLayout }\n })\n\n useEffect(() => {\n const { update } = handlers\n if (!Keyboard.isVisible()) {\n keyboard.current = null\n update()\n }\n const subscriptions = [\n Keyboard.addListener('keyboardDidHide', () => {\n keyboard.current = null\n update()\n }),\n Keyboard.addListener('keyboardDidShow', (event) => {\n keyboard.current = event\n update()\n }),\n ]\n return () => {\n for (const subscription of subscriptions) subscription.remove()\n }\n }, [handlers])\n\n // A view that is enabled again shows the latest value.\n useEffect(() => {\n if (enabled && shownBottom.current !== latestBottom.current) {\n shownBottom.current = latestBottom.current\n setBottom(latestBottom.current)\n }\n }, [enabled])\n\n const bottomHeight = enabled ? bottom : 0\n const outerStyle = useMemo(() => {\n if (behavior === 'padding') return [style, { paddingBottom: bottomHeight }]\n // A height change applies only while the keyboard shows, so the view gets its height back.\n // A fixed height needs `flex: 0`.\n if (behavior === 'height' && bottom > 0) {\n return [style, { height: initialFrameHeight - bottomHeight, flex: 0 }]\n }\n return style\n }, [behavior, bottom, bottomHeight, initialFrameHeight, style])\n const innerStyle = useMemo(\n () => [contentContainerStyle, { bottom: bottomHeight }],\n [contentContainerStyle, bottomHeight],\n )\n return (\n <View {...rest} style={outerStyle} onLayout={handlers.handleLayout}>\n {behavior === 'position' ? <View style={innerStyle}>{children}</View> : children}\n </View>\n )\n}\n"],"mappings":";;;;;;;;;;AAcA,SAAgB,qBAAqB,OAAgD;CACnF,MAAM,EACJ,UACA,UACA,uBACA,UAAU,MACV,yBAAyB,GACzB,OACA,UACA,GAAG,SACD;CAGJ,MAAM,CAAC,QAAQ,aAAa,SAAS,CAAC;CACtC,MAAM,CAAC,oBAAoB,yBAAyB,SAAS,CAAC;CAE9D,MAAM,QAAQ,OAA+B,IAAI;CACjD,MAAM,WAAW,OAA6B,IAAI;CAClD,MAAM,eAAe,OAAO,CAAC;CAC7B,MAAM,cAAc,OAAO,CAAC;CAC5B,MAAM,gBAAgB,OAAO,CAAC;CAC9B,MAAM,SAAS,OAAO;EAAE;EAAU;EAAS;EAAwB;CAAS,CAAC;CAC7E,gBAAgB;EACd,OAAO,UAAU;GAAE;GAAU;GAAS;GAAwB;EAAS;CACzE,CAAC;CAGD,MAAM,CAAC,YAAY,eAAe;EAChC,MAAM,0BAA0B,kBAA2C;GACzE,MAAM,SAAS,MAAM;GACrB,IAAI,WAAW,MAAM,OAAO;GAC5B,MAAM,YAAY,cAAc,UAAU,OAAO,QAAQ;GACzD,IAAI,OAAO,QAAQ,aAAa,UAC9B,OAAO,KAAK,IAAI,YAAY,UAAU,OAAO,IAAI,OAAO,SAAS,WAAW,CAAC;GAG/E,OAAO,KAAK,IAAI,OAAO,IAAI,OAAO,SAAS,WAAW,CAAC;EACzD;EAEA,MAAM,eAAqB;GACzB,MAAM,QAAQ,SAAS;GACvB,MAAM,OAAO,UAAU,OAAO,IAAI,uBAAuB,MAAM,cAAc;GAC7E,IAAI,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;EAAoB;CAAK,CAAC;CAC9D,MAAM,aAAa,cACX,CAAC,uBAAuB,EAAE,QAAQ,aAAa,CAAC,GACtD,CAAC,uBAAuB,YAAY,CACtC;CACA,OACE,oBAAC,MAAD;EAAM,GAAI;EAAM,OAAO;EAAY,UAAU,SAAS;EACnD,UAAA,aAAa,aAAa,oBAAC,MAAD;GAAM,OAAO;GAAa;EAAe,CAAA,IAAI;CACpE,CAAA;AAEV"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HostInstance, ViewProps } from "../View/types.js";
|
|
2
|
+
export interface KeyboardAvoidingViewProps extends ViewProps {
|
|
3
|
+
/** How the view moves out of the way of the keyboard. With no value, it doesn't. */
|
|
4
|
+
behavior?: "height" | "position" | "padding" | undefined;
|
|
5
|
+
/** The style of the inner view, with the `position` behavior. */
|
|
6
|
+
contentContainerStyle?: ViewProps["style"];
|
|
7
|
+
/** `false` stops the view from moving. Defaults to `true`. */
|
|
8
|
+
enabled?: boolean | undefined;
|
|
9
|
+
/** The distance between the top of the window and the top of the view. Defaults to 0. */
|
|
10
|
+
keyboardVerticalOffset?: number | undefined;
|
|
11
|
+
}
|
|
12
|
+
/** The element of the outer view. */
|
|
13
|
+
export type KeyboardAvoidingViewInstance = HostInstance;
|
|
14
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ModalEvent, ModalOrientationChangeEvent, ModalProps } from "./types.js";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* React Native's `Modal` on a `<dialog>` in the top layer. `showModal()` makes the rest of the
|
|
5
|
+
* page inert, keeps the focus inside, and turns Escape into `onRequestClose`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function Modal(props: ModalProps): ReactElement | null;
|
|
8
|
+
export type { ModalEvent, ModalOrientationChangeEvent, ModalProps };
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { Platform } from "../../apis/Platform/index.js";
|
|
2
|
+
import { StyleSheet } from "../../apis/StyleSheet/index.js";
|
|
3
|
+
import { claimPress } from "../../events/press/Pressability.js";
|
|
4
|
+
import { toDOMProps } from "../../render/domProps.js";
|
|
5
|
+
import { useStyleRegistry } from "../../style/StyleRegistryContext.js";
|
|
6
|
+
import { lockScroll, unlockScroll } from "../../utils/scrollLock.js";
|
|
7
|
+
import { View } from "../View/index.js";
|
|
8
|
+
import { createContext, useCallback, useContext, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
import { createPortal } from "react-dom";
|
|
11
|
+
// src/components/Modal/index.tsx
|
|
12
|
+
const MODAL_CLASS = "rn-modal";
|
|
13
|
+
const RULES = [
|
|
14
|
+
`.${MODAL_CLASS}{position:fixed;inset:0;z-index:2147483647;box-sizing:border-box;width:100%;height:100%;max-width:none;max-height:none;margin:0;padding:0;border:0;background:transparent;color:inherit;overflow:hidden}`,
|
|
15
|
+
`.${MODAL_CLASS}[open]{display:flex;flex-direction:column}`,
|
|
16
|
+
`.${MODAL_CLASS}:not([open]){display:none}`,
|
|
17
|
+
`.${MODAL_CLASS}:focus{outline:none}`,
|
|
18
|
+
`.${MODAL_CLASS}[data-closing]{pointer-events:none}`,
|
|
19
|
+
`@supports selector(::backdrop){.${MODAL_CLASS}::backdrop{background:transparent}}`
|
|
20
|
+
];
|
|
21
|
+
const DURATION_MS = 200;
|
|
22
|
+
const motions = {
|
|
23
|
+
slide: {
|
|
24
|
+
property: "transform",
|
|
25
|
+
hidden: "translateY(100%)",
|
|
26
|
+
shown: "translateY(0)",
|
|
27
|
+
easing: "cubic-bezier(0.37, 0, 0.63, 1)"
|
|
28
|
+
},
|
|
29
|
+
fade: {
|
|
30
|
+
property: "opacity",
|
|
31
|
+
hidden: "0",
|
|
32
|
+
shown: "1",
|
|
33
|
+
easing: "cubic-bezier(0.333, 0, 0.667, 0.333)"
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const motionOf = (type) => type === "slide" || type === "fade" ? Platform.isDisableAnimations ? null : motions[type] : null;
|
|
37
|
+
const animate = (element, motion, to, running) => {
|
|
38
|
+
const from = running === null ? motion[to === "shown" ? "hidden" : "shown"] : getComputedStyle(element)[motion.property];
|
|
39
|
+
running?.cancel();
|
|
40
|
+
return element.animate([{ [motion.property]: from }, { [motion.property]: motion[to] }], {
|
|
41
|
+
duration: DURATION_MS,
|
|
42
|
+
easing: motion.easing,
|
|
43
|
+
fill: to === "hidden" ? "forwards" : "none"
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
const HostContext = createContext(null);
|
|
47
|
+
const createHost = () => {
|
|
48
|
+
const children = /* @__PURE__ */ new Set();
|
|
49
|
+
let shown = false;
|
|
50
|
+
return {
|
|
51
|
+
add: (child) => {
|
|
52
|
+
children.add(child);
|
|
53
|
+
if (shown) child.show();
|
|
54
|
+
return () => {
|
|
55
|
+
children.delete(child);
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
showChildren: () => {
|
|
59
|
+
shown = true;
|
|
60
|
+
for (const child of children) child.show();
|
|
61
|
+
},
|
|
62
|
+
hideChildren: () => {
|
|
63
|
+
shown = false;
|
|
64
|
+
const list = Array.from(children);
|
|
65
|
+
for (let index = list.length - 1; index >= 0; index--) list[index]?.hide();
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
const subscribeNothing = () => () => {};
|
|
70
|
+
const useIsClient = () => useSyncExternalStore(subscribeNothing, () => true, () => false);
|
|
71
|
+
/**
|
|
72
|
+
* React Native's `Modal` on a `<dialog>` in the top layer. `showModal()` makes the rest of the
|
|
73
|
+
* page inert, keeps the focus inside, and turns Escape into `onRequestClose`.
|
|
74
|
+
*/
|
|
75
|
+
function Modal(props) {
|
|
76
|
+
const { visible = true, onDismiss, animationType } = props;
|
|
77
|
+
const shown = useIsClient() && visible;
|
|
78
|
+
const [exiting, setExiting] = useState(false);
|
|
79
|
+
const [lastShown, setLastShown] = useState(shown);
|
|
80
|
+
if (lastShown !== shown) {
|
|
81
|
+
setLastShown(shown);
|
|
82
|
+
setExiting(!shown && animationType != null && animationType !== "none");
|
|
83
|
+
}
|
|
84
|
+
const mounted = shown || exiting;
|
|
85
|
+
const onExited = useCallback(() => setExiting(false), []);
|
|
86
|
+
const dismiss = useRef(onDismiss);
|
|
87
|
+
const wasMounted = useRef(false);
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
dismiss.current = onDismiss;
|
|
90
|
+
});
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
if (wasMounted.current && !mounted) dismiss.current?.();
|
|
93
|
+
wasMounted.current = mounted;
|
|
94
|
+
}, [mounted]);
|
|
95
|
+
return mounted ? createPortal(/* @__PURE__ */ jsx(ModalDialog, {
|
|
96
|
+
...props,
|
|
97
|
+
closing: !shown,
|
|
98
|
+
onExited
|
|
99
|
+
}), document.body) : null;
|
|
100
|
+
}
|
|
101
|
+
function ModalDialog(props) {
|
|
102
|
+
const { children, style, transparent, backdropColor, onRequestClose, onShow, ref, modalRef, animationType, closing, onExited, visible: _visible, onDismiss: _onDismiss, allowSwipeDismissal: _allowSwipeDismissal, hardwareAccelerated: _hardwareAccelerated, navigationBarTranslucent: _navigationBarTranslucent, onOrientationChange: _onOrientationChange, presentationStyle: _presentationStyle, statusBarTranslucent: _statusBarTranslucent, supportedOrientations: _supportedOrientations, ...rest } = props;
|
|
103
|
+
const className = useStyleRegistry().staticClass(MODAL_CLASS, RULES);
|
|
104
|
+
const dialog = useRef(null);
|
|
105
|
+
const open = useRef(false);
|
|
106
|
+
const announced = useRef(false);
|
|
107
|
+
const parent = useContext(HostContext);
|
|
108
|
+
const [host] = useState(createHost);
|
|
109
|
+
const animation = useRef(null);
|
|
110
|
+
const latest = useRef({
|
|
111
|
+
onRequestClose,
|
|
112
|
+
onShow,
|
|
113
|
+
onExited,
|
|
114
|
+
animationType
|
|
115
|
+
});
|
|
116
|
+
useLayoutEffect(() => {
|
|
117
|
+
latest.current = {
|
|
118
|
+
onRequestClose,
|
|
119
|
+
onShow,
|
|
120
|
+
onExited,
|
|
121
|
+
animationType
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
useImperativeHandle(ref, () => dialog.current, []);
|
|
125
|
+
useImperativeHandle(modalRef, () => dialog.current, []);
|
|
126
|
+
useLayoutEffect(() => {
|
|
127
|
+
const element = dialog.current;
|
|
128
|
+
if (element === null) return;
|
|
129
|
+
const modal = typeof element.showModal === "function";
|
|
130
|
+
let focused = null;
|
|
131
|
+
const layer = {
|
|
132
|
+
show: () => {
|
|
133
|
+
if (open.current) return;
|
|
134
|
+
open.current = true;
|
|
135
|
+
if (modal) element.showModal();
|
|
136
|
+
else {
|
|
137
|
+
focused = document.activeElement;
|
|
138
|
+
element.setAttribute("open", "");
|
|
139
|
+
element.tabIndex = -1;
|
|
140
|
+
element.focus();
|
|
141
|
+
}
|
|
142
|
+
lockScroll();
|
|
143
|
+
host.showChildren();
|
|
144
|
+
const announce = () => {
|
|
145
|
+
if (announced.current) return;
|
|
146
|
+
announced.current = true;
|
|
147
|
+
latest.current.onShow?.({ nativeEvent: null });
|
|
148
|
+
};
|
|
149
|
+
const motion = motionOf(latest.current.animationType);
|
|
150
|
+
if (motion === null || typeof element.animate !== "function") {
|
|
151
|
+
announce();
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const next = animate(element, motion, "shown", null);
|
|
155
|
+
animation.current = next;
|
|
156
|
+
next.onfinish = () => {
|
|
157
|
+
if (animation.current !== next) return;
|
|
158
|
+
animation.current = null;
|
|
159
|
+
announce();
|
|
160
|
+
};
|
|
161
|
+
},
|
|
162
|
+
hide: () => {
|
|
163
|
+
if (!open.current) return;
|
|
164
|
+
open.current = false;
|
|
165
|
+
animation.current?.cancel();
|
|
166
|
+
animation.current = null;
|
|
167
|
+
host.hideChildren();
|
|
168
|
+
if (modal) element.close();
|
|
169
|
+
else {
|
|
170
|
+
element.removeAttribute("open");
|
|
171
|
+
if (focused instanceof HTMLElement && focused.isConnected) focused.focus();
|
|
172
|
+
}
|
|
173
|
+
unlockScroll();
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
let remove;
|
|
177
|
+
if (parent === null) layer.show();
|
|
178
|
+
else remove = parent.add(layer);
|
|
179
|
+
return () => {
|
|
180
|
+
remove?.();
|
|
181
|
+
layer.hide();
|
|
182
|
+
};
|
|
183
|
+
}, [host, parent]);
|
|
184
|
+
const wasClosing = useRef(false);
|
|
185
|
+
useLayoutEffect(() => {
|
|
186
|
+
const element = dialog.current;
|
|
187
|
+
if (element === null || closing === wasClosing.current) return;
|
|
188
|
+
wasClosing.current = closing;
|
|
189
|
+
const motion = motionOf(latest.current.animationType);
|
|
190
|
+
const canAnimate = motion !== null && typeof element.animate === "function";
|
|
191
|
+
if (closing) {
|
|
192
|
+
host.hideChildren();
|
|
193
|
+
if (!canAnimate) {
|
|
194
|
+
latest.current.onExited();
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const next = animate(element, motion, "hidden", animation.current);
|
|
198
|
+
animation.current = next;
|
|
199
|
+
next.onfinish = () => {
|
|
200
|
+
if (animation.current === next) latest.current.onExited();
|
|
201
|
+
};
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
host.showChildren();
|
|
205
|
+
if (!canAnimate || animation.current === null) return;
|
|
206
|
+
const next = animate(element, motion, "shown", animation.current);
|
|
207
|
+
animation.current = next;
|
|
208
|
+
next.onfinish = () => {
|
|
209
|
+
if (animation.current === next) animation.current = null;
|
|
210
|
+
};
|
|
211
|
+
}, [closing, host]);
|
|
212
|
+
const requestClose = () => {
|
|
213
|
+
latest.current.onRequestClose?.({ nativeEvent: null });
|
|
214
|
+
};
|
|
215
|
+
const handleCancel = (event) => {
|
|
216
|
+
if (event.target !== event.currentTarget) return;
|
|
217
|
+
event.preventDefault();
|
|
218
|
+
if (!closing) requestClose();
|
|
219
|
+
};
|
|
220
|
+
const handleClose = (event) => {
|
|
221
|
+
const element = event.currentTarget;
|
|
222
|
+
if (event.target === element && open.current && !element.open) element.showModal();
|
|
223
|
+
};
|
|
224
|
+
const domProps = toDOMProps(rest);
|
|
225
|
+
const appPointerDown = domProps["onPointerDown"];
|
|
226
|
+
const appClick = domProps["onClick"];
|
|
227
|
+
const appKeyDown = domProps["onKeyDown"];
|
|
228
|
+
const containerStyle = transparent ? styles.transparent : backdropColor != null ? { backgroundColor: backdropColor } : void 0;
|
|
229
|
+
return /* @__PURE__ */ jsx("dialog", {
|
|
230
|
+
...domProps,
|
|
231
|
+
ref: dialog,
|
|
232
|
+
className,
|
|
233
|
+
"data-closing": closing ? "" : void 0,
|
|
234
|
+
onCancel: handleCancel,
|
|
235
|
+
onClose: handleClose,
|
|
236
|
+
onPointerDown: (event) => {
|
|
237
|
+
appPointerDown?.(event);
|
|
238
|
+
claimPress(event.nativeEvent);
|
|
239
|
+
},
|
|
240
|
+
onClick: (event) => {
|
|
241
|
+
appClick?.(event);
|
|
242
|
+
claimPress(event.nativeEvent);
|
|
243
|
+
},
|
|
244
|
+
onKeyDown: (event) => {
|
|
245
|
+
appKeyDown?.(event);
|
|
246
|
+
const element = event.currentTarget;
|
|
247
|
+
if (event.key === "Escape" && typeof element.showModal !== "function" && event.target.closest("dialog") === element) requestClose();
|
|
248
|
+
},
|
|
249
|
+
children: /* @__PURE__ */ jsx(HostContext.Provider, {
|
|
250
|
+
value: host,
|
|
251
|
+
children: /* @__PURE__ */ jsx(View, {
|
|
252
|
+
style: [
|
|
253
|
+
styles.container,
|
|
254
|
+
style,
|
|
255
|
+
containerStyle
|
|
256
|
+
],
|
|
257
|
+
children
|
|
258
|
+
})
|
|
259
|
+
})
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
const styles = StyleSheet.create({
|
|
263
|
+
container: {
|
|
264
|
+
flex: 1,
|
|
265
|
+
backgroundColor: "white"
|
|
266
|
+
},
|
|
267
|
+
transparent: { backgroundColor: "transparent" }
|
|
268
|
+
});
|
|
269
|
+
export { Modal };
|
|
270
|
+
|
|
271
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Modal/index.tsx"],"sourcesContent":["import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useRef,\n useState,\n useSyncExternalStore,\n type KeyboardEvent,\n type MouseEvent,\n type PointerEvent,\n type ReactElement,\n type SyntheticEvent,\n} from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { Platform } from '../../apis/Platform'\nimport { StyleSheet } from '../../apis/StyleSheet'\nimport { claimPress } from '../../events/press/Pressability'\nimport { toDOMProps } from '../../render/domProps'\nimport { useStyleRegistry } from '../../style/StyleRegistryContext'\nimport { lockScroll, unlockScroll } from '../../utils/scrollLock'\nimport { View } from '../View'\nimport type { ModalProps } from './types'\n\nexport type { ModalEvent, ModalOrientationChangeEvent, ModalProps } from './types'\n\nconst MODAL_CLASS = 'rn-modal'\n// The dialog fills the viewport, and the content box fills the dialog. The z-index matters only\n// where the browser has no top layer.\nconst RULES = [\n `.${MODAL_CLASS}{position:fixed;inset:0;z-index:2147483647;box-sizing:border-box;width:100%;height:100%;max-width:none;max-height:none;margin:0;padding:0;border:0;background:transparent;color:inherit;overflow:hidden}`,\n `.${MODAL_CLASS}[open]{display:flex;flex-direction:column}`,\n `.${MODAL_CLASS}:not([open]){display:none}`,\n `.${MODAL_CLASS}:focus{outline:none}`,\n // A modal on its way out takes no more presses.\n `.${MODAL_CLASS}[data-closing]{pointer-events:none}`,\n // A browser without `::backdrop` drops the inner rule, where `insertRule` would throw.\n `@supports selector(::backdrop){.${MODAL_CLASS}::backdrop{background:transparent}}`,\n]\n\n// The window animations of React Native's Android modal: 200 ms (`config_shortAnimTime`). `slide`\n// uses the default AccelerateDecelerateInterpolator, (1 - cos(πt)) / 2, and `fade` the\n// AccelerateInterpolator, t², which this Bézier draws exactly.\nconst DURATION_MS = 200\ntype Motion = { property: 'transform' | 'opacity'; hidden: string; shown: string; easing: string }\nconst motions: Record<'slide' | 'fade', Motion> = {\n slide: {\n property: 'transform',\n hidden: 'translateY(100%)',\n shown: 'translateY(0)',\n easing: 'cubic-bezier(0.37, 0, 0.63, 1)',\n },\n fade: {\n property: 'opacity',\n hidden: '0',\n shown: '1',\n easing: 'cubic-bezier(0.333, 0, 0.667, 0.333)',\n },\n}\n\nconst motionOf = (type: ModalProps['animationType']): Motion | null =>\n type === 'slide' || type === 'fade' ? (Platform.isDisableAnimations ? null : motions[type]) : null\n\n// Runs from the end opposite `to`, or from where a running animation is, so a turn doesn't jump.\n// The way out holds its last frame until the dialog closes.\nconst animate = (\n element: HTMLElement,\n motion: Motion,\n to: 'shown' | 'hidden',\n running: Animation | null,\n): Animation => {\n const from =\n running === null\n ? motion[to === 'shown' ? 'hidden' : 'shown']\n : getComputedStyle(element)[motion.property]\n running?.cancel()\n return element.animate([{ [motion.property]: from }, { [motion.property]: motion[to] }], {\n duration: DURATION_MS,\n easing: motion.easing,\n fill: to === 'hidden' ? 'forwards' : 'none',\n })\n}\n\n// A nested modal shows after its parent, so it's on top, and hides before it.\ntype Layer = { show: () => void; hide: () => void }\ntype Host = { add: (child: Layer) => () => void }\nconst HostContext = createContext<Host | null>(null)\n\nconst createHost = (): Host & { showChildren: () => void; hideChildren: () => void } => {\n const children = new Set<Layer>()\n let shown = false\n return {\n add: (child) => {\n children.add(child)\n if (shown) child.show()\n return () => {\n children.delete(child)\n }\n },\n showChildren: () => {\n shown = true\n for (const child of children) child.show()\n },\n hideChildren: () => {\n shown = false\n // Last shown, first hidden. No `toReversed()`: Chrome 95 and Safari 15.1 don't have it.\n const list = Array.from(children)\n for (let index = list.length - 1; index >= 0; index--) list[index]?.hide()\n },\n }\n}\n\nconst subscribeNothing = (): (() => void) => () => {}\n// `false` on the server and in the hydration render, so the markup matches, then `true`.\nconst useIsClient = (): boolean =>\n useSyncExternalStore(\n subscribeNothing,\n () => true,\n () => false,\n )\n\n/**\n * React Native's `Modal` on a `<dialog>` in the top layer. `showModal()` makes the rest of the\n * page inert, keeps the focus inside, and turns Escape into `onRequestClose`.\n */\nexport function Modal(props: ModalProps): ReactElement | null {\n const { visible = true, onDismiss, animationType } = props\n const shown = useIsClient() && visible\n\n // The dialog stays while its exit animation runs, as on iOS.\n const [exiting, setExiting] = useState(false)\n const [lastShown, setLastShown] = useState(shown)\n if (lastShown !== shown) {\n setLastShown(shown)\n setExiting(!shown && animationType != null && animationType !== 'none')\n }\n const mounted = shown || exiting\n const onExited = useCallback(() => setExiting(false), [])\n\n const dismiss = useRef(onDismiss)\n const wasMounted = useRef(false)\n useEffect(() => {\n dismiss.current = onDismiss\n })\n useEffect(() => {\n if (wasMounted.current && !mounted) dismiss.current?.()\n wasMounted.current = mounted\n }, [mounted])\n\n return mounted\n ? createPortal(<ModalDialog {...props} closing={!shown} onExited={onExited} />, document.body)\n : null\n}\n\ntype DialogProps = ModalProps & {\n // `visible` became `false`, and the exit animation runs.\n closing: boolean\n onExited: () => void\n}\n\nfunction ModalDialog(props: DialogProps): ReactElement {\n const {\n children,\n style,\n transparent,\n backdropColor,\n onRequestClose,\n onShow,\n ref,\n modalRef,\n animationType,\n closing,\n onExited,\n // Read by Modal.\n visible: _visible,\n onDismiss: _onDismiss,\n // Native only.\n allowSwipeDismissal: _allowSwipeDismissal,\n hardwareAccelerated: _hardwareAccelerated,\n navigationBarTranslucent: _navigationBarTranslucent,\n onOrientationChange: _onOrientationChange,\n presentationStyle: _presentationStyle,\n statusBarTranslucent: _statusBarTranslucent,\n supportedOrientations: _supportedOrientations,\n ...rest\n } = props\n\n const registry = useStyleRegistry()\n const className = registry.staticClass(MODAL_CLASS, RULES)\n const dialog = useRef<HTMLDialogElement>(null)\n const open = useRef(false)\n // Once per show, also when StrictMode runs the effect twice.\n const announced = useRef(false)\n const parent = useContext(HostContext)\n const [host] = useState(createHost)\n\n const animation = useRef<Animation | null>(null)\n const latest = useRef({ onRequestClose, onShow, onExited, animationType })\n useLayoutEffect(() => {\n latest.current = { onRequestClose, onShow, onExited, animationType }\n })\n\n useImperativeHandle(ref, () => dialog.current as HTMLDialogElement, [])\n useImperativeHandle(modalRef, () => dialog.current as HTMLDialogElement, [])\n\n useLayoutEffect(() => {\n const element = dialog.current\n if (element === null) return\n // Firefox before 98 and Safari before 15.4 have no `showModal()`. There the dialog is a fixed\n // box on top, with the focus moved in and out, and no trap.\n const modal = typeof element.showModal === 'function'\n let focused: Element | null = null\n\n const layer: Layer = {\n show: () => {\n if (open.current) return\n open.current = true\n if (modal) element.showModal()\n else {\n focused = document.activeElement\n element.setAttribute('open', '')\n element.tabIndex = -1\n element.focus()\n }\n lockScroll()\n host.showChildren()\n const announce = (): void => {\n if (announced.current) return\n announced.current = true\n latest.current.onShow?.({ nativeEvent: null })\n }\n const motion = motionOf(latest.current.animationType)\n if (motion === null || typeof element.animate !== 'function') {\n announce()\n return\n }\n const next = animate(element, motion, 'shown', null)\n animation.current = next\n // As on iOS, onShow fires once the modal is in place.\n next.onfinish = () => {\n if (animation.current !== next) return\n animation.current = null\n announce()\n }\n },\n hide: () => {\n if (!open.current) return\n open.current = false\n animation.current?.cancel()\n animation.current = null\n host.hideChildren()\n // The browser gives the focus back to the element that had it before `showModal()`.\n if (modal) element.close()\n else {\n element.removeAttribute('open')\n if (focused instanceof HTMLElement && focused.isConnected) focused.focus()\n }\n unlockScroll()\n },\n }\n\n let remove: (() => void) | undefined\n if (parent === null) layer.show()\n else remove = parent.add(layer)\n return () => {\n remove?.()\n layer.hide()\n }\n }, [host, parent])\n\n // The exit animation when `visible` becomes `false`, and the way back when it turns `true` again\n // before the exit ends.\n const wasClosing = useRef(false)\n useLayoutEffect(() => {\n const element = dialog.current\n if (element === null || closing === wasClosing.current) return\n wasClosing.current = closing\n const motion = motionOf(latest.current.animationType)\n const canAnimate = motion !== null && typeof element.animate === 'function'\n if (closing) {\n // A nested modal goes at once.\n host.hideChildren()\n if (!canAnimate) {\n latest.current.onExited()\n return\n }\n const next = animate(element, motion, 'hidden', animation.current)\n animation.current = next\n next.onfinish = () => {\n if (animation.current === next) latest.current.onExited()\n }\n return\n }\n host.showChildren()\n if (!canAnimate || animation.current === null) return\n const next = animate(element, motion, 'shown', animation.current)\n animation.current = next\n next.onfinish = () => {\n if (animation.current === next) animation.current = null\n }\n }, [closing, host])\n\n const requestClose = (): void => {\n latest.current.onRequestClose?.({ nativeEvent: null })\n }\n\n // React passes the events of a nested dialog up through the portal, so each dialog handles only\n // its own. `visible` decides, so the dialog doesn't close itself.\n const handleCancel = (event: SyntheticEvent<HTMLDialogElement>): void => {\n if (event.target !== event.currentTarget) return\n event.preventDefault()\n if (!closing) requestClose()\n }\n\n // Chrome closes a dialog anyway on a second Escape with no other input between. The app still\n // shows the modal, so it opens again.\n const handleClose = (event: SyntheticEvent<HTMLDialogElement>): void => {\n const element = event.currentTarget\n if (event.target === element && open.current && !element.open) element.showModal()\n }\n\n const domProps = toDOMProps(rest)\n const appPointerDown = domProps['onPointerDown'] as ((event: PointerEvent) => void) | undefined\n const appClick = domProps['onClick'] as ((event: MouseEvent) => void) | undefined\n const appKeyDown = domProps['onKeyDown'] as ((event: KeyboardEvent) => void) | undefined\n\n const containerStyle = transparent\n ? styles.transparent\n : backdropColor != null\n ? { backgroundColor: backdropColor }\n : undefined\n\n return (\n <dialog\n {...domProps}\n ref={dialog}\n className={className}\n data-closing={closing ? '' : undefined}\n onCancel={handleCancel}\n onClose={handleClose}\n // The presses inside stay inside, as the native host claims the responder.\n onPointerDown={(event) => {\n appPointerDown?.(event)\n claimPress(event.nativeEvent)\n }}\n onClick={(event) => {\n appClick?.(event)\n claimPress(event.nativeEvent)\n }}\n onKeyDown={(event) => {\n appKeyDown?.(event)\n const element = event.currentTarget\n if (\n event.key === 'Escape' &&\n typeof element.showModal !== 'function' &&\n (event.target as Element).closest('dialog') === element\n ) {\n requestClose()\n }\n }}\n >\n <HostContext.Provider value={host}>\n <View style={[styles.container, style, containerStyle]}>{children}</View>\n </HostContext.Provider>\n </dialog>\n )\n}\n\nconst styles = StyleSheet.create({\n container: { flex: 1, backgroundColor: 'white' },\n transparent: { backgroundColor: 'transparent' },\n})\n"],"mappings":";;;;;;;;;;;AA6BA,MAAM,cAAc;AAGpB,MAAM,QAAQ;CACZ,IAAI,YAAY;CAChB,IAAI,YAAY;CAChB,IAAI,YAAY;CAChB,IAAI,YAAY;CAEhB,IAAI,YAAY;CAEhB,mCAAmC,YAAY;AACjD;AAKA,MAAM,cAAc;AAEpB,MAAM,UAA4C;CAChD,OAAO;EACL,UAAU;EACV,QAAQ;EACR,OAAO;EACP,QAAQ;CACV;CACA,MAAM;EACJ,UAAU;EACV,QAAQ;EACR,OAAO;EACP,QAAQ;CACV;AACF;AAEA,MAAM,YAAY,SAChB,SAAS,WAAW,SAAS,SAAU,SAAS,sBAAsB,OAAO,QAAQ,QAAS;AAIhG,MAAM,WACJ,SACA,QACA,IACA,YACc;CACd,MAAM,OACJ,YAAY,OACR,OAAO,OAAO,UAAU,WAAW,WACnC,iBAAiB,OAAO,CAAC,CAAC,OAAO;CACvC,SAAS,OAAO;CAChB,OAAO,QAAQ,QAAQ,CAAC,GAAG,OAAO,WAAW,KAAK,GAAG,GAAG,OAAO,WAAW,OAAO,IAAI,CAAC,GAAG;EACvF,UAAU;EACV,QAAQ,OAAO;EACf,MAAM,OAAO,WAAW,aAAa;CACvC,CAAC;AACH;AAKA,MAAM,cAAc,cAA2B,IAAI;AAEnD,MAAM,mBAAkF;CACtF,MAAM,2BAAW,IAAI,IAAW;CAChC,IAAI,QAAQ;CACZ,OAAO;EACL,MAAM,UAAU;GACd,SAAS,IAAI,KAAK;GAClB,IAAI,OAAO,MAAM,KAAK;GACtB,aAAa;IACX,SAAS,OAAO,KAAK;GACvB;EACF;EACA,oBAAoB;GAClB,QAAQ;GACR,KAAK,MAAM,SAAS,UAAU,MAAM,KAAK;EAC3C;EACA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
|
6
|
+
export type ModalOrientationChangeEvent = {
|
|
7
|
+
nativeEvent: {
|
|
8
|
+
orientation: "portrait" | "landscape";
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export type ModalProps = Omit<ViewProps, "ref"> & {
|
|
12
|
+
ref?: Ref<HTMLDialogElement> | undefined;
|
|
13
|
+
modalRef?: Ref<HTMLDialogElement> | undefined;
|
|
14
|
+
visible?: boolean | undefined;
|
|
15
|
+
transparent?: boolean | undefined;
|
|
16
|
+
backdropColor?: string | undefined;
|
|
17
|
+
animationType?: "none" | "slide" | "fade" | undefined;
|
|
18
|
+
onRequestClose?: ((event: ModalEvent) => void) | undefined;
|
|
19
|
+
onShow?: ((event: ModalEvent) => void) | undefined;
|
|
20
|
+
onDismiss?: (() => void) | undefined;
|
|
21
|
+
allowSwipeDismissal?: boolean | undefined;
|
|
22
|
+
hardwareAccelerated?: boolean | undefined;
|
|
23
|
+
navigationBarTranslucent?: boolean | undefined;
|
|
24
|
+
onOrientationChange?: ((event: ModalOrientationChangeEvent) => void) | undefined;
|
|
25
|
+
presentationStyle?: "fullScreen" | "pageSheet" | "formSheet" | "overFullScreen" | undefined;
|
|
26
|
+
statusBarTranslucent?: boolean | undefined;
|
|
27
|
+
supportedOrientations?: ReadonlyArray<"portrait" | "portrait-upside-down" | "landscape" | "landscape-left" | "landscape-right"> | undefined;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PressableAndroidRippleConfig, PressableInstance, PressableProps, PressableStateCallbackType } from "./types.js";
|
|
2
|
+
import { NamedExoticComponent } from "react";
|
|
3
|
+
export declare const Pressable: NamedExoticComponent<PressableProps>;
|
|
4
|
+
export type { PressableAndroidRippleConfig, PressableInstance, PressableProps, PressableStateCallbackType };
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|