react-native-nitro-modal 0.1.5 → 0.3.0-rc
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 +65 -11
- package/android/src/main/java/com/margelo/nitro/nitromodal/BottomSheetPresenter.kt +335 -34
- package/android/src/main/java/com/margelo/nitro/nitromodal/HybridNitroModal.kt +63 -22
- package/android/src/main/java/com/margelo/nitro/nitromodal/ModalConfig.kt +31 -1
- package/android/src/main/java/com/margelo/nitro/nitromodal/ModalContentRoot.kt +48 -5
- package/android/src/main/java/com/margelo/nitro/nitromodal/ModalPresenter.kt +63 -4
- package/android/src/main/java/com/margelo/nitro/nitromodal/NitroModalHostView.kt +68 -8
- package/ios/HybridNitroModal.swift +111 -20
- package/ios/ModalConfig.swift +44 -2
- package/ios/NitroModalHostView.swift +73 -8
- package/ios/SheetView.swift +575 -0
- package/ios/SheetViewController.swift +19 -450
- package/lib/module/NitroModal.js +39 -7
- package/lib/module/NitroModal.js.map +1 -1
- package/lib/module/NitroModalView.js +4 -3
- package/lib/module/NitroModalView.js.map +1 -1
- package/lib/module/NitroModalView.native.js +3 -0
- package/lib/module/NitroModalView.native.js.map +1 -1
- package/lib/module/NitroModalView.web.js +159 -0
- package/lib/module/NitroModalView.web.js.map +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/web/AnimatedValue.js +126 -0
- package/lib/module/web/AnimatedValue.js.map +1 -0
- package/lib/module/web/ModalConfig.js +30 -0
- package/lib/module/web/ModalConfig.js.map +1 -0
- package/lib/module/web/ModalController.js +306 -0
- package/lib/module/web/ModalController.js.map +1 -0
- package/lib/module/web/ModalPresenter.js +280 -0
- package/lib/module/web/ModalPresenter.js.map +1 -0
- package/lib/module/web/PopupPresenter.js +117 -0
- package/lib/module/web/PopupPresenter.js.map +1 -0
- package/lib/module/web/SheetPresenter.js +494 -0
- package/lib/module/web/SheetPresenter.js.map +1 -0
- package/lib/module/web/dom.js +138 -0
- package/lib/module/web/dom.js.map +1 -0
- package/lib/typescript/src/NitroModal.d.ts +35 -4
- package/lib/typescript/src/NitroModal.d.ts.map +1 -1
- package/lib/typescript/src/NitroModal.nitro.d.ts +29 -2
- package/lib/typescript/src/NitroModal.nitro.d.ts.map +1 -1
- package/lib/typescript/src/NitroModalView.d.ts +2 -1
- package/lib/typescript/src/NitroModalView.d.ts.map +1 -1
- package/lib/typescript/src/NitroModalView.native.d.ts +1 -0
- package/lib/typescript/src/NitroModalView.native.d.ts.map +1 -1
- package/lib/typescript/src/NitroModalView.web.d.ts +6 -0
- package/lib/typescript/src/NitroModalView.web.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/web/AnimatedValue.d.ts +49 -0
- package/lib/typescript/src/web/AnimatedValue.d.ts.map +1 -0
- package/lib/typescript/src/web/ModalConfig.d.ts +30 -0
- package/lib/typescript/src/web/ModalConfig.d.ts.map +1 -0
- package/lib/typescript/src/web/ModalController.d.ts +70 -0
- package/lib/typescript/src/web/ModalController.d.ts.map +1 -0
- package/lib/typescript/src/web/ModalPresenter.d.ts +107 -0
- package/lib/typescript/src/web/ModalPresenter.d.ts.map +1 -0
- package/lib/typescript/src/web/PopupPresenter.d.ts +20 -0
- package/lib/typescript/src/web/PopupPresenter.d.ts.map +1 -0
- package/lib/typescript/src/web/SheetPresenter.d.ts +65 -0
- package/lib/typescript/src/web/SheetPresenter.d.ts.map +1 -0
- package/lib/typescript/src/web/dom.d.ts +42 -0
- package/lib/typescript/src/web/dom.d.ts.map +1 -0
- package/nitrogen/generated/android/c++/JHybridNitroModalSpec.cpp +60 -6
- package/nitrogen/generated/android/c++/JHybridNitroModalSpec.hpp +10 -2
- package/nitrogen/generated/android/c++/JNamedSheetDetent.hpp +64 -0
- package/nitrogen/generated/android/c++/JSheetDetent.cpp +26 -0
- package/nitrogen/generated/android/c++/JSheetDetent.hpp +42 -37
- package/nitrogen/generated/android/c++/views/JHybridNitroModalStateUpdater.cpp +20 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/HybridNitroModalSpec.kt +40 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/NamedSheetDetent.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitromodal/SheetDetent.kt +47 -10
- package/nitrogen/generated/android/nitromodal+autolinking.cmake +1 -0
- package/nitrogen/generated/ios/NitroModal-Swift-Cxx-Bridge.hpp +53 -8
- package/nitrogen/generated/ios/NitroModal-Swift-Cxx-Umbrella.hpp +4 -3
- package/nitrogen/generated/ios/c++/HybridNitroModalSpecSwift.hpp +32 -5
- package/nitrogen/generated/ios/c++/views/HybridNitroModalComponent.mm +24 -0
- package/nitrogen/generated/ios/swift/HybridNitroModalSpec.swift +4 -0
- package/nitrogen/generated/ios/swift/HybridNitroModalSpec_cxx.swift +110 -5
- package/nitrogen/generated/ios/swift/NamedSheetDetent.swift +48 -0
- package/nitrogen/generated/ios/swift/SheetDetent.swift +15 -33
- package/nitrogen/generated/shared/c++/HybridNitroModalSpec.cpp +8 -0
- package/nitrogen/generated/shared/c++/HybridNitroModalSpec.hpp +14 -5
- package/nitrogen/generated/shared/c++/{SheetDetent.hpp → NamedSheetDetent.hpp} +17 -17
- package/nitrogen/generated/shared/c++/views/HybridNitroModalComponent.cpp +9 -1
- package/nitrogen/generated/shared/c++/views/HybridNitroModalComponent.hpp +15 -2
- package/nitrogen/generated/shared/json/NitroModalConfig.json +4 -0
- package/package.json +3 -2
- package/src/NitroModal.nitro.ts +30 -2
- package/src/NitroModal.tsx +71 -8
- package/src/NitroModalView.native.tsx +4 -0
- package/src/NitroModalView.tsx +9 -4
- package/src/NitroModalView.web.tsx +180 -0
- package/src/index.tsx +2 -0
- package/src/web/AnimatedValue.ts +193 -0
- package/src/web/ModalConfig.ts +67 -0
- package/src/web/ModalController.ts +338 -0
- package/src/web/ModalPresenter.ts +333 -0
- package/src/web/PopupPresenter.ts +129 -0
- package/src/web/SheetPresenter.ts +647 -0
- package/src/web/dom.ts +171 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/// <reference lib="dom" />
|
|
4
|
+
|
|
5
|
+
export const ZERO_INSETS = {
|
|
6
|
+
top: 0,
|
|
7
|
+
right: 0,
|
|
8
|
+
bottom: 0,
|
|
9
|
+
left: 0
|
|
10
|
+
};
|
|
11
|
+
export const canUseDOM = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
12
|
+
|
|
13
|
+
/** Converts a color from `processColor` (0xAARRGGBB) to CSS, scaling its alpha by `opacity`. */
|
|
14
|
+
export function toCSSColor(argb, opacity = 1) {
|
|
15
|
+
// As an unsigned 32-bit value, whatever the sign it was passed with.
|
|
16
|
+
const value = (argb % 2 ** 32 + 2 ** 32) % 2 ** 32;
|
|
17
|
+
const channel = shift => Math.floor(value / 2 ** shift) % 256;
|
|
18
|
+
const alpha = channel(24) / 255 * Math.min(Math.max(opacity, 0), 1);
|
|
19
|
+
return `rgba(${channel(16)}, ${channel(8)}, ${channel(0)}, ${Number(alpha.toFixed(3))})`;
|
|
20
|
+
}
|
|
21
|
+
let safeAreaProbe = null;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* `env(safe-area-inset-*)`, read through a hidden probe element. Non-zero on
|
|
25
|
+
* notched devices when the page opts in with `viewport-fit=cover`.
|
|
26
|
+
*/
|
|
27
|
+
export function readSafeAreaInsets() {
|
|
28
|
+
if (!safeAreaProbe?.isConnected) {
|
|
29
|
+
if (!document.body) return ZERO_INSETS;
|
|
30
|
+
const probe = document.createElement('div');
|
|
31
|
+
probe.setAttribute('aria-hidden', 'true');
|
|
32
|
+
probe.style.cssText = 'position:fixed;top:0;left:0;width:0;height:0;visibility:hidden;pointer-events:none;' + 'padding:env(safe-area-inset-top,0px) env(safe-area-inset-right,0px) ' + 'env(safe-area-inset-bottom,0px) env(safe-area-inset-left,0px);';
|
|
33
|
+
document.body.appendChild(probe);
|
|
34
|
+
safeAreaProbe = probe;
|
|
35
|
+
}
|
|
36
|
+
const style = getComputedStyle(safeAreaProbe);
|
|
37
|
+
return {
|
|
38
|
+
top: parseFloat(style.paddingTop) || 0,
|
|
39
|
+
right: parseFloat(style.paddingRight) || 0,
|
|
40
|
+
bottom: parseFloat(style.paddingBottom) || 0,
|
|
41
|
+
left: parseFloat(style.paddingLeft) || 0
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** The part of the safe area insets that `element` overlaps. */
|
|
46
|
+
export function inlineInsets(element) {
|
|
47
|
+
const safeArea = readSafeAreaInsets();
|
|
48
|
+
const rect = element.getBoundingClientRect();
|
|
49
|
+
const clamp = (value, max) => Math.min(Math.max(value, 0), max);
|
|
50
|
+
return {
|
|
51
|
+
top: clamp(safeArea.top - rect.top, rect.height),
|
|
52
|
+
right: clamp(rect.right - (window.innerWidth - safeArea.right), rect.width),
|
|
53
|
+
bottom: clamp(rect.bottom - (window.innerHeight - safeArea.bottom), rect.height),
|
|
54
|
+
left: clamp(safeArea.left - rect.left, rect.width)
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Height of the on-screen keyboard over a layout viewport `layoutHeight` tall.
|
|
60
|
+
* Mobile browsers keep the layout viewport and shrink the visual one.
|
|
61
|
+
*/
|
|
62
|
+
export function readKeyboardHeight(layoutHeight) {
|
|
63
|
+
const visual = window.visualViewport;
|
|
64
|
+
// Pinch zoom shrinks the visual viewport too.
|
|
65
|
+
if (!visual || Math.abs(visual.scale - 1) > 0.01) return 0;
|
|
66
|
+
const covered = layoutHeight - visual.offsetTop - visual.height;
|
|
67
|
+
return covered >= 1 ? Math.round(covered) : 0;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** The size of the viewport before anything is on screen. */
|
|
71
|
+
export function estimateViewport() {
|
|
72
|
+
return {
|
|
73
|
+
width: document.documentElement.clientWidth || window.innerWidth,
|
|
74
|
+
height: window.innerHeight
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function isVerticalScroller(node) {
|
|
78
|
+
if (!(node instanceof HTMLElement) || node.scrollHeight <= node.clientHeight) return false;
|
|
79
|
+
const {
|
|
80
|
+
overflowY
|
|
81
|
+
} = getComputedStyle(node);
|
|
82
|
+
return overflowY === 'auto' || overflowY === 'scroll';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** The innermost element from `target` up to (not including) `root` that scrolls vertically. */
|
|
86
|
+
export function findVerticalScroller(target, root) {
|
|
87
|
+
let node = target instanceof Element ? target : null;
|
|
88
|
+
for (; node && node !== root; node = node.parentElement) {
|
|
89
|
+
if (isVerticalScroller(node)) return node;
|
|
90
|
+
}
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Whether a scroller between `target` and `root` can scroll further by `deltaY`. */
|
|
95
|
+
export function canScrollWithin(target, root, deltaY) {
|
|
96
|
+
let node = target instanceof Element ? target : null;
|
|
97
|
+
for (; node && node !== root; node = node.parentElement) {
|
|
98
|
+
if (!isVerticalScroller(node)) continue;
|
|
99
|
+
const canScroll = deltaY < 0 ? node.scrollTop > 0 : node.scrollTop + node.clientHeight < node.scrollHeight - 1;
|
|
100
|
+
if (canScroll) return true;
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
export function isTextInput(target) {
|
|
105
|
+
return target instanceof Element && target.closest('input, textarea, select, [contenteditable]:not([contenteditable="false"])') != null;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** Swallows the click that follows a mouse drag, so the content under the pointer isn't pressed. */
|
|
109
|
+
export function suppressNextClick() {
|
|
110
|
+
const swallow = event => {
|
|
111
|
+
event.stopPropagation();
|
|
112
|
+
event.preventDefault();
|
|
113
|
+
};
|
|
114
|
+
window.addEventListener('click', swallow, {
|
|
115
|
+
capture: true,
|
|
116
|
+
once: true
|
|
117
|
+
});
|
|
118
|
+
// A click, if any, is dispatched in the same task as the pointerup.
|
|
119
|
+
setTimeout(() => {
|
|
120
|
+
window.removeEventListener('click', swallow, {
|
|
121
|
+
capture: true
|
|
122
|
+
});
|
|
123
|
+
}, 0);
|
|
124
|
+
}
|
|
125
|
+
export function prefersReducedMotion() {
|
|
126
|
+
return typeof window.matchMedia === 'function' && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
127
|
+
}
|
|
128
|
+
let clipValue = null;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* `overflow: clip` rounds the corners without making the element a scroll
|
|
132
|
+
* container, which focusing an input could otherwise scroll.
|
|
133
|
+
*/
|
|
134
|
+
export function clipOverflow() {
|
|
135
|
+
clipValue ??= typeof CSS !== 'undefined' && CSS.supports('overflow', 'clip') ? 'clip' : 'hidden';
|
|
136
|
+
return clipValue;
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=dom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ZERO_INSETS","top","right","bottom","left","canUseDOM","window","document","toCSSColor","argb","opacity","value","channel","shift","Math","floor","alpha","min","max","Number","toFixed","safeAreaProbe","readSafeAreaInsets","isConnected","body","probe","createElement","setAttribute","style","cssText","appendChild","getComputedStyle","parseFloat","paddingTop","paddingRight","paddingBottom","paddingLeft","inlineInsets","element","safeArea","rect","getBoundingClientRect","clamp","height","innerWidth","width","innerHeight","readKeyboardHeight","layoutHeight","visual","visualViewport","abs","scale","covered","offsetTop","round","estimateViewport","documentElement","clientWidth","isVerticalScroller","node","HTMLElement","scrollHeight","clientHeight","overflowY","findVerticalScroller","target","root","Element","parentElement","canScrollWithin","deltaY","canScroll","scrollTop","isTextInput","closest","suppressNextClick","swallow","event","stopPropagation","preventDefault","addEventListener","capture","once","setTimeout","removeEventListener","prefersReducedMotion","matchMedia","matches","clipValue","clipOverflow","CSS","supports"],"sourceRoot":"../../../src","sources":["web/dom.ts"],"mappings":";;AAAA;;AAcA,OAAO,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A,OAAO,SAASI,oBAAoBA,CAAA,EAAY;EAC9C,OACE,OAAOhF,MAAM,CAACiF,UAAU,KAAK,UAAU,IACvCjF,MAAM,CAACiF,UAAU,CAAC,kCAAkC,CAAC,CAACC,OAAO;AAEjE;AAEA,IAAIC,SAAwB,GAAG,IAAI;;AAEnC;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAAA,EAAW;EACrCD,SAAS,KACP,OAAOE,GAAG,KAAK,WAAW,IAAIA,GAAG,CAACC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,GAC1D,MAAM,GACN,QAAQ;EACd,OAAOH,SAAS;AAClB","ignoreList":[]}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { type ReactNode, type Ref } from 'react';
|
|
2
2
|
import { type ColorValue, type StyleProp, type ViewStyle } from 'react-native';
|
|
3
3
|
import type { DismissReason, KeyboardBehavior, ModalMode, PopupAnimation, SheetDetent } from './NitroModal.nitro.js';
|
|
4
|
+
/**
|
|
5
|
+
* Where a `bottomSheet` lives.
|
|
6
|
+
* - `modal`: presented over the whole app, with a backdrop.
|
|
7
|
+
* - `inline`: inside the component's own frame (`style`), as part of your
|
|
8
|
+
* screen. No backdrop, the views behind it stay interactive, and the user
|
|
9
|
+
* can't dismiss it.
|
|
10
|
+
*/
|
|
11
|
+
export type ModalPresentation = 'modal' | 'inline';
|
|
4
12
|
export interface NitroModalRef {
|
|
5
13
|
/** Opens the modal. Only for uncontrolled usage (no `isOpen` prop). */
|
|
6
14
|
present(): void;
|
|
@@ -18,7 +26,23 @@ export interface NitroModalProps {
|
|
|
18
26
|
isOpen?: boolean;
|
|
19
27
|
/** @default 'bottomSheet' */
|
|
20
28
|
mode?: ModalMode;
|
|
21
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* `inline` keeps a `bottomSheet` inside this component's frame, like a
|
|
31
|
+
* persistent sheet that is part of the screen. Popups are always modal.
|
|
32
|
+
* @default 'modal'
|
|
33
|
+
*/
|
|
34
|
+
presentation?: ModalPresentation;
|
|
35
|
+
/**
|
|
36
|
+
* Inline only: the frame the sheet lives in, laid out like any view.
|
|
37
|
+
* The sheet rests against its bottom edge and its largest detent reaches its
|
|
38
|
+
* top edge. @default StyleSheet.absoluteFill
|
|
39
|
+
*/
|
|
40
|
+
style?: StyleProp<ViewStyle>;
|
|
41
|
+
/**
|
|
42
|
+
* Sheet heights, smallest first: named sizes, or the content height in
|
|
43
|
+
* dp/pt above the bottom safe area. Android uses at most three.
|
|
44
|
+
* @default ['fitContent']
|
|
45
|
+
*/
|
|
22
46
|
detents?: SheetDetent[];
|
|
23
47
|
/** @default 0 */
|
|
24
48
|
initialDetentIndex?: number;
|
|
@@ -26,13 +50,13 @@ export interface NitroModalProps {
|
|
|
26
50
|
backdropColor?: ColorValue;
|
|
27
51
|
/** @default 0.4 */
|
|
28
52
|
backdropOpacity?: number;
|
|
29
|
-
/** Blur radius (dp/pt) behind the modal. Android 12+; approximated on iOS. @default 0 */
|
|
53
|
+
/** Blur radius (dp/pt/px) behind the modal. Android 12+; approximated on iOS. @default 0 */
|
|
30
54
|
backdropBlur?: number;
|
|
31
55
|
/** @default true */
|
|
32
56
|
dismissOnBackdropPress?: boolean;
|
|
33
57
|
/** Swipe down to dismiss a `bottomSheet`. @default true */
|
|
34
58
|
dismissOnSwipe?: boolean;
|
|
35
|
-
/** Android back button/gesture dismisses the modal. @default true */
|
|
59
|
+
/** Android back button/gesture (Escape on web) dismisses the modal. @default true */
|
|
36
60
|
dismissOnBackButton?: boolean;
|
|
37
61
|
/** @default false */
|
|
38
62
|
showGrabber?: boolean;
|
|
@@ -51,9 +75,16 @@ export interface NitroModalProps {
|
|
|
51
75
|
onDetentChange?: (index: number) => void;
|
|
52
76
|
onBackdropPress?: () => void;
|
|
53
77
|
onBackButtonPress?: () => void;
|
|
78
|
+
/**
|
|
79
|
+
* Pull-to-refresh: the user dragged the sheet down past its lowest detent
|
|
80
|
+
* and let go. Only for sheets that can't be swiped away (inline, or
|
|
81
|
+
* `dismissOnSwipe={false}`), and only from a gesture that starts with the
|
|
82
|
+
* sheet resting on its lowest detent.
|
|
83
|
+
*/
|
|
84
|
+
onPullToRefresh?: () => void;
|
|
54
85
|
children?: ReactNode;
|
|
55
86
|
testID?: string;
|
|
56
87
|
ref?: Ref<NitroModalRef>;
|
|
57
88
|
}
|
|
58
|
-
export declare function NitroModal({ isOpen, mode, detents, initialDetentIndex, backdropColor, backdropOpacity, backdropBlur, dismissOnBackdropPress, dismissOnSwipe, dismissOnBackButton, showGrabber, cornerRadius, backgroundColor, keyboardBehavior, popupAnimation, contentContainerStyle, onPresent, onDismiss, onDetentChange, onBackdropPress, onBackButtonPress, children, testID, ref, }: NitroModalProps): import("react").JSX.Element;
|
|
89
|
+
export declare function NitroModal({ isOpen, mode, presentation, style, detents, initialDetentIndex, backdropColor, backdropOpacity, backdropBlur, dismissOnBackdropPress, dismissOnSwipe, dismissOnBackButton, showGrabber, cornerRadius, backgroundColor, keyboardBehavior, popupAnimation, contentContainerStyle, onPresent, onDismiss, onDetentChange, onBackdropPress, onBackButtonPress, onPullToRefresh, children, testID, ref, }: NitroModalProps): import("react").JSX.Element;
|
|
59
90
|
//# sourceMappingURL=NitroModal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NitroModal.d.ts","sourceRoot":"","sources":["../../../src/NitroModal.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,SAAS,EACd,KAAK,GAAG,EACT,MAAM,OAAO,CAAC;AACf,OAAO,EAKL,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"NitroModal.d.ts","sourceRoot":"","sources":["../../../src/NitroModal.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,SAAS,EACd,KAAK,GAAG,EACT,MAAM,OAAO,CAAC;AACf,OAAO,EAKL,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAA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,qBAAqB;IACrB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,uBAAuB;IACvB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,gEAAgE;IAChE,qBAAqB,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7C,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;IAC5C,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC/B;;;;;OAKG;IACH,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;CAC1B;AAmBD,wBAAgB,UAAU,CAAC,EACzB,MAAM,EACN,IAAoB,EACpB,YAAsB,EACtB,KAAK,EACL,OAAyB,EACzB,kBAAsB,EACtB,aAAuB,EACvB,eAAqB,EACrB,YAAgB,EAChB,sBAA6B,EAC7B,cAAqB,EACrB,mBAA0B,EAC1B,WAAmB,EACnB,YAAY,EACZ,eAAe,EACf,gBAAwB,EACxB,cAAwB,EACxB,qBAAqB,EACrB,SAAS,EACT,SAAS,EACT,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,QAAQ,EACR,MAAM,EACN,GAAG,GACJ,EAAE,eAAe,+BA4KjB"}
|
|
@@ -7,13 +7,19 @@ import type { HybridView, HybridViewMethods, HybridViewProps } from 'react-nativ
|
|
|
7
7
|
*/
|
|
8
8
|
export type ModalMode = 'bottomSheet' | 'popup';
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Named resting heights of a `bottomSheet`.
|
|
11
11
|
* - `small`: ~25% of the available height.
|
|
12
12
|
* - `medium`: ~50% of the available height.
|
|
13
13
|
* - `large`: the full available height.
|
|
14
14
|
* - `fitContent`: the measured height of the React content.
|
|
15
15
|
*/
|
|
16
|
-
export type
|
|
16
|
+
export type NamedSheetDetent = 'small' | 'medium' | 'large' | 'fitContent';
|
|
17
|
+
/**
|
|
18
|
+
* A resting height of a `bottomSheet`: a named height, or the height
|
|
19
|
+
* (dp/pt) of the content above the bottom safe area, clamped to the
|
|
20
|
+
* available height.
|
|
21
|
+
*/
|
|
22
|
+
export type SheetDetent = NamedSheetDetent | number;
|
|
17
23
|
/**
|
|
18
24
|
* How the modal reacts to the software keyboard.
|
|
19
25
|
* - `pan`: the sheet/card is translated above the keyboard, in sync with the
|
|
@@ -36,6 +42,12 @@ export interface NitroModalProps extends HybridViewProps {
|
|
|
36
42
|
/** Whether the modal should be presented. */
|
|
37
43
|
isOpen: boolean;
|
|
38
44
|
mode: ModalMode;
|
|
45
|
+
/**
|
|
46
|
+
* A `bottomSheet` that lives inside the host view's own bounds instead of
|
|
47
|
+
* being presented over the app: no backdrop, touches outside the sheet
|
|
48
|
+
* reach the views behind it, and the user can't dismiss it.
|
|
49
|
+
*/
|
|
50
|
+
isInline: boolean;
|
|
39
51
|
/** Detents of a `bottomSheet`, smallest first. At most 3 are used on Android. */
|
|
40
52
|
detents: SheetDetent[];
|
|
41
53
|
/** Index into `detents` that the sheet opens at. */
|
|
@@ -56,6 +68,11 @@ export interface NitroModalProps extends HybridViewProps {
|
|
|
56
68
|
contentBackgroundColor?: number;
|
|
57
69
|
keyboardBehavior: KeyboardBehavior;
|
|
58
70
|
popupAnimation: PopupAnimation;
|
|
71
|
+
/**
|
|
72
|
+
* Pulling a `bottomSheet` down past its lowest detent calls
|
|
73
|
+
* `onPullToRefresh`. Needs `dismissOnSwipe` off (always the case inline).
|
|
74
|
+
*/
|
|
75
|
+
pullToRefreshEnabled: boolean;
|
|
59
76
|
/** The present transition finished. */
|
|
60
77
|
onPresent?: () => void;
|
|
61
78
|
/** The modal is fully gone. Fired exactly once for every presentation request. */
|
|
@@ -67,6 +84,16 @@ export interface NitroModalProps extends HybridViewProps {
|
|
|
67
84
|
onBackButtonPress?: () => void;
|
|
68
85
|
/** The area available to the content changed (rotation, keyboard, sheet sizing). */
|
|
69
86
|
onContentAreaChange?: (area: ModalContentArea) => void;
|
|
87
|
+
/**
|
|
88
|
+
* The user pulled the sheet down past its lowest detent and let go. The
|
|
89
|
+
* gesture must start with the sheet resting on that detent.
|
|
90
|
+
*/
|
|
91
|
+
onPullToRefresh?: () => void;
|
|
92
|
+
/**
|
|
93
|
+
* Inline sheets: where the sheet's top rests within the host view (or
|
|
94
|
+
* will, once it settles). Lets React lay the content out where it is shown.
|
|
95
|
+
*/
|
|
96
|
+
onRestingTopChange?: (top: number) => void;
|
|
70
97
|
}
|
|
71
98
|
export interface NitroModalMethods extends HybridViewMethods {
|
|
72
99
|
present(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NitroModal.nitro.d.ts","sourceRoot":"","sources":["../../../src/NitroModal.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EACjB,eAAe,EAChB,MAAM,4BAA4B,CAAC;AAEpC;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,OAAO,CAAC;AAEhD;;;;;;GAMG;AACH,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"NitroModal.nitro.d.ts","sourceRoot":"","sources":["../../../src/NitroModal.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EACjB,eAAe,EAChB,MAAM,4BAA4B,CAAC;AAEpC;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,OAAO,CAAC;AAEhD;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,YAAY,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AAI,CAAC;IACvB,kFAAkF;IAClF,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;IAC5C,qDAAqD;IACrD,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,qCAAqC;IACrC,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC/B,oFAAoF;IACpF,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACvD;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B;;;OAGG;IACH,kBAAkB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5C;AAED,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IAC1D,OAAO,IAAI,IAAI,CAAC;IAChB,OAAO,IAAI,IAAI,CAAC;IAChB,oDAAoD;IACpD,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { ReactNativeView } from 'react-native-nitro-modules';
|
|
1
|
+
import type { callback as nitroCallback, ReactNativeView } from 'react-native-nitro-modules';
|
|
2
2
|
import type { NitroModalMethods, NitroModalProps } from './NitroModal.nitro.js';
|
|
3
|
+
export declare const callback: typeof nitroCallback;
|
|
3
4
|
export declare const NitroModalView: ReactNativeView<NitroModalProps, NitroModalMethods>;
|
|
4
5
|
//# sourceMappingURL=NitroModalView.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NitroModalView.d.ts","sourceRoot":"","sources":["../../../src/NitroModalView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"NitroModalView.d.ts","sourceRoot":"","sources":["../../../src/NitroModalView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,IAAI,aAAa,EACzB,eAAe,EAChB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,uBAAoB,CAAC;AAkB7E,eAAO,MAAM,QAAQ,EAAgC,OAAO,aAAa,CAAC;AAE1E,eAAO,MAAM,cAAc,EACe,eAAe,CACrD,eAAe,EACf,iBAAiB,CAClB,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { NitroModalMethods, NitroModalProps } from './NitroModal.nitro.js';
|
|
2
|
+
export { callback } from 'react-native-nitro-modules';
|
|
2
3
|
export declare const NitroModalView: import("react-native-nitro-modules").ReactNativeView<NitroModalProps, NitroModalMethods>;
|
|
3
4
|
//# sourceMappingURL=NitroModalView.native.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NitroModalView.native.d.ts","sourceRoot":"","sources":["../../../src/NitroModalView.native.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,uBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"NitroModalView.native.d.ts","sourceRoot":"","sources":["../../../src/NitroModalView.native.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,uBAAoB,CAAC;AAI7E,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD,eAAO,MAAM,cAAc,0FAGY,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ReactNativeView } from 'react-native-nitro-modules';
|
|
2
|
+
import type { NitroModalMethods, NitroModalProps } from './NitroModal.nitro.js';
|
|
3
|
+
/** The web view takes plain functions; only native host components need them wrapped. */
|
|
4
|
+
export declare function callback<T>(func: T): T;
|
|
5
|
+
export declare const NitroModalView: ReactNativeView<NitroModalProps, NitroModalMethods>;
|
|
6
|
+
//# sourceMappingURL=NitroModalView.web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NitroModalView.web.d.ts","sourceRoot":"","sources":["../../../src/NitroModalView.web.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,uBAAoB,CAAC;AAW7E,yFAAyF;AACzF,wBAAgB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAEtC;AAsJD,eAAO,MAAM,cAAc,EAAmC,eAAe,CAC3E,eAAe,EACf,iBAAiB,CAClB,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { NitroModal, type NitroModalProps, type NitroModalRef, } from './NitroModal.js';
|
|
2
|
-
export type { DismissReason, KeyboardBehavior, ModalMode, PopupAnimation, SheetDetent, } from './NitroModal.nitro.js';
|
|
1
|
+
export { NitroModal, type ModalPresentation, type NitroModalProps, type NitroModalRef, } from './NitroModal.js';
|
|
2
|
+
export type { DismissReason, KeyboardBehavior, ModalMode, NamedSheetDetent, PopupAnimation, SheetDetent, } from './NitroModal.nitro.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,KAAK,eAAe,EACpB,KAAK,aAAa,GACnB,MAAM,iBAAc,CAAC;AACtB,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,SAAS,EACT,cAAc,EACd,WAAW,GACZ,MAAM,uBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,aAAa,GACnB,MAAM,iBAAc,CAAC;AACtB,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,SAAS,EACT,gBAAgB,EAChB,cAAc,EACd,WAAW,GACZ,MAAM,uBAAoB,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** How an `AnimatedValue` moves to its target. */
|
|
2
|
+
export type Motion = {
|
|
3
|
+
type: 'spring';
|
|
4
|
+
/** Period of the undamped spring, in seconds. Lower is snappier. */
|
|
5
|
+
response: number;
|
|
6
|
+
/** 1 settles without overshoot; lower values bounce. */
|
|
7
|
+
dampingRatio: number;
|
|
8
|
+
} | {
|
|
9
|
+
type: 'timing';
|
|
10
|
+
/** In milliseconds. */
|
|
11
|
+
duration: number;
|
|
12
|
+
easing: (progress: number) => number;
|
|
13
|
+
};
|
|
14
|
+
/** Jumps to the target at once. The completion still arrives on the next frame. */
|
|
15
|
+
export declare const INSTANT: Motion;
|
|
16
|
+
export interface AnimateOptions {
|
|
17
|
+
/** Starting velocity in units per second. Defaults to the current velocity. */
|
|
18
|
+
velocity?: number;
|
|
19
|
+
/** Finish as soon as a spring reaches the target instead of when it settles. */
|
|
20
|
+
stopAtTarget?: boolean;
|
|
21
|
+
/** Runs once the target is reached, unless another animation or `set` takes over first. */
|
|
22
|
+
onEnd?: () => void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A number animated on `requestAnimationFrame` that reports every frame
|
|
26
|
+
* through `onChange`. A new animation starts from the current value and
|
|
27
|
+
* velocity, so transitions can be turned around mid-flight.
|
|
28
|
+
*/
|
|
29
|
+
export declare class AnimatedValue {
|
|
30
|
+
private readonly precision;
|
|
31
|
+
private readonly onChange;
|
|
32
|
+
private current;
|
|
33
|
+
private speed;
|
|
34
|
+
private run;
|
|
35
|
+
private frame;
|
|
36
|
+
private lastTime;
|
|
37
|
+
/** `precision`: distance from the target at which a spring counts as settled. */
|
|
38
|
+
constructor(value: number, precision: number, onChange: (value: number) => void);
|
|
39
|
+
get value(): number;
|
|
40
|
+
get isAnimating(): boolean;
|
|
41
|
+
/** Jumps to `value`, cancelling any animation. */
|
|
42
|
+
set(value: number): void;
|
|
43
|
+
stop(): void;
|
|
44
|
+
animateTo(target: number, motion: Motion, options?: AnimateOptions): void;
|
|
45
|
+
private step;
|
|
46
|
+
private stepTiming;
|
|
47
|
+
private stepSpring;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=AnimatedValue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnimatedValue.d.ts","sourceRoot":"","sources":["../../../../src/web/AnimatedValue.ts"],"names":[],"mappings":"AAEA,kDAAkD;AAClD,MAAM,MAAM,MAAM,GACd;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,oEAAoE;IACpE,QAAQ,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,YAAY,EAAE,MAAM,CAAC;CACtB,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,uBAAuB;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;CACtC,CAAC;AAEN,mFAAmF;AACnF,eAAO,MAAM,OAAO,EAAE,MAIrB,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gFAAgF;IAChF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,2FAA2F;IAC3F,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;CACpB;AAgBD;;;;GAIG;AACH,qBAAa,aAAa;IAUtB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAV3B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,GAAG,CAAoB;IAC/B,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,QAAQ,CAAK;IAErB,iFAAiF;gBAE/E,KAAK,EAAE,MAAM,EACI,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI;IAKpD,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED,kDAAkD;IAClD,GAAG,CAAC,KAAK,EAAE,MAAM;IAOjB,IAAI;IAQJ,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB;IAwBtE,OAAO,CAAC,IAAI,CAyBV;IAEF,OAAO,CAAC,UAAU;IAkBlB,OAAO,CAAC,UAAU;CA8BnB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { KeyboardBehavior, ModalMode, NitroModalProps, PopupAnimation, SheetDetent } from '../NitroModal.nitro.js';
|
|
2
|
+
/** Snapshot of the props that shape a presentation. */
|
|
3
|
+
export interface ModalConfig {
|
|
4
|
+
mode: ModalMode;
|
|
5
|
+
/**
|
|
6
|
+
* A `bottomSheet` rendered in place, filling the host view: no backdrop,
|
|
7
|
+
* the page behind stays interactive, and the user can't dismiss it.
|
|
8
|
+
*/
|
|
9
|
+
isInline: boolean;
|
|
10
|
+
detents: SheetDetent[];
|
|
11
|
+
initialDetentIndex: number;
|
|
12
|
+
/** 0xAARRGGBB, from `processColor`. */
|
|
13
|
+
backdropColor: number;
|
|
14
|
+
backdropOpacity: number;
|
|
15
|
+
backdropBlurRadius: number;
|
|
16
|
+
dismissOnBackdropPress: boolean;
|
|
17
|
+
dismissOnSwipe: boolean;
|
|
18
|
+
dismissOnBackButton: boolean;
|
|
19
|
+
grabberVisible: boolean;
|
|
20
|
+
/** `null` uses the default. */
|
|
21
|
+
cornerRadius: number | null;
|
|
22
|
+
/** 0xAARRGGBB; `null` uses the system background. */
|
|
23
|
+
contentBackgroundColor: number | null;
|
|
24
|
+
keyboardBehavior: KeyboardBehavior;
|
|
25
|
+
popupAnimation: PopupAnimation;
|
|
26
|
+
pullToRefreshEnabled: boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare function makeConfig(props: NitroModalProps): ModalConfig;
|
|
29
|
+
export declare function isSameConfig(a: ModalConfig, b: ModalConfig): boolean;
|
|
30
|
+
//# sourceMappingURL=ModalConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalConfig.d.ts","sourceRoot":"","sources":["../../../../src/web/ModalConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,SAAS,EACT,eAAe,EACf,cAAc,EACd,WAAW,EACZ,MAAM,wBAAqB,CAAC;AAE7B,uDAAuD;AACvD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,SAAS,CAAC;IAChB;;;OAGG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,uCAAuC;IACvC,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,sBAAsB,EAAE,OAAO,CAAC;IAChC,cAAc,EAAE,OAAO,CAAC;IACxB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,cAAc,EAAE,OAAO,CAAC;IACxB,+BAA+B;IAC/B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,qDAAqD;IACrD,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,cAAc,EAAE,cAAc,CAAC;IAC/B,oBAAoB,EAAE,OAAO,CAAC;CAC/B;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,WAAW,CAuB9D;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,GAAG,OAAO,CAMpE"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { NitroModalMethods, NitroModalProps } from '../NitroModal.nitro.js';
|
|
2
|
+
import type { ModalElements, PresenterListener } from './ModalPresenter.js';
|
|
3
|
+
/**
|
|
4
|
+
* The web counterpart of the native `HybridNitroModal`: receives the host
|
|
5
|
+
* view's props and drives one presenter per presentation.
|
|
6
|
+
*
|
|
7
|
+
* Presentation is a small state machine so that rapid `isOpen` toggles, user
|
|
8
|
+
* dismissals and unmounts always settle on a consistent state, and every
|
|
9
|
+
* accepted present request ends with exactly one `onDismiss`. Transitions are
|
|
10
|
+
* interrupted rather than queued: closing mid-enter turns the enter around,
|
|
11
|
+
* and opening mid-exit turns the exit around (that session carries on, so it
|
|
12
|
+
* gets no `onDismiss` and at most one `onPresent`).
|
|
13
|
+
*/
|
|
14
|
+
export declare class ModalController implements PresenterListener {
|
|
15
|
+
private readonly setMounted;
|
|
16
|
+
readonly methods: Pick<NitroModalMethods, 'present' | 'dismiss' | 'snapToDetent'>;
|
|
17
|
+
private props;
|
|
18
|
+
private config;
|
|
19
|
+
private isOpen;
|
|
20
|
+
private phase;
|
|
21
|
+
/** What React (or an imperative call) asked for. */
|
|
22
|
+
private wantsOpen;
|
|
23
|
+
/** A present request was accepted and its `onDismiss` is still owed. */
|
|
24
|
+
private sessionActive;
|
|
25
|
+
/** `onPresent` was sent for the current session. */
|
|
26
|
+
private presentSent;
|
|
27
|
+
private dismissReason;
|
|
28
|
+
private reconcileScheduled;
|
|
29
|
+
private isAttached;
|
|
30
|
+
private presenter;
|
|
31
|
+
private elements;
|
|
32
|
+
/** Inline: the element the sheet fills. */
|
|
33
|
+
private host;
|
|
34
|
+
private lastContentArea;
|
|
35
|
+
/** `setMounted` renders (or removes) the modal's elements. */
|
|
36
|
+
constructor(setMounted: (mounted: boolean) => void);
|
|
37
|
+
attach(): void;
|
|
38
|
+
/** The host view unmounted. Also runs for React's strict-mode remount, so `attach` must work again. */
|
|
39
|
+
detach(): void;
|
|
40
|
+
/** The host view rendered with new props. */
|
|
41
|
+
update(props: NitroModalProps): void;
|
|
42
|
+
/** Inline: the element the sheet fills, rendered in place. */
|
|
43
|
+
hostDidChange(host: HTMLElement | null): void;
|
|
44
|
+
elementsDidMount(elements: ModalElements): void;
|
|
45
|
+
elementsWillUnmount(): void;
|
|
46
|
+
contentDidRender(): void;
|
|
47
|
+
/** Escape key, routed by React Native Web's `Modal` to the topmost modal. */
|
|
48
|
+
handleBackPress: () => void;
|
|
49
|
+
private get isVisible();
|
|
50
|
+
private requestPresent;
|
|
51
|
+
private requestDismiss;
|
|
52
|
+
/** Coalesces the requests made in one task, e.g. an open and a close in the same handler. */
|
|
53
|
+
private scheduleReconcile;
|
|
54
|
+
private reconcile;
|
|
55
|
+
private startPresent;
|
|
56
|
+
private startDismiss;
|
|
57
|
+
private finishDismiss;
|
|
58
|
+
private endSession;
|
|
59
|
+
onPresented(): void;
|
|
60
|
+
onDismissed(): void;
|
|
61
|
+
onBackdropPress(): void;
|
|
62
|
+
onSwipeDismiss(): void;
|
|
63
|
+
onDetentChange(index: number): void;
|
|
64
|
+
onPullToRefresh(): void;
|
|
65
|
+
onContentAreaChange(width: number, height: number): void;
|
|
66
|
+
/** Lets React size the content before the first presentation. */
|
|
67
|
+
private reportEstimatedContentArea;
|
|
68
|
+
private handleWindowResize;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=ModalController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalController.d.ts","sourceRoot":"","sources":["../../../../src/web/ModalController.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGV,iBAAiB,EACjB,eAAe,EAChB,MAAM,wBAAqB,CAAC;AAQ7B,OAAO,KAAK,EACV,aAAa,EAEb,iBAAiB,EAClB,MAAM,qBAAkB,CAAC;AAM1B;;;;;;;;;;GAUG;AACH,qBAAa,eAAgB,YAAW,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UAAU;IAclB,WAAW;IAUX,WAAW;IAIX,eAAe;IAOf,cAAc;IAMd,cAAc,CAAC,KAAK,EAAE,MAAM;IAI5B,eAAe;IAIf,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAWjD,iEAAiE;IACjE,OAAO,CAAC,0BAA0B;IAyBlC,OAAO,CAAC,kBAAkB,CAIxB;CACH"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { type Insets, type Size } from './dom.js';
|
|
2
|
+
import type { ModalConfig } from './ModalConfig.js';
|
|
3
|
+
/** DOM rendered by the web host view for one presentation. */
|
|
4
|
+
export interface ModalElements {
|
|
5
|
+
/** Full-window layer holding the backdrop and the surface. */
|
|
6
|
+
overlay: HTMLElement;
|
|
7
|
+
backdrop: HTMLElement;
|
|
8
|
+
/** The sheet or the popup card. */
|
|
9
|
+
surface: HTMLElement;
|
|
10
|
+
/** Hosts the React content. */
|
|
11
|
+
content: HTMLElement;
|
|
12
|
+
grabber: HTMLElement;
|
|
13
|
+
}
|
|
14
|
+
export interface PresenterListener {
|
|
15
|
+
/** An enter transition settled: the first one, or one that reversed an exit. */
|
|
16
|
+
onPresented(): void;
|
|
17
|
+
/** The exit transition finished. Called at most once per presenter. */
|
|
18
|
+
onDismissed(): void;
|
|
19
|
+
onBackdropPress(): void;
|
|
20
|
+
/** The user swiped the sheet down far enough to dismiss it. */
|
|
21
|
+
onSwipeDismiss(): void;
|
|
22
|
+
onDetentChange(index: number): void;
|
|
23
|
+
onContentAreaChange(width: number, height: number): void;
|
|
24
|
+
/** The user pulled the sheet past its lowest detent and let go. */
|
|
25
|
+
onPullToRefresh(): void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Owns one presentation from show to dismiss. Subclasses lay out the surface
|
|
29
|
+
* and drive the enter/exit animations; this class tracks the viewport, the
|
|
30
|
+
* on-screen keyboard and the content size, and handles the backdrop and
|
|
31
|
+
* teardown.
|
|
32
|
+
*
|
|
33
|
+
* Transitions are interruptible: dismissing mid-enter turns the enter around,
|
|
34
|
+
* and `cancelDismiss` turns an exit back around. Once an exit starts the modal
|
|
35
|
+
* stops taking input.
|
|
36
|
+
*
|
|
37
|
+
* Inline, the elements fill the host view in place of a full-window layer:
|
|
38
|
+
* only the surface takes input, and the keyboard is left to the page.
|
|
39
|
+
*/
|
|
40
|
+
export declare abstract class ModalPresenter {
|
|
41
|
+
protected config: ModalConfig;
|
|
42
|
+
protected readonly listener: PresenterListener;
|
|
43
|
+
protected elements: ModalElements | null;
|
|
44
|
+
protected viewport: Size;
|
|
45
|
+
protected insets: Insets;
|
|
46
|
+
/** Part of the viewport covered by the on-screen keyboard, from the bottom. */
|
|
47
|
+
protected keyboardHeight: number;
|
|
48
|
+
/** Measured size of the React content. */
|
|
49
|
+
protected contentSize: Size;
|
|
50
|
+
protected entering: boolean;
|
|
51
|
+
protected isDismissing: boolean;
|
|
52
|
+
private finished;
|
|
53
|
+
private observedContent;
|
|
54
|
+
private resizeObserver;
|
|
55
|
+
/** Inline: follows the host's size, which can change without a window resize. */
|
|
56
|
+
private hostObserver;
|
|
57
|
+
constructor(config: ModalConfig, listener: PresenterListener);
|
|
58
|
+
get isShown(): boolean;
|
|
59
|
+
/** Takes over the rendered elements and starts the enter transition. */
|
|
60
|
+
show(elements: ModalElements): void;
|
|
61
|
+
update(config: ModalConfig): void;
|
|
62
|
+
/** The React content re-rendered; its root element may have changed. */
|
|
63
|
+
contentDidRender(): void;
|
|
64
|
+
/**
|
|
65
|
+
* Animated dismissal, also from mid-enter. `onDismissed` follows when it
|
|
66
|
+
* completes, unless `cancelDismiss` turns it around first.
|
|
67
|
+
*/
|
|
68
|
+
dismiss(): void;
|
|
69
|
+
/**
|
|
70
|
+
* Reverses a running exit from wherever it is. `onPresented` follows once
|
|
71
|
+
* it settles. Returns false when there is no exit to reverse.
|
|
72
|
+
*/
|
|
73
|
+
cancelDismiss(): boolean;
|
|
74
|
+
/** Tears down without animating or notifying the listener. */
|
|
75
|
+
destroy(): void;
|
|
76
|
+
snapToDetent(_index: number): void;
|
|
77
|
+
/** The elements are in place; lay out the hidden state. */
|
|
78
|
+
protected abstract didShow(): void;
|
|
79
|
+
/** Animates from the current state to presented, then calls `notifyPresented`. */
|
|
80
|
+
protected abstract animateIn(): void;
|
|
81
|
+
/** Animates from the current state (possibly mid-enter) to gone, then calls `onEnd`. */
|
|
82
|
+
protected abstract animateOut(onEnd: () => void): void;
|
|
83
|
+
protected abstract configDidChange(previous: ModalConfig): void;
|
|
84
|
+
/** The viewport size, safe area or keyboard height changed. */
|
|
85
|
+
protected abstract viewportDidChange(): void;
|
|
86
|
+
protected abstract contentSizeDidChange(): void;
|
|
87
|
+
protected abstract stopAnimations(): void;
|
|
88
|
+
/** For subclasses: the running enter animation settled. */
|
|
89
|
+
protected notifyPresented(): void;
|
|
90
|
+
protected reportContentArea(width: number, height: number): void;
|
|
91
|
+
protected teardown(): void;
|
|
92
|
+
private finish;
|
|
93
|
+
private applyBackdrop;
|
|
94
|
+
/** Inline, only the surface takes input; the rest reaches the page. */
|
|
95
|
+
private setInteractive;
|
|
96
|
+
private measureViewport;
|
|
97
|
+
/** Re-targets the observer at the content's root element. Returns whether its size changed. */
|
|
98
|
+
private observeContent;
|
|
99
|
+
private measureContent;
|
|
100
|
+
private handleContentResize;
|
|
101
|
+
private handleResize;
|
|
102
|
+
private handleKeyboard;
|
|
103
|
+
private handleBackdropClick;
|
|
104
|
+
/** Keeps the page behind the modal from scrolling; scrollable content still scrolls. */
|
|
105
|
+
private handleWheel;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=ModalPresenter.d.ts.map
|