react-native-nitro-modal 0.1.5 → 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 +17 -7
- 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
package/README.md
CHANGED
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
[](https://www.npmjs.com/package/react-native-nitro-modal)
|
|
8
8
|
[](https://www.npmjs.com/package/react-native-nitro-modal)
|
|
9
9
|
[](LICENSE)
|
|
10
|
-

|
|
10
|
+

|
|
11
11
|
|
|
12
12
|
</div>
|
|
13
13
|
|
|
14
14
|
---
|
|
15
15
|
|
|
16
|
-
`react-native-nitro-modal` renders your React content inside native modal presentations — an edge-attached UIKit sheet on iOS and Material `BottomSheetBehavior` on Android — so gestures, detent snapping, keyboard handling and transitions are handled natively, not re-implemented in JavaScript.
|
|
16
|
+
`react-native-nitro-modal` renders your React content inside native modal presentations — an edge-attached UIKit sheet on iOS and Material `BottomSheetBehavior` on Android — so gestures, detent snapping, keyboard handling and transitions are handled natively, not re-implemented in JavaScript. On the web (React Native Web), the same API renders a DOM sheet and popup with matching behavior.
|
|
17
17
|
|
|
18
18
|
## Features
|
|
19
19
|
|
|
@@ -35,9 +35,10 @@
|
|
|
35
35
|
| `react-native-nitro-modules` | `^0.37.1` |
|
|
36
36
|
| iOS | 15.0+ (16.0+ for `small` and `fitContent`) |
|
|
37
37
|
| Android | API 24 (Android 7.0)+ |
|
|
38
|
+
| Web | via `react-native-web` (tested with 0.21) |
|
|
38
39
|
|
|
39
40
|
> [!NOTE]
|
|
40
|
-
>
|
|
41
|
+
> Other platforms (e.g. macOS, Windows) are not supported. There the component renders nothing and logs a one-time warning.
|
|
41
42
|
|
|
42
43
|
## Installation
|
|
43
44
|
|
|
@@ -171,10 +172,10 @@ const sheet = useRef<NitroModalRef>(null);
|
|
|
171
172
|
| `initialDetentIndex` | `number` | `0` | Index into `detents` the sheet opens at. |
|
|
172
173
|
| `backdropColor` | `ColorValue` | `'black'` | Backdrop color. |
|
|
173
174
|
| `backdropOpacity` | `number` | `0.4` | Backdrop opacity, `0`–`1`. |
|
|
174
|
-
| `backdropBlur` | `number` | `0` | Blur radius (dp/pt) behind the modal. `0` disables it. See [platform notes](#platform-notes).
|
|
175
|
+
| `backdropBlur` | `number` | `0` | Blur radius (dp/pt/px) behind the modal. `0` disables it. See [platform notes](#platform-notes). |
|
|
175
176
|
| `dismissOnBackdropPress` | `boolean` | `true` | Tapping the backdrop closes the modal. |
|
|
176
177
|
| `dismissOnSwipe` | `boolean` | `true` | Swiping down closes a bottom sheet. |
|
|
177
|
-
| `dismissOnBackButton` | `boolean` | `true` | The Android back button/gesture closes the modal.
|
|
178
|
+
| `dismissOnBackButton` | `boolean` | `true` | The Android back button/gesture (Escape on web) closes the modal. |
|
|
178
179
|
| `showGrabber` | `boolean` | `false` | Shows the drag handle on a bottom sheet. |
|
|
179
180
|
| `cornerRadius` | `number` | platform default | Corner radius of the sheet/card. |
|
|
180
181
|
| `backgroundColor` | `ColorValue` | system surface | Background of the sheet/card. |
|
|
@@ -192,7 +193,7 @@ const sheet = useRef<NitroModalRef>(null);
|
|
|
192
193
|
| `onDismiss` | `(reason: DismissReason) => void` | The modal is fully gone. Fires exactly once per presentation. |
|
|
193
194
|
| `onDetentChange` | `(index: number) => void` | A bottom sheet settled on a different detent. |
|
|
194
195
|
| `onBackdropPress` | `() => void` | The backdrop was tapped (fires even when `dismissOnBackdropPress` is `false`). |
|
|
195
|
-
| `onBackButtonPress` | `() => void` | The Android hardware/gesture back was pressed.
|
|
196
|
+
| `onBackButtonPress` | `() => void` | The Android hardware/gesture back (Escape on web) was pressed. |
|
|
196
197
|
|
|
197
198
|
### `NitroModalRef`
|
|
198
199
|
|
|
@@ -253,6 +254,15 @@ import type {
|
|
|
253
254
|
- Predictive back (Android 14+, when the app opts in or targets SDK 36) previews the exit while the gesture runs: the sheet uses Material's bottom-sheet animation and the popup scales down.
|
|
254
255
|
- Transitions are interruptible: closing during the enter animation turns it around, and reopening during the exit animation brings the same modal back (no extra `onDismiss`/`onPresent`). Once the exit starts, taps and back presses reach the screen below, as with a native dialog.
|
|
255
256
|
|
|
257
|
+
**Web**
|
|
258
|
+
|
|
259
|
+
- Renders through React Native Web's `Modal`, so it stacks with your other modals, traps focus while open and returns it on close. Nothing is rendered in place.
|
|
260
|
+
- Bottom sheets can be dragged with touch or mouse, with the same detent snapping, fling-to-dismiss and hand-off to scrollable content as on iOS. A touch that starts on content already scrolled down scrolls it natively instead of moving the sheet.
|
|
261
|
+
- The Escape key acts as the back button: it fires `onBackButtonPress` and, unless `dismissOnBackButton` is `false`, dismisses the topmost modal with reason `'backButton'`. The browser's history back is not intercepted.
|
|
262
|
+
- `backdropBlur` uses CSS `backdrop-filter`. Without `backgroundColor`, the sheet/card uses the CSS `Canvas` system color, which follows your page's `color-scheme`.
|
|
263
|
+
- `keyboardBehavior` follows the on-screen keyboard through the `visualViewport` API (mobile browsers). Safe-area insets are respected when the page uses `viewport-fit=cover`.
|
|
264
|
+
- Sheets are at most 640px wide and centered. Animations are skipped when the user prefers reduced motion.
|
|
265
|
+
|
|
256
266
|
**Colors**
|
|
257
267
|
|
|
258
268
|
- `backdropColor` and `backgroundColor` accept any color string or number supported by `processColor`. `PlatformColor` and `DynamicColorIOS` values are not supported yet.
|
|
@@ -263,7 +273,7 @@ The repository includes an example app that covers content-sized sheets, multi-d
|
|
|
263
273
|
|
|
264
274
|
```sh
|
|
265
275
|
yarn
|
|
266
|
-
yarn example ios # or: yarn example android
|
|
276
|
+
yarn example ios # or: yarn example android / yarn example web
|
|
267
277
|
```
|
|
268
278
|
|
|
269
279
|
## Contributing
|
package/lib/module/NitroModal.js
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
4
4
|
import { processColor, StyleSheet, useWindowDimensions, View } from 'react-native';
|
|
5
|
-
import { callback } from '
|
|
6
|
-
import { NitroModalView } from './NitroModalView';
|
|
5
|
+
import { callback, NitroModalView } from './NitroModalView';
|
|
7
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
7
|
const DEFAULT_DETENTS = ['fitContent'];
|
|
9
8
|
const BLACK = 0xff000000;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useImperativeHandle","useLayoutEffect","useMemo","useRef","useState","processColor","StyleSheet","useWindowDimensions","View","callback","NitroModalView","jsx","_jsx","DEFAULT_DETENTS","BLACK","toNativeColor","color","undefined","processed","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","isControlled","internalOpen","setInternalOpen","open","sessionActive","setSessionActive","prevOpen","setPrevOpen","renderContent","area","setArea","hybridRef","latest","current","nativeCallbacks","instance","reason","index","onContentAreaChange","next","width","height","present","console","warn","dismiss","snapToDetent","detentsKey","join","nativeDetents","Set","split","windowSize","contentArea","containerStyle","maxWidth","maxHeight","includes","style","styles","host","backdropBlurRadius","grabberVisible","contentBackgroundColor","collapsable","container","create","position","left","top"],"sourceRoot":"../../src","sources":["NitroModal.tsx"],"mappings":";;AAAA,SACEA,mBAAmB,EACnBC,eAAe,EACfC,OAAO,EACPC,MAAM,EACNC,QAAQ,QAGH,OAAO;AACd,SACEC,YAAY,EACZC,UAAU,EACVC,mBAAmB,EACnBC,IAAI,QAIC,cAAc;
|
|
1
|
+
{"version":3,"names":["useImperativeHandle","useLayoutEffect","useMemo","useRef","useState","processColor","StyleSheet","useWindowDimensions","View","callback","NitroModalView","jsx","_jsx","DEFAULT_DETENTS","BLACK","toNativeColor","color","undefined","processed","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","isControlled","internalOpen","setInternalOpen","open","sessionActive","setSessionActive","prevOpen","setPrevOpen","renderContent","area","setArea","hybridRef","latest","current","nativeCallbacks","instance","reason","index","onContentAreaChange","next","width","height","present","console","warn","dismiss","snapToDetent","detentsKey","join","nativeDetents","Set","split","windowSize","contentArea","containerStyle","maxWidth","maxHeight","includes","style","styles","host","backdropBlurRadius","grabberVisible","contentBackgroundColor","collapsable","container","create","position","left","top"],"sourceRoot":"../../src","sources":["NitroModal.tsx"],"mappings":";;AAAA,SACEA,mBAAmB,EACnBC,eAAe,EACfC,OAAO,EACPC,MAAM,EACNC,QAAQ,QAGH,OAAO;AACd,SACEC,YAAY,EACZC,UAAU,EACVC,mBAAmB,EACnBC,IAAI,QAIC,cAAc;AAUrB,SAASC,QAAQ,EAAEC,cAAc,QAAQ,kBAAkB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AA0D5D,MAAMC,eAA8B,GAAG,CAAC,YAAY,C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IAAA,GAC3BwB,eAAe;IAAAjB,QAAA,EAElBW,aAAa,gBACZxC,IAAA,CAACJ,IAAI;MACHgF,WAAW,EAAE,KAAM;MACnB9C,MAAM,EAAEA,MAAO;MACfwC,KAAK,EAAE,CAACC,MAAM,CAACM,SAAS,EAAEX,cAAc,EAAE3C,qBAAqB,CAAE;MAAAM,QAAA,EAEhEA;IAAQ,CACL,CAAC,GACL;EAAI,CACM,CAAC;AAErB;AAEA,MAAM0C,MAAM,GAAG7E,UAAU,CAACoF,MAAM,CAAC;EAC/B;EACA;EACAN,IAAI,EAAE;IACJO,QAAQ,EAAE,UAAU;IACpBC,IAAI,EAAE,CAAC;IACPC,GAAG,EAAE,CAAC;IACN7B,KAAK,EAAE,CAAC;IACRC,MAAM,EAAE;EACV,CAAC;EACD;EACA;EACAwB,SAAS,EAAE;IACTE,QAAQ,EAAE,UAAU;IACpBC,IAAI,EAAE,CAAC;IACPC,GAAG,EAAE;EACP;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -3,15 +3,16 @@
|
|
|
3
3
|
let warned = false;
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Platforms without
|
|
7
|
-
*
|
|
6
|
+
* Platforms without an implementation render nothing. iOS and Android use
|
|
7
|
+
* `NitroModalView.native.tsx`, web uses `NitroModalView.web.tsx`.
|
|
8
8
|
*/
|
|
9
9
|
function UnsupportedNitroModalView() {
|
|
10
10
|
if (!warned) {
|
|
11
11
|
warned = true;
|
|
12
|
-
console.warn('react-native-nitro-modal is only implemented on iOS and
|
|
12
|
+
console.warn('react-native-nitro-modal is only implemented on iOS, Android and web.');
|
|
13
13
|
}
|
|
14
14
|
return null;
|
|
15
15
|
}
|
|
16
|
+
export const callback = func => func;
|
|
16
17
|
export const NitroModalView = UnsupportedNitroModalView;
|
|
17
18
|
//# sourceMappingURL=NitroModalView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["warned","UnsupportedNitroModalView","console","warn","NitroModalView"],"sourceRoot":"../../src","sources":["NitroModalView.tsx"],"mappings":";;
|
|
1
|
+
{"version":3,"names":["warned","UnsupportedNitroModalView","console","warn","callback","func","NitroModalView"],"sourceRoot":"../../src","sources":["NitroModalView.tsx"],"mappings":";;AAMA,IAAIA,MAAM,GAAG,KAAK;;AAElB;AACA;AACA;AACA;AACA,SAASC,yBAAyBA,CAAA,EAAG;EACnC,IAAI,CAACD,MAAM,EAAE;IACXA,MAAM,GAAG,IAAI;IACbE,OAAO,CAACC,IAAI,CACV,uEACF,CAAC;EACH;EACA,OAAO,IAAI;AACb;AAEA,OAAO,MAAMC,QAAQ,GAAKC,IAAa,IAAKA,IAA6B;AAEzE,OAAO,MAAMC,cAAc,GACzBL,yBAGC","ignoreList":[]}
|
|
@@ -4,5 +4,8 @@ import { getHostComponent } from 'react-native-nitro-modules';
|
|
|
4
4
|
// Resolved through the package's own `exports` so the path works from both
|
|
5
5
|
// `src/` and the compiled `lib/module/` output (a relative `../nitrogen` breaks there).
|
|
6
6
|
const NitroModalConfig = require('react-native-nitro-modal/nitrogen/generated/shared/json/NitroModalConfig.json');
|
|
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';
|
|
7
10
|
export const NitroModalView = getHostComponent('NitroModal', () => NitroModalConfig);
|
|
8
11
|
//# sourceMappingURL=NitroModalView.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getHostComponent","NitroModalConfig","require","NitroModalView"],"sourceRoot":"../../src","sources":["NitroModalView.native.tsx"],"mappings":";;AAAA,SAASA,gBAAgB,QAAQ,4BAA4B;AAC7D;AACA;AACA,MAAMC,gBAAgB,GAAGC,OAAO,CAAC,+EAA+E,CAAC;AAGjH,OAAO,MAAMC,cAAc,
|
|
1
|
+
{"version":3,"names":["getHostComponent","NitroModalConfig","require","callback","NitroModalView"],"sourceRoot":"../../src","sources":["NitroModalView.native.tsx"],"mappings":";;AAAA,SAASA,gBAAgB,QAAQ,4BAA4B;AAC7D;AACA;AACA,MAAMC,gBAAgB,GAAGC,OAAO,CAAC,+EAA+E,CAAC;AAGjH;AACA;AACA,SAASC,QAAQ,QAAQ,4BAA4B;AAErD,OAAO,MAAMC,cAAc,GAAGJ,gBAAgB,CAG5C,YAAY,EAAE,MAAMC,gBAAgB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/// <reference lib="dom" />
|
|
4
|
+
|
|
5
|
+
import { useLayoutEffect, useRef, useState } from 'react';
|
|
6
|
+
import { Modal } from 'react-native';
|
|
7
|
+
import { ModalController } from "./web/ModalController.js";
|
|
8
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
/** The web view takes plain functions; only native host components need them wrapped. */
|
|
10
|
+
export function callback(func) {
|
|
11
|
+
return func;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Web implementation of the hybrid view. The modal renders through React
|
|
16
|
+
* Native Web's `Modal` (a portal with focus trapping, Escape handling and
|
|
17
|
+
* stacking with other modals) and is laid out and animated by the presenters
|
|
18
|
+
* in `./web`. In place, it renders nothing.
|
|
19
|
+
*/
|
|
20
|
+
function WebNitroModalView(props) {
|
|
21
|
+
const {
|
|
22
|
+
hybridRef,
|
|
23
|
+
children
|
|
24
|
+
} = props;
|
|
25
|
+
const [mounted, setMounted] = useState(false);
|
|
26
|
+
const [controller] = useState(() => new ModalController(setMounted));
|
|
27
|
+
const overlay = useRef(null);
|
|
28
|
+
const backdrop = useRef(null);
|
|
29
|
+
const surface = useRef(null);
|
|
30
|
+
const content = useRef(null);
|
|
31
|
+
const grabber = useRef(null);
|
|
32
|
+
useLayoutEffect(() => {
|
|
33
|
+
controller.attach();
|
|
34
|
+
return () => controller.detach();
|
|
35
|
+
}, [controller]);
|
|
36
|
+
useLayoutEffect(() => {
|
|
37
|
+
hybridRef?.(controller.methods);
|
|
38
|
+
}, [controller, hybridRef]);
|
|
39
|
+
useLayoutEffect(() => {
|
|
40
|
+
controller.update(props);
|
|
41
|
+
});
|
|
42
|
+
useLayoutEffect(() => {
|
|
43
|
+
if (!mounted) return undefined;
|
|
44
|
+
controller.elementsDidMount({
|
|
45
|
+
overlay: overlay.current,
|
|
46
|
+
backdrop: backdrop.current,
|
|
47
|
+
surface: surface.current,
|
|
48
|
+
content: content.current,
|
|
49
|
+
grabber: grabber.current
|
|
50
|
+
});
|
|
51
|
+
return () => controller.elementsWillUnmount();
|
|
52
|
+
}, [controller, mounted]);
|
|
53
|
+
useLayoutEffect(() => {
|
|
54
|
+
if (mounted) {
|
|
55
|
+
controller.contentDidRender();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
if (!mounted) return null;
|
|
59
|
+
|
|
60
|
+
// Styles set here never change; the presenters write sizes, positions,
|
|
61
|
+
// colors and animated values straight to the elements.
|
|
62
|
+
return /*#__PURE__*/_jsx(Modal, {
|
|
63
|
+
visible: true,
|
|
64
|
+
transparent: true,
|
|
65
|
+
animationType: "none",
|
|
66
|
+
onRequestClose: controller.handleBackPress,
|
|
67
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
68
|
+
ref: overlay,
|
|
69
|
+
tabIndex: -1,
|
|
70
|
+
style: styles.overlay,
|
|
71
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
72
|
+
ref: backdrop,
|
|
73
|
+
"aria-hidden": true,
|
|
74
|
+
style: styles.backdrop
|
|
75
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
76
|
+
ref: surface,
|
|
77
|
+
style: styles.surface,
|
|
78
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
79
|
+
ref: content,
|
|
80
|
+
style: styles.content,
|
|
81
|
+
children: children
|
|
82
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
83
|
+
ref: grabber,
|
|
84
|
+
"aria-hidden": true,
|
|
85
|
+
style: styles.grabber
|
|
86
|
+
})]
|
|
87
|
+
})]
|
|
88
|
+
})
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
const styles = {
|
|
92
|
+
overlay: {
|
|
93
|
+
position: 'fixed',
|
|
94
|
+
inset: 0,
|
|
95
|
+
outline: 'none'
|
|
96
|
+
},
|
|
97
|
+
backdrop: {
|
|
98
|
+
position: 'absolute',
|
|
99
|
+
inset: 0,
|
|
100
|
+
touchAction: 'none'
|
|
101
|
+
},
|
|
102
|
+
surface: {
|
|
103
|
+
position: 'absolute',
|
|
104
|
+
left: 0,
|
|
105
|
+
top: 0,
|
|
106
|
+
boxSizing: 'border-box',
|
|
107
|
+
willChange: 'transform'
|
|
108
|
+
},
|
|
109
|
+
// Pinned at the origin like the native content view; the React content is
|
|
110
|
+
// positioned and sized inside it by `NitroModal`.
|
|
111
|
+
content: {
|
|
112
|
+
position: 'absolute',
|
|
113
|
+
left: 0,
|
|
114
|
+
top: 0
|
|
115
|
+
},
|
|
116
|
+
grabber: {
|
|
117
|
+
position: 'absolute',
|
|
118
|
+
top: 5,
|
|
119
|
+
left: '50%',
|
|
120
|
+
width: 36,
|
|
121
|
+
height: 5,
|
|
122
|
+
marginLeft: -18,
|
|
123
|
+
borderRadius: 2.5,
|
|
124
|
+
backgroundColor: 'rgba(127, 127, 127, 0.4)',
|
|
125
|
+
pointerEvents: 'none'
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
export const NitroModalView = WebNitroModalView;
|
|
129
|
+
//# sourceMappingURL=NitroModalView.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useLayoutEffect","useRef","useState","Modal","ModalController","jsx","_jsx","jsxs","_jsxs","callback","func","WebNitroModalView","props","hybridRef","children","mounted","setMounted","controller","overlay","backdrop","surface","content","grabber","attach","detach","methods","update","undefined","elementsDidMount","current","elementsWillUnmount","contentDidRender","visible","transparent","animationType","onRequestClose","handleBackPress","ref","tabIndex","style","styles","position","inset","outline","touchAction","left","top","boxSizing","willChange","width","height","marginLeft","borderRadius","backgroundColor","pointerEvents","NitroModalView"],"sourceRoot":"../../src","sources":["NitroModalView.web.tsx"],"mappings":";;AAAA;;AAEA,SACEA,eAAe,EACfC,MAAM,EACNC,QAAQ,QAGH,OAAO;AACd,SAASC,KAAK,QAAQ,cAAc;AAGpC,SAASC,eAAe,QAAQ,0BAAuB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAOxD;AACA,OAAO,SAASC,QAAQA,CAAIC,IAAO,EAAK;EACtC,OAAOA,IAAI;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,iBAAiBA,CAACC,KAA6B,EAAE;EACxD,MAAM;IAAEC,SAAS;IAAEC;EAAS,CAAC,GAAGF,KAAK;EACrC,MAAM,CAACG,OAAO,EAAEC,UAAU,CAAC,GAAGd,QAAQ,CAAC,KAAK,CAAC;EAC7C,MAAM,CAACe,UAAU,CAAC,GAAGf,QAAQ,CAAC,MAAM,IAAIE,eAAe,CAACY,UAAU,CAAC,CAAC;EACpE,MAAME,OAAO,GAAGjB,MAAM,CAAiB,IAAI,CAAC;EAC5C,MAAMkB,QAAQ,GAAGlB,MAAM,CAAiB,IAAI,CAAC;EAC7C,MAAMmB,OAAO,GAAGnB,MAAM,CAAiB,IAAI,CAAC;EAC5C,MAAMoB,OAAO,GAAGpB,MAAM,CAAiB,IAAI,CAAC;EAC5C,MAAMqB,OAAO,GAAGrB,MAAM,CAAiB,IAAI,CAAC;EAE5CD,eAAe,CAAC,MAAM;IACpBiB,UAAU,CAACM,MAAM,CAAC,CAAC;IACnB,OAAO,MAAMN,UAAU,CAACO,MAAM,CAAC,CAAC;EAClC,CAAC,EAAE,CAACP,UAAU,CAAC,CAAC;EAEhBjB,eAAe,CAAC,MAAM;IACpBa,SAAS,GAAGI,UAAU,CAACQ,OAA4B,CAAC;EACtD,CAAC,EAAE,CAACR,UAAU,EAAEJ,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KAAK,EAAEC,MAAM,CAACnB,OAAQ;UAAAP,QAAA,EACtCA;QAAQ,CACN,CAAC,eACNR,IAAA;UAAK+B,GAAG,EAAEf,OAAQ;UAAC,mBAAW;UAACiB,KAAK,EAAEC,MAAM,CAAClB;QAAQ,CAAE,CAAC;MAAA,CACrD,CAAC;IAAA,CACH;EAAC,CACD,CAAC;AAEZ;AAEA,MAAMkB,MAAM,GAAG;EACbtB,OAAO,EAAE;IACPuB,QAAQ,EAAE,OAAO;IACjBC,KAAK,EAAE,CAAC;IACRC,OAAO,EAAE;EACX,CAAC;EACDxB,QAAQ,EAAE;IACRsB,QAAQ,EAAE,UAAU;IACpBC,KAAK,EAAE,CAAC;IACRE,WAAW,EAAE;EACf,CAAC;EACDxB,OAAO,EAAE;IACPqB,QAAQ,EAAE,UAAU;IACpBI,IAAI,EAAE,CAAC;IACPC,GAAG,EAAE,CAAC;IACNC,SAAS,EAAE,YAAY;IACvBC,UAAU,EAAE;EACd,CAAC;EACD;EACA;EACA3B,OAAO,EAAE;IACPoB,QAAQ,EAAE,UAAU;IACpBI,IAAI,EAAE,CAAC;IACPC,GAAG,EAAE;EACP,CAAC;EACDxB,OAAO,EAAE;IACPmB,QAAQ,EAAE,UAAU;IACpBK,GAAG,EAAE,CAAC;IACND,IAAI,EAAE,KAAK;IACXI,KAAK,EAAE,EAAE;IACTC,MAAM,EAAE,CAAC;IACTC,UAAU,EAAE,CAAC,EAAE;IACfC,YAAY,EAAE,GAAG;IACjBC,eAAe,EAAE,0BAA0B;IAC3CC,aAAa,EAAE;EACjB;AACF,CAAyC;AAEzC,OAAO,MAAMC,cAAc,GAAG5C,iBAG7B","ignoreList":[]}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/// <reference lib="dom" />
|
|
4
|
+
|
|
5
|
+
/** How an `AnimatedValue` moves to its target. */
|
|
6
|
+
|
|
7
|
+
/** Jumps to the target at once. The completion still arrives on the next frame. */
|
|
8
|
+
export const INSTANT = {
|
|
9
|
+
type: 'timing',
|
|
10
|
+
duration: 0,
|
|
11
|
+
easing: t => t
|
|
12
|
+
};
|
|
13
|
+
/** Longest frame integrated at once, so a dropped frame can't throw the spring off. */
|
|
14
|
+
const MAX_FRAME_SECONDS = 0.064;
|
|
15
|
+
const SPRING_STEP_SECONDS = 0.004;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A number animated on `requestAnimationFrame` that reports every frame
|
|
19
|
+
* through `onChange`. A new animation starts from the current value and
|
|
20
|
+
* velocity, so transitions can be turned around mid-flight.
|
|
21
|
+
*/
|
|
22
|
+
export class AnimatedValue {
|
|
23
|
+
speed = 0;
|
|
24
|
+
run = null;
|
|
25
|
+
frame = null;
|
|
26
|
+
lastTime = 0;
|
|
27
|
+
|
|
28
|
+
/** `precision`: distance from the target at which a spring counts as settled. */
|
|
29
|
+
constructor(value, precision, onChange) {
|
|
30
|
+
this.precision = precision;
|
|
31
|
+
this.onChange = onChange;
|
|
32
|
+
this.current = value;
|
|
33
|
+
}
|
|
34
|
+
get value() {
|
|
35
|
+
return this.current;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Jumps to `value`, cancelling any animation. */
|
|
39
|
+
set(value) {
|
|
40
|
+
this.stop();
|
|
41
|
+
this.current = value;
|
|
42
|
+
this.speed = 0;
|
|
43
|
+
this.onChange(value);
|
|
44
|
+
}
|
|
45
|
+
stop() {
|
|
46
|
+
this.run = null;
|
|
47
|
+
if (this.frame != null) {
|
|
48
|
+
cancelAnimationFrame(this.frame);
|
|
49
|
+
this.frame = null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
animateTo(target, motion, options = {}) {
|
|
53
|
+
if (options.velocity !== undefined) {
|
|
54
|
+
this.speed = options.velocity;
|
|
55
|
+
}
|
|
56
|
+
const now = performance.now();
|
|
57
|
+
this.run = {
|
|
58
|
+
target,
|
|
59
|
+
motion,
|
|
60
|
+
options,
|
|
61
|
+
from: this.current,
|
|
62
|
+
startTime: now,
|
|
63
|
+
side: Math.sign(this.current - target)
|
|
64
|
+
};
|
|
65
|
+
if (motion.type === 'timing' && motion.duration <= 0) {
|
|
66
|
+
this.current = target;
|
|
67
|
+
this.speed = 0;
|
|
68
|
+
this.onChange(target);
|
|
69
|
+
}
|
|
70
|
+
if (this.frame == null) {
|
|
71
|
+
this.lastTime = now;
|
|
72
|
+
this.frame = requestAnimationFrame(this.step);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
step = time => {
|
|
76
|
+
this.frame = null;
|
|
77
|
+
const run = this.run;
|
|
78
|
+
if (!run) return;
|
|
79
|
+
const dt = Math.min(Math.max((time - this.lastTime) / 1000, 0), MAX_FRAME_SECONDS);
|
|
80
|
+
this.lastTime = time;
|
|
81
|
+
const done = run.motion.type === 'timing' ? this.stepTiming(run, run.motion, time, dt) : this.stepSpring(run, run.motion, dt);
|
|
82
|
+
if (done) {
|
|
83
|
+
this.current = run.target;
|
|
84
|
+
this.speed = 0;
|
|
85
|
+
this.run = null;
|
|
86
|
+
}
|
|
87
|
+
this.onChange(this.current);
|
|
88
|
+
if (done) {
|
|
89
|
+
run.options.onEnd?.();
|
|
90
|
+
} else {
|
|
91
|
+
this.frame = requestAnimationFrame(this.step);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
stepTiming(run, motion, time, dt) {
|
|
95
|
+
const progress = motion.duration > 0 ? Math.min(Math.max((time - run.startTime) / motion.duration, 0), 1) : 1;
|
|
96
|
+
const next = run.from + (run.target - run.from) * motion.easing(progress);
|
|
97
|
+
if (dt > 0) {
|
|
98
|
+
this.speed = (next - this.current) / dt;
|
|
99
|
+
}
|
|
100
|
+
this.current = next;
|
|
101
|
+
return progress >= 1;
|
|
102
|
+
}
|
|
103
|
+
stepSpring(run, motion, dt) {
|
|
104
|
+
const omega = 2 * Math.PI / motion.response;
|
|
105
|
+
const stiffness = omega * omega;
|
|
106
|
+
const damping = 2 * motion.dampingRatio * omega;
|
|
107
|
+
let offset = this.current - run.target;
|
|
108
|
+
let velocity = this.speed;
|
|
109
|
+
const steps = Math.ceil(dt / SPRING_STEP_SECONDS);
|
|
110
|
+
for (let i = 0; i < steps; i++) {
|
|
111
|
+
const h = dt / steps;
|
|
112
|
+
velocity += (-stiffness * offset - damping * velocity) * h;
|
|
113
|
+
offset += velocity * h;
|
|
114
|
+
}
|
|
115
|
+
this.current = run.target + offset;
|
|
116
|
+
this.speed = velocity;
|
|
117
|
+
if (run.options.stopAtTarget && (run.side === 0 || Math.sign(offset) !== run.side)) {
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
return Math.abs(offset) < this.precision && Math.abs(velocity) < this.precision * 20;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=AnimatedValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["INSTANT","type","duration","easing","t","MAX_FRAME_SECONDS","SPRING_STEP_SECONDS","AnimatedValue","speed","run","frame","lastTime","constructor","value","precision","onChange","current","set","stop","cancelAnimationFrame","animateTo","target","motion","options","velocity","undefined","now","performance","from","startTime","side","Math","sign","requestAnimationFrame","step","time","dt","min","max","done","stepTiming","stepSpring","onEnd","progress","next","omega","PI","response","stiffness","damping","dampingRatio","offset","steps","ceil","i","h","stopAtTarget","abs"],"sourceRoot":"../../../src","sources":["web/AnimatedValue.ts"],"mappings":";;AAAA;;AAEA;;AAgBA;AACA,OAAO,MAAMA,OAAe,GAAG;EAC7BC,IAAI,EAAE,QAAQ;EACdC,QAAQ,EAAE,CAAC;EACXC,MAAM,EAAGC,CAAC,IAAKA;AACjB,CAAC;AAqBD;AACA,MAAMC,iBAAiB,GAAG,KAAK;AAC/B,MAAMC,mBAAmB,GAAG,KAAK;;AAEjC;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,aAAa,CAAC;EAEjBC,KAAK,GAAG,CAAC;EACTC,GAAG,GAAe,IAAI;EACtBC,KAAK,GAAkB,IAA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,CAAC,GAAGF,KAAK,EAAEE,CAAC,EAAE,EAAE;MAC9B,MAAMC,CAAC,GAAGnB,EAAE,GAAGgB,KAAK;MACpB5B,QAAQ,IAAI,CAAC,CAACwB,SAAS,GAAGG,MAAM,GAAGF,OAAO,GAAGzB,QAAQ,IAAI+B,CAAC;MAC1DJ,MAAM,IAAI3B,QAAQ,GAAG+B,CAAC;IACxB;IACA,IAAI,CAACvC,OAAO,GAAGP,GAAG,CAACY,MAAM,GAAG8B,MAAM;IAClC,IAAI,CAAC3C,KAAK,GAAGgB,QAAQ;IAErB,IACEf,GAAG,CAACc,OAAO,CAACiC,YAAY,KACvB/C,GAAG,CAACqB,IAAI,KAAK,CAAC,IAAIC,IAAI,CAACC,IAAI,CAACmB,MAAM,CAAC,KAAK1C,GAAG,CAACqB,IAAI,CAAC,EAClD;MACA,OAAO,IAAI;IACb;IACA,OACEC,IAAI,CAAC0B,GAAG,CAACN,MAAM,CAAC,GAAG,IAAI,CAACrC,SAAS,IACjCiB,IAAI,CAAC0B,GAAG,CAACjC,QAAQ,CAAC,GAAG,IAAI,CAACV,SAAS,GAAG,EAAE;EAE5C;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/** Snapshot of the props that shape a presentation. */
|
|
4
|
+
|
|
5
|
+
export function makeConfig(props) {
|
|
6
|
+
return {
|
|
7
|
+
mode: props.mode,
|
|
8
|
+
detents: props.detents,
|
|
9
|
+
initialDetentIndex: Number.isFinite(props.initialDetentIndex) ? Math.trunc(props.initialDetentIndex) : 0,
|
|
10
|
+
backdropColor: props.backdropColor,
|
|
11
|
+
backdropOpacity: props.backdropOpacity,
|
|
12
|
+
backdropBlurRadius: props.backdropBlurRadius,
|
|
13
|
+
dismissOnBackdropPress: props.dismissOnBackdropPress,
|
|
14
|
+
dismissOnSwipe: props.dismissOnSwipe,
|
|
15
|
+
dismissOnBackButton: props.dismissOnBackButton,
|
|
16
|
+
grabberVisible: props.grabberVisible,
|
|
17
|
+
cornerRadius: props.cornerRadius >= 0 ? props.cornerRadius : null,
|
|
18
|
+
contentBackgroundColor: props.contentBackgroundColor ?? null,
|
|
19
|
+
keyboardBehavior: props.keyboardBehavior,
|
|
20
|
+
popupAnimation: props.popupAnimation
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function isSameConfig(a, b) {
|
|
24
|
+
return Object.keys(a).every(key => key === 'detents' ? a.detents.join() === b.detents.join() : a[key] === b[key]);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=ModalConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["makeConfig","props","mode","detents","initialDetentIndex","Number","isFinite","Math","trunc","backdropColor","backdropOpacity","backdropBlurRadius","dismissOnBackdropPress","dismissOnSwipe","dismissOnBackButton","grabberVisible","cornerRadius","contentBackgroundColor","keyboardBehavior","popupAnimation","isSameConfig","a","b","Object","keys","every","key","join"],"sourceRoot":"../../../src","sources":["web/ModalConfig.ts"],"mappings":";;AAQA;;AAqBA,OAAO,SAASA,UAAUA,CAACC,KAAsB,EAAe;EAC9D,OAAO;IACLC,IAAI,EAAED,KAAK,CAACC,IAAI;IAChBC,OAAO,EAAEF,KAAK,CAACE,OAAO;IACtBC,kBAAkB,EAAEC,MAAM,CAACC,QAAQ,CAACL,KAAK,CAACG,kBAAkB,CAAC,GACzDG,IAAI,CAACC,KAAK,CAACP,KAAK,CAACG,kBAAkB,CAAC,GACpC,CAAC;IACLK,aAAa,EAAER,KAAK,CAACQ,aAAa;IAClCC,eAAe,EAAET,KAAK,CAACS,eAAe;IACtCC,kBAAkB,EAAEV,KAAK,CAACU,kBAAkB;IAC5CC,sBAAsB,EAAEX,KAAK,CAACW,sBAAsB;IACpDC,cAAc,EAAEZ,KAAK,CAACY,cAAc;IACpCC,mBAAmB,EAAEb,KAAK,CAACa,mBAAmB;IAC9CC,cAAc,EAAEd,KAAK,CAACc,cAAc;IACpCC,YAAY,EAAEf,KAAK,CAACe,YAAY,IAAI,CAAC,GAAGf,KAAK,CAACe,YAAY,GAAG,IAAI;IACjEC,sBAAsB,EAAEhB,KAAK,CAACgB,sBAAsB,IAAI,IAAI;IAC5DC,gBAAgB,EAAEjB,KAAK,CAACiB,gBAAgB;IACxCC,cAAc,EAAElB,KAAK,CAACkB;EACxB,CAAC;AACH;AAEA,OAAO,SAASC,YAAYA,CAACC,CAAc,EAAEC,CAAc,EAAW;EACpE,OAAQC,MAAM,CAACC,IAAI,CAACH,CAAC,CAAC,CAA2BI,KAAK,CAAEC,GAAG,IACzDA,GAAG,KAAK,SAAS,GACbL,CAAC,CAAClB,OAAO,CAACwB,IAAI,CAAC,CAAC,KAAKL,CAAC,CAACnB,OAAO,CAACwB,IAAI,CAAC,CAAC,GACrCN,CAAC,CAACK,GAAG,CAAC,KAAKJ,CAAC,CAACI,GAAG,CACtB,CAAC;AACH","ignoreList":[]}
|