react-native-nitro-modal 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -7
- package/android/src/main/java/com/margelo/nitro/nitromodal/BottomSheetPresenter.kt +72 -21
- package/android/src/main/java/com/margelo/nitro/nitromodal/HybridNitroModal.kt +17 -3
- package/android/src/main/java/com/margelo/nitro/nitromodal/ModalPresenter.kt +121 -12
- package/android/src/main/java/com/margelo/nitro/nitromodal/PopupPresenter.kt +92 -31
- package/lib/module/NitroModal.js +1 -2
- 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 +129 -0
- package/lib/module/NitroModalView.web.js.map +1 -0
- package/lib/module/web/AnimatedValue.js +123 -0
- package/lib/module/web/AnimatedValue.js.map +1 -0
- package/lib/module/web/ModalConfig.js +26 -0
- package/lib/module/web/ModalConfig.js.map +1 -0
- package/lib/module/web/ModalController.js +279 -0
- package/lib/module/web/ModalController.js.map +1 -0
- package/lib/module/web/ModalPresenter.js +245 -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 +469 -0
- package/lib/module/web/SheetPresenter.js.map +1 -0
- package/lib/module/web/dom.js +125 -0
- package/lib/module/web/dom.js.map +1 -0
- package/lib/typescript/src/NitroModal.d.ts +2 -2
- package/lib/typescript/src/NitroModal.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/web/AnimatedValue.d.ts +48 -0
- package/lib/typescript/src/web/AnimatedValue.d.ts.map +1 -0
- package/lib/typescript/src/web/ModalConfig.d.ts +24 -0
- package/lib/typescript/src/web/ModalConfig.d.ts.map +1 -0
- package/lib/typescript/src/web/ModalController.d.ts +65 -0
- package/lib/typescript/src/web/ModalController.d.ts.map +1 -0
- package/lib/typescript/src/web/ModalPresenter.d.ts +98 -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 +40 -0
- package/lib/typescript/src/web/dom.d.ts.map +1 -0
- package/package.json +3 -2
- package/src/NitroModal.tsx +3 -4
- package/src/NitroModalView.native.tsx +4 -0
- package/src/NitroModalView.tsx +9 -4
- package/src/NitroModalView.web.tsx +138 -0
- package/src/web/AnimatedValue.ts +189 -0
- package/src/web/ModalConfig.ts +57 -0
- package/src/web/ModalController.ts +305 -0
- package/src/web/ModalPresenter.ts +298 -0
- package/src/web/PopupPresenter.ts +129 -0
- package/src/web/SheetPresenter.ts +582 -0
- package/src/web/dom.ts +154 -0
|
@@ -26,13 +26,13 @@ export interface NitroModalProps {
|
|
|
26
26
|
backdropColor?: ColorValue;
|
|
27
27
|
/** @default 0.4 */
|
|
28
28
|
backdropOpacity?: number;
|
|
29
|
-
/** Blur radius (dp/pt) behind the modal. Android 12+; approximated on iOS. @default 0 */
|
|
29
|
+
/** Blur radius (dp/pt/px) behind the modal. Android 12+; approximated on iOS. @default 0 */
|
|
30
30
|
backdropBlur?: number;
|
|
31
31
|
/** @default true */
|
|
32
32
|
dismissOnBackdropPress?: boolean;
|
|
33
33
|
/** Swipe down to dismiss a `bottomSheet`. @default true */
|
|
34
34
|
dismissOnSwipe?: boolean;
|
|
35
|
-
/** Android back button/gesture dismisses the modal. @default true */
|
|
35
|
+
/** Android back button/gesture (Escape on web) dismisses the modal. @default true */
|
|
36
36
|
dismissOnBackButton?: boolean;
|
|
37
37
|
/** @default false */
|
|
38
38
|
showGrabber?: boolean;
|
|
@@ -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,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAEhB,SAAS,EAET,cAAc,EACd,WAAW,EACZ,MAAM,uBAAoB,CAAC;AAG5B,MAAM,WAAW,aAAa;IAC5B,uEAAuE;IACvE,OAAO,IAAI,IAAI,CAAC;IAChB,sEAAsE;IACtE,OAAO,IAAI,IAAI,CAAC;IAChB,oDAAoD;IACpD,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,6BAA6B;IAC7B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,yFAAyF;IACzF,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;IACxB,iBAAiB;IACjB,kBAAkB,CAAC,E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AmB,EACnB,YAAY,EACZ,eAAe,EACf,gBAAwB,EACxB,cAAwB,EACxB,qBAAqB,EACrB,SAAS,EACT,SAAS,EACT,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,QAAQ,EACR,MAAM,EACN,GAAG,GACJ,EAAE,eAAe,+BAuJjB"}
|
|
@@ -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":"AAUA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,uBAAoB,CAAC;AAQ7E,yFAAyF;AACzF,wBAAgB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAEtC;AAgHD,eAAO,MAAM,cAAc,EAAmC,eAAe,CAC3E,eAAe,EACf,iBAAiB,CAClB,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
/** Jumps to `value`, cancelling any animation. */
|
|
41
|
+
set(value: number): void;
|
|
42
|
+
stop(): void;
|
|
43
|
+
animateTo(target: number, motion: Motion, options?: AnimateOptions): void;
|
|
44
|
+
private step;
|
|
45
|
+
private stepTiming;
|
|
46
|
+
private stepSpring;
|
|
47
|
+
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AS,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,24 @@
|
|
|
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
|
+
detents: SheetDetent[];
|
|
6
|
+
initialDetentIndex: number;
|
|
7
|
+
/** 0xAARRGGBB, from `processColor`. */
|
|
8
|
+
backdropColor: number;
|
|
9
|
+
backdropOpacity: number;
|
|
10
|
+
backdropBlurRadius: number;
|
|
11
|
+
dismissOnBackdropPress: boolean;
|
|
12
|
+
dismissOnSwipe: boolean;
|
|
13
|
+
dismissOnBackButton: boolean;
|
|
14
|
+
grabberVisible: boolean;
|
|
15
|
+
/** `null` uses the default. */
|
|
16
|
+
cornerRadius: number | null;
|
|
17
|
+
/** 0xAARRGGBB; `null` uses the system background. */
|
|
18
|
+
contentBackgroundColor: number | null;
|
|
19
|
+
keyboardBehavior: KeyboardBehavior;
|
|
20
|
+
popupAnimation: PopupAnimation;
|
|
21
|
+
}
|
|
22
|
+
export declare function makeConfig(props: NitroModalProps): ModalConfig;
|
|
23
|
+
export declare function isSameConfig(a: ModalConfig, b: ModalConfig): boolean;
|
|
24
|
+
//# 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,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;CAChC;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,WAAW,CAmB9D;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,GAAG,OAAO,CAMpE"}
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
private lastContentArea;
|
|
33
|
+
/** `setMounted` renders (or removes) the modal's elements. */
|
|
34
|
+
constructor(setMounted: (mounted: boolean) => void);
|
|
35
|
+
attach(): void;
|
|
36
|
+
/** The host view unmounted. Also runs for React's strict-mode remount, so `attach` must work again. */
|
|
37
|
+
detach(): void;
|
|
38
|
+
/** The host view rendered with new props. */
|
|
39
|
+
update(props: NitroModalProps): void;
|
|
40
|
+
elementsDidMount(elements: ModalElements): void;
|
|
41
|
+
elementsWillUnmount(): void;
|
|
42
|
+
contentDidRender(): void;
|
|
43
|
+
/** Escape key, routed by React Native Web's `Modal` to the topmost modal. */
|
|
44
|
+
handleBackPress: () => void;
|
|
45
|
+
private get isVisible();
|
|
46
|
+
private requestPresent;
|
|
47
|
+
private requestDismiss;
|
|
48
|
+
/** Coalesces the requests made in one task, e.g. an open and a close in the same handler. */
|
|
49
|
+
private scheduleReconcile;
|
|
50
|
+
private reconcile;
|
|
51
|
+
private startPresent;
|
|
52
|
+
private startDismiss;
|
|
53
|
+
private finishDismiss;
|
|
54
|
+
private endSession;
|
|
55
|
+
onPresented(): void;
|
|
56
|
+
onDismissed(): void;
|
|
57
|
+
onBackdropPress(): void;
|
|
58
|
+
onSwipeDismiss(): void;
|
|
59
|
+
onDetentChange(index: number): void;
|
|
60
|
+
onContentAreaChange(width: number, height: number): void;
|
|
61
|
+
/** Lets React size the content before the first presentation. */
|
|
62
|
+
private reportEstimatedContentArea;
|
|
63
|
+
private handleWindowResize;
|
|
64
|
+
}
|
|
65
|
+
//# 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;AAG7B,OAAO,KAAK,EACV,aAAa,EAEb,iBAAiB,EAClB,MAAM,qBAAkB,CAAC;AAM1B;;;;;;;;;;GAUG;AACH,qBAAa,eAAgB,YAAW,iBAAiB;IAgC3C,OAAO,CAAC,QAAQ,CAAC,UAAU;IA/BvC,QAAQ,CAAC,OAAO,EAAE,IAAI,CACpB,iBAAiB,EACjB,SAAS,GAAG,SAAS,GAAG,cAAc,CACvC,CAQC;IAEF,OAAO,CAAC,KAAK,CAAgC;IAC7C,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,KAAK,CAAiB;IAC9B,oDAAoD;IACpD,OAAO,CAAC,SAAS,CAAS;IAC1B,wEAAwE;IACxE,OAAO,CAAC,aAAa,CAAS;IAC9B,oDAAoD;IACpD,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,aAAa,CAAiC;IACtD,OAAO,CAAC,kBAAkB,CAAS;IACnC,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,SAAS,CAA+B;IAChD,OAAO,CAAC,QAAQ,CAA8B;IAC9C,OAAO,CAAC,eAAe,CAAiC;IAExD,8DAA8D;gBACjC,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI;IAInE,MAAM;IAKN,uGAAuG;IACvG,MAAM;IAiBN,6CAA6C;IAC7C,MAAM,CAAC,KAAK,EAAE,eAAe;IAqB7B,gBAAgB,CAAC,QAAQ,EAAE,aAAa;IAOxC,mBAAmB;IAInB,gBAAgB;IAIhB,6EAA6E;IAC7E,eAAe,aAOb;IAIF,OAAO,KAAK,SAAS,GAEpB;IAED,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,cAAc;IAQtB,6FAA6F;IAC7F,OAAO,CAAC,iBAAiB;IAWzB,OAAO,CAAC,SAAS;IAwBjB,OAAO,CAAC,YAAY;IAgBpB,OAAO,CAAC,YAAY;IAYpB,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,UAAU;IAclB,WAAW;IAUX,WAAW;IAIX,eAAe;IAOf,cAAc;IAMd,cAAc,CAAC,KAAK,EAAE,MAAM;IAI5B,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAWjD,iEAAiE;IACjE,OAAO,CAAC,0BAA0B;IAYlC,OAAO,CAAC,kBAAkB,CAIxB;CACH"}
|
|
@@ -0,0 +1,98 @@
|
|
|
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
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Owns one presentation from show to dismiss. Subclasses lay out the surface
|
|
27
|
+
* and drive the enter/exit animations; this class tracks the viewport, the
|
|
28
|
+
* on-screen keyboard and the content size, and handles the backdrop and
|
|
29
|
+
* teardown.
|
|
30
|
+
*
|
|
31
|
+
* Transitions are interruptible: dismissing mid-enter turns the enter around,
|
|
32
|
+
* and `cancelDismiss` turns an exit back around. Once an exit starts the modal
|
|
33
|
+
* stops taking input.
|
|
34
|
+
*/
|
|
35
|
+
export declare abstract class ModalPresenter {
|
|
36
|
+
protected config: ModalConfig;
|
|
37
|
+
protected readonly listener: PresenterListener;
|
|
38
|
+
protected elements: ModalElements | null;
|
|
39
|
+
protected viewport: Size;
|
|
40
|
+
protected insets: Insets;
|
|
41
|
+
/** Part of the viewport covered by the on-screen keyboard, from the bottom. */
|
|
42
|
+
protected keyboardHeight: number;
|
|
43
|
+
/** Measured size of the React content. */
|
|
44
|
+
protected contentSize: Size;
|
|
45
|
+
protected entering: boolean;
|
|
46
|
+
protected isDismissing: boolean;
|
|
47
|
+
private finished;
|
|
48
|
+
private observedContent;
|
|
49
|
+
private resizeObserver;
|
|
50
|
+
constructor(config: ModalConfig, listener: PresenterListener);
|
|
51
|
+
get isShown(): boolean;
|
|
52
|
+
/** Takes over the rendered elements and starts the enter transition. */
|
|
53
|
+
show(elements: ModalElements): void;
|
|
54
|
+
update(config: ModalConfig): void;
|
|
55
|
+
/** The React content re-rendered; its root element may have changed. */
|
|
56
|
+
contentDidRender(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Animated dismissal, also from mid-enter. `onDismissed` follows when it
|
|
59
|
+
* completes, unless `cancelDismiss` turns it around first.
|
|
60
|
+
*/
|
|
61
|
+
dismiss(): void;
|
|
62
|
+
/**
|
|
63
|
+
* Reverses a running exit from wherever it is. `onPresented` follows once
|
|
64
|
+
* it settles. Returns false when there is no exit to reverse.
|
|
65
|
+
*/
|
|
66
|
+
cancelDismiss(): boolean;
|
|
67
|
+
/** Tears down without animating or notifying the listener. */
|
|
68
|
+
destroy(): void;
|
|
69
|
+
snapToDetent(_index: number): void;
|
|
70
|
+
/** The elements are in place; lay out the hidden state. */
|
|
71
|
+
protected abstract didShow(): void;
|
|
72
|
+
/** Animates from the current state to presented, then calls `notifyPresented`. */
|
|
73
|
+
protected abstract animateIn(): void;
|
|
74
|
+
/** Animates from the current state (possibly mid-enter) to gone, then calls `onEnd`. */
|
|
75
|
+
protected abstract animateOut(onEnd: () => void): void;
|
|
76
|
+
protected abstract configDidChange(previous: ModalConfig): void;
|
|
77
|
+
/** The viewport size, safe area or keyboard height changed. */
|
|
78
|
+
protected abstract viewportDidChange(): void;
|
|
79
|
+
protected abstract contentSizeDidChange(): void;
|
|
80
|
+
protected abstract stopAnimations(): void;
|
|
81
|
+
/** For subclasses: the running enter animation settled. */
|
|
82
|
+
protected notifyPresented(): void;
|
|
83
|
+
protected reportContentArea(width: number, height: number): void;
|
|
84
|
+
protected teardown(): void;
|
|
85
|
+
private finish;
|
|
86
|
+
private applyBackdrop;
|
|
87
|
+
private measureViewport;
|
|
88
|
+
/** Re-targets the observer at the content's root element. Returns whether its size changed. */
|
|
89
|
+
private observeContent;
|
|
90
|
+
private measureContent;
|
|
91
|
+
private handleContentResize;
|
|
92
|
+
private handleResize;
|
|
93
|
+
private handleKeyboard;
|
|
94
|
+
private handleBackdropClick;
|
|
95
|
+
/** Keeps the page behind the modal from scrolling; scrollable content still scrolls. */
|
|
96
|
+
private handleWheel;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=ModalPresenter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalPresenter.d.ts","sourceRoot":"","sources":["../../../../src/web/ModalPresenter.ts"],"names":[],"mappings":"AAEA,OAAO,EA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ACxF,OAAO,CAAC,WAAW,CAMjB;CACH"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Insets, type Size } from './dom.js';
|
|
2
|
+
import { ModalPresenter } from './ModalPresenter.js';
|
|
3
|
+
/** Best guess of the content area before the popup is on screen. */
|
|
4
|
+
export declare function popupContentArea(viewport: Size, insets: Insets): Size;
|
|
5
|
+
/** `popup` mode: a centered card over the backdrop with a fade/scale transition. */
|
|
6
|
+
export declare class PopupPresenter extends ModalPresenter {
|
|
7
|
+
/** 0 hidden, 1 presented. */
|
|
8
|
+
private readonly progress;
|
|
9
|
+
protected didShow(): void;
|
|
10
|
+
protected animateIn(): void;
|
|
11
|
+
protected animateOut(onEnd: () => void): void;
|
|
12
|
+
protected configDidChange(): void;
|
|
13
|
+
protected viewportDidChange(): void;
|
|
14
|
+
protected contentSizeDidChange(): void;
|
|
15
|
+
protected stopAnimations(): void;
|
|
16
|
+
private get isAnimated();
|
|
17
|
+
private layout;
|
|
18
|
+
private render;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=PopupPresenter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PopupPresenter.d.ts","sourceRoot":"","sources":["../../../../src/web/PopupPresenter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAwB,KAAK,MAAM,EAAE,KAAK,IAAI,EAAE,MAAM,UAAO,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAkB,CAAC;AAmClD,oEAAoE;AACpE,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAGrE;AAED,oFAAoF;AACpF,qBAAa,cAAe,SAAQ,cAAc;IAChD,6BAA6B;IAC7B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAEvB;IAEF,SAAS,CAAC,OAAO;IAKjB,SAAS,CAAC,SAAS;IAMnB,SAAS,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,IAAI;IAItC,SAAS,CAAC,eAAe;IAKzB,SAAS,CAAC,iBAAiB;IAI3B,SAAS,CAAC,oBAAoB;IAI9B,SAAS,CAAC,cAAc;IAIxB,OAAO,KAAK,UAAU,GAErB;IAED,OAAO,CAAC,MAAM;IA6Bd,OAAO,CAAC,MAAM;CAWf"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { SheetDetent } from '../NitroModal.nitro.js';
|
|
2
|
+
import { type Insets, type Size } from './dom.js';
|
|
3
|
+
import type { ModalConfig } from './ModalConfig.js';
|
|
4
|
+
import { ModalPresenter, type PresenterListener } from './ModalPresenter.js';
|
|
5
|
+
/** Best guess of the content area before the sheet is on screen. */
|
|
6
|
+
export declare function sheetContentArea(detents: SheetDetent[], viewport: Size, insets: Insets): Size;
|
|
7
|
+
/**
|
|
8
|
+
* `bottomSheet` mode: an edge-attached sheet with detents, dragging,
|
|
9
|
+
* swipe-to-dismiss and hand-off to scrollable content, like the iOS
|
|
10
|
+
* implementation.
|
|
11
|
+
*/
|
|
12
|
+
export declare class SheetPresenter extends ModalPresenter {
|
|
13
|
+
private selectedIndex;
|
|
14
|
+
/** The sheet sits below the viewport (before presenting / while dismissing). */
|
|
15
|
+
private isOffscreen;
|
|
16
|
+
private drag;
|
|
17
|
+
/** Vertical velocity of the swipe that requested the dismissal. */
|
|
18
|
+
private releaseVelocity;
|
|
19
|
+
/** The sheet's top edge in the viewport. */
|
|
20
|
+
private readonly top;
|
|
21
|
+
constructor(config: ModalConfig, listener: PresenterListener);
|
|
22
|
+
snapToDetent(index: number): void;
|
|
23
|
+
protected didShow(): void;
|
|
24
|
+
protected animateIn(): void;
|
|
25
|
+
protected animateOut(onEnd: () => void): void;
|
|
26
|
+
protected configDidChange(): void;
|
|
27
|
+
protected viewportDidChange(): void;
|
|
28
|
+
protected contentSizeDidChange(): void;
|
|
29
|
+
protected stopAnimations(): void;
|
|
30
|
+
protected teardown(): void;
|
|
31
|
+
private get detents();
|
|
32
|
+
private get maximumDetentValue();
|
|
33
|
+
private get keyboardLift();
|
|
34
|
+
private height;
|
|
35
|
+
/** Sheet top when resting on `detents[index]`. The bottom safe area is added below the content. */
|
|
36
|
+
private restingTop;
|
|
37
|
+
private get detentTops();
|
|
38
|
+
private layout;
|
|
39
|
+
private render;
|
|
40
|
+
/** Fully dimmed at every detent; fades out below the lowest one. */
|
|
41
|
+
private backdropAlpha;
|
|
42
|
+
private motion;
|
|
43
|
+
private settle;
|
|
44
|
+
private animateToRest;
|
|
45
|
+
private canDrag;
|
|
46
|
+
private beginDrag;
|
|
47
|
+
/** Decides who handles a gesture once it moves: the sheet, or the content (scrolling, horizontal swipes). */
|
|
48
|
+
private claim;
|
|
49
|
+
private activate;
|
|
50
|
+
private moveDrag;
|
|
51
|
+
private release;
|
|
52
|
+
/** Abandons the gesture without settling (the exit or the content takes over). */
|
|
53
|
+
private cancelDrag;
|
|
54
|
+
private stopTracking;
|
|
55
|
+
private velocity;
|
|
56
|
+
/** Rubber-bands above the tallest detent, and below the lowest one when swiping can't dismiss. */
|
|
57
|
+
private constrained;
|
|
58
|
+
private handleTouchStart;
|
|
59
|
+
private handleTouchMove;
|
|
60
|
+
private handleTouchEnd;
|
|
61
|
+
private handlePointerDown;
|
|
62
|
+
private handlePointerMove;
|
|
63
|
+
private handlePointerUp;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=SheetPresenter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SheetPresenter.d.ts","sourceRoot":"","sources":["../../../../src/web/SheetPresenter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAqB,CAAC;AAEvD,OAAO,EAKL,KAAK,MAAM,EACX,KAAK,IAAI,EACV,MAAM,UAAO,CAAC;AACf,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAe,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,KAAK,iBAAiB,EAAE,MAAM,qBAAk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AAO,CAAC,OAAO;IAwCf,kFAAkF;IAClF,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,QAAQ;IAWhB,kGAAkG;IAClG,OAAO,CAAC,WAAW;IAiBnB,OAAO,CAAC,gBAAgB,CAiBtB;IAEF,OAAO,CAAC,eAAe,CAqBrB;IAEF,OAAO,CAAC,cAAc,CAKpB;IAIF,OAAO,CAAC,iBAAiB,CAqBvB;IAEF,OAAO,CAAC,iBAAiB,CAkBvB;IAEF,OAAO,CAAC,eAAe,CAIrB;CACH"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface Size {
|
|
2
|
+
width: number;
|
|
3
|
+
height: number;
|
|
4
|
+
}
|
|
5
|
+
export interface Insets {
|
|
6
|
+
top: number;
|
|
7
|
+
right: number;
|
|
8
|
+
bottom: number;
|
|
9
|
+
left: number;
|
|
10
|
+
}
|
|
11
|
+
export declare const ZERO_INSETS: Insets;
|
|
12
|
+
export declare const canUseDOM: boolean;
|
|
13
|
+
/** Converts a color from `processColor` (0xAARRGGBB) to CSS, scaling its alpha by `opacity`. */
|
|
14
|
+
export declare function toCSSColor(argb: number, opacity?: number): string;
|
|
15
|
+
/**
|
|
16
|
+
* `env(safe-area-inset-*)`, read through a hidden probe element. Non-zero on
|
|
17
|
+
* notched devices when the page opts in with `viewport-fit=cover`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function readSafeAreaInsets(): Insets;
|
|
20
|
+
/**
|
|
21
|
+
* Height of the on-screen keyboard over a layout viewport `layoutHeight` tall.
|
|
22
|
+
* Mobile browsers keep the layout viewport and shrink the visual one.
|
|
23
|
+
*/
|
|
24
|
+
export declare function readKeyboardHeight(layoutHeight: number): number;
|
|
25
|
+
/** The size of the viewport before anything is on screen. */
|
|
26
|
+
export declare function estimateViewport(): Size;
|
|
27
|
+
/** The innermost element from `target` up to (not including) `root` that scrolls vertically. */
|
|
28
|
+
export declare function findVerticalScroller(target: EventTarget | null, root: Element): HTMLElement | null;
|
|
29
|
+
/** Whether a scroller between `target` and `root` can scroll further by `deltaY`. */
|
|
30
|
+
export declare function canScrollWithin(target: EventTarget | null, root: Element, deltaY: number): boolean;
|
|
31
|
+
export declare function isTextInput(target: EventTarget | null): boolean;
|
|
32
|
+
/** Swallows the click that follows a mouse drag, so the content under the pointer isn't pressed. */
|
|
33
|
+
export declare function suppressNextClick(): void;
|
|
34
|
+
export declare function prefersReducedMotion(): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* `overflow: clip` rounds the corners without making the element a scroll
|
|
37
|
+
* container, which focusing an input could otherwise scroll.
|
|
38
|
+
*/
|
|
39
|
+
export declare function clipOverflow(): string;
|
|
40
|
+
//# sourceMappingURL=dom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../../../src/web/dom.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,IAAI;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,MAAM;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,WAAW,EAAE,MAAiD,CAAC;AAE5E,eAAO,MAAM,SAAS,SAC4C,CAAC;AAEnE,gGAAgG;AAChG,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,SAAI,GAAG,MAAM,CAM5D;AAID;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAmB3C;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAM/D;AAED,6DAA6D;AAC7D,wBAAgB,gBAAgB,IAAI,IAAI,CAKvC;AASD,gGAAgG;AAChG,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,WAAW,GAAG,IAAI,EAC1B,IAAI,EAAE,OAAO,GACZ,WAAW,GAAG,IAAI,CAMpB;AAED,qFAAqF;AACrF,wBAAgB,eAAe,CAC7B,MAAM,EAAE,WAAW,GAAG,IAAI,EAC1B,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,MAAM,GACb,OAAO,CAWT;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,GAAG,OAAO,CAO/D;AAED,oGAAoG;AACpG,wBAAgB,iBAAiB,SAUhC;AAED,wBAAgB,oBAAoB,IAAI,OAAO,CAK9C;AAID;;;GAGG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAMrC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-modal",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "react native native modal",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -47,7 +47,8 @@
|
|
|
47
47
|
"keywords": [
|
|
48
48
|
"react-native",
|
|
49
49
|
"ios",
|
|
50
|
-
"android"
|
|
50
|
+
"android",
|
|
51
|
+
"web"
|
|
51
52
|
],
|
|
52
53
|
"repository": {
|
|
53
54
|
"type": "git",
|
package/src/NitroModal.tsx
CHANGED
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
type StyleProp,
|
|
17
17
|
type ViewStyle,
|
|
18
18
|
} from 'react-native';
|
|
19
|
-
import { callback } from 'react-native-nitro-modules';
|
|
20
19
|
import type {
|
|
21
20
|
DismissReason,
|
|
22
21
|
KeyboardBehavior,
|
|
@@ -26,7 +25,7 @@ import type {
|
|
|
26
25
|
PopupAnimation,
|
|
27
26
|
SheetDetent,
|
|
28
27
|
} from './NitroModal.nitro';
|
|
29
|
-
import { NitroModalView } from './NitroModalView';
|
|
28
|
+
import { callback, NitroModalView } from './NitroModalView';
|
|
30
29
|
|
|
31
30
|
export interface NitroModalRef {
|
|
32
31
|
/** Opens the modal. Only for uncontrolled usage (no `isOpen` prop). */
|
|
@@ -54,13 +53,13 @@ export interface NitroModalProps {
|
|
|
54
53
|
backdropColor?: ColorValue;
|
|
55
54
|
/** @default 0.4 */
|
|
56
55
|
backdropOpacity?: number;
|
|
57
|
-
/** Blur radius (dp/pt) behind the modal. Android 12+; approximated on iOS. @default 0 */
|
|
56
|
+
/** Blur radius (dp/pt/px) behind the modal. Android 12+; approximated on iOS. @default 0 */
|
|
58
57
|
backdropBlur?: number;
|
|
59
58
|
/** @default true */
|
|
60
59
|
dismissOnBackdropPress?: boolean;
|
|
61
60
|
/** Swipe down to dismiss a `bottomSheet`. @default true */
|
|
62
61
|
dismissOnSwipe?: boolean;
|
|
63
|
-
/** Android back button/gesture dismisses the modal. @default true */
|
|
62
|
+
/** Android back button/gesture (Escape on web) dismisses the modal. @default true */
|
|
64
63
|
dismissOnBackButton?: boolean;
|
|
65
64
|
/** @default false */
|
|
66
65
|
showGrabber?: boolean;
|
|
@@ -4,6 +4,10 @@ import { getHostComponent } from 'react-native-nitro-modules';
|
|
|
4
4
|
const NitroModalConfig = require('react-native-nitro-modal/nitrogen/generated/shared/json/NitroModalConfig.json');
|
|
5
5
|
import type { NitroModalMethods, NitroModalProps } from './NitroModal.nitro';
|
|
6
6
|
|
|
7
|
+
// Host components need their function props wrapped. Exported from here so
|
|
8
|
+
// web bundles never import `react-native-nitro-modules`.
|
|
9
|
+
export { callback } from 'react-native-nitro-modules';
|
|
10
|
+
|
|
7
11
|
export const NitroModalView = getHostComponent<
|
|
8
12
|
NitroModalProps,
|
|
9
13
|
NitroModalMethods
|
package/src/NitroModalView.tsx
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
callback as nitroCallback,
|
|
3
|
+
ReactNativeView,
|
|
4
|
+
} from 'react-native-nitro-modules';
|
|
2
5
|
import type { NitroModalMethods, NitroModalProps } from './NitroModal.nitro';
|
|
3
6
|
|
|
4
7
|
let warned = false;
|
|
5
8
|
|
|
6
9
|
/**
|
|
7
|
-
* Platforms without
|
|
8
|
-
*
|
|
10
|
+
* Platforms without an implementation render nothing. iOS and Android use
|
|
11
|
+
* `NitroModalView.native.tsx`, web uses `NitroModalView.web.tsx`.
|
|
9
12
|
*/
|
|
10
13
|
function UnsupportedNitroModalView() {
|
|
11
14
|
if (!warned) {
|
|
12
15
|
warned = true;
|
|
13
16
|
console.warn(
|
|
14
|
-
'react-native-nitro-modal is only implemented on iOS and
|
|
17
|
+
'react-native-nitro-modal is only implemented on iOS, Android and web.'
|
|
15
18
|
);
|
|
16
19
|
}
|
|
17
20
|
return null;
|
|
18
21
|
}
|
|
19
22
|
|
|
23
|
+
export const callback = ((func: unknown) => func) as typeof nitroCallback;
|
|
24
|
+
|
|
20
25
|
export const NitroModalView =
|
|
21
26
|
UnsupportedNitroModalView as unknown as ReactNativeView<
|
|
22
27
|
NitroModalProps,
|